@arcgis/core 5.1.0-next.74 → 5.1.0-next.75
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/arcade/ArcadePortal.js +1 -1
- package/arcade/functions/aiServices.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/portalUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +2 -0
- package/assets/esri/core/workers/chunks/09630888267cde87654f.js +1 -0
- package/assets/esri/core/workers/chunks/0fa207c68dfd7ddee160.js +1 -0
- package/assets/esri/core/workers/chunks/146424b5717d0a645ee1.js +1 -0
- package/assets/esri/core/workers/chunks/{d00dafad202450e6ee2e.js → 14eb2cc8e2ad6d8d03fd.js} +1 -1
- package/assets/esri/core/workers/chunks/1765dfeac20e34ce25b7.js +1 -0
- package/assets/esri/core/workers/chunks/176dd195f77b98cb0b0f.js +1 -0
- package/assets/esri/core/workers/chunks/1906416c84bab369bbd6.js +1 -0
- package/assets/esri/core/workers/chunks/{b98c24229463029504e8.js → 1f6b7626f333809837ef.js} +1 -1
- package/assets/esri/core/workers/chunks/1ff3c15a51c4dc991806.js +1 -0
- package/assets/esri/core/workers/chunks/2a2e97918524e0f436d7.js +1 -0
- package/assets/esri/core/workers/chunks/2b0b398180ed98c2c84c.js +1 -0
- package/assets/esri/core/workers/chunks/{bab23b905678e42815e5.js → 312036c89a6a09bb06c2.js} +1 -1
- package/assets/esri/core/workers/chunks/{37091cf498a16ccad7ff.js → 330b47ac0759c3c35cc5.js} +1 -1
- package/assets/esri/core/workers/chunks/34b6b5dd415c68f0b0d1.js +1 -0
- package/assets/esri/core/workers/chunks/{a270960d80d8344dd75f.js → 34ea3ed78041437a8fc8.js} +1 -1
- package/assets/esri/core/workers/chunks/384c235d36f32769e32b.js +1 -0
- package/assets/esri/core/workers/chunks/3a183259805638c25363.js +1 -0
- package/assets/esri/core/workers/chunks/{deaca3cd202851ecf9c2.js → 3cce9dad8ee0e4971d50.js} +1 -1
- package/assets/esri/core/workers/chunks/3efbb684c0409955186d.js +1 -0
- package/assets/esri/core/workers/chunks/40d251b6b42a41d68bd2.js +1 -0
- package/assets/esri/core/workers/chunks/42336e0d1ef88737b078.js +1 -0
- package/assets/esri/core/workers/chunks/47b3a5213539548ff3a6.js +1 -0
- package/assets/esri/core/workers/chunks/4a23b27bfbcfa08fd9a7.js +1 -0
- package/assets/esri/core/workers/chunks/52b3a11c962810bc6dbe.js +1 -0
- package/assets/esri/core/workers/chunks/53750e85f3128993a43a.js +1 -0
- package/assets/esri/core/workers/chunks/{4bbe684050b3b04681d0.js → 537fe2522dff1e6ce03b.js} +1 -1
- package/assets/esri/core/workers/chunks/55fd201ca5e10c6e4761.js +1 -0
- package/assets/esri/core/workers/chunks/56941e8bbd2d49bf2656.js +1 -0
- package/assets/esri/core/workers/chunks/5d8e944b192aad4cf986.js +1 -0
- package/assets/esri/core/workers/chunks/{5476c2f7b83f4ccd0335.js → 5e1b847b116d21908a54.js} +1 -1
- package/assets/esri/core/workers/chunks/5ed8d8b5336c81fbcda3.js +1 -0
- package/assets/esri/core/workers/chunks/60915a3708a34da1977e.js +1 -0
- package/assets/esri/core/workers/chunks/61c523dd9d8027922465.js +1 -0
- package/assets/esri/core/workers/chunks/65c61171e6c6be5c5c2f.js +1 -0
- package/assets/esri/core/workers/chunks/6a3d207308b29651f397.js +1 -0
- package/assets/esri/core/workers/chunks/6c35583707f5c339ee99.js +1 -0
- package/assets/esri/core/workers/chunks/702e8468836863abd81b.js +1 -0
- package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +1 -0
- package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +1 -0
- package/assets/esri/core/workers/chunks/7b6c8be59ed87e386aa4.js +1 -0
- package/assets/esri/core/workers/chunks/7c820c5f6f05480d5050.js +1 -0
- package/assets/esri/core/workers/chunks/80f4f686ce403cb2693f.js +1 -0
- package/assets/esri/core/workers/chunks/852f4cd514008fee5a55.js +1 -0
- package/assets/esri/core/workers/chunks/8a3bff0f58483c1665f9.js +1 -0
- package/assets/esri/core/workers/chunks/8b046e28f879079caada.js +1 -0
- package/assets/esri/core/workers/chunks/8d738e9acc2f222235ea.js +1 -0
- package/assets/esri/core/workers/chunks/9103eb0b9078019d3a26.js +1 -0
- package/assets/esri/core/workers/chunks/915e2711d3a2cfa402b2.js +1 -0
- package/assets/esri/core/workers/chunks/91f9e0e3662d4bf9f163.js +1 -0
- package/assets/esri/core/workers/chunks/99c161fecae710b53b40.js +1 -0
- package/assets/esri/core/workers/chunks/99d298d0039c536fcf3e.js +1 -0
- package/assets/esri/core/workers/chunks/9a5ef33d99a8f89956ff.js +1 -0
- package/assets/esri/core/workers/chunks/9d10db72e342fe63c981.js +1 -0
- package/assets/esri/core/workers/chunks/{a36761e3122f70fbb3c9.js → 9d6491f996eeb0c646ed.js} +1 -1
- package/assets/esri/core/workers/chunks/a015c2f54eb91e43a1f4.js +1 -0
- package/assets/esri/core/workers/chunks/a242ec19a7508de436da.js +1 -0
- package/assets/esri/core/workers/chunks/a320998f18922a35899f.js +1 -0
- package/assets/esri/core/workers/chunks/a7f9f478bd1493fc3c76.js +1 -0
- package/assets/esri/core/workers/chunks/aac6a57edd7494125204.js +1 -0
- package/assets/esri/core/workers/chunks/b73c146d3e550eaf07eb.js +1 -0
- package/assets/esri/core/workers/chunks/b7af0e6b9aadbcaf6a0b.js +1 -0
- package/assets/esri/core/workers/chunks/b803e7b0d489bb628d72.js +1 -0
- package/assets/esri/core/workers/chunks/baeb96aef03d4c566af7.js +1 -0
- package/assets/esri/core/workers/chunks/bc75ab48f4c7609ef09d.js +1 -0
- package/assets/esri/core/workers/chunks/bc78937986854e500b8e.js +1 -0
- package/assets/esri/core/workers/chunks/bd10d21545bca9a49de0.js +1 -0
- package/assets/esri/core/workers/chunks/{b905e637a67fbb7af4ae.js → bf8f603848bad4a7deb4.js} +1 -1
- package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +2 -0
- package/assets/esri/core/workers/chunks/c31ee5617c61a933cb0e.js +1 -0
- package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +1 -0
- package/assets/esri/core/workers/chunks/ce7ef7c4ca14d66d96f6.js +1 -0
- package/assets/esri/core/workers/chunks/{5b324e572737a308500d.js → cf14b3a44705dacefac4.js} +1 -1
- package/assets/esri/core/workers/chunks/d3b086eb9aa8c7d09048.js +1 -0
- package/assets/esri/core/workers/chunks/d55cef8199b8246fea3f.js +1 -0
- package/assets/esri/core/workers/chunks/d8decaee2c780e1b5e35.js +1 -0
- package/assets/esri/core/workers/chunks/{41809c16544ec25120fa.js → d95ffd990b3a7df69e1e.js} +1 -1
- package/assets/esri/core/workers/chunks/dc54d4a9fe1691862356.js +1 -0
- package/assets/esri/core/workers/chunks/dda2cb5c073d1e65f14f.js +1 -0
- package/assets/esri/core/workers/chunks/e18badd11f360cc2912b.js +1 -0
- package/assets/esri/core/workers/chunks/{ad064583f8a836005098.js → e262c4864dc06c43b380.js} +1 -1
- package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +1 -0
- package/assets/esri/core/workers/chunks/e9c5c295b6bf10e942a4.js +1 -0
- package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +1 -0
- package/assets/esri/core/workers/chunks/{873c1b705ac3d4e6c384.js → ea97619a4470f1540b99.js} +1 -1
- package/assets/esri/core/workers/chunks/eaab5ac049622986e3bc.js +1 -0
- package/assets/esri/core/workers/chunks/edee616b6f1b5be8fd39.js +1 -0
- package/assets/esri/core/workers/chunks/ef0085aa743b33cb549f.js +1 -0
- package/assets/esri/core/workers/chunks/f0250cecb243b32cdba7.js +1 -0
- package/assets/esri/core/workers/chunks/f518835b2dc89a48cfb1.js +1 -0
- package/assets/esri/core/workers/chunks/f6c8e93ca2987e83f925.js +1 -0
- package/assets/esri/themes/base/widgets/_Sketch.scss +32 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/SpatialReference.js +1 -1
- package/chunks/aiServices.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/config.js +1 -1
- package/core/workers/registry.js +1 -1
- package/form/elements/AttachmentElement.d.ts +15 -16
- package/form/elements/GroupElement.d.ts +3 -2
- package/form/elements/inputs/attachments/AttachmentInput.d.ts +7 -9
- package/form/elements/inputs/attachments/AudioInput.d.ts +6 -8
- package/form/elements/inputs/attachments/DocumentInput.d.ts +5 -7
- package/form/elements/inputs/attachments/ImageInput.d.ts +6 -8
- package/form/elements/inputs/attachments/Input.d.ts +2 -6
- package/form/elements/inputs/attachments/SignatureInput.d.ts +5 -7
- package/form/elements/inputs/attachments/VideoInput.d.ts +6 -8
- package/form/elements/inputs/attachments/types.d.ts +3 -3
- package/geometry/FlatGeometry.js +1 -1
- package/geometry/operators/projectOperator.js +1 -1
- package/graphic/ImageryGraphicOrigin.js +1 -1
- package/graphic/ImageryTileGraphicOrigin.js +1 -1
- package/graphic/WCSGraphicOrigin.js +1 -1
- package/kernel.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/package.json +4 -4
- package/popup/Features.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/symbols/support/previewCIMSymbol.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/DimensionController.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/managers/MeasurementManager.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/snapping/SelfSnappingEngine.js +1 -1
- package/views/support/GeometryWorker.js +2 -0
- package/views/support/GeometryWorkerHandle.js +2 -0
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -3
- package/widgets/FeatureTable/Grid/GridViewModel.d.ts +2 -11
- package/widgets/FeatureTable/support/types.d.ts +2 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +28 -0
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer.d.ts +27 -0
- package/widgets/Sketch/SketchViewModel.d.ts +10 -2
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/MeasuredContentGroup.js +1 -1
- package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/00bae4b7e179336e0362.js +0 -1
- package/assets/esri/core/workers/chunks/041c372e98a6fba90b36.js +0 -1
- package/assets/esri/core/workers/chunks/0783890816bac45277b9.js +0 -1
- package/assets/esri/core/workers/chunks/07aac6245a0d1adbb2d4.js +0 -1
- package/assets/esri/core/workers/chunks/1286f41f245ef22b3a26.js +0 -1
- package/assets/esri/core/workers/chunks/12e575a6d2b008b8fc2b.js +0 -1
- package/assets/esri/core/workers/chunks/161d60fdac2013c15543.js +0 -1
- package/assets/esri/core/workers/chunks/168de44a789d1cecc1f8.js +0 -1
- package/assets/esri/core/workers/chunks/1d9d7915cf7449e5d468.js +0 -1
- package/assets/esri/core/workers/chunks/1db1656a033f3992f0d6.js +0 -1
- package/assets/esri/core/workers/chunks/235cb82952a18ff8d206.js +0 -1
- package/assets/esri/core/workers/chunks/27b80c386cebadcaca3c.js +0 -1
- package/assets/esri/core/workers/chunks/29d3890a5a43d934067a.js +0 -1
- package/assets/esri/core/workers/chunks/2f17438d215bea3ce70f.js +0 -1
- package/assets/esri/core/workers/chunks/356cb86606b8c674f947.js +0 -1
- package/assets/esri/core/workers/chunks/398e0dd2bc7e1ab84831.js +0 -1
- package/assets/esri/core/workers/chunks/3b1052aa30af3f6186cc.js +0 -1
- package/assets/esri/core/workers/chunks/3e87e3ad857d72f6ecbb.js +0 -1
- package/assets/esri/core/workers/chunks/42e483fde18f12da32a6.js +0 -1
- package/assets/esri/core/workers/chunks/43ab44d37bc0ea97ef98.js +0 -1
- package/assets/esri/core/workers/chunks/488ed9584b527ec47be3.js +0 -1
- package/assets/esri/core/workers/chunks/4ad32580e0c0699fde1f.js +0 -1
- package/assets/esri/core/workers/chunks/4c13869d260a902d3014.js +0 -1
- package/assets/esri/core/workers/chunks/54ed37ec9682ea739deb.js +0 -1
- package/assets/esri/core/workers/chunks/5511e640e171c294f52a.js +0 -2
- package/assets/esri/core/workers/chunks/55369c5bd65bcaf78da1.js +0 -1
- package/assets/esri/core/workers/chunks/56fd3da911c2c4511e5d.js +0 -1
- package/assets/esri/core/workers/chunks/59592bb25f226865e88a.js +0 -1
- package/assets/esri/core/workers/chunks/5d55b4449bcb24cd72b6.js +0 -1
- package/assets/esri/core/workers/chunks/5d8fe41a3c06ddb4094b.js +0 -1
- package/assets/esri/core/workers/chunks/608d707fd9d9f9088473.js +0 -1
- package/assets/esri/core/workers/chunks/6a21c9a4aeebe806ea39.js +0 -1
- package/assets/esri/core/workers/chunks/6c7ff968bd4fc816442d.js +0 -1
- package/assets/esri/core/workers/chunks/6d11ec355e5474b2968b.js +0 -1
- package/assets/esri/core/workers/chunks/6d25230dd85a4ba54c4f.js +0 -1
- package/assets/esri/core/workers/chunks/7027d93dc5a4595d70c6.js +0 -1
- package/assets/esri/core/workers/chunks/70b35b2446558d5280e3.js +0 -1
- package/assets/esri/core/workers/chunks/7349cb45a93e6916f115.js +0 -1
- package/assets/esri/core/workers/chunks/76edaeaf8fe344bb77a8.js +0 -1
- package/assets/esri/core/workers/chunks/76fe5b821d6b54db5721.js +0 -1
- package/assets/esri/core/workers/chunks/7951d93f5f15aa76f49c.js +0 -1
- package/assets/esri/core/workers/chunks/7a56c836c89a8b978800.js +0 -1
- package/assets/esri/core/workers/chunks/81d30c9062ad0120a863.js +0 -1
- package/assets/esri/core/workers/chunks/88c5f7c712c6b89b5109.js +0 -1
- package/assets/esri/core/workers/chunks/88e469b82d2594f23649.js +0 -1
- package/assets/esri/core/workers/chunks/8a8242e7cc7e6a9e7876.js +0 -1
- package/assets/esri/core/workers/chunks/9444ed8ea117861ae89b.js +0 -1
- package/assets/esri/core/workers/chunks/9a38fd68b02b617c45d3.js +0 -1
- package/assets/esri/core/workers/chunks/9be9ccce6369f67202bc.js +0 -1
- package/assets/esri/core/workers/chunks/a37c28e3c4a2be9fd1d5.js +0 -1
- package/assets/esri/core/workers/chunks/a8d7f59927bdad564141.js +0 -1
- package/assets/esri/core/workers/chunks/a94bd20551c1179c7ec5.js +0 -1
- package/assets/esri/core/workers/chunks/a9d2c83bb10b5ade0ca0.js +0 -1
- package/assets/esri/core/workers/chunks/abe22ae8ee0dcc9efbb7.js +0 -1
- package/assets/esri/core/workers/chunks/b702279c48f3009f6dd8.js +0 -1
- package/assets/esri/core/workers/chunks/bc887bd62579dba81e2b.js +0 -1
- package/assets/esri/core/workers/chunks/be0341567bb19e101a4f.js +0 -1
- package/assets/esri/core/workers/chunks/be1d6a571f76933dfbb0.js +0 -1
- package/assets/esri/core/workers/chunks/bfcdc5c315131aae34d8.js +0 -1
- package/assets/esri/core/workers/chunks/c0f624a2ca0d07ef8f8c.js +0 -1
- package/assets/esri/core/workers/chunks/c327fe276238af60fda4.js +0 -1
- package/assets/esri/core/workers/chunks/c5f155fe114a2a05aaf2.js +0 -2
- package/assets/esri/core/workers/chunks/c61002a117dc2218d6af.js +0 -1
- package/assets/esri/core/workers/chunks/c804a66ef7615aa8de89.js +0 -1
- package/assets/esri/core/workers/chunks/cb5e4b9b4a59c2622eb5.js +0 -1
- package/assets/esri/core/workers/chunks/d201a5dff18a5bb467ab.js +0 -1
- package/assets/esri/core/workers/chunks/d21fdd67477800101f3b.js +0 -1
- package/assets/esri/core/workers/chunks/db588bf3256e95c977b7.js +0 -1
- package/assets/esri/core/workers/chunks/dfdd474fddcd1d6091ce.js +0 -1
- package/assets/esri/core/workers/chunks/e235ea4293d5d463acfb.js +0 -1
- package/assets/esri/core/workers/chunks/e43486113aaf72ac4dc1.js +0 -1
- package/assets/esri/core/workers/chunks/ea4c3393c5757e309a71.js +0 -1
- package/assets/esri/core/workers/chunks/ed216ddeb7f59f510bd0.js +0 -1
- package/assets/esri/core/workers/chunks/ef8886dff54063928bcb.js +0 -1
- package/assets/esri/core/workers/chunks/f43a63094190d2074cd0.js +0 -1
- package/assets/esri/core/workers/chunks/f5223ffb3be548c9b0a1.js +0 -1
- package/views/support/MeasurementWorker.js +0 -2
- package/views/support/MeasurementWorkerHandle.js +0 -2
- /package/assets/esri/core/workers/chunks/{5511e640e171c294f52a.js.LICENSE.txt → 07aca5ecad659d55e795.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{c5f155fe114a2a05aaf2.js.LICENSE.txt → bfe575da727ce7c8d331.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4383,5756],{31139(e,t,s){s.d(t,{O:()=>u,a:()=>g,c:()=>m});var n=s(61691),r=s(55537),i=s(95213),o=s(79187),a=s(88885),h=s(83661);function m(e,t,s,n,r){return l(e,t,null,s,n,r)}function l(e,t,s,n,a,h){const l=e.getGeometryType();if(l===r.G.enumPoint){const s=e.getXY();return t.contains(s)?e:e.createInstance()}if(l===r.G.enumEnvelope){const s=o.Envelope2D.constructEmpty();if(e.queryEnvelope(s),s.intersect(t)){const t=e.clone();return t.setEnvelope(s),t}return e.createInstance()}if(e.isEmpty())return e;if(t.isEmpty())return e.createInstance();const g=t.clone();{const t=new o.Envelope2D;if(e.queryLooseEnvelope(t),g.containsEnvelope(t))return e;if(!g.isIntersecting(t))return e.createInstance();0===a&&(t.intersect(g),t.inflate(Math.max(.1*t.maxDimension(),1)),t.intersect(g),g.assign(t))}let u=n;if((null!==s||Number.isNaN(u))&&(u=(0,i.c)(s,g,!1).total()),l===r.G.enumGeometryCollection){const t=e,s=e.createInstance();for(let e=0,n=t.getGeometryCount();e<n;e++){const n=t.getGeometry(e);if(n.isEmpty())continue;const r=m(n,g,u,a,h);r.isEmpty()||(r===n?s.addGeometry(r.clone()):s.addGeometry(r))}return s}(0,r.i)(l)||(0,r.a)("Clip: geometry not supported");const _=e.getImpl().getAccelerators();if(null!==_){const e=_.getRasterizedGeometry();(0,r.g)(null===e)}switch(l){case r.G.enumMultiPoint:{const t=e;let s;const n=t.getPointCount(),i=t.getImpl().getAttributeStreamRef(0);let o=0;for(let e=0;e<n;e++){const n=i.readPoint2D(2*e);g.contains(n)||(0===o&&(s=t.createInstance()),o<e&&s.addPoints(t,o,e),o=e+1)}return o>0&&s.addPoints(t,o,n),0===o?t:((0,r.g)(null!==s),s)}case r.G.enumPolygon:case r.G.enumPolyline:return function(e,t,s,n,r){return new c(t,r).clipMultiPath2(e,s,n)}(e,g,u,a,h);default:(0,r.d)("")}}function g(e,t,s,n,r,i){const a=new c(t,i),h=new o.Envelope2D;return e.queryLooseEnvelope(h),t.containsEnvelope(h)?e:t.isIntersecting(h)?a.clipPolesOut(e,r):e.createInstance()}class c{constructor(e,t){this.m_shape=new a.E,this.m_geometry=a.n,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new o.Envelope2D(e),this.m_progressTracker=t}progress_(){}clipMultiPath2(e,t,s){return e.getGeometryType()===r.G.enumPolygon?this.clipPolygonOrProjectedPolyline2(e,s):this.clipPolyline(e,t)}clipPolygonOrProjectedPolyline2(e,t){const s=e.getGeometryType()===r.G.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return e.createInstance();const n=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(n),this.m_geometry=s?this.m_shape.addGeometry(e):this.m_shape.addGeometry(e,this.m_extent);const i=o.Envelope2D.constructEmpty(),m=o.Envelope2D.constructEmpty(),l=new h.P,g=new h.P,u=(0,h.d)(9,Number.NaN),_=(0,h.d)(9,Number.NaN),p=(0,h.m)(h.P,9);let d=null;const f=new a.L,x=[];let P=!1;for(let e=0;!P&&e<4;e++){let t=!1;const o=!!(1&e);let h=0;switch(e){case 0:h=this.m_extent.xmin,t=n.xmin<=h&&n.xmax>=h;break;case 1:h=this.m_extent.ymin,t=n.ymin<=h&&n.ymax>=h;break;case 2:h=this.m_extent.xmax,t=n.xmin<=h&&n.xmax>=h;break;case 3:h=this.m_extent.ymax,t=n.ymin<=h&&n.ymax>=h}if(t){P=!0;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;){let n=!0,E=-1,y=-1;const S=this.m_shape.getFirstVertex(t);let C=S;do{this.progress_(),d=this.m_shape.getSegment(C);let t=d;if(null===t){const e=this.m_shape.getNextVertex(C);if(e===a.n){(0,r.g)(s),0===E&&x.push(C);break}this.m_shape.queryXY(C,l),f.setStartXY(l),this.m_shape.queryXY(e,g),f.setEndXY(g),t=f}t.queryLooseEnvelope(i);let S=c.checkSegmentIntersection(i,e,h);t.isCurve()&&0===S&&t.isCurve()&&(f.setStartXY(t.getStartXY()),f.setEndXY(t.getEndXY()),this.m_shape.replaceCurveWithLine(C),t=f,f.queryEnvelope(i),S=c.checkSegmentIntersection(i,e,h));let I=0,v=a.n;if(-1===S){const s=t.intersectionWithAxis2D(o,h,u,_);if(s>0){let e=null;if(t.isCurve()){e=p,(0,r.g)(s<=9);for(let e=0;e<s;e++)o?p[e].setCoords(u[e],h):p[e].setCoords(h,u[e]);I=this.m_shape.splitSegmentAxisAware(C,_,s,e,o?1:0)}else I=this.m_shape.splitSegmentAxisAware(C,_,s,null,-1)}else I=0;I+=1;let i=C,a=this.m_shape.getNextVertex(i);t=null;for(let t=0;t<I;t++){this.m_shape.queryXY(i,l),this.m_shape.queryXY(a,g),d=this.m_shape.getSegment(i);let t=d;null===t&&(f.setStartXY(l),f.setEndXY(g),t=f),t.queryEnvelope(m);let s=c.checkSegmentIntersection(m,e,h);t.isCurve()&&0===s&&(this.m_shape.replaceCurveWithLine(i),f.setStartXY(l),f.setEndXY(g),t=f,t.queryEnvelope(m),s=c.checkSegmentIntersection(m,e,h)),-1===s&&(o?Math.abs(l.y-h)<Math.abs(g.y-h)?(l.y=h,this.m_shape.setXY(i,l)):(g.y=h,this.m_shape.setXY(a,g)):Math.abs(l.x-h)<Math.abs(g.x-h)?(l.x=h,this.m_shape.setXY(i,l)):(g.x=h,this.m_shape.setXY(a,g)),d=this.m_shape.getSegment(i),t=d,null===t&&(f.setStartXY(l),f.setEndXY(g),t=f),t.queryEnvelope(m),s=c.checkSegmentIntersection(m,e,h),-1===s&&(s=c.checkSegmentIntersectionLoose(m,e,h)));const r=E;E=s,-1===y&&(y=E),0===r&&1===E||1===r&&0===E||0===r&&0===E&&x.push(i),1===E&&(P=!1,n=!1),i=a,v=i,a=this.m_shape.getNextVertex(a)}}if(0===I){const e=E;E=S,-1===y&&(y=E),0===e&&E>=1||e>=1&&0===E||0===e&&0===E&&x.push(C),1===E&&(P=!1,n=!1),v=this.m_shape.getNextVertex(C)}if(C=v,x.length>=256){for(let e=1,t=x.length-1;e<t;e++){const t=x[e];s?this.m_shape.snapVertexForPoleClipping(t,h):this.m_shape.removeVertex(t,!1)}x[1]=x.at(-1),x.length=2}}while(C!==S);if(!n){0!==y||!s&&0!==E&&2!==E||x.push(S);for(let e=0,t=x.length;e<t;e++){const t=x[e];s?this.m_shape.snapVertexForPoleClipping(t,h):this.m_shape.removeVertex(t,!1)}}x.length=0,t=n||0===this.m_shape.getPathSize(t)?this.m_shape.removePath(t):this.m_shape.getNextPath(t)}}}if(P)return e.createInstance();d=null,s?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),t>0&&this.densifyAlongClipExtent(t);const E=this.m_shape.getGeometry(this.m_geometry);return E.getGeometryType()===r.G.enumPolygon&&E.setFillRule(e.getFillRule()),E}clipPolyline(e,t){const s=o.Envelope2D.constructEmpty(),n=o.Envelope2D.constructEmpty(),r=(0,h.d)(9,Number.NaN),i=(0,h.d)(9,Number.NaN),m=new a.S;let l=e;const g=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(g);for(let t=0;t<4;t++){let o=!1;const a=!!(1&t);let u=0;switch(t){case 0:u=this.m_extent.xmin,o=g.xmin<=u&&g.xmax>=u;break;case 1:u=this.m_extent.ymin,o=g.ymin<=u&&g.ymax>=u;break;case 2:u=this.m_extent.xmax,o=g.xmin<=u&&g.xmax>=u;break;case 3:u=this.m_extent.ymax,o=g.ymin<=u&&g.ymax>=u}if(!o)continue;const _=l;l=e.createInstance();const p=_.getImpl().querySegmentIterator();p.resetToFirstPath();const d=new h.P,f=new h.P;for(;p.nextPath();){let e=-1,o=!0;for(;p.hasNextSegment();){this.progress_();const h=p.nextSegment(),g=h.isDegenerate(0);h.queryLooseEnvelope(s);const _=c.checkSegmentIntersection(s,t,u);if(-1===_){const s=h.intersectionWithAxis2D(a,u,r,i);let _=0;d.assign(h.getStartXY());for(let p=0;p<=s;p++){const x=p<s?i[p]:1;if(_===x)continue;h.queryCut(_,x,m,!1);const P=m.get();let E=!1;if(P.getStartXY().equals(d)||(P.setStartXY(d),E=!0),p<s&&(a?(f.x=r[p],f.y=u):(f.x=u,f.y=r[p]),P.getEndXY().equals(f)||(P.setEndXY(f),E=!0)),E&&P.normalizeAfterEndpointChange(),!g&&P.isDegenerate(0))continue;P.queryEnvelope(n);let y=c.checkSegmentIntersection(n,t,u);if(-1===y){const e=P.getStartXY(),s=P.getEndXY();E=!1,a?Math.abs(e.y-u)<Math.abs(s.y-u)?(e.y=u,P.setStartXY(e),e.equals(P.getStartXY())||(P.setStartXY(e),E=!0)):(s.y=u,s.equals(P.getEndXY())||(P.setEndXY(s),E=!0)):Math.abs(e.x-u)<Math.abs(s.x-u)?(e.x=u,e.equals(P.getStartXY())||(P.setStartXY(e),E=!0)):(s.x=u,s.equals(P.getEndXY())||(P.setEndXY(s),E=!0)),E&&P.normalizeAfterEndpointChange(),P.queryEnvelope(n),y=c.checkSegmentIntersection(n,t,u),-1===y&&(y=c.checkSegmentIntersectionLoose(n,t,u))}d.assign(P.getEndXY()),_=x,e=y,e>=1?(l.addSegment(P,o),o=!1):o=!0}}else e=_,e>=1?(l.addSegment(h,o),o=!1):o=!0}}}return l}static checkSegmentIntersection(e,t,s){switch(t){case 0:return e.xmin<s&&e.xmax<=s?0:e.xmin>=s?e.xmax===s?2:1:-1;case 1:return e.ymin<s&&e.ymax<=s?0:e.ymin>=s?e.ymax===s?2:1:-1;case 2:return e.xmin>=s&&e.xmax>s?0:e.xmax<=s?e.xmin===s?2:1:-1;case 3:return e.ymin>=s&&e.ymax>s?0:e.ymax<=s?e.ymin===s?2:1:-1}return(0,r.d)(""),0}static checkSegmentIntersectionLoose(e,t,s){switch(t){case 0:{const t=Math.abs(e.xmin-s),n=Math.abs(e.xmax-s);return e.xmin<s?t>n?0:1:((0,r.d)(""),1)}case 1:{const t=Math.abs(e.ymin-s),n=Math.abs(e.ymax-s);return e.ymin<s?t>n?0:1:((0,r.d)(""),1)}case 2:{const t=Math.abs(e.xmin-s),n=Math.abs(e.xmax-s);return e.xmax>s?t<n?0:1:((0,r.d)(""),1)}case 3:{const t=Math.abs(e.ymin-s),n=Math.abs(e.ymax-s);return e.ymax>s?t<n?0:1:((0,r.d)(""),1)}}return(0,r.d)(""),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 e=new h.P;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let n=0,r=this.m_shape.getPathSize(t);n<r;n++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,e),this.m_extent.xmin!==e.x&&this.m_extent.xmax!==e.x&&this.m_extent.ymin!==e.y&&this.m_extent.ymax!==e.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(e){const t=new h.P(0,0),s=new h.P(0,0),n=(0,h.d)(2048,Number.NaN);for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==a.n;i=this.m_shape.getNextPath(i)){const o=this.m_shape.getFirstVertex(i);let a=o;do{const i=this.m_shape.getNextVertex(a);this.m_shape.queryXY(a,t);let o=-1;if(t.x===this.m_extent.xmin?(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmin&&(o=1)):t.x===this.m_extent.xmax&&(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmax&&(o=1)),t.y===this.m_extent.ymin?(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymin&&(o=0)):t.y===this.m_extent.ymax&&(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymax&&(o=0)),-1===o){a=i;continue}if(this.isCurve(a)){a=i;continue}const m=t.clone(),l=new h.P(0,0);if(o){const n=t.y-this.m_extent.ymin;l.y=(0,h.e)(s.y-t.y),m.y=e*(0,h.f)(Math.floor(Math.abs(n)/e),n)+this.m_extent.ymin,l.y<0&&(m.y+=e)}else{const n=t.x-this.m_extent.xmin;l.x=(0,h.e)(s.x-t.x),m.x=e*(0,h.f)(Math.floor(Math.abs(n)/e),n)+this.m_extent.xmin,l.x<0&&(m.x+=e)}const g=o?s.y-t.y:s.x-t.x,c=Math.abs(g);if(c/e>65536&&(0,r.d)(""),c>0){const s=Math.trunc(c/e)+2;n.length<s&&(n.length=s);let i=0;for(let s=0;;s++){const a=m.add(l.mul(s*e)),h=(o?a.y-t.y:a.x-t.x)/g;if(h>=1)break;h<=0||((0,r.g)(i<=n.length),n[i]=h,i++)}0!==i&&this.m_shape.splitSegment(a,n,i)}a=i}while(a!==o)}}splitSegments(e,t){let s=-1;const n=new h.P,r=[];for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==a.n;i=this.m_shape.getNextPath(i)){let o=this.m_shape.getFirstVertex(i),h=a.n;for(let a=0,m=this.m_shape.getPathSize(i);a<m;a++,o=h)if(this.progress_(),h=this.m_shape.getNextVertex(o),this.m_shape.queryXY(o,n),(e?n.y===t:n.x===t)&&(this.m_shape.queryXY(h,n),e?n.y===t:n.x===t)){if(this.isCurve(o))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(o,s)&&(r.push(o),this.m_shape.setUserIndex(o,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(r.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),r.length<3)return;r.sort((e,t)=>this.compareVertices(e,t));const i=new h.P,o=new h.P,m=new h.P;o.setNAN();let l=-1,g=[],c=[];const u=this.m_shape.createUserIndex(),_=this.m_shape.createUserIndex();for(let s=0,a=r.length;s<a;s++){const a=r[s];if(this.m_shape.queryXY(a,n),!n.isEqualPoint2D(o)){if(-1===l){l=s,o.setCoordsPoint2D(n);continue}for(let n=l;n<s;n++){const s=r[n],a=this.m_shape.getNextVertex(s),h=this.m_shape.getPrevVertex(s);let m=!1;this.m_shape.queryXY(a,i),o.compare(i)<0&&(e?i.y===t:i.x===t)&&(this.isCurve(s)||(g.push(s),m=!0,this.m_shape.setUserIndex(s,_,1))),this.m_shape.queryXY(h,i),o.compare(i)<0&&(e?i.y===t:i.x===t)&&(this.isCurve(h)||(m||g.push(s),this.m_shape.setUserIndex(s,u,1)))}for(let e=0,t=g.length;e<t;e++){const t=g[e],s=this.m_shape.getUserIndex(t,u),r=this.m_shape.getUserIndex(t,_);if(1===s){const e=this.m_shape.getPrevVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(n)){const r=h.P.distance(o,m);s=h.P.distance(m,n)/r,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const i=this.m_shape.getPrevVertex(t);this.m_shape.setXY(i,n),c.push(i),this.m_shape.setUserIndex(i,u,1),this.m_shape.setUserIndex(i,_,-1)}}if(1===r){const e=this.m_shape.getNextVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(n)){const e=h.P.distance(o,m);s=h.P.distance(o,n)/e,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const r=this.m_shape.getNextVertex(t);this.m_shape.setXY(r,n),c.push(r),this.m_shape.setUserIndex(r,u,-1),this.m_shape.setUserIndex(r,_,1)}}}const a=g;g=c,c=a,c.length=0,l=s,o.setCoordsPoint2D(n)}}this.m_shape.removeUserIndex(u),this.m_shape.removeUserIndex(_)}resolveOverlaps(e,t){const s=new h.P,n=[];let i=-1;for(let r=0,o=this.m_verticesOnExtent.length;r<o;r++){this.progress_();const o=this.m_verticesOnExtent[r];if(o===a.n)continue;const h=this.m_shape.getNextVertex(o);if(this.m_shape.queryXY(o,s),(e?s.y===t:s.x===t)&&(this.m_shape.queryXY(h,s),e?s.y===t:s.x===t)){if(this.isCurve(o))continue;-1===i&&(i=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(o,i)&&(n.push(o),this.m_shape.setUserIndex(o,i,-2)),-2!==this.m_shape.getUserIndex(h,i)&&(n.push(h),this.m_shape.setUserIndex(h,i,-2))}}if(0===n.length)return void(-1!==i&&this.m_shape.removeUserIndex(i));(0,r.g)(-1!==i),n.sort((e,t)=>this.compareVertices(e,t));for(let e=0,t=n.length;e<t;e++){const t=n[e];this.m_shape.setUserIndex(t,i,e)}const o=new h.P,m=new h.P;m.setNAN();let l=-1;for(let r=0,h=n.length;r<h;r++){this.progress_();const h=n[r];if(h!==a.n&&(this.m_shape.queryXY(h,s),!s.isEqualPoint2D(m))){if(-1!==l)for(;;){let s=!1;const h=r;for(let g=l;g<h;g++){const h=n[g];if(h===a.n)continue;let l=a.n;const c=this.m_shape.getNextVertex(h);this.m_shape.queryXY(c,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(h)||(l=c));let u=a.n;const _=this.m_shape.getPrevVertex(h);if(this.m_shape.queryXY(_,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(_)||(u=_)),l===a.n||u===a.n){if(l!==a.n||u!==a.n){for(let c=g+1;c<r;c++){const r=n[c];if(r===a.n)continue;const g=this.m_shape.getNextVertex(r);let _=a.n;this.m_shape.queryXY(g,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(r)||(_=g));const p=this.m_shape.getPrevVertex(r);let d=a.n;if(this.m_shape.queryXY(p,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(p)||(d=p)),_!==a.n&&d!==a.n){this.beforeRemoveVertex(r,n,i),this.m_shape.removeVertex(r,!1),this.beforeRemoveVertex(_,n,i),this.m_shape.removeVertex(_,!1),s=!0;break}if(l!==a.n&&d!==a.n){this.removeOverlap(n,h,l,r,d,i),s=!0;break}if(u!==a.n&&_!==a.n){this.removeOverlap(n,r,_,h,u,i),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(h,n,i),this.m_shape.removeVertex(h,!1),this.beforeRemoveVertex(l,n,i),this.m_shape.removeVertex(l,!1),s=!0}if(!s)break}l=r,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(i)}beforeRemoveVertex(e,t,s){let n=this.m_shape.getUserIndex(e,s);(0,r.g)(n>=0),t[n]=a.n,n=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),(0,r.g)(n>=0),this.m_verticesOnExtent[n]=a.n;const i=this.m_shape.getPathFromVertex(e);i!==a.n&&this.m_shape.getFirstVertex(i)===e&&(this.m_shape.setFirstVertex(i,a.n),this.m_shape.setLastVertex(i,a.n))}removeOverlap(e,t,s,n,r,i){this.m_shape.setNextVertex(t,n),this.m_shape.setPrevVertex(n,t),this.m_shape.setPrevVertex(s,r),this.m_shape.setNextVertex(r,s),this.beforeRemoveVertex(n,e,i),this.m_shape.removeVertexInternal(n,!1),this.beforeRemoveVertex(r,e,i),this.m_shape.removeVertexInternal(r,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(e){for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;t=this.m_shape.getNextPath(t)){const s=this.m_shape.getPathSize(t);if(s<3)continue;let n=this.m_shape.getFirstVertex(t);const r=new h.P;this.m_shape.queryXY(n,r);let i=r.y===e&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const o=new h.P;this.m_shape.queryXY(n,o);let a=o.y===e&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const m=new h.P;for(let t=0,h=s-2;t<h;t++,n=this.m_shape.getNextVertex(n)){this.progress_(),this.m_shape.queryXY(n,m);const t=m.y===e;a&&i&&t&&(o.x-r.x)*(m.x-o.x)<=0?(this.m_shape.removeVertex(this.m_shape.getPrevVertex(n),!1),o.setCoordsPoint2D(m),a=t&&!this.isCurve(n)):(r.setCoordsPoint2D(o),i=a,o.setCoordsPoint2D(m),a=t&&!this.isCurve(n))}}}fixPaths(){for(let e=0,t=this.m_verticesOnExtent.length;e<t;e++){const t=this.m_verticesOnExtent[e];t!==a.n&&this.m_shape.setPathToVertex(t,a.n)}const e=this.m_shape.hasCurves();let t=0,s=0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==a.n;){const n=this.m_shape.getFirstVertex(e);if(n===a.n||e!==this.m_shape.getPathFromVertex(n)){const t=e;e=this.m_shape.getNextPath(e),this.m_shape.setFirstVertex(t,a.n),this.m_shape.removePathOnly(t);continue}let r=n,i=0;do{this.m_shape.setPathToVertex(r,e),i++,r=this.m_shape.getNextVertex(r)}while(r!==n);this.m_shape.setRingAreaValid(e,!1),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(n)),this.m_shape.setPathSize(e,i),s+=i,t++,e=this.m_shape.getNextPath(e)}for(let n=0,i=this.m_verticesOnExtent.length;n<i;n++){let i=this.m_verticesOnExtent[n];if(i===a.n)continue;let o=this.m_shape.getPathFromVertex(i);if(o!==a.n)continue;o=this.m_shape.insertPath(this.m_geometry,a.n);let h=!1,m=0;const l=i;do{this.m_shape.setPathToVertex(i,o),m++,e&&m<=2&&(h||=this.isCurve(i)),i=this.m_shape.getNextVertex(i)}while(i!==l);if(h?0===m:m<=2){let e=this.m_shape.getUserIndex(l,this.m_verticesOnExtentIndex);(0,r.g)(e>=0),this.m_verticesOnExtent[e]=a.n;const t=this.m_shape.removeVertex(l,!1);2===m&&(e=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),e>=0&&(this.m_verticesOnExtent[e]=a.n),this.m_shape.removeVertex(t,!1));const s=o;o=this.m_shape.getNextPath(o),this.m_shape.setFirstVertex(s,a.n),this.m_shape.removePathOnly(s);continue}this.m_shape.setClosedPath(o,!0),this.m_shape.setPathSize(o,m),this.m_shape.setFirstVertex(o,l),this.m_shape.setLastVertex(o,this.m_shape.getPrevVertex(l)),this.m_shape.setRingAreaValid(o,!1),s+=m,t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let n=0;for(let e=this.m_shape.getFirstGeometry();e!==a.n;e=this.m_shape.getNextGeometry(e))n+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(n)}dbgCheckPathFirst(){}isCurve(e){return null!==this.m_shape.getSegment(e)}compareVertices(e,t){const s=new h.P;this.m_shape.queryXY(e,s);const n=new h.P;return this.m_shape.queryXY(t,n),s.compare(n)}clipPolesOut(e,t){return this.clipPolygonOrProjectedPolyline2(e,t)}}class u{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new _(e,t,s,n)}execute(e,t,s,n){return function(e,t,s,n){return l(e,t,s,Number.NaN,0,n)}(e,t,s,n)}}class _ extends n.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,e||(0,r.a)(""),this.m_envelope=t,this.m_inputGeometryCursor=e,this.m_spatialRefImpl=s,this.m_tolerance=(0,i.c)(s,t,!1).total()}next(){let e;return(e=this.m_inputGeometryCursor.next())?((0,r.c)(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),m(e,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},24383(e,t,s){s.d(t,{NonSimpleResult:()=>n});class n{assign(e){this.m_reason=e.m_reason,this.m_vertexIndex1=e.m_vertexIndex1,this.m_vertexIndex2=e.m_vertexIndex2}constructor(e,t,s){void 0!==e?(this.m_reason=e,this.m_vertexIndex1=t,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}}},5247(e,t,s){s.d(t,{O:()=>h});var n=s(61691),r=s(55537),i=s(88885),o=i.D;class a extends n.G{constructor(e,t,s,n,r,i){super(),this.m_densificator=new o(t,s,n,i,!1,r),this.m_index=-1,this.m_inputGeoms=e}tock(){return!0}getRank(){return 1}next(){let e=null;for(;e=this.m_inputGeoms.next();)return(0,r.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.densify(e);return null}getGeometryID(){return this.m_index}densify(e){return this.m_densificator.densify(e)}}class h{getOperatorType(){return 10202}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}executeMany(e,t,s,n,r,i=12e3){return new a(e,t,s,n,i,r)}execute(e,t,s,n,r,o=12e3){return(0,i.d)(e,t,s,n,r,o)}}},15756(e,t,s){s.d(t,{$:()=>No,C:()=>cs,I:()=>Lo,J:()=>Ao,K:()=>Mo,L:()=>Bo,M:()=>Eo,N:()=>wo,O:()=>cn,Q:()=>v,R:()=>Hr,S:()=>Xr,T:()=>ks,U:()=>C,V:()=>kr,W:()=>Nr,X:()=>Gr,Y:()=>ts,Z:()=>w,_:()=>Ui,a:()=>li,a0:()=>Co,a1:()=>_n,a2:()=>Sr,a3:()=>Ar,a4:()=>pn,a5:()=>Wi,a6:()=>P,a7:()=>ii,a8:()=>qn,a9:()=>br,aD:()=>eo,aE:()=>Xi,aF:()=>yo,aG:()=>Fr,aH:()=>F,aI:()=>Ki,aJ:()=>Zi,aK:()=>jn,aL:()=>Ri,aM:()=>oo,aN:()=>zi,aO:()=>p,aP:()=>zo,aa:()=>Po,ab:()=>Un,ac:()=>xn,ad:()=>Pn,ae:()=>dn,af:()=>fn,ag:()=>On,ao:()=>So,as:()=>Ae,at:()=>Me,au:()=>rr,av:()=>ir,aw:()=>as,ax:()=>Ns,b:()=>mi,c:()=>hi,f:()=>Js,g:()=>sn,h:()=>Oi,i:()=>qi,j:()=>or,k:()=>cr,l:()=>es,m:()=>ci,n:()=>nr,o:()=>ar,p:()=>mr,q:()=>gi,r:()=>$e,s:()=>Us,t:()=>Ys,u:()=>ls,v:()=>ms,w:()=>os,x:()=>vs,y:()=>Gs});var n=s(5482),r=s(79187),i=s(55537),o=s(88885),a=s(95213),h=s(83661),m=s(11878),l=s(31139),g=s(5247),c=s(61691),u=s(76061),_=s(24383);class p{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move)return this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,void(e.move.m_sr=null);if(e.copy)return this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,void(this.m_sr=e.copy.m_sr);e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){const s=e;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,t))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new p({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class d{constructor(e){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():""}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&(0,i.a)("unit type mismatch"),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return(0,h.at)((0,h.au)(this.getUnitType()),(0,h.au)(this.getUnitToBaseFactor()))}equals(e){return!!e&&this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName()}static isValidWkid(e){return!1}}const f={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,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,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,104220,104221,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,10635,10636,10735,10736,10758,37e3,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,10898,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,104032,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 x extends d{constructor(e){if("number"==typeof e)return super(),this.m_factor=e,void(this.m_wkid=0);super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function P(e){return new Ti}class E{constructor(e,t,s){void 0===e?(this.x=new h.H,this.y=new h.H,this.z=new h.H):e instanceof a.f?(this.x=new h.H(e.x),this.y=new h.H(e.y),this.z=new h.H(e.z)):e instanceof h.H?(this.x=e.clone(),this.y=t.clone(),this.z=s.clone()):(0,i.a)("EPoint3D constructor")}dotProduct(e){return this.x.mulE(e.x).addE(this.y.mulE(e.y)).addE(this.z.mulE(e.z))}crossProduct(e){return new E(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){const t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),s=e.x.mulE(this.z).subE(this.x.mulE(e.z)),n=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new E(t,s,n)}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(e,t){return e.sub(t).length()}negate(){return new E(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new E(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new E(this.x.subE(e.x),this.y.subE(e.y),this.z.subE(e.z))}subThis(e){return this.x.subThisE(e.x),this.y.subThisE(e.y),this.z.subThisE(e.z),this}addThis(e){return this.x.addThisE(e.x),this.y.addThisE(e.y),this.z.addThisE(e.z),this}mul(e){return new E(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new E(this.x.divE(e),this.y.divE(e),this.z.divE(e))}eq(e){return this.x.eq(e.x)&&this.y.eq(e.y)&&this.z.eq(e.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return a.f.construct(this.x.value(),this.y.value(),this.z.value())}}class y{constructor(e){if(this.m_origin=new a.f,this.m_normal=new a.f,this.m_axisX=new a.f,this.m_axisY=new a.f,!e)return this.m_origin=new a.f,this.m_normal=new a.f(0,0,1),this.m_axisX=new a.f(1,0,0),void(this.m_axisY=new a.f(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):(0,i.g)(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return(0,i.g)(0),this}set(e,t,s,n){(0,i.g)(0)}setFromPoints(e,t,s){let n=t.sub(e);const r=s.sub(e);this.m_normal=n.crossProductVector(r);let i=!0;if(this.m_normal.isZero()){if(i=!1,n.isZero()&&(n=r),n.isZero()){const t=0,s=1;return this.m_normal.setCoords(t,t,s),this.m_axisX.setCoords(s,t,t),this.m_axisY.setCoords(t,s,t),this.m_origin=e,!1}this.m_axisX=n.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}else this.m_normal.normalizeThis(),this.m_axisX=n.getUnitVector();return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,i}getCoord(e,t){return(0,i.g)(0),{}}getCoord2D(e){return(0,i.g)(0),{}}getCoordX(e,t){return(0,i.g)(0),0}getCoordY(e,t){return(0,i.g)(0),0}getCoordZ(e,t){return(0,i.g)(0),0}setPreferredAxisX(e){(0,i.g)(0)}getOrigin(){return(0,i.g)(0),{}}getNormal(){return(0,i.g)(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){(0,i.g)(0)}setAxisY(e,t=!1){(0,i.g)(0)}recalculateAxisY(){(0,i.g)(0)}setOrigin(e){(0,i.g)(0)}setNormal(e,t){(0,i.g)(0)}intersect(e,t){return(0,i.g)(0),!1}intersectLine(e){return(0,i.g)(0),0}intersectLineEx(e,t){return(0,i.g)(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new h.P;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return(0,i.g)(0),{}}signedDistance(e){return(0,i.g)(0),0}distance(e){return(0,i.g)(0),0}}function S(e,t){return!1}function C(e,t,s,n,r=100,o=S){let a,m,l,g,c,u,_,p,d;(0,i.g)(n>0);let f,x,P,E=0,y=0;const C=(0,h.aq)();t>s&&(s=(0,h.c)(t,t=s));const I=e(t),v=e(s);I<v?(a=m=l=t,g=c=u=I):(a=m=l=s,g=c=u=v);let b=0;for(;b<r&&(P=.5*(s-t),d=t+P,f=n*(Math.abs(a)+.25),x=2*f,!(o(a,g)||Math.abs(a-d)<=x-P));++b){if(Math.abs(y)>f){const e=(a-m)*(g-u);let n=(a-l)*(g-c),r=(a-l)*n-(a-m)*e;n=2*(n-e),n>0&&(r=-r),n=Math.abs(n);const i=y;y=E,Math.abs(r)>=Math.abs(n*i*.5)||r<=n*(t-a)||r>=n*(s-a)?(y=a>=d?t-a:s-a,E=(0,h.aq)()*y):(E=r/n,p=a+E,(p-t<x||s-p<x)&&(E=d-a<0?-Math.abs(f):Math.abs(f)))}else y=a>=d?t-a:s-a,E=y*C;p=a+E,_=e(p),_<g?(p>=a?t=a:s=a,l=m,m=a,a=p,u=c,c=g,g=_):(p<a?t=p:s=p,_<=c||m===a?(l=m,m=p,u=c,c=_):(_<=u||l===a||l===m)&&(l=p,u=_))}return(0,h.k)(a,g)}function I(e,t,s){return e>s?e-=Math.ceil((e-s)/h.p)*h.p:e<t&&(e+=Math.ceil((t-e)/h.p)*h.p),e}function v(e,t,s){return function(e,t,s){const n=s.x,r=s.y;return b(e,t,Math.cos(n),Math.sin(n),Math.cos(r),Math.sin(r),0)}(e,t,s)}function b(e,t,s,n,r,i,o){const h=e/Math.sqrt(1-t*i*i),m=h+o,l=m*r*s,g=m*r*n,c=(h*(1-t)+o)*i;return a.f.construct(l,g,c)}function G(e,t,s){const n=new h.H,r=new h.H,i=new h.H,o=new h.H;n.setCos(s.x),r.setSin(s.x),i.setCos(s.y),o.setSin(s.y);const a=o.negate().mulE(o.mul(t)).add(1).sqrt(),m=new h.H(e).divE(a),l=m.mulE(i).mulE(n),g=m.mulE(i).mulE(r),c=m.mul(1-t).mulE(o);return new E(l,g,c)}function w(e,t,s){const n=s.x,r=s.y,i=s.z,o=Math.atan2(r,n),a=Math.sqrt(n*n+r*r),m=Math.atan2(i,(1-t)*a);return h.P.construct(o,m)}function N(e,t,s){const n=1-t,r=e/Math.sqrt((0,h.a)(s.x)+(0,h.a)(s.y)+(0,h.a)(s.z)/n);return s.mul(r)}function T(e,t,s,n,r){const i=v(e,t,s),o=v(e,t,n);return w(0,t,a.f.lerp(i,o,r))}function D(e,t,s,r,o,m=0,l){if(2===m||3===m)return function(e,t,s,n,r,i=!1,o){const m=N(e,t,s);if(i){const i=new y({pt0:new a.f(0,0,0),pt1:n,pt2:r}),l=i.closestCoordinate(s),g=i.closestCoordinate(n),c=i.closestCoordinate(r),u=h.P.getClosestCoordinate(g,c,l),_=N(e,t,a.f.lerp(n,r,u)),p=a.f.distance(_,m);return o&&o.assign(_),(0,h.k)(u,p)}const l=s=>{const i=N(e,t,a.f.lerp(n,r,s));return a.f.distance(i,m)},g=a.f.distance(n,r);if(g>0){const s=A(e,g),{first:i,second:m}=C(l,0,1,s);return o&&o.assign(N(e,t,a.f.lerp(n,r,i))),(0,h.k)(i,m)}{const e=a.f.distance(s,n);return o&&o.assign(s),(0,h.k)(.5,e)}}(e,t,s,r,o,3===m,l);const g=w(0,t,s),c=s=>{const h=w(0,t,a.f.lerp(r,o,s));return function(e,t,s,r,o){switch((0,i.g)(s.isFinite()&&r.isFinite()),o){case 0:return function(e,t,s,r){const i={stack:[],error:void 0,hasError:!1};try{const o=(0,n.mS)(i,new Eo,!1);return wo.geodeticDistance(e,t,s.x,s.y,r.x,r.y,o,null,null,So.PE_LINETYPE_GEODESIC),o.val}catch(e){i.error=e,i.hasError=!0}finally{(0,n.hk)(i)}}(e,t,s,r);case 1:return function(e,t,s){const r={stack:[],error:void 0,hasError:!1};try{const i=(0,n.mS)(r,new Eo,!1);return wo.greatEllipticDistance(e,t,s.x,s.y,s.x,s.y,i,null,null),i.val}catch(e){r.error=e,r.hasError=!0}finally{(0,n.hk)(r)}}(e,t,s);case 2:case 3:{const n=v(e,t,s),i=v(e,t,r);return a.f.distance(n,i)}default:(0,i.t)("")}}(e,t,g,h,m)},u=a.f.distance(r,o);if(u>0){const s=A(e,u),{first:n,second:i}=C(c,0,1,s);return l&&l.assign(N(e,t,a.f.lerp(r,o,n))),(0,h.k)(n,i)}{const e=c(0);return l&&l.assign(r),(0,h.k)(.5,e)}}function V(e,t,s,n,r,i){if(i[0]=Number.NaN,i[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>h.o||Math.abs(n.y)>h.o)return 0;if((Math.abs(s.y)===h.o||Math.abs(n.y)===h.o)&&s.x!==n.x)return 0;if(Math.abs(r)>=h.o)return 0;if(s.y>0&&n.y>0&&s.y>r&&n.y>r||s.y<0&&n.y<0&&s.y<r&&n.y<r)return 0;const a=o._.constructPoint2D(s),m=o._.constructPoint2D(n),l=G(1,t,a),g=G(1,t,m),c=l.crossProductVector(g);if(c.z.isZero())return h.E.construct(s.y,n.y).containsCoordinate(r)?(i[0]=s.x,1):0;const u=c.x.divE(c.z.negate()),_=c.y.divE(c.z.negate()),p=u.mulE(u).addE(_.mulE(_)).sqrt();if(p.isZero()||u.isZero()&&_.isZero())return 0===r?(i[0]=s.x,i[1]=n.x,2):0;const d=(1-t)*Math.tan(r)/p.value();if(Math.abs(d)>1)return 0;const f=Math.acos(d),x=Math.atan2(_.value(),u.value()),P=x-f;let E=x+f;const y=Math.min(s.x,n.x),S=Math.max(s.x,n.x);I(P,y,S),0!==r?I(E,y,S):E=P;let C=0;return y<=P&&P<=S&&(i[C]=P,C++),E!==P&&y<=E&&E<=S&&(i[C]=E,C++),C}function k(e,t){t[0]>.5*Math.PI?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<.5*-Math.PI&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),(0,i.g)(t[0]>=.5*-Math.PI&&t[0]<=.5*Math.PI)}function F(e,t,s,n,r){n=(0,h.s)(n,-h.o,h.o),r=(0,h.s)(r,-h.o,h.o);const i=h.o-.03;let o;return o=n>i&&r>i||n<-i&&r<-i?function(e,t,s){let n=1;if(t<0&&(n=-1,t=-t,s=-s),0!==e){const r=e*e,i=r*e,o=[1,(1+11*e)/12,(1+118*e+241*r)/360,(1+1089*e+10419*r+8651*i)/20160,(1+9836*e+318246*r+1027436*i+i*e*458881)/1814400],a=t=>{let s=0;const n=(0,h.a)(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-(0,h.a)(t/(1-e)),s},m=a(h.o-t);return(a(h.o-s)-m)*n}{const e=h.o-t,r=h.o-s,i=-4*(0,h.a)(Math.sin(e/2));return(-4*(0,h.a)(Math.sin(r/2))-i)*n}}(e,n,r):H(e,r)-H(e,n),.5*(s-t)*o*function(e){return 1-e}(e)}function H(e,t){if(0===t)return 0;const s=Math.sin(t);let n=s,r=s;if(0!==e){n/=1-e*s*s;const t=Math.sqrt(e);r=s*(0,h.y)(t*s)}return n+r}function A(e,t){if(0!==t){const s=e*(0,h.aG)()/t;return Math.min(s,1e-10)}return 0}class M{constructor(e){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return M.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 U(e){return 1n<<(0x3fn&BigInt(e))}function q(e){return e>>6}class O{constructor(e){this.m_bits=[],void 0!==e&&e.copy&&(this.m_bits=e.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(e){const t=U(e),s=q(e);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&t)}setBit(e){const t=U(e),s=q(e);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=t}clearBit(e){}flipBit(e){const t=U(e),s=q(e);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=t,0n!==(this.m_bits[s]&t)}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(2&e)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((s,n)=>{t|=s===e.m_bits[n]?2:1}),!(1&t||(e.m_bits.forEach((e,s)=>{t|=e===this.m_bits[s]?2:1}),1&t))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>(0,h.az)(e,t),(0,h.au)(0))}getUnorderedBitIterator(){return new M(this)}}class Y{constructor(e,t){this.m_map=new Map,this.m_hf=e,this.m_ef=t}add(e){const t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;const s=this.m_map.get(t);return s instanceof Array?s.find(t=>this.m_ef(t,e))||s.push(e):this.m_ef(s,e)||this.m_map.set(t,[s,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){const t=this.m_hf(e);if(!this.m_map.has(t))return!1;const s=this.m_map.get(t);return s instanceof Array?void 0!==s.find(t=>this.m_ef(t,e)):this.m_ef(s,e)}get(e){const t=this.m_hf(e),s=this.m_map.get(t);if(void 0!==s)return s instanceof Array?s.find(t=>this.m_ef(t,e)):s}get size(){let e=0;for(const t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[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 B extends a.a6{constructor(e){super(),this.m_bufferLeft=new o.S,this.m_bufferRight=new o.S,this.m_intervalLeft=h.E.constructEmpty(),this.m_intervalRight=h.E.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=e}compare(e,t,s){const n=t,r=e.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(r,this.m_bufferRight);const i=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(i.getStartX(),i.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=i.getStartY()===i.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(i.getStartY()===o.getStartY()&&i.getStartX()===o.getStartX())return a?1:-1;if(i.getEndY()===o.getEndY()&&i.getEndX()===o.getEndX())return a?-1:1}let m=i.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const e=i.getEndY(),t=o.getEndY(),s=Math.min(e,t);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),m=i.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(e){this.m_yScanline=e}}class R{constructor(e){this.m_segmentBuffer=new o.S,this.m_point=h.P.getNAN(),this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){const s=e.getElement(t);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),r=new h.E;if(r.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<r.vmin)return-1;if(this.m_point.x>r.vmax)return 1;const i=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<i?-1:this.m_point.x>i?1:0}}var X,L,z;function W(e,t){return{parentage:e,rank:t}}function j(e,t){const s=e.length;if(s!==t.length)return!1;const n=e[0].parentage;if(n!==t[0].parentage)return!1;if(-1===n)return!0;for(let n=1;n<s;++n)if(e[n].parentage!==t[n].parentage)return!1;return!0}function Z(e,t,s){s.length=0;let n=!1;{let r=e.getHalfEdgeVertexIterator(t);for(;r!==o.n;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(W(o,i)),r=e.incrementVertexIterator(r)}}{let r=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;r!==o.n;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(W(o,i)),r=e.incrementVertexIterator(r)}}n&&s.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:e.parentage>t.parentage?1:0),-1===s[0].parentage&&(s.length=1)}(z=X||(X={}))[z.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",z[z.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",z[z.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding",function(e){e[e.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",e[e.enumPathBreakNode=2]="enumPathBreakNode"}(L||(L={}));class K{constructor(){this.m_shape=null,this.m_clusterData=new a.S(8),this.m_clusterVertices=new a.S(2),this.m_firstCluster=o.n,this.m_lastCluster=o.n,this.m_halfEdgeData=new a.S(8),this.m_chainData=new a.S(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(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,s=!0,n=!1){n?this.setEditShapeImpl3D_(e,X.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,X.enumInputModeBuildGraph,null,t,s)}setAndSimplifyEditShapeAlternate(e,t,s=null,n=!1){const r=[];r.push(t),this.m_simplifiedGeometry=t,n?this.setEditShapeImpl3D_(e,X.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(e,X.enumInputModeSimplifyAlternate,r,s,e.getGeometryType(t)===i.G.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,s=null){const n=[];n.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,X.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=o.n,this.m_lastCluster=o.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=o.n,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){const s=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(e,t){(0,i.g)(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){const s=this.getClusterIndex_(e),n=this.m_clusterIndices[t];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1),r.write(n,s)}hasClusterUserIndexFlags(e,t,s){if(-1===t)return!1;const n=this.getClusterUserIndex(e,t);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,s|i)}clearClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,~s&i)}createUserIndexForClusters(e=-1){const t=new a.a(this.m_clusterData.capacity(),e);for(let e=0,s=this.m_clusterIndices.length;e<s;e++)if(null===this.m_clusterIndices[e])return this.m_clusterIndices[e]=t,e;return this.m_clusterIndices.push(t),this.m_clusterIndices.length-1}deleteUserIndexForClusters(e){this.m_clusterIndices[e]=null}getHalfEdgeOrigin(e){return this.m_halfEdgeData.getField(e,1)}getHalfEdgeTo(e){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(e))}getHalfEdgeTwin(e){return this.m_halfEdgeData.getField(e,4)}getHalfEdgePrev(e){return this.m_halfEdgeData.getField(e,5)}getHalfEdgeNext(e){return this.m_halfEdgeData.getField(e,6)}getHalfEdgeChain(e){return this.m_halfEdgeData.getField(e,2)}getHalfEdgeFaceParentage(e){return this.getChainParentage(this.getHalfEdgeChain(e))}getHalfEdgeVertexIterator(e){return this.m_halfEdgeData.getField(e,7)}getHalfEdgeFromXY(e,t){this.queryXY(this.getHalfEdgeOrigin(e),t)}getHalfEdgeToXY(e,t){this.queryXY(this.getHalfEdgeTo(e),t)}isHalfEdgeCurve(e){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}getHalfEdgeFromXYZ(e,t){(0,i.g)(0)}getHalfEdgeToXYZ(e,t){(0,i.g)(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&K.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){const s=this.getHalfEdgeIndex_(e),n=this.m_edgeIndices[t];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(e,t,s){const n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];r.size()<=n&&r.resize(this.m_halfEdgeData.size(),-1),r.write(n,s)}createUserIndexForHalfEdges(e){void 0===e&&(e=-1);const t=new a.a(this.m_halfEdgeData.capacity(),e);for(let e=0,s=this.m_edgeIndices.length;e<s;e++)if(null===this.m_edgeIndices[e])return this.m_edgeIndices[e]=t,e;this.m_edgeIndices.push(t);const s=this.m_edgeIndices.length-1;return(0,i.g)(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.getHalfEdgeChain(s),r=this.getHalfEdgeTwin(s),i=this.getHalfEdgeChain(r);this.setChainHalfEdge_(n,o.n),this.setChainHalfEdge_(i,o.n),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonInterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonExterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return(0,i.g)(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){const t=this.getChainIndex_(e);let s=this.m_chainAreas.read(t);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(e),s=this.m_chainAreas.read(t)),s}getChainPerimeter(e){return(0,i.g)(0),0}getChainUserIndex(e,t){const s=this.getChainIndex_(e),n=this.m_chainIndices[t];return n.size()<=s?-1:n.read(s)}setChainUserIndex(e,t,s){const n=this.getChainIndex_(e),r=this.m_chainIndices[t];r.size()<=n&&r.resize(this.m_chainData.size(),-1),r.write(n,s)}createUserIndexForChains(){const e=new a.a(this.m_chainData.capacity(),-1);for(let t=0,s=this.m_chainIndices.length;t<s;t++)if(null===this.m_chainIndices[t])return this.m_chainIndices[t]=e,t;return this.m_chainIndices.push(e),this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,s,n){const r=t===o.n?e.createGeometry(i.G.enumPolygon):t,a=new o.S;this.extractPolygonPathFromChain_(e,r,s,n,a);for(let t=this.getChainFirstIsland(s);t!==o.n;t=this.getChainNextInParent(t))this.extractPolygonPathFromChain_(e,r,t,n,a);return r}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return(0,i.g)(t>=0),1<<Math.min(t,31)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_clusterIndex)}getHalfEdgeFromVertex(e){return this.m_shape.getUserIndex(e,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(e){if((0,i.g)(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);(0,i.g)(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){(0,i.g)(this.m_bBuildGeometryParentageSets);const t=new O,s=e=>{const s=this.getChainHalfEdge(e);let n=s;do{const e=this.getEdgeBitSet_(n);null!==e&&t.assignOr(e);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&t.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(e);for(let t=this.getChainFirstIsland(e);t!==o.n;t=this.getChainNextInParent(t))s(e);return t}getChainPolygons(e){return(0,i.g)(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||null===e)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==o.n;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}const t=[],s=e.getUnorderedBitIterator();for(let e=s.next();e!==M.npos();e=s.next())(0,i.g)(this.m_geometryMapID.has(e)),t.push(this.m_geometryMapID.get(e));return t}getVertexDominant(e,t){if(t===o.n)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==o.n){let s=o.n;for(let n=this.getClusterVertexIterator(e);n!==o.n;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===o.n&&(s=e);const r=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(r)===t){s=e;break}}return s}{const t=this.getClusterVertexIterator(e);return t!==o.n?this.getVertexFromVertexIterator(t):o.n}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode)}setBreakNode(e,t){(0,i.g)(-1!==this.m_clusterBreakNodeIndex),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode)}setStrongPathNode(e,t){if(-1===this.m_clusterBreakNodeIndex){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode)}getSegmentParentage(e){if(-1===this.m_segmentParentageIndex)return-1;const t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){const t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(s);return e!==this.getHalfEdgeTwin(n)}isCrossroadBehind(e){return(0,i.g)(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===o.n)return o.n;let n=s,r=o.n,i=o.n;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===o.n){if(r=this.getClusterHalfEdge(t),r===o.n)return o.n;i=r}if(this.getHalfEdgeTo(i)===e)return n=this.getHalfEdgeTwin(i),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(n!==s&&i!==r);return o.n}querySegmentXY(e,t){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const e=this.m_shape.getSegmentFromIndex(s);t.copyFrom(e,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);t.copyFrom(n,!0),t.get().reverse()}return}}t.createLine();const s=t.get(),n=h.P.getNAN();this.getHalfEdgeFromXY(e,n),s.setStartXY(n),this.getHalfEdgeToXY(e,n),s.setEndXY(n)}isCurveEdge(e){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}compareEdgeAnglesCurveHelper_(e,t,s){const n=new o.S,r=new o.S;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const a=n.get(),m=r.get();if(a.equals(m))return 0;const l=new h.P;this.getHalfEdgeFromXY(e,l);const g=new h.P;this.getHalfEdgeToXY(e,g);const c=new h.P;return this.getHalfEdgeToXY(t,c),(0,i.g)(!g.isEqualPoint2D(c)),(0,o.R)(a,m)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=h.P.getNAN();this.getHalfEdgeToXY(e,n);const r=h.P.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=h.P.getNAN();this.getHalfEdgeFromXY(e,i);const o=h.P.getNAN();o.setSub(n,i);const a=h.P.getNAN();return a.setSub(r,i),!s||a.y>=0&&o.y>0?h.P.compareVectors(o,a):0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return(0,i.g)(0),0}compareEdgeAnglesForPair3D_(e,t){return(0,i.g)(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);(0,i.g)(n===t),(0,i.g)(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=o.n));const a=this.getChainIndex_(t),h=this.m_chainAreas.read(a);Number.isNaN(h)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const m=this.getChainHalfEdge(t);m!==e&&m!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==o.n?t:this.getClusterHalfEdge(e);if(n===o.n)return o.n;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return o.n;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==o.n;s=this.getNextCluster(s)){let n=o.n;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===o.n)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));let i=r;for(;;){const s=this.getHalfEdgeNext(i),a=this.getHalfEdgePrev(i),h=this.getHalfEdgeTwin(i);if(a===h){if(this.deleteEdgeInternal_(i),e=!0,n!==i&&n!==h||(n=o.n),i===r||a===r){if(r=s,i===r||a===r)break;i=s;continue}}else this.setHalfEdgeUserIndex(i,t,1);if(i=s,i===r)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){const e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){const e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);const t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){const e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return(0,i.g)(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){const s=t?o.n:e;for(let t=this.getHalfEdgeVertexIterator(e);t!==o.n;t=this.incrementVertexIterator(t)){const e=this.getVertexFromVertexIterator(t);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==o.n&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);const s=this.getChainFirstIsland(t);this.setChainNextInParent_(e,s),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){const s=this.getChainIndex_(e);this.m_chainAreas.write(s,t)}setChainPerimeter_(e,t){const s=this.getChainIndex_(e);this.m_chainPerimeters.write(s,t)}updateChainAreaAndPerimeter_(e){const t=this.m_shape.hasCurves(),s=new h.K(0),n=new h.K(0),r=this.getChainHalfEdge(e),i=h.P.getNAN(),a=h.P.getNAN(),m=h.P.getNAN();this.getHalfEdgeFromXY(r,i),a.setCoordsPoint2D(i);let l=r;do{this.getHalfEdgeToXY(l,m),t&&this.isCurveEdge(l)||n.pe(h.P.distance(a,m)),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==e&&s.pe((m.x-i.x-(a.x-i.x))*(m.y-i.y+(a.y-i.y))*.5),a.setCoordsPoint2D(m),l=this.getHalfEdgeNext(l)}while(l!==r);if(t){const t=new o.S;l=r;do{this.getHalfEdgeToXY(l,m);const r=this.isCurveEdge(l);if(r&&(this.querySegmentXY(l,t),n.pe(t.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==e&&r){const e=t.get().calculateArea2DHelper();s.pe(e)}l=this.getHalfEdgeNext(l)}while(l!==r)}const g=this.getChainIndex_(e);this.m_chainAreas.write(g,s.getResult()),this.m_chainPerimeters.write(g,n.getResult())}getChainTopmostEdge_(e){return(0,i.g)(0),0}planeSweepParentage_(e,t){const s=new B(this),n=new a.T;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let m=null;const l=h.P.getNAN();for(let h=this.getFirstCluster();h!==o.n;h=this.getNextCluster(h)){this.progress_(t);const g=this.getClusterHalfEdge(h);if(g!==o.n){if(r.length=0,!this.tryOptimizedInsertion_(n,i,r,h,g)){this.queryXY(h,l),s.setY(l.y);let e=g;do{const t=this.getHalfEdgeUserIndex(e,i);-1!==t&&(n.deleteNode(t),this.setHalfEdgeUserIndex(e,i,a.S.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(g!==e);e=g;do{if(-1===this.getHalfEdgeUserIndex(e,i)){const t=n.addElement(e);r.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(g!==e)}for(let t=r.length-1;t>=0;t--){const s=r[t],o=n.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,i,s),this.planeSweepParentagePropagateParentage_(n,s,e)}}else if(this.getClusterChain(h)===o.n){null===m&&(m=new R(this)),this.queryXY(h,l),m.setPointXY(l);const e=n.searchLowerBound(m);let t=this.m_universeChain;if(-1!==e){let s=n.getElement(e);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,e)),s!==o.n&&(t=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(t,h)}}this.deleteUserIndexForHalfEdges(i)}planeSweepParentagePropagateParentage_(e,t,s){const n=e.getElement(t),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==o.n)return;const a=this.getLeftSkipPolylines_(e,t),h=this.getHalfEdgeTwin(n),m=this.getHalfEdgeChain(h);let l=this.getChainParent(r),g=this.getChainParent(m);if(a===o.n)l===o.n&&(m===r?(this.setChainParent_(m,this.m_universeChain),g=this.m_universeChain,l=g):(g===o.n&&(this.setChainParent_(m,this.m_universeChain),g=this.m_universeChain),this.setChainParent_(r,m),l=m));else{const e=this.getHalfEdgeChain(a);if(g===o.n){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(m,t),g=t}else this.setChainParent_(m,e),g=e;m===r&&(l=g)}}l===o.n&&(this.trySetChainParentFromTwin_(r,m),l=this.getChainParent(r)),(0,i.g)(l!==o.n),s===X.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,a):s===X.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,a,h,r,m):s===X.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,a,h,r,m)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===o.n?(i=e.getNext(i),r=this.getHalfEdgeChain(s)):r=this.getHalfEdgeChain(n);let a=null,h=this.getChainParentage(r);for(this.m_bBuildGeometryParentageSets&&(a=this.getChainBitSet(r));-1!==i;i=e.getNext(i)){const t=e.getElement(i),s=this.getHalfEdgeTwin(t);r=this.getHalfEdgeChain(t);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(n);e=new O({copy:e}),e.assignOr(a),this.setChainBitSet_(n,e);let s=this.getChainBitSet(r);const i=this.getLeftEdgeBitSet_(t),o=new O({copy:a});if(o.assignSubtract(i),o.isZero())break;s=new O({copy:s}),s.assignOr(o),this.setChainBitSet_(r,s),a=s}const o=this.getChainParentage(n),m=o|h;m!==o&&this.setChainParentage_(n,m);let l=this.getChainParentage(r);const g=h&~this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft);if(g&&(l|=g,this.setChainParentage_(r,l)),0===g)break;h=l}}propagateParentageWinding_(e,t,s,n,r,a,h){if(a===h)return;let m=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);m+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let l=0;const g=[],c=[];c.push(0);for(let s=e.getFirst();s!==t;s=e.getNext(s)){const t=e.getElement(s),n=this.getHalfEdgeTwin(t),r=this.getHalfEdgeChain(t),a=this.getHalfEdgeChain(n);if(r!==a){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),l+=e;let s=!1;0!==g.length&&g.at(-1)===a&&(c.pop(),g.pop(),s=!0),(0,i.g)(this.getChainParent(a)!==o.n),s&&this.getChainParent(a)===r||(c.push(l),g.push(r))}}if(l+=m,0!==g.length&&g.at(-1)===h&&(c.pop(),g.pop()),0!==l){if(0===c.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}else if(0!==c.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}propagateParentageAlternate_(e,t,s,n,r,i,a){const h=this.m_simplifiedGeometry,m=this.getGeometryID(h);if(n===o.n)this.setChainParentage_(a,this.m_universeGeomID),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,m):this.setChainParentage_(i,this.m_universeGeomID);else{const e=this.getChainParentage(a);if(0===e){const e=this.getHalfEdgeChain(n),t=this.getChainParentage(e);this.setChainParentage_(a,t),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,t===m?this.m_universeGeomID:m):this.setChainParentage_(i,t)}else 1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,e===m?this.m_universeGeomID:m):this.setChainParentage_(i,e)}}tryOptimizedInsertion_(e,t,s,n,r){let i=r,h=-1,m=o.n,l=0;do{if(2===l)return!1;const e=this.getHalfEdgeUserIndex(i,t);if(-1!==e){if(-1!==h)return!1;h=e}else{if(m!==o.n)return!1;m=i}l++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return m!==o.n&&-1!==h&&(this.setHalfEdgeUserIndex(e.getElement(h),t,a.S.impossibleIndex2()),e.setElement(h,m),s.push(h),!0)}trySetChainParentFromTwin_(e,t){const s=this.getChainArea(e);if(0===s)return!1;const n=this.getChainArea(t);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(e,t),!0;{const s=this.getChainParent(t);if(s!==o.n)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=t.size();s<n;s++){const n=t.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),a=this.m_shape.getPathFromVertex(n),h=this.m_shape.getGeometryFromPath(a),m=this.m_shape.getGeometryType(h);if((0,i.h)(m)){const t=this.m_shape.getNextVertex(n);if(t===o.n)continue;const s=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(r===s)continue;const a=this.newHalfEdgePair_(),l=this.getHalfEdgeTwin(a),g=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(g,0,n),this.m_clusterVertices.setField(g,1,-1),this.setHalfEdgeVertexIterator_(a,g),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,a),this.setHalfEdgeOrigin_(a,r);const c=this.getClusterHalfEdge(r);if(c===o.n)this.setClusterHalfEdge_(r,a),this.setHalfEdgePrev_(a,l),this.setHalfEdgeNext_(l,a);else{const e=this.getHalfEdgePrev(c);this.setHalfEdgePrev_(c,l),this.setHalfEdgeNext_(l,c),this.setHalfEdgeNext_(e,a),this.setHalfEdgePrev_(a,e)}this.setHalfEdgeOrigin_(l,s);const u=this.getClusterHalfEdge(s);if(u===o.n)this.setClusterHalfEdge_(s,l),this.setHalfEdgeNext_(a,l),this.setHalfEdgePrev_(l,a);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,a),this.setHalfEdgeNext_(a,u),this.setHalfEdgeNext_(e,l),this.setHalfEdgePrev_(l,e)}const _=this.getGeometryID(h);if(e===X.enumInputModeBuildGraph){const e=m===i.G.enumPolygon?_:0;if(this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new O,t=this.m_shape.getGeometryUserIndex(h,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(a,e),this.setEdgeBitSet_(l,null),this.setLeftEdgeBitSet_(l,e),this.setLeftEdgeBitSet_(a,null)}}else if(e===X.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(n),s=this.m_shape.getXY(t);let r=0,i=0;e.compare(s)<0?r=1:i=-1,this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,r),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,i)}else e===X.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const p=m===i.G.enumPolygon?K.c_EdgeBitMask:0;this.setHalfEdgeParentage_(a,_|p),this.setHalfEdgeParentage_(l,_|p)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,s=t.size();e<s;e++){const s=t.read(e);if(this.m_shape.getSegment(s)){const e=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);e!==o.n&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{const s=this.getHalfEdgeVertexIterator(t);if(s!==o.n){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,o.n)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==o.n){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,o.n)}}if(-1!==this.m_segmentIndexHe){let r=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==r){if(-2===r){const s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,s)}if(r=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===r){const e=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){const t=[];for(let s=this.getFirstCluster();s!==o.n;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==o.n){let r=n;do{t.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(t.length>1){let r=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=(0,h.c)(t[0],t[0]=t[1]):r=!1;let i=t[0],a=i,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a),g=o.n;for(let s=1,n=t.length;s<n;s++){const n=t[s],r=this.getHalfEdgeTwin(n),h=this.getHalfEdgeOrigin(r);if(h!==m||n===a)this.updateVertexToHalfEdgeConnection_(g,!1),g=o.n,a=n,m=h,l=r;else{if(e===X.enumInputModeBuildGraph){const e=this.getHalfEdgeParentageMask_(a)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(a,e),this.setHalfEdgeParentage_(l,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(l,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(l,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,s;e=this.getEdgeBitSet_(a),t=this.getEdgeBitSet_(n),s=new O({copy:e}),s.assignOr(t),this.setEdgeBitSet_(a,s),e=this.getEdgeBitSet_(l),t=this.getEdgeBitSet_(r),s=new O({copy:e}),s.assignOr(t),this.setEdgeBitSet_(l,s),e=this.getLeftEdgeBitSet_(a),t=this.getLeftEdgeBitSet_(n),s=new O({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(a,s),e=this.getLeftEdgeBitSet_(l),t=this.getLeftEdgeBitSet_(r),s=new O({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(l,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const e=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const e=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(a,n),this.deleteEdgeImpl_(n),g=a,t[s]=o.n,n===i&&(t[0]=o.n,i=o.n)}}if(this.updateVertexToHalfEdgeConnection_(g,!1),g=o.n,!r){i=o.n;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==o.n){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=o.n;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===o.n)continue;if(i===o.n){i=s,a=i,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a);continue}if(s===a)continue;const n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(l,s),this.setHalfEdgePrev_(s,l),a=s,m=r,l=n}this.setClusterHalfEdge_(s,i)}}}}sortHalfEdgesByAngle3D_(e){(0,i.g)(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,o.n);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==o.n;e=this.getNextCluster(e)){const n=this.getClusterHalfEdge(e);if(n!==o.n){let e=n;do{if(1!==this.getHalfEdgeUserIndex(e,s)){const n=this.newChain_();this.setChainHalfEdge_(n,e),this.setChainPrev_(n,t),this.setChainNext_(t,n);let r=null;this.m_bBuildGeometryParentageSets&&(r=new O),t=n;let i=0,o=e;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(i|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&r.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,n),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==e);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(n,r),this.setChainParentage_(n,i)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==n)}}this.m_chainAreas=new a.A(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new a.A(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_(e){(0,i.g)(0)}simplifyAlternate_(){(0,i.g)(0)}simplifyWinding_(){(0,i.g)(0)}setEditShapeImpl_(e,t,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let m=this.m_shape.getTotalPointCount();if(s){m=0;for(let e=0,t=s.length;e<t;e++)m+=this.m_shape.getPointCount(s[e])}const l=new a.a(0);let g=0,c=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==o.n;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,c++);for(let t=this.m_shape.getFirstPath(e);t!==o.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,n=this.m_shape.getPathSize(t);s<n;s++)l.add(e),e=this.m_shape.getNextVertex(e)}(0,i.e)(this.m_shape.getGeometryType(e))||(g+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:o.n,t++):e=this.m_shape.getNextGeometry(e)}}this.m_universeGeomID=1<<Math.min(c,31),this.m_pointCount=l.size(),this.m_shape.sortVerticesSimpleByY(l,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,g)),this.m_clusterIndex=this.m_shape.createUserIndex();const u=h.P.getNAN();let _=0;const p=h.P.getNAN();for(let e=0;e<=this.m_pointCount;e++){if(e<this.m_pointCount){const t=l.read(e);this.m_shape.queryXY(t,p)}else p.setNAN();if(!u.isEqualPoint2D(p)){if(_<e){const t=this.newCluster_();let s=o.n,n=-1;for(let r=_;r<e;r++){n=l.read(r),this.m_shape.setUserIndex(n,this.m_clusterIndex,t);const e=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(e,0,n),this.m_clusterVertices.setField(e,1,s),s=e;const i=this.m_shape.getPathFromVertex(n),o=this.m_shape.getGeometryFromPath(i),a=this.getGeometryID(o);this.setClusterParentage_(t,this.getClusterParentage(t)|a)}this.setClusterVertexIterator_(t,s),this.setClusterVertexIndex_(t,this.m_shape.getVertexIndex(n)),this.m_lastCluster!==o.n&&this.setNextCluster_(this.m_lastCluster,t),this.setPrevCluster_(t,this.m_lastCluster),this.m_lastCluster=t,this.m_firstCluster===o.n&&(this.m_firstCluster=t)}_=e,u.setCoordsPoint2D(p)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){const t=l.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){const e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(n,!0);{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==o.n;){for(let t=this.m_shape.getFirstPath(e);t!==o.n;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){const e=this.m_shape.getFirstVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(t)){const e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}}null!=s?(e=t<s.length?s[t]:o.n,t++):e=this.m_shape.getNextGeometry(e)}}if(t===X.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===X.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===X.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,l),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(t),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,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_(e,t,s,n,r){(0,i.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,i.g)(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){const t=this.getHalfEdgeNext(e),s=this.getHalfEdgePrev(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeNext(n),i=this.getHalfEdgePrev(n);t!==n&&(this.setHalfEdgeNext_(i,t),this.setHalfEdgePrev_(t,i)),s!==n&&(this.setHalfEdgeNext_(s,r),this.setHalfEdgePrev_(r,s));const a=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(a)===e&&(r!==e?this.setClusterHalfEdge_(a,r):this.setClusterHalfEdge_(a,o.n));const h=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(h)===n&&(t!==n?this.setClusterHalfEdge_(h,t):this.setClusterHalfEdge_(h,o.n)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(e,t){let s=t;for(;;){if(s=e.getPrev(s),-1===s)return o.n;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=(0,h.a)(this.m_checkDirtyPlanesweepTolerance),t=new h.P,s=new h.P,n=new h.P,r=new h.P,i=new h.P;for(let a=this.getFirstCluster();a!==o.n;a=this.getNextCluster(a)){const h=this.getClusterHalfEdge(a);if(h!==o.n){let o=h;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,s),n.setSub(s,t);let a=n.sqrLength();do{const h=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==h){this.getHalfEdgeToXY(o,r),i.setSub(r,t);const h=i.sqrLength(),m=i.crossProduct(n),l=m*m/(h*a);if(Math.min(h,a)*l<=e&&i.dotProduct(n)>=0)return!1;n.assign(i),a=h,s.assign(r)}}while(o!==h)}}return!0}extractPolygonPathFromChain_(e,t,s,n,r){const i=this.m_shape.hasSegmentParentage(),h=this.getChainHalfEdge(s);let m=h,l=o.n;const g=new a.P;do{const a=this.getHalfEdgeTwin(m);if(this.getHalfEdgeChain(a)!==s){let s=o.n;const a=this.getHalfEdgeOrigin(m);if(n===o.n){const e=this.getClusterVertexIterator(a);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(a);e!==o.n;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===o.n&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let h;if(l===o.n&&(l=e.insertPath(t,o.n),e.setClosedPath(l,!0)),this.m_shape===e?h=e.addVertex(l,s):(this.m_shape.queryPoint(s,g),h=e.addPoint(l,g)),this.isHalfEdgeCurve(m)&&(this.querySegmentXY(m,r),e.setSegmentToIndex(e.getVertexIndex(h),r.get().clone())),i){const t=this.getSegmentParentage(m);e.setSegmentParentageAndBreak(h,t,this.isBreakNode(a))}}m=this.getHalfEdgeNext(m)}while(m!==h)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;(0,i.g)(-1!==this.m_clusterBreakNodeIndex),(0,i.g)(-1===this.m_segmentParentageIndex);for(let e=this.getFirstCluster();e!==o.n;e=this.getNextCluster(e)){let t=0;const s=this.getClusterHalfEdge(e);if(s!==o.n){let e=s;do{t++,e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==s&&t<3)}2!==t&&this.setBreakNode(e,!0)}let e=[],t=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==o.n;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==o.n){let n=!1,i=r;do{let r=i;for(;-1===this.getHalfEdgeUserIndex(r,s);){const i=this.getHalfEdgeNext(r),o=this.getHalfEdgeTwin(r);Z(this,r,t);const a=t.at(-1).parentage;if(!n){const t=this.getHalfEdgeOrigin(r);if(!this.isBreakNode(t)){const t=this.getHalfEdgePrev(r);r!==t&&(Z(this,t,e),n=!0)}}if(n&&!j(t,e)){const e=this.getHalfEdgeOrigin(r);this.setBreakNode(e,!0)}e=(0,h.c)(t,t=e),n=!0;const m=this.getHalfEdgeOrigin(i);this.isBreakNode(m)&&(n=!1),this.setHalfEdgeUserIndex(r,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(r,s,1),this.setHalfEdgeUserIndex(o,s,1),r=i}i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==r)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(e){return null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=new Y(e=>e.getHashCode(),(e,t)=>e.equals(t)),this.m_uniqueBitSets.add(this.getEmptySet())),null===e?this.getEmptySet():this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return(0,i.g)(t>=0),(0,i.g)(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return(0,i.g)(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setLeftEdgeBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setChainBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(e,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=t:(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new O),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_(e){}dbgVerifyEdgeSegment(e){}}K.c_EdgeParentageMask=~(1<<31),K.c_EdgeBitMask=1<<31;class Q{freeNode_(e){this.m_listNodes.deleteElement(e)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){this.m_lists.deleteElement(e)}newList_(){return this.m_lists.newElement()}Init_(e){(0,i.g)(0)}constructor(e){this.m_listNodes=new a.S(2),this.m_listOfLists=Q.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new a.S(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==Q.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,e),this.m_listOfLists=e),e}deleteList(e){let t=this.getFirst(e);for(;t!==Q.st_nullNode();){const e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==Q.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==Q.st_nullNode()&&this.m_lists.setField(s,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);const s=this.m_lists.getField(e,1),n=this.newNode_();return s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,n)):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,n)),this.m_listNodes.setField(n,0,t),n}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,s){t!==Q.st_nullNode()?(this.m_listNodes.setField(t,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,t)):(this.m_lists.setField(e,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,Q.st_nullNode())),this.freeNode_(s)}deleteElementSearch(e,t){let s=-1,n=this.getFirst(e);for(;n!==t;)s=n,n=this.getNext(n);this.deleteElementDirect(e,s,t)}concatenateLists(e,t){const s=this.m_lists.getField(e,1),n=this.m_lists.getField(t,0);if(n!==Q.st_nullNode()&&(s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==Q.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==Q.st_nullNode()&&this.m_lists.setField(s,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){(0,i.g)(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){const t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=Q.st_nullNode()}isEmpty(e){return(0,i.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(e){return this.m_lists.getField(e,3)}}function J(e=-1){return{m_value:e,m_line:new o.L,m_segment:null,m_segmentInfo:new o.a7(-1),m_env:new h.E(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class $ extends a.a6{constructor(e,t,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new _.NonSimpleResult,this.m_tempSimpleEdge1=J(),this.m_tempSimpleEdge2=J(),this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.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 h.P,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*e.getTotalPointCount()/2,67)),r=Math.min(7,n);this.m_simpleEdgesCache.length=r}tryGetCachedEdge_(e){const t=this.m_simpleEdgesCache[(e&(0,h.j)())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&(0,h.j)())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[t];s&&s.m_value===e&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){const t=(e&(0,h.j)())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[t];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=J(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=e,this.m_simpleEdgesCache[t]=s,s)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=null!==e.m_segment,e.m_bCurve){const t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){const s=e.getStartXY(),n=e.getEndXY(),r=t.getStartXY(),i=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(r)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(i)<0?n:i);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-r)>this.m_tolerance)return s<r?-1:1}const o=s.compare(r)<0?r:s,a=n.compare(i)<0?n:i;let m=0,l=0;for(let s=1;s<5;s++){(0,h.U)(o,a,s/5,this.m_ptSweep);const n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=Math.abs(n-r);i>m&&(m=i,l=n<r?-1:1)}return 0===l?this.errorCracking():l}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);const s=this.compareNonHorizontalLowerEnd_(e,t),n=this.compareNonHorizontalUpperEnd_(e,t);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(e,t){const s=h.P.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=h.P.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=h.P.getNAN();r.setSub(e.getEndXY(),t.getStartXY());const i=n.dotProduct(s),o=r.dotProduct(s),a=Math.abs(i),m=Math.abs(o);if(a<m){if(a<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return i<0&&o<0?-1:i>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let s=1;if(e.m_line.getStartY()<t.m_line.getStartY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getStartX()-r.getStartX(),o=t.m_dxdy*(n.getStartY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}compareNonHorizontalUpperEnd_(e,t){let s=1;if(t.m_line.getEndY()<e.m_line.getEndY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getEndX()-r.getStartX(),o=t.m_dxdy*(n.getEndY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new _.NonSimpleResult(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const e=6;this.m_nonSimpleResult=new _.NonSimpleResult(e,this.m_vertex1,this.m_vertex2)}else this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n;return-1}compareSegments_(e,t,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 e=s.m_bHorizontal?1:0;return e|=n.m_bHorizontal?2:0,0===e?this.compareNonHorizontal_(s,n):1===e?this.compareHorizontal1_(s.m_line,n.m_line):2===e?-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 i,a;if(r&&e===this.m_prev1?i=this.m_prevX1:(i=Number.NaN,this.m_prev1=o.n),r&&t===this.m_prev2?a=this.m_prevX2:(a=Number.NaN,this.m_prev2=o.n),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(i)){this.m_prev1=e;const t=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);i=t,this.m_prevX1=t}if(Number.isNaN(a)){this.m_prev2=t;const e=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=e,this.m_prevX2=e}const h=(0,o.Y)(!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(i-a)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):i<a?-1:i>a?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=t;return this.m_currentNode=s,this.compareSegments(r,r,n,n)}compareSegments(e,t,s,n){let r=this.tryGetCachedEdge_(e);null===r?this.m_vertex1===t?r=this.m_tempSimpleEdge1:(this.m_vertex1=t,r=this.tryCreateCachedEdge_(e),null===r&&(r=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(r,t)):this.m_vertex1=t;let i=this.tryGetCachedEdge_(s);return null===i?this.m_vertex2===n?i=this.m_tempSimpleEdge2:(this.m_vertex2=n,i=this.tryCreateCachedEdge_(s),null===i&&(i=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(i,n)):this.m_vertex2=n,this.compareSegments_(t,n,r,i)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class ee{constructor(e,t){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=h.P.getNAN(),this.m_line1=new o.L,this.m_seg1=null,this.m_env=h.E.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){const s=e.getElement(t);return this.compareVertex(e,t,s)}compareVertex(e,t,s){let n,i=this.m_shape.getSegment(s),a=!0;if(null==i)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),i=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=r.Envelope2D.constructEmpty();i.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),n=0===e.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=t,this.m_bIntersectionDetected=!0,0;let m=0;if(a){(0,o.a0)(this.m_line1);const e=this.m_line1.getStartXY(),t=new h.P;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new h.P;s.setSub(this.m_pointOfInterest,e),m=t.dotProduct(s),m/=t.length()}else m=i.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x;return m<10*-this.m_tolerance?-1:m>10*this.m_tolerance?1:(i.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(m)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=m),this.m_bIntersectionDetected=!0),m<0?-1:m>0?1:0)}}class te{constructor(e,t){this.m_lists=new Q(!1),this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(te.st_nullNode()),this.m_bitFilter=new Int32Array(10*e+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=t%this.m_hashBuckets.length;let r=this.m_hashBuckets[n];return r===Q.st_nullNode()&&(r=this.m_lists.createList(),this.m_hashBuckets[n]=r),this.m_lists.addElement(r,e)}deleteElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%this.m_hashBuckets.length,n=this.m_hashBuckets[s];n===Q.st_nullNode()&&(0,i.a)("");let r=this.m_lists.getFirst(n),o=Q.st_nullNode();for(;r!==Q.st_nullNode();){const t=this.m_lists.getData(r),i=this.m_lists.getNext(r);t===e?(this.m_lists.deleteElementDirect(n,o,r),this.m_lists.getFirst(n)===Q.st_nullNode()&&(this.m_lists.deleteList(n),this.m_hashBuckets[s]=Q.st_nullNode())):o=r,r=i}}getFirstInBucket(e){const t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(31&t)))return Q.st_nullNode();const s=e%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===Q.st_nullNode()?Q.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){const t=this.m_hash.getHash(e);let s=this.getFirstInBucket(t);for(;s!==Q.st_nullNode();){const t=this.m_lists.getData(s);if(this.m_hash.equal(t,e))return s;s=this.m_lists.getNext(s)}return Q.st_nullNode()}deleteNode(e){const t=this.getElement(e),s=this.m_hash.getHash(t)%this.m_hashBuckets.length,n=this.m_hashBuckets[s];n===Q.st_nullNode()&&(0,i.a)(""),this.m_lists.deleteElementSearch(n,e),this.m_lists.getFirst(n)===Q.st_nullNode()&&(this.m_lists.deleteList(n),this.m_hashBuckets[s]=Q.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return Q.st_nullNode()}clear(){(0,i.g)(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function se(e,t,s,n,r){const i=new ae(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=n,i.m_bHasSegmentParentage=e.hasSegmentParentage(),i.clusterNonReciprocal()}function ne(e,t,s,n,r){const i=e-s,o=t-n;return i*i+o*o<=r}function re(e,t,s,n,r,i){const o={pt:new h.P,weight:0,rank:0,bMerged:!1},a=s+r;let m=!1,l=e.x;e.x!==t.x&&(n===i&&(l=(e.x*s+t.x*r)/a),m=!0);let g=e.y;return e.y!==t.y&&(n===i&&(g=(e.y*s+t.y*r)/a),m=!0),n!==i?n>i?(o.rank=n,o.weight=s,o.pt=e):(o.rank=i,o.weight=r,o.pt=t):(o.pt.setCoords(l,g),o.weight=a,o.rank=n),o.bMerged=m,o}function ie(e,t){const s=(0,h.aK)(e);return(0,h.aF)(s,t)}class oe{constructor(e,t,s,n,r){this.m_workPt=new h.P,this.m_shape=e,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=t.clone(),this.m_hashValues=r}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);const t=this.m_workPt.x-this.m_origin.x,s=Math.trunc(t*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return ie(s,Math.trunc(n*this.m_invCellSize+.5))}equal(e,t){return(0,i.g)(0),!1}}class ae{constructor(e){this.m_origin=h.P.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=o.n,this.m_bucketArray=(0,h.d)(4,Number.NaN),this.m_bucketHash=(0,h.d)(4,Number.NaN),this.m_dbgCandidateCheckCount=0,this.m_nsr=new _.NonSimpleResult,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new Q,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){const s=h.P.getNAN();this.m_shape.queryXY(e,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,r=(s.y-this.m_origin.y)*this.m_invCellSize,i=Math.trunc(n),o=Math.trunc(r);let a=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1){const s=ie(i+e,o+t),n=this.m_hashTable.getFirstInBucket(s);n!==te.st_nullNode()&&(this.m_bucketArray[a]=n,this.m_bucketHash[a]=s,a++)}for(let e=a-1;e>=1;e--){const t=this.m_bucketArray[e];for(let s=e-1;s>=0;s--)if(t===this.m_bucketArray[s]){this.m_bucketHash[s]=-1,a--,e!==a&&(this.m_bucketHash[e]=this.m_bucketHash[a],this.m_bucketArray[e]=this.m_bucketArray[a]);break}}for(let n=0;n<a;n++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[n],s,this.m_bucketArray[n],t)}collectNearestNeighbourCandidates(e,t,s,n,r){const i=h.P.getNAN();for(let o=n;o!==te.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);e===n||-1!==t&&this.m_shape.getUserIndex(n,this.m_hashValues)!==t||(this.m_shape.queryXY(n,i),ne(s.x,s.y,i.x,i.y,this.m_sqrTolerance)&&r.push(o))}}mergeClusters(e,t,s){let n=this.m_shape.getUserIndex(e,this.m_newClusters);const r=this.m_shape.getUserIndex(t,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,e),this.m_shape.setUserIndex(e,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,t):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(t,this.m_newClusters,a.S.impossibleIndex2());const i=this.mergeVertices(e,t);if(s){const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return i}mergeVertices(e,t){const s=h.P.getNAN();this.m_shape.queryXY(e,s);const n=h.P.getNAN();this.m_shape.queryXY(t,n);const r=this.m_shape.getRank(e),i=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),a=this.m_shape.getWeight(t);let m,l,g,c,u=!1;if(r===i?(m=r,l=o+a,g=s.x,s.x!==n.x&&(g=(s.x*o+n.x*a)/l,u=!0),c=s.y,s.y!==n.y&&(c=(s.y*o+n.y*a)/l,u=!0)):(r>i?(g=s.x,c=s.y,l=o,m=r):(g=n.x,c=n.y,l=a,m=i),u=!s.equals(n)),u&&(this.m_shape.setXYMonotonic(e,g,c),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,s),this.m_shape.setSegmentParentageBreakVertex(t,s)}return this.m_shape.setWeight(e,l),this.m_shape.setRank(e,m),u}needsClustering(){const e={stack:[],error:void 0,hasError:!1};try{(0,n.mS)(e,(0,h.h)(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);const t=this.m_shape.getSelectedCount(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const r=Math.max(s.height(),s.width())/((0,h.i)()-1);this.m_cellSize<r&&(this.m_cellSize=r,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 oe(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new te(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==o.n;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===a.S.impossibleIndex2())continue;let s;if(0===e?(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,t),0!==t.length){for(let e=0,s=t.length;e<s;e++){this.progress_();const s=t[e],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new _.NonSimpleResult(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return i}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}clusterNonReciprocal(){const e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();const s=Math.max(t.height(),t.width())/((0,h.i)()-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 oe(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new te(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==o.n;t=e.next()){this.progress_();const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{const e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=t.next();s!==o.n;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===a.S.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,t);let r=!1;for(;this.collectClusterCandidates(s,e),0!==e.length;){let t=0;for(let n=0,r=e.length;n<r;n++){this.progress_();const i=e[n],o=this.m_hashTable.getElement(i);this.m_hashTable.deleteNode(i);const a=n+1===r;t|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==t,n||=0!==t,e.length=0,!t)break}r&&(t=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,t)}e.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 e=h.P.getNAN();for(let t=this.m_clusters.getFirstList();t!==Q.st_nullNode();t=this.m_clusters.getNextList(t)){let s=this.m_clusters.getFirst(t);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,e);const r=this.m_shape.getRank(n),i=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==Q.st_nullNode();s=this.m_clusters.getNext(s)){const t=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(n,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,i),this.m_shape.setRank(t,r)}}}}class he{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 a.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_(e,t,s,n,r,i,o,a,h,m){return function(e,t,s,n,r,i,o,a,h,m){return{segmentIndex:e,weightStart:t,rankStart:s,weightEnd:n,rankEnd:r,weightInterior:i,rankInterior:o,segmentParentage:m,u:me(a,h)}}(e,t,s,n,r,i,o,a,h,m)}pushSegment(e,t,s,n,r,i,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,s,n,r,i,o,a,h,m)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?0===e?this.m_param1.length-1:this.m_param2.length-1:0===e?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return 0===e?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return 0===e?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){2!==this.m_inputSegments.length&&(0,i.d)(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=(0,h.a)(e*he.c_smallToleranceFactor);let n=!1;const r=this.m_inputParts[0],a=this.m_inputParts[1],m=this.m_inputSegments[r.segmentIndex],l=this.m_inputSegments[a.segmentIndex];if(t||5&(0,o.Q)(!0,m,l,e,!0)){const t=(0,o.Z)(!0,m,l,null,this.m_param1,this.m_param2,e);0===t&&(0,i.d)("");const g=new Array(t);for(let e=0;e<t;++e)g[e]=h.P.getNAN();const c=new Float64Array(t),u=new Int32Array(t),_=new Array(t),p=new Array(t);for(let e=0;e<t;++e)_[e]=le(),p[e]=le();for(let e=0;e<t;e++){const t=this.m_param1[e],i=this.m_param2[e];let o,d=r.rankInterior,f=r.weightInterior;0===t?(d=r.rankStart,f=r.weightStart,o=r.u.bBreakStart):1===t?(d=r.rankEnd,f=r.weightEnd,o=r.u.bBreakEnd):(this.m_changed1=!0,o=!1);let x,P=a.rankInterior,E=a.weightInterior;0===i?(P=a.rankStart,E=a.weightStart,x=a.u.bBreakStart):1===i?(P=a.rankEnd,E=a.weightEnd,x=a.u.bBreakEnd):(this.m_changed2=!0,x=!1);const y=d,S=P;let C=1,I=0,v=h.P.getNAN();if(y===S){const n=m.getCoord2D(t),r=l.getCoord2D(i);C=f+E,I=d,(0,h.U)(n,r,E/C,v);const o=h.P.sqrDistance(v,n),a=h.P.sqrDistance(v,r);_[e].bBigMove=o>s,p[e].bBigMove=a>s,this.m_changed1||n.equals(v)||(this.m_changed1=!0),this.m_changed2||r.equals(v)||(this.m_changed2=!0)}else if(y>S){v=m.getCoord2D(t);const n=l.getCoord2D(i);C=f,I=d;const r=h.P.sqrDistance(v,n);_[e].bBigMove=!1,p[e].bBigMove=r>s,this.m_changed2||n.equals(v)||(this.m_changed2=!0)}else{v=l.getCoord2D(i),C=E,I=P;const n=m.getCoord2D(t),r=h.P.sqrDistance(v,n);_[e].bBigMove=r>s,p[e].bBigMove=!1,this.m_changed1||n.equals(v)||(this.m_changed1=!0)}g[e].assign(v),c[e]=C,u[e]=I,_[e].bIsBreak=o||x,p[e].bIsBreak=o||x,n||=_[e].bBigMove||p[e].bBigMove}const d=r.rankInterior,f=r.weightInterior;let x=0,P=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param1[s]:1;if(n!==x){const i=this.allocResultSegment(),o=this.m_resultSegments[i];let a,l,p,E;m.queryCut(x,n,o,!1),o.get().snapControlPoints(e*e);let y=!1,S=!1,C=!1,I=!1,v=!1,b=h.P.getNAN(),G=h.P.getNAN();-1!==P?(l=u[P],a=c[P],y=_[P].bBigMove,b.assign(g[P]),C=_[P].bIsBreak,v=!0):(a=r.weightStart,l=r.rankStart,b=o.get().getStartXY(),C=r.u.bBreakStart),s<t?(E=u[s],p=c[s],S=_[s].bBigMove,G.assign(g[s]),I=_[s].bIsBreak,v=!0):(p=r.weightEnd,E=r.rankEnd,G=o.get().getEndXY(),I=r.u.bBreakEnd),v&&o.get().setCoordsForIntersector(b,G,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,a,l,p,E,f,d,C,I,r.segmentParentage));const w=this.m_resultParts1.at(-1);w.u.bBigMoveStart=y,w.u.bBigMoveEnd=S,x=n,P=s}else-1===P&&(P=s)}const E=(0,h.d)(t,0);for(let e=0;e<t;e++)E[e]=e;t>2?(E.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:this.m_param2[e]>this.m_param2[t]?1:0),(0,h.v)(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=(0,h.c)(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),E[1]=(0,h.c)(E[0],E[0]=E[1]));const y=a.rankInterior,S=a.weightInterior;x=0,P=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param2[s]:1;if(n!==x){const r=this.allocResultSegment(),i=this.m_resultSegments[r];let o,m,_,d;l.queryCut(x,n,i,!1),i.get().snapControlPoints(e*e);let f=h.P.getNAN(),C=h.P.getNAN(),I=!1,v=!1,b=!1,G=!1,w=!1;if(-1!==P){const e=E[P];o=c[e],m=u[e],f.assign(g[e]),b=p[e].bBigMove,I=p[e].bIsBreak,w=!0}else o=a.weightStart,m=a.rankStart,f=i.get().getStartXY(),I=a.u.bBreakStart;if(s!==t){const e=E[s];_=c[e],d=u[e],C.assign(g[e]),G=p[e].bBigMove,v=p[e].bIsBreak,w=!0}else _=a.weightEnd,d=a.rankEnd,C=i.get().getEndXY(),v=a.u.bBreakEnd;w&&i.get().setCoordsForIntersector(f,C,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,o,m,_,d,S,y,I,v,a.segmentParentage));const N=this.m_resultParts2.at(-1);N.u.bBigMoveStart=b,N.u.bBigMoveEnd=G,x=n,P=s}else-1===P&&(P=s)}return n?3:2}return 0}intersectLines3D(e,t,s,n){return(0,i.g)(0),1}intersect2D(e,t){const s=this.m_inputParts[0],n=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[n.segmentIndex].getGeometryType();return r!==i.G.enumLine||o!==i.G.enumLine?new _e(this).intersectCurves(e,t):this.intersectLines(e,t)}intersect2DEx(e,t,s,n,r){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&(0,i.d)(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const o=(0,h.a)(e*he.c_smallToleranceFactor);let a=!1;const m=this.m_inputParts[0],l=this.m_inputSegments[m.segmentIndex];if(r||l.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=(0,h.d)(16,Number.NaN);const r=l.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let i=m.rankInterior,g=m.weightInterior;0===r?(i=m.rankStart,g=m.weightStart):1===r?(i=m.rankEnd,g=m.weightEnd):this.m_changed1=!0;let c=i;const u=s,_=n;c===u&&l.isCurve()&&(c=u+1);let p=1,d=0;const f=new h.P;if(c===u){const e=l.getCoord2D(r),s=t.getXY();p=g+_,d=i,(0,h.U)(e,s,_/p,f),this.m_changed1||e.equals(f)||(this.m_changed1=!0),this.m_changed2||s.equals(f)||(this.m_changed2=!0),a=h.P.sqrDistance(f,e)>o}else c>u?(f.assign(l.getCoord2D(r)),p=g,d=i,this.m_changed2||f.equals(t.getXY())||(this.m_changed2=!0)):(f.assign(l.getCoord2D(r)),p=_,d=u,this.m_changed1||f.equals(t.getXY())||(this.m_changed1=!0),a=h.P.sqrDistance(f,t.getXY())>o);let x=0,P=-1;const E=1;for(let t=0;t<=E;t++){const s=t<E?this.m_param1[0]:1;if(s!==x){const n=this.allocResultSegment(),r=this.m_resultSegments[n];l.queryCut(x,s,r),r.get().snapControlPoints(e*e);let i=m.weightStart,o=m.weightEnd,a=m.rankStart,h=m.rankEnd;const g=m.rankInterior,c=m.weightInterior;let u=m.u.bBreakStart,_=m.u.bBreakEnd;-1!==P&&(i=p,a=d,u=!0,r.get().setCoordsForIntersector(f,r.get().getEndXY(),!0)),t!==E&&(o=p,h=d,_=!0,r.get().setCoordsForIntersector(r.get().getStartXY(),f,!0)),x=s,this.m_resultParts1.push(this.newIntersectionPart_(n,i,a,o,h,c,g,u,_,m.segmentParentage))}P=t}return this.m_point.setXY(f),this.m_pointWeight=p,this.m_pointRank=d,a?3:2}return 0}intersect3D(e,t,s,n){return(0,i.g)(0),1}intersect3DEx(e,t,s,n,r,o,a){return(0,i.g)(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new o.S,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new o.S({copy:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new o.S({segment:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}}function me(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function le(){return{bBigMove:!1,bIsBreak:!1}}he.maxWeight=.1*Number.MAX_VALUE,he.c_smallToleranceFactor=.01,he.c_maxGeometryTypeToRankDelta=8;let ge=class{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(e,t,s){if(1===t.getDescription().getAttributeCount())return;const n=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),i=new a.P;t.queryStart(i),s?(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i)):(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)),t.queryEnd(i),s?(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)):(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i))}copyFromWhenOverlap(e,t,s){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,s?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class ce{constructor(){this.hash=0,this.pt=new h.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(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;null!==e.prevEqual;e=e.prevEqual);return e}}function ue(e,t,s,n){return{edge1:e,edge2:t,recursion:s,bIsIntersecting:n}}class _e{constructor(e){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 h.P,this.m_cell=new h.P,this.parent=e}addSegment(e,t,s,n,r,o,a,h,m,l,g){const c=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,m),u=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,o,l);this.newEdge(c,u,e,a,h,g),null===this.m_chainOrigin1?this.m_chainOrigin1=c:null===this.m_chainOrigin2?this.m_chainOrigin2=c:(0,i.g)(0)}intersectCurvesHelper(e,t,s,n,r){const a=this.getSegment(e).get(),m=this.getSegment(t).get();if(a.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(e,t,s,n);if(0!==l)return l;const g=(0,h.a)(.01*s);let c=!1,u=this.processSharpCorners(a,m,s,r>4);const _=u>0;if(!_){if(!(n||5&(0,o.Y)(!0,!1,a,m,s,!0)))return 0;u=(0,o.Z)(!0,a,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===u&&(0,i.d)("");const p=a.getGeometryType(),d=m.getGeometryType(),f=(0,h.m)(h.P,u),x=(0,h.m)(h.P,u),P=(0,h.d)(u,Number.NaN),E=(0,h.d)(u,Number.NaN),y=(0,h.d)(u,Number.NaN),S=(0,h.d)(u,Number.NaN),C=(0,h.n)(le,u),I=(0,h.n)(le,u);let v=!1,b=!1;for(let n=0;n<u;n++){const r=this.parent.m_param1[n],i=this.parent.m_param2[n];let o=e.rank,l=e.weight,u=!0,G=!1;0===r?(o=e.start.rank,l=e.start.weight,G=e.start.bIsBreak):1===r?(o=e.end.rank,l=e.end.weight,G=e.end.bIsBreak):(v=!0,u=!1);let w=t.rank,N=t.weight,T=!1,D=!0;0===i?(w=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===i?(w=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(b=!0,D=!1);let V=o,k=w;if(V===k&&(V*=he.c_maxGeometryTypeToRankDelta,k*=he.c_maxGeometryTypeToRankDelta,V+=pe(p,a,!1),k+=pe(d,m,!1)),u&&D&&k===V){const e=a.getCoord2D(r),t=m.getCoord2D(i);e.equals(t)&&(k=V-1)}let F=1,H=0,A=1,M=0;const U=new h.P,q=new h.P,O=a.getCoord2D(r),Y=m.getCoord2D(i);if(_&&h.P.distance(O,Y)>s)U.setCoordsPoint2D(O),q.setCoordsPoint2D(Y),F=l,A=N,H=o,M=w,C[n].bBigMove=!1,I[n].bBigMove=!1,G=!0,T=!0;else if(V===k){A=F=l+N,M=H=o,(0,h.U)(O,Y,N/F,U),q.setCoordsPoint2D(U);const e=h.P.sqrDistance(U,O),t=h.P.sqrDistance(U,Y);C[n].bBigMove=e>g,I[n].bBigMove=t>g,v||O.equals(U)||(v=!0),b||Y.equals(q)||(b=!0)}else if(V>k){U.setCoordsPoint2D(O),q.setCoordsPoint2D(U),A=F=l,M=H=o;const e=h.P.sqrDistance(U,Y);C[n].bBigMove=!1,I[n].bBigMove=e>g,b||Y.equals(q)||(b=!0)}else{q.setCoordsPoint2D(Y),U.setCoordsPoint2D(q),A=F=N,M=H=w;const e=h.P.sqrDistance(U,O);C[n].bBigMove=e>g,I[n].bBigMove=!1,v||O.equals(U)||(v=!0)}f[n].assign(U),x[n].assign(q),P[n]=F,E[n]=A,y[n]=H,S[n]=M,C[n].bIsBreak=G||T,I[n].bIsBreak=G||T,c||=C[n].bBigMove||I[n].bBigMove,n>0&&(r!==this.parent.m_param1[n-1]&&i!==this.parent.m_param2[n-1]||(y[n]<=y[n-1]?(f[n].assign(x[n-1]),P[n]=E[n-1],y[n]=S[n-1],x[n].assign(x[n-1]),E[n]=E[n-1],S[n]=S[n-1],C[n].bBigMove||=C[n-1].bBigMove,I[n].bBigMove||=I[n-1].bBigMove,C[n].bIsBreak||=C[n-1].bIsBreak,I[n].bIsBreak||=I[n-1].bIsBreak):(f[n-1].assign(f[n]),P[n-1]=P[n],y[n-1]=y[n],x[n-1].assign(x[n]),E[n-1]=E[n],S[n-1]=S[n],C[n-1].bBigMove||=C[n].bBigMove,I[n-1].bBigMove||=I[n].bBigMove,C[n-1].bIsBreak||=C[n].bIsBreak,I[n-1].bIsBreak||=I[n].bIsBreak)))}if(!(v||b||2!==u||p===i.G.enumLine&&d===i.G.enumLine)){if(this.processDoublyConnectedEdges(e,t,r+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;(0,i.g)(0)}this.parent.m_changed1||=v,this.parent.m_changed2||=b;let G=e,w=e.end.weight,N=e.end.rank,T=e.end.bBigMove,D=e.end.bIsBreak,V=0,k=-1;for(let t=0;t<=u;t++){const n=t<u?this.parent.m_param1[t]:1;if(n!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,m,l,g;a.queryCut(V,n,i,!1),i.get().snapControlPoints(s*s);let c=!1,_=!1,p=!1,d=!1;const x=new h.P,E=new h.P;-1!==k?(m=y[k],o=P[k],p=C[k].bBigMove,c=C[k].bIsBreak,x.assign(f[k])):(o=e.start.weight,m=e.start.rank,p=e.start.bBigMove,c=e.start.bIsBreak,x.assign(i.get().getStartXY())),t<u?(g=y[t],l=P[t],d=C[t].bBigMove,_=C[t].bIsBreak,E.assign(f[t])):(l=w,g=N,d=T,_=D,E.assign(i.get().getEndXY()));let S=G;n<1&&(this.splitEdgeInPlace(G),S=G.getNextInChain()),this.updateSegmentOnly(G,r),0===G.start.hash||G.start.pt.equals(x)||(this.m_newNodes.push(G.start),this.removeNodeFromHash(G.start),G.start.hash=0),0===G.end.hash||G.end.pt.equals(E)||(this.m_newNodes.push(G.end),this.removeNodeFromHash(G.end),G.end.hash=0),G.start.pt.assign(x),G.end.pt.assign(E),G.start.bBigMove||=p,G.end.bBigMove||=d,G.start.bIsBreak||=c,G.end.bIsBreak||=_,G.start.weight=o,G.start.rank=m,G.end.weight=l,G.end.rank=g,G=S,V=n,k=t}else-1===k&&(k=t)}const F=G.getNextInChain(),H=[];H.length=u;for(let e=0;e<u;e++)H[e]=e;u>2?(H.sort((e,t)=>(0,h.a7)(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(h.a7)):2===u&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=(0,h.c)(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),H[1]=(0,h.c)(H[0],H[0]=H[1])),G=t,w=t.end.weight,N=t.end.rank,T=t.end.bBigMove,D=t.end.bIsBreak,V=0,k=-1;for(let e=0;e<=u;e++){const n=e<u?this.parent.m_param2[e]:1;if(n!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,l,g;m.queryCut(V,n,i,!1),i.get().snapControlPoints(s*s);const c=new h.P,_=new h.P;let p=!1,d=!1,f=!1,P=!1;if(-1!==k){const e=H[k];o=E[e],a=S[e],c.assign(x[e]),f=I[e].bBigMove,p=I[e].bIsBreak}else o=t.start.weight,a=t.start.rank,f=t.start.bBigMove,p=t.start.bIsBreak,c.assign(i.get().getStartXY());if(e!==u){const t=H[e];l=E[t],g=S[t],_.assign(x[t]),P=I[t].bBigMove,d=I[t].bIsBreak}else l=w,g=N,P=T,d=D,_.assign(i.get().getEndXY());let y=G;n<1&&(this.splitEdgeInPlace(G),y=G.getNextInChain()),this.updateSegmentOnly(G,r),0===G.start.hash||G.start.pt.equals(c)||(this.m_newNodes.push(G.start),this.removeNodeFromHash(G.start),G.start.hash=0),0===G.end.hash||G.end.pt.equals(_)||(this.m_newNodes.push(G.end),this.removeNodeFromHash(G.end),G.end.hash=0),G.start.pt.assign(c),G.end.pt.assign(_),G.start.bBigMove||=f,G.end.bBigMove||=P,G.start.bIsBreak||=p,G.end.bIsBreak||=d,G.start.weight=o,G.start.rank=a,G.end.weight=l,G.end.rank=g,G=y,V=n,k=e}else-1===k&&(k=e)}const A=G.getNextInChain();return this.postProcessResultPartsForCurves(e,F,t,A,r+1),c?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&(0,i.d)(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=(0,h.av)(16);const s=r.Envelope2D.constructEmpty();for(let e=0;e<2;e++){const t=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex]),n=r.Envelope2D.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex].queryLooseEnvelope(n),s.mergeEnvelope2D(n);const i=this.parent.m_inputParts[e];this.addSegment(t,0,i.weightStart,i.rankStart,i.weightEnd,i.rankEnd,i.weightInterior,i.rankInterior,i.u.bBreakStart,i.u.bBreakEnd,i.segmentParentage)}s.inflateCoords(100*e,100*e),this.m_origin.assign(s.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(ue(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let n=0,o=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),(0,i.g)(t.recursion>=0),(0,i.g)(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);o&&(o=!1,n=s)}for(let e=0;e<2;e++){const t=0===e?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let s=(0===e?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=s;s=s.getNextInChain())t.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)),t.at(-1).u.bBigMoveStart=s.start.bBigMove,t.at(-1).u.bBigMoveEnd=s.end.bBigMove}return n}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),a=this.parent.m_resultSegments[t.segmentIndex].get(),m=r.getStartXY().equals(a.getStartXY())&&r.getEndXY().equals(a.getEndXY()),l=r.getStartXY().equals(a.getEndXY())&&r.getEndXY().equals(a.getStartXY());if(!m&&!l)return 0;const g=(0,o.a1)(r,a,!0);if(0!==g&&(0,o.a2)(r,a)&&e.segmentParentage===t.segmentParentage){let e=!1;if(g>0)e=r.equals(a);else{(0,i.g)(-1===g);const t=new o.S({segment:a});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const c=s*he.c_smallToleranceFactor;let u=!1;if(0===g){const e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,n=e.length;t<n;++t){const n=e[t],i=new h.P;r.queryCoord2D(n,i);const o=a.getClosestCoordinate(i,!1),m=new h.P;a.queryCoord2D(o,m);const l=h.P.distance(i,m);if(l>s)return 0;u||=l>c}for(let t=0,n=e.length;t<n;++t){const n=e[t],i=new h.P;a.queryCoord2D(n,i);const o=r.getClosestCoordinate(i,!1),m=new h.P;r.queryCoord2D(o,m);const l=h.P.distance(i,m);if(l>s)return 0;u||=l>c}}let _=e.rank,p=t.rank;return _===p&&(_*=he.c_maxGeometryTypeToRankDelta,p*=he.c_maxGeometryTypeToRankDelta,_+=pe(r.getGeometryType(),r,!0),p+=pe(a.getGeometryType(),a,!0)),_>p?(t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,r,m)):p>_?(e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,r,m)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)),u?3:2}postProcessResultPartsForCurves(e,t,s,n,r){r===(0,h.aC)()&&(0,i.d)("curve_helper");for(let s=e;s!==t;s=s.getNextInChain())this.updateSegmentToNodes(s);for(let e=s;e!==n;e=e.getNextInChain())this.updateSegmentToNodes(e);for(let o=e;o!==t;o=o.getNextInChain()){const e=o.end.pt.sub(o.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(o.start.pt.equals(t.start.pt)&&o.end.pt.equals(t.end.pt)?s=1:o.start.pt.equals(t.end.pt)&&o.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=o.start.pt.equals(t.start.pt)?1:0;if(s||(s=o.end.pt.equals(t.end.pt)?2:0,s||(s=o.end.pt.equals(t.start.pt)?3:0,s||(s=o.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),a=e.dotProduct(n);let h;switch(s){case 1:case 2:h=a>0;break;case 3:case 4:h=a<0;break;default:(0,i.d)("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(ue(o,t,r,!1))}continue}const n=this.parent.m_resultSegments[o.segmentIndex],a=this.parent.m_resultSegments[t.segmentIndex],m=[.5,.25,.75];for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new h.P;n.get().queryCoord2D(t,r);const i=a.get().getClosestCoordinate(r,!1),o=new h.P;if(a.get().queryCoord2D(i,o),h.P.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ue(o,t,r,!1));continue}for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new h.P;a.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),o=new h.P;if(n.get().queryCoord2D(i,o),h.P.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ue(o,t,r,!1));continue}o.equalEdge=t,t.equalEdge=o;let l=o.rank,g=t.rank;l===g&&(l*=he.c_maxGeometryTypeToRankDelta,g*=he.c_maxGeometryTypeToRankDelta,l+=pe(n.get().getGeometryType(),n.get(),!0),g+=pe(a.get().getGeometryType(),a.get(),!0)),l>g||l===g&&o.segmentParentage<=t.segmentParentage?(n.copyTo(a,!1),t.segmentParentage=o.segmentParentage,-1===s&&a.get().reverse()):(a.copyTo(n,!1),o.segmentParentage=t.segmentParentage,-1===s&&n.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(s.start),n&&this.updateAttachedEdgesAfterNodeChange(n.start)}processDoublyConnectedEdges(e,t,s,n){s===(0,h.aC)()&&(0,i.d)("curve_helper");const r=this.getSegment(e).get(),a=this.getSegment(t).get(),m=r.getStartXY().equals(a.getStartXY())&&r.getEndXY().equals(a.getEndXY())?1:r.getEndXY().equals(a.getStartXY())&&r.getStartXY().equals(a.getEndXY())?-1:0;if(0!==m){const i=new o.S;r.queryCut(0,.5,i),i.get().snapControlPoints(n*n);const h=new o.S;r.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=i.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(i),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let l=a.getClosestCoordinate(e.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),a.queryCut(0,l,i),i.get().snapControlPoints(n*n),a.queryCut(l,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=i.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(i),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),m>0?(this.m_pairs.push(ue(e,t,s,!1)),this.m_pairs.push(ue(e.getNextInChain(),t.getNextInChain(),s,!1))):(this.m_pairs.push(ue(e,t.getNextInChain(),s,!1)),this.m_pairs.push(ue(e.getNextInChain(),t,s,!1))),!0}return!1}newNode(e,t,s,n){const r=new ce;return this.m_newNodes.push(r),r.pt=e,r.rank=s,r.weight=t,r.bIsBreak=n,r}newEdge(e,t,s,n,r,i){const o=new ge;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=s,o.segmentParentage=i,o.rank=r,o.weight=n,o}splitEdgeInPlace(e){e.segmentIndex=-1;const t=new ge,s=new ce;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=t,s.prevInChain=e,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=e.weight,s.rank=e.rank,s.bIsBreak=!1,s.bBigMove=!1,t.start=s,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=s,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();null!==t;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){const t=e.prevInChain;if(t&&t.hasSegment()){const s=this.getSegment(t).get();e.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(t.start.pt,t.end.pt,!1),s.ensureXYMonotone())}const s=e.nextInChain;if(s&&s.hasSegment()){const t=this.getSegment(s).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(s.start.pt,s.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){const t=this.getSegment(e).get();e.start.pt.equals(t.getStartXY())&&e.end.pt.equals(t.getEndXY())||(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1;const s=[],n=[],r=[];for(let e=0,t=this.m_newNodes.length;e<t;e++){const s=this.m_newNodes[e];if(null===s)continue;let n=s;for(let r=e+1;r<t;r++){const e=this.m_newNodes[r];null!==e&&s.pt.equals(e.pt)&&(n.nextInHash=e,e.prevInHash=n,n=e,this.m_newNodes[r]=null)}}for(let i=0,o=this.m_newNodes.length;i<o;i++){const o=this.m_newNodes[i];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const i=(0,h.av)(4),a=this.hashTableBinsToCheck(o,i);for(let t=0;t<a;t++)if(null!==i[t])for(let a=i[t];null!==a;){const t=a.nextInHash;h.P.distance(o.pt,a.pt)<=e&&(s.push(a),this.removeNodeFromHash(a),a.hash=0,r.push(a),n.push(a)),a=t}let m=!1;for(const e of s)if(!o.pt.equals(e.pt)){const s=re(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,m=!0,t=!0}if(s.length=0,!m)break;o.hash=this.calculateHash(o.pt)}r.push(o),n.push(o);for(let e=o.nextInHash;null!==e;){e.prevInHash=null;const t=e.nextInHash;e.nextInHash=null,r.push(e),n.push(e),e=t}const a=o.hash;let m=null,l=null;for(const e of n)o!==e&&(e.hash=a,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=m,m&&(m.nextInHash=e),e.prevEqual=l,e.nextEqual=null,l&&(l.nextEqual=e),l=e,m=e;const g=a%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[g],null!==this.m_hashTableOfEquals[g]&&(this.m_hashTableOfEquals[g].prevInHash=m),this.m_hashTableOfEquals[g]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(const e of r)this.updateAttachedEdgesAfterNodeChange(e)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=(0,h.av)(2*e.length),this.m_hashTableOfEqualsSize=0;for(const t of e){let e=t;for(;e;){const t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){const t=e.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[t];e.nextInHash=s,null!==s&&(s.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){const t=e.hash%this.m_hashTableOfEquals.length,s=e.prevInHash,n=e.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[t]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){const s=(e.pt.x-this.m_origin.x)/this.m_cell.x,n=(e.pt.y-this.m_origin.y)/this.m_cell.y,r=(0,h.i)()-1,i=Math.round((0,h.s)(s,-r,r)),o=Math.round((0,h.s)(n,-r,r));let a=i|o<<32;a=(0,h.au)(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let m=i+1|o<<32;m=(0,h.au)(m);let l=1;t[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(l=2);let g=i+1|o+1<<32;g=(0,h.au)(g),t[l]=this.m_hashTableOfEquals[g%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}l++;let c=i|o+1<<32;c=(0,h.au)(c),t[l]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}return l++,l}calculateHash(e){const t=(e.x-this.m_origin.x)/this.m_cell.x,s=(e.y-this.m_origin.y)/this.m_cell.y,n=(0,h.i)()-1;let r=Math.round((0,h.s)(t,-n,n))|Math.round((0,h.s)(s,-n,n))<<32;return r=(0,h.au)(r),0===r&&(r=1),r}processSharpCorners(e,t,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,0,0,s,2,r,i,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return a+1}}if(e.getEndXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,1,1,s,2,r,i,n);if(a){for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),a+1}}if(e.getStartXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,0,1,s,2,r,i,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return a+1}}if(e.getEndXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,1,0,s,2,r,i,n);if(a){for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),a+1}}return 0}}function pe(e,t,s){let n=0;switch(e){case i.G.enumLine:n=0;break;case i.G.enumBezier:n=2;break;case i.G.enumRationalBezier2:n=3;break;case i.G.enumBezier2:n=1;break;case i.G.enumEllipticArc:n=0===t.projectionBehavior()?5:4;break;default:(0,i.d)("")}return s?5-n:n}class de extends ${constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=this.m_parent.getEdgeOriginVertices(t),i=this.m_parent.m_edgeVertices.getFirstElement(r),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(t,i,n,a)}}class fe extends ee{constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;const s=e.getElement(t),n=this.m_parent.getEdgeOriginVertices(s),r=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=t,this.compareVertex(e,t,r)}}class xe extends a.a6{constructor(e){super(),this.pt1=h.P.getNAN(),this.pt2=h.P.getNAN(),this.m_shape=e}compare(e,t,s){this.m_shape.queryXY(t,this.pt1);const n=e.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class Pe{constructor(e){this.m_point=h.P.getNAN(),this.m_pt=h.P.getNAN(),this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){const s=e.getElement(t);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Ee{constructor(e,t){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new a.S(8),this.m_clusters=new a.S(5),this.m_clusterVertices=new Q(!1),this.m_edgeVertices=new Q(!1),this.m_helperPoint=new a.P,this.m_eventQ=new a.T,this.m_sweepStructure=new a.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 he,this.m_segBuf1=new o.S,this.m_segBuf2=new o.S,this.m_sweepPoint=new h.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=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){const s=new m.T;s.setSwapCoordinates(),e.applyTransformation(s),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let n=this.sweepImpl_();return e.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,o.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(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,s){this.m_edges.setField(e,0+t,s)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,s){this.m_edges.setField(e,3+t,s)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+s)}setNextEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+n,s)}getPrevEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+s)}setPrevEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+n,s)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){const t=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(t,s),e!==o.n&&(this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){const s=this.getClusterVertices(e);this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){const t=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,s),-1!==e&&this.m_edgeVertices.addElement(s,e),t}addVertexToEdge_(e,t){const s=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(s,t)}deleteEdge_(e){this.m_edges.deleteElement(e);const t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&(0,h.ay)(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){-1===this.getEdgeCluster(e,0)?this.setEdgeCluster_(e,0,t):-1===this.getEdgeCluster(e,1)?this.setEdgeCluster_(e,1,t):(0,i.d)(""),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){const s=this.getClusterFirstEdge(t);if(-1!==s){const n=this.getNextEdge(s,t);this.setPrevEdge_(n,t,e),this.setNextEdge_(e,t,n),this.setNextEdge_(s,t,e),this.setPrevEdge_(e,t,s)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);const s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1));let n=this.getClusterFirstEdge(e),r=this.getClusterFirstEdge(t);if(-1!==r){let s=r,i=r,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,t),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===e){this.disconnectEdge_(s);const e=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(s),s===a){r=-1;break}r===s&&(r=this.getClusterFirstEdge(t),i=a,o=!0)}s=a}while(s!==i||o);if(-1!==r){do{const n=this.getEdgeEnd(s,t),r=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,e),s=r}while(s!==i);if(n=this.getClusterFirstEdge(e),-1!==n){const t=this.getNextEdge(n,e),s=this.getNextEdge(r,e);t===n?(this.setClusterFirstEdge_(e,r),this.addEdgeToClusterImpl_(n,e),this.setClusterFirstEdge_(e,n)):s===r&&this.addEdgeToClusterImpl_(r,e),this.setNextEdge_(r,e,t),this.setPrevEdge_(t,e,r),this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n)}else this.setClusterFirstEdge_(e,r)}}const i=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(o);-1!==t;t=this.m_clusterVertices.getNext(t)){const s=this.m_clusterVertices.getElement(t);this.m_shape.setUserIndex(s,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(i,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);const s=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),a=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,a),t===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,e),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(s===r&&n===i||n===r&&s===i)){const e=this.getClusterXY(s),t=this.getClusterXY(r);e.isEqualPoint2D(t)?(s!==r&&this.mergeClusters_(s,r),n!==i&&this.mergeClusters_(n,i)):(n!==r&&this.mergeClusters_(n,r),s!==i&&this.mergeClusters_(s,i))}this.dbgCheckEdge_(e)}disconnectEdge_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,s)}disconnectEdgeFromCluster_(e,t){const s=this.getNextEdge(e,t),n=this.getPrevEdge(e,t),r=this.getClusterFirstEdge(t);s!==e?(this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n),r===e&&this.setClusterFirstEdge_(t,s)):this.setClusterFirstEdge_(t,-1)}applyIntersectorToEditShape_(e,t,s){let n=this.m_edgeVertices.getFirst(e);const r=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(r),o=this.m_shape.getNextVertex(r),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(r),m=this.m_shape.getXY(o);let l=!1,g=!1;const c=t.getResultSegment(s,0).getStartXY(),u=t.getResultSegment(s,t.getResultSegmentCount(s)-1).getEndXY();h.equals(c)||(l=!0),m.equals(u)||(g=!0),this.m_shape.splitSegmentWithIntersector(r,t,s,!0,!0);const _=this.m_bTrackChanges&&t.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(r,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const e=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(e)===i;this.m_shape.splitSegmentWithIntersector(e,t,s,r,!0),_&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(l&&this.updateClusterXY(!0,i,c,t.getResultSegmentStartPointWeight(s,0),t.getResultSegmentStartPointRank(s,0)),g){const e=t.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,u,t.getResultSegmentEndPointWeight(s,e),t.getResultSegmentEndPointRank(s,e))}}createEdgesAndClustersFromSplitEdge_(e,t,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(e),r=this.getEdgeCluster(e,0),i=this.getEdgeCluster(e,1);let o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);const h=a.S.impossibleIndex3();this.setEdgeSweepNode_(o,h),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,r);const m=t.getResultSegmentCount(s);for(let e=1;e<m;e++){const e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);const t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,h),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,i);for(let e=this.m_edgeVertices.getFirst(n);-1!==e;e=this.m_edgeVertices.getNext(e)){let t=this.m_edgeVertices.getElement(e);if(this.getClusterFromVertex(t)===r){let e=0;const s=this.m_tempEdgeBuffer.length;do{if(e>0){const s=this.m_tempEdgeBuffer[e-1];this.addVertexToCluster_(s,t)}const s=this.m_tempEdgeBuffer[e];e+=2,this.addVertexToEdge_(s,t),t=this.m_shape.getNextVertex(t)}while(e<s)}else{let e=this.m_tempEdgeBuffer.length-1;do{if(e<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[e+1];this.addVertexToCluster_(s,t)}const s=this.m_tempEdgeBuffer[e];e-=2,this.addVertexToEdge_(s,t),t=this.m_shape.getNextVertex(t)}while(e>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,s){const n=this.getEdgeCluster(t,0),r=this.getClusterXY(n),i=this.getEdgeCluster(t,1),o=this.getClusterXY(i),h=s.getResultSegmentCount(e);let m=s.getResultSegment(e,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 e=r.compare(o),t=m.getEndXY();(r.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(e,h-1);const g=m.getEndXY();o.isEqualPoint2D(g)||(this.m_bComplications||o.compare(this.m_sweepPoint)*g.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(i,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(i)),this.m_tempEdgeBuffer.push(t);for(let e=0,s=this.m_tempEdgeBuffer.length;e<s;e++){const s=this.m_tempEdgeBuffer[e],n=this.getEdgeSweepNode(s);a.S.isValidElement(n)&&(this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(s,-1));const r=a.S.impossibleIndex3();s!==t&&this.getEdgeSweepNode(s)!==r&&(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){const s=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,s,t),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0)}fixIntersection_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e),n=this.m_sweepStructure.getElement(t);let r=null,i=null;const o=this.getEdgeOriginVertices(s),a=this.m_edgeVertices.getFirstElement(o),h=this.getEdgeOriginVertices(n),m=this.m_edgeVertices.getFirstElement(h);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),g=this.m_shape.getWeight(a),c=this.m_shape.getSegmentParentageBreakVertex(a),u=this.m_shape.getWeight(l),_=this.m_shape.getSegmentParentageBreakVertex(l),p=this.m_shape.getSegmentWeight(a),d=this.m_shape.getRank(a),f=this.m_shape.getRank(l),x=this.m_shape.getSegmentRank(a),P=this.m_shape.getSegmentParentage(a);this.m_shape.querySegment(m,this.m_segBuf2,!1,!1),i=this.m_segBuf2.get();const E=this.m_shape.getNextVertex(m),y=this.m_shape.getWeight(m),S=this.m_shape.getSegmentParentageBreakVertex(m),C=this.m_shape.getWeight(E),I=this.m_shape.getSegmentParentageBreakVertex(E),v=this.m_shape.getSegmentWeight(m),b=this.m_shape.getRank(m),G=this.m_shape.getRank(E),w=this.m_shape.getSegmentRank(m),N=this.m_shape.getSegmentParentage(m);this.m_segmentIntersector.pushSegment(r,g,d,u,f,p,x,c,_,P),this.m_segmentIntersector.pushSegment(i,y,b,C,G,v,w,S,I,N),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,n,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t);let n=null;const r=this.getEdgeOriginVertices(s),i=this.m_edgeVertices.getFirstElement(r);this.m_shape.querySegment(i,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(i),a=this.m_shape.getWeight(i),h=this.m_shape.getSegmentParentageBreakVertex(i),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),g=this.m_shape.getSegmentWeight(i),c=this.m_shape.getRank(i),u=this.m_shape.getRank(o),_=this.m_shape.getSegmentRank(i),p=this.m_shape.getSegmentParentage(i),d=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(n,a,c,m,u,g,_,h,l,p),this.m_shape.queryPoint(d,this.m_helperPoint);const f=this.m_shape.getWeight(d),x=this.m_shape.getRank(d);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=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())||t>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);a.S.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==a.S.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(e),-1===s){const t=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(t);return this.mergeEdges_(s,e),!1}if(this.setEdgeSweepNode_(e,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,s),!0}return!1}isEdgeOnSweepLine_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1),n=this.getClusterXY(t),r=this.getClusterXY(s);if(h.P.sqrDistance(n,r)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const i=n.compare(this.m_sweepPoint),o=r.compare(this.m_sweepPoint);return i<=0&&o>0?s:o<=0&&i>0?t:i>0&&o>0?a.S.impossibleIndex2():-1}fillEventQueue(){const e=new a.a(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let s=t.next();s!==o.n;s=t.next())-1!==this.m_shape.getUserIndex(s,this.m_vertexClusterIndex)&&e.add(s);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(e.size()),this.m_eventQ.setComparator(new xe(this.m_shape));const s=h.P.getNAN();s.setNAN();let n=-1;for(let t=0,r=e.size();t<r;t++){const r=e.read(t);if(this.m_shape.getXY(r).isEqualPoint2D(s)){const e=this.m_shape.getUserIndex(r,this.m_vertexClusterIndex);this.mergeClusters_(n,e);continue}n=this.getClusterFromVertex(r),this.m_shape.queryXY(r,s);const i=this.m_eventQ.addBiggestElement(r);this.setClusterEventQNode_(n,i)}}fillEventQueuePass2(){const e=new a.a(0);for(let t=this.m_eventQ.getFirst();-1!==t;t=this.m_eventQ.getNext(t)){const s=this.m_eventQ.getElement(t);e.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,s=e.size();t<s;t++){const s=e.read(t),n=this.getClusterFromVertex(s),r=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,r)}}getAffectedEdges(e,t){const s=this.getClusterFirstEdge(e);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);a.S.isValidElement(s)&&t.push(n),n=this.getNextEdge(n,e)}while(n!==s)}updateClusterXY(e,t,s,n,r){const i=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(i);-1!==t;t=this.m_clusterVertices.getNext(t)){const i=this.m_clusterVertices.getElement(t);this.m_shape.setXYMonotonicPoint2D(i,s),this.m_shape.setWeight(i,n),this.m_shape.setRank(i,r),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}}splitEdge_(e,t,s,n){this.dbgCheckEdge_(e),-1!==t&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),-1!==t&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,n),-1!==t&&this.processSplitHelper1_(1,t,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){const t=this.m_modifiedClusters[e],s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1))}const r=this.getEdgeOriginVertices(e),i=-1!==t?this.getEdgeOriginVertices(t):-1;if(this.applyIntersectorToEditShape_(r,n,0),-1!==i)this.applyIntersectorToEditShape_(i,n,1);else{const e=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,e,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,n,0),-1!==t&&this.createEdgesAndClustersFromSplitEdge_(t,n,1),this.m_edgeVertices.deleteList(r),this.deleteEdge_(e),-1!==t&&(this.m_edgeVertices.deleteList(i),this.deleteEdge_(t));for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){const t=this.m_modifiedClusters[e];t===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let s=this.getClusterEventQNode(t);if(-1===s){const e=this.getClusterFirstVertex(t);if(s=this.m_eventQ.addUniqueElement(e),-1===s){const e=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(e),n=this.getClusterFromVertex(s);this.mergeClusters_(n,t)}else this.setClusterEventQNode_(t,s)}}this.m_modifiedClusters.length=0}getClusterXY(e){const t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new de(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const e=[];let t=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=a.S.impossibleIndex2(),r=a.S.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 t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===t,!a){let s=t;do{const t=this.getEdgeSweepNode(s);-1===t?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):t!==r&&e.push(t),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=1===e.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let t=0,s=e.length;t<s;t++){const s=this.m_sweepStructure.getElement(e[t]);this.setEdgeSweepNode_(s,n)}let t=n,s=n;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(t===n){const e=this.m_sweepStructure.getPrev(i);if(-1!==e){const s=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(s)!==n&&(t=e)}else t=-1}if(s===n){const e=this.m_sweepStructure.getNext(i);if(-1!==e){const t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==n&&(s=e)}else s=-1}if(t!==n&&s!==n)break}for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_sweepStructure.getElement(s);this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(n,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=s,-1!==t&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,s):-1===t&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===t&&(t=new fe(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.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 Pe(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_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==o.n;t=this.m_shape.getNextGeometry(t))if((0,i.h)(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==o.n;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===o.n)continue;let r=this.m_shape.getNextVertex(n);if(r===o.n||r===n)continue;let i=-1;e.selected(n)&&(i=this.newCluster_(n));let a=-1;-1!==i&&e.selected(r)&&(a=this.newEdge_(n),this.addEdgeToCluster(a,i));let h=a;for(let e=0,s=t-2;e<s;e++){const e=this.m_shape.getNextVertex(r);let t=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==h&&this.addEdgeToCluster(h,s),this.m_shape.selected(e)&&(t=this.newEdge_(r),this.addEdgeToCluster(t,s))}h=t,r=e}if(this.m_shape.isClosedPath(s)){const e=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const t=this.newCluster_(r);if(-1!==h&&this.addEdgeToCluster(h,t),this.m_shape.selected(e)){const e=this.newEdge_(r);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,i)}}}else{let e=-1;this.m_shape.selected(r)&&(e=this.newCluster_(r),-1!==h&&this.addEdgeToCluster(h,e))}}else for(let e=this.m_shape.getFirstPath(t);e!==o.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n;s++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function ye(e,t,s){return{vertex0:e,vertex1:t,dir:s}}class Se{constructor(e){this.m_shape=null,this.m_spikes=[],this.m_points=new a.a(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let s=e.getFirstPath(t);s!==o.n;s=e.getNextPath(s)){let t=e.getFirstVertex(s);for(let n=0,r=e.getPathSize(s);n<r;n++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let t=0,s=this.m_points.size();t<s;++t)e.setUserIndex(this.m_points.read(t),this.m_pointsIndex,t);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const n=e.getXY(s);let r=1,a=0;const h=[];for(let t=1;t<this.m_points.size();t++){const i=this.m_points.read(t);if(i===o.n)continue;if(-1===e.getUserIndex(i,this.m_pointsIndex))continue;const m=e.getXY(i);if(m.isEqualPoint2D(n))r++;else{if(r>1){for(let s=a;s<t;s++){const t=this.m_points.read(s);if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const r=e.getNextVertex(t),i=e.getPrevVertex(t);if(t!==r&&!e.isEqualXYPoint2D(r,n)){const e=ye(t,r,1);h.push(e)}if(t!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=ye(t,i,-1);h.push(e)}}h.length>0&&this.processBunch_(h,n)}s=i,n.assign(m),r=1,a=t}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let m=e.getPointCount(t);for(let t=0;t<this.m_points.size();t++){const s=this.m_points.read(t);if(s===o.n)continue;if(-1!==e.getUserIndex(s,this.m_pointsIndex)){e.setUserIndex(s,this.m_pointsIndex,-1);continue}const n=e.getPathFromVertex(s);e.getFirstVertex(n)===s&&e.setFirstVertex(n,o.n),e.freeVertex(s),this.m_points.write(t,o.n),m--}const l=e.createPathUserIndex();let g=e.getPathCount(t);for(let s=0,n=this.m_points.size();s<n;++s){if(this.m_points.read(s)===o.n)continue;let n=this.m_points.read(s);if(-1!==e.getUserIndex(n,this.m_pointsIndex))continue;let r=e.getPathFromVertex(n),a=-1;if(2===e.getPathUserIndex(r,l)){r=o.n;for(let t=e.getNextVertex(n);t!==n;t=e.getNextVertex(t)){const s=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(s,l)){r=s,n=t;break}}r===o.n&&(r=e.insertPath(t,o.n),e.setClosedPath(r,!0),g++),(0,i.g)(r!==o.n)}e.setPathUserIndex(r,l,2),a=e.getFirstVertex(r);let h=0,m=!1,c=n;do{a===c&&(m=!0),e.setUserIndex(c,this.m_pointsIndex,1);const t=e.getPathFromVertex(c);t!==r&&(2!==e.getPathUserIndex(t,l)&&(e.setPathUserIndex(t,l,1),e.setFirstVertex(t,o.n)),e.setPathToVertex(c,r)),h++,c=e.getNextVertex(c)}while(c!==n);m||e.setFirstVertex(r,n),e.setPathSize(r,h)}for(let s=e.getFirstPath(t);s!==o.n;){const t=e.getNextPath(s);1!==e.getPathUserIndex(s,l)&&e.getFirstVertex(s)!==o.n||(e.removePathOnly(s),g--),s=t}e.setGeometryVertexCount(t,m),e.setGeometryPathCount(t,g),e.removePathUserIndex(l),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,s)=>{const n=this.m_shape.getXY(e.vertex1).sub(t),r=this.m_shape.getXY(s.vertex1).sub(t),i=h.P.compareVectors(n,r);return 0===i?e.dir<s.dir?-1:1:i});let s=0;const n=this.m_shape.getXY(e[0].vertex1);let r=1;const i=this.m_shape.hasCurves();for(let t=1,o=e.length;t<o;t++){const a=this.m_shape.getXY(e[t].vertex1);if(!(a.isEqualPoint2D(n)&&(r++,t+1<o))){if(2===r){const t=e[s],n=e[s+1],r=t.dir;if(r!==n.dir){let e=!0;if(i&&(e=!this.m_shape.isCurve(1===t.dir?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),e){if(1===r){const e=t.vertex0,s=n.vertex0;this.m_shape.setNextVertex(e,s),this.m_shape.setPrevVertex(s,e),this.m_shape.getPrevVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setPrevVertex(r,i),this.m_shape.setNextVertex(i,r),this.m_shape.getNextVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}else{const e=t.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(s,e),this.m_shape.getNextVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setNextVertex(r,i),this.m_shape.setPrevVertex(i,r),this.m_shape.getPrevVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(a),s=t,r=1}}e.length=0}}function Ce(e){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))if((0,i.h)(e.getGeometryType(t)))return!0;return!1}function Ie(e,t,s,n,r){if(!Ce(t))return!1;let i=new be(r);if(i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n,i.needsCrackingImpl_())return n&&n.assign(i.m_nonSimpleResult),!0;const o=new m.T;o.setSwapCoordinates(),t.applyTransformation(o),i=new be(r),i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n;const a=i.needsCrackingImpl_();return t.applyTransformation(o),!!a&&(n&&n.assign(i.m_nonSimpleResult),!0)}function ve(e,t){return{t:e,index:t}}class be{crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){const t=new m.T;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1;const t=new o.S,s=new o.S,n=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty(),m=!1,l=new a.P,g=new he,c=this.m_shape.getTotalPointCount(),u=c*c*2,_=this.m_shape.queryVertexIteratorOnSelection();for(let r=_.next();r!==o.n;r=_.next()){const a=this.m_shape.getGeometryType(_.currentGeometry());let c=1,p=1,d=1,f=0,x=0,P=0;const E=this.m_shape.getSegmentParentage(r);let y=!1,S=!1,C=null,I=!1;if((0,i.e)(a))c=this.m_shape.getWeight(r),f=this.m_shape.getRank(r);else{if(C=this.getSegment_(r,t),null===C)continue;const e=this.m_shape.getVertexIndex(r);c=this.m_shape.getWeightWithIndex(e),f=this.m_shape.getRankWithIndex(e),d=this.m_shape.getSegmentWeightWithIndex(e),P=this.m_shape.getSegmentRankWithIndex(e),y=this.m_shape.getSegmentParentageBreakVertex(r);{const e=this.m_shape.getNextVertex(r);p=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(n),n.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const v=new o.X({copy:_});let b=v.next();b!==o.n&&(b=v.next());let G=0;for(;b!==o.n;b=v.next()){if(0!==G){G--;continue}if(this.m_shape.getTotalPointCount()>u)return e;this.progress_();const a=this.m_shape.getGeometryType(v.currentGeometry());let w=null,N=!1,T=0,D=0,V=0,k=0,F=0,H=0,A=!1,M=!1;const U=this.m_shape.getSegmentParentage(b);if((0,i.e)(a))T=this.m_shape.getWeight(b),k=this.m_shape.getRank(b);else{if(w=this.getSegment_(b,s),null===w)continue;const e=this.m_shape.getVertexIndex(b);T=this.m_shape.getWeightWithIndex(e),k=this.m_shape.getRankWithIndex(e),V=this.m_shape.getSegmentWeightWithIndex(e),H=this.m_shape.getSegmentRankWithIndex(e),A=this.m_shape.getSegmentParentageBreakVertex(b);{const e=this.m_shape.getNextVertex(b);D=this.m_shape.getWeight(e),F=this.m_shape.getRank(e),M=this.m_shape.getSegmentParentageBreakVertex(e)}if(w.queryLooseEnvelope(h),w.isDegenerate(this.m_tolerance)){if(!w.isDegenerate(0))continue;N=!0,w=null}}let q=0,O=0;if(null!==C&&null!==w)n.isIntersectingNe(h)&&0!==(0,o.Y)(!0,!0,C,w,this.m_tolerance,!0)&&(g.pushSegment(C,c,f,p,x,d,P,y,S,E),g.pushSegment(w,T,k,D,F,V,H,A,M,U),g.intersect2D(this.m_tolerance,!0),e||=g.getSegmentChanged(0)||g.getSegmentChanged(1),q=g.getResultSegmentCount(0),O=g.getResultSegmentCount(1),q+O>0&&(this.m_shape.splitSegmentWithIntersector(r,g,0,!0,!0),this.m_shape.splitSegmentWithIntersector(b,g,1,!0,!0),this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(r,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(b,!0))),O>1&&(G+=O-1),g.clear());else if(null!==C){const t=this.m_shape.getXY(b);if(n.contains(t)){if(g.pushSegment(C,c,f,p,x,d,P,y,S,E),this.m_shape.queryPoint(b,l),g.intersect2DEx(this.m_tolerance,l,k,T,m),e||=g.getSegmentChanged(0)||g.getResultPointChanged(),q=g.getResultSegmentCount(0),q>0)if(this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(r,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(b,!0)),this.m_shape.splitSegmentWithIntersector(r,g,0,!0,!0),N){let e=o.n;for(let t=this.m_shape.getNextVertex(b);t!==o.n&&t!==b&&(w=this.getSegment_(t,s),e=t,null!=w&&w.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=b;t!==o.n&&(this.m_shape.setPoint(t,g.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(b,g.getResultPoint(),!0);g.clear()}}else{if(null===w)continue;{const t=this.m_shape.getXY(r);if(h.inflateCoords(this.m_tolerance,this.m_tolerance),h.contains(t)){if(g.pushSegment(w,T,k,D,F,V,H,A,M,U),this.m_shape.queryPoint(r,l),g.intersect2DEx(this.m_tolerance,l,f,c,m),e||=g.getSegmentChanged(0)||g.getResultPointChanged(),O=g.getResultSegmentCount(0),O>0)if(this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(b,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(r,!0)),this.m_shape.splitSegmentWithIntersector(b,g,0,!0,!0),G+=O-1,I){let e=o.n;for(let t=this.m_shape.getNextVertex(r);t!==o.n&&t!==r&&(w=this.getSegment_(t,s),e=t,null!=w&&w.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=r;t!==o.n&&(this.m_shape.setPoint(t,g.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(r,g.getResultPoint(),!0);g.clear()}}}if(q+O!==0&&0!==q){let e=!1;for(;C=this.getSegment_(r,t),null!=C&&(C.queryEnvelope(n),C.isDegenerate(this.m_tolerance));){if(!(q>1)){e=!0;break}r=_.next(),q--,(0,i.g)(r!==o.n)}if(e)break}}}return e}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Ee(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1;const t=new a.a(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let e=0,n=s.next();n!==o.n;++e,n=s.next())t.write(e,n);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(o.n);const n=this.m_shape.createUserIndex(),r=this.m_shape.createUserIndex();this.m_sweepComparator=new $(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let m=null;const l=[],g=[];let c=0;const u=new h.P;for(let s=t.read(c++);s!==o.n;){this.m_shape.queryXY(s,u);let a=!1;do{let e=this.m_shape.getNextVertex(s),i=this.m_shape.getPrevVertex(s);a||=e!==o.n||i!==o.n,e===o.n||this.m_shape.selected(e)||(e=o.n),i===o.n||this.m_shape.selected(i)||(i=o.n),e!==o.n&&this.m_shape.compareVerticesSimpleY(s,e)<0&&(g.push(s),g.push(e)),i!==o.n&&this.m_shape.compareVerticesSimpleY(s,i)<0&&(g.push(i),g.push(i));const h=this.m_shape.getUserIndex(s,n);-1!==h&&(l.push(h),this.m_shape.setUserIndex(s,n,-1));const m=this.m_shape.getUserIndex(s,r);-1!==m&&(l.push(m),this.m_shape.setUserIndex(s,r,-1)),s=t.read(c++)}while(s!==o.n&&this.m_shape.isEqualXYPoint2D(s,u));if(!a&&(null===m&&(m=new ee(this.m_shape,this.m_tolerance)),m.setPoint(u),this.m_sweepStructure.searchUpperBound(m),m.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&((0,i.d)("needsCrackingIMpl_"),this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1));break}let p=1===l.length&&2===g.length;const d=32;l.length>d&&(0,h.v)(l);let f=-1,x=-1;if(!p)for(let t=0,s=l.length;t<s;t++){const s=l[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===l.indexOf(n))if(-1===f)f=n;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1)}const r=this.m_sweepStructure.getNext(s);if(-1!==r&&-1===l.indexOf(r))if(-1===x)x=r;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1)}if(-1!==f&&-1!==x)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(u.y,u.x),!p){for(let e=0,t=l.length;e<t;e++){const t=l[e];this.m_sweepStructure.deleteNode(t)}l.length=0}if(!p&&-1!==f&&-1!==x&&this.checkForIntersections_(f,x)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,s=g.length;t<s;t+=2){const s=g[t],i=g[t+1];let o;if(p?(o=this.m_sweepStructure.replaceElementAtPosition(l[0],s,!0,!0),l.length=0,p=!1):o=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}-1===this.m_shape.getUserIndex(i,n)?this.m_shape.setUserIndex(i,n,o):this.m_shape.setUserIndex(i,r,o)}if(e)break;g.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(r),e}checkForIntersections_(e,t){const s=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,s,t);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(e,t){return be.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,s){return e.querySegment(t,s,!1,!1)?s.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,s){const n=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(n);const m=r.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(m),m.inflateCoords(s,s),!m.isIntersecting(n))return e;const l=e.getImpl(),g=l.getAccelerators();let c=null,u=null;g&&(u=g.getQuadTree()),function(e,t){const s=e.getPointCount();if(s<16)return!1;return 2*s+Math.log(s)/Math.log(2)*1*t<1*s*t}(e,(0,i.v)(t))&&(c=(0,a.H)(l,m),u=c);const _=u?u.getIteratorForQT():null,p=t.querySegmentIterator(),d=e.querySegmentIterator(),f=(0,h.d)(15,Number.NaN),x=[];for(;p.nextPath();)for(;p.hasNextSegment();){const e=p.nextSegment();if(u){_.resetIterator(e,s);for(let t=_.next();-1!==t;t=_.next()){this.progress_();const n=u.getElement(t);if(d.resetToVertex(n,-1),d.hasNextSegment()){const t=d.nextSegment().intersect(e,null,f,null,s);for(let e=0;e<t;e++){const t=f[e];if(0===t||1===t)continue;const s=ve(t,d.getStartPointIndex());x.push(s)}}}}else{const t=r.Envelope2D.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(s,s),!n.isIntersecting(t))continue;for(d.resetToFirstPath();d.nextPath();)for(;d.hasNextSegment();){const n=d.nextSegment(),i=r.Envelope2D.constructEmpty();if(n.queryLooseEnvelope(i),!i.isIntersecting(t))continue;const o=n.intersect(e,null,f,null,s);for(let e=0;e<o;e++){const t=f[e];if(0===t||1===t)continue;const s=ve(t,d.getStartPointIndex());x.push(s)}}}}if(0===x.length)return e;x.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:e.t>t.t?1:0);const P=e.createInstance();for(P.getGeometryType()===i.G.enumPolygon&&P.setFillRule(e.getFillRule()),d.resetToFirstPath();d.nextPath()&&!d.hasNextSegment(););(0,i.g)(d.hasNextSegment());let E=d.nextSegment();const y=new o.S;let S=-1;for(let e=0,t=x.length;e<t;){const s=x[e].index;let n=e+1;for(;n<t&&x[n].index===s;)++n;for(;d.getStartPointIndex()<s;){this.progress_();const e=d.hasNextSegment(),t=d.getPathIndex();if((e||!d.isClosingSegment()||d.isCurve())&&((0,i.g)(null!==E),P.addSegment(E,S!==t)),S=t,!e){for(d.isPathClosed();d.nextPath()&&!d.hasNextSegment(););(0,i.g)(d.hasNextSegment())}E=d.nextSegment()}let r=0;for(let t=e;t<n;t++){const e=x[t].t;if(e===r)continue;(0,i.g)(null!==E),E.queryCut(r,e,y),r=e;const s=d.getPathIndex();P.addSegment(y.get(),S!==s),S=s}const o=d.hasNextSegment();if((o||!d.isClosingSegment()||d.isCurve())&&((0,i.g)(null!=E),E.queryCut(r,1,y),P.addSegment(y.get(),!1)),o)E=d.nextSegment();else{for(;d.nextPath()&&!d.hasNextSegment(););E=d.hasNextSegment()?d.nextSegment():null}e=n}if(null!==E){const e=d.getPathIndex();(d.hasNextSegment()||!d.isClosingSegment()||d.isCurve())&&P.addSegment(E,S!==e),S=e}let C=d.hasNextSegment();for(;;){if(!C){for(;d.nextPath()&&(C=d.hasNextSegment(),!C););if(!C)break}E=d.nextSegment();const e=d.getPathIndex();C=d.hasNextSegment(),(C||!d.isClosingSegment()||d.isCurve())&&P.addSegment(E,S!==e),S=e}return P}constructor(e){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new _.NonSimpleResult,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 a.T,this.m_progressTracker=e}}be.s_bForceBruteForce=!0;class Ge{constructor(e,t){this.m_monotoneParts=(0,h.m)(o.S,16),this.m_xOrds=(0,h.d)(16,Number.NaN),this.m_inputPoint=h.P.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY())))return void(this.m_bBreak=!0);if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const t=Math.min(e.getStartX(),e.getEndX()),s=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let t=!1;const s=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>s)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){const n=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);t=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){const t=e.getClosestCoordinate(this.m_inputPoint,!1),s=e.getCoord2D(t);return h.P.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){const t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let s=0;if(e.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=e.getMonotonicParts(this.m_monotoneParts,!0),(0,i.g)(this.m_monotoneParts.length>=s)),s>0)for(let e=0;e<s;e++){const t=this.m_monotoneParts[e].get(),s=h.E.construct(t.getStartY(),t.getEndY());if(!(s.vmin>this.m_inputPoint.y||s.vmax<this.m_inputPoint.y)&&(this._DoOne(t),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return(0,i.g)(0),2}}function we(e,t,s){if(e.isEmpty())return 0;const n=r.Envelope2D.constructEmpty();if(e.queryLooseEnvelope(n),n.inflateCoords(s,s),!n.contains(t))return 0;const o=e.getImpl().getAccelerators();if(o){o.getRasterizedGeometry()&&(0,i.g)(0);const n=o.getQuadTree();if(n)return function(e,t,s,n){const i=new r.Envelope2D;e.queryLooseEnvelope(i),i.inflateCoords(n,n);const o=0===e.getFillRule(),a=new Ge(o,n);a.setInputPoint(s);const h=i.clone();h.xmax=s.x+n,h.ymin=s.y-n,h.ymax=s.y+n;const m=e.getImpl().querySegmentIterator(),l=t.getIterator(h,n);for(let e=l.next();-1!==e;e=l.next())if(m.resetToVertex(t.getElement(e),-1),m.hasNextSegment()){const e=m.nextSegment();if(a.processSegment(e))return-1}return a._Result()?1:0}(e,n,t,s)}return function(e,t,s){const n=0===e.getFillRule(),r=new Ge(n,s);r.setInputPoint(t);const i=e.getImpl().querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(r.processSegment(e))return-1}return r._Result()?1:0}(e,t,s)}function Ne(e,t){const s=e.getPointCount();return!(s<16)&&2*s+Math.log(s)/Math.log(2)*1*t<1*s*t}class Te{getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?s:t}constructor(e){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),s=this.getEnd2(e);this.m_shape.getPrevVertex(t)===s&&(s=(0,h.c)(t,t=s));const n=h.P.getNAN(),r=h.P.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),(0,i.g)(!n.equals(r)),n.y<r.y}getStart(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?t:s}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(-1!==this.m_firstFree){const t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}const t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let De=class extends a.a6{constructor(e){super(),this.m_line1=new o.L,this.m_line2=new o.L,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges;let o;this.m_leftElm===t?o=this.m_leftx:(this.m_seg1=r.getSegment(t),this.m_seg1?o=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,o=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=o,this.m_leftElm=t);let a,h=r.getSegment(n);if(h?a=h.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(n),this.m_line2,!0),h=this.m_line2,a=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),o===a){const e=r.isBottomUp(t),s=r.isBottomUp(n),m=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=s?h.getEndY():h.getStartY(),g=Math.min(m,l);let c=.5*(g+this.m_helper.m_yScanline);c===this.m_helper.m_yScanline&&(c=g),o=this.m_seg1.intersectionOfYMonotonicWithAxisX(c,0),a=h.intersectionOfYMonotonicWithAxisX(c,0),o===a&&(0,i.w)("")}return o<a?-1:o>a?1:0}reset(){this.m_leftElm=-1}};class Ve{constructor(e){this.m_node=-1,this.m_index=0,this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const e=this.m_node;if(-1===e)return o.n;const t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){const e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return o.n}}class ke{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new a.T,this.m_yScanline=0,this.m_geometry=o.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=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new De(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const e=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||(this.m_edges=new Te(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let s=0,n=e.length;s<n;s++)-1!==e[s]&&t++;(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let t=0,s=e.length;t<s;t++){const s=e[t];s!==o.n&&this.insertEdge_(s,-1)}for(let e=0;e<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;e++){const s=this.m_unknownNodes[e],n=this.m_AET.getElement(s),r=this.m_edges.getPath(n),h=this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex);let m=o.n;if(0===h){let e=this.m_AET.getPrev(s),n=s,r=!1;for(;e!==a.T.st_nullNode();){const t=this.m_AET.getElement(e),s=this.m_edges.getPath(t);if(0!==this.m_shape.getPathUserIndex(s,this.m_pathOrientationIndex)){m=s;break}n=e,e=this.m_AET.getPrev(e)}if(e===a.T.st_nullNode())r=!0,e=n;else{const t=this.m_AET.getElement(e);r=this.m_edges.isBottomUp(t),e=this.m_AET.getNext(e),r=!r}do{const s=this.m_AET.getElement(e),o=this.m_edges.getPath(s);if(0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(s)){const e=this.m_shape.getFirstVertex(o);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(o,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(o,this.m_pathOrientationIndex,r?3:2),!r){let e=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex);2===e?(m=this.m_shape.getPathUserIndex(m,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex),(0,i.g)(3===e)):(0,i.g)(3===e);const t=this.m_shape.getPathUserIndex(m,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(m,this.m_pathParentageIndex,o),this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(o,this.m_pathParentsIndex,m)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}m=o,n=e,e=this.m_AET.getNext(e),r=!r}while(n!==s)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),r=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const e=this.m_AET.getElement(n);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==r){const e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let i=-1;-1!==n&&-1!==r?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(r),e[t]=o.n):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=o.n)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=h.P.getNAN(),n=h.P.getNAN();this.m_shape.queryXY(e,s);const r=this.m_shape.getNextVertex(e);this.m_shape.queryXY(r,n);let i=!1;if(s.y<n.y){i=!0;const s=this.m_edges.newEdge(e);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s)),-1===this.m_shape.getUserIndex(r,this.m_node1UserIndex)?this.m_shape.setUserIndex(r,this.m_node1UserIndex,n):this.m_shape.setUserIndex(r,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,n),s.y<n.y){i=!0;const s=this.m_edges.newEdge(o);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s)),-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,n):this.m_shape.setUserIndex(o,this.m_node2UserIndex,n);const r=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return i}fixRingSelfTangency_(){const e=[],t=[];let s=-1,n=-1;const r=new h.P;let a=o.n,m=o.n,l=-1;const g=new Ve(this);for(let i=g.next();i!==o.n;i=g.next()){const o=new h.P;this.m_shape.queryXY(i,o);const g=this.m_shape.getPathFromVertex(i);r.equals(o)&&m===g?(-1===n&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),n=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,n,-1)),-1===l&&(l=t.length,this.m_shape.setUserIndex(a,n,l),t.push(1),-1===this.m_shape.getPathUserIndex(g,s)&&(this.m_shape.setPathUserIndex(g,s,a),e.push(g))),this.m_shape.setUserIndex(i,n,l),t[t.length-1]++):(l=-1,r.assign(o)),a=i,m=g}if(0===e.length)return!1;(0,i.g)(-1!==s);for(let r=0,i=e.length;r<i;r++){const i=e[r];let o=this.m_shape.getPathUserIndex(i,s);const a=this.m_shape.getUserIndex(o,n),h=[],m=[];h.push(o),m.push(a);for(let e=this.m_shape.getNextVertex(o);e!==o;e=this.m_shape.getNextVertex(e)){const s=e,r=this.m_shape.getUserIndex(s,n);if(-1!==r){if(0===m.length){m.push(r),h.push(s);continue}if(m.at(-1)===r){const i=h.at(-1);this.m_shape.peelALoopIntoAPath(i,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,m.pop(),h.pop()),o=i,e=i}else h.push(e),m.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const e={stack:[],error:void 0,hasError:!1};try{let t,s=!1;const r=(0,n.mS)(e,(0,h.h)(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new a.a(0);for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e)){let s=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)t.add(s),s=this.m_shape.getNextVertex(s)}this.m_shape.sortVerticesSimpleByY(t,0,e),this.progress_(!0),this.m_sortedVerticesArray=t}else r.bForget=!0;if(this.m_bFixSelfTangency&&(s=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){const t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!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 e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const m=h.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 l=new Ve(this);for(let e=l.next();e!==o.n&&(this.progress_(),this.m_shape.queryXY(e,m),m.y!==this.m_yScanline&&i.length&&(s=this.processBunchForRingOrientationTest_(i)||s,this.m_sweepComparator.reset(),i.length=0),i.push(e),this.m_yScanline=m.y,0!==this.m_unknownRingOrientationCount);e=l.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(i)||s,i.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==o.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){this.m_shape.setExterior(t,!0);for(let s=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);s!==o.n;){const n=this.m_shape.getPathUserIndex(s,this.m_pathParentageIndex);e.push(s),this.m_shape.setExterior(s,!1),this.m_shape.setPathUserIndex(s,this.m_pathParentageIndex,t),s=n}let s=t,n=e.length;for(let e=this.m_shape.getNextPath(t);n>0&&e!==o.n;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=o.n;break}s=e}if(0!==n){s=t;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,a.a7),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}e.length=0,t=this.m_shape.getNextPath(s)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const e=this.m_shape.createPathUserIndex();let t=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==o.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,e,t),t++;for(let e=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e!==o.n;){const t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,n),e=t}let r=n,i=s.length,h=t;for(let t=this.m_shape.getNextPath(n);i>0&&t!==o.n;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=o.n;break}r=t,this.m_shape.setPathUserIndex(t,e,-h),h++}if(0!==i){r=n,h=t;for(let t=0,n=s.length;t<n;t++){const n=s[t];this.m_shape.setPathUserIndex(n,e,-h),h++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,a.a7)}r=n}t=h,s.length=0,n=this.m_shape.getNextPath(r)}else n=this.m_shape.getNextPath(n);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function Fe(e,t,s,n,r,i){const o=new He(i);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=r,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class He{constructor(e){this.m_shape=null,this.m_geometry=o.n,this.m_sortedVertices=new a.R,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_sorterSegmentBuffer1=null,this.m_sorterSegmentBuffer2=null,this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=o.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=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=new h.P;this.m_shape.queryXY(s,n);const r=new h.P,o=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(o,r),n.equals(r))return 0;const a=this.m_bunchEdgeCenterPoints[e],m=new h.P;this.m_shape.queryXY(a,m);const l=this.m_bunchEdgeCenterPoints[t],g=new h.P;this.m_shape.queryXY(l,g);const c=new h.P;c.setSub(n,m);const u=new h.P;return u.setSub(r,g),(c.isZero()||u.isZero())&&(0,i.w)(""),h.P.compareVectors(c,u)}compareAnglesCurves_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeEndPoints[t],r=this.m_bunchEdgeCenterPoints[e],i=this.m_bunchEdgeCenterPoints[t],a=this.m_shape.getNextVertex(r)===s,h=this.m_shape.getNextVertex(i)===n,m=a?this.m_shape.isCurve(r):this.m_shape.isCurve(s),l=h?this.m_shape.isCurve(i):this.m_shape.isCurve(n);return m||l?(this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new o.S),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new o.S),a?this.m_shape.querySegment(r,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(s,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),h?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse()),(0,o.R)(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())):this.compareAnglesLines_(e,t)}beforeRemoveVertex_(e,t){const s=this.m_shape.getUserIndex(e,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_(e),t){const t=this.m_shape.getPathFromVertex(e);if(t!==o.n&&this.m_shape.getFirstVertex(t)===e){const s=this.m_shape.getNextVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s);{const s=this.m_shape.getPrevVertex(e);if(s!==e&&this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s)}}this.m_shape.setFirstVertex(t,o.n),this.m_shape.setLastVertex(t,o.n)}}}processBunch_(){let e=!1;const t=new h.P(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,n=0,r=!0;for(;s!==this.m_nextVertexToProcess;){const e=this.m_sortedVertices.getData(s);r&&(this.m_shape.queryXY(e,t),r=!1);const i=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex)!==a.a7&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,a.a7),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==a.a7&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,a.a7),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),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((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e],s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,e)}const i=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e];if(-1===t)continue;const s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!i)break;e=!0}return e}processCrossOvers_(e){let t=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,o=this.m_bunchEdgeIndices.length;i<o&&-1!==n&&-1!==r&&n!==r;i++){const i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[r],a=this.m_bunchEdgeEndPoints[i],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a),l=!0);let g=this.m_shape.getNextVertex(h),c=!1;this.m_shape.isEqualXYPoint2D(g,e)||(g=this.m_shape.getPrevVertex(h),c=!0);const u=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=c?this.m_shape.getPrevVertex(g):this.m_shape.getNextVertex(g);let p=!1;(this.removeSpike_(m)||this.removeSpike_(g)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(u)||this.removeSpike_(_))&&(p=!0),m!==g&&(!p&&this.m_shape.isEqualXY(a,h)&&(p=this.resolveOverlap_(l,c,m,a,g,h)),!p&&this.m_shape.isEqualXY(u,_)&&(p=this.resolveOverlap_(!l,!c,m,u,g,_)),!p&&this.m_shape.isEqualXY(a,_)&&(p=this.resolveOverlap_(l,!c,m,a,g,_)),!p&&this.m_shape.isEqualXY(u,h)&&(p=this.resolveOverlap_(!l,c,m,u,g,h))),p&&(t=!0),s||=p,n=p?this.getNextEdgeIndex_(n):r,r=this.getNextEdgeIndex_(n)}}if(!t){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let r=0,i=this.m_bunchEdgeIndices.length;r<i&&-1!==s&&-1!==n&&s!==n;r++){const r=this.m_bunchEdgeIndices[s],i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[r],a=this.m_bunchEdgeEndPoints[i];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),g=this.getDirection_(m,a),c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),u=g?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,g,o,h,c,a,m,u);1!==_?0===_?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):t=!0}}return t}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===i.G.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)&&new ks(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const t=this.m_shape.getPointCount(this.m_geometry),s=new a.a(0);this.m_shape.dbgVerifyMonotone();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(s,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let e=0;e<t;e++){const t=s.read(e),n=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,t);this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,n)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let n=0,r=!1;do{r=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new h.P(0,0);this.m_firstCoincidentVertex!==a.R.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,o=this.m_firstCoincidentVertex;for(;o!==a.R.st_nullNode()&&(o=this.m_sortedVertices.getNext(o),o!==a.R.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(o),n=h.P.getNAN();if(this.m_shape.queryXY(e,n),t.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=o;const e=this.processBunch_();o=this.m_nextVertexToProcess,o!==a.R.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(o),n),e&&(r=!0)}t.setCoordsPoint2D(n),this.m_firstCoincidentVertex=o,s=0}}this.m_nextVertexToProcess=-1,s>0&&this.processBunch_()&&(r=!0),n++>10&&(0,i.d)(""),r&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(r=!0),e||=r}while(r);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=function(e,t,s,n,r){const i=new ke(r);return i.m_shape=e,i.m_geometry=t,i.m_sortedVertices=s,i.m_bFixSelfTangency=n,i.fixRingOrientation_()}(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,s,n,r,i,o,a){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(i),-1;const m=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),g=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),c=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),u=(0,h.d)(8,Number.NaN),_=(0,h.d)(4,Number.NaN);u[0]=0,_[0]=m,u[1]=0,_[1]=l,u[2]=1,_[2]=g,u[3]=1,_[3]=c;for(let e=1;e<4;e++){const t=_[e],s=u[e];let n=e-1;for(;n>=0&&_[n]>t;)_[n+1]=_[n],u[n+1]=u[n],n--;_[n+1]=t,u[n+1]=s}let p=0;if(u[0]&&(p|=1),u[1]&&(p|=2),u[2]&&(p|=4),u[3]&&(p|=8),5!==p&&10!==p)return 0;if(e!==t&&(a=(0,h.c)(i,i=a)),e)this.m_shape.setNextVertex(a,n),this.m_shape.setPrevVertex(n,a),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,n),this.m_shape.setNextVertex(n,a),this.m_shape.setPrevVertex(r,o),this.m_shape.setNextVertex(o,r),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const r=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,r),this.m_shape.setSegmentToIndex(t,s)}}return 1}resolveOverlap_(e,t,s,n,r,i){return this.resolveOverlapOddEven_(e,t,s,n,r,i)}resolveOverlapOddEven_(e,t,s,n,r,i){if(e!==t){e||(r=(0,h.c)(s,s=r),i=(0,h.c)(n,n=i));const t=this.m_shape.getNextVertex(r),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,t),this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(s),t=this.m_shape.getVertexIndex(r),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(s),t=this.m_shape.getSegmentParentage(r);this.m_shape.setSegmentParentageAndBreak(s,t,!0),this.m_shape.setSegmentParentageAndBreak(r,e,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}this.removeSpike_(r)}else{const o=e?s:n,a=t?r:i,h=e?n:s,m=t?i:r;let l=null;if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);const t=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(t,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let g=-1;this.m_bHasSegmentParentage&&(g=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 u=m;for(;u!==a;){const e=this.m_shape.getPrevVertex(u),t=this.m_shape.getNextVertex(u);if(this.m_shape.setPrevVertex(u,t),this.m_shape.setNextVertex(u,e),c||=u===o,this.m_bHasSegments&&u!==o){const e=this.m_shape.getVertexIndex(t),s=l;l=this.m_shape.getSegmentFromIndex(e),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(e,s)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,g),g=e}u=t}let _=null;if(!c){const e=this.m_shape.getPrevVertex(a),t=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,t),this.m_shape.setNextVertex(a,e),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let p=-1,d=-1;if(this.m_bHasSegmentParentage&&(p=c?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),d=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,p,!0),this.m_shape.setSegmentParentageAndBreak(h,d,!0)),_){const e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,_)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==o.n;){const s=this.m_shape.getNextPath(t);let n=this.m_shape.getFirstVertex(t);for(let s=0,r=this.m_shape.getPathSize(t);s<r&&r>1;){this.progress_();const{v:i,bModified:a}=this.checkAndCleanupSpike_(t,n);if(i===o.n)break;a?(e=!0,n=i,s=0,r=this.m_shape.getPathSize(t)):(n=i,s++)}t=s}return e}checkAndCleanupSpike_(e,t){const s={v:o.n,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=o.n,a=o.n;for(;this.m_shape.isEqualXY(n,r)&&(i=n,a=r,r!==t);)n=this.m_shape.getPrevVertex(n),r=this.m_shape.getNextVertex(r);if(i===o.n)return s.v=r,s;s.bModified=!0;for(let e=this.m_shape.getNextVertex(i);this.beforeRemoveVertex_(e,!1),e!==a;e=this.m_shape.getNextVertex(e));if(i===t)return this.m_polylineDegeneracies!==o.n?this.m_shape.movePath(this.m_polylineDegeneracies,o.n,e):this.m_shape.removePath(e),s.v=o.n,s;{const e=this.m_shape.peelALoopIntoAPath(i,a);this.m_polylineDegeneracies!==o.n?this.m_shape.movePath(this.m_polylineDegeneracies,o.n,e):this.m_shape.removePath(e)}return s.v=i,s}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(e),n=o.n,r=o.n;for(;this.m_shape.isEqualXY(t,s)&&(n=t,r=s,s!==e);)t=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(s);if(n===o.n)return!1;if(this.m_shape.peelALoop(n,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===o.n)for(let e=this.m_shape.getNextVertex(r);;){const t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(e),null),this.m_shape.removeVertexInternal(e,!1),e===r)break;e=t}else{for(let e=r;;){const t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!1),e=t,e===r)break}const e=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,o.n,r,r,e)}return!0}fixOrphanVertices_(){let e=0;for(let e=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==e;e=this.m_sortedVertices.getNext(e)){const t=this.m_sortedVertices.getData(e);this.m_shape.setPathToVertex(t,o.n)}let t=0;for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==o.n;){const n=this.m_shape.getFirstVertex(s);if(n===o.n||this.m_shape.getPathFromVertex(n)!==o.n){const e=s;s=this.m_shape.getNextPath(s),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(n,s);let r=1;for(let e=this.m_shape.getNextVertex(n);e!==n;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,s),r++;this.m_shape.setRingAreaValid(s,!1),this.m_shape.setPathSize(s,r),this.m_shape.setLastVertex(s,this.m_shape.getPrevVertex(n)),t+=r,e++,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 n=this.m_sortedVertices.getData(s);if(this.m_shape.getPathFromVertex(n)!==o.n)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,o.n,n,n,r);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let s=0;for(let e=this.m_shape.getFirstGeometry();e!==o.n;e=this.m_shape.getNextGeometry(e))s+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}getPrevEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}transferVertexData_(e,t){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(e){const t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);-1!==t&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function Ae(e,t,s,n,m,l=!0){switch(Me(n)){case 0:break;case 1:(0,i.a)("relation string length has to be 9 characters");break;default:(0,i.a)("relation string")}if(l){const r=function(e,t,s){return function(e){return"T*F**FFF*"===e}(e)?3:function(e){return"FF*FF****"===e}(e)?4:function(e,t,s){return!(0===t&&0===s||(2===t&&2===s?"F***T****"!==e:2!==t&&1!==t||0!==s||"F**T*****"!==e))}(e,t,s)?8:function(e,t,s){return t>s?"T*****T**"===e:1===t&&1===s&&"0********"===e}(e,t,s)?16:function(e){return"T**FF*FF*"===e}(e)?64:function(e){return"T*****FF*"===e}(e)?1:function(e,t,s){return t===s&&(1!==t?"T*T***T**"===e:"1*T***T**"===e)}(e,t,s)?32:0}(n,e.getDimension(),t.getDimension());if(0!==r)return $e(e,t,s,r,m)}let g=0;if("number"==typeof s)g=s;else{const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n);const i=r.Envelope2D.constructEmpty();t.queryEnvelope(i);const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(i),g=(0,a.d)(s,o,!1)}const c=je(e,g),u=je(t,g);if(c.isEmpty()||u.isEmpty())return function(e,t,s){const n=(0,h.d)(9,-1);if(e.isEmpty()&&t.isEmpty())return Xe(n,s);let a,m=!1;e.isEmpty()?(a=t,m=!0):a=e,n[0]=-1,n[1]=-1,n[3]=-1,n[4]=-1,n[6]=-1,n[7]=-1,n[8]=2;const l=a.getGeometryType();if((0,i.h)(l))if(l===i.G.enumPolygon)if(0!==a.calculateArea2D())n[2]=2,n[5]=1;else{n[5]=-1;const e=r.Envelope2D.constructEmpty();a.queryEnvelope(e),n[2]=e.height()||e.width()?1:0}else{const e=0!==a.calculateLength2D();n[2]=e?1:0,n[5]=(0,o.K)(a)?0:-1}else n[2]=0,n[5]=-1;return m&&We(n),Xe(n,s)}(c,u,n);const _=c.getGeometryType(),p=u.getGeometryType();let d=!1;switch(_){case i.G.enumPolygon:switch(p){case i.G.enumPolygon:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaAreaPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaAreaDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPolyline:d=Ue(c,u,g,n,m);break;case i.G.enumPoint:d=Ye(c,u,g,n);break;case i.G.enumMultiPoint:d=qe(c,u,g,n,m)}break;case i.G.enumPolyline:switch(p){case i.G.enumPolygon:d=Ue(u,c,g,Ze(n),m);break;case i.G.enumPolyline:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setLineLinePredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.lineLineDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),Le(r,h.m_topoGraph,h.m_clusterIndexA),Le(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPoint:d=Be(c,u,g,n,m);break;case i.G.enumMultiPoint:d=Oe(c,u,g,n,m)}break;case i.G.enumPoint:switch(p){case i.G.enumPolygon:d=Ye(u,c,g,Ze(n));break;case i.G.enumPolyline:d=Be(u,c,g,Ze(n),m);break;case i.G.enumPoint:d=function(e,t,s,n){const r=e.getXY(),i=t.getXY(),o=(0,h.d)(9,-1);return h.P.sqrDistance(r,i)<=s*s?o[0]=0:(o[2]=0,o[6]=0),o[8]=2,Xe(o,n)}(c,u,g,n);break;case i.G.enumMultiPoint:d=Re(u,c,g,Ze(n))}break;case i.G.enumMultiPoint:switch(p){case i.G.enumPolygon:d=qe(u,c,g,Ze(n),m);break;case i.G.enumPolyline:d=Oe(u,c,g,Ze(n),m);break;case i.G.enumMultiPoint:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setPointPointPredicates_();const m=new r.Envelope2D,l=new r.Envelope2D;e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.pointPointDisjointPredicates_(),g=!0),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPoint:d=Re(c,u,g,n)}break;default:d=!1}return d}function Me(e){if(9!==e.length)return 1;for(let t=0;t<9;t++){const s=e[t];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function Ue(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaLinePredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaLineDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),Le(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function qe(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaPointPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaPointDisjointPredicates_(e),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function Oe(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setLinePointPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.linePointDisjointPredicates_(e),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),Le(r,h.m_topoGraph,h.m_clusterIndexA),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function Ye(e,t,s,n,i){const o=new ze;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a);const h=t.getXY();let m=!1;if(nt(h,a,s)&&(o.areaPointDisjointPredicates_(e),m=!0),!m){const t=es(e,h,s);if(1===t)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===t)if(o.m_matrix[6]=-1,0!==e.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 t=r.Envelope2D.constructEmpty();e.queryEnvelope(t),o.m_matrix[2]=t.height()||t.width()?1:-1}else o.areaPointDisjointPredicates_(e)}return Xe(o.m_matrix,n)}function Be(e,t,s,n,i){const a=new ze;a.resetMatrix_(),a.setPredicates_(n),a.setLinePointPredicates_();const h=r.Envelope2D.constructEmpty();e.queryEnvelope(h);let m=!1;if(nt(t.getXY(),h,s)&&(a.linePointDisjointPredicates_(e),m=!0),!m){let n=null,r=!1,h=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&($e(e,t,s,4,i)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(n=(0,o.c)(e),h=!$e(n,t,s,4,i),r=!0,a.m_matrix[0]=h?-1:0),a.m_matrix[6]=-1)),a.m_performPredicates[3]&&(null!==n&&n.isEmpty()?a.m_matrix[3]=-1:(r||(null==n&&(n=(0,o.c)(e)),h=!$e(n,t,s,4,i),r=!0),a.m_matrix[3]=h?0:-1)),a.m_performPredicates[5])if(null!==n&&n.isEmpty())a.m_matrix[5]=-1;else if(r&&!h)a.m_matrix[5]=0;else{null===n&&(n=(0,o.c)(e));const r=$e(n,t,s,3,i);a.m_matrix[5]=r?-1:0}if(a.m_performPredicates[2])if(0!==e.calculateLength2D())a.m_matrix[2]=1;else{const n=new o.M({vd:e.getDescription()});n.addPoints(e,0,e.getPointCount());const r=$e(n,t,s,3,i);a.m_matrix[2]=r?-1:0}}return Xe(a.m_matrix,a.m_scl)}function Re(e,t,s,n,i){const o=new ze;o.resetMatrix_(),o.setPredicates_(n),o.setPointPointPredicates_();const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a);const m=t.getXY(),l=new h.P;let g=!1;if(nt(m,a,s)&&(o.pointPointDisjointPredicates_(),g=!0),!g){let t=!1,n=!0;const r=s*s;for(let s=0;s<e.getPointCount()&&(e.queryXY(s,l),h.P.sqrDistance(l,m)<=r?t=!0:n=!1,!t||n);s++);t?(o.m_matrix[0]=0,o.m_matrix[2]=n?-1:0,o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[2]=0,o.m_matrix[6]=0)}return Xe(o.m_matrix,n)}function Xe(e,t){for(let s=0;s<9;s++)switch(t[s]){case"T":if(-1===e[s])return!1;break;case"F":if(-1!==e[s])return!1;break;case"0":if(0!==e[s])return!1;break;case"1":if(1!==e[s])return!1;break;case"2":if(2!==e[s])return!1}return!0}function Le(e,t,s){const n=t.getGeometryID(e);for(let e=t.getFirstCluster();e!==o.n;e=t.getNextCluster(e)){if(0===(t.getClusterParentage(e)&n))continue;const r=t.getClusterHalfEdge(e);if(r===o.n){t.setClusterUserIndex(e,s,0);continue}let i=r,a=0;do{const e=i;0!==(t.getHalfEdgeParentage(e)&n)&&a++,i=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(i!==r);t.setClusterUserIndex(e,s,a)}}class ze{nullFunc(){return(0,i.d)("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new K,this.m_matrix=(0,h.d)(9,0),this.m_maxDim=(0,h.d)(9,0),this.m_performPredicates=(0,h.d)(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_(e){this.m_scl=e;for(let e=0;e<9;e++)"*"!==this.m_scl[e]?(this.m_performPredicates[e]=!0,this.m_predicateCount++):this.m_performPredicates[e]=!1}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&-2===this.m_matrix[e]&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return!(-2===this.m_matrix[e]||(-1===this.m_matrix[e]?(this.m_performPredicates[e]=!1,this.m_predicateCount--,0):"T"!==this.m_scl[e]&&"F"!==this.m_scl[e]&&this.m_matrix[e]<this.m_maxDim[e]||(this.m_performPredicates[e]=!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_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,s,n,i){const o=-1!==t,a=-1!==n;if(o||a)if(("T"!==s&&"F"!==s&&o||"T"!==i&&"F"!==i&&a)&&0===e.calculateArea2D()){if(a&&(this.m_matrix[n]=-1),o){const s=r.Envelope2D.constructEmpty();e.queryEnvelope(s),this.m_matrix[t]=s.height()||s.width()?1:0}}else o&&(this.m_matrix[t]=2),a&&(this.m_matrix[n]=1)}areaAreaContainsPredicates_(e){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_(e,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(e){this.areaAreaContainsPredicates_(e),We(this.m_matrix)}areaLineDisjointPredicates_(e,t){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 e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=(0,o.K)(t);this.m_matrix[7]=e?0:-1}this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){const e=this.m_scl[0],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const e=(0,o.K)(t);this.m_matrix[1]=e?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_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){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_(e,t){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 t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=(0,o.K)(e);this.m_matrix[5]=t?0:-1}if(this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=(0,o.K)(t);this.m_matrix[7]=e?0:-1}}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=(0,o.K)(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,s,3);const t=this.isPredicateKnown_(3);n&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,s);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,s,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,s,t,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(7);n&&=r}return n}lineLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,s,t,this.m_clusterIndexB,this.m_clusterIndexA,3);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,s,this.m_clusterIndexA,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,s,t,this.m_clusterIndexB,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(6);n&&=r}return n}pointPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}return n}interiorAreaInteriorArea_(e,t,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(n&t)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(e,t,s,n){if(2===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(n&t)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(e),r=this.m_topoGraph.getClusterParentage(n);if(0!==(r&t)&&0!==(r&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(r&s)&&0===(i&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(e,t,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[1]=0)}}}interiorAreaExteriorLine_(e,t,s){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getHalfEdgeParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,s,n){if(1===this.m_matrix[3])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(r&t)||0===(r&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(e,t,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);0!==(n&t)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(e),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(s&t)&&0===(n&t)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)&&0===(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[7]=0)}}}interiorLineInteriorLine_(e,t,s,n,r){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(i&t)||0===(i&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2==0&&t%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(e,t,s,n,r,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&t)&&0!==(a&s)){const e=this.m_topoGraph.getClusterUserIndex(o,n),t=this.m_topoGraph.getClusterUserIndex(o,r);if(e%2==0&&t%2!=0)return void(this.m_matrix[i]=0)}}}interiorLineExteriorLine_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(e,t,s,n,r){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2!=0&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(e,t,s,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const t=this.m_topoGraph.getHalfEdgeTo(e);if(0===(this.m_topoGraph.getClusterParentage(t)&s)&&this.m_topoGraph.getClusterUserIndex(t,n)%2!=0)return void(this.m_matrix[r]=0)}}interiorAreaInteriorPoint_(e,t){if(0!==this.m_matrix[0]&&0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0!==(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(e,t){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(e,t){1!==this.m_matrix[5]&&0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(0!==this.m_matrix[6]&&0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0===(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[0])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0===(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2!=0||(this.m_matrix[0]=0)}interiorLineExteriorPoint_(e,t,s,n){if(1!==this.m_matrix[2])if(-1===this.m_topoGraph.getClusterHalfEdge(e)){if(0!==this.m_matrix[2]&&0===(this.m_topoGraph.getClusterParentage(e)&s))return void(this.m_matrix[2]=0)}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[3])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0===(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2==0||(this.m_matrix[3]=0)}boundaryLineExteriorPoint_(e,t,s,n){if(0===this.m_matrix[5])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2==0||(this.m_matrix[5]=0)}exteriorLineInteriorPoint_(e,t,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(e);0!==(n&t)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(e,t,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(e,t,s,n){if(0===this.m_matrix[n])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(e,n,r),s))break;continue}let i=t;do{let e=i;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(e,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==i&&!s);if(s)break;i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(i!==t);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);for(let e=this.m_topoGraph.getFirstCluster();e!==o.n&&(s=this.m_predicatesCluster(e,n,r),!s);e=this.m_topoGraph.getNextCluster(e));s||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,s){let n=0;if(e.hasCurves()){const r=new cs,i=e.getEnvelope2D(s),o=ms(t.total(),i);n=gs(o,0),os(e,o,t.total(),0,r,null,s),r.clearStitcher(e)}_s(e,t.add(n),s,!1,!1),e.filterClosePoints(0,!0,!0,!1,o.n);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,!1,o.n,s);this.setEditShape_(e,s)}}function We(e){const t=e[1],s=e[2],n=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=s,e[7]=n}function je(e,t,s){const n=e.getGeometryType();if((0,i.f)(n)){const t=new o.a({vd:e.getDescription()});return t.addSegment(e,!0),t}if(n===i.G.enumEnvelope){const s=e,n=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),n.height()<=t&&n.width()<=t){const t=new a.P({vd:e.getDescription()});return s.getCenter(t),t}if(n.height()<=t||n.width()<=t){const t=new o.a({vd:e.getDescription()}),n=new a.P;return s.queryCornerByVal(0,n),t.startPathPoint(n),s.queryCornerByVal(2,n),t.lineToPoint(n),t}const i=new o.P({vd:e.getDescription()});return i.addEnvelope(s,!1),i}return e}function Ze(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Ke{nullFunc(){return(0,i.d)("should not be called"),!1}constructor(e,t,s,n=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=r.Envelope2D.constructEmpty(),this.m_envInter=r.Envelope2D.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const o=e.getAccelerators();let h=null;null!=o&&(h=n?o.getQuadTreeForPaths():o.getQuadTree());const m=t.getAccelerators();let l=null;if(null!=m&&(l=n?m.getQuadTreeForPaths():m.getQuadTree()),null===h&&null===l&&!n){const n=e.getPointCount(),o=t.getPointCount();if(n>10&&o>10){const m=r.Envelope2D.constructEmpty(),g=r.Envelope2D.constructEmpty(),c=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(m),t.queryLooseEnvelope(g),m.inflateCoords(s,s),g.inflateCoords(s,s),c.setCoords({env2D:m}),c.intersect(g),n>=o?h=(0,i.h)(e.getGeometryType())?(0,a.H)(e,c):(0,a._)(e,c):l=(0,i.h)(t.getGeometryType())?(0,a.H)(t,c):(0,a._)(t,c)}}this.construct_(e,h,t,l,s,n)}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,i.h)(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,i.h)(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,i.q)(""),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,i.q)(""),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_(e,t,s,n,o,h){const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(m),s.queryLooseEnvelope(l),m.inflateCoords(o,o),l.inflateCoords(o,o),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=s;const g=e.getGeometryType(),c=s.getGeometryType();this.m_bPaths=h,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.G.enumUnknown,this.m_bQuadTree=!1,null!==t&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,(0,i.h)(c)?(this.m_queryType=c,this.m_function=this.nextPath_,h?this.m_pathIndex=s.getPathCount():this.m_segIter=s.querySegmentIterator()):(this.m_queryType=c,this.m_function=this.nextPoint_,this.m_pointIndex=s.getPointCount())),this.m_bQuadTree||null!==n&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=n,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,(0,i.h)(g)?(this.m_queryType=g,this.m_function=this.nextPath_,h?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=g,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(h&&(0,i.h)(g)&&(0,i.h)(c)?this.m_intersector=(0,a.a2)(e,s,o):(0,i.h)(g)&&(0,i.h)(c)?(this.m_intersector=(0,a.$)(e,s,o),this.m_bSwapElements=!1):(0,i.h)(g)&&!(0,i.h)(c)?(this.m_intersector=(0,a.a0)(e,s,o),this.m_bSwapElements=!1):!(0,i.h)(g)&&(0,i.h)(c)?(this.m_intersector=(0,a.a0)(s,e,o),this.m_bSwapElements=!0):(this.m_intersector=(0,a.a1)(e,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 e=this.m_segIter.nextSegment(),t=new r.Envelope2D;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const e=new h.P;if(this.m_bSwapElements){const t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{const t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(r.Envelope2D.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&((0,i.h)(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Qe(e){return 2===e?1:1===e?2:128===e?64:64===e?128:e}function Je(e,t,s){let n;if(e instanceof io||null===e){const i=r.Envelope2D.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(s),n=(0,a.d)(e,i,!1)}else n=e;return n}function $e(e,t,s,n,m){if(e.isEmpty()||t.isEmpty())return 4===n;(0,i.c)(e),(0,i.c)(t);let g=e.getGeometryType(),c=t.getGeometryType();if(g===i.G.enumEnvelope){if(c===i.G.enumEnvelope)return function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return 4===n;const i=r.Envelope2D.constructEmpty();e.queryEnvelope(i);const o=r.Envelope2D.constructEmpty();t.queryEnvelope(o);const a=Je(s,i,o);switch(n){case 4:return tt(i,o,a);case 2:return Tt(o,i,a,!1);case 128:return Tt(o,i,a,!0);case 1:return Tt(i,o,a,!1);case 64:return Tt(i,o,a,!0);case 3:return Nt(i,o,a);case 8:return function(e,t,s){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;const n=new r.Envelope2D;return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.intersect(t),!(!n.isEmpty()&&n.height()>s&&n.width()>s||(n.setCoords({env2D:e}),n.inflateCoords(s,s),n.intersect(t),n.isEmpty()))}(i,o,a);case 32:return function(e,t,s){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;if(kt(e,t,s))return!1;if(kt(t,e,s))return!1;const n=new r.Envelope2D;return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.intersect(t),!n.isEmpty()&&(n.height()>s||n.width()>s)}(i,o,a);case 16:return!1}return!1}(e,t,s,n);if(c===i.G.enumPoint)return et(t,e,s,Qe(n))}else if(g===i.G.enumPoint){if(c===i.G.enumEnvelope)return et(e,t,s,n);if(c===i.G.enumPoint)return function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=t.getXY();let m;if(s instanceof io||null===s){const e=r.Envelope2D.constructEmpty();e.setCoords({pt:i}),e.merge(o),m=(0,a.d)(s,e,!1)}else m=s;switch(n){case 4:return function(e,t,s){return h.P.sqrDistance(e,t)>s*s}(i,o,m);case 2:case 128:return wt(o,i,m);case 1:case 64:return wt(i,o,m);case 3:return Gt(i,o,m)}return!1}(e,t,s,n)}const u=r.Envelope2D.constructEmpty();e.queryEnvelope(u);const _=r.Envelope2D.constructEmpty();t.queryEnvelope(_);const p=Je(s,u,_);if(tt(u,_,p))return 4===n;let d=!1,f=null,x=null,P=null,E=null;switch((0,i.f)(g)?(f=new o.a({vd:e.getDescription()}),f.addSegment(e,!0),P=f,g=i.G.enumPolyline):P=e,(0,i.f)(c)?(x=new o.a({vd:t.getDescription()}),x.addSegment(t,!0),E=x,c=i.G.enumPolyline):E=t,g!==i.G.enumEnvelope&&c!==i.G.enumEnvelope?(P.getDimension()<E.getDimension()||g===i.G.enumPoint&&c===i.G.enumMultiPoint)&&(n=Qe(n)):g!==i.G.enumPolygon&&c!==i.G.enumEnvelope&&(n=Qe(n)),g){case i.G.enumPolygon:switch(c){case i.G.enumPolygon:d=function(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return st(e,t,0,!0),1===Dt(e,t,s,!0)}(e,t,s);case 2:return _t(t,e,s,r);case 128:return pt(t,e,s);case 1:return _t(e,t,s,r);case 64:return pt(e,t,s);case 3:return ut(e,t,s,r);case 8:return function(e,t,s){return st(e,t),Lt(e,t,s,null)}(e,t,s);case 32:return function(e,t,s,n){return st(e,t),zt(e,t,s,n)}(e,t,s,r)}return!1}(P,E,p,n,m);break;case i.G.enumPolyline:d=rt(P,E,p,n,m);break;case i.G.enumPoint:d=it(P,E,p,n);break;case i.G.enumMultiPoint:d=ot(P,E,p,n);break;case i.G.enumEnvelope:d=at(P,E,p,n,m)}break;case i.G.enumPolyline:switch(c){case i.G.enumPolygon:d=rt(E,P,p,n,m);break;case i.G.enumPolyline:d=function(e,t,s,n,i){switch(n){case 4:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl();return!new Ke(n,r,s,!0).next()||!Ot(e,t,s)}(e,t,s);case 2:return Et(t,e,s,i);case 128:return yt(t,e,s,i);case 1:return Et(e,t,s,i);case 64:return yt(e,t,s,i);case 3:return function(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!Nt(i,o,s)&&(st(e,t),!!At(e,t,s)||(e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"**F**FFF*",n,!1):Ut(e,t,s,!1)))}(e,t,s,i);case 8:return function(e,t,s,n){st(e,t);const i=[],a=Yt(e,t,s,i);if(-2===a){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=(0,l.c)(e,a,s,0,n),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=(0,l.c)(t,a,s,0,n),m.isEmpty())return!1}else m=t;return Ae(h,m,s,"F********",n,!1)}if(0!==a)return!1;const h=new o.M;for(let e=0;e<i.length;e+=2){const t=i[e],s=i[e+1];h.addXY(t,s)}const m=e.getBoundary(),g=t.getBoundary();return m.addPoints(g,0,g.getPointCount()),!m.isEmpty()&&Ct(m,h,s)}(e,t,s,i);case 32:return function(e,t,s,n){st(e,t);const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=Ht(i,o,s),h=Ht(o,i,s),m=e.hasNonLinearSegments(),g=t.hasNonLinearSegments(),c=Yt(e,t,s,null);if(-1===c)return!1;if(1===c){if(a&&h)return!0;if(!m&&!g)return a&&!h?!qt(t,e,s,!1):h&&!a?!qt(e,t,s,!1):!qt(e,t,s,!1)&&!qt(t,e,s,!1)}const u=r.Envelope2D.constructEmpty(),_=r.Envelope2D.constructEmpty(),p=r.Envelope2D.constructEmpty();let d,f;u.setCoords({env2D:i}),u.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:o}),_.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:u}),p.intersect(_);let x="";if(x+="1*",a){if(t.getPointCount()>10){if(f=(0,l.c)(t,p,s,0,n),f.isEmpty())return!1}else f=t;x+="****"}else f=t,x+="T***";if(h){if(e.getPointCount()>10){if(d=(0,l.c)(e,p,s,0,n),d.isEmpty())return!1}else d=e;x+="***"}else d=e,x+="T**";return Ae(d,f,s,x,n,!1)}(e,t,s,i);case 16:return function(e,t,s,n){st(e,t);const i=[],a=Yt(e,t,s,i);if(-2===a){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=(0,l.c)(e,a,s,0,n),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=(0,l.c)(t,a,s,0,n),m.isEmpty())return!1}else m=t;return Ae(h,m,s,"0********",n,!1)}if(0!==a)return!1;const h=new o.M;for(let e=0;e<i.length;e+=2){const t=i[e],s=i[e+1];h.addXY(t,s)}const m=e.getBoundary(),g=t.getBoundary();return m.addPoints(g,0,g.getPointCount()),!!m.isEmpty()||!Ct(m,h,s)}(e,t,s,i)}return!1}(P,E,p,n,m);break;case i.G.enumPoint:d=ht(P,E,p,n);break;case i.G.enumMultiPoint:d=mt(P,E,p,n);break;case i.G.enumEnvelope:d=lt(P,E,p,n,m)}break;case i.G.enumPoint:switch(c){case i.G.enumPolygon:d=it(E,P,p,n);break;case i.G.enumPolyline:d=ht(E,P,p,n);break;case i.G.enumMultiPoint:d=gt(E,P,p,n)}break;case i.G.enumMultiPoint:switch(c){case i.G.enumPolygon:d=ot(E,P,p,n);break;case i.G.enumPolyline:d=mt(E,P,p,n);break;case i.G.enumMultiPoint:d=function(e,t,s,n){switch(n){case 4:return function(e,t,s){const n=e,r=t,i=new Ke(n,r,s,!1),o=s*s,a=new h.P,m=new h.P;for(;i.next();){const e=i.getRedElement(),t=i.getBlueElement();if(n.queryXY(e,a),r.queryXY(t,m),h.P.sqrDistance(a,m)<=o)return!1}return!0}(e,t,s);case 2:case 128:return Ct(t,e,s);case 1:case 64:return Ct(e,t,s);case 3:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!!Nt(n,i,s)&&(!!function(e,t,s){if(e.getPointCount()!==t.getPointCount())return!1;const n=new h.P,r=new h.P;let i=!0;const o=s*s;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,n),t.queryXY(s,r),h.P.sqrDistance(n,r)>o){i=!1;break}return!!i}(e,t,s)||Mt(e,t,s,!1,!0,!1))}(e,t,s);case 32:return function(e,t,s){return Mt(e,t,s,!1,!1,!0)}(e,t,s)}return!1}(P,E,p,n);break;case i.G.enumPoint:d=gt(P,E,p,n);break;case i.G.enumEnvelope:d=ct(P,E,p,n)}break;case i.G.enumEnvelope:switch(c){case i.G.enumPolygon:d=at(E,P,p,n,m);break;case i.G.enumPolyline:d=lt(E,P,p,n,m);break;case i.G.enumMultiPoint:d=ct(E,P,p,n)}}return d}function et(e,t,s,n,i){if(e.isEmpty()||t.isEmpty())return 4===n;const o=e.getXY(),h=r.Envelope2D.constructEmpty();t.queryEnvelope(h);const m=function(e,t,s){let n;if(e instanceof io||null===e){const i=r.Envelope2D.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(s),n=(0,a.d)(e,i,!1)}else n=e;return n}(s,o,h);switch(n){case 4:return nt(o,h,m);case 2:case 128:return function(e,t,s){if(t.height()<=s||t.width()<=s)return!1;const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.containsExclusive(e)}(o,h,m);case 1:case 64:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D;return n.setCoords({pt:e}),Nt(n,t,s)}(o,h,m);case 8:return function(e,t,s){if(t.height()<=s||t.width()<=s)return!1;const n=new r.Envelope2D,i=new r.Envelope2D;return n.setCoords({env2D:t}),n.inflateCoords(s,s),!!n.contains(e)&&(i.setCoords({env2D:t}),i.inflateCoords(-s,-s),!i.containsExclusive(e))}(o,h,m)}return!1}function tt(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!e.isIntersecting(n)}function st(e,t,s,n=!1){const r=e.getGeometryType(),o=t.getGeometryType();if((0,i.i)(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();(0,i.g)(null===e)}}if((0,i.i)(o)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();(0,i.g)(null===t)}}return 0}function nt(e,t,s,n){const i=r.Envelope2D.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(s,s),!i.contains(e)}function rt(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t,0,!0),1===Dt(e,t,s,!0)}(e,t,s);case 1:return function(e,t,s,n){const i=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(h),!!kt(i,h,s)&&(st(e,t),function(e,t,s,n){const i=[!1],h=Vt(e,t,s,i);if(i[0])return h;const m=r.Envelope2D.constructEmpty();let g;if(t.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(g=(0,l.c)(e,m,s,0,n),g.isEmpty())return!1}else g=e;return function(e,t,s,n){const i=new ze;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaLinePredicates_();const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let l=!1;if(tt(h,m,s)&&(i.areaLineDisjointPredicates_(e,t),l=!0),l||st(e,t),l)return Xe(i.m_matrix,i.m_scl);const g=new o.E,c=g.addGeometry(e),u=g.addGeometry(t);return i.setEditShapeCrackAndCluster_(g,new a.C(s,0),n),0!==g.getPointCount(c)&&(i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape(),Xe(i.m_matrix,i.m_scl))}(g,t,s,n)}(e,t,s,n))}(e,t,s,i);case 64:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!!kt(n,i,s)&&(st(e,t),2===Dt(e,t,s,!1))}(e,t,s);case 8:return dt(e,t,s,i);case 16:return function(e,t,s){return st(e,t),function(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),m=o.querySegmentIterator(),g=(0,h.d)(2,Number.NaN),c=(0,h.d)(2,Number.NaN),u=new Ke(i,o,s);let _=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();a.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=a.nextSegment(),r=m.nextSegment();let i=0;if(Kt(n,r)?!_&&r.isIntersecting(n,s)&&(_=!0):i=r.intersect(n,null,c,g,s),2===i)_=!0;else if(i){const e=g[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return!0;_=!0}}if(!_)return!1;const p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty(),f=r.Envelope2D.constructEmpty(),x=r.Envelope2D.constructEmpty(),P=r.Envelope2D.constructEmpty();if(e.queryEnvelope(p),t.queryEnvelope(d),Ht(d,p,s)){let r,i;if(f.setCoords({env2D:p}),f.inflateCoords(1e3*s,1e3*s),x.setCoords({env2D:d}),x.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:f}),P.intersect(x),e.getPointCount()>10){if(r=(0,l.c)(e,P,s,0,n),r.isEmpty())return!1}else r=e;if(t.getPointCount()>10){if(i=(0,l.c)(t,P,s,0,n),i.isEmpty())return!1}else i=t;return Ae(r,i,s,"T********",n,!1)}return Ae(e,t,s,"T*****T**",n,!1)}(e,t,s,null)}(e,t,s)}return!1}function it(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return 0===$t(e,t,s)}(e,t,s);case 1:case 64:return function(e,t,s){return function(e,t,s){return 1===es(e,t,s)}(e,t.getXY(),s)}(e,t,s);case 8:return function(e,t,s){return function(e,t,s){return 2===es(e,t,s)}(e,t.getXY(),s)}(e,t,s)}return!1}function ot(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t),1===function(e,t,s){const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n),n.inflateCoords(s,s);const i=new h.P,a=e.getImpl(),m=new o.P;let l=e,g=!1,c=!1,u=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,i),n.contains(i)){const e=es(l,i,s);if(1===e)return c=!0,4;if(2===e)return 4;u=!0}else u=!0;g||(!Ne(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return c?u?4:2:1}(e,t,s)}(e,t,s);case 1:return ft(e,t,s,!1);case 64:return ft(e,t,s,!0);case 8:return function(e,t,s){st(e,t);const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n),n.inflateCoords(s,s);const i=new h.P;let a=!1;const m=e.getImpl(),l=new o.P;let g=e,c=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,i),n.contains(i)){const e=es(g,i,s);if(2===e)a=!0;else if(1===e)return!1}c||(!Ne(e,t.getPointCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),c=!0)}return!!a}(e,t,s);case 16:return function(e,t,s){st(e,t);const n=new r.Envelope2D,i=new r.Envelope2D,a=new r.Envelope2D;e.queryEnvelope(n),t.queryEnvelope(a),i.setCoords({env2D:n}),i.inflateCoords(s,s);let m=!1,l=!1;const g=new h.P,c=e.getImpl(),u=new o.P;let _=e,p=!1;for(let n=0;n<t.getPointCount();n++){if(t.queryXY(n,g),i.contains(g)){const e=es(_,g,s);0===e?l=!0:1===e&&(m=!0)}else l=!0;if(m&&l)return!0;p||(!Ne(e,t.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),_=u),p=!0)}return!1}(e,t,s)}return!1}function at(e,t,s,n,i){if(function(e,t,s){st(e,t);const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!kt(i,n,s)&&0===es(e,i.getLowerLeft(),0)&&!i.contains(e.getXY(0))&&!Xt(e,i,s)}(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return xt(e,t,s,!1);case 128:return xt(e,t,s,!0);case 1:return Pt(e,t,s,!1,i);case 64:return Pt(e,t,s,!0,i);case 3:return function(e,t,s,n){const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),!Nt(i,a,s))return!1;const h=new o.P;return h.addEnvelope(t,!1),ut(e,h,s,n)}(e,t,s,i);case 8:return function(e,t,s,n){st(e,t);const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),kt(a,i,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new o.P;return h.addEnvelope(t,!1),Lt(e,h,s,n)}(e,t,s,i);case 32:return function(e,t,s,n){st(e,t);const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),kt(a,i,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new o.P;return h.addEnvelope(t,!1),zt(e,h,s,n)}(e,t,s,i);case 16:return!1}return!1}function ht(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return st(e,t),!Rt(e,t.getXY(),s)}(e,t,s);case 1:case 64:return function(e,t,s){return st(e,t),function(e,t,s){return Rt(e,t,s)&&!Zt(e,t,s)}(e,t.getXY(),s)}(e,t,s);case 8:return function(e,t,s){return st(e,t),Zt(e,t.getXY(),s)}(e,t,s)}return!1}function mt(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t),!Bt(e,t,s,!1)}(e,t,s);case 1:case 64:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),t.queryEnvelope(i),!kt(n,i,s))return!1;st(e,t);const o=Bt(e,t,s,!0);if(!o)return o;const a=e.getBoundary();return a.isEmpty()?o:!Ct(a,t,s)}(e,t,s);case 8:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl(),i=new o.M,a=new Ke(n,r,s,!1),h=n.querySegmentIterator();let m=!1;for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();h.resetToVertex(e,-1);const n=h.nextSegment(),o=r.getXY(t);n.isIntersectingPoint(o,s)&&(m=!0,i.addPoint2D(o))}if(!m)return!1;const l=e.getBoundary();return!l.isEmpty()&&Ct(l,i,s)}(e,t,s);case 16:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl(),i=r.getPointCount(),a=(0,h.d)(i,!1),m=new Ke(n,r,s,!1),l=n.querySegmentIterator();let g=!1;for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();l.resetToVertex(e,-1);const n=l.nextSegment(),i=r.getXY(t);n.isIntersectingPoint(i,s)&&(g=!0,a[t]=!0)}if(!g)return!1;let c=!1;for(let e=0;e<i;e++)if(!a[e]){c=!0;break}if(!c)return!1;const u=e.getBoundary();if(u.isEmpty())return!0;const _=new o.M;for(let e=0;e<i;e++)a[e]&&_.addPoint2D(r.getXY(e));return!Ct(u,_,s)}(e,t,s)}return!1}function lt(e,t,s,n,a){if(function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();e.queryEnvelope(n),t.queryEnvelope(i);const o=function(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)?1073741824:n.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}(i,n,s);return 0===o?!Xt(e,i,s):4===o}(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return St(e,t,s,!1);case 128:return St(e,t,s,!0);case 1:case 64:case 32:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;return e.queryEnvelope(n),t.queryEnvelope(i),!(i.height()>s&&i.width()>s)&&Nt(n,i,s)}(e,t,s);case 8:return function(e,t,s,n){const a=new r.Envelope2D,m=new r.Envelope2D;if(e.queryEnvelope(a),t.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;const l=new r.Envelope2D,g=new r.Envelope2D;if(l.setCoords({env2D:m}),g.setCoords({env2D:m}),l.inflateCoords(s,s),g.inflateCoords(-s,-s),g.containsEnvelope(a)||!a.isIntersecting(l))return!1;const c=e.getImpl().querySegmentIterator();c.stripAttributes();const u=e.getImpl().getAccelerators();let _=null,p=null;null!==u&&(_=u.getQuadTree(),null!==_&&(p=_.getIterator(m,s))),p||c.nextPath()||(0,i.d)("relational_operations");let d=!1,f=null;const x=new h.P,P=new h.P,E=e.hasNonLinearSegments();let y=!1;for(;;){if(null!==p){const e=p.next();if(-1===e)break;c.resetToVertex(_.getElement(e),-1),f=c.nextSegment()}else{for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;f=c.nextSegment()}if(E&&f.getGeometryType()!==i.G.enumLine){const e=new r.Envelope2D;if(f.queryEnvelope(e),g.containsEnvelope(e))return!1;if(l.isIntersecting(e)){y=!0;break}}else{x.assign(f.getStartXY()),P.assign(f.getEndXY());let e=g.clipLine(x,P);if(0!==e)return!1;d||(e=l.clipLine(x,P),0!==e&&(d=!0))}}if(!y)return d;const S=new o.P;return S.addEnvelope(m,!1),dt(S,e,s,n)}(e,t,s,a);case 16:return function(e,t,s){const n=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(n),t.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;const m=new r.Envelope2D;if(m.setCoords({env2D:a}),m.inflateCoords(s,s),m.containsEnvelope(n))return!1;const l=new r.Envelope2D;if(l.setCoords({env2D:a}),l.inflateCoords(-s,-s),!l.isIntersecting(n))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const c=e.getImpl().getAccelerators();let u=null,_=null;if(null!==c&&(u=c.getQuadTree(),null!==u&&(_=u.getIterator(a,s))),!_){const e=g.nextPath();(0,i.g)(e)}let p=!1,d=null;const f=new h.P,x=new h.P;let P=null,E=null,y=null,S=null;for(e.hasNonLinearSegments()&&(P=new o.L,E=new o.L,y=new o.L,S=new o.L,l.querySide(0,P),l.querySide(1,E),l.querySide(2,y),l.querySide(3,S));;){if(null!==_){const e=_.next();if(-1===e)break;g.resetToVertex(u.getElement(e),-1),d=g.nextSegment()}else{for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;d=g.nextSegment()}if(d.getGeometryType()===i.G.enumLine){if(f.assign(d.getStartXY()),x.assign(d.getEndXY()),0!==l.clipLine(f,x)){p=!0;break}}else{if(P.isIntersecting(d,s)){p=!0;break}if(E.isIntersecting(d,s)){p=!0;break}if(y.isIntersecting(d,s)){p=!0;break}if(S.isIntersecting(d,s)){p=!0;break}}}return p&&!0}(e,t,s)}return!1}function gt(e,t,s,n,r){switch(n){case 4:return vt(e,t,s);case 2:case 128:return function(e,t,s){return It(e,t,s)}(e,t,s);case 1:case 64:return function(e,t,s){return!vt(e,t,s)}(e,t,s);case 3:return It(e,t,s)}return!1}function ct(e,t,s,n,i){switch(n){case 4:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),t.queryEnvelope(i),kt(i,n,s))return!1;const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.inflateCoords(s,s);const a=new h.P;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,a),o.contains(a))return!1;return!0}(e,t,s);case 2:return bt(e,t,s,!1);case 128:return bt(e,t,s,!0);case 1:case 64:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;return e.queryEnvelope(n),t.queryEnvelope(i),!(i.height()>s||i.width()>s)&&Nt(n,i,s)}(e,t,s);case 8:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D,o=new r.Envelope2D;if(t.queryEnvelope(n),n.height()<=s||n.width()<=s)return!1;i.setCoords({env2D:n}),o.setCoords({env2D:n}),i.inflateCoords(s,s),o.inflateCoords(-s,-s);const a=new h.P;let m=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,a),i.contains(a)){if(o.containsExclusive(a))return!1;m=!0}return m}(e,t,s);case 16:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;if(e.queryEnvelope(n),t.queryEnvelope(i),kt(i,n,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new r.Envelope2D,a=new r.Envelope2D;o.setCoords({env2D:i}),o.inflateCoords(-s,-s),a.setCoords({env2D:i}),a.inflateCoords(s,s);const m=new h.P;let l=!1,g=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,m),!l&&o.containsExclusive(m)&&(l=!0),g||a.contains(m)||(g=!0),l&&g)return!0;return!1}(e,t,s)}return!1}function ut(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!Nt(i,o,s))return!1;if(st(e,t),At(e,t,s))return!0;const a=e.calculateLength2D(),h=t.calculateLength2D(),m=Math.max(e.getPointCount(),t.getPointCount());return!(Math.abs(a-h)>4*m*s)&&(e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"**F**FFF*",n,!1):Ut(e,t,s,!0))}function _t(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),Wt(e,t,s,n))}function pt(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),2===Dt(e,t,s,!1))}function dt(e,t,s,n){return st(e,t),function(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),m=o.querySegmentIterator(),g=(0,h.d)(2,Number.NaN),c=(0,h.d)(2,Number.NaN),u=new Ke(i,o,s);let _=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();a.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=a.nextSegment(),r=m.nextSegment();let i=0;if(Kt(n,r)?!_&&r.isIntersecting(n,s)&&(_=!0):i=r.intersect(n,null,c,g,s),2===i)_=!0;else if(i){const e=g[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return!1;_=!0}}if(!_)return!1;const p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty(),f=r.Envelope2D.constructEmpty();let x,P;if(e.queryEnvelope(p),t.queryEnvelope(d),p.inflateCoords(1e3*s,1e3*s),d.inflateCoords(1e3*s,1e3*s),f.setCoords({env2D:p}),f.intersect(d),e.getPointCount()>10){if(x=(0,l.c)(e,f,s,0,n),x.isEmpty())return!1}else x=e;if(t.getPointCount()>10){if(P=(0,l.c)(t,f,s,0,n),P.isEmpty())return!1}else P=t;return Ae(x,P,s,"F********",n,!1)}(e,t,s,n)}function ft(e,t,s,n,i){const a=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(m),!kt(a,m,s))return!1;st(e,t);let l=!1;const g=new h.P,c=e.getImpl(),u=new o.P;let _=e,p=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,g),!a.contains(g))return!1;const i=es(_,g,s);if(1===i)l=!0;else if(0===i)return!1;if(n&&2===i)return!1;p||(!Ne(e,t.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),_=u),p=!0)}return l}function xt(e,t,s,n,i){const o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();return e.queryEnvelope(o),t.queryEnvelope(a),n?Ft(a,o,s):kt(a,o,s)}function Pt(e,t,s,n,i){const a=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(h),!kt(a,h,s))return!1;st(e,t);const m=new o.P;return m.addEnvelope(t,!1),n?2===Dt(e,m,s,!1):Wt(e,m,s,i)}function Et(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"******FF*",n,!1):qt(t,e,s,!1))}function yt(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),Ae(e,t,s,"T**FF*FF*",n,!1))}function St(e,t,s,n,a){const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();if(e.queryEnvelope(h),t.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;if(n)return Ft(m,h,s);if(!kt(m,h,s))return!1;const l=r.Envelope2D.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-s,-s);const g=r.Envelope2D.constructEmpty();if(g.setCoords({env2D:m}),g.inflateCoords(s,s),l.containsEnvelope(h))return!0;const c=e.getImpl().querySegmentIterator();c.stripAttributes(),c.nextPath()||(0,i.d)("relational_operations");let u,_,p,d,f,x,P=!1;const E=e.hasNonLinearSegments();for(E&&(p=new o.L,d=new o.L,f=new o.L,x=new o.L,l.querySide(0,p),l.querySide(1,d),l.querySide(2,f),l.querySide(3,x));;){for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;const e=c.nextSegment();if(E&&e.getGeometryType()!==i.G.enumLine){if(e.isIntersecting(p,s)){P=!0;break}if(e.isIntersecting(d,s)){P=!0;break}if(e.isIntersecting(f,s)){P=!0;break}if(e.isIntersecting(x,s)){P=!0;break}}else if(u=e.getStartXY(),_=e.getEndXY(),0!==l.clipLine(u,_)){P=!0;break}}return P}function Ct(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&Mt(t,e,s,!0,!1,!1)}function It(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),Nt(i,o,s)}function vt(e,t,s,n){return jt(e,t.getXY(),s)}function bt(e,t,s,n,i){const o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;if(n)return Ft(a,o,s);if(!kt(a,o,s))return!1;let m=!1;const l=r.Envelope2D.constructEmpty(),g=r.Envelope2D.constructEmpty();l.setCoords({env2D:a}),g.setCoords({env2D:a}),l.inflateCoords(-s,-s),g.inflateCoords(s,s);const c=new h.P;for(let t=0;t<e.getPointCount();t++){if(e.queryXY(t,c),!g.contains(c))return!1;l.containsExclusive(c)&&(m=!0)}return m}function Gt(e,t,s,n){return h.P.sqrDistance(e,t)<=s*s}function wt(e,t,s,n){return Gt(e,t,s)}function Nt(e,t,s,n){return kt(e,t,s)&&kt(t,e,s)}function Tt(e,t,s,n,i){if(e.height()<=s||e.width()<=s)return!1;if(n)return Ft(e,t,s);if(!kt(e,t,s))return!1;const o=r.Envelope2D.constructEmpty();return o.setCoords({env2D:e}),o.inflateCoords(-s,-s),o.intersect(t),!o.isEmpty()}function Dt(e,t,s,n,a){const m=new h.P,l=new h.P,g=r.Envelope2D.constructEmpty(),c=r.Envelope2D.constructEmpty(),u=e.getImpl(),_=t.getImpl(),p=_.getGeometryType(),d=new Ke(u,_,s,!0);if(!d.next())return 1;if(Ot(e,t,s))return n?4:0;const f=new o.P;let x=e;const P=new o.P;let E=null;p===i.G.enumPolygon&&(E=t);const y=p===i.G.enumPolygon?(0,h.d)(u.getPathCount(),!1):[],S=(0,h.d)(_.getPathCount(),!1);let C=!1,I=!1,v=!1,b=!1,G=!1,w=!1;do{if(v&&G||b&&w)break;if(v&&b)break;const r=d.getRedElement(),o=d.getBlueElement();if(!S[o]&&(l.assign(t.getXY(t.getPathStart(o))),g.setCoords({env2D:d.getRedEnvelope()}),g.inflateCoords(s,s),g.contains(l))){if(0!==es(x,l,0)){if(b=!0,n)return 4}else w=!0;S[o]=!0}if(p===i.G.enumPolygon&&!y[r]&&(m.assign(e.getXY(e.getPathStart(r))),c.setCoords({env2D:d.getBlueEnvelope()}),c.inflateCoords(s,s),c.contains(m))){if(0!==es(E,m,0)){if(v=!0,n)return 4}else G=!0;y[r]=!0}if(C||(!Ne(e,t.getPathCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?x=e:(e.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),C=!0),p===i.G.enumPolygon&&!I){const s=t;!Ne(s,e.getPathCount()-1)||null!==_.getAccelerators()&&null!==_.getAccelerators().getQuadTree()?E=t:(s.copyTo(P),P.getImpl().buildQuadTreeAccelerator(1),E=P),I=!0}}while(d.next());if(!v&&!b)return 1;if(!G||!w){if(p===i.G.enumPolygon)for(let e=0,t=u.getPathCount();e<t;e++)if(!y[e]){G=!0;break}for(let e=0,t=_.getPathCount();e<t;e++)if(!S[e]){w=!0;break}}return v&&G||b&&w||v&&b?4:b?2:3}function Vt(e,t,s,n,a){n[0]=!1;const h=e.getImpl(),m=t.getImpl(),l=h.querySegmentIterator(),g=m.querySegmentIterator(),c=[0,0],u=[0,0],_=new Ke(h,m,s);let p=!1;for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement();l.resetToVertex(e,-1),g.resetToVertex(t,-1);const r=l.nextSegment(),i=g.nextSegment();let o=0;if(Kt(r,i)?!p&&i.isIntersecting(r,s)&&(p=!0):o=i.intersect(r,null,u,c,s),0!==o&&(p=!0,1===o)){const e=c[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return n[0]=!0,!1}}if(!p){n[0]=!0;const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a),a.inflateCoords(s,s);const l=new o.P;let g=e,c=!1;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)>0){const n=r.Envelope2D.constructEmpty();if(t.queryPathEnvelope(s,n),!a.isIntersecting(n))return!1;{const e=we(g,t.getXY(t.getPathStart(s)),0);if((0,i.g)(-1!==e),0===e)return!1}c||(!Ne(e,t.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),c=!0)}if(1===e.getPathCount()||t.getGeometryType()===i.G.enumPolyline)return!0;const u=t,_=r.Envelope2D.constructEmpty();u.queryEnvelope(_),_.inflateCoords(s,s);const p=new o.P;let d=u,f=!1;for(let t=0,s=e.getPathCount();t<s;t++)if(e.getPathSize(t)>0){const s=r.Envelope2D.constructEmpty();if(e.queryPathEnvelope(t,s),_.isIntersecting(s)){const s=we(d,e.getXY(e.getPathStart(t)),0);if((0,i.g)(-1!==s),1===s)return!1}f||(!Ne(u,e.getPathCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?d=u:(u.copyTo(p),p.getImpl().buildQuadTreeAccelerator(1),d=p),f=!0)}return!0}return!1}function kt(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)}function Ft(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),e.containsExclusiveEnvelope(n)}function Ht(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!(n.contains(e.getLowerLeft())&&n.contains(e.getLowerRight())&&n.contains(e.getUpperLeft())&&n.contains(e.getUpperRight()))}function At(e,t,s,n){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);const r=new h.P,i=new h.P;let o=!0;const a=s*s;for(let s=0;s<e.getPathCount();s++){if(e.getPathEnd(s)!==t.getPathEnd(s)){o=!1;break}for(let n=e.getPathStart(s);n<t.getPathEnd(s);n++)if(e.queryXY(n,r),t.queryXY(n,i),h.P.sqrDistance(r,i)>a){o=!1;break}if(!o)break}return!!o}function Mt(e,t,s,n,r,i,o){const a=e.getImpl(),m=t.getImpl(),l=a.getPointCount(),g=m.getPointCount(),c=(0,h.d)(l,!1),u=r||i?(0,h.d)(g,!1):[],_=s*s,p=new Ke(a,m,s);for(;p.next();){const e=p.getRedElement(),t=p.getBlueElement(),s=a.getXY(e),n=m.getXY(t);h.P.sqrDistance(s,n)<=_&&(c[e]=!0,(r||i)&&(u[t]=!0))}let d=!1,f=!1;for(let e=0;e<l;e++){const t=c[e];if(d||=!t,f||=t,(r||n)&&d)return!1}if(n)return!0;let x=!1,P=!1;for(let e=0;e<g;e++){const t=u[e];if(x||=!t,P||=t,r&&x)return!1}return!!r||d&&f&&x&&P}function Ut(e,t,s,n){return qt(e,t,s,n)&&qt(t,e,s,n)}function qt(e,t,s,n){if((0,i.p)(e),(0,i.p)(t),t.isEmpty())return!1;let o=!0;const m=(0,h.d)(2,Number.NaN),l=(0,h.d)(2,Number.NaN),g=[],c=new Jt;let u;const _=r.Envelope2D.constructEmpty(),p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty();e.queryEnvelope(_),t.queryEnvelope(p),_.inflateCoords(s,s),p.inflateCoords(s,s),d.setCoords({env2D:_}),d.intersect(p);const f=e.getImpl().querySegmentIterator(),x=t.getImpl().querySegmentIterator(),P=t.getImpl().getAccelerators();let E=null,y=null,S=null,C=null;if(null!==P&&(E=P.getQuadTree(),y=P.getQuadTreeForPaths(),null!==y&&(C=y.getIteratorForQT())),null===E){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(E=(0,a.H)(t.getImpl(),d))}for(null!==E&&(S=E.getIteratorForQT());f.nextPath();)for(;f.hasNextSegment();){let e=f.nextSegment();if(e.queryEnvelope(_),!_.isIntersecting(d))return o=!1,!1;if(null!==C&&(C.resetIterator(_,s),-1===C.next()))continue;let t=0,r=null;if(null!=S)S.resetIterator(e,s);else if(x.resetToFirstPath(),!x.nextPath())return o=!1,!1;do{if(t=0,null!==S){const n=S.next();if(-1===n)return o=!1,!1;x.resetToVertex(E.getElement(n),-1),r=x.nextSegment(),t=e.intersect(r,null,m,l,s)}else{for(;!x.hasNextSegment();)if(!x.nextPath())return o=!1,!1;r=x.nextSegment(),r.queryEnvelope(p),p.inflateCoords(s,s),_.isIntersecting(p)&&(t=e.intersect(r,null,m,l,s))}}while(2!==t||0!==m[0]||n&&!(l[0]<=l[1]));let h=Number.NaN,P=!1;do{let n=!1;if(1===m[1]){if(!f.hasNextSegment()){P=!0;break}e=f.nextSegment(),n=!0}if(1===l[1]&&l[0]<=l[1]){if(-1===h)break;if(h=1,!x.hasNextSegment())break;r=x.nextSegment(),n=!0}if(0===l[1]&&l[0]>l[1]){if(1===h)break;if(Number.isNaN(h)){if(!x.hasPreviousSegment())break;x.previousSegment(),h=-1}if(!x.hasPreviousSegment())break;r=x.previousSegment(),n=!0}if(!n)break;t=e.intersect(r,null,m,l,s)}while(2===t&&(!n||l[0]<=l[1]));if(P)continue;const y=e.calculateLength2D();e.queryEnvelope(_),g.length=0,c.m_overlapEvents.length=0;let I=!1,v=!1,b=0;const G=(0,a.d)(null,_,!0);for(null!==S?S.resetIterator(e,s):(x.resetToFirstPath(),x.nextPath()||(0,i.d)("relational_operations"));;){if(t=0,null!==S){const n=S.next();if(-1===n)break;x.resetToVertex(E.getElement(n),-1),r=x.nextSegment(),t=e.intersect(r,null,m,l,s)}else{for(;!x.hasNextSegment()&&x.nextPath(););if(!x.hasNextSegment())break;r=x.nextSegment(),r.queryEnvelope(p),p.inflateCoords(s,s),_.isIntersecting(p)&&(t=e.intersect(r,null,m,l,s))}if(2===t&&(!n||l[0]<=l[1])){const e=f.getStartPointIndex(),t=f.getPathIndex(),n=x.getStartPointIndex(),r=x.getPathIndex();if(u=Qt(e,t,m[0],m[1],n,r,l[0],l[1]),c.m_overlapEvents.push(u),g.push(g.length),!(I||u.m_scalarA0<b&&u.m_scalarA1<b))if(0===b&&y*(u.m_scalarA0-b)>s)I=!0;else if(0!==b&&y*(u.m_scalarA0-b)>G)I=!0;else if(b=u.m_scalarA1,y*(1-b)<=s||1===b){v=!0;break}}}if(!v){if(!I)return o=!1,!1;g.length>1&&g.sort((e,t)=>c.compareOverlapEvents(e,t)),b=0;for(let e=0;e<c.m_overlapEvents.length;e++)if(u=c.m_overlapEvents[g[e]],!(u.m_scalarA0<b&&u.m_scalarA1<b)){if(0===b&&y*(u.m_scalarA0-b)>s)return o=!1,!1;if(0!==b&&y*(u.m_scalarA0-b)>G)return o=!1,!1;if(b=u.m_scalarA1,y*(1-b)<=s||1===b)break}if(y*(1-b)>s)return o=!1,!1;g.length=0,c.m_overlapEvents.length=0}}return o}function Ot(e,t,s){const n=e.getImpl(),r=t.getImpl(),i=n.querySegmentIterator(),o=r.querySegmentIterator(),a=new Ke(n,r,s);for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();i.resetToVertex(e,-1),o.resetToVertex(t,-1);const n=i.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function Yt(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),m=(0,h.d)(2,Number.NaN),l=new Ke(r,i,s);let g=!1,c=-1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const r=o.nextSegment(),i=a.nextSegment();let u=0;if(Kt(r,i)){if(i.isIntersecting(r,s))return-2}else u=r.intersect(i,null,m,null,s);if(u)if(2===u){const e=r.calculateLength2D(),t=m[0];if(e*(m[1]-t)>s)return c=1,c;g=!0}else if(c=0,n){const e=m[0],t=new h.P;r.queryCoord2D(e,t),n.push(t.x),n.push(t.y)}}return g?-2:c}function Bt(e,t,s,n){const r=e.getImpl(),i=t,o=i.getPointCount(),a=n?(0,h.d)(o,!1):[],m=new Ke(r,i,s,!1),l=r.querySegmentIterator();for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();l.resetToVertex(e,-1);const r=l.nextSegment(),o=i.getXY(t);if(r.isIntersectingPoint(o,s)){if(!n)return!0;a[t]=!0}}if(!n)return!1;for(let e=0;e<o;e++)if(!a[e])return!1;return!0}function Rt(e,t,s){const n=new h.P,i=s*s,o=e.querySegmentIterator(),a=e.getImpl().getAccelerators();if(null!==a){const e=a.getQuadTree();if(null!==e){const a=r.Envelope2D.constructEmpty();a.setCoords({pt:t});const m=e.getIterator(a,s);for(let s=m.next();-1!==s;s=m.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,n),h.P.sqrDistance(t,n)<=i)return!0}return!1}}const m=r.Envelope2D.constructEmpty();for(;o.nextPath();)for(;o.hasNextSegment();){const e=o.nextSegment();if(e.queryEnvelope(m),m.inflateCoords(s,s),!m.contains(t))continue;const r=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(r,n),h.P.sqrDistance(t,n)<=i)return!0}return!1}function Xt(e,t,s,n){const a=e.querySegmentIterator(),m=e.getImpl().getAccelerators(),l=e.hasNonLinearSegments();let g=null,c=null,u=null,_=null;if(null!==m){const e=m.getQuadTree();if(null!==e){const n=e.getIterator(t,s);l&&(g=new o.L,c=new o.L,u=new o.L,_=new o.L,t.querySide(0,g),t.querySide(1,c),t.querySide(2,u),t.querySide(3,_));const h=r.Envelope2D.constructEmpty();h.setCoords({env2D:t}),h.inflateCoords(s,s);for(let r=n.next();-1!==r;r=n.next())if(a.resetToVertex(e.getElement(r),-1),a.hasNextSegment()){const e=a.nextSegment();if(e.getGeometryType()===i.G.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(h.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(g,s))return!0;if(e.isIntersecting(c,s))return!0;if(e.isIntersecting(u,s))return!0;if(e.isIntersecting(_,s))return!0}return!1}}if(l){g=new o.L,c=new o.L,u=new o.L,_=new o.L,t.querySide(0,g),t.querySide(1,c),t.querySide(2,u),t.querySide(3,_);const n=e.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const e=n.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(g,s))return!0;if(e.isIntersecting(c,s))return!0;if(e.isIntersecting(u,s))return!0;if(e.isIntersecting(_,s))return!0}}else{const n=r.Envelope2D.constructEmpty();n.setCoords({env2D:t}),n.inflateCoords(s,s);const i=e.getImpl(),o=i.getAttributeStreamRef(0),a=new h.P;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0;const s=new h.P,r=new h.P,m=new h.P,l=i.getPathStart(e),g=new h.P;for(let h=l,c=i.getPathEnd(e);h<c;h++)if(t)o.queryPoint2D(2*h,s),g.assign(s),t=!1;else{if(o.queryPoint2D(2*h,a),r.setCoordsPoint2D(s),m.setCoordsPoint2D(a),n.clipLine(r,m))return!0;s.assign(a)}if(i.isClosedPath(e)&&!t&&(r.setCoordsPoint2D(s),m.setCoordsPoint2D(g),n.clipLine(r,m)))return!0}}return!1}function Lt(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),m=[0],g=(0,a.Y)(i.getIsSimple(0,m))&&(0,a.Y)(o.getIsSimple(0,m)),c=i.querySegmentIterator(),u=o.querySegmentIterator(),_=(0,h.d)(2,0),p=(0,h.d)(2,0),d=new Ke(i,o,s);let f=!1;for(;d.next();){const e=d.getRedElement(),t=d.getBlueElement();c.resetToVertex(e,-1),u.resetToVertex(t,-1);const n=c.nextSegment(),r=u.nextSegment();let i=0;if(Kt(n,r)){if(r.isIntersecting(n,s)){f=!0;break}}else i=r.intersect(n,null,p,_,s);if(2===i){const e=_[0],t=_[1],r=n.calculateLength2D();if(g&&(t-e)*r>s)return!1;f=!0}else if(i){const e=_[0],t=p[0];if(e>0&&e<1&&t>0&&t<1)return!1;f=!0}}if(!f)return!1;const x=r.Envelope2D.constructEmpty(),P=r.Envelope2D.constructEmpty(),E=r.Envelope2D.constructEmpty();let y,S;if(e.queryEnvelope(x),t.queryEnvelope(P),x.inflateCoords(1e3*s,1e3*s),P.inflateCoords(1e3*s,1e3*s),E.setCoords({env2D:x}),E.intersect(P),e.getPointCount()>10){if(y=(0,l.c)(e,E,s,0,n),y.isEmpty())return!1}else y=e;if(t.getPointCount()>10){if(S=(0,l.c)(t,E,s,0,n),S.isEmpty())return!1}else S=t;return Ae(y,S,s,"F********",n,!1)}function zt(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),m=[0],g=(0,a.Y)(i.getIsSimple(0,m))&&(0,a.Y)(o.getIsSimple(0,m)),c=r.Envelope2D.constructEmpty(),u=r.Envelope2D.constructEmpty(),_=r.Envelope2D.constructEmpty();e.queryEnvelope(c),t.queryEnvelope(u);let p=!1;const d=Ht(c,u,s),f=Ht(u,c,s),x=i.querySegmentIterator(),P=o.querySegmentIterator(),E=(0,h.d)(2,Number.NaN),y=(0,h.d)(2,Number.NaN),S=new Ke(i,o,s);for(;S.next();){const e=S.getRedElement(),t=S.getBlueElement();x.resetToVertex(e,-1),P.resetToVertex(t,-1);const n=x.nextSegment(),r=P.nextSegment();let i=0;if(Kt(n,r)){if(r.isIntersecting(n,s))break}else i=r.intersect(n,null,y,E,s);if(2===i){const e=E[0],t=E[1],r=n.calculateLength2D();if(g&&(t-e)*r>s&&(p=!0,d&&f))return!0}else if(i){const e=E[0],t=y[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const C=r.Envelope2D.constructEmpty(),I=r.Envelope2D.constructEmpty();let v,b;C.setCoords({env2D:c}),C.inflateCoords(1e3*s,1e3*s),I.setCoords({env2D:u}),I.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:C}),_.intersect(I);let G="";if(G+=p?"**":"T*",d){if(t.getPointCount()>10){if(b=(0,l.c)(t,_,s,0,n),b.isEmpty())return!1}else b=t;G+="****"}else b=t,G+="T***";if(f){if(e.getPointCount()>10){if(v=(0,l.c)(e,_,s,0,n),v.isEmpty())return!1}else v=e;G+="***"}else v=e,G+="T**";return Ae(v,b,s,G,n,!1)}function Wt(e,t,s,n){const i=[!1],h=Vt(e,t,s,i);if(i[0])return h;const m=r.Envelope2D.constructEmpty();let g;if(t.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(g=(0,l.c)(e,m,s,0,n),g.isEmpty())return!1}else g=e;return function(e,t,s,n){const i=new ze;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaAreaPredicates_();const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let l=!1;if(tt(h,m,s)&&(i.areaAreaDisjointPredicates_(e,t),l=!0),l||st(e,t),l)return Xe(i.m_matrix,i.m_scl);let g=new o.E,c=g.addGeometry(e),u=g.addGeometry(t),_=null,p=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){_=new cs;const e=ms(s,g.getEnvelope2D(n));p=gs(e,0),os(g,e,s,0,_,null,n)}_s(g,new a.C(s,0).add(p),n,!1,!1);const d=g.getGeometry(u).getBoundary();if(g.filterClosePoints(0,!0,!0,!1,o.n),Fe(g,c,-1,!1,o.n,n),0===g.getPointCount(c))return!1;Fe(g,u,-1,!1,o.n,n),i.setEditShape_(g,n);const f=0===g.getPointCount(u);if(!f){i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape();const e=Xe(i.m_matrix,i.m_scl);if(!e)return e}const x=g.getGeometry(c);return g=new o.E,c=g.addGeometry(x),u=g.addGeometry(d),i.setEditShape_(g,n),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(f?"T*****F**":"******F**"),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape(),Xe(i.m_matrix,i.m_scl)}(g,t,s,n)}function jt(e,t,s,n){const r=new h.P,i=s*s;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,r),h.P.sqrDistance(r,t)<=i)return!1;return!0}function Zt(e,t,s){const n=e.getBoundary();return!n.isEmpty()&&!jt(n,t,s)}function Kt(e,t){return e.getGeometryType()!==i.G.enumLine||t.getGeometryType()!==i.G.enumLine}function Qt(e,t,s,n,r,i,o,a){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:s,m_scalarA1:n,m_ivertexB:r,m_ipathB:i,m_scalarB0:o,m_scalarB1:a}}class Jt{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(e,t){const s=this.m_overlapEvents[e],n=this.m_overlapEvents[t];if(s.m_ipathA<n.m_ipathA)return-1;if(s.m_ipathA===n.m_ipathA){if(s.m_ivertexA<n.m_ivertexA)return-1;if(s.m_ivertexA===n.m_ivertexA){if(s.m_scalarA0<n.m_scalarA0)return-1;if(s.m_scalarA0===n.m_scalarA0){if(s.m_scalarA1<n.m_scalarA1)return-1;if(s.m_scalarA1===n.m_scalarA1&&s.m_ivertexB<n.m_ivertexB)return-1}}}return 1}}function $t(e,t,s){const n=function(e,t,s){return t.isEmpty()?0:we(e,t.getXY(),s)}(e,t,s);return n?1===n?1:2:0}function es(e,t,s){const n=we(e,t,s);return n?1===n?1:2:0}function ts(e,t,s,n,o){if(e.getGeometryType()===i.G.enumPolygon)!function(e,t,s,n,r){for(let i=0;i<s;i++)r[i]=es(e,t[i],n)}(e,t,s,n,o);else if(e.getGeometryType()===i.G.enumEnvelope){const i=r.Envelope2D.constructEmpty();e.queryEnvelope(i),function(e,t,s,n,r){if(e.isEmpty()){for(let e=0;e<s;e++)r[e]=0;return}const i=e.clone();i.inflateCoords(.5*-n,.5*-n);const o=e.clone();o.inflateCoords(.5*n,.5*n);for(let e=0;e<s;e++)i.contains(t[e])?r[e]=1:o.contains(t[e])?r[e]=2:r[e]=0}(i,t,s,n,o)}else(0,i.q)("")}function ss(e,t,s,n,o){const h=e.getGeometryType();h===i.G.enumPolyline?function(e,t,s,n,o){const h=e.getImpl(),m=h.getAccelerators();let l=null;m&&(l=m.getRasterizedGeometry());let g=s;for(let e=0;e<s;e++)o[e]=1,l&&(0,i.g)(0);if(g){if(m){let e=null;null!==m&&null!==m.getQuadTree()&&(e=m.getQuadTree());const i=h.getPointCount();if(null===e&&i>20&&i*s>4*i+Math.log(i)*s&&(e=(0,a.H)(h)),e){let i=null;const a=h.querySegmentIterator(),m=new r.Envelope2D;for(let r=0;r<s&&g;r++)if(1===o[r]){m.setCoords(t[r]),null===i?i=e.getIterator(m,n):i.resetIterator(m,n);let s=-1;for(let h=i.next();-1!==h;h=i.next()){if(a.resetToVertex(e.getElement(h),s),s=a.getPathIndex(),a.nextSegment().isIntersectingPoint(t[r],n)){o[r]=2,g--;break}o[r]=0}}return}}const e=h.querySegmentIterator();for(;e.nextPath()&&g;)for(;e.hasNextSegment()&&g;){const r=e.nextSegment();for(let e=0;e<s&&g;e++)1===o[e]&&r.isIntersectingPoint(t[e],n)&&(o[e]=2,g--)}}for(let e=0;e<s;e++)1===o[e]&&(o[e]=0)}(e,t,s,n,o):(0,i.f)(h)?(0,i.g)(0):(0,i.q)("")}function ns(){return Number.isNaN(this.radius.value())}function rs(e,t,s,n){return{pt:e.clone(),t,err:s,checkCount:n}}class is{constructor(e,t,s,n,r){this.m_left=e,this.m_tracker=r,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 h.P,ptEnd:new h.P,center:new o._,radius:new h.H,fcenter:new o.a5,fradius2:new h.M,maxError:Number.NaN,isLine:ns}}closeToCircularArc(e,t,s,n,r,i){if(this.m_circleCheckCounter++,i.maxError=0,!is.checkSweepAngle(e,t))return!1;if(i.ptStart.setCoordsPoint2D(s),i.ptEnd.setCoordsPoint2D(r),e.isCircular()){const t=e;return i.fradius2=h.M.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),i.radius.set(t.getSemiMajorAxis()),i.fcenter.assignPoint2D(t.getCenter()),i.center.set(t.getCenter()),!0}const a=i.ptEnd.sub(i.ptStart).clone();if(a.leftPerpendicularThis(),a.normalize(),Math.abs(a.dotProduct(n.sub(i.ptStart)))<=this.m_eps)return!!this.confirmIsLine(i,a)&&(i.radius.set(Number.NaN),i.center.setCoords(0,0),!0);{const s=i.ptEnd.sub(i.ptStart),r=n.sub(i.ptStart),o=s.crossProduct(r);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*r.sqrLength();let m=a*r.y-h*s.y;m/=o;let l=s.x*h-r.x*a;l/=o;const g=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*g>this.m_eps)return!1;const c=m+i.ptStart.x,u=l+i.ptStart.y;i.radius.set(g),i.center.setCoords(c,u);const _=this.maxCircleApproximationError(e,t,i);if(_>this.m_eps)return i.maxError=_,!1}const m=(new o.a5).assignPoint2D(i.ptStart),l=(new o.a5).assignPoint2D(i.ptEnd).sub(m),g=(new o.a5).assignPoint2D(n).sub(m),c=l.crossProduct(g);if(c.isZero())return!1;const u=l.sqrLength().mulDouble(.5),_=g.sqrLength().mulDouble(.5),p=u.mul(g.y).sub(_.mul(l.y)),d=l.x.mul(_).sub(g.x.mul(u)),f=p.mul(p).add(d.mul(d)),x=c.clone();x.invertThis(),i.fradius2=f.mul(x).mul(x),i.fcenter.setCoords(p.mul(x).add(m.x),d.mul(x).add(m.y)),i.center.setWithEps(i.fcenter.asPoint2D()),i.radius.setWithEps(Math.sqrt(i.fradius2.toDouble()));const P=o._.constructPoint2D(i.ptStart).subE(i.center),E=o._.constructPoint2D(i.ptEnd).subE(i.center);if(!P.dotProduct(E).gt(h.J))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.G.enumEllipticArc){const s=e,n=(0,o.a6)(s,t.vmin),r=(0,o.a6)(s,t.vmax);return!(Math.abs(r-n)>.5*h.o)}return!0}confirmIsLine(e,t){const s=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(s.mul(.25)))>this.m_eps||Math.abs(t.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,s){const n=[.25,.75],r=[.1,.25,.75,.9];let o,a;e.getGeometryType()===i.G.enumEllipticArc?(o=n,a=n.length):(o=r,a=r.length);let m=0;for(let n=0;n<a;++n){const r=new h.P;e.queryCoord2D((0,h.q)(t.vmin,t.vmax,o[n]),r);const i=r.sub(s.center.value()).length(),a=Math.abs(i-s.radius.value());a>m&&(m=a)}return m}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=(0,h.d)(9,Number.NaN);let r;e?r=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,r=2);const i=[],o=[],a=new h.P(0,0);for(let e=1;e<r;e++){const r=new h.E(n[e-1],n[e]);for(this.m_bReversedLeft=!is.goodOrientation(this.m_left,r),this.m_bReversedLeft?(i.push(rs(a,r.vmin,0,0)),i.push(rs(a,r.vmax,0,0))):(i.push(rs(a,r.vmax,0,0)),i.push(rs(a,r.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t);i.length>1;){this.progress_();const e=i.at(-1);let n=e.checkCount,r=e.err;const a=e.pt.clone(),m=e.t,l=i[i.length-2].t,g=.5*(m+l),c=this.m_left.getCoord2D(g);if(r<=this.m_eps||n>=5){const e=new h.E;if(e.setCoords(m,l),this.closeToCircularArc(this.m_left,e,a,c,i[i.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(m):t.push(l)),s++,i.pop();continue}n=0,r=this.m_leftArc.maxError}e.t=g,e.pt.setCoordsPoint2D(c),r*=.125,n++,e.err=r,e.checkCount=n,i.push(rs(a,m,r,n))}this.m_bReversedLeft&&t&&(t.length=t.length+o.length,(0,h.b)(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new o.a,s=[];if(!this.approximateWithCirclesImpl(!0,s))return t;let n=0;const r=this.m_left.getStartXY();t.startPath(r);for(let i=1;i<s.length;++i)if(e)t.lineTo(this.m_left.getCoord2D(s[i]));else{const e=new h.P;this.m_left.queryCoord2D(s[i],e);const a=new h.P;this.m_left.queryCoord2D(.5*(s[i]+n),a);const m=new o.l;m.constructCircularArcThreePoint(r,e,a),t.addSegment(m,!1),r.assign(e),n=s[i]}return t}static goodOrientation(e,t){const s=e.getCoord2D(t.vmin),n=e.getCoord2D(t.vmax);return s.compare(n)<0}progress_(e=!1){}}function os(e,t,s,n,r,i,o){(function(e,t,s,n,r,i){e.hasCurves()?(e.setCurveStitcherPointer(n),n.m_impl=new us(i,!1,null),n.m_impl.buildMonotonicCurveParentage(e,t,s,r)):n.m_impl=null})(e,t,s,r,i,o),ds(e,s,o)}function as(e,t,s,n){if(!(0,i.h)(e.getGeometryType()))return e;const r=e.getImpl();if(!r.hasNonLinearSegments())return e;const h=e.createInstance();h.getGeometryType()===i.G.enumPolygon&&h.setFillRule(e.getFillRule()),new o.E;const m=new a.P,l=new o.S,g=[],c=[],u=[],_=e.getDescription().getAttributeCount()>1,p=r.querySegmentIterator();for(;p.nextPath();){let e=!0;for(;p.hasNextSegment();){const n=p.isClosingSegment(),r=p.nextSegment();if(!r.isCurve()){h.addSegment(r,e,n),e=!1;continue}let a,d=!1;const f=!0,x=!0;switch(r.getGeometryType()){case i.G.enumEllipticArc:case i.G.enumRationalBezier2:a=(0,o.O)(r,t,s,f,x,c,u,g),d=!0;break;default:a=(0,o.N)(r,t,s,!0,f,c,g)}const P=d?2:3;c[1].isNAN()?(l.createLine(),l.get().construct(c[0],c[P])):d?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c,u)):(l.createCubicBezier(),l.get().constructPoints(c)),_&&e&&(r.queryCoord(g[0],m),l.get().setStart(m)),_&&(r.queryCoord(g[1],m),l.get().setEnd(m)),h.addSegment(l.get(),e,n&&1===a),e=!1;for(let e=1,t=a,s=P;e<t;++e,s+=P)c[s+1].isNAN()?(l.createLine(),l.get().construct(c[s],c[s+P])):d?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c.slice(s),u.slice(s))):(l.createCubicBezier(),l.get().constructPoints(c.slice(s))),_&&(r.queryCoord(g[e+1],m),l.get().setEnd(m)),h.addSegment(l.get(),!1,n&&e+1===t)}}return h}function hs(e){if(!e.hasSegmentParentage())return;const t=e.queryVertexIteratorOnSelection();for(let s=t.next();s!==o.n;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==o.n?e.getSegmentParentage(t):-1,r=e.getSegmentParentage(s);-1!==r&&-1!==n&&r!==n&&e.setSegmentParentageBreakVertex(s,!0)}}function ms(e,t){return t||(t=r.Envelope2D.constructEmpty()),function(e,t){let s=t.isEmpty()?e:(0,a.c)(null,t,!0).total();return s>e&&(s=e),.125*s}(e,t)}function ls(e,t){return.125*e}function gs(e,t){return 3*e+3*t}class cs{constructor(){this.m_impl=null}stitchCurves(e,t,s,n){this.m_impl&&(this.m_impl.stitchCurves(e,t,s),n&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&(this.m_impl.clearStitcher(e),this.m_impl=null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class us{constructor(e,t,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=e,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,s,n){const r=!1;if(!e.hasCurves())return;(0,i.g)(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=s;const h=new a.P,m=new o.S,l=[],g=[],c=[];for(let n=e.getFirstGeometry();n!==o.n;n=e.getNextGeometry(n))for(let a=e.getFirstPath(n);a!==o.n;a=e.getNextPath(a)){let n=e.getPathSize(a),u=e.getFirstVertex(a),p=0,d=-1;for(let f=0;f<n;f++){let x=e.getNextVertex(u);if(!e.querySegment(u,m,!0,!1)){u=x;continue}if(0===p){d=e.getVertexIndex(u);const t=us.regularizeCurve(e,m.get(),u,s);if(t>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new _.NonSimpleResult(13,d,-1)),p=t,n=e.getPathSize(a),x=e.getNextVertex(u);const s=e.querySegment(u,m,!0,!1);(0,i.g)(s)}}else p--;const P=e.getVertexIndex(u);let E;-1!==this.m_originalVertexIndex&&e.setUserIndex(u,this.m_originalVertexIndex,d),e.setSegmentToIndex(P,null);let y=!1;switch(m.get().getGeometryType()){case i.G.enumEllipticArc:case i.G.enumRationalBezier2:E=(0,o.O)(m.get(),t,s,r,!0,g,c,l),y=!0;break;default:{const e=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();E=(0,o.N)(m.get(),t,s,e,r,g,l)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(u,S,!0),!g[1].isNAN()){let t=null;t=y?new o.T({points:g,weights:c}):new o.y({cp:g}),t.snapControlPoints(s*s),e.setSegmentToIndex(P,t)}const C=y?2:3;for(let t=1,n=E,r=C;t<n;++t,r+=C){m.get().queryCoord(l[t],h);const n=e.insertVertex(a,x,h);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,d),!g[r+1].isNAN())if(y){const t=new o.T({points:g.slice(r),weights:c.slice(r)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(n),t)}else{const t=new o.y({cp:g.slice(r)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(n),t)}e.setSegmentParentageAndBreak(n,S,!1)}E>1&&(f+=E-1,n=e.getPathSize(a)),this.m_originalPlanarSegments.push(m.releaseSegment()),u=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;(0,i.g)(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const h=new a.P,m=new o.S,l=new o.D(0,t,0,this.m_progressTracker,!1,n),g=[];for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))for(let n=e.getFirstPath(t);n!==o.n;n=e.getNextPath(n)){let t=e.getPathSize(n),r=e.getFirstVertex(n);for(let o=0;o<t;o++){let o=e.getNextVertex(r);if(!e.querySegment(r,m,!0,!1)){r=o;continue}if(us.regularizeCurve(e,m.get(),r,s)>=0){t=e.getPathSize(n),o=e.getNextVertex(r);const s=e.querySegment(r,m,!0,!1);(0,i.g)(s)}const a=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,a),e.setSegmentToIndex(a,null),g.length=0,l.densifySegment(m.get(),g),this.progress_();const c=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,c,!0);for(let t=1,s=g.length-1;t<s;++t){m.get().queryCoord(g[t],h);const s=e.insertVertex(n,o,h);e.setSegmentParentageAndBreak(s,c,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(s,this.m_originalVertexIndex,a)}this.m_originalPlanarSegments.push(m.releaseSegment()),r=o}}e.clearSegments()}stitchCurves(e,t,s){us.st_stitchCurvesImpl(this,e,t,s,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){us.st_stitchCurvesImpl(null,e,o.n,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==o.n?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.G.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case i.G.enumBezier:return 2;case i.G.enumBezier2:return 3;case i.G.enumLine:return-1;case i.G.enumRationalBezier2:return 4;default:(0,i.t)("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,a,m){if(t===s&&0===n)return(0,i.g)(e.getNextVertex(t)===o.n),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const l=e.getNextVertex(t),g=e.getXY(t),c=e.getXY(s);let u,_=0;{let t=2,r=g;for(let n=l;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);_+=h.P.distance(s,r),r=s,t++}_+=h.P.distance(c,r),(0,i.g)(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(l,s);const p=m;let d=r.getClosestCoordinate(g,!1),f=r.getClosestCoordinate(c,!1);const x=r.calculateLength2D();let P=r.tToLength(d),E=r.tToLength(f);const y=Math.abs(P)>10*p&&Math.abs(P-x)>10*p,S=Math.abs(E)>10*p&&Math.abs(E-x)>10*p,C=e=>{const t=e.calculateLength2D();return Math.abs(t-_)>Math.max(.2*_,4*p)?null:e};let I=r.isClosed();if(!I){const e=h.P.distance(r.getStartXY(),r.getEndXY());e<=p&&x>5*e&&(I=!0)}if(I){let o,a,m=new h.P;if(2===n)m=h.P.lerp(g,c,.5),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o);else{let s=e.getNextNthVertex(t,(n-1)/2);m=e.getXY(s),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o);let i=Math.abs(a)>10*p&&Math.abs(a-x)>10*p;if(!i&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o),i=Math.abs(a)>10*p&&Math.abs(a-x)>10*p),!i))return}let l=!1;const _=P===E;if(_){const s=0;let i=2,o=4;n-1<=4&&(i=s+1,o=s+2);const a=g,m=e.getXY(e.getNextNthVertex(t,i)),c=e.getXY(e.getNextNthVertex(t,o));l=-h.P.orientationNonRobust(a,m,c)*(0,h.e)(r.calculateArea2DHelper())>0}else S?y?l=a>P:a<E?(P=0,d=0):(P=x,d=1):a>P?(E=x,f=1):(E=0,f=0);if(_)u=r.clone(),u.dropAllAttributes(),l||u.reverse(),(0,i.g)(g.equals(c));else{let e=!1;d>f&&(e=!0,[d,f]=[f,d]),u=r.cut(d,f,!0),u.getDescription().getAttributeCount(),e&&u.reverse()}u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}else if(y||S){if((!y||!S)&&h.P.distance(r.getStartXY(),r.getEndXY())<10*p){const n=[(0,h.k)(d,f),(0,h.k)(d,f),(0,h.k)(d,f)];y?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],o=[0,0,0];let a=Number.MAX_VALUE,m=0;for(let e=0;e<3;e++){let t=!1;if(n[e].first>n[e].second){t=!0;const s=n[e].first;n[e].first=n[e].second,n[e].second=s}i[e]=r.cut(n[e].first,n[e].second,!0),i[e].dropAllAttributes(),t&&i[e].reverse(),i[e].setCoordsForIntersector(g,c,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(_-o[e]);s<a&&(a=s,m=e)}return u=i[m],u=C(u),void(u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u)))}let n=!1;d>f&&(n=!0,[d,f]=[f,d]),u=r.cut(d,f,!0),u.dropAllAttributes(),n&&u.reverse(),u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}else{if(u=r.clone(),u.dropAllAttributes(),P>E&&u.reverse(),_<Math.max(.75*x,x-this.m_densificationDeviation*(n-1))){const e=d>f?f:d,t=u.tToLength(e)+_;let s=u.lengthToT(t);s=(0,h.s)(s,e,1),u=u.cut(e,s,!0)}u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}}processSpanCurves_(e,t,s,n,r,a,h){if(t===s&&0===n)return(0,i.g)(e.getNextVertex(t)===o.n),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const m=e.getNextVertex(t);{let t=2;for(let n=m;n!==s;n=e.getNextVertex(n))t++;(0,i.g)(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(m,s);const l=e.getXY(t),g=e.getXY(s);if(r.isClosed()){if(l.isEqualPoint2D(g)&&l.isEqualPoint2D(r.getStartXY())){let i;if(i=this.verifySegmentFitnessCurves(e,t,s,n,r,a,h)){const n=r.clone();return n.dropAllAttributes(),i<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(l.isEqualPoint2D(r.getStartXY())){if(g.isEqualPoint2D(r.getEndXY())){const o=r.clone();o.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,o,a,h);if(m)return(0,i.g)(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),o)}}else if(g.isEqualPoint2D(r.getStartXY())&&l.isEqualPoint2D(r.getEndXY())){const o=r.getReversed();o.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,o,a,h);if(m)return(0,i.g)(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),o)}this.processSpanSplitSegmentCurves(e,t,s,n,r,a,h)}processSpan_(e,t,s,n,r,i,o){return 0===this.m_type?void this.processSpanSmartTe_(e,t,s,n,r,i,o):void this.processSpanCurves_(e,t,s,n,r,i,o)}processSpanSplitSegmentCurves(e,t,s,n,r,i,o){if(r.isLine())return;if(this.fitSegmentToSpanCurves(e,t,s,n,r,i,o))return;const a=o*o;let m=n,l=t;const g=e.getXY(t);let c=r.getClosestCoordinate(g,!1);const u=r.getCoord2D(c);let _=!1;const p=h.P.sqrDistance(g,u);if(p>a){const n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),n===s)return;l=n,_=!0,m-=1}let d=s;const f=e.getXY(s);c=r.getClosestCoordinate(f,!1);const x=r.getCoord2D(c);let P=!1;const E=h.P.sqrDistance(f,x);if(E>a){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===l)return;d=t,P=!0,m-=1}if((_||P)&&this.fitSegmentToSpanCurves(e,l,d,m,r,i,o))return;let y=!1;if(!_&&p>0){const s=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),s===d)return;l=s,_=!0,y=!0,m-=1}if(!P&&E>0){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===l)return;d=t,P=!0,y=!0,m-=1}if(y&&this.fitSegmentToSpanCurves(e,l,d,m,r,i,o))return;let S=l;for(;;){const t=e.getNextVertex(S);if(this.approximateSpanSectionCurves(e,S,r,i,o),S=t,S===d)return}}fitSegmentToSpanCurves(e,t,s,n,r,i,a){const m=[];m.push(e.getXY(t));let l=t;const g=new o.S;for(;;){e.querySegment(l,g,!1,!0);const t=[.1,.25,.4,.5,.6,.75,.9,1];let r=0;for(const e of t)(2===n||1&r)&&m.push(g.get().getCoord2D(e)),r++;if(l=e.getNextVertex(l),l===s)break}const c=(()=>{let e=m[0].compare(m.at(-1));if(0===e){const t=new h.K(0);(function(e,t,s){if(s.reset(),t<3)return;const n=e[0].clone(),r=n.x,i=n.y,o=e[1].clone(),a=new h.P;for(let r=2;r<t;r++)a.assign(e[r]),s.pe((a.x-n.x)*(o.y-i)),n.assign(o),o.assign(a);s.pe((r-n.x)*(o.y-i))})(m,m.length,t),e=t.getResult()>=0?-1:1}return e>0})();c&&m.reverse();const u=r.clone();if(u.dropAllAttributes(),c&&u.reverse(),u.setSegmentFromCoordsForStitcher(m,m.length),c&&u.reverse(),u.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,s,n,u,i,a)){this.removeSpanBetween(e,t,s);const n=e.getVertexIndex(t);return e.setSegmentToIndex(n,u),!0}return!1}approximateSpanSectionCurves(e,t,s,n,r){const m=new o.S;if(!e.querySegment(t,m,!0,!1))return;const l=s.getGeometryType();if(l!==m.get().getGeometryType()){if(l===i.G.enumEllipticArc){if(m.get().getGeometryType()!==i.G.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];!function(e,t,s,n,r){const i=(0,o.$)(t),a=Math.max(4*i,s);new is(t,null,a,Number.NaN,r).approximateWithCirclesImpl(!1,n)}(0,m.get(),r,s,this.m_progressTracker);const n=e.getNextVertex(t),i=e.getPathFromVertex(t),l=new a.P;let g=t;for(let t=1,r=s.length;t<r;t++){const r=s[t],a=m.get().getCoord2D(s[t-1]),c=m.get().getCoord2D((0,h.q)(s[t-1],r,.5));m.get().queryCoord(r,l);const u=l.getXY(),_=new o.l;_.constructCircularArcThreePoint(a,u,c);let p=o.n;r<1&&(p=e.insertVertex(i,n,l)),e.setSegmentToIndex(e.getVertexIndex(g),_),g=p}return}{const s=(0,h.m)(h.P,3);m.get().queryControlPoints(s);const n=[0,0,0];m.get().queryWeights(n);const r=(0,o.U)(n),i=new o.l;return(0,o.V)(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}(0,i.d)("approximate_span_section_")}}verifySegmentFitnessCurves(e,t,s,n,r,i,a){const m=e.getXY(t),l=e.getXY(s);if(!m.isEqualPoint2D(r.getStartXY())||!l.isEqualPoint2D(r.getEndXY()))return 0;let g=0;if(r.isClosed()){const e=r.getCoord2D(.1).sub(m);g=r.getCoord2D(.7).sub(m).crossProduct(e)>=0?1:-1}const c=(0,h.d)(o.W.s_maxMonotonicPartParams,Number.NaN);let u=r.getMonotonicPartParams(c.length,c);u--;const _=new o.L,p=[1,.5,.75,.25];let d=0,f=t;const x=m.clone();for(;;){const t=e.getNextVertex(f);let n=e.getSegment(f);null===n&&(e.queryLineConnector(f,_,!0),n=_);for(let e=t===s?1:0;e<p.length;e++){const t=n.getCoord2D(p[e]);if(!r.isCloserThanDistance(t,h.E.unit(),a))return 0}if(u>1)for(let e=1;e<u;){const t=r.getCoord2D(c[e]);n.isCloserThanDistance(t,h.E.unit(),a)?(c[u-1]=(0,h.c)(c[e],c[e]=c[u-1]),u--):e++}if(g){const e=n.getCoord2D(.25);d+=e.sub(m).crossProduct(x.sub(m)),x.assign(e),e.assign(n.getCoord2D(.75)),d+=e.sub(m).crossProduct(x.sub(m)),x.assign(e)}if(f=t,f===s)return u>1?0:g?d<0?-g:g:1}}removeSpanBetween(e,t,s){e.setSegmentToIndex(e.getVertexIndex(t),null);const n=e.getNextVertex(t);n!==s&&e.removeVertices(n,s)}static st_stitchCurvesImpl(e,t,s,n,r){if(!t.hasSegmentParentage())return;hs(t);let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;)if((0,i.l)(t.getGeometryType(a))){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);const h=t.isClosedPath(s);h&&(a+=1);let m=t.getFirstVertex(s);const l=t.getSegmentParentage(m);if(h){if(-1!==l&&!t.getSegmentParentageBreakVertex(m)){let e=t.getPrevVertex(m);const s=m;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(l!==r){(0,i.g)(-1===r);break}if(m=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){m=s,t.setSegmentParentageBreakVertex(m,!0);break}e=t.getPrevVertex(e),(0,i.g)(n<a)}}}else(0,i.g)(-1===l||t.getSegmentParentageBreakVertex(m));let g=m;for(let s=0;s<a&&g!==o.n;){const h=t.getSegmentParentage(g);if(-1===h){if(s++,g=t.getNextVertex(g),g===m)break;continue}let l=0,c=o.n;const u=g;l=1;let _=t.getNextVertex(u);for(;s<a&&_!==o.n;){s++,c=_,l++;const e=t.getSegmentParentage(_);if(-1===e||t.getSegmentParentageBreakVertex(_))break;(0,i.g)(e===h),_=t.getNextVertex(_)}if(c===o.n){(0,i.g)(0);break}if(!r){const s=e.m_originalPlanarSegments[h];e.processSpan_(t,u,c,l,s,h,n)}if(g=c,g===m)break}}if(s!==o.n)break;a=t.getNextGeometry(a)}else a=s===o.n?t.getNextGeometry(a):o.n}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);t.isClosedPath(s)&&(a+=1);let h=!0,m=!1;const l=t.getFirstVertex(s);let g=l;for(let s=0;s<a&&g!==o.n;){let c=t.getSegmentParentage(g);if(-1===c||h){h=!1,s++,g=t.getNextVertex(g),m=!0;continue}let u,_,p=0;if(m?(u=t.getPrevVertex(g),_=g,(0,i.g)(u!==o.n),(0,i.g)(_!==u),(0,i.g)(-1===t.getSegmentParentage(u)||l===u)):(u=g,_=t.getNextVertex(u),s++,(0,i.g)(_!==o.n),(0,i.g)(_!==u),c=t.getSegmentParentage(_)),p=2,m=!1,-1===c||t.getSegmentParentageBreakVertex(_)){g=_;continue}let d=t.getNextVertex(_);for(s++;s<a&&d!==o.n;){_=d,p++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;(0,i.g)(e===c),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[c];e.processSpan_(t,u,_,p,s,c,n)}g=_}}if(s!==o.n)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;)if((0,i.l)(t.getGeometryType(a))){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);const h=t.isClosedPath(s);h&&(a+=1);let m=t.getFirstVertex(s);if(h){if(-1!==t.getSegmentParentage(m)){let e=m;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===a){m=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else(0,i.g)(-1===t.getSegmentParentage(m)||t.getSegmentParentageBreakVertex(m));let l=m;for(let s=0;s<a&&l!==o.n;){const h=t.getSegmentParentage(l);if(-1===h){s++,l=t.getNextVertex(l);continue}let m=0,g=o.n;const c=l;m=1;let u=t.getNextVertex(c);for(;s<a&&u!==o.n;){s++,g=u,m++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;(0,i.g)(e===h),u=t.getNextVertex(u)}if(g===o.n)break;if(!r){const s=e.m_originalPlanarSegments[h];e.processSpan_(t,c,g,m,s,h,n)}l=g}}if(s!==o.n)break;a=t.getNextGeometry(a)}else a=s===o.n?t.getNextGeometry(a):o.n}static regularizeCurve(e,t,s,n){let r=t.snapControlPoints(n*n);if(r){const n=e.getVertexIndex(s),r=t.clone();e.setSegmentToIndex(n,r)}if(t.getGeometryType()===o.y.type){const i=[],o=t.calculateSpecialPointsForCracking(n,i);if(o>0){const a=[];if(o>1)for(let e=0;e<o;e++)if(a.push(t.getCoord2D(i[e])),e>0){const t=(Math.abs(a[e].x)+Math.abs(a[e].y))*(0,h.g)(),s=h.P.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new h.P;(0,h.U)(a[e-1],a[e],.5,t),a[e-1]=t,a[e]=t}}e.splitSegment(s,i,o),r=e.snapControlPoints(s,o+1,n*n)||r;for(let t=0;t<o;t++)s=e.getNextVertex(s),e.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function _s(e,t,s,n,r){return new xs(e,s,t,n,r).do_()}function ps(e,t,s=1,n=1,r=1,i=1){if(n>i)return e;if(i>n)return t;const o=new a.P;return function(e,t,s,n,r,i,o,a,h){const m=e.equals(t);if(n>i)return o.assignCopy(e),h[0]=n,a[0]=s,m;if(i>n)return o=t,h[0]=i,a[0]=r,m;o.assignCopy(e);const l=re(e.getXY(),t.getXY(),s,n,r,i);o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank}(e,t,s,n,r,i,o,[0],[0]),o}function ds(e,t,s){return xs.fixCurveTwoPointLoops(e,t,s)}function fs(e){return(0,a.h)(e)}class xs{constructor(e,t,s,n,r){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=r,this.m_progressCounter=0}do_(){const e=new a.C(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=fs(e);let s=(0,a.U)(e);const n=1.00001*s;s*=1.000001;let r=!1;const m=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),l=this.m_shape.hasPointFeatures();for(let e=0;;e++){this.m_shape.dbgCheckSelection(),e>m&&(0,i.d)("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let a=-1;0===e&&(a=this.firstCrack_(),r||=a>0);const h=this.cluster_(t);if(this.m_shape.dbgVerifyMonotone(),r||=h,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(t,!0,!1,this.m_bTrackChanges,o.n);r||=e,this.m_shape.dbgVerifyMonotone()}const g=this.m_shape.snapControlPointsOnSelection(n*n);r||=g,this.m_shape.dbgCheckSelection();let c=!1;if((0===e&&-1===a||l||Ie(!0,this.m_shape,s,null,this.m_progressTracker))&&(c=this.crack_(n),r||=c,this.m_shape.dbgVerifyMonotone()),!c&&!xs.fixCurveTwoPointLoops(this.m_shape,t,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return r&&function(e){if(!e.hasSegmentParentage())return;hs(e);const t=new a.a(0),s=e.queryVertexIteratorOnSelection();for(let e=s.next();e!==o.n;e=s.next())t.add(e);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(o.n);const n=h.P.getNAN();e.queryXY(t.read(0),n);let r=0;const i=h.P.getNAN();for(let s=1,a=t.size();s<a;s++){{const n=t.read(s);n!==o.n?e.queryXY(n,i):i.setNAN()}if(!i.isEqualPoint2D(n)){if(s-r>1){let n=!1;for(let i=r;i<s;++i){const s=t.read(i);if(e.getSegmentParentageBreakVertex(s)){n=!0;break}}if(!n){const i=(t,s,n)=>{const r=e.getPrevVertex(t),i=e.getNextVertex(t);r!==o.n?s.assign(e.getXY(r)):s.setNAN(),i!==o.n?n.assign(e.getXY(i)):n.setNAN()},a=new h.P,m=new h.P;i(t.read(r),a,m);for(let e=r+1;e<s;++e){const s=t.read(e);if(s===o.n)continue;const r=new h.P,l=new h.P;i(s,r,l);const g=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if(!(g(r,a)&&g(l,m)||g(l,a)&&g(r,m))){n=!0;break}}}if(n)for(let n=r;n<s;++n)e.setSegmentParentageBreakVertex(t.read(n),!0)}n.setCoordsPoint2D(i),r=s}}}(this.m_shape),r}cluster_(e){return se(this.m_shape,e,o.n,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return function(e,t,s,n){if(!Ce(e))return!1;const r=new be(n);r.m_shape=e,r.m_tolerance=t,r.m_bTrackChanges=s;let i=!1;const o=e.hasCurves()?5:15;return i=e.getTotalPointCount()<o?r.crackBruteForce_():r.crackerPlaneSweep_(),i}(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,s){if(!e.hasCurves())return!1;e.dbgVerifyCurves();const n=e.createUserIndexUninitialized(),r=new a.a(0),m=e.queryVertexIteratorOnSelection();for(let t=m.next();t!==o.n;t=m.next())r.add(t),e.setUserIndex(t,n,-1);if(0===r.size())return!1;r.add(o.n),e.sortVerticesSimpleByY(r,0,r.size()-1);let l=0;const g=e.getXY(r.read(l)),c=new h.P(Number.NaN,Number.NaN),u=[];for(let t=1,s=r.size();t<s;++t){const s=r.read(t),i=s!==o.n?e.getXY(s):c;if(i.equals(g))continue;const a=[];for(let s=l;s<t;s++){const t=r.read(s),i=e.getPrevVertex(t);if(i!==o.n&&-1===e.getUserIndex(i,n)){const t=Ps(e.getXY(i),e.getSegment(i));0!==h.P.sqrDistance(g,t.otherPt)&&(t.vert=i,t.dir=-1,a.push(t)),e.setUserIndex(i,n,1)}const m=e.getNextVertex(t);if(m!==o.n&&-1===e.getUserIndex(t,n)){const s=Ps(e.getXY(m),e.getSegment(t));0!==h.P.sqrDistance(g,s.otherPt)&&(s.vert=t,s.dir=1,a.push(s)),e.setUserIndex(t,n,1)}}if(a.length>1){a.sort((e,t)=>ys(e,t));const e=Ps(c.clone(),null);a.push(e);let t=0;for(let e=1,s=a.length;e<s;e++)if(!a[e].otherPt.equals(a[e-1].otherPt)){if(e-t>1&&null!==a[t].seg){let s=!1;const n=t;for(let r=t+1;r<e;r++)if(!Es(a[n],a[r])){s=!0;break}if(s)for(let s=t;s<e&&null!==a[s].seg;s++)u.push(a[s].vert)}t=e}}l=t,g.setCoordsPoint2D(i)}for(const s of u){const n=e.getSegment(s);(0,i.g)(null!==n);const r=e.getXY(s),o=e.getXY(e.getNextVertex(s));if(h.P.distance(r,o)<3*t)e.setSegmentToIndex(e.getVertexIndex(s),null);else{const t=n.lengthToT(.5*n.calculateLength2D());e.splitSegment(s,[t],1)}}return e.removeUserIndex(n),u.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=(0,a.c)(null,e,!0).total();if(4*t<this.m_tolerance.total()){let e=!1;const s=1.1*t,n=t,r=this.cluster_(s);e||=r;let i=0;this.m_bFilterDegenerateSegments&&(i=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,o.n));const a=this.crack_(n);return e||=a,e?1:i?2:0}return-1}progress_(e=!1){this.m_progressCounter++,!e&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function Ps(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function Es(e,t){if((0,i.g)(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const s=e.seg.getGeometryType();if(s!==t.seg.getGeometryType())return!1;if(s===i.G.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=(0,h.c)(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=(0,h.c)(o,o=a)),r.equals(o)&&i.equals(a)}if(s===i.G.enumRationalBezier2){const s=e.seg,n=t.seg,r=s.getControlPoint1(),i=n.getControlPoint1();if(!r.equals(i))return!1;const o=[0,0,0];s.queryWeights(o),-1===e.dir&&(o[2]=(0,h.c)(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=(0,h.c)(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}(0,i.d)("")}function ys(e,t){const s=e.otherPt.compare(t.otherPt);return 0!==s?s:function(e,t){if(null===e.seg||null===t.seg)return null!==e.seg?-1:null!==t.seg?1:0;const s=e.seg.getGeometryType(),n=t.seg.getGeometryType();return s<n?-1:s>n?1:0}(e,t)}var Ss=i.h,Cs=i.f,Is=i.z;function vs(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:(0,i.g)(0,"unrecognized cut side")}return 3}function bs(e,t,s,n,r,o,h){const m=new ks(r);m.m_bOGCOutput=!0;const l=e.getGeometryType()===i.G.enumPolygon&&1===e.getFillRule()&&!(0,a.Y)(n);return m.planarSimplifyImpl_(e,t,l,s,n,r,o,h)}function Gs(e,t,s,n,r,i,o,a){return new ks(i).planarSimplifyImpl_(e,t,s,n,r,i,o,a)}function ws(e,t,s){return function(e,t,s){const n=e.createInstance(),r=(0,h.m)(h.P,100),o=new Array(100),a=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&(0,i.d)("");for(let i=0;i<a;){const a=e.queryCoordinates(r,r.length,i,-1)-i;l?ts(t,r,a,s.total(),o):ss(t,r,a,s.total(),o);let h=0;for(let t=0;t<a;t++)0===o[t]&&(m&&(m=!1,n.addPoints(e,0,i)),h!==t&&n.addPoints(e,i+h,i+t),h=t+1);m||h===a||n.addPoints(e,i+h,i+a),i+=a}return m?e:n}(e,t,s)}function Ns(e,t,s,n){if(e.getDimension()>t.getDimension())return Fs(Hs(e),e,0,"^");if(e.getDimension()<t.getDimension())return Fs(Hs(t),e,0,"^");if(e.isEmpty())return Fs(Hs(t),e,0,"^");if(t.isEmpty())return Fs(Hs(e),e,0,"^");const h=new r.Envelope2D;e.queryEnvelope(h);const m=new r.Envelope2D;t.queryEnvelope(m);const l=new r.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=new ks(n),u=new o.E,_=u.addGeometry(Hs(e)),p=u.addGeometry(Hs(t));let d=0,f=null;if(u.hasCurves()){f=new cs;const e=u.getEnvelope2D(n);d=ls(g.total()),os(u,ms(g.total(),e),g.total(),0,f,null,n)}c.setEditShapeCrackAndCluster(u,g);const x=c.symmetricDifference(_,p);null!==f&&f.stitchCurves(u,x,d,!0);const P=Fs(u.getGeometry(x),e,0,"^");return Ss(P.getGeometryType())&&(P.getImpl().setIsSimple(4,g.total()),P.getGeometryType()===i.G.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Ts(e,t,s){return function(e,t,s){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return e.createInstance();const n=[new h.P],r=[0],o=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&(0,i.d)(""),n[0]=e.getXY(),o?ts(t,n,1,s.total(),r):ss(t,n,1,s.total(),r),0===r[0]?e.createInstance():e}(e,t,s)}function Ds(e,t,s,n,r,h=!1){0===t&&(0,i.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=t;s<n;s++)m=Math.max(e[s].getDimension(),m);if(2===m||1===m)return new ks(n).dissolveMultiPaths_(m,!1,e,t,s,r,h);let l=0,g=-1;for(let s=0,n=t;s<n;s++)e[s].getDimension()===m&&(-1===g&&(g=s),e[s].isEmpty()||(g=s,l++));if(l<2)return Hs(e[g]);const c=a.p.constructEmpty(),u=new o.E;let _=o.n;for(let s=0,n=t;s<n;s++)if(e[s].getDimension()===m&&!e[s].isEmpty()){_===o.n?_=u.addGeometry(Hs(e[s])):u.appendGeometry(_,Hs(e[s]));const t=a.p.constructEmpty();e[s].queryLooseEnvelope(t),c.mergeEnv3D(t)}const p=(0,a.c)(s,c.getEnvelope2D(),!0),d=new ks(n);if(h){const e=(0,a.Z)(s,c.getEnvelopeZs(),!0);return d.planarSimplify3DImpl_(u,p,e,0,!0)}return d.m_bOGCOutput=!0,d.planarSimplifyMultiPoints(u,p,!1,-1)}function Vs(e,t,s,n,r,h=!1){t<2&&(0,i.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=t;s<n;s++)m=Math.max(e[s].getDimension(),m);if(2===m||1===m)return new ks(n).dissolveMultiPaths_(m,!0,e,t,s,r,h);const l=a.p.constructEmpty(),g=new o.E;let c=o.n,u=0,_=-1;for(let s=0,n=t;s<n;s++)if(e[s].getDimension()===m&&(-1===_&&(_=s),!e[s].isEmpty())){_=s,c===o.n?c=g.addGeometry(Hs(e[s])):g.appendGeometry(c,Hs(e[s]));const t=a.p.constructEmpty();e[s].queryLooseEnvelope(t),l.mergeEnv3D(t),u++}if(u<2)return Hs(e[_]);const p=0===m?s:null,d=(0,a.c)(p,l.getEnvelope2D(),!0),f=new ks(n);if(h){const e=(0,a.Z)(p,l.getEnvelopeZs(),!0);return f.m_bOGCOutput=!0,f.planarSimplify3DImpl_(g,d,e,0,!0)}return f.planarSimplifyMultiPoints(g,d,!0,-1)}class ks{constructor(e){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=h.P.getNAN(),this.m_dummyPt2=h.P.getNAN(),this.m_fromEdgeForPolylines=o.n,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=e}linesToPolygonsImpl(e,t){let s=0,n=0,r=null;if(e.hasCurves()){r=new cs;const i=e.getEnvelope2D(this.m_progressTracker);n=ls(t.total());const o=ms(t.total(),i);s=gs(o,n),os(e,o,t.total(),0,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(s));const i=this.m_topoGraph.createUserIndexForChains(),a=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(a,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(a);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);const h=[];for(let t=this.m_topoGraph.getFirstChain();t!==o.n;t=this.m_topoGraph.getChainNext(t)){if(1===this.m_topoGraph.getChainUserIndex(t,i))continue;this.m_topoGraph.setChainUserIndex(t,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);if(0===this.m_topoGraph.getChainArea(t))continue;const s=this.m_topoGraph.extractPolygonFromChainAndIslands(e,o.n,t,o.n);null!=r&&r.stitchCurves(e,s,n,!1);const a=e.getGeometry(s);h.push(a)}return new u.S(h)}autoCompleteImpl(e,t,s){let n=0,r=0,i=null;if(e.hasCurves()){i=new cs;const t=e.getEnvelope2D(this.m_progressTracker);r=ls(s.total());const o=ms(s.total(),t);n=gs(o,r),os(e,o,s.total(),0,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,s.add(n));const a=this.m_topoGraph.getGeometryID(t),h=this.m_topoGraph.createUserIndexForChains(),m=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(m,h,1);for(let e=this.m_topoGraph.getChainFirstIsland(m);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,h,1);const l=[];for(let t=this.m_topoGraph.getFirstChain();t!==o.n;t=this.m_topoGraph.getChainNext(t)){if(1===this.m_topoGraph.getChainUserIndex(t,h))continue;this.m_topoGraph.setChainUserIndex(t,h,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,h,1);if(0!==this.m_topoGraph.getChainParentage(t))continue;const s=this.m_topoGraph.getChainHalfEdge(t);let n=s,m=!1;do{const e=this.m_topoGraph.getHalfEdgeTwin(n);if(this.m_topoGraph.getHalfEdgeChain(e)!==t&&0!==(this.m_topoGraph.getHalfEdgeParentage(n)&a)){m=!0;break}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==s);if(!m)continue;if(0===this.m_topoGraph.getChainArea(t))continue;const g=this.m_topoGraph.extractPolygonFromChainAndIslands(e,o.n,t,o.n);null!==i&&i.stitchCurves(e,g,r,!1);const c=e.getGeometry(g);l.push(c)}return new u.S(l)}setEditShape(e,t=!1){null===this.m_topoGraph&&(this.m_topoGraph=new K),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){_s(e,t,this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,this.m_bOGCOutput,o.n,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==o.n;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==o.n;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===o.n)continue;let r=s.getNextVertex(n);for(;r!==o.n;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),a=this.m_topoGraph.getHalfEdgeConnector(t,i);if(a!==o.n){const t=this.m_topoGraph.getHalfEdgeTwin(a);this.m_topoGraph.setHalfEdgeUserIndex(a,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}n=r,r=s.getNextVertex(n)}}}flushVertices_(e,t){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),r=new o.S,i=s.insertPath(e,o.n);t.push(t[0]);const a=t.length;let h=o.n;for(let e=0;e<a;e++){const o=t[e];if(h=s.addVertex(i,o),!n)continue;const m=this.m_topoGraph.getClusterFromVertex(o);if(e>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(h,!0),e<a-1){const n=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(t[e+1])),i=this.m_topoGraph.getSegmentParentage(n);s.setSegmentParentageAndBreak(h,i,e>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,r),s.setSegmentToIndex(s.getVertexIndex(h),r.get().clone()))}}if(n){const e=this.m_topoGraph.getClusterFromVertex(t[a-1]);this.m_topoGraph.isBreakNode(e)&&s.setSegmentParentageBreakVertex(h,!0)}s.setClosedPath(i,!0)}processPolygonCuts_(e,t,s,n){const r=this.m_topoGraph.getGeometryID(s),a=this.m_topoGraph.getGeometryID(n),h=[],m=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);if(n===o.n)continue;let g=n;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(g,l)){let s=g,n=g,o=!1,c=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,l,1),o||0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&r)&&(n=s,o=!0),o){const t=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(n);h.push(r),-1!==e&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&(c|=this.m_topoGraph.getHalfEdgeUserIndex(s,e))}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==n);if(o&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(n))>0){const e=m.createGeometry(i.G.enumPolygon);this.flushVertices_(e,h),-1!==t&&m.setGeometryUserIndex(e,t,c)}h.length=0}g=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(g))}while(g!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(e,t,s,n){this.m_topoGraph.removeSpikes_();let r=-1;-1!==e&&(r=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(r,s)),this.processPolygonCuts_(r,e,t,s),-1!==r&&(this.m_topoGraph.deleteUserIndexForHalfEdges(r),r=-1);const i=this.m_topoGraph.getShape();for(let e=i.getFirstGeometry();e!==o.n;e=i.getNextGeometry(e))e!==t&&e!==s&&n.push(e);n.sort((e,t)=>{const s=i.getFirstPath(e),n=i.getRingArea(s),r=i.getFirstPath(t),o=i.getRingArea(r);return n<o?-1:n>o?1:0})}cut(e,t,s,n,r){const o=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(n),h=(0,i.z)(o),m=(0,i.z)(a);if(2!==h||1!==m){if(1===h&&1===m)return void new Ms(this,e,t,s,n,r).Do();(0,i.d)("")}else this.cutPolygonPolyline_(t,s,n,r)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){const t=e.getGeometryType();if(t===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.G.enumPoint){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if((0,i.f)(t)){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.G.enumMultiPoint&&t!==i.G.enumPolyline&&t!==i.G.enumPolygon&&(0,i.a)("Unexpected geometry type"),e}dissolveNonSimplePolygons(e,t,s,n){(0,i.g)(t>0);const r=new o.E;let a=0,h=-1;for(let s=0,n=t;s<n;s++)2===e[s].getDimension()&&(-1===h&&(h=s),e[s].isEmpty()||(a++,r.addGeometry(e[s])));return 0===a?((0,i.g)(h>=0),this.normalizeInputGeometry(e[h])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,s,n,m,l,g){(0,i.g)(e>=1&&e<=2),(0,i.g)(n>0);const c=8&l?1:2,u=a.p.constructEmpty();let _=0,p=-1,d=!0;for(let t=0,r=n;t<r;t++)if(s[t].getDimension()===e&&(-1===p&&(p=t),!s[t].isEmpty())){p=t,_++;const n=a.p.constructEmpty();if(s[t].queryLooseEnvelope(n),u.mergeEnv3D(n),2===e&&d&&s[t].getGeometryType()===i.G.enumPolygon)if(16&l){const e=[0],n=s[t].getImpl().getIsSimple(0,e),r=this.m_bOGCOutput?5===n:(0,a.i)(n);d&&=r}else{const e=(0,a.k)(s[t],0);d&&=e}}if(_<2&&((0,i.g)(p>=0),0===_||!(16&l)))return this.normalizeInputGeometry(s[p]);if(!d){const e=(0,a.c)(t?null:m,u.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,n,e,l)}const f=s.slice(0,n),x=(0,a.c)(m,u.getEnvelope2D(),!0),P=10*(0,a.h)(x);let E=new a.C(0,0);if(g&&(E=(0,a.Z)(m,u.getEnvelopeZs(),!0)),1===_&&1===e&&2===c&&!t)return g?((0,i.g)(0),{}):this.m_bOGCOutput?bs(f[p],x,!1,-1,this.m_progressTracker,c,!1):Gs(f[p],x,!1,!1,-1,this.m_progressTracker,c,!1);const y=new a.a3;y.startConstruction();let S=2===e?3:4,C=0;for(let s=0,o=n;s<o;s++){if(f[s].getDimension()!==e||f[s].isEmpty())continue;let n=f[s].getGeometryType();if(n!==i.G.enumEnvelope){if((0,i.f)(n)?(f[s]=this.normalizeInputGeometry(f[s]),n=i.G.enumPolyline):(0,i.g)((0,i.h)(n)),1===e){(0,i.g)(n===i.G.enumPolyline);let e=-1;if(g)(0,i.g)(0,"3d not implemented yet");else{const t=[0];e=f[s].getImpl().getIsSimple(x.total(),t)}if(this.m_bOGCOutput?5!==e:!(0,a.i)(e))if(t)S=-1;else{g?(0,i.g)(0,"3d not implemented yet"):this.m_bOGCOutput?f[s]=bs(f[s],x,!1,-1,this.m_progressTracker,c,!1):f[s]=Gs(f[s],x,!1,!1,-1,this.m_progressTracker,c,!1);const e=[0];(0,i.g)((0,a.i)(f[s].getImpl().getIsSimple(x.total(),e)))}}else{(0,i.g)(n===i.G.enumPolygon);const e=[0],t=f[s].getImpl().getIsSimple(0,e);(0,i.g)((0,a.Y)(t))}const o=f[s].getImpl();for(let e=0,t=o.getPathCount();e<t;e++){const t=r.Envelope2D.constructEmpty();o.queryLoosePathEnvelope(e,t),t.inflateCoords(P,P),y.addEnvelope(C,t),C++}}else{(0,i.g)(n===i.G.enumEnvelope);const e=r.Envelope2D.constructEmpty();f[s].queryLooseEnvelope(e),e.inflateCoords(P,P),y.addEnvelope(C,e),C++,S=-1}}y.endConstruction();const I=C,v=(0,h.d)(I,-2147483647),b=(0,h.d)(I,-1);let G=0;p=-1,C=0;for(let t=0,s=n;t<s;t++){if(f[t].getDimension()!==e)continue;if(-1===p&&(p=t),f[t].isEmpty())continue;p=t,G++;const s=f[t].getGeometryType();if((0,i.h)(s))for(let e=0,s=f[t].getPathCount();e<s;e++)b[C]=t,v[C]=-e-1,C++;else(0,i.g)(s===i.G.enumEnvelope),b[C]=t,v[C]=-1,C++}if(G<2&&2===e)return(0,i.g)(p>=0),this.normalizeInputGeometry(f[p]);let w=I;for(;y.next()&&w>0;){this.progress_();const e=y.getHandleA(),t=y.getHandleB(),s=y.getElement(e),n=y.getElement(t);b[s]!==b[n]&&(v[s]<0&&(w--,v[s]=-(v[s]+1)),v[n]<0&&(w--,v[n]=-(v[n]+1)))}const N=new o.E;let T,D=!1,V=0;for(let t=0,s=n;t<s;t++){if(f[t].getDimension()!==e||f[t].isEmpty())continue;const s=f[t].getGeometryType(),n=V;let r=0,a=0;const h=(0,i.h)(s)?f[t]:null;for(let e=n,s=v.length;e<s&&b[e]===t;e++)v[e]>=0&&(r++,a+=h?h.getPathSize(v[e]):(0,i.v)(f[t])),V++;if(a>.95*(0,i.v)(f[t])){N.addGeometry(this.normalizeInputGeometry(f[t]));for(let e=n;e<V;e++)v[e]<0&&(v[e]=-(v[e]+1))}else{if(0===r){D=!0;continue}{D=!0,(0,i.g)((0,i.h)(s)),(0,i.g)(null!=h);const e=new o.P({vd:f[t].getDescription()}),r=new o.a({vd:f[t].getDescription()}),a=s===i.G.enumPolygon?e:r;for(let e=n;e<V;e++)v[e]>=0&&a.addPath(h,v[e],!0);N.addGeometry(a)}}}if(N.getFirstGeometry()!==o.n){const s=2===e,n=t?(0,a.c)(null,u.getEnvelope2D(),!0):x;let r=new a.C(0,0);if(g&&(r=t?(0,a.Z)(null,u.getEnvelopeZs(),!0):E),2===e&&!(2&l)){N.collapseAllGeometriesToFirst();let e=0,t=null;if(N.hasCurves()&&!N.hasSegmentParentage()){t=new cs;const s=N.getEnvelope2D(this.m_progressTracker);e=ls(n.total()),os(N,ms(n.total(),s),n.total(),0,t,null,this.m_progressTracker)}(function(e,t,s,n){s>0&&se(e,s,t,!1,n),new Se(n).executeImpl_(e,t)})(N,N.getFirstGeometry(),n.total(),this.m_progressTracker),null!==t&&t.stitchCurves(N,o.n,e,!0)}if(g)T=this.planarSimplify3DImpl_(N,n,r,c,!0);else if(2===e)T=this.planarSimplifyPolygons(N,n,s,t,-1,!1);else{const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=c,T=this.planarSimplifyPolylines(N,n,t,e,-1)}if(!D){const e=[0];S=T.getImpl().getIsSimple(n.total(),e)}}else(0,i.g)(D),(0,i.g)(p>=0),T=2===e?new o.P({vd:f[p].getDescription()}):new o.a({vd:f[p].getDescription()});if(D){let e=0;for(let t=0,s=v.length;t<s;t++){const s=b[t];if(!(s<0)&&v[t]<0){const n=f[s].getGeometryType(),r=(0,i.h)(n)?f[s]:null;if(r){const s=-(v[t]+1);e+=r.getPathSize(s)}else e+=4}}T.reserve(T.getPointCount()+e);for(let e=0,t=v.length;e<t;e++){const t=b[e];if(!(t<0)&&v[e]<0){const s=f[t].getGeometryType(),n=(0,i.h)(s)?f[t]:null;if(n){const t=-(v[e]+1);T.addPath(n,t,!0)}else s===i.G.enumEnvelope?T.addEnvelope(f[t],!1):((0,i.g)((0,i.f)(s)),T.addSegment(f[t],!0))}}}let k=0;if(2===e?-1!==S&&(S=3,k=t?0:x.total()):((0,i.g)(1===e),t||-1===S||(k=x.total())),g||T.getImpl().setIsSimple(S,k),!t&&D)if(2===e){if(!g)return(new Js).execute(T,m,!1,this.m_progressTracker);(0,i.g)(0,"3d not yet implemented")}else 1===e&&1!==c&&(T=g?((0,i.g)(0),{}):function(e,t,s,n){const r=new ks(n),a=new o.E,h=a.addGeometry(t),m=r.planarSimplifyNoCrackingAndCluster(e,a,h,s);return(0,i.g)(m,"planar_simplify_no_cracking_and_cluster"),a.getGeometry(h)}(this.m_bOGCOutput,T,c,this.m_progressTracker),T.getImpl().setIsSimple(S,k));return T}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==o.n)do{if(this.progress_(),1!==this.m_topoGraph.getHalfEdgeUserIndex(r,e)){const s=this.m_topoGraph.getHalfEdgeTwin(r);this.m_topoGraph.setHalfEdgeUserIndex(s,e,1),this.m_topoGraph.setHalfEdgeUserIndex(r,e,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(r);if(this.isGoodParentage(n)){const e=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(e)&&t.push(r)}}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,s,n){let r=(0,h.j)(),a=o.n;for(let n=this.m_topoGraph.getClusterVertexIterator(e);n!==o.n;n=this.m_topoGraph.incrementVertexIterator(n)){const e=this.m_topoGraph.getVertexFromVertexIterator(n),i=t.getUserIndex(e,s);i>=0&&i<r&&(r=i,a=e)}(0,i.g)(a!==o.n);let m=t.getUserIndex(a,n);return m>0&&(t.setUserIndex(a,n,--m),0===m&&t.setUserIndex(a,s,-1)),a}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,s,n,r){const a=this.m_topoGraph.getShape();if(a.getGeometryType(e)!==i.G.enumPolygon)return;const h=a.hasSegmentParentage(),m=new o.S;for(let i=a.getFirstPath(e);i!==o.n;i=a.getNextPath(i)){const e=a.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);const l=this.m_topoGraph.getHalfEdgeFromVertex(e);if(l===o.n)continue;const g=this.m_topoGraph.getHalfEdgeUserIndex(l,s);if(1===g||2===g)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 u=a.insertPath(t,o.n);a.setClosedPath(u,!0);let _=l,p=e,d=this.m_topoGraph.getClusterFromVertex(p),f=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(p,r),t=a.addVertex(u,e);if(this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,m),a.setSegmentToIndex(a.getVertexIndex(t),m.get().clone())),h){const e=this.m_topoGraph.getSegmentParentage(_);a.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(d))}let i,l;-1!==n&&this.m_topoGraph.setClusterUserIndex(d,n,1),this.m_topoGraph.setHalfEdgeUserIndex(_,s,1),_=this.m_topoGraph.getHalfEdgeNext(_);do{i=1===f?a.getNextVertex(p):a.getPrevVertex(p),l=i!==o.n?this.m_topoGraph.getClusterFromVertex(i):o.n}while(l===d);const g=this.m_topoGraph.getHalfEdgeOrigin(_);if(g!==l){do{i=1===f?a.getPrevVertex(p):a.getNextVertex(p),l=i!==o.n?this.m_topoGraph.getClusterFromVertex(i):o.n}while(l===d);if(g!==l){l=g;const e=this.m_topoGraph.getClusterVertexIterator(l);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else f=-f}d=l,p=i}while(_!==l)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==o.n&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==o.n&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const a=new o.S,h=this.m_topoGraph.getShape();h.dbgVerifyCurves();const m=h.hasSegmentParentage();for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n)continue;let l=t;do{this.progress_();const e=this.m_topoGraph.getHalfEdgeUserIndex(l,r);if(1!==e&&2!==e){const e=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(e)){const e=h.insertPath(s,o.n);h.setClosedPath(e,!0);let t=l;do{const s=this.m_topoGraph.getHalfEdgeVertexIterator(t);let l=o.n;if(s!==o.n)l=this.m_topoGraph.getVertexFromVertexIterator(s);else{const e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(t));l=this.m_topoGraph.getVertexFromVertexIterator(e),l=h.getNextVertex(l)}const g=this.chooseVertexFromVertexCluster_(l,n),c=h.addVertex(e,g);if(m){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);h.setSegmentParentageAndBreak(c,e,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,a),h.setSegmentToIndex(h.getVertexIndex(c),a.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(t,r,1),-1!==i){const e=this.m_topoGraph.getClusterFromVertex(g);this.m_topoGraph.setClusterUserIndex(e,i,1)}t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,r,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==t)}}topoOperationPolygonPolygon_(e,t,s,n=!1){this.dissolveTopoGraphCommonEdges_();const r=this.m_topoGraph.getShape(),a=r.createGeometry(i.G.enumPolygon),h=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,a,s,h,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(h),n||Fe(r,a,3,this.m_bOGCOutput,o.n,this.m_progressTracker),a}topoOperationPolyline_(e,t){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(o.n,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.G.enumMultiPoint),s=e.insertPath(t,o.n);for(let t=this.m_topoGraph.getFirstCluster();t!==o.n;t=this.m_topoGraph.getNextCluster(t)){const n=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(n)){let n=o.n;for(let s=this.m_topoGraph.getClusterVertexIterator(t);s!==o.n;s=this.m_topoGraph.incrementVertexIterator(s)){const t=this.m_topoGraph.getVertexFromVertexIterator(s);n===o.n&&(n=t);const r=e.getGeometryFromPath(e.getPathFromVertex(t)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){n=t;break}}e.addVertex(s,n)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=(0,i.z)(s),a=(0,i.z)(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=o.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===a?this.topoOperationPolygonPolygon_(e,t,l):1===r&&a>0||1===a&&r>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===r||0===a?this.topoOperationMultiPoint_():void(0,i.d)("")}topoOperationPolygonPolygonEx(e,t,s){const n=this.m_topoGraph.getShape(),r=n.createGeometry(i.G.enumPolygon),a=n.createGeometry(i.G.enumPolyline),h=n.createGeometry(i.G.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=o.n;const l=this.m_topoGraph.createUserIndexForHalfEdges(),g=this.m_topoGraph.createUserIndexForClusters();n.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,r,s,l,g),n.dbgVerifyCurves();const c=n.hasSegmentParentage(),u=new o.S;for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n)continue;let r=t;do{let t=this.m_topoGraph.getHalfEdgeUserIndex(r,l),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(r),l),h=t|i;if(2===h){let m=this.m_topoGraph.getHalfEdgeParentage(r);if(this.isGoodParentage(m)){const _=n.insertPath(a,o.n);let p=r;const d=this.chooseVertexFromCluster_(e,s);let f=n.addVertex(_,d);if(c){const e=this.m_topoGraph.getSegmentParentage(r),t=this.m_topoGraph.getHalfEdgeOrigin(r);n.setSegmentParentageAndBreak(f,e,this.m_topoGraph.isBreakNode(t))}this.m_topoGraph.isHalfEdgeCurve(r)&&(this.m_topoGraph.querySegmentXY(r,u),n.setSegmentToIndex(n.getVertexIndex(f),u.get().clone())),this.m_topoGraph.setClusterUserIndex(e,g,1);do{this.progress_();const e=this.m_topoGraph.getHalfEdgeTo(p),o=this.chooseVertexFromCluster_(e,s);if(f=n.addVertex(_,o),c){const e=this.m_topoGraph.getSegmentParentage(r),t=this.m_topoGraph.getHalfEdgeOrigin(r);n.setSegmentParentageAndBreak(f,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.setHalfEdgeUserIndex(p,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l,1),this.m_topoGraph.setClusterUserIndex(e,g,1),p=this.m_topoGraph.getHalfEdgeNext(p),t=this.m_topoGraph.getHalfEdgeUserIndex(p,l),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l),h=t|i,2!==h)break;if(m=this.m_topoGraph.getHalfEdgeParentage(p),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(p,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l,1);break}this.m_topoGraph.isHalfEdgeCurve(r)&&p!==r&&(this.m_topoGraph.querySegmentXY(r,u),n.setSegmentToIndex(n.getVertexIndex(f),u.get().clone()))}while(p!==r)}else this.m_topoGraph.setHalfEdgeUserIndex(r,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(r),l,1)}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==t)}for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){if(this.progress_(),1===this.m_topoGraph.getClusterUserIndex(e,g))continue;const t=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(t)){m===o.n&&(m=n.insertPath(h,o.n));const t=this.m_topoGraph.getClusterVertexIterator(e);let r=o.n;if(t!==o.n){r=this.m_topoGraph.getVertexFromVertexIterator(t);const e=this.chooseVertexFromVertexCluster_(r,s);n.addVertex(m,e)}}}this.m_topoGraph.deleteUserIndexForClusters(g),this.m_topoGraph.deleteUserIndexForHalfEdges(l),n.dbgVerifyCurves(),Fe(n,r,3,this.m_bOGCOutput,o.n,this.m_progressTracker);const _=[o.n,o.n,o.n];return _[0]=h,_[1]=a,_[2]=r,_}topoOperationPolylinePolylineOrPolygonEx(e,t){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(o.n,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.G.enumMultiPoint),s=e.insertPath(t,o.n);for(let t=this.m_topoGraph.getFirstCluster();t!==o.n;t=this.m_topoGraph.getNextCluster(t)){const n=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(n)){let n=o.n;for(let s=this.m_topoGraph.getClusterVertexIterator(t);s!==o.n;s=this.m_topoGraph.incrementVertexIterator(s)){const t=this.m_topoGraph.getVertexFromVertexIterator(s);n===o.n&&(n=t);const r=e.getGeometryFromPath(e.getPathFromVertex(t)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){n=t;break}}e.addVertex(s,n)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Is(s),a=Is(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=o.n;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===a)return this.topoOperationPolygonPolygonEx(e,t,l);if(1===r&&a>0||1===a&&r>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[t,e]}if(0===r||0===a){const e=[];return e.push(this.topoOperationMultiPoint()),e}(0,i.d)("")}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){const s=this.getCombinedHalfEdgeParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t),r=this.m_topoGraph.getHalfEdgeTo(t);let i=0,a=0;for(let h=this.m_topoGraph.getClusterVertexIterator(n);h!==o.n;h=this.m_topoGraph.incrementVertexIterator(h)){const n=this.m_topoGraph.getVertexFromVertexIterator(h),m=e.getPathFromVertex(n),l=e.getGeometryFromPath(m),g=this.m_topoGraph.getGeometryID(l),c=e.getFirstVertex(m),u=0!==(g&s);u&&c===n&&(this.m_fromEdgeForPolylines=t);const _=e.getNextVertex(n);if(_!==o.n&&this.m_topoGraph.getClusterFromVertex(_)===r){if(i++,u){if(this.m_fromEdgeForPolylines===o.n&&c===_){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}a++}}else{const s=e.getPrevVertex(n);if(s!==o.n&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===o.n&&c===s){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}a--}}}return this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(r,this.m_dummyPt2),(0!==a?a:i)*h.P.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(e,t){const s=this.m_topoGraph.getHalfEdgePrev(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return o.n;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=o.n;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==o.n)return o.n;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(r))}return i}tryMoveThroughCrossroadForward(e,t){const s=this.m_topoGraph.getHalfEdgeNext(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){const t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return o.n;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=o.n;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==o.n)return o.n;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(r))}return i}isOnALoop(e,t){let s=e;const n=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let r=0;r<n;r++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,t))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===e)return!0}(0,i.d)("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,a,m,l,g,c){(0,i.g)(r===o.n&&a>=0&&m>=0||-1===a&&-1===m),(0,i.g)(-1===l&&1!==c.unsplitBehavior||-1!==l&&1===c.unsplitBehavior);const u=c.ogcRule,_=c.allCrossRoadsImpassable,p=1===c.unsplitBehavior,d=0===c.unsplitBehavior,f=this.m_topoGraph.getShape(),x=f.hasSegmentParentage();let P=e,E=this.m_topoGraph.getHalfEdgeTwin(P);const y=new o.S;this.m_fromEdgeForPolylines=o.n;let S=this.prevailingDirection(f,P),C=P,I=o.n,v=!1,b=!1,G=!1;if(!p)for(;;){const t=this.m_topoGraph.getHalfEdgePrev(P);if(t===E){G=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(E);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){v=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(_){v=!0;break}if(P=this.tryMoveThroughCrossroadBackwards(P,!0),P===o.n){v=!0;break}E=this.m_topoGraph.getHalfEdgeTwin(P)}else P=t,E=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){G=!0;break}if(P===e){I=e,b=!0;break}const r=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(r))break;C=P,S+=this.prevailingDirection(f,P)}if(I===o.n){for(P=e,E=this.m_topoGraph.getHalfEdgeTwin(P),I=P;;){const e=this.m_topoGraph.getHalfEdgeNext(P),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){v=!0;break}if(e===E){G=!0;break}if(-1!==l){const e=this.m_topoGraph.getHalfEdgeOrigin(E);if(1===this.m_topoGraph.getClusterUserIndex(e,l)){v=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(E);if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(t||_){v=!0;break}if(P=this.tryMoveThroughCrossroadForward(P,!0),P===o.n){v=!0;break}E=this.m_topoGraph.getHalfEdgeTwin(P)}else P=e,E=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){G=!0;break}const r=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(r))break;I=P,S+=this.prevailingDirection(f,P)}const t=this.m_topoGraph.getHalfEdgeOrigin(C);b=this.m_topoGraph.getHalfEdgeTo(I)===t}else if(this.m_fromEdgeForPolylines!==o.n){C=e,I=this.tryMoveThroughCrossroadBackwards(C,!1),(0,i.g)(I!==o.n);const t=this.m_topoGraph.getHalfEdgeTwin(C);this.m_topoGraph.getHalfEdgeNext(t)}let w=b;b||G||g&&(w=this.isOnALoop(e,s),w||(w=this.isOnALoop(E,s)));const N=S>=0;let T=!1;w&&v&&(b?(T=u,N&&(T||p||d)&&C!==e&&((0,i.g)(!p),C=e,T=!1)):(p||N&&d)&&(C=e));let D=0;for(P=C;E=this.m_topoGraph.getHalfEdgeTwin(P),this.m_topoGraph.setHalfEdgeUserIndex(P,s,1),this.m_topoGraph.setHalfEdgeUserIndex(E,s,1),D++,P!==I;)P=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1);N||(I=(0,h.c)(C,C=I),I=this.m_topoGraph.getHalfEdgeTwin(I),C=this.m_topoGraph.getHalfEdgeTwin(C));let V=f.insertPath(t,o.n);P=C;const k=this.m_topoGraph.getHalfEdgeOrigin(C);let F;F=-1!==a?this.chooseVertexByOrder(k,f,a,m):this.chooseVertexFromCluster_(k,r),this.m_topoGraph.isStrongPathNode(k)&&f.setStrongPathStart(V,!0);let H=f.addVertex(V,F),A=H;-1!==n&&this.m_topoGraph.setClusterUserIndex(k,n,1);let M=0;const U=T?Math.trunc((D+1)/2):-1;let q=o.n,O=!0,Y=o.n;for(;;){if(x){const e=this.m_topoGraph.getSegmentParentage(P),t=this.m_topoGraph.getHalfEdgeOrigin(P);f.setSegmentParentageAndBreak(A,e,O||this.m_topoGraph.isBreakNode(t))}O=!1,this.m_topoGraph.isHalfEdgeCurve(P)&&(this.m_topoGraph.querySegmentXY(P,y),f.setSegmentToIndex(f.getVertexIndex(A),y.get().clone())),q!==o.n&&-1!==m&&f.addToUserIndex(q,m,-1);const e=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1),s=this.m_topoGraph.getHalfEdgeTo(P);let i;if(i=-1!==a?this.chooseVertexByOrder(s,f,a,m):this.chooseVertexFromCluster_(s,r),H=f.addVertex(V,i),Y=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),x&&this.m_topoGraph.isBreakNode(s)&&f.setSegmentParentageBreakVertex(H,!0),q=i,M++,T&&M===U&&(V=f.insertPath(t,o.n),H=f.addVertex(V,i),O=!0,-1!==m&&f.addToUserIndex(i,m,-1),q=o.n),P===I)break;P=e,A=H}Y!==o.n&&this.m_topoGraph.isStrongPathNode(Y)&&f.setStrongPathEnd(V,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,s,n){(0,i.g)(t===o.n||e===o.n);const r=this.m_topoGraph.getShape(),a=t=>e===o.n?t===o.n?r.getFirstGeometry():r.getNextGeometry(t):t===o.n?e:o.n,m=r.createGeometry(i.G.enumPolyline);let l=-1;s&&(l=this.m_topoGraph.createUserIndexForClusters());const g=this.m_topoGraph.createUserIndexForHalfEdges(),c=t===o.n?r.createUserIndex():-1,u=t===o.n?r.createUserIndex():-1;let _=-1;if(1===n.unsplitBehavior){_=this.m_topoGraph.createUserIndexForClusters();for(let e=a(o.n);e!==o.n;e=a(e))for(let t=r.getFirstPath(e);t!==o.n;t=r.getNextPath(t)){{const e=r.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,_,1)}if(!r.isClosedPath(t)){const e=r.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,_,1)}}}if(t===o.n){let e=0;for(let t=a(o.n);t!==o.n;t=a(t))for(let s=r.getFirstPath(t);s!==o.n;s=r.getNextPath(s))if(r.isClosedPath(s)){let t=r.getFirstVertex(s);for(let n=0,i=r.getPathSize(s);n<i;n++,t=r.getNextVertex(t))r.setUserIndex(t,c,e++),r.setUserIndex(t,u,2)}else{const t=r.getFirstVertex(s);r.setUserIndex(t,c,e++),r.setUserIndex(t,u,1);let n=r.getNextVertex(t);for(let t=1,i=r.getPathSize(s)-1;t<i;++t)r.setUserIndex(n,c,e++),r.setUserIndex(n,u,2),n=r.getNextVertex(n);r.setUserIndex(n,c,e++),r.setUserIndex(n,u,1)}}for(let e=a(o.n);e!==o.n;e=a(e))for(let s=r.getFirstPath(e);s!==o.n;s=r.getNextPath(s)){let e=r.getFirstVertex(s);for(let i=0,a=r.getPathSize(s);i<a;i++,e=r.getNextVertex(e)){const s=this.m_topoGraph.getHalfEdgeFromVertex(e);if(s===o.n)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,g))continue;const r=this.getCombinedHalfEdgeParentage(s);if(this.isGoodParentage(r)){const e=0===i;this.restorePolylineParts(s,m,g,l,t,c,u,_,e,n)}}}let p=o.n;if(s){p=r.createGeometry(i.G.enumMultiPoint);let e=o.n;for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s))if(this.progress_(),1!==this.m_topoGraph.getClusterUserIndex(s,l)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===o.n&&(e=r.insertPath(p,o.n));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==o.n){let i;this.m_topoGraph.getVertexFromVertexIterator(n),i=-1!==c?this.chooseVertexByOrder(s,r,c,u):this.chooseVertexFromCluster_(s,t),r.addVertex(e,i)}}}}return-1!==u&&r.removeUserIndex(u),-1!==c&&r.removeUserIndex(c),-1!==l&&r.removeUserIndex(l),this.m_topoGraph.deleteUserIndexForHalfEdges(g),(0,h.k)(m,p)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=(0,i.z)(s),a=(0,i.z)(n);if(r>a)return e;const h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,2===r&&2===a){let s=o.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===r&&2===a){const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}if(1===r&&1===a){const t={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}if(0===r)return this.topoOperationMultiPoint_();(0,i.d)("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Is(s),a=Is(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);return(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,this.m_maskLookup[h]=!0,this.m_maskLookup[m]=!0,2===r&&2===a?this.topoOperationPolygonPolygon_(e,t,o.n):1===r&&1===a?this.topoOperationPolyline_(o.n,this.m_bOGCOutput):0===r&&0===a?this.topoOperationMultiPoint():void(0,i.d)("")}planarSimplifyNoCrackingAndCluster(e,t,s,n){this.m_bOGCOutput=e,this.m_topoGraph=new K;const r=t.getFillRule(s),a=t.getGeometryType(s);if(1!==r||a===i.G.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const h=this.m_topoGraph.getGeometryID(s);if((0,i.g)(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=h+1,this.m_maskLookup[h]=!0,t.getGeometryType(s)===i.G.enumPolygon||1===r&&t.getGeometryType(s)!==i.G.enumMultiPoint){t.setFillRule(s,0);const i=this.topoOperationPolygonPolygon_(s,o.n,o.n);if(t.swapGeometry(i,s),t.removeGeometry(i),1===r&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,s,n)}else if(t.getGeometryType(s)===i.G.enumPolyline){const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=n;const r=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(r,s),t.removeGeometry(r)}else if(t.getGeometryType(s)===i.G.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,s),t.removeGeometry(e)}else(0,i.d)("");return!0}unsplitPolylineExact(e){return(0,i.g)(0),new o.a}planarSimplifyPolylines(e,t,s,n,r){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const s=e.getGeometryType(t);(0,i.g)(s===i.G.enumPolyline)}let a=0,h=0,m=null;if(e.hasCurves()&&!e.hasSegmentParentage()){m=new cs;const s=e.getEnvelope2D(this.m_progressTracker);h=ls(t.total());const n=ms(t.total(),s);a=gs(n,h),os(e,n,t.total(),0,m,null,this.m_progressTracker)}{const s=fs(t.add(a));e.filterClosePoints(s,!1,!1,!1,o.n)}if(this.m_topoGraph=new K,4!==r&&5!==r)if(null===m&&s){const n=new Ee(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(_s(e,t,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else _s(e,t.add(a),this.m_progressTracker,!0,!1),s=!1;else s=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const l=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(s&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,n,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(l);(0,i.g)(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const c=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),n);null!==m&&m.stitchCurves(e,c,h,!0);const u=e.getGeometry(c);return s||u.getImpl().setIsSimple(4,t.total()),u}planarSimplifyMultiPoints(e,t,s,n){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const s=e.getGeometryType(t);(0,i.g)(s===i.G.enumMultiPoint)}this.m_topoGraph=new K,4!==n&&5!==n?(_s(e,t,this.m_progressTracker,!0,!1),s=!1):s=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const r=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,r,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const a=this.m_topoGraph.getGeometryID(r);(0,i.g)(a>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=a+1,this.m_maskLookup[a]=!0;const h=this.topoOperationMultiPoint(),m=e.getGeometry(h);return s||m.getImpl().setIsSimple(4,t.total()),m}planarSimplifyPolygons(e,t,s,n,r,a){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const n=e.getGeometryType(t);(0,i.g)(n===i.G.enumPolygon||n===i.G.enumPolyline&&s)}let h=0,m=0,l=null;if(e.hasCurves()&&!e.hasSegmentParentage()){l=new cs;const s=e.getEnvelope2D(this.m_progressTracker);m=ls(t.total());const n=ms(t.total(),s);h=gs(n,m),os(e,n,t.total(),0,l,null,this.m_progressTracker)}if(a){_s(e,t.add(h),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,!1,o.n,this.m_progressTracker)}if(this.m_topoGraph=new K,a||4===r||5===r)n=!1;else if(null===l&&n){const s=new Ee(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(_s(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else _s(e,t.add(h),this.m_progressTracker,!0,!1),n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(n&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const c=this.m_topoGraph.getGeometryID(g);(0,i.g)(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0,e.setFillRule(g,0);const u=this.m_bOGCOutput&&s,_=u;let p=this.topoOperationPolygonPolygon_(g,o.n,o.n,_);u&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(g),this.m_topoGraph=new K,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,p,this.m_progressTracker),p=this.topoOperationPolygonPolygon_(p,o.n,o.n,!1)),null!==l&&l.stitchCurves(e,p,m,!0);const d=e.getGeometry(p);return d.setFillRule(0),n?d.getImpl().setIsSimple(3,0):(d.getImpl().setIsSimple(4,t.total()),d.getImpl().updateOGCFlagsProtected()),d}planarSimplify3DImpl_(e,t,s,n,r){return(0,i.g)(0),{}}planarSimplifyImpl_(e,t,s,n,r,h,m,l){if(e.isEmpty())return e.clone();const g=e.getGeometryType(),c=new o.E,u=c.addGeometry(e);if((0,a.Y)(r)&&g===i.G.enumPolygon&&(s=!1,c.setFillRule(u,0)),l&&(e.hasAttribute(1)&&c.replaceNaNs(1,0),c.removeNaNVertices()),g===i.G.enumPolygon||g===i.G.enumPolyline&&s)return this.planarSimplifyPolygons(c,t,s,n,r,!1);if(g===o.a.type){const e={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=m,this.planarSimplifyPolylines(c,t,n,e,r)}if(g===i.G.enumMultiPoint)return this.planarSimplifyMultiPoints(c,t,n,r);(0,i.d)("what else?")}}function Fs(e,t,s,n){const r=e.getGeometryType();if(r===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(r===i.G.enumPoint&&("|"===n||"^"===n)){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(r===i.G.enumLine){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(r===i.G.enumMultiPoint&&"-"===n&&t.getGeometryType()===i.G.enumPoint){const t=new a.P({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(r===i.G.enumMultiPoint&&"&"===n&&t.getGeometryType()===i.G.enumPoint){const t=new a.P({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function Hs(e){const t=e.getGeometryType();if(t===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.G.enumPoint){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(Cs(t)){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.G.enumMultiPoint&&t!==i.G.enumPolyline&&t!==i.G.enumPolygon&&(0,i.a)("Unexpected geometry type"),e}function As(e,t,s,n){const r=s===o.n?e.getClusterHalfEdge(t):s;let a=r;(0,i.g)(e.getHalfEdgeOrigin(r)===t);do{n(a),a=e.getHalfEdgeNext(e.getHalfEdgeTwin(a))}while(a!==r)}class Ms{constructor(e,t,s,n,r,i){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(r),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=r,this.m_rCutHandles=i,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){let t=0;const s=this.m_rShape.getPathSize(e);for(let n=this.m_rShape.getFirstVertex(e);t<s;t++,n=this.m_rShape.getNextVertex(n))this.m_rShape.setUserIndex(n,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(n)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return 8|e}classifyStandardCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),a=r===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),h=i===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),l=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));let g=1,c=32,u=32;if(As(this.m_rTopoGraph,t,l,e=>{e===m&&(g=2),e===a&&(c=g),e===h&&(u=g)}),this.m_bConsiderTouch)32!==c&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|c),32!==u&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u);else{if(32===c||32===u)return 1;if(c===u&&a!==m&&a!==l&&h!==m&&h!==l)return 1;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|c),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u)}return 0}classifyTouchCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),a=r===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),h=i===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=s===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),l=n===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let t;return(t=m===a||l===a)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=m===h||l===h)&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),t?0:1}if(a===o.n)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===o.n)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(l!==o.n){if(a===l)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===l)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=1;As(this.m_rTopoGraph,t,l,t=>{if(t===a){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=2}else if(t===h){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=2}})}else{if(a===m)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===m)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=2;As(this.m_rTopoGraph,t,m,t=>{if(t===a){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=1}else if(t===h){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=1}})}return 0}classifyCutVertex(e,t){let s=0,n=0;for(let r=this.m_rTopoGraph.getClusterVertexIterator(t);r!==o.n;r=this.m_rTopoGraph.incrementVertexIterator(r)){const i=this.m_rTopoGraph.getVertexFromVertexIterator(r);if(this.m_rShape.getGeometryFromVertex(i)===this.m_cutter){n++;const r=this.m_rShape.getPrevVertex(i),a=this.m_rShape.getNextVertex(i);s+=r===o.n||a===o.n?this.classifyTouchCut(e,t,r,a):this.classifyStandardCut(e,t,r,a)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,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 e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){const t=this.m_rShape.getPathSize(e);let s=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,0);s=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,s=this.m_rShape.getNextVertex(s)){const e=this.m_rTopoGraph.getClusterFromVertex(s);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(s,e)}}const e=(e,t)=>{let s=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==o.n;t=this.m_rShape.getNextPath(t)){let s=this.m_rShape.getFirstVertex(t);const n=this.m_rShape.isClosedPath(t),r=this.m_rShape.getPathSize(t)+(n?1:0);let i=1,o=32;for(let t=this.m_rShape.getNextVertex(s);i<r;++i,s=t,t=this.m_rShape.getNextVertex(t)){const n=e(s,t);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=n),32!==o&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,o|n)}s=this.m_rShape.getLastVertex(t);let a=32;i=1;for(let t=this.m_rShape.getPrevVertex(s);i<r;++i,s=t,t=this.m_rShape.getPrevVertex(t)){const n=e(t,s);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=n),32!==a&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,a|n)}}let t=o.n,s=o.n,n=32;const r=this.m_rShape.hasSegmentParentage(),a=new o.S;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){const h=this.m_rShape.isClosedPath(e),m=this.m_rShape.getPathSize(e)+(h?1:0);let l=1,g=this.m_rShape.getFirstVertex(e),c=o.n,u=!0;for(let e=this.m_rShape.getNextVertex(g);l<m;++l,e=this.m_rShape.getNextVertex(e)){let h=this.m_rShape.getUserIndex(g,this.m_cutteeBreadcrumbsIndex);8===h?h=3:(h&=-9,4&h?h=4:3&~h||(h=3)),h!==n?(t!==o.n&&(c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n)),t=this.m_rShape.createGeometry(i.G.enumPolyline),s=this.m_rShape.insertPath(t,o.n),n=h,u=!0):this.m_rShape.getUserIndex(g,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==h&&(c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),s=this.m_rShape.insertPath(t,o.n),u=!0),c=this.m_rShape.addVertex(s,g);const m=this.m_rTopoGraph.getClusterFromVertex(g);!u&&r&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(c,!0);const l=this.m_rTopoGraph.getHalfEdgeFromVertex(g);if(r){const e=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(c,e,u||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,a),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(c),a.get().clone())),g=e,u=!1}c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n),t=o.n,s=o.n,n=32}}}function Us(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=new r.Envelope2D;return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Us(i,t,s,n,h)}(0,i.B)(m),(0,i.i)(m)||(0,i.t)("OGC simplify is not implemented for this geometry type");const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if(5===c||0===c)return c;const u=new Qs(e,t,c,h,!0);return m===i.G.enumMultiPoint||m===i.G.enumPolyline||m===i.G.enumPolygon?(c=u.isSimplePlanarImpl(),(0,a.i)(c)&&(c=5)):(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}function qs(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=r.Envelope2D.constructEmpty();return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),qs(i,t,s,n,h)}const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if(-1!==c)return c;const u=new Qs(e,t,c,h,!1);return m===i.G.enumMultiPoint?c=u.multipointIsSimpleAsFeature():m===i.G.enumPolyline?c=u.polylineIsSimpleAsFeature():m===i.G.enumPolygon?c=u.polygonIsSimpleAsFeature():(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}function Os(e,t,s,n){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.G.enumPoint){const t=new _.NonSimpleResult;if(Bs(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.G.enumEnvelope){const s=(0,a.e)(t,e,!0).total(),n=e,i=r.Envelope2D.constructEmpty();return n.queryEnvelope(i),i.isDegenerate(s)?n.createInstance():e}if((0,i.f)(h)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Os(i,t,s,n)}(0,i.B)(h);const m=(0,a.e)(t,e,!1).total(),l=e.getImpl().getIsSimple(m,[0]),g=s?-1:l;if((0,a.i)(g)){if(h===i.G.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((h===i.G.enumMultiPoint||h===i.G.enumPolyline)&&g>=1)return e;const c=new Qs(e,t,g,n,!1);let u;return h===i.G.enumMultiPoint?u=c.multipointSimplifyAsFeature():h===i.G.enumPolyline?u=c.polylineSimplifyAsFeature():h===i.G.enumPolygon?u=c.polygonSimplifyAsFeature():(0,i.d)(""),u}function Ys(e,t,s,n){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.G.enumPoint){const t=new _.NonSimpleResult;if(Bs(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.G.enumEnvelope){const s=e,n=new r.Envelope2D;s.queryEnvelope(n);const i=(0,a.e)(t,e,!0).total();return n.isDegenerate(i)?s.createInstance():e}if((0,i.f)(h)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Ys(i,t,s,n)}(0,i.B)(h),(0,i.i)(h)||(0,i.t)("OGC simplify is not implemented for this geometry type");const m=(0,a.e)(t,e,!1).total(),l=e.getImpl().getIsSimple(m,[0]),g=s?-1:l;if(5===g){if(h===i.G.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return bs(e,(0,a.e)(t,e,!0),!1,g,n,0,!0)}function Bs(e,t){const s=e.getX(),n=e.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){const s=e.getZ();if(!Number.isFinite(s))return t&&(t.m_reason=Number.isNaN(s)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class Rs{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(e){this.m_flags&=-2,this.m_flags=this.m_flags|(e?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function Xs(e,t,s,n,r){return{x:e,y:t,ipath:s,ivertex:n,ipolygon:r}}function Ls(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function zs(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function Ws(e,t,s,n,r,i){return{x:e,y:t,ipath:s,ivertex:n,bBoundary:r,bEndPoint:i}}function js(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.bBoundary=t.bBoundary,e.bEndPoint=t.bEndPoint}class Zs extends a.a6{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*n);return r<0?-1:r>0?1:0}}class Ks extends a.a6{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges[t],i=this.m_helper.m_edges[n],o=r.getReversed(),a=i.getReversed();let h=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const e=o?r.m_segment.getStartY():r.m_segment.getEndY(),t=a?i.m_segment.getStartY():i.m_segment.getEndY(),s=Math.min(e,t);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),h=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return h<m?-1:h>m?1:0}}class Qs{constructor(e,t,s,n,r){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new a.R,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new a.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 _.NonSimpleResult,this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=e,this.m_knownSimpleResult=s,this.m_sr=t;const i=(0,a.e)(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=(0,a.h)(i),this.m_toleranceIsSimpleCracking=(0,a.U)(i),this.m_toleranceSimplify=(0,a.e)(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=r,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 e=this.m_geometry.getGeometryType();return(0,i.h)(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?(0,i.h)(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.G.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return(0,i.g)(0),7}generateSortedPairs(e){let t=null;(0,i.h)(e.getGeometryType())&&(t=e);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==t,n=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new a.a(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let e=0;e<n;e++)if(this.m_pairs.push(2*e),this.m_pairs.push(2*e+1),this.m_pairIndices.add(2*e),this.m_pairIndices.add(2*e+1),s){for(;e>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const o=new a.B,m={parent:this,workPt:new h.P,userSort(e,t,n){n.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,s))},getValue(e){const t=this.parent.m_pairs[e],s=t>>1;return this.parent.m_xy.queryPoint2D(2*s,this.workPt),this.workPt.y+(1&t?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};o.sort(this.m_pairIndices,0,2*n,m)}_TestToleranceDistancePlanar(e,t){const s=this.m_xy.read(2*e),n=this.m_xy.read(2*e+1),r=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1);return!ne(s,n,r,i,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||0!==this.m_geometry.getDimension()&&s===r&&n===i}checkStructure(){const e=this.m_geometry.getGeometryType();if((0,i.h)(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.G.enumPolygon?3:2;for(let s=0,n=e.getPathCount();s<n;s++)if(e.getPathSize(s)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(s)&&e.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new _.NonSimpleResult(1,s,0),!1}}if((0,i.i)(e)){const e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let s=0,n=e.getPointCount();s<n;s++)if(!t.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new _.NonSimpleResult(2,s,0),!1;if(this.m_geometry.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(!Number.isFinite(e))return Number.isNaN(e)?this.m_nonSimpleResult=new _.NonSimpleResult(3,s,0):this.m_nonSimpleResult=new _.NonSimpleResult(2,s,0),!1}}}return!0}checkDegenerateSegments(e){const t=this.m_geometry.getImpl(),s=t.querySegmentIterator(),n=t.hasAttribute(1),r=n?(0,a.W)(this.m_sr,t,!1).total():0,i=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment();let a=t.calculateLowerLength2D();if(!(a>o||i&&t.isCurve()&&(a=t.calculateLength2D(),a>o))){if(e&&n){const e=t.getStartAttributeAsDbl(1,0),s=t.getEndAttributeAsDbl(1,0);if(Math.abs(s-e)>r)continue}return this.m_nonSimpleResult=new _.NonSimpleResult(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return(0,i.g)(0),!1}_CheckClustering(){const e=this.m_geometry.getImpl();this.generateSortedPairs(e);const t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new Zs(this)),this.m_AET.setCapacity(t);for(let e=0,s=2*t;e<s;e++){this.progress_();const t=this.m_pairIndices.read(e),s=this.m_pairs[t],n=s>>1;if(1&s){const e=this.m_AET.search(n),t=this.m_AET.getPrev(e),s=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==a.T.st_nullNode()&&s!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new _.NonSimpleResult(5,this.m_AET.getElement(t),this.m_AET.getElement(s)),!1}else{const e=this.m_AET.addElement(n),t=this.m_AET.getPrev(e);if(t!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),n))return this.m_nonSimpleResult=new _.NonSimpleResult(5,n,this.m_AET.getElement(t)),!1;const s=this.m_AET.getNext(e);if(s!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new _.NonSimpleResult(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new o.E,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new cs;const e=r.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(e);const t=ms(this.m_toleranceSimplify.total(),e),s=new _.NonSimpleResult;if(function(e,t,s,n,r,i,o,a){e.hasCurves()?(e.setCurveStitcherPointer(i),i.m_impl=new us(a,!0,r),i.m_impl.buildMonotonicCurveParentage(e,t,s,null),ds(e,s,a)):i.m_impl=null}(this.m_editShape,t,this.m_toleranceSimplify.total(),0,s,this.m_curveStitcher,0,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!1}const e=new _.NonSimpleResult;return Ie(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(null!=this.m_curveStitcher?(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null):(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){s.resetTo(t);do{for(;s.hasNextSegment();){const n=s.nextSegment(),r=(0,o.Q)(!0,e,n,this.m_toleranceIsSimpleCracking,!0);if(r){const e=2===r?7:6;return this.m_nonSimpleResult=new _.NonSimpleResult(e,t.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const t=[],s=e.getPointCount();let n=Number.NaN,r=0;for(let e=0,i=2*s;e<i;e++){this.progress_();const s=this.m_pairIndices.read(e),i=this.m_pairs[s];if(1&i)continue;const o=i>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(t.length&&(a!==n||h!==r)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),n=a,r=h}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){const e=this.m_geometry.getImpl(),t=[];for(let s=0,n=e.getPathCount();s<n;s++)t.push(e.isClosedPathInXYPlane(s));const s={x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1};let n,r,i;{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];n=t[m],r=e.getPathStart(m),i=e.getPathEnd(m)-1,s.bEndPoint=a===r||a===i,this.m_bOGCRestrictions?s.bBoundary=!n&&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 m=h>>1,l=this.m_xy.readPoint2D(2*m),g=this.m_pathsForOGCTests[m];let c;g!==s.ipath&&(n=t[g],r=e.getPathStart(g),i=e.getPathEnd(g)-1);const u=m===r||m===i;c=this.m_bOGCRestrictions?!n&&u:u;const p=Ws(l.x,l.y,g,m,c,u);if(p.x===s.x&&p.y===s.y)if(this.m_bOGCRestrictions){if(!(p.bBoundary&&s.bBoundary||p.ipath===s.ipath&&p.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new _.NonSimpleResult(10,p.ivertex,s.ivertex),!1}else if(!p.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new _.NonSimpleResult(7,p.ivertex,s.ivertex),!1;js(s,p)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return(0,i.g)(0),!1}checkSelfIntersectionsPolygonsOGC(){const e=this.m_geometry.getImpl(),t=[];let s=-1,n=!1;for(let r=0,i=e.getPathCount();r<i;r++)e.isExteriorRingOGC(r)&&(n=!1,s++,r<i-1&&(e.isExteriorRingOGC(r+1)||(n=!0))),t.push(n?s:-1);const r={x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1};{const e=this.m_pairIndices.read(0),s=this.m_pairs[e]>>1,n=this.m_xy.readPoint2D(2*s),i=this.m_pathsForOGCTests[s];r.ipath=i,r.x=n.x,r.y=n.y,r.ivertex=s,r.ipolygon=t[i]}const i=[];for(let e=1,s=this.m_pairIndices.size();e<s;e++){const s=this.m_pairIndices.read(e),n=this.m_pairs[s];if(1&n)continue;const o=n>>1,a=this.m_xy.readPoint2D(2*o),h=this.m_pathsForOGCTests[o],m=Xs(a.x,a.y,h,o,t[h]);if(m.x===r.x&&m.y===r.y){if(m.ipath===r.ipath)return this.m_nonSimpleResult=new _.NonSimpleResult(11,m.ivertex,r.ivertex),!1;t[m.ipath]>=0&&t[m.ipath]===t[r.ipath]&&(0!==i.length&&Ls(i.at(-1),r)||i.push({...r}),i.push(m))}zs(r,m)}if(0===i.length)return!0;const o=new a.R(!0);t.fill(-1);let m=-1;const l=new h.P;for(let e=0,s=i.length;e<s;e++){const s=i[e];s.x===l.x&&s.y===l.y||(m=o.createList(0),l.x=s.x,l.y=s.y);let n=t[s.ipath];-1===n&&(n=o.createList(2),t[s.ipath]=n),o.addElement(n,m),o.addElement(m,n)}const g=[];for(let e=o.getFirstList();-1!==e;e=o.getNextList(e)){const s=o.getListData(e);if(1&s||!(2&s))continue;let n=-1;for(g.push(e),g.push(-1);g.length;){const e=g.at(-1);g.pop();const t=g.at(-1);g.pop();const s=o.getListData(t);if(1&s){n=2&s?t:e;break}o.setListData(t,1|s);for(let s=o.getFirst(t);-1!==s;s=o.getNext(s)){const n=o.getData(s);n!==e&&(g.push(n),g.push(t))}}if(-1!==n){const e=t.indexOf(n);return this.m_nonSimpleResult=new _.NonSimpleResult(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){const e=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new _.NonSimpleResult(8,1===e.getPathCount()?1:-1,-1),0;if(1===e.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new a.b(e.getPathCount(),0),this.m_pathParentage=new a.a(e.getPathCount(),-1);let t=-1,s=0;for(let n=0,r=e.getPathCount();n<r;n++){const r=e.calculateRingArea2D(n);if(this.m_pathOrientations.write(n,r<0?0:8),r>0)t=n,s=r;else{if(0===r)return this.m_nonSimpleResult=new _.NonSimpleResult(8,n,-1),0;if((t<0||s<Math.abs(r))&&(this.m_nonSimpleResult=new _.NonSimpleResult(9,n,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(n,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;const n=e.getPointCount();this.m_yScanline=Number.NaN;const r=[];this.m_xyToNode1=new a.a(n,a.T.st_nullNode()),this.m_xyToNode2=new a.a(n,a.T.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new Ks(this));for(let e=0,t=2*n;this.m_unknownOrientationPathCount>0&&e<t;e++){const t=this.m_pairIndices.read(e),s=this.m_pairs[t];if(1&s)continue;const n=s>>1,i=this.m_xy.read(2*n+1);if(i!==this.m_yScanline&&r.length){if(!this.processBunchForRingOrientationTest(r))return 0;r.length=0}r.push(n),this.m_yScanline=i}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(r)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(e){if(1===e.length)return!0;for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();-1===t&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let e=0,s=this.m_edges.length;e<s;e++)this.m_crossOverHelperList.addElement(t,e);let s=!0,n=-1,r=-1;for(;s;){s=!1;let e=this.m_crossOverHelperList.getFirst(t);if(-1===e)break;let i=this.m_crossOverHelperList.getNext(e);for(;-1!==i;){const o=this.m_crossOverHelperList.getData(e),a=this.m_crossOverHelperList.getData(i);if(n=this.m_edges[o].m_vertexIndex,r=this.m_edges[a].m_vertexIndex,n!==r)e=i,i=this.m_crossOverHelperList.getNext(e);else if(s=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(i),i=this.m_crossOverHelperList.deleteElement(t,i),-1===i||-1===e)break}}const i=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),i>0)return this.m_nonSimpleResult=new _.NonSimpleResult(7,n,r),!1;for(let t=0,s=e.length;t<s;t++)this.recycleEdge(this.m_edges[t]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,s=e.length;t<s;t++){const s=e[t];let n=this.m_xyToNode1.read(s);if(n!==a.T.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(s,a.T.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==a.T.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(s,a.T.st_nullNode())}}for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===a.T.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();if(r.getStartY()<r.getEndY()){const e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=t):(n=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(n);this.m_xyToNode1.read(e)===a.T.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}}for(let e=0,t=this.m_newEdges.length;e<t&&this.m_unknownOrientationPathCount>0;e++){const t=this.m_newEdges[e],s=this.m_AET.getElement(t),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let e=-1,s=this.m_AET.getPrev(t),n=t,r=0;{let t=-1,i=null,o=-1,h=0;for(;s!==a.T.st_nullNode()&&(t=this.m_AET.getElement(s),i=this.m_edges[t],o=i.m_pathIndex,h=this.m_pathOrientations.read(o),!(3&h));)n=s,s=this.m_AET.getPrev(s);s===a.T.st_nullNode()?(r=1,s=n):(e=1==(3&h)?o:this.m_pathParentage.read(o),r=i.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const t=this.m_AET.getElement(s),i=this.m_edges[t],o=i.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(r!==i.getRightSide())return this.m_nonSimpleResult=new _.NonSimpleResult(8,o,-1),!1;const t=r&&!i.getReversed()?1:2;if(a=-4&a|t,this.m_pathOrientations.write(o,a),2===t&&0===this.m_nonSimpleResult.m_reason){const t=this.m_pathParentage.read(o);if(t!==e&&(this.m_nonSimpleResult=new _.NonSimpleResult(9,o,t),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}e=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),r=r?0:1}while(n!==t)}}return this.m_newEdges.length=0,!0}createEdge(e,t,s,n){let r;return e.getGeometryType()===i.G.enumLine?r=this.createEdgeLine(e):(r=new Rs,r.m_segment=e.clone()),r.m_vertexIndex=t,r.m_pathIndex=s,r.m_flags=0,r.setReversed(n),r}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new Rs,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.G.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,s,n){let r=e.calculateLowerLength2D();if(r<=s){let i=!0;if(e.isCurve()&&(r=e.calculateLength2D(),i=r<=s),i){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let s=e.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-t)<=n}return!0}return!1}return!1}static isShortSegmentPoints(e,t,s,n,r){if(s){const s=e.getXYZ(),i=t.getXYZ();return(0,a.X)(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return h.P.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),o=e.querySegmentIterator();o.resetToPath(t),(0,i.g)(o.nextPath());const m=this.m_toleranceSimplify.total();let l=!1,g=!0;const c=new a.P,u=new a.P,_=new h.P;for(;o.hasNextSegment();){this.progress_();const e=o.nextSegment();if(Qs.isShortSegment(e,r,m,s))if(l){if(e.queryEnd(u),Qs.isShortSegmentPoints(c,u,r,m,s))continue;g&&(n.startPathPoint(c),g=!1),e.queryEnd(c),n.lineToPoint(c),l=!1}else _.assign(e.getStartXY()),e.queryStart(c),l=!0;else if(l)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(_,e.getEndXY(),!1),t.setStart(c),Qs.isShortSegment(t,r,m,s))continue;n.addSegment(t,g),g=!1,l=!1}else{if(e.queryEnd(u),Qs.isShortSegmentPoints(c,u,r,m,s))continue;g&&(n.startPathPoint(c),g=!1),n.lineToPoint(u),l=!1}else n.addSegment(e,g),g=!1}if(g)return;if(!l)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),c):e.getPointByVal(e.getPathEnd(t)-1,c);const p=n.querySegmentIterator();p.resetToLastPath(),p.resetToLastSegment();const d=n.getDescription().getAttributeCount()>1;for((0,i.g)(p.previousPath());p.hasPreviousSegment();){const e=p.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),c.getXY(),!1),!Qs.isShortSegment(t,r,m,s)){d&&t.setEnd(c);const e=p.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.addSegment(t,!1)}}else if(e.queryStart(u),!Qs.isShortSegmentPoints(u,c,r,m,s)){const e=p.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(c)}}n.removePath(n.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;const t=e.getPointCount(),s=(0,h.d)(t,0);for(let e=0;e<t;e++)s[e]=e;s.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let e=1;e<t;e++)if(0===this.compareVerticesMultiPoint(s[e-1],s[e]))return this.m_nonSimpleResult=new _.NonSimpleResult(5,s[e-1],s[e]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl();const t=Qs.hasNanZs(e);let s,n=this.m_geometry;t&&(s=this.m_geometry.clone(),e=s.getImpl(),s.replaceNaNs(1,a.V.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=(0,h.d)(r,0);for(let e=0;e<r;e++)i[e]=e;i.sort((e,t)=>this.compareVerticesMultiPoint(e,t));const o=new Array(r);o.fill(!1);let m=-1;for(let t=0;t<r;t++){const s=i[t];e.getXY(s).isFinite()&&((m<0||0!==this.compareVerticesMultiPoint(m,s))&&(o[s]=!0),m=s)}const l=this.m_geometry.createInstance();let g=0,c=0;for(let e=0;e<r;e++)o[e]?c=e+1:(g<c&&l.addPoints(n,g,c),g=e+1);return g<c&&l.addPoints(n,g,c),l.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),l}polylineSimplifyAsFeature(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator(),n=this.m_geometry.createInstance(),r=this.m_geometry,i=e.hasAttribute(1),o=i?(0,a.W)(this.m_sr,e,!0).total():0,m=[],l=[];let g=null;i&&(g=e.getAttributeStreamRef(1));const c=new a.P,u=e.hasNonLinearSegments(),_=this.m_toleranceSimplify.total();for(;t.nextPath();){if(s.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(u&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,n);continue}s.resetToLastSegment();let a=0,p=0,d=!0,f=!0;for(;t.hasNextSegment();){this.progress_();const n=t.nextSegment(),r=s.previousSegment();if(t.getStartPointIndex()>s.getStartPointIndex())break;if(d){const s=t.getStartPointIndex();e.getXY(s).isNAN()||(d=!1,m.push(s))}if(f){const t=s.getEndPointIndex();e.getXY(t).isNAN()||(l.push(t),f=!1)}if(!d){const s=m.at(-1),r=t.getEndPointIndex();if(r-s>1){const t=new h.P;t.setSub(e.getXY(s),e.getXY(r)),a=t.length()}else a=n.calculateLength2D();if(a>_)m.push(r),a=0;else if(i){let e=g.read(s);Number.isNaN(e)&&(e=0);let t=g.read(r);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(m.push(r),a=0)}}if(!f){const t=l.at(-1),n=s.getStartPointIndex();if(n-t>1){const s=new h.P;s.setSub(e.getXY(t),e.getXY(n)),p=s.length()}else p=r.calculateLength2D();if(p>_)l.push(n),p=0;else if(i){let e=g.read(t);Number.isNaN(e)&&(e=0);let s=g.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-e)>o&&(l.push(n),p=0)}}}if(m.length>0&&l.length>0&&(m.at(-1)<l.at(-1)?m.length>l.length?m.pop():l.pop():(m.at(-1)===l.at(-1)||l.pop(),l.pop())),l.length+m.length>=2){let e=!1;for(let t=0,s=m.length;t<s;t++)r.getPointByVal(m[t],c),e?n.lineToPoint(c):(n.startPathPoint(c),e=!0);for(let t=l.length-1;t>0;t--)r.getPointByVal(l[t],c),e?n.lineToPoint(c):(n.startPathPoint(c),e=!0);r.isClosedPath(t.getPathIndex())?n.closePathWithLine():l.length>0&&(r.getPointByVal(l[0],c),n.lineToPoint(c))}m.length=0,l.length=0}return i&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,_),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!(0,a.Y)(this.m_knownSimpleResult))return Gs(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new o.E;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),0!==e.getTotalPointCount()){let t=null,s=0,n=0;if(e.hasCurves()){t=new cs;const i=r.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(i);const o=ms(this.m_toleranceSimplify.total(),i);s=ls(this.m_toleranceSimplify.total()),n=gs(o,s),os(e,o,this.m_toleranceSimplify.total(),0,t,null,this.m_progressTracker)}(0,a.Y)(this.m_knownSimpleResult)||_s(e,this.m_toleranceSimplify.add(n),this.m_progressTracker,!0,!1),this.m_geometry.getGeometryType()===i.G.enumPolygon&&Fe(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==t&&t.stitchCurves(e,e.getFirstGeometry(),s,!0)}const t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===i.G.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,s){if(e===t)return 0;const n=this.m_pairs[e],r=this.m_pairs[t],i=n>>1,o=r>>1,a=this.m_xy.readPoint2D(2*i);a.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=this.m_xy.readPoint2D(2*o);m.y+=1&r?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const l=a.compare(m);if(0===l&&s){const e=this.m_pathsForOGCTests[i]-this.m_pathsForOGCTests[o];return(0,h.e)(e)}return l}compareVerticesMultiPoint(e,t){if(e===t)return 0;const s=this.m_multiVertexGeom.getXY(e),n=this.m_multiVertexGeom.getXY(t),r=!s.isFinite(),i=!n.isFinite();if(r||i)return r<i?-1:r>i?1:0;if(s.y<n.y)return-1;if(s.y>n.y)return 1;if(s.x<n.x)return-1;if(s.x>n.x)return 1;for(let s=1;s<this.m_attributeCount;s++){const n=this.m_description.getSemantics(s),r=a.V.getComponentCount(n);for(let s=0;s<r;s++){const r=this.m_multiVertexGeom.getAttributeAsDbl(n,e,s),i=this.m_multiVertexGeom.getAttributeAsDbl(n,t,s),o=(0,h.r)(r,i);if(0!==o)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;const s=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&s.negateThis();const n=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&n.negateThis();const r=s.getQuarter(),i=n.getQuarter();if(i===r){const e=s.crossProduct(n);return e<0?1:e>0?-1:0}return r<i?-1:1}}class Js{getOperatorType(){return 10103}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,s,n,r){const i=qs(e,t,s,n,r);return(0,a.Q)(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,h){const m=function(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=new r.Envelope2D;return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),qs(i,t,s,n,h)}const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if((0,a.i)(c)||0===c)return c;const u=new Qs(e,t,c,h,!1);return m===i.G.enumMultiPoint||m===i.G.enumPolyline||m===i.G.enumPolygon?c=u.isSimplePlanarImpl():(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}(e,t,s,n,h);return(0,a.i)(m)}executeMany(e,t,s,n){return new $s(e,t,s,n)}execute(e,t,s,n){const r=new u.S([e]),o=this.executeMany(r,t,s,n).next();return o||(0,i.d)("null geometry"),o}}class $s extends c.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||(0,i.a)(""),e.getGeometryType()===i.G.enumGeometryCollection){const t=(0,o.g)(e,-1),s=(new Js).executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=e.createInstance();for(let e=s.next();null!=e;e=s.next())n.addGeometry(e);return n}return Os(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}class en{constructor(e,t,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=e,this.m_sr=t,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const s=(0,a.g)(this.m_intersectorGeom,e),n=(0,a.c)(this.m_sr,s,!0).total(),m=r.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const g=r.Envelope2D.constructEmpty();e.queryEnvelope(g),m.inflateCoords(2*n,2*n),m.intersect(g),m.inflateCoords(100*n,100*n);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),u=(0,l.c)(e,m,0,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,h.c)(u,u=c)),function(e,t,s,n){const h=r.Envelope2D.constructEmpty();e.queryEnvelope(h);const m=r.Envelope2D.constructEmpty();t.queryEnvelope(m);const l=r.Envelope2D.constructEmpty();l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=new r.Envelope2D(m),u=(0,a.h)(g);if(c.inflateCoords(u,u),!h.isIntersecting(c)){if(e.getDimension()<=t.getDimension())return Fs(Hs(e.createInstance()),e,0,"&");if(e.getDimension()>t.getDimension())return Fs(Hs(t.createInstance()),e,0,"&")}const _=new ks(n),p=new o.E,d=p.addGeometry(Hs(e)),f=p.addGeometry(Hs(t));let x=0,P=0,E=null;if(p.hasCurves()){E=new cs;const e=p.getEnvelope2D(n);P=ls(g.total());const t=ms(g.total(),e);x=gs(t,P),os(p,t,g.total(),0,E,null,n)}_.setEditShapeCrackAndCluster(p,g.add(x));const y=_.intersection(d,f);null!==E&&E.stitchCurves(p,y,P,!0);const S=Fs(p.getGeometry(y),e,0,"&");return Ss(S.getGeometryType())&&(S.getImpl().setIsSimple(4,g.total()),S.getGeometryType()===i.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}(u,c,this.m_sr,this.m_progressTracker)}intersectEx(e){const t=this.tryFastImplementation(e);if(null!==t){const s=[];return s.length=3,s[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,s)}const s=(0,a.g)(this.m_intersectorGeom,e),n=(0,a.c)(this.m_sr,s,!0).total(),m=r.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const g=r.Envelope2D.constructEmpty();e.queryEnvelope(g),m.inflateCoords(2*n,2*n),m.intersect(g),m.inflateCoords(100*n,100*n);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),u=(0,l.c)(e,m,0,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,h.c)(u,u=c));const _=function(e,t,s,n){const h=new Array(3),m=r.Envelope2D.constructEmpty();e.queryEnvelope(m);const l=r.Envelope2D.constructEmpty();t.queryEnvelope(l);const g=r.Envelope2D.constructEmpty();g.setCoords({env2D:m}),g.mergeEnvelope2D(l);const c=(0,a.c)(s,g,!0),u=new r.Envelope2D(l),_=(0,a.h)(c);if(u.inflateCoords(_,_),!m.isIntersecting(u)){if(e.getDimension()<=t.getDimension()){const t=Fs(Hs(e.createInstance()),e,0,"&");return h[t.getDimension()]=t,h}if(e.getDimension()>t.getDimension()){const s=Fs(Hs(t.createInstance()),e,0,"&");return h[s.getDimension()]=s,h}}const p=new ks(n),d=new o.E,f=d.addGeometry(Hs(e)),x=d.addGeometry(Hs(t));let P=0,E=0,y=null;if(d.hasCurves()){y=new cs;const e=d.getEnvelope2D(n);E=ls(c.total());const t=ms(c.total(),e);P=gs(t,E),os(d,t,c.total(),0,y,null,n)}p.setEditShapeCrackAndCluster(d,c.add(P)),d.dbgVerifyCurves();const S=p.intersectionEx(f,x);for(const t of S){null!==y&&y.stitchCurves(d,t,E,!1);const s=Fs(d.getGeometry(t),e,0,"&");Ss(s.getGeometryType())&&(s.getImpl().setIsSimple(4,c.total()),s.getGeometryType()===i.G.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),h[s.getDimension()]=s}return null!==y&&y.clearStitcher(d),h}(u,c,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,_)}init(e,t,s,n=null){(0,i.g)(0)}static intersectPoints(e,t,s){const n=(0,a.g)(e,t);return function(e,t,s){return e.isEmpty()||t.isEmpty()?e.createInstance():function(e,t,s){const n=(0,a.h)(e);return ne(t.getX(),t.getY(),s.getX(),s.getY(),(0,h.a)(n))}(s,e,t)?new a.P({copy:ps(e,t)}):e.createInstance()}(e,t,(0,a.c)(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===i.G.enumPoint&&t===i.G.enumPoint){const t=en.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new o.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.G.enumEnvelope&&this.m_intersectorGeomType===i.G.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new a.E({copy:t});return n.intersect(s),n}const s=(0,a.g)(e,this.m_intersectorGeom),n=(0,a.c)(this.m_sr,s,!0),h=e.isEmpty(),m=this.m_intersectorGeom.isEmpty();let g=h||m;if(!g){const t=function(e,t,s){const n=new r.Envelope2D;e.queryEnvelope(n);const o=new r.Envelope2D;t.queryEnvelope(o);const a=new r.Envelope2D(o);if(a.inflate(2*s),!a.isIntersecting(n))return 4;const h=e.getGeometryType(),m=t.getGeometryType();if(h===i.G.enumEnvelope&&n.containsEnvelope(a))return 1;if(m===i.G.enumEnvelope){const e=new r.Envelope2D(n);if(e.inflate(2*s),o.containsEnvelope(e))return 2}return 0}(this.m_intersectorGeom,e,n.total());if(4===t)g=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(g){const s=(0,i.z)(t),n=(0,i.z)(this.m_intersectorGeomType);return s<n?en.ReturnEmpty(e,h):s>n||0===s&&t===i.G.enumMultiPoint&&this.m_intersectorGeomType===i.G.enumPoint?this.ReturnEmptyIntersector():en.ReturnEmpty(e,h)}if(t===i.G.enumEnvelope&&0===(0,i.z)(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.G.enumEnvelope&&0===(0,i.z)(t)){const s=t===i.G.enumEnvelope?e:this.m_intersectorGeom,o=t===i.G.enumEnvelope?this.m_intersectorGeom:e,a=r.Envelope2D.constructEmpty();return s.queryEnvelope(a),(0,l.c)(o,a,n.total(),0,this.m_progressTracker)}if(0===(0,i.z)(t)&&(0,i.z)(this.m_intersectorGeomType)>0||(0,i.z)(t)>0&&0===(0,i.z)(this.m_intersectorGeomType)){if(t===i.G.enumMultiPoint)return ws(e,this.m_intersectorGeom,n);if(t===i.G.enumPoint)return Ts(e,this.m_intersectorGeom,n);if(this.m_intersectorGeomType===i.G.enumMultiPoint)return ws(this.m_intersectorGeom,e,n);if(this.m_intersectorGeomType===i.G.enumPoint)return Ts(this.m_intersectorGeom,e,n);(0,i.d)("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,s){let n=0;return 1&t?(s[0]||(s[0]=new o.M({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new o.a({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new o.P({vd:e})):s.splice(n,1),new u.S(s)}}class tn extends c.G{constructor(e,t,s,n,r){super(),this.m_smallCursor=null,this.m_progressTracker=n,this.m_geomIntersector=t.next(),this.m_intersector=new en(this.m_geomIntersector,s,r,n),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=r,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&(0,i.a)("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let e;if(null!==this.m_smallCursor){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();)return(0,i.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask?this.m_intersector.intersect(e):(this.m_smallCursor=this.m_intersector.intersectEx(e),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class sn{getOperatorType(){return 1e4}accelerateGeometry(e,t,s){if(!this.canAccelerateGeometry(e))return!1;(0,a.e)(t,e,!0);let n=0;return e.getGeometryType()!==i.G.enumPolygon&&e.getGeometryType()!==i.G.enumPolyline||!(0,o.I)(e)||0===s||(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),!!n}canAccelerateGeometry(e){return(0,o.I)(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new tn(e,t,s,n,r)}execute(e,t,s,n){if(e.getGeometryType()===i.G.enumPoint&&t.getGeometryType()===i.G.enumPoint)return en.intersectPoints(e,t,s);const r=new u.S([e]),o=new u.S([t]),a=this.executeMany(r,o,s,n,-1).next();return a||(0,i.d)("null output"),a}}function nn(e,t,s){return t.m_projector.project(e,s)}function rn(e,t,s,n,r){return e.m_projector.transformInPlaceZ(t,null,s,n,null,r)}function on(e,t,s,n){if(e&&t&&t.isPannable()||(0,i.a)("fold_into_360_range_geodetic"),e.isEmpty())return e;if(4===s)return an(e,t,n);let h=e;const m=h.getGeometryType();if((0,i.h)(m)){h=Gr(e,t);const n=new r.Envelope2D;h.queryEnvelope(n);const i=(0,a.c)(t,n,!1).total(),o=t.getPannableExtent();let m=Math.floor((n.xmin-o.xmin)/o.width())*o.width()+o.xmin,l=h;for(;m<n.xmax;)m>n.xmin+i&&m<n.xmax-i&&(l=vr(l,t,s,!0,m)),m+=o.width();h=l}else{if(m===i.G.enumEnvelope){const e=new o.P({vd:h.getDescription()});return e.addEnvelope(h,!1),on(e,t,s,n)}if((0,i.f)(m)){const e=new o.a({vd:h.getDescription()});return e.addSegment(h,!0),on(e,t,s,n)}}return an(h,t,n)}function an(e,t,s){if(e&&t&&t.isPannable()||(0,i.a)(""),e.isEmpty())return e;let n;const r=e.getGeometryType();if(r===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});t.addEnvelope(e,!1),n=t}else if((0,i.f)(r)){const t=new o.a({vd:e.getDescription()});t.addSegment(e,!0),n=t}else n=e;const a=Gr(n,t);return a.isEmpty()?a:Er(a,t,0,a!==e,0,s)}function hn(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let m=new h.E,g=new h.E;i&&(m=t.getZGridRange()),o&&(g=t.getMGridRange());let c=(new l.O).execute(e,r,s,n);if(i){const t=c.queryInterval(1,0);m.contains(t)||(e===c&&(c=c.clone()),(0,a.a5)(c,m,1,0))}if(o){const t=c.queryInterval(2,0);g.contains(t)||(e===c&&(c=c.clone()),(0,a.a5)(c,g,2,0))}return c}class mn{constructor(e){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,e||(0,i.a)(""),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;const t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.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(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const s=e.getGeometryType();if(s===i.G.enumPoint)return this.projectPoint(e,t);const n=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),a=this.m_projTransform.getOutputSR();if(0===n&&n===r){const t=gn(o,a),s=e.clone();return s.applyTransformation(t),s}switch(s){case i.G.enumPolyline:case i.G.enumPolygon:return this.projectMultiPath(e,t);case i.G.enumMultiPoint:return this.projectMultiPoint(e,t);case i.G.enumEnvelope:return this.projectEnvelope(e,t);case i.G.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:(0,i.d)("")}}projectPoint(e,t){const s=[e.getXY()];let n,r=null;(n=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(s,r,1,s,r,null);const i=e.clone();return i.setXY(s[0]),n&&i.setZ(r[0]),i}projectMultiPoint(e,t){let s=new o.M({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),h=r.getCoordinateSystemType();if(3===a&&(0,i.g)(0),s=kr(s,n,this.m_inputPCSHorizonClipOption,t),s.isEmpty())return s;2===a&&Or(n,0,s),zr(this.m_projTransform,s,!1);let m=0;3===h&&(0,i.g)(0);const l=2===h;return l?m=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(m=this.m_centralMeridianOfOutputGCS),l&&0!==this.m_outputPCSHorizonClipOption||(s=Er(s,ji(r),m,!1,0,t)),l&&(s=dr(s,r,this.m_outputPCSHorizonClipOption,t),Mr(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const s=e.getGeometryType();return s===i.G.enumPolygon?this.projectPolygon(e,t):s===i.G.enumPolyline?this.projectPolyline(e,t):void(0,i.d)("project_multi_path_")}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&e.hasAttribute(1);let n=h.E.constructEmpty();if(s&&(n=e.queryInterval(1,0)),n.width()>0){const s=e.clone();s.setInterval(1,0,n.vmin,n.vmin);const r=this.projectEnvelopeHelper(s,t);s.setInterval(1,0,n.vmax,n.vmax);const i=this.projectEnvelopeHelper(s,t);return r.merge(i),r}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){(0,i.g)(e.getGeometryType()===i.G.enumPolygon),(0,i.g)(!this.m_projTransform.isIdentity()),(0,i.g)(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),a=s.getCoordinateSystemType(),h=n.getCoordinateSystemType(),m=new o.P({copy:e});3===a&&(0,i.g)(0),3===h&&(0,i.g)(0);const c=2===a,u=2===h,_=c?s.getGCS():s,p=u?n.getGCS():n,d=!u&&!this.m_bDontHackPolesInGeogToGeog;let f=!1,x=kr(m,s,this.m_inputPCSHorizonClipOption,t);if(x.isEmpty())return x;let P=this.m_densificationStepInput;const E=!Number.isNaN(P);let y;E&&(x=(new g.O).execute(x,P,0,0,t));let S=u?n.getPCSInfo():null,C=Number.NaN;c&&(C=s.getCentralMeridian());const I=null!==n.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=x;if(c&&(Rr(s,C,e),E)){const e=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,e,d),E){const e=s.getGCS().getUnitsPerMillimeter();P*=n.getGCS().getUnitsPerMillimeter()/e}y=e}else{let e=new o.a({vd:x.getDescription()});if(e.addAndExplicitlyOpenAllPaths(x,!1),c){if(Rr(s,C,e),E){const e=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),i=n.getSouthPoleGeometry()===vo.PE_POLE_LINE_CURVED,o=n.getNorthPoleGeometry()===vo.PE_POLE_LINE_CURVED;if(i||o){const s=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*_.getOneDegreeGCSUnit();i&&(s.ymin=-n),o&&(s.ymax=n),e=(0,l.a)(e,s,_,0,0,t)}}}if(jr(this.m_projTransform,e,d),E){const e=ji(s).getUnitsPerMillimeter();P*=ji(n).getUnitsPerMillimeter()/e}let i=Number.NaN;u?(S=n.getPCSInfo(),i=n.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=ln(s)|ln(n),h=10*p.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(a=3,h=10*p.getTolerance(0)),y=function(e,t,s,n,r,i,o,a,h){return new zn(e,null,s,t,n,r,o,a,i).geoNormalizePolygonGeometry(h)}(x,s,e,p,i,t,a,h,this.m_bNormalizeOutputGeometry),a=0}if(I&&((0,i.g)(!n.isPannable()),y=ur(y,n,t)),u){if(!f){const e=p.getPannableExtent().width();if(y.queryInterval(0,0).width()>=e-10*p.getTolerance(0)){const e=S.getNorthPoleLocation(),t=S.getSouthPoleLocation(),s=S.getNorthPoleGeometry(),n=S.getSouthPoleGeometry();let r=0;s===vo.PE_POLE_POINT&&e!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(r=1),n===vo.PE_POLE_POINT&&t!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(r|=2),f||=0!==r}}y=dr(y,n,this.m_outputPCSHorizonClipOption,t),E&&(y=(new g.O).execute(y,P,0,0,t)),qr(n,y,this.m_bNormalizeOutputGeometry)}return y.isEmpty()||f&&(y=(new Js).execute(y,n,!1,t)),y}projectPolyline(e,t){(0,i.g)(e.getGeometryType()===i.G.enumPolyline),(0,i.g)(!this.m_projTransform.isIdentity()),(0,i.g)(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),r=s.getCoordinateSystemType(),a=n.getCoordinateSystemType(),h=new o.a({copy:e});3===r&&(0,i.g)(0),3===a&&(0,i.g)(0);const m=2===r,l=2===a;m&&s.getGCS();const c=l?n.getGCS():n,u=!l&&!this.m_bDontHackPolesInGeogToGeog;let _=kr(h,s,this.m_inputPCSHorizonClipOption,t);if(_.isEmpty())return _;let p=Number.NaN;m&&(p=s.getCentralMeridian());const d=null!==n.getGCSSplitLines();let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let P;if(x&&(_=(new g.O).execute(_,f,0,0,t)),this.m_bDontGeonormalizePolygon){if(m&&(Rr(s,p,_),x)){const e=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,_,u),x){const e=s.getGCS().getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}P=_}else{const e=new o.a({vd:_.getDescription()});if(e.addAndExplicitlyOpenAllPaths(_,!1),m&&(Rr(s,p,e),x)){const e=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,e,u),x){const e=s.getGCS().getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}let r=Number.NaN;l?r=n.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=ln(s)|ln(n),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,a=0),P=function(e,t,s,n,r,i,o,a,h){return new zn(e,null,s,t,n,r,o,a,i).geoNormalizePolylineGeometry(h)}(_,s,e,c,r,t,i,a,this.m_bNormalizeOutputGeometry),i=0}return d&&((0,i.g)(!n.isPannable()),P=ur(P,n,t)),l&&(P=dr(P,n,this.m_outputPCSHorizonClipOption,t),x&&(P=(new g.O).execute(P,f,0,0,t)),qr(n,P,this.m_bNormalizeOutputGeometry)),P.isEmpty(),P}projectGeometryCollection(e,t){return(0,i.g)(0),{}}projectEnvelopeHelper(e,t){const s=(e.height()+e.width())/400;if(0!==s){const n=(new g.O).execute(e,s,0,0,t),i=this.projectMultiPath(n,t),h=new a.E({vd:e.getDescription()});if(i.isEmpty()){const s=Math.min(e.height(),e.width()),i=(0,a.e)(this.m_projTransform.getInputSR(),e,!0).total();if(s>100*i){const e=r.Envelope2D.constructEmpty(),t=(0,a.c)(this.m_projTransform.getOutputSR(),e,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(i,t*n))return h}const m=new o.a;m.addAndExplicitlyOpenAllPaths(n,!1),this.projectMultiPath(m,t).queryEnvelope(h);const l=new o.M({vd:e.getDescription()});l.reserve(4);const g=new a.P;for(let t=0;t<4;t++)e.queryCornerByVal(t,g),l.add(g);const c=this.projectMultiPoint(l,t),u=new a.E;return c.queryEnvelope(u),h.merge(u),h}return i.queryEnvelope(h),h}{const s=e.getCenterXY(),n=new a.P(s),r=this.projectPoint(n,t),i=new a.E({vd:e.getDescription()});if(r.isEmpty())i.setEmpty();else{e.copyTo(i);const t=r.getXY();i.setCoords(t.x,t.y,t.x,t.y)}return i}}transformInPlace(e,t,s,n){return(0,i.g)(0),0}transformInPlaceZ(e,t,s,n,r,o){if(this.m_projTransform.isIdentity())return e!==n&&(0,h.aw)(n,e,s),t!==r&&(0,h.b)(r,t,0,0,s),s;const a=this.m_projTransform,m=a.getInputSR(),l=a.getOutputSR(),g=m.getCoordinateSystemType(),c=l.getCoordinateSystemType();if(0===g&&g===c)return gn(m,l).transformPoints2D(e,s,n),a.isVertical()&&(0,i.g)(0),s;3===g&&(0,i.t)("image: transform_in_place_"),3===c&&(0,i.t)("image: transform_in_place_"),function(e,t,s,n,r){const o=n.getCoordinateSystemType();if(2===o){if(0===r)s!==e&&(0,h.aw)(s,e,t),function(e,t,s){const n=e.getPCSHorizon();if(n.getGeometryType()===i.G.enumPolygon){const r=e.getDefaultPrecisionSR().getTolerance(0),i=n;for(let e=0;e<s;e++)1!==es(i,t[e],r)&&t[e].setNAN();return}if(n.getGeometryType()===i.G.enumEnvelope){const e=n;for(let n=0;n<s;n++)e.contains(t[n])||t[n].setNAN();return}(0,i.a)("")}(n,s,t);else if(s!==e&&(0,h.aw)(s,e,t),n.isPannable()){const e=n.getTolerance(0);(function(e,t,s,n){for(let r=0;r<t;r++){if(e[r].y<s.ymin||e[r].y>s.ymax){e[r].setNAN();continue}const t=e[r].x;e[r].x=Cr(t,s,n)}})(s,t,n.getPannableExtent(),e),yr(s,t,n,0)}}else{(0,i.g)(1===o);const r=n.getTolerance(0),a=n.getPannableExtent();for(let n=0;n<t;n++)s[n].assign(Vr(e[n],a,r))}}(e,s,n,m,this.m_inputPCSHorizonClipOption),r!==t&&(0,h.b)(r,t,0,0,s),2===g&&Xr(m,0,n,s),Jr(this.m_projTransform,n,r,s,!1);let u=0;const _=2===c;_?u=l.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(u=this.m_centralMeridianOfOutputGCS),_&&0!==this.m_outputPCSHorizonClipOption||yr(n,s,l.getGCS(),u),_&&(Pr(n,s,l,this.m_outputPCSHorizonClipOption),Hr(l,n,s,!1));let p=s;for(let e=0;e<s;++e)n[e].isNAN()&&(r&&(r[e]=Number.NaN),p--);return p}}function ln(e){if(2!==e.getCoordinateSystemType())return 0;let t=0;const s=e.getPCSInfo(),n=s.getNorthPoleLocation(),r=s.getSouthPoleLocation(),i=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return i===vo.PE_POLE_POINT&&n!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===vo.PE_POLE_POINT&&r!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function gn(e,t){const s=e.getHorzUnitFactor(),n=t.getHorzUnitFactor();let r=1,i=1;const o=20015077/180;1===e.getUnit().getUnitType()&&(r=o),1===t.getUnit().getUnitType()&&(i=o);const a=s/n*(r!==i?r/i:1),h=new m.T;return h.setScaleCoords(a,a),h}class cn{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s){return!t||t.isIdentity()?e:new un(e,t,s)}execute(e,t,s){return t.isIdentity()?e:nn(e,t,s)}transform(e,t,s,n,r=!0){return r?function(e,t,s,n){e.m_projector.transformInPlaceZ(t,null,s,n,null,null);const r=n.slice(0,s).filter(e=>!e.isNAN());for(let e=0,t=r.length;e<t;++e)n[e].assign(r[e]);return r.length}(e,t,s,n):rn(e,t,s,n,null)}transform3D(e,t,s,n,r=!0){return(0,i.g)(0),0}foldInto360Range(e,t){return an(e,t,null)}foldInto360RangeGeodetic(e,t,s){return on(e,t,s,null)}normalizeGeometryEx(e,t,s,n,r=0){return function(e,t,s,n,r){if(!t.isPannable()||e.isEmpty())return e;const l=e.getGeometryType();l===i.G.enumGeometryCollection&&(0,i.t)("not yet impl for geometry collection");const g=t.getPannableExtent();Number.isNaN(s)&&(s=g.getCenterX());const c=g.width(),u=.5*c,_=r>0,p=e.queryInterval(0,0);if(!_&&p.width()<u||!(0,i.i)(e.getGeometryType())){const t=p.getCenter();if(Math.abs(t-s)<=u)return e;{const n=new m.T,r=(0,h.ax)((s-t)/c)*c;n.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(n),i}}if(l===i.G.enumPolygon){let i=new o.a({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),_&&(i=_n(i,t,2,r,Number.NaN,null,!0));const m=[];if(!n){{let s=e;_&&(s=new o.P,s.add(i,!1));const n=function(e,t,s){const n=Ui();t.querySpheroidData(n);const r=t.getGCS()!==t?t.getSRToGCSTransform():null,i=(0,h.m)(h.P,100),o=new a.f(0,0,0),m=e.getPointCount(),l=t.getGCS().getUnit().getUnitToBaseFactor();for(let t=0,s=m;t<s;){const a=Math.min(100,s-t);e.queryCoordinates(i,a,t,t+a),r&&(new cn).transform(r,i,a,i,!1);for(let e=0;e<a;e++){if(i[e].isNAN())continue;i[e].scale(l);const t=v(n.majorSemiAxis,n.e2,i[e]);o.addThis(t)}t+=a}const g=w(n.majorSemiAxis,n.e2,o);g.scale(1/l);const c=e;if(!new On(t.getGCS(),g).project(c))return 0;s.length=e.getPathCount();const u=c.calculateArea2D()<0;for(let t=0,n=e.getPathCount();t<n;t++){const e=c.calculateRingArea2D(t),n=u?e<0:e>0;s[t]=n}return u?-1:1}(e,t,m);if(n)n<0&&i.reverseAllPaths();else{const e=s.getPathCount();for(let t=0;t<e;t++)m.push(s.calculateRingArea2D(t)>0)}}n=m}return new zn(null,n,i,null,t,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(l===i.G.enumPolyline){let n=new o.a({vd:e.getDescription()});return n.addAndExplicitlyOpenAllPaths(e,!1),_&&(n=_n(n,t,2,r,Number.NaN,null,!0)),new zn(null,null,n,null,t,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(l===i.G.enumMultiPoint){const t=e,n=t.getAttributeStreamRef(0);let r,i=null,o=s,a=0;const m=.1*c;for(let s=0,l=t.getPointCount();s<l;s++){const t=n.read(2*s);let l=t-o;if(Math.abs(l)>u&&(l=(0,h.ax)(l/c)*c,a-=l,Math.abs(a)<m&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const n=t+a;i.write(2*s,n)}o=t}return i?(r.notifyModified(),r):e}(0,i.d)("")}(e,t,s,n,r)}normalizeGeometry(e,t,s){return function(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,o=e.queryInterval(0,0);if(o.width()<r||!(0,i.i)(e.getGeometryType())){if(Number.isNaN(s))return e;const t=o.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new m.T,i=(0,h.ax)((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const a=e.getGeometryType(),l=e,g=l.getAttributeStreamRef(0),c=e.clone(),u=c.getAttributeStreamRef(0);let _=0,p=0,d=0,f=(0,i.h)(a)?0:-1;const x=h.E.constructEmpty();let P=!1;for(let e=0,t=l.getPointCount();e<t;e++){const t=g.read(2*e);e===p&&((0,i.h)(a)?(0===f&&Number.isNaN(s)&&(P=!0),f>0&&Number.isNaN(s)&&(s=x.getCenter(),P=!1),p=l.getPathEnd(f),f++):p=l.getPointCount(),Number.isNaN(s)?d=t:(d=s,_=0));let o=t-d;Math.abs(o)>r&&(o=(0,h.ax)(o/n)*n,_-=o,Math.abs(_)<.1*n&&(_=0));const m=t+_;u.write(2*e,m),P&&x.mergeCoordinate(m),d=t}return c.notifyModified(),c}(e,t,s)}clipToSpatialReference(e,t,s,n=0){return function(e,t,s,n){const o=t.getCoordinateSystemType();if(0===o){const n=new oo;return t.queryPrecisionDescriptor(n),hn(e,n,t,s)}let a=e;2!==n&&3!==n||!t.isPannable()||(a=an(a,t,s));const h=new oo;if(t.queryPrecisionDescriptor(h),a=hn(a,h,t,s),0===n||a.isEmpty())return a;if(1===o){if(1===n){const e=new r.Envelope2D;a.queryLooseEnvelope(e);const n=t.getPannableExtent(),i=.01*n.width();return n.xmin=e.xmin-i,n.xmax=e.xmax+i,(new l.O).execute(a,n,t,s)}return a}if(2===o){const e=t.getPCSHorizon();if(1===n||2===n){const n=(new sn).execute(a,e,t,s);return n===e?n.clone():n}return a}if(3===o)return a;(0,i.d)("missing implementation")}(e,t,s,n)}}class un extends c.G{constructor(e,t,s){super(),this.m_projTrans=t,this.m_progressTracker=s,this.m_index=-1,e||(0,i.a)(""),this.m_inputGeoms=e}next(){const e=this.m_inputGeoms.next();return null!=e?((0,i.p)(e),(0,i.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),nn(e,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function _n(e,t,s,n,r,a,h=!1){e||(0,i.a)("Geometry.Geodetic_densify.densify");let m=e.getGeometryType();if((0,i.c)(e),e.isEmpty()||(0,i.e)(m))return e;const l=new En;l.m_sr=t,l.m_gcs=t.getGCS(),l.m_transform=l.m_gcs!==t?t.getSRToGCSTransform():null,l.m_progressTracker=a;const g=Ui();let c,u,_;if(l.m_gcs.querySpheroidData(g),l.m_a=g.majorSemiAxis,l.m_eSquared=g.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=n,l.m_maxDeviation=r,l.m_curveType=s,m===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});t.addEnvelope(e,!1),c=t,m=i.G.enumPolygon}else if((0,i.f)(m)){const t=new o.a({vd:e.getDescription()});t.addSegment(e,!0),c=t,m=i.G.enumPolyline}else c=e;if(4!==l.m_curveType){if((0,i.g)((0,i.h)(m)),u=l.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(c),u.isEmpty())return u;u=pn(l.m_rpu,u);let e=l.geodeticDensify(u);h||(e=(new cn).foldInto360RangeGeodetic(e,l.m_gcs,l.m_curveType)),_=l.m_transform&&!l.m_transform.isIdentity()?(new cn).execute(e,l.m_transform.getInverse(),a):e}else{let e;if((0,i.g)((0,i.h)(m)),t.isPannable())e=Gr(c,t);else{const s=t.getPCSHorizon();e=(new sn).execute(c,s,t,a),e===s&&(e=s.clone())}if(u=e,u.isEmpty())return u;_=l.shapePreservingDensify(u)}return _}function pn(e,t){const s=new r.Envelope2D;if(t.queryLooseEnvelope(s),s.width()*e<Math.PI)return t;let n=!1;const i=t.querySegmentIterator(),o=new h.P,m=new h.P;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment();if(o.setCoordsPoint2D(t.getStartXY()),m.setCoordsPoint2D(t.getEndXY()),o.scale(e),m.scale(e),Math.abs(o.x-m.x)>Math.PI){if(!fn(o,m)){n=!0;break}if(Math.abs(o.x-m.x)>2*Math.PI){n=!0;break}}}if(!n)return t;const l=t.createInstance();l.reserve(t.getPointCount());const g=t.getDescription().getAttributeCount()>1,c=new h.P,u=new h.P,_=new h.P(0,0),p=new h.P(0,0),d=new a.P;for(i.resetToFirstPath();i.nextPath();){let t=Number.NaN,s=0;for(;i.hasNextSegment();){const n=i.nextSegment();if(o.setCoordsPoint2D(n.getStartXY()),m.setCoordsPoint2D(n.getEndXY()),o.scale(e),m.scale(e),Number.isNaN(t)?(s=Vn(o.x,Number.NaN,s),_.setCoordsPoint2D(o)):_.setCoordsPoint2D(p),t=_.x,fn(o,m)){if(m.x-o.x>2*Math.PI)for(;m.x-o.x>2*Math.PI;)m.x-=2*Math.PI;else if(m.x-o.x<2*-Math.PI)for(;m.x-o.x<2*-Math.PI;)m.x+=2*Math.PI;s=Vn(m.x,Number.NaN,s),p.setCoordsPoint2D(m)}else c.setCoordsPoint2D(m),Mn(c),s=Vn(c.x,t,s),p.setCoords(s+c.x,c.y);if(Math.abs(p.x-m.x)<.5&&p.setCoordsPoint2D(m),g)n.queryCoord(0,d),u.setCoordsPoint2D(_),u.scale(1/e),d.setXY(u),i.isFirstSegmentInPath()?l.startPathPoint(d):l.lineToPoint(d),i.isLastSegmentInPath()&&!i.isPathClosed()&&(n.queryCoord(1,d),u.setCoordsPoint2D(p),u.scale(1/e),d.setXY(u),l.lineToPoint(d));else{i.isFirstSegmentInPath()&&l.insertPath2D(-1,null,0,0,!0);const t=l.getPathCount()-1;u.setCoordsPoint2D(_),u.scale(1/e),l.insertPoint2D(t,-1,u),i.isLastSegmentInPath()&&!i.isPathClosed()&&(u.setCoordsPoint2D(p),u.scale(1/e),l.insertPoint2D(t,-1,u))}}}return l}function dn(e,t,s,n,r,i,o,a,m,l,g,c){const u=new h.P,_=new h.P,p=n.compare(r)>0;Tn(p,n,r,u,_);const d=Cn(e,t,s,u,_,i,o,a,m,l,null,g,c);return p&&Nn(m,l,null,g),d}function fn(e,t){return!(!Po(e.y,h.o)||!Po(t.y,h.o))||!(!Po(e.y,-h.o)||!Po(t.y,-h.o))}function xn(e,t){return!(!Po(e.y,h.o)||Po(t.y,h.o))||!(!Po(e.y,-h.o)||Po(t.y,-h.o))}function Pn(e,t){return!(!Po(t.y,h.o)||Po(e.y,h.o))||!(!Po(t.y,-h.o)||Po(e.y,-h.o))}class En{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(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new o.S,a=e.getDescription().getAttributeCount()>1;for(;s.nextPath();){const e=[0];for(;s.hasNextSegment();){const o=s.nextSegment(),m=o.getStartXY(),l=o.getEndXY();m.scale(this.m_rpu),l.scale(this.m_rpu);const g=new h.P,c=new h.P,u=m.compare(l)>0;Tn(u,m,l,g,c),n.length=0,r.length=0,this.m_maxLength>0?Cn(this.m_a,this.m_eSquared,this.m_curveType,g,c,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,a?r:null,n,e):In(),u&&Nn(null,null,a?r:null,n),n[0].setCoordsPoint2D(o.getStartXY()),n.at(-1).setCoordsPoint2D(o.getEndXY());const _=1/this.m_rpu;for(let e=1,t=n.length-1;e<t;e++)n[e].scale(_);if(a){const e=Dn(u,o,i);Sn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),o,e,r,n,t)}else yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}}return t}shapePreservingDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new o.S,a=e.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment(),o=e.getStartXY(),h=e.getEndXY(),m=o.compare(h)>0,l=Dn(m,e,i);n.length=0,r.length=0,wn(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,a?r:null,n),m&&Nn(null,null,a?r:null,n),a?Sn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),e,l,r,n,t):yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){const t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Gr(e,this.m_gcs),!t))return e;const s=e.createInstance();s.reserveParts(e.getPointCount(),e.getPathCount());for(let t=0,n=e.getPathCount();t<n;++t){let n=new o.M;const r=e.getPathStart(t),i=e.getPathEnd(t);n.addPoints(e,r,i);const h=e.isClosedPath(t);let m=!1;if(h&&i-r===1&&e.hasNonLinearSegmentsPath(t)){const t=new a.P;e.getPointByVal(r,t),n.add(t),m=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(h&&!m){const t=new a.P;e.getPointByVal(r,t),n.add(t)}if(n=(new cn).execute(n,this.m_transform,this.m_progressTracker),h&&n.getPointCount()>1){const e=n.getXY(0),t=n.getXY(n.getPointCount()-1);e.equals(t)&&n.removePoint(n.getPointCount()-1)}}n.getPointCount()>1&&(s.addPathMultiPoint(n,0,-1,!0),h&&s.closePathWithLine())}return s}}function yn(e,t,s,n){e&&n.insertPath2D(-1,null,0,0,!0);const r=n.getPathCount()-1;n.insertPointsFromPoints(r,-1,s,0,s.length-1,!0),t&&n.insertPoint2D(r,-1,s.at(-1))}function Sn(e,t,s,n,r,i,o){o.reserve(o.getPointCount()+i.length-1);const h=new a.P;if(s.queryStart(h),e?o.startPathPoint(h):o.lineToPoint(h),i.length>2){const e=n.calculateLength2D();for(let t=1;t<i.length-1;t++){const s=n.lengthToT(r[t]*e);n.queryCoord(s,h),h.setXY(i[t]),o.lineToPoint(h)}}t&&(s.queryEnd(h),o.lineToPoint(h))}function Cn(e,t,s,r,i,o,a,m,l,g,c,u,_){const p={stack:[],error:void 0,hasError:!1};try{const d=(0,n.mS)(p,new Eo,!1),f=(0,n.mS)(p,new Eo,!1),x=(0,n.mS)(p,new Eo,!1);wo.geodeticDistance(e,t,r.x,r.y,i.x,i.y,x,d,f,s);const P=x.val,E=d.val,y=f.val;let S=E,C=y;S<0&&(S+=2*Math.PI),C<0&&(C+=2*Math.PI),l&&(l[0]=S),g&&(g[0]=C);let I=Number.NaN,v=Number.NaN;if(null!==c){const s=No.q90(e,t),n=No.q(e,t,r.y);I=(s-n)/P,v=(s+n)/P}const b=xn(r,i),G=Pn(r,i),w=b||G,N=function(e,t,s){return!(!An(e,t,s)||Po(e.y,h.o)||Po(e.y,-h.o)||Po(t.y,h.o)||Po(t.y,-h.o))}(r,i,m),T=(0,n.mS)(p,new h.S(new Eo,new Eo),!1),D=new h.P,V=new h.P,k=new h.P;_[0]=Vn(r.x,Number.NaN,_[0]);let F=_[0];if(P<=o)return u.push(r.clone()),_[0]=Vn(i.x,Number.NaN,_[0]),null!=c&&c.push(0),w?(b&&kn(r,i,c,u),G&&Fn(r,i,c,u)):N?Hn(r,i,E,I,v,c,u):a>0&&(V.setCoords(r.x-F,r.y),D.setCoords(i.x-_[0],i.y),F=vn()),u.push(i.clone()),P;const H=1+Math.ceil(P/o),A=P/(H-1),M=new h.P;u.push(r.clone()),M.setCoordsPoint2D(r),V.setCoords(r.x-_[0],r.y),null!==c&&c.push(0);for(let n=1;n<H;n++){let o;if(n<H-1){const i=n*A;wo.geodeticCoordinate(e,t,r.x,r.y,i,E,T.at(0),T.at(1),s),D.setCoords(T.at(0).val,T.at(1).val),_[0]=Vn(D.x,M.x,_[0]),k.setCoords(_[0]+D.x,D.y),o=n/(H-1)}else _[0]=Vn(i.x,Number.NaN,_[0]),D.setCoords(i.x-_[0],i.y),k.setCoordsPoint2D(i),o=1;w?(1===n&&b&&kn(r,k,c,u),n===H-1&&G&&Fn(M,i,c,u)):N?An(M,k,m)&&(r.x<i.x?M.x>k.x&&(_[0]+=2*Math.PI,k.setCoords(_[0]+D.x,D.y)):M.x<k.x&&(_[0]-=2*Math.PI,k.setCoords(_[0]+D.x,D.y)),Hn(M,k,E,I,v,c,u)):a>0&&vn(),u.push(k.clone()),null!=c&&c.push(o),M.setCoordsPoint2D(k),V.setCoordsPoint2D(D),F=_[0]}return P}catch(e){p.error=e,p.hasError=!0}finally{(0,n.hk)(p)}}function In(e,t,s,n,r,o,a,h,m,l){(0,i.g)(0)}function vn(e,t,s,n,r,o,a,h,m,l,g,c,u,_,p){return(0,i.g)(0),0}function bn(e,t,s,n){const r=v(e,t,s),i=v(e,t,n);return a.f.distance(r,i)}function Gn(e,t,s,n,r,o,m,l){const g=new Array,c=(0,h.m)(Array,8);let u=2,_=r.getCoord2D(o);c[0][0]=_.x,c[0][1]=_.y,_=r.getCoord2D(m),c[1][0]=_.x,c[1][1]=_.y;const p=e=>{if(null!==s){const t=Co.projToGeog(s,e,c);(0,i.g)(t===e)}for(const e of c)e[0]*=n,e[1]*=n};p(2),g.push(v(e,t,new h.P(c[0][0],c[0][1]))),g.push(v(e,t,new h.P(c[1][0],c[1][1])));let d=a.f.distance(g[0],g[1]);if(d>l)return d;let f=0;for(u=3;u<=17;){const s=1/(u-1);let n=0;for(let e=1;e<u;++e)if(1&e){const t=(0,h.q)(o,m,e*s);r.queryCoord2D(t,_),c[n][0]=_.x,c[n][1]=_.y,n++}p(n);let x=1;for(let s=0;s<n;++s)g.splice(x,0,v(e,t,new h.P(c[s][0],c[s][1]))),x++;x=0;let P=g[x];x++;let E=0;for(;x!==g.length;++x){const e=g[x];E+=a.f.distance(P,e),P=e}if(E>l)return E;if(f=E-d,(0,i.g)(f>=0||Math.abs(f)<1e-14*E),f<0&&(f=0),d=E,E+f<=l)return E+f;u=2*u-1}return d+f}function wn(e,t,s,n,r,o,a,m,l){const g=n.isCurve(),c=function(e,t){return e*Math.sqrt(1-t)}(e,t)*Math.PI*179/180;let u=o;o>0&&!(o>c)||(u=c);const _=a,p=_>0;let d=Number.NaN;p&&(d=function(e,t,s){const n=s/(2*function(e,t){return(1-t)*e}(e,t)),r=n*n;return s*(1-r*(.16666666666666666-.008333333333333333*r))}(e,t,_));const f=1===r.getCoordinateSystemType();let x=null;f||(x=r.getPECoordSys());const P=r.getTolerance(0),E=n.getStartXY(),y=n.getEndXY(),S=new h.P,C=new h.P;if(f)S.setCoordsPoint2D(E),S.scale(s),C.setCoordsPoint2D(y),C.scale(s);else{const e=[E.x,E.y,y.x,y.y];Co.projToGeog(x,2,e),S.setCoords(e[0],e[1]),S.scale(s),C.setCoords(e[2],e[3]),C.scale(s)}let I=0,b=0;const G=[],w=[],N=[];G.push(y.clone()),w.push(C.clone()),N.push(1),l.push(E.clone()),null!==m&&m.push(b);const V=r.isPannable(),k=E.clone(),F=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let H=5;g||(p?(F[0]=.5,F[1]=.25,F[2]=.75,H=3):H=1),(0,i.g)(u>0);const A=e=>{if(e=e.clone(),null!==x){const t=[e.x,e.y];Co.projToGeog(x,1,t),e.setCoords(t[0],t[1])}return e.scale(s),e};for(;w.length>0;){const o=G.at(-1).clone();C.assign(w.at(-1));const a=N.at(-1);let c=!1,_=Number.NaN;const E=Gn(e,t,x,s,n,b,a,u);let y=u>=E&&Math.abs(S.y-C.y)<.9*Math.PI;f&&y&&(y=Math.abs(S.x-C.x)<.9*Math.PI);const M=new h.P,U=new h.P;let q=!1;if(!p&&y&&y&&(q=!0),n.calculateSubLength(b,a)<=P&&(q=!0),!q)for(let m=0;m<H;m++){const l=(0,h.q)(b,a,F[m]),u=new h.P;n.queryCoord2D(l,u);const x=A(u);if(0===m&&(_=l,M.setCoordsPoint2D(u),U.setCoordsPoint2D(x),!y)){c=!0;break}if((0,i.g)(p),f&&Math.abs(S.x-x.x)>=Math.PI){c=!0;break}let P=new h.P,E=new h.P;g?(P=h.P.lerp(k,o,F[m]),E=A(P)):(P=u.clone(),E=x.clone());const I=T(e,t,S,C,F[m]),G=I.clone();if(f?(G.x/=s,G.y/=s):(G.x/=s,G.y/=s,rn(r.getGCSToSRTransform(),[G],1,[G],null)),G.isNAN()){const s=v(e,t,x),n=v(e,t,S),r=v(e,t,C),{second:i}=D(e,t,s,n,r,2,null);if(i>d){c=!0;break}}else{if(V){const e=r.getPannableExtent().width(),t=(0,h.q)(n.getStartX(),n.getEndX(),.5);for(;G.x<t-.5*e;)G.x+=e;for(;G.x>=t+.5*e;)G.x-=e}const s=n.getClosestCoordinateOnInterval(G,new h.E(b,a),-1);let i=n.getCoord2D(s);i=A(i);let o=bn(e,t,i,I);if(o>d){if(o<4*d){const s=v(e,t,i),n=v(e,t,S),r=v(e,t,C),{second:a}=D(e,t,s,n,r,2,null);o=a}if(o>d){c=!0;break}}else if(g){let s=v(e,t,x);const n=v(e,t,S),r=v(e,t,C);let{second:i}=D(e,t,s,n,r,3,null);if(i<=d){s=v(e,t,E);const{second:o}=D(e,t,s,n,r,3,null);i=o}if(i>d){c=!0;break}}}}c?(G.push(M.clone()),w.push(U.clone()),N.push(_)):(G.pop(),w.pop(),N.pop(),l.push(o.clone()),I+=E,null!==m&&m.push(I),k.setCoordsPoint2D(o),S.setCoordsPoint2D(C),b=a)}if(null!==m){const e=1/I;for(let t=0;t<m.length;t++)m[t]*=e}}function Nn(e,t,s,n){if(n.reverse(),null!==s&&s.reverse(),e){const s=e[0],n=t[0];e[0]=n,t[0]=s}}function Tn(e,t,s,n,r){e?(n.setCoordsPoint2D(s),r.setCoordsPoint2D(t)):(n.setCoordsPoint2D(t),r.setCoordsPoint2D(s))}function Dn(e,t,s){return e?(s.create(t.getGeometryType()),t.copyTo(s.get()),s.get().reverse(),s.get()):t}function Vn(e,t,s){if(Number.isNaN(t)){for(;s-e>Math.PI;)s-=2*Math.PI;for(;e-s>Math.PI;)s+=2*Math.PI;return s}return s+e-t>Math.PI?s-=2*Math.PI:t-(s+e)>Math.PI&&(s+=2*Math.PI),s}function kn(e,t,s,n){if(e.y>0){const r=new h.P;r.setCoords(t.x,h.o),Po(e.x,r.x)||Po(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new h.P;r.setCoords(t.x,-h.o),Po(e.x,r.x)||Po(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}}function Fn(e,t,s,n){if(t.y>0){const r=new h.P;r.setCoords(e.x,h.o),Po(t.x,r.x)||Po(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new h.P;r.setCoords(e.x,-h.o),Po(t.x,r.x)||Po(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}}function Hn(e,t,s,n,r,i,o){if(function(e){return function(e,t){return 0===e||Math.abs(e)<=t}(e,xo)}(s)){if(h.o-e.y>0){const t=new h.P;t.setCoords(e.x,h.o),o.push(t),null!==i&&i.push(n)}if(h.o-t.y>0){const e=new h.P;e.setCoords(t.x,h.o),o.push(e),null!==i&&i.push(n)}}else{if(h.o+e.y>0){const t=new h.P;t.setCoords(e.x,-h.o),o.push(t),null!==i&&i.push(r)}if(h.o+t.y>0){const e=new h.P;e.setCoords(t.x,-h.o),o.push(e),null!==i&&i.push(r)}}}function An(e,t,s){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=s}function Mn(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=2*Math.PI;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=2*Math.PI}function Un(e,t,s,r){const i={stack:[],error:void 0,hasError:!1};try{const o=[s.x],a=[s.y-r],h=[s.x],m=[s.y+r];k(o,a),k(h,m);const l=(0,n.mS)(i,new Eo,!1),g=(0,n.mS)(i,new Eo,!1);return wo.greatEllipticDistance(e,t,s.x,s.y,o[0],a[0],l,null,null),wo.greatEllipticDistance(e,t,s.x,s.y,h[0],m[0],g,null,null),Math.min(l.val,g.val)}catch(e){i.error=e,i.hasError=!0}finally{(0,n.hk)(i)}}function qn(e,t,s,n,i){const o=new r.Envelope2D;s.queryEnvelope(o);const h=(0,a.e)(null,s,!0).total();if(t.xmin-o.xmin<=h&&o.xmax-t.xmax<=h)return s;const g=t.width();let c=0;for(;t.xmin+c*g<o.xmin;)c++;for(;t.xmin+c*g>o.xmin;)c--;const u=c*g,_=new m.T;_.setShiftCoords(-u,0);const p=s;p.applyTransformation(_);const d=new r.Envelope2D;p.queryEnvelope(d);let f=null;if(d.xmax>t.xmax){let s=0;const n=new r.Envelope2D;n.setCoords({env2D:t}),n.ymin-=1,n.ymax+=1;let o=p;for(;n.xmin<d.xmax;){d.xmax>n.xmax&&(o=vr(o,e,2,!0,n.xmax));const r=(0,a.j)(o,n),h=(0,a.c)(null,r,!0).total(),m=(0,l.c)(o,n,h,Number.NaN,i);null===f?f=m===o?m.clone():m:(_.setShiftCoords(-s*g,0),m.applyTransformation(_),f.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=t.xmax+s*g}}else f=p;return f}class On{constructor(e,t){this.m_basisX=new a.f,this.m_basisY=new a.f,this.m_normal=new a.f,(0,i.g)(1===e.getCoordinateSystemType()),this.m_gcs=e;const s=Ui();e.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);const n=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,o=Math.cos(n),m=Math.sin(n),l=Math.cos(r),g=Math.sin(r);this.m_cartCenter3D=function(e,t,s,n,r,i){return b(e,t,s,n,r,i,0)}(this.m_a,this.m_e2,o,m,l,g),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),a.f.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(h.P.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(h.P.construct(0,.5*-Math.PI/this.m_rpu))}project(e){const t=e.getGeometryType();if((0,i.i)(t)){(0,i.p)(e);const t=e;return this.projectMultiVertex(t)}(0,i.a)("Gnomonic.project")}unproject(e,t,s){const n=e.getGeometryType();if((0,i.i)(n)){(0,i.p)(e);let m=e;const l=[];if(n===i.G.enumPolygon){const e=m.getPathCount();for(let t=0;t<e;t++){const e=m.calculateRingArea2D(t);l.push(e)}}return this.unprojectMultiVertex(t,m),(0,i.h)(n)?(function(e,t,s){const n=e.getPannableExtent(),r=h.P.construct(0,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new h.P;a.setNAN();let m=Number.NaN;for(let e=0;e<s.getPathCount();e++)for(let t=s.getPathStart(e);t<s.getPathEnd(e);t++){const r=s.getXY(t),h=Po(r.y,n.ymax)||Po(n.ymin,r.y);t===s.getPathStart(e)?(a.setNAN(),m=0):a.isNAN()||h||(m=Rn(r.x,a.x,o,i,m)),r.x+=m,s.setXYNoCurves(t,r),h||a.setCoordsPoint2D(r)}s.getImpl().notifyModifiedFlags(2001)}(this.m_gcs,0,m),function(e,t,s,n,m){const l=n.getGeometryType(),g=t.getPannableExtent();let c=n,u=!1,_=!1;if(l===i.G.enumPolygon){const s=new r.Envelope2D,n=h.P.construct(0,0);s.setCoords({env2D:g}),s.centerAt(n),u=function(e,t,s,n,i){const a=function(e,t){const s=new r.Envelope2D;t.queryEnvelope(s);const n=Po(e.ymax,s.ymax),i=Po(e.ymin,s.ymin),a=n||i;return!!a&&(function(e,t){const s=new o.P,n=new r.Envelope2D;for(let r=0;r<t.getPathCount();r++){t.queryPathEnvelope(r,n);let i=Po(e.ymax,n.ymax),o=Po(e.ymin,n.ymin);if(!i&&!o){s.addPath(t,r,!0);continue}s.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(r),m=t.getPathEnd(r),l=m-a;let g=-1;for(g=a;g<m;g++){const s=t.getXY(g);if(i=Po(e.ymax,s.y),o=Po(e.ymin,s.y),!i&&!o)break}let c=g,u=!1,_=Number.NaN;do{const n=t.getXY(c);i=Po(e.ymax,n.y),o=Po(e.ymin,n.y);const m=a+(c+1-a)%l;if(i||o){let i=h.P.construct(_,n.y);s.insertPoint2D(r,-1,i);const o=t.getXY(m),a=Po(e.ymax,o.y),l=Po(e.ymin,o.y);a||l||(i=h.P.construct(o.x,n.y),u?s.setXYNoCurves(s.getPointCount()-1,i):s.insertPoint2D(r,-1,i)),u=!0}else s.insertPoint2D(r,-1,n),_=n.x,u=!1;c=m}while(c!==g)}t.setEmpty(),t.add(s,!1)}(e,t),a)}(s,n),m=function(e,t,s,n,r){const i=[],a=[],h=.5*s.width();for(let o=0;o<n.getPathCount();o++){const m=n.getXY(n.getPathStart(o)),l=n.getXY(n.getPathEnd(o)-1),g=e[o]<0;if(Math.abs(m.x-l.x)>h){const e=Yn(g,t,s,o,n,r);i.push(e),a.push(o)}else if(!g&&n.calculateRingArea2D(o)<0){const e=Bn(t,s,o,n,r);i.push(e),a.push(o)}}if(0===i.length)return!1;const m=new o.P({vd:n.getDescription()});let l=0,g=a[l];for(let e=0;e<n.getPathCount();e++)e===g?(m.add(i[l],!1),l++,l<a.length&&(g=a[l])):m.addPath(n,e,!0);return n.setEmpty(),n.add(m,!1),!0}(e,t,s,n,i);return a||m}(e,t,s,c,m);const i=function(e,t,s,n){const i=new r.Envelope2D;s.queryEnvelope(i);const o=(0,a.e)(null,s,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return s;const h=s.createInstance();let m=s.createInstance();const l=new r.Envelope2D,g=s.getPathCount();for(let r=0;r<g;r++)s.queryPathEnvelope(r,l),t.xmin-l.xmin<=o&&l.xmax-t.xmax<=o?h.addPath(s,r,!0):(m.setEmpty(),m.addPath(s,r,!0),m=qn(e,t,m,0,n),h.add(m,!0));return h}(t,s,c,m);i!==c&&(_=!0),c=i}else c=(new cn).foldInto360RangeGeodetic(c,t,2);l===i.G.enumPolygon&&(u||_)&&(c=(new Js).execute(c,t,!1,m)),c!==n&&(n.setEmpty(),n.add(c,!1))}(l,this.m_gcs,0,m,s)):m=Er(m,this.m_gcs,0,!0,0,s),m}(0,i.a)("Gnomonic.unproject")}projectPoint(e){const t=e.mul(this.m_rpu),s=v(this.m_a,this.m_e2,t),n=this.m_normal.dotProduct(s);if(n<=0)return h.P.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new h.P;return o.x=this.m_basisX.dotProduct(i),o.y=this.m_basisY.dotProduct(i),o}unprojectPoint(e){const t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return w(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){const t=e.getImpl();let s=!0;const n=new h.P,r=new h.P;for(let e=0,i=t.getPointCount();e<i;e++)t.queryXY(e,n),n.y*this.m_rpu>.5*Math.PI?r.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?r.assign(this.m_southPolePcs):r.assign(this.projectPoint(n)),t.setXYNoCurves(e,r),r.isNAN()&&(s=!1);return t.notifyModifiedFlags(2001),s}unprojectMultiVertex(e,t){const s=t.getImpl(),n=e*e,r=!this.m_northPolePcs.isNAN(),i=!this.m_southPolePcs.isNAN();for(let e=0,t=s.getPointCount();e<t;e++){const t=s.getXY(e);let o=new h.P;r&&h.P.sqrDistance(t,this.m_northPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*Math.PI),o.scale(1/this.m_rpu)):i&&h.P.sqrDistance(t,this.m_southPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),o.scale(1/this.m_rpu)):o=this.unprojectPoint(t),s.setXYNoCurves(e,o)}s.notifyModifiedFlags(2001)}}function Yn(e,t,s,n,i,g){const c=new o.P,u=new o.P,_=new m.T,p=i.getXY(i.getPathStart(n)),d=i.getXY(i.getPathEnd(n)-1),f=s.width(),x=.5*f,P=new r.Envelope2D;i.queryEnvelope(P);const E=Math.ceil(P.width()/f)+1;let y,S;p.x>d.x?(y=-f,S=e?s.ymin:s.ymax):(y=f,S=e?s.ymax:s.ymin),_.setShiftCoords(y,0),c.addPath(i,n,!0),u.add(c,!1);const C=new a.P;for(let e=0;e<E;e++)u.applyTransformation(_),u.getPointByVal(0,C),c.lineToPoint(C),c.addSegmentsFromPath(u,0,0,u.getSegmentCount()-1,!1);const I=c.getXY(0),v=c.getXY(c.getPointCount()-1);I.y=S,v.y=S,c.lineTo(v);const b=new h.P;for(b.setCoordsPoint2D(v),b.x-=.5*y;Math.abs(b.x-I.x)>x;)c.lineTo(b),b.x-=.5*y;c.lineTo(I);const G=s.getCenter().x,w=new r.Envelope2D;c.queryEnvelope(w);let N=0;const T=w.getCenter().x;T-G>x?N=-Math.ceil((T-G-x)/f):G-T>x&&(N=Math.ceil((G-T-x)/f)),0!==N&&(_.setShiftCoords(N*f,0),c.applyTransformation(_));const D=new o.E,V=D.addGeometry(c);br(D,V,t,0,2,!0,s.xmin),br(D,V,t,0,2,!0,s.xmax);const k=D.getGeometry(V),F=(0,a.j)(k,s);F.inflateCoords(0,1);const H=(0,a.c)(null,F,!0);return(0,l.c)(k,s,H.total(),Number.NaN,g)}function Bn(e,t,s,n,i){const g=t.width(),c=.5*g,u=t.getCenter().x,_=new r.Envelope2D;n.queryPathEnvelope(s,_);let p,d=0,f=_.getCenter().x;if(f-u>c?d=-Math.ceil((f-u-c)/g):u-f>c&&(d=Math.ceil((u-f-c)/g)),0!==d){const e=new m.T;e.setShiftCoords(d*g,0),n.getImpl().applyTransformationToPath(e,s),n.queryPathEnvelope(s,_),f=_.getCenter().x}const x=new r.Envelope2D;t.containsExclusiveEnvelope(_)?(p=!1,x.setCoords({env2D:t})):(p=!0,x.setCoords({env2D:t}),x.xmin-=g,x.xmax+=g);let P=n.createInstance();P.addPathPoint2D(null,0,!0);const E=new h.P;if(E.setCoords(x.xmin,x.ymin),P.insertPoint2D(0,-1,E),E.setCoords(x.xmin,x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(.5*(x.xmin+x.xmax),x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(x.xmax,x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(x.xmax,x.ymin),P.insertPoint2D(0,-1,E),E.setCoords(.5*(x.xmin+x.xmax),x.ymin),P.insertPoint2D(0,-1,E),p){P.addPath(n,s,!0);const r=new m.T;f<u?r.setShiftCoords(g,0):r.setShiftCoords(-g,0),n.getImpl().applyTransformationToPath(r,s),P.addPath(n,s,!0);const h=new o.E,c=h.addGeometry(P);br(h,c,e,0,2,!0,t.xmin),br(h,c,e,0,2,!0,t.xmax),P=h.getGeometry(c);const _=(0,a.j)(P,t);_.inflateCoords(0,1);const p=(0,a.c)(null,_,!0).total();P=(0,l.c)(P,t,p,Number.NaN,i)}else P.addPath(n,s,!0);return P}function Rn(e,t,s,n,r){return r+e-t>s?r-=n:t-(r+e)>s&&(r+=n),r}function Xn(e,t,s,n,r,i){const m=t.getAttributeStreamRef(0),l=t.getPointCount();let g=!1;const c=new h.P;for(let e=0;e<l;++e){if(m.queryPoint2D(2*e,c),1&i&&c.y>=s){g=!0;break}if(2&i&&c.y<=-s){g=!0;break}}if(!g)return!1;let u=!1;e&&(u=t.getImpl().isClosedPathInXYPlane(0));const _=new o.E,p=_.addGeometry(t),d=_.getFirstPath(p);let f=-1,x=!0;const P=new h.P,E=new a.P;let y=o.n;const S=Ln*r/360;for(let e=_.getFirstVertex(d);e!==o.n;e=_.getNextVertex(e)){_.queryXY(e,c);let t=1&i&&c.y>=s?1:0;if(t|=2&i&&c.y<=-s?2:0,f>0&&f!==t){if(P.x!==c.x){const t=_.getPrevVertex(e);_.queryPoint(t,E);const s=_.insertVertex(d,e,E);P.x=c.x,_.setXY(s,P)}if(u){let t=y!==o.n?_.getNextVertex(y):_.getFirstVertex(d);const s=_.getPrevVertex(e);for(;t!==s;)t=_.removeVertex(t,!1);if(y!==o.n){const e=_.getXY(y),t=_.getXY(s);if(Math.abs(e.x-t.x)>S){_.queryPoint(y,E);const n=_.insertVertex(d,s,E);e.x=(0,h.q)(e.x,t.x,.5),_.setXY(n,e)}}}y=o.n}if(t&&(c.y=(0,h.f)(n,c.y),_.setXY(e,c),!x&&f!==t))if(c.x!==P.x){_.queryPoint(e,E);const t=_.insertVertex(d,e,E);_.setXYCoords(t,P.x,c.y),y=t}else y=e;f=t,P.assign(c),x=!1}if(u){if(y!==o.n){let e=_.getNextVertex(y);for(;e!==o.n;)e=_.removeVertex(e,!1)}const e=_.getFirstVertex(d);let t=_.getLastVertex(d);const s=_.getXY(e),n=_.getXY(t);if(!s.equals(n)&&(_.queryPoint(e,E),t=_.insertVertex(d,o.n,E),Math.abs(s.x-n.x)>S)){const e=_.insertVertex(d,t,E);s.x=(0,h.q)(s.x,n.x,.5),_.setXY(e,s)}}return t.assignCopy(_.getGeometry(p)),!0}const Ln=210;class zn{constructor(e,t,s,n,r,o,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=function(e,t){const s=e.getPannableExtent();return Number.isNaN(t)||s.centerAtCoords(t,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=Ln*this.m_degree,(0,i.g)(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,r,m,l){let g=s;const c=new o.a({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Xn(!0,c,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(g=!1));let u=-1;g&&(u=this.m_originalGeometry.getPathStart(e));const _=c.getAttributeStreamRef(0),p=c.getPointCount();let d=0,f=_.read(0),x=0;const P=3*this.m_pannableSR.getTolerance(0);let E=!1;const y=new h.P,S=new h.P;let C=!1;const I=c.hasNonLinearSegments(),v=new h.P;for(let e=1;e<p;++e){_.queryPoint2D(2*e,v);const t=v.x;let s=t+d;const r=s-f;if(v.x=s,Math.abs(r)>this.m_GCSLargeDelta){if(g){const t=u+e-1,s=u+(e+1<p?e:0),i=m.read(2*t),o=(m.read(2*s)-i)*n;Math.abs(r-o)>1*this.m_degree&&(g=!1)}g||(d-=(0,h.f)(this.m_width360,s-f),s=t+d,++x,C=0!==d,v.x=s)}else E||(0,a.a4)(y,S,v,P)&&(E=!0);C&&(I&&(0,i.d)("error in geonormalize_ring_ for curves"),_.write(2*e,s)),f=s,y.setCoordsPoint2D(S),S.setCoordsPoint2D(v)}x&&c.notifyModified();const b=c.getXY(0),G=c.getXY(p-1);if(h.P.distance(b,G)<P){const e=this.finalizeGeoNormalizeClosedRing(c,E,r);l.add(e,!1)}else{t<0&&(null!==this.m_originalGeometry?((0,i.g)(null!==this.m_originalGeometry),t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0):t=1);const s=this.finalizeGeoNormalizeOpenedRing(t>0,c);l.add(s,!1)}}geoNormalizePolygonGeometry(e){(0,i.g)(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),(0,i.g)(this.m_pannableSR.isPannable());let t=null,s=Number.NaN;const n=!!this.m_originalSR&&this.m_originalSR.isPannable();n&&(t=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const a=new o.P({vd:this.m_inputPoly.getDescription()});for(let r=0,i=this.m_inputPoly.getPathCount();r<i;++r){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[r]?1:0:-1;this.geonormalizeRing(r,i,n,s,e,t,a)}const h=this.m_pannableSR.getTolerance(0),m=this.m_pannableExtent.width()/180;Dr(a,this.m_pannableExtent,.1*h,!1);const c=r.Envelope2D.constructEmpty();if(c.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=r.Envelope2D.constructEmpty();for(let s=0,n=a.getPathCount();s<n;s++)if(a.queryPathEnvelope(s,t),!(c.xmin<=t.xmin&&c.xmax>=t.xmax||t.xmin>=c.xmax||t.xmax<=c.xmin)){e=!1;break}if(e)break;c.move(.5*this.m_width360,0)}e||c.setCoords({env2D:this.m_pannableExtent})}let u=(0,l.c)(a,c,h,m,this.m_progressTracker),_=a!==u;const p=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,d=u.calculateArea2D();let f=0;if(d>0&&p<0)f=1;else if(d<=0&&p>0)if(0===d){if(this.m_originalSR){let e=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?e=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(e=this.m_originalSR.getPannableExtent().getArea()),p>.99*e&&(f=-1)}}else f=-1;if(0!==f){const e=function(e,t){let s=new o.P({vd:e});s.addEnvelope(t,!1);const n=t.width()/180;return s=(new g.O).execute(s,n,0,0,null),s}(u.getDescription(),c);e.add(u,!1),_=!0,u=e}return _&&(u=(new Js).execute(u,this.m_pannableSR,!1,this.m_progressTracker)),u}geoNormalizePolylineGeometry(e){(0,i.g)(this.m_pannableSR.isPannable());let t=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let n=1;s&&((0,i.g)(this.m_originalGeometry),n=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const a=this.m_pannableExtent.width(),g=a*(0,h.O)()*4;let c=e,u=Number.NaN;const _=h.E.constructEmpty();this.m_bAdjustedAtPoles=0;let p=new o.a({vd:this.m_inputPoly.getDescription()});for(let e=0,l=this.m_inputPoly.getPathCount();e<l;++e){let l=s;const d=new o.a({vd:this.m_inputPoly.getDescription()});d.addPath(this.m_inputPoly,e,!0);const f=this.m_inputPoly.isClosedPath(e);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Xn(f,d,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,a,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(l=!1));let x=-1;const P=d.getPointCount();let E=!1;l&&(x=this.m_originalGeometry.getPathStart(e),E=this.m_originalGeometry.isClosedPath(e));const y=d.getAttributeStreamRef(0);let S=0,C=y.read(0),I=0;const v=new h.P,b=new h.P;let G=!1;const w=d.hasNonLinearSegments(),N=new h.P;for(let e=1;e<P;++e){y.queryPoint2D(2*e,N);const s=N.x;let r=s+S;const o=r-C;if(N.x=r,Math.abs(o)>this.m_GCSLargeDelta){if(l){const s=x+e-1;let r=x;(!E||e+1<P)&&(r+=e);const i=t.read(2*s),a=(t.read(2*r)-i)*n;Math.abs(o-a)>1*this.m_degree&&(l=!1)}l||(S-=(0,h.f)(this.m_width360,r-C),r=s+S,++I,G=0!==S,N.x=r)}G&&(w&&(0,i.d)("error in geonormalize_ring_ for curves"),y.write(2*e,r)),C=r,v.setCoordsPoint2D(b),b.setCoordsPoint2D(N)}if(I&&d.notifyModified(),c){let e=!1;if(!d.isEmpty()){const t=r.Envelope2D.constructEmpty();if(d.queryEnvelope(t),t.width()>=a||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(u)){const e=this.m_centralLongitude-.5*a;u=t.xmin,u+=Math.round((e-t.xmin)/a)*a,u>e&&(u-=a),(0,i.g)(u<=e),u<e&&(u+=a),(0,i.g)(u>=e)}let s=Math.round((u-t.xmin)/a)*a;if(t.xmin+s>u+g&&(s-=a),t.xmin+s<u-g&&(s+=a),_.mergeCoordinate(t.xmin+s),_.mergeCoordinate(t.xmax+s),e=_.width()>=a,!e){const e=new m.T;e.setShiftCoords(s,0),d.applyTransformation(e)}}}p.add(d,!1),e&&(p=(()=>{const e=new o.a({vd:p.getDescription()});for(let t=0,s=p.getPathCount();t<s;++t){const s=new o.a({vd:p.getDescription()});s.addPath(p,t,!0);const n=Er(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(n,!1)}return e})(),c=!1)}else{const e=Er(d,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);p.add(e,!1)}}if(c)return p;const d=this.m_pannableSR.getTolerance(0),f=this.m_pannableExtent.width()/180;return Dr(p,this.m_pannableExtent,.1*d,!1),(0,l.c)(p,this.m_pannableExtent,d,f,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const s=t.getPointCount(),n=t.getXY(0),a=t.getXY(s-1);{const e=Math.abs(a.x-n.x),t=Math.round(e/this.m_width360)*this.m_width360;(0,i.g)(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const l=(0,h.e)(a.x-n.x),g=r.Envelope2D.constructEmpty();t.queryLooseEnvelope(g);const c=this.m_pannableExtent.getCenterX();let u=0,_=c-this.m_width360,p=c+this.m_width360;if(l>=0){let e=Math.ceil((_-g.xmin)/this.m_width360);for(e*=this.m_width360;_>g.xmin+e;)e+=this.m_width360;for(;_<g.xmax+e;)e-=this.m_width360;for(u=e,g.width()>720&&(p=_+360*Math.ceil(g.width()/360));p<g.xmax;)p+=this.m_width360}else{let e=Math.ceil((p-g.xmax)/this.m_width360);for(e*=this.m_width360;p<g.xmax+e;)e-=this.m_width360;for(;p>g.xmin+e;)e+=this.m_width360;for(u=e,g.width()>720&&(_=p-360*Math.ceil(g.width()/360));_>g.xmin;)_-=this.m_width360}const d=Math.round(Math.abs(a.x-n.x)/this.m_width360)*this.m_width360,f=l*d,x=g.clone();x.move(u,0);const P=new h.P(0,0),E=new m.T;E.setShiftCoords(u,0),t.applyTransformation(E);const y=new o.a({vd:t.getDescription()});y.add(t,!1),P.assign(t.getXY(s-1));let S=0,C=y.getXY(0).x;for(;l>0?x.xmax<p:x.xmin>_;)x.move(f,0),E.xd=f,t.applyTransformation(E),C+=f,this.m_pannableExtent.xmin<=C&&this.m_pannableExtent.xmax>=C&&(S=y.getPointCount()-1),t.setXY(0,P),P.assign(t.getXY(s-1)),y.addSegmentsFromPath(t,0,0,s-1,!1);const I=new o.P({vd:y.getDescription()});I.add(y,!1);const v=y.getXY(0),b=y.getXY(y.getPointCount()-1),G=l<0?e:!e,w=I.getPointCount()-1;if(G){const e=new h.P(b.x,this.m_pannableExtent.ymax);I.lineTo(e);const t=new h.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);I.lineTo(t);const s=new h.P(v.x,this.m_pannableExtent.ymax);I.lineTo(s)}else{const e=new h.P(b.x,this.m_pannableExtent.ymin);I.lineTo(e);const t=new h.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);I.lineTo(t);const s=new h.P(v.x,this.m_pannableExtent.ymin);I.lineTo(s)}if(I.interpolateAttributesPath(0,w,0),I.getImpl().changeRingStartPoint(S),d>this.m_width360){const e=new o.P({copy:I});E.setShiftCoords(this.m_width360,0),e.applyTransformation(E),I.add(e,!1)}return I}finalizeGeoNormalizeClosedRing(e,t,s){const n=new o.P({vd:e.getDescription()});if(n.add(e,!1),n.hasNonLinearSegments()&&(()=>{const e=n.getPointCount()-2;return n.getSegmentType(e)!==i.G.enumLine})()){const e=new o.S,t=n.getPointCount()-2;n.getSegmentBuffer(t,e,!1),n.removePointFromPath(0,t+1),n.closeLastPathWithSegment(e.get())}else n.removePointFromPath(0,n.getPointCount()-1);const a=r.Envelope2D.constructEmpty();n.queryLooseEnvelope(a);let l=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(l*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+l;)l+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+l;)l-=this.m_width360;if(l+=this.m_width360,0!==l){a.move(l,0);const e=new m.T;e.setShiftCoords(l,0),n.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){const e=n.calculateArea2D(),t=(new Js).execute(n,this.m_pannableSR,!0,this.m_progressTracker);if(t!==n){const s=t.calculateArea2D();(0,h.e)(e)!==(0,h.e)(s)&&t.reverseAllPaths(),n.assignMove(t)}}let e;if(e=new o.P(s?{copy:n}:{move:n}),s)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const t=new m.T;t.setShiftCoords(this.m_width360,0),n.applyTransformation(t),e.add(n,!1)}return e}let g=new o.P({vd:e.getDescription()});g.add(n,!1);const c=t||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 e=new m.T;e.setShiftCoords(this.m_width360,0),n.applyTransformation(e),g.add(n,!1)}if(c){const e=g.calculateArea2D();g.setFillRule(1),g=(new Js).execute(g,this.m_pannableSR,!0,this.m_progressTracker);const t=g.calculateArea2D();(0,h.e)(e)!==(0,h.e)(t)&&g.reverseAllPaths()}return g}geonormalize_ring_(e,t,s,n,r,o,a){(0,i.g)(0)}}function Wn(e){(0,i.g)(0);const t=function(e){const t=new ai({},!0);return t.m_WKID=e,t}(e),s=new Zn;return s.setVertProj_(t),s}function jn(e){return!1}class Zn{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new Ti,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return(0,i.g)(0),0}getID(){return(0,i.g)(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return(0,i.g)(0),""}getTextExtended(e){return(0,i.g)(0),""}getText2(e){return(0,i.g)(0),""}getUnit(){return(0,i.g)(0),{}}equals(e){return(0,i.g)(0),!1}equalForProjection(e){return(0,i.g)(0),!1}getPeVertcsCopy(){return(0,i.g)(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return(0,i.g)(0),0}isDepth(){return(0,i.g)(0),!1}getVerticalShift(){return(0,i.g)(0),0}isCustomWkid(){return!!this.m_peVertSysVal&&this.m_peVertSysVal.isCustomWkid()}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Kn(e,t,s,n,r){if(e.equals(t))return!1;if(n){let s=1,i=0,o=1,a=1,h=0,m=1;Number.isNaN(e.m_heightMetersPerUnit)||(s=e.m_heightMetersPerUnit,i=e.m_heightZ0,o=e.m_heightSign,a=t.m_heightMetersPerUnit,h=t.m_heightZ0,m=t.m_heightSign);const l=o*m*s/a;for(let e=0;e<r;e++)n[e]=(n[e]-i)*l+h}let i=1,a=0;if(Number.isNaN(e.m_XYToRadians)||(i=e.m_XYToRadians/t.m_XYToRadians,a=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,0!==a&&(a=(0,o.b)(a),a/=t.m_XYToRadians)),Array.isArray(s)){const e=s;for(let t=0;t<r;t++)e[t][0]=e[t][0]*i+a,e[t][1]=e[t][1]*i}else{const e=s;for(let t=0;t<r;t++){const s=t<<1;e[s]=e[s]*i+a,e[s+1]=e[s+1]*i}}return!0}function Qn(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(e){this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0,this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees},equals(e){return(0,h.Q)(this.m_heightSign,e.m_heightSign)&&(0,h.Q)(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&(0,h.Q)(this.m_heightZ0,e.m_heightZ0)&&(0,h.Q)(this.m_XYToRadians,e.m_XYToRadians)&&(0,h.Q)(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,t&&(0,i.g)(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){const s=e?e.getPECoordSys():null,n=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Jn{constructor(e){this.m_constantsLoaded=-1,this.m_isUsable=-1,this.m_inputSR=null,this.m_outputSR=null,this.m_inputSRHorz=null,this.m_outputSRHorz=null,this.m_inputVCS=null,this.m_outputVCS=null,this.m_hashCode=0,this.m_areaOfUse=new a.E,this.m_inputUnitParams=Qn(),this.m_outputUnitParams=Qn(),(0,i.g)(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=yo.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const t=this.m_geogTran.getGeogcs1();yo.getCode(t);const s=this.m_geogTran.getGeogcs2();yo.getCode(s),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():((0,i.g)(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||(0,i.d)("vcs not impl");const t=this.m_geogTran.getParameters();null!==t[So.PE_PARM_ND]&&(e=0===t[So.PE_PARM_ND].getValue())}t=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=t}return 0!==t}isUsable(){let e=this.m_isUsable;return-1===e&&(this.m_geogTran?this.m_isUsable=e=this.m_geogTran?1:0:this.m_isUsable=e=this.m_vertTran?1:0),1===e}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return 0===e&&(e=this.m_latestID>0?(0,h.au)(this.m_latestID):(0,h.aA)(this.getText()),0===e&&(e=345),this.m_hashCode=e),e}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():((0,i.t)("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,s,n,r,o;if(this.m_geogTran){const i=this.m_geogTran.getGeogcs1(),a=Ei(i),h=this.m_geogTran.getGeogcs2(),m=Ei(h);let l=-1,g=-1;l=a.getVcsCode(),g=m.getVcsCode(),s=Li(i,null,0,1),n=Li(h,null,0,1),l>0&&g>0?(r=Wn(l),o=Wn(g),e={},t={}):(e=s,t=n)}else(0,i.g)(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=s,this.m_outputSRHorz=n,this.m_inputVCS=r,this.m_outputVCS=o)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=Number.NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_outputUnitParams.m_XYToRadians=Number.NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_vertTran)(0,i.g)(0);else if(this.m_geogTran){const e=this.m_geogTran;let t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function $n(e,t,s,n,r,i,o){let a=null;t&&(a=t.getPEVerticalCoordSys());let h=null;e&&(h=e.getPECoordSys());let m=null;n&&(m=n.getPEVerticalCoordSys());let l=null;if(s&&(l=s.getPECoordSys()),!(h||a||l||m))return!1;const g=Qn();g.initFromGcsAndVcsPe(h,a);const c=Qn();return c.initFromGcsAndVcsPe(l,m),Kn(g,c,r,i,o)}function er(e,t,s,n,r,i,o,a){const h=t,m=e,l=Qn();l.initFromGcsAndVcsPe(m,h),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Kn(l,a,r,i,o)}function tr(e,t,s,n,r,i,o,a,h){const m=Qn(),l=Qn();m.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),l.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),m.processUnitParams(e),l.processUnitParams(m),m.processUnitParams(l),a>0&&Kn(m,l,i,o,a),h.assign(l)}function sr(e,t,s,n,r,i,o){const a=t.getVerttran(),h=t.getGeogtran();if(o.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),i>0){t.prepareOrThrow();const e=s?So.PE_TRANSFORM_2_TO_1:So.PE_TRANSFORM_1_TO_2;a?Kr():Qr(h,i,n,r,e)}}class nr{supportsCurves(){return!0}accelerateGeometry(e,t,s){return rr(e,t,s)}canAccelerateGeometry(e){return ir(e)}}function rr(e,t,s){if(!ir(e))return!1;(0,a.N)(t,e,!1);let n=0;const r=e.getGeometryType();return(0,i.h)(r)&&(0,o.I)(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),(0,i.h)(r)&&(0,o.J)(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function ir(e){return(0,o.I)(e)||(0,o.J)(e)}class or extends nr{getOperatorType(){return 8}execute(e,t,s,n){return $e(e,t,s,1,n)}}class ar{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new hr(e,t,s,n)}execute(e,t,s,n){return this.executeMany(new u.S([e]),new u.S([t]),s,n).next()}}class hr extends c.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=s;const r=t.next();this.m_geomSubtractor=r||new o.P}next(){const e=this.m_inputGeoms.next();return e?((0,i.c)(e),(0,i.y)(e),this.m_index=this.m_inputGeoms.getGeometryID(),function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return e;const m=e.getDimension(),g=t.getDimension();if(m>g)return e;const c=e.getGeometryType(),u=t.getGeometryType(),_=new r.Envelope2D,p=new r.Envelope2D,d=new r.Envelope2D;e.queryEnvelope(_),t.queryEnvelope(p),d.setCoords({env2D:_}),d.mergeEnvelope2D(p);const f=(0,a.c)(s,d,!0),x=(0,a.h)(f),P=new r.Envelope2D;if(P.setCoords({env2D:_}),P.inflateCoords(x,x),!P.isIntersecting(p))return e;if(1===m&&2===g){const h=function(e,t,s,n,h){const m=new a.E;e.queryEnvelope(m);const l=new r.Envelope2D;t.queryEnvelope(l),m.merge(l);const g=.1*m.width(),c=.1*m.height();m.inflateCoords(g,c);const u=new o.P;u.addEnvelope(m,!1);const _=u.getImpl();if(s===i.G.enumPolygon){const e=t.getImpl();_.add(e,!0)}else _.addEnvelope(t,!0);return new en(u,n,-1,h).tryFastImplementation(e)}(e,t,u,s,n);if(h)return h}if(c===i.G.enumPoint){let s;switch((0,i.f)(u)?(s=new o.a({vd:t.getDescription()}),s.addSegment(t,!0)):s=t,u){case i.G.enumPolygon:return function(e,t,s){return 0===$t(t,e,s.total())?e:e.createInstance()}(e,s,f);case i.G.enumPolyline:return function(e,t,s){const n=e.getXY(),i=t.querySegmentIterator(),o=(0,a.h)(s),m=o*o;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment(),a=new r.Envelope2D;if(t.queryEnvelope(a),a.inflateCoords(o,o),!a.contains(n))continue;if(t.isIntersectingPoint(n,s.total()))return e.createInstance();let l=t.getStartXY();if(h.P.sqrDistance(n,l)<=m)return e.createInstance();if(l=t.getEndXY(),h.P.sqrDistance(n,l)<=m)return e.createInstance()}return e}(e,s,f);case i.G.enumMultiPoint:return function(e,t,s){const n=t.getImpl().getAttributeStreamRef(0),r=t.getPointCount(),i=e.getXY(),o=(0,a.h)(s),m=o*o,l=new h.P;for(let t=0;t<r;t++)if(n.queryPoint2D(2*t,l),h.P.sqrDistance(l,i)<=m)return e.createInstance();return e}(e,s,f);case i.G.enumEnvelope:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getXY();return n.contains(i)?e.createInstance():e}(e,s,f);case i.G.enumPoint:return function(e,t,s){const n=(0,a.h)(s),r=n*n,i=e.getXY(),o=t.getXY();return h.P.sqrDistance(i,o)<=r?e.createInstance():e}(e,s,f);default:(0,i.a)("invalid shape type")}}else if(c===i.G.enumMultiPoint)switch(u){case i.G.enumPolygon:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getPointCount();let o=!1;const a=(0,h.d)(i,!1),m=new h.P;for(let r=0;r<i;r++)e.queryXY(r,m),n.contains(m)&&0!==es(t,m,s.total())&&(o=!0,a[r]=!0);if(!o)return e;const l=e.createInstance();for(let t=0;t<i;t++)a[t]||l.addPoints(e,t,t+1);return l}(e,t,f);case i.G.enumEnvelope:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getPointCount();let o=!1;const a=(0,h.d)(i,!1),m=new h.P;for(let t=0;t<i;t++)e.queryXY(t,m),n.contains(m)&&(o=!0,a[t]=!0);if(!o)return e;const l=e.createInstance();for(let t=0;t<i;t++)a[t]||l.addPoints(e,t,t+1);return l}(e,t,f);case i.G.enumPoint:return function(e,t,s){const n=e.getImpl().getAttributeStreamRef(0),r=e.getPointCount(),i=t.getXY();let o=!1;const m=(0,h.d)(r,!1),l=(0,a.h)(s),g=l*l,c=new h.P;for(let e=0;e<r;e++)n.queryPoint2D(2*e,c),h.P.sqrDistance(c,i)<=g&&(o=!0,m[e]=!0);if(!o)return e;const u=e.createInstance();for(let t=0;t<r;t++)m[t]||u.addPoints(e,t,t+1);return u}(e,t,f)}const E=new r.Envelope2D(_);return E.inflate(100*f.total()),function(e,t,s,n){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return Fs(Hs(e),e,0,"-");const h=new r.Envelope2D;e.queryEnvelope(h);const m=new r.Envelope2D;t.queryEnvelope(m);const l=new r.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=m.clone(),u=(0,a.h)(g);if(c.inflateCoords(u,u),!h.isIntersecting(c))return Fs(Hs(e),e,0,"-");const _=new ks(n),p=new o.E,d=p.addGeometry(Hs(e)),f=p.addGeometry(Hs(t));let x=0,P=0,E=null;if(p.hasCurves()){E=new cs;const e=p.getEnvelope2D(n);P=ls(g.total());const t=ms(g.total(),e);x=gs(t,P),os(p,t,g.total(),0,E,null,n)}_.setEditShapeCrackAndCluster(p,g.add(x));const y=_.difference(d,f);null!==E&&E.stitchCurves(p,y,P,!0);const S=Fs(p.getGeometry(y),e,0,"-");return Ss(S.getGeometryType())&&(S.getImpl().setIsSimple(4,g.total()),S.getGeometryType()===i.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}(e,(0,l.c)(t,E,0,0,n),s,n)}(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class mr{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n=0){return new gr(e,t,s,n)}execute(e,t,s,n){const r=new u.S([e,t]),o=new gr(r,s,n,0).next();return o||(0,i.d)("null output"),o}}class lr{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>function(e,t){return h.P.compareZorder(e.location,t.location)?-1:e.location.equals(t.location)?0:1}(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class gr extends c.G{constructor(e,t,s,n,r=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=(0,h.av)(4),this.m_dimGeomCounts=(0,h.d)(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=(0,h.d)(4,!1),this.m_complexUnionGeoms=(0,h.av)(4),this.m_totalNonEmptyGeomCounters=(0,h.d)(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=n,this.m_bIs3D=r}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 e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?(0,i.g)(0):this.m_complexUnionGeoms[e]=(new ar).execute(this.m_complexUnionGeoms[e],this.m_complexUnionGeoms[t],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&(0,i.d)(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.G.enumPoint){const e=new o.M({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}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(e){return this.m_readyGeoms[e]}finishDim(e,t,s){let n=t;if(!s)return 16&this.m_options?(n=Ds([n],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),n):n;if(1&this.m_options)return n;if(1===e)if(8&this.m_options||!(16&this.m_options||this.m_totalNonEmptyGeomCounters[e]>1))1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?(0,i.g)(0):n=(new Js).execute(n,this.m_spatialReference,!1,this.m_progressTracker));else{n=Ds([n],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=n.getImpl().getIsSimple(0,e);(0,i.g)(this.m_bIs3D||(0,a.i)(t))}else this.m_bIs3D?(0,i.g)(0):n=(new Js).execute(n,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&n.getGeometryType()===i.G.enumPoint){const e=new o.M({vd:n.getDescription()});n.isEmpty()||e.add(n),n=e}return n}static getLevel(e){const t=(0,i.v)(e);let s=t>0?(Math.log(t)-Math.log(32))/Math.log(4):0;return s<0&&(s=0),Math.floor(s)}step_(){if(this.m_bDone)return!0;let e;if(this.m_inputGeoms?(e=this.m_inputGeoms.next(),null===e?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,null!==e){const t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let e=0;e<=this.m_maxDimension;e++){for(;this.m_dimGeomCounts[e]>1;){const t=this.collectGeometriesToUnion(e);if(null===t)break;{let s;s=1&this.m_options?Ds(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Vs(t,t.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(e,!0,s)}}if(this.m_bDone&&((0,i.g)(this.m_dimGeomCounts[e]<=1),0!==this.m_dimGeomCounts[e])){const t=this.m_unionBins[e].entries().next().value,s=t[1].geomPairs()[0].geom,n=t[1].geomPairs()[0].bUnioned;this.m_unionBins[e].clear(),this.m_readyGeoms[e]=this.finishDim(e,s,n)}}return this.m_bDone}addGeom(e,t,s){const n={geom:null,vertexCount:-1,bUnioned:!1,location:new h.P};n.geom=s;const o=(0,i.v)(s);n.vertexCount=o;const a=r.Envelope2D.constructEmpty();s.queryEnvelope(a),n.location=o>0?a.getCenter():new h.P(0,0);const m=gr.getLevel(s);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let l=null;const g=this.m_unionBins[e].get(m);g&&(l=g),null===l&&(l=new lr,this.m_unionBins[e].set(m,l)),n.bUnioned=t,l.addPair(n),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(1&this.m_options&&!this.m_bDone)return null;let t=null;const s=[];for(const t of this.m_unionBins[e].keys())s.push(t);(0,h.v)(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const r=this.m_unionBins[e].get(s[n]);{const i=5e3,o=4,a=r.getBinVertexCount()>i&&r.geomCount()>=o;if(this.m_bDone||a){for(let r=0;r<n;r++){if(-1===s[r])continue;const n=this.m_unionBins[e].get(s[r]);n.sort(),this.m_dimGeomCounts[e]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const e of n.geomPairs())t||(t=new Array),t.push(e.geom);n.clear(),this.m_unionBins[e].delete(s[r]),s[r]=-1}r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(const e of r.geomPairs())t||(t=new Array),t.push(e.geom);if(r.clear(),this.m_unionBins[e].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&(0,i.A)(),e.hasAttribute(1)||(0,i.a)("Geometry must have Zs")),(0,i.c)(e)}}class cr extends nr{getOperatorType(){return 3}execute(e,t,s,n=null){return $e(e,t,s,4,n)}}function ur(e,t,s){const n=t.getGCSSplitLines();if(null===n)return e;const l=t.getGCS(),g=l.getPannableExtent().width(),c=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(c);const u=h.E.constructEmpty();c.queryIntervalX(u);const _=n.querySegmentIterator();let p=null;const d=new m.T;for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment(),t=e.queryInterval(0,0),s=h.E.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>u.vmin;)s.move(-g),n--;for(;s.vmin<=u.vmax;){if(s.isIntersecting(u)){null===p&&(p=new o.a);const t=new o.L({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(d.setShiftCoords(n*g,0),t.applyTransformation(d)),p.addSegment(t,!0)}s.move(g),++n}}if(null!==p){const t=(0,a.e)(l,p,!0);return function(e,t,s,n){const r=t.getGeometryType();if((0,i.h)(r))return new be(n).crackAWithBMultiPath_(e,t,s);(0,i.t)("crack_A_with_B")}(e,p,(0,a.h)(t),s)}return e}function _r(e,t,s){let n=e.getName();return to(n)||(s||t>0?(n=e.toString(So.PE_STR_NAME_CANON|So.PE_STR_AUTH_NONE),n=function(e){return e.toLocaleUpperCase("en-US")}(n)):n=e.toString(So.PE_STR_AUTH_TOP)),n}function pr(e,t=-1){if((t>1||t<-1)&&(0,i.a)("verbosity"),-1===t)return e.toString();{const s=0===t?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL;return e.toString(s)}}function dr(e,t,s,n){if(e.isEmpty()||1===s)return e;const o=e.getGeometryType();if(o===i.G.enumPoint){const n=e,r=n.getXY();return 0===Pr([r],1,t,s)||r.isNAN()?n.setEmpty():n.setXY(r),e}if(o===i.G.enumMultiPoint){const n=e,r=e.createInstance(),i=n.getPointCount();r.reserve(i);const o=n.getAttributeStreamRef(0),h=n.getDescription().getAttributeCount()>1,m=new a.P,l=Float64Array.from(o.getArray());if(Pr(l,i,t,s)>0)for(let e=0,t=2*i;e<t;e+=2)Number.isNaN(l[e])||(h?(n.getPointByVal(e>>1,m),m.setXYCoords(l[e],l[e+1]),r.add(m)):r.addXY(l[e],l[e+1]));return r}let h=e;const g=t.getOneDegreeGCSUnit(),c=90*g,u=180*g,_=360*g,p=t.getCentralMeridian(),d=.5*g,f=r.Envelope2D.constructEmpty();h.queryEnvelope(f);const x=t.getGCSHorizon(),P=t.getGCSHorisonIsInclusive(),E=x.getGeometryType()===i.G.enumEnvelope,y=r.Envelope2D.constructEmpty();x.queryEnvelope(y);const S=t.getGCS();if(2!==s&&4!==s||(y.xmin=p-u,y.xmax=y.xmin+_),4===s){if(!(f.width()>_-g)){const e=r.Envelope2D.constructEmpty();e.setCoords({xmin:f.xmin-g,ymin:y.ymin,xmax:f.xmax+g,ymax:y.ymax}),h=(new l.O).execute(h,e,S,n);let t=Math.floor((p-f.getCenterX())/_);for(f.move(t*_,0);f.xmin>y.xmax;)t-=1,f.move(-_,0);for(;f.xmin<y.xmin;)t+=1,f.move(_,0);if(0!==t){const e=new m.T;e.setShiftCoords(t*_,0),h.applyTransformation(e)}return h}s=2}if(2===s&&(y.xmin=p-u,y.xmax=y.xmin+_),f.ymin<-c||f.ymax>c){const e=r.Envelope2D.constructEmpty();if(e.setCoords({xmin:f.xmin-g,ymin:-c,xmax:f.xmax+g,ymax:c}),h=(new l.O).execute(h,e,S,n),h.isEmpty())return h;h.queryEnvelope(f)}if(P&&(y.ymax<f.ymin||y.ymin>f.ymax))return h.createInstance();f.width()>_&&(h=Nr(h,p-u,_,S,!0,0,!0,n),h.queryEnvelope(f));let C=function(e,t,s,n,r){return e>=s&&t<=n?0:wr(.5*(t+e),s,n,r)}(f.xmin,f.xmax,y.xmin,y.xmax,_);if(0!==C&&f.move(C,0),f.xmax>y.xmax||f.xmin<y.xmin){if(f.xmax>y.xmax)for(;f.xmin>=y.xmax;)f.move(-_,0),C-=_;for(;f.xmin<y.xmax-_;)f.move(_,0),C+=_}const I=(0,a.N)(S,x,!1);if(0!==C){const e=new m.T;e.setShiftCoords(C,0),h.applyTransformation(e),C=0}if(P){if(E&&y.containsEnvelope(f))return h;const e=new Array(2);for(let t=0;t<2;t++){let s;if(E?s=(0,i.h)(o)?(0,l.c)(h,y,I,d,n):(0,l.c)(h,y,I,0,n):(s=(new sn).execute(h,x,S,n),s===x&&(s=s.clone())),y.xmin<=f.xmin&&y.xmax>=f.xmax)return s;if(y.xmin>=f.xmin&&y.xmax<=f.xmax)return s;if(e[t]=s,0===t){f.move(-_,0);const e=new m.T;e.setShiftCoords(-_,0),h.applyTransformation(e)}}return(0,i.h)(o)?e[0].add(e[1],!1):(0,i.d)("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(y.ymax<f.ymin||y.ymin>f.ymax)return h;let e=0;for(;!h.isEmpty()&&f.xmax>y.xmin;){if(0!==e){const t=new m.T;t.setShiftCoords(e,0),h.applyTransformation(t)}if((new cr).execute(h,x,S,n)||(h=(new ar).execute(h,x,S,n),x===h&&(h=h.clone())),0!==e){const t=new m.T;t.setShiftCoords(-e,0),h.applyTransformation(t)}e-=_,f.move(-_,0)}return h}}function fr(e,t,s,r,i,m){const l={stack:[],error:void 0,hasError:!1};try{if(2===m)return function(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>h.o||Math.abs(n.y)>h.o)return Number.NaN;if((Math.abs(s.y)===h.o||Math.abs(n.y)===h.o)&&s.x!==n.x)return Number.NaN;const{first:i,second:m}=(0,h.aE)(s.x,n.x);let l=r;if(l=I(l,i,m),!h.E.construct(s.x,n.x).containsCoordinate(l))return Number.NaN;const g=o._.constructPoint2D(s),c=o._.constructPoint2D(n),u=G(1,t,g),_=G(1,t,c),p=u.crossProductVector(_);if(p.z.isZero())return s.y;const d=p.x.divE(p.z.negate()),f=p.y.divE(p.z.negate()),x=d.mulE(d).addE(f.mulE(f)).sqrt();if(x.isZero()||d.isZero()&&f.isZero())return s.y;const P=Math.atan2(f.value(),d.value());let E=Math.atan2(x.value()*Math.cos(P-l),1-t);const y=v(1,t,h.P.construct(l,E)),S=a.f.construct(y.x,y.y,-y.z),C=p.value().dotProduct(y),b=p.value().dotProduct(S);return Math.abs(b)<Math.abs(C)&&(E=-E),E}(0,t,s,r,i);if(Math.abs(s.x-r.x)>=Math.PI||!si(s.x,r.x,i))return Number.NaN;s.x>r.x&&(r=(0,h.c)(s,s=r));const g=(0,n.mS)(l,new Eo,!1),c=(0,n.mS)(l,new Eo,!1),u=(0,n.mS)(l,new Eo,!1),_=s.clone();wo.geodeticDistance(e,t,s.x,s.y,r.x,r.y,c,g,null,m);const p=c.val;let d=0,f=1;for(;p*(f-d)>1e-12*e;){const n=.5*(d+f);if(wo.geodeticCoordinate(e,t,s.x,s.y,p*n,g.val,c,u,m),_.x=c.val,_.y=u.val,_.x===i)return _.y;if(si(s.x,_.x,i))f=n;else{if(!si(r.x,_.x,i))return Number.NaN;d=n}}return _.y}catch(e){l.error=e,l.hasError=!0}finally{(0,n.hk)(l)}}function xr(e,t,s,n){for(let r=0,i=0;r<n;r++,i+=2)t[s+r].x=e[i],t[s+r].y=e[i+1]}function Pr(e,t,s,n){if(0===t||1===n)return t;const o=function(e,t){let s;if(Array.isArray(e)){const n=e;s=new Float64Array(2*t);for(let e=0,r=0;e<t;e++,r+=2)s[r]=n[e].x,s[r+1]=n[e].y}else s=e;return s}(e,t);if(2===n){const n=s.getPannableExtentInGCS();let r=t;for(let e=0,s=2*t;e<s;e+=2)(o[e+1]>n.ymax||o[e+1]<n.ymin)&&(o[e]=Number.NaN,r--);return r?(Tr(o,t,n.xmin,n.width(),!0),e!==o&&xr(o,e,0,t),r):(e!==o&&xr(o,e,0,t),0)}const m=s.getOneDegreeGCSUnit(),l=90*m,g=180*m,c=360*m;let u=t;for(let e=0,s=2*t;e<s;e+=2)(o[e+1]>l||o[e+1]<-l)&&(o[e]=Number.NaN,u--);if(!u)return e!==o&&xr(o,e,0,t),0;const _=r.Envelope2D.constructEmpty();_.setFromPoints(o,t);const p=s.getGCSHorizon(),d=s.getGCSHorisonIsInclusive(),f=p.getGeometryType()===i.G.enumEnvelope,x=r.Envelope2D.constructEmpty();if(p.queryEnvelope(x),d&&(x.ymax<_.ymin||x.ymin>_.ymax))return e!==o&&xr(o,e,0,t),0;if(d)if(Tr(o,t,x.getCenterX()-g,c,!0),u=t,f)for(let e=0,s=2*t;e<s;e+=2)x.containsCoords(o[e],o[e+1])||(o[e]=Number.NaN,u--);else{const e=(0,a.N)(s.getGCS(),p,!1),n=new h.P;for(let s=0,r=2*t;s<r;s+=2)n.setCoords(o[s],o[s+1]),0!==es(p,n,e)||(o[s]=Number.NaN,u--)}else{Tr(o,t,-g,c,!0),u=t;const e=(0,a.N)(s.getGCS(),p,!1),n=new h.P;for(let s=0,r=2*t;s<r;s+=2){n.setCoords(o[s],o[s+1]),n.isNAN()&&u--;const t=wr(n.x,x.xmin,x.xmax,c);n.x+=t,0!==es(p,n,e)&&(o[s]=Number.NaN,u--)}}return e!==o&&xr(o,e,0,t),u}function Er(e,t,s,n,r,o){if(t.isPannable()||(0,i.a)("fold_into_360_degree_range"),e.isEmpty())return e;let a,h;if(2===t.getCoordinateSystemType()){const e=t.getPannableExtent();h=e.xmin,a=e.width()}else{const e=t.getOneDegreeGCSUnit();a=360*e,h=s-180*e}return Nr(e,h,a,t,n,r,!0,o)}function yr(e,t,s,n){let r,i;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();r=e.xmin,i=e.width()}else{const e=s.getOneDegreeGCSUnit();i=360*e,r=n-180*e}Tr(e,t,r,i)}function Sr(e,t){const s=t.width();let n=(0,h.l)(e-t.vmin,s);return n<0&&(n+=s),t.snapClip(n+t.vmin)}function Cr(e,t,s){return e>t.xmax&&e-t.xmax<s?t.xmax:e<t.xmin&&t.xmin-e<s?t.xmin:e}function Ir(e,t,s){if(e[0]<t.vmin||e[0]>t.vmax||s&&e[0]===t.vmax){const s=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/s)*s,e[0]=t.snapClip(e[0]),!0}return!1}function vr(e,t,s,n,r){const i=new o.E,h=i.addGeometry(e);return br(i,h,t,(0,a.N)(t,e,!1),s,n,r),i.getGeometry(h)}function br(e,t,s,r,a,m,l){const g={stack:[],error:void 0,hasError:!1};try{(0,i.g)(Oi()),s.isPannable()||(0,i.q)("insert_geodetic_points");const c=s.getPannableExtent(),u=s.getGCS(),_=Ui();u.querySpheroidData(_);const p=u.getUnit().getUnitToBaseFactor(),d=_.majorSemiAxis,f=_.e2;let x=0;const P=new h.E;c.queryIntervalX(P);let E=null;const y=(0,h.d)(4,Number.NaN);2===s.getCoordinateSystemType()?(E=s.getPECoordSys(),m?(y[0]=Sr(l,P),y[1]=c.getCenterY(),Co.projToGeog(E,1,y),x=y[0]*p):(y[0]=c.getCenterX(),y[1]=l,Co.projToGeog(E,1,y),x=y[1]*p)):x=l*p,m||0===x||2===a||(0,i.q)("insert_geodetic_points: 1");const S=(0,n.mS)(g,new Eo,!1),C=new h.P,I=new h.P,v=new h.P,b=new h.P,G=new h.P,w=new h.P;for(let n=e.getFirstPath(t);n!==o.n;n=e.getNextPath(n)){const t=e.getFirstVertex(n);e.queryXY(t,v);let i=!1;const g=e.getNextVertex(t);for(let t=g;t!==o.n;t=e.getNextVertex(t)){if(t===g){if(i)break;i=!0}if(e.queryXY(t,b),m&&(r<l-v.x&&b.x-l>r||r<l-b.x&&v.x-l>r)||!m&&(0!==l||r<-v.y&&b.y>r||r<-b.y&&v.y>r))do{if(Math.abs(v.x-b.x)>=.5*P.width())break;2===s.getCoordinateSystemType()?(y[0]=Sr(v.x,P),y[1]=v.y,y[2]=Sr(b.x,P),y[3]=b.y,Br(E,2,y,0),G.x=y[0]*p,G.y=y[1]*p,w.y=y[3]*p):(G.x=v.x*p,G.y=v.y*p,w.y=b.y*p),w.x=(b.x-v.x)*Math.PI*2/P.width()+G.x;let n=0;const r=(0,h.m)(h.P,2);if(m){if(I.x=x,I.y=fr(d,f,G,w,x,a),Number.isNaN(I.y))break;r[0]=I,n=1}else if(2===a){const e=[0,0];if(n=V(0,f,G,w,x,e),!n)break;r[0].x=e[0],r[0].y=x,2===n&&(r[1].x=e[1],r[1].y=x)}else{if(I.x=ni(d,f,G,w,a),Number.isNaN(I.x))break;I.y=0,r[0]=I,n=1}let i=-1;for(let o=0;o<n;o++){wo.geodeticDistance(d,f,G.x,G.y,w.x,w.y,S,null,null,a);const n=S.val;wo.geodeticDistance(d,f,G.x,G.y,r[o].x,r[o].y,S,null,null,a);const g=S.val;2===s.getCoordinateSystemType()?(y[0]=r[o].x/p,y[1]=r[o].y/p,Co.geogToProj(E,1,y),m?(C.y=y[1],C.x=l):(C.x=ri(y[0],v.x,b.x,P),C.y=l)):m?(C.x=l,C.y=r[o].y/p):(C.x=ri(r[o].x/p,v.x,b.x,P),C.y=l);const c=n>0?(0,h.s)(g/n,0,1):.5;if(0===c||1===c)continue;if(i>c)continue;const u=e.getPrevVertex(t);e.splitSegment(u,[c],1);const _=e.getNextVertex(u);e.setXYCoords(_,C.x,C.y),i=c}}while(0);v.setCoordsPoint2D(b)}}}catch(e){g.error=e,g.hasError=!0}finally{(0,n.hk)(g)}}function Gr(e,t){(0,i.g)(t.isPannable());const s=t.getPannableExtent();if(e.getGeometryType()===i.G.enumPoint){const t=e.getY();return s.ymin<=t&&t<=s.ymax?e:e.createInstance()}const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n);const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.xmin=n.xmin,o.xmax=n.xmax,o.inflateCoords(.01*o.height(),0);const h=(0,a.d)(t,n,!1);let m;return m=o.containsEnvelope(n)?e:(0,l.c)(e,o,h,0,null),m}function wr(e,t,s,n){return(0,h.ax)((.5*(s+t)-e)/n)*n}function Nr(e,t,s,n,a,g,c,u){const _=e.getGeometryType(),p=h.E.constructEmpty();p.setCoords(t,t+s);const d=[0];if(_===i.G.enumPoint){const t=e;if(d[0]=t.getX(),Ir(d,p,c)){const t=a?e:e.clone();return t.setX(d[0]),t}return e}const f=r.Envelope2D.constructEmpty();if(e.queryEnvelope(f),f.isEmpty())return e;if(_===i.G.enumMultiPoint){const t=a?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let i=!1;for(let e=0;e<r;e+=2)d[0]=n.read(e),Ir(d,p,c)&&(n.write(e,d[0]),i=!0);return i&&s.notifyModifiedFlags(2001),t}const x=h.E.constructEmpty();if(f.queryIntervalX(x),p.contains(x))return p.vmax,x.vmax,e;const P=r.Envelope2D.constructEmpty();if(P.setCoords({env2D:f}),0===x.width()){let t=x.vmin;t+=Math.ceil((p.vmin-t)/s)*s,t=p.snapClip(t);const n=a?e:e.clone();return n.setAttributeBasic(0,0,t),n}if(_===i.G.enumEnvelope){const t=a?e:e.clone();return f.intersect(P),t.setEnvelope(f),t}const E=.1*Math.max(f.height(),f.width())*1;P.inflateCoords(0,E);let y=e;const S=n.getTolerance(0),C=new m.T;for(;;){const e=Math.floor((x.vmin-t)/s),r=Math.ceil((x.vmax-t)/s);if(!(r-e>3))break;{const o=Math.floor(.5*(r+e));P.xmin=f.xmin-E,P.xmax=t+s*o;const a=(0,l.c)(y,P,S,g,u);P.xmin=P.xmax,P.xmax=f.xmax+E;const h=(0,l.c)(y,P,S,g,u);C.setShiftCoords((o-r)*s,0),h.applyTransformation(C),_===i.G.enumPolygon?y=(new mr).execute(a,h,n,u):(y=a,y.add(h,!1)),y.queryEnvelope(f),f.queryIntervalX(x)}}P.xmin=t,P.xmax=t+s;const I=r.Envelope2D.constructEmpty();I.setCoords({env2D:P}),I.inflateCoords(S,0);const v=Math.floor((f.xmin-P.xmin)/s)*s;let b;v?(P.move(v,0),C.setShiftCoords(-v,0)):C.setIdentity(),b=_===i.G.enumPolyline?new o.a({vd:y.getDescription()}):new o.P({vd:y.getDescription()});const G=r.Envelope2D.constructEmpty(),w=r.Envelope2D.constructEmpty();for(;f.xmax>P.xmin;){const e=(0,l.c)(y,P,S,0,u);e.queryEnvelope(w);let t=!1;t=_===i.G.enumPolyline?!e.isEmpty()&&(w.width()>S||w.height()>S):!e.isEmpty()&&(_!==i.G.enumPolygon||w.width()>S),t&&(e.applyTransformation(C),e.queryEnvelope(w),b.queryEnvelope(G),G.inflateCoords(S,S),G.isIntersecting(w)&&_===i.G.enumPolygon?b=(new mr).execute(b,e,n,u):b.add(e,!1)),P.move(s,0),C.shiftCoords(-s,0)}return b}function Tr(e,t,s,n,r=!0){const i=new h.E;i.setCoords(s,s+n);const o=[0];if(Array.isArray(e)){const s=e;for(let e=0;e<t;e++)i.containsRightExclusive(s[e].x)||(o[0]=s[e].x,Ir(o,i,r),s[e].x=o[0])}else{const s=e;for(let e=0;e<t;e++){const t=e<<1;i.containsRightExclusive(s[t])||(o[0]=s[t],Ir(o,i,r),s[t]=o[0])}}}function Dr(e,t,s,n=!0){if(e.isEmpty())return;const o=e.getGeometryType();if(!n||o!==i.G.enumPolygon)if((0,i.i)(o)){let n=!1;if((0,i.h)(o)&&e.hasNonLinearSegments()){const r=e.getImpl(),o=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();(0,i.g)(null!==a);for(let e=0,i=r.getPathCount();e<i;e++){let i=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);h&&r.getPathSize(e)>0&&(i=1==(31&a.read(m-1)));for(let h=r.getPathStart(e);h<m;h++)if(1==(31&a.read(h))){if(i){const e=o.read(2*h),r=Cr(e,t,s);r!==e&&(n=!0,o.write(2*h,r))}i=!0}else i=!1}}else{const r=e.getImpl(),i=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){const r=i.read(2*e),o=Cr(r,t,s);o!==r&&(n=!0,i.write(2*e,o))}}n&&e.getImpl().notifyModifiedFlags(2001)}else if(o===i.G.enumEnvelope){const n=e,i=r.Envelope2D.constructEmpty();n.queryEnvelope(i),i.xmin=Cr(i.xmin,t,s),i.xmax=Cr(i.xmax,t,s),n.setEnvelope(i)}else if(o===i.G.enumPoint){const n=e;n.setX(Cr(n.getX(),t,s))}else(0,i.d)("")}function Vr(e,t,s){const n=new h.P;return n.x=Cr(e.x,t,s),n.y=e.y,n}function kr(e,t,s,n){const o=e.getGeometryType();(0,i.g)(o===i.G.enumPolygon||o===i.G.enumPolyline||o===i.G.enumMultiPoint);const m=t.getCoordinateSystemType();if(2===m){let m=e;if(0===s){const s=function(e,t){if(t.isEmpty())return 0;const s=e.getPECoordSys();if(s.getProjection().getCode()===So.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Ui();e.querySpheroidData(n);const i=s.getParameters();if(null===i[So.PE_PARM_LAM0])return 0;if(null===i[So.PE_PARM_PHI0])return 0;const o=[i[So.PE_PARM_LAM0].getValue(),i[So.PE_PARM_PHI0].getValue()];Co.geogToProj(s,1,o);const a=new h.P(o[0],o[1]),m=r.Envelope2D.constructEmpty();t.queryEnvelope(m);const l=(0,h.m)(h.P,4);m.queryCorners(l);let g=0;const c=e.getOneMeter();let u=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,_=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;_-=u/180,u*=c,_*=c;for(let e=0;e<4;e++){const t=h.P.distance(l[e],a);if(t>u)g++;else if(t>_)return-1}if(0===g)return 1;if(4===g){const e=r.Envelope2D.constructEmpty();return e.setCoords({center:a,width:u,height:u}),m.isIntersectingNe(e)?-1:0}return-1}return-1}(t,e);if(0===s)return e.createInstance();if(1===s)return e;const o=t.getPCSHorizon(),g=o.getGeometryType(),c=t.getDefaultPrecisionSR();if(g===i.G.enumEnvelope){const s=r.Envelope2D.constructEmpty();o.queryEnvelope(s);const i=(0,a.d)(c,s,!1);m=(0,l.c)(e,s,i,5e4*t.getOneMeterPCSUnit(),n)}else(new or).execute(o,e,c,n)||(m=(new sn).execute(m,o,c,n),m===o&&(m=m.clone()))}else if(t.isPannable()){const e=r.Envelope2D.constructEmpty();m.queryEnvelope(e);const a=t.getPannableExtent();a.containsEnvelope(e)||(Dr(m,a,t.getTolerance(0)),2!==s&&4!==s||(m=Gr(m,t)),4!==s?m=Er(m,t,0,!0,1e5*t.getOneMeterPCSUnit(),n):o===i.G.enumPolygon&&e.width()>2*a.width()&&(m=Nr(m,-2*a.width(),2*a.width(),t,!0,0,!0,n)))}return m}if((0,i.g)(1===m),o===i.G.enumMultiPoint)return Dr(e,t.getPannableExtent(),t.getTolerance(0)),e;{const s=r.Envelope2D.constructEmpty();e.queryEnvelope(s);let a=e;const h=t.getPannableExtent();if(s.ymin<h.ymin||s.ymax>h.ymax){const e=Math.max(1,s.calculateToleranceFromEnvelope()),i=new r.Envelope2D(s.xmin-e,h.ymin,s.xmax+e,h.ymax);if(a=(new l.O).execute(a,i,t,n),a.isEmpty())return a}return o===i.G.enumPolygon&&s.width()>2*h.width()&&(a=Nr(a,-2*h.width(),2*h.width(),t,!0,0,!0,n)),a}}function Fr(e,t){const s=t.getPointCount();if(!s)return;const n=t.getImpl(),r=n.getAttributeStreamRef(0),i=e;Co.geogToProj(i,s,r.getArray()),n.notifyModifiedFlags(2001)}function Hr(e,t,s,n){if(!s)return;const r=e.getPECoordSys();if(1===s){if(t[0].isNAN())return;const s=[t[0].x,t[0].y];if(Co.geogToProj(r,1,s),n){const{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(t[0].x-e.getCentralMeridian())+r}return void t[0].setCoords(s[0],s[1])}const i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let m=0;i&&(m=e.getCentralMeridian());const l=new Float64Array(512);for(let g=0;g<s;){for(let e=g;e<s&&t[e].isNAN();++e)g++;let c=Math.min(256,s-g);if(c>0){for(let e=1,s=g+1;e<c;++e,++s)if(t[s].isNAN()){c=e;break}for(let e=0;e<c;++e){const s=e<<1;l[s]=t[g+e].x,l[s+1]=t[g+e].y}if(Co.geogToProj(r,c,l),n){const{first:s,second:n}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<c;++e)l[e<<1]=s*(t[g+e].x-m)+n}if(i)for(let e=0,s=g;e<c;e++,s++){const n=e<<1,r=l[n],i=(0,h.e)(r),g=t[s].x-m;i*(0,h.e)(g)<0&&Math.abs(r)>a&&(l[n]-=i*o)}xr(l,t,g,c),g+=c}}}function Ar(e,t,s,n){const i=new o.M({vd:t.getDescription()});let a;i.addPoints(t,0,-1),a=(new cn).execute(i,e,n);const h=t.getPointCount();if(s.setEmpty(),e.getInputSR().isPannable()){if(h!==a.getPointCount())return!1;const n=new r.Envelope2D;t.queryEnvelope(n);const i=new r.Envelope2D;a.queryEnvelope(i);const o=n.width(),m=i.width();if(0!==o&&0!==m){const t=m/o,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==o||0!==m)return!1;s.add(t,!1);for(let e=0;e<h;e++){const t=a.getXY(e);s.setXY(e,t)}return!0}return!1}function Mr(e,t,s){(0,i.g)(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),o=r.getAttributeStreamRef(0),a=e.getPECoordSys();let m=0;const l=o.readRange(0,2*n);let g=()=>{Co.geogToProj(a,n,l)};const c=e.isPannable()&&!s,u=c?e.getPannableExtent().width():0,_=179*u/360;if(e.isPannable()&&(m=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;g=()=>{Co.geogToProj(a,n,l);for(let e=0;e<n;e++){const t=e<<1,n=o.read(t),i=s*(n-m)+r;l[t]=i}}}if(g(),c)for(let e=0;e<n;e++){const t=e<<1,s=l[t],n=(0,h.e)(s),r=o.read(t)-m;n*(0,h.e)(r)<0&&Math.abs(s)>_&&(l[t]+=-n*u)}o.writeRangeFromArray(0,2*n,l,!0,1),r.notifyModifiedFlags(2001)}function Ur(e,t,s){switch(t.getGeometryType()){case i.G.enumLine:return void function(e,t,s){const n=[t.getStartXY(),t.getEndXY()];Hr(e,n,2,s),t.setStartXY(n[0]),t.setEndXY(n[1]),t.normalizeAfterEndpointChange()}(e,t,s);case i.G.enumBezier:return void function(e,t,s){const n=(0,h.m)(h.P,4);t.queryControlPoints(n),$r(e,n,4,s),t.setControlPoints(n)}(e,t,s);case i.G.enumEllipticArc:return void function(e,t,s){if(0===t.projectionBehavior())!function(e,t,s){ti(!0,e,0,t,s)}(e,t,s);else{const n=t.isClosed()&&t.isMajor(),r=[t.getStartXY(),n?t.getCenter():t.getEndXY()],i=[r[0].clone(),r[1].clone()];$r(e,i,2,s);const o=new m.T;o.initializeFromTwoPointsArray(r,i),t.applyTransformation(o);const a=n?0:1;t.setCoordsForIntersector(i[0],i[a],!1)}}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return void(0,i.g)(0);default:(0,i.d)("")}}function qr(e,t,s){if(!t.hasNonLinearSegments())return void Mr(e,t,s);if((0,i.g)(!s||e.isPannable()),t.isEmpty())return;const n=e.getPECoordSys(),r=e.isPannable(),m=r?e.getPannableExtent().width():0,l=179*m/360;let g=0;r&&(g=e.getCentralMeridian());const c=t.createInstance();c.reserveParts(t.getPointCount(),t.getPathCount());const u=t.getImpl(),_=new o.S;for(let i=0,o=t.getPathCount();i<o;++i)if(u.hasNonLinearSegmentsPath(i)){let t=!0,n=-1;const r=u.getPathStart(i),o=r+u.getSegmentCountPath(i);u.isClosedPath(i)&&(n=o-1);const m=new h.P;for(let i=r;i<o;++i){if(u.getSegmentBuffer(i,_,!1),Ur(e,_.get(),s),t||_.get().getStartXY().equals(m)||_.get().moveTo(m),i!==n)c.addSegment(_.get(),t);else{if(t){const e=new a.P;_.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(_.get())}m.assign(_.get().getEndXY()),t=!1}}else{const e=1024;let s,o=u.getPathSize(i),a=Math.min(o,e);c.insertPath(-1,t,i,!0);const _=u.getAttributeStreamRef(0),p=c.getAttributeStreamRef(0);for(let t=u.getPathStart(i),c=u.getPathEnd(i);t<c;){if(s=_.readRange(t,a),Co.geogToProj(n,a,s),r)for(let e=0;e<a;e++){const t=e<<1,n=s[t],r=(0,h.e)(n),i=_.read(2*(0+e))-g;r*(0,h.e)(i)<0&&Math.abs(n)>l&&(s[t]+=-r*m)}p.writeRangeFromArray(t,a,s,!0,1),t+=a,o-=a,a=Math.min(o,e)}}t.assignMove(c)}function Or(e,t,s){let n=s.getPointCount();if(!n)return;const r=s.getImpl(),i=r.getAttributeStreamRef(0);let o=Math.min(n,1e3),a=0;const m=e.getPECoordSys();Number.isNaN(t)&&(t=0);const l=e.isPannable(),g=e.getOneDegreeGCSUnit(),c=360*g,u=179*g;let _;for(;n;){if(_=i.readRange(2*a,2*o),Br(m,o,_,t),l)for(let e=0;e<o;e++){const s=e<<1,n=_[s]-t,r=(0,h.e)(n),o=i.read(2*(a+e));r*(0,h.e)(o)<0&&Math.abs(n)>u&&(_[s]+=-r*c)}i.writeRangeFromArray(2*a,2*o,_,!0,1),a+=o,n-=o,o=Math.min(n,1e3)}r.notifyModifiedFlags(2001)}function Yr(e,t,s){switch(s.getGeometryType()){case i.G.enumLine:return void function(e,t,s){const n=[s.getStartXY(),s.getEndXY()];Xr(e,t,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}(e,t,s);case i.G.enumBezier:return void function(e,t,s){const n=(0,h.m)(h.P,4);s.queryControlPoints(n),ei(e,t,n,4),s.setControlPoints(n)}(e,t,s);case i.G.enumEllipticArc:return void function(e,t,s){if(0===s.projectionBehavior())!function(e,t,s){ti(!1,e,t,s,!1)}(e,t,s);else{const n=s.isClosed()&&s.isMajor(),r=[s.getStartXY(),n?s.getCenter():s.getEndXY()],i=[r[0].clone(),r[1].clone()];ei(e,t,i,2);const o=new m.T;o.initializeFromTwoPointsArray(r,i),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(i[0],i[a],!1)}}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return void(0,i.g)(0);default:(0,i.d)("")}}function Br(e,t,s,n){const r=Co.projToGeogCenter(e,t,s,n);for(let e=0;e<t;++e){const t=e<<1;(0,i.g)(Number.isFinite(s[t]+s[t+1]))}return r}function Rr(e,t,s){if(!s.hasNonLinearSegments())return void Or(e,t,s);if(s.isEmpty())return;const n=e.getPECoordSys();Number.isNaN(t)&&(t=0);const r=e.isPannable(),i=e.getOneDegreeGCSUnit(),m=360*i,l=179*i,g=s.createInstance();g.reserveParts(s.getPointCount(),s.getPathCount());const c=s.getImpl(),u=new o.S;for(let i=0,o=s.getPathCount();i<o;++i)if(c.hasNonLinearSegmentsPath(i)){let s=!0,n=-1;const r=c.getPathStart(i),o=r+c.getSegmentCountPath(i);c.isClosedPath(i)&&(n=o-1);const m=new h.P;for(let i=r;i<o;++i){if(c.getSegmentBuffer(i,u,!1),Yr(e,t,u.get()),s||u.get().getStartXY().equals(m)||u.get().moveTo(m),i!==n)g.addSegment(u.get(),s);else{if(s){const e=new a.P;u.get().queryStart(e),g.startPathPoint(e)}g.closeLastPathWithSegment(u.get())}m.assign(u.get().getEndXY()),s=!1}}else{const e=1e3;let o,a=c.getPathSize(i),u=Math.min(a,e);g.insertPath(-1,s,i,!0);const _=c.getAttributeStreamRef(0),p=g.getAttributeStreamRef(0);for(let s=c.getPathStart(i),g=c.getPathEnd(i);s<g;){if(o=_.readRange(2*s,2*u),Br(n,u,o,t),r)for(let e=0;e<u;e++){const n=e<<1,r=o[n]-t,i=(0,h.e)(r),a=_.read(2*s);i*(0,h.e)(a)<0&&Math.abs(r)>l&&(o[n]+=-i*m)}p.writeRangeFromArray(2*s,2*u,o,!0,1),s+=u,a-=u,u=Math.min(a,e)}}s.assignMove(g)}function Xr(e,t,s,n){const r=e.getPECoordSys();Number.isNaN(t)&&(t=0);const i=e.isPannable(),o=e.getOneDegreeGCSUnit(),a=360*o,m=179*o,l=new Float64Array(512);for(let e=0;e<n;){for(let t=e;t<n&&s[t].isNAN();++t)e++;let o=Math.min(256,n-e);if(o>0){for(let t=1,n=e+1;t<o;++t,++n)if(s[n].isNAN()){o=t;break}for(let t=0;t<o;t++){const n=t<<1;l[n]=s[e+t].x,l[n+1]=s[e+t].y}if(Br(r,o,l,t),i)for(let n=0,r=e;n<o;++n,++r){const e=n<<1,i=s[r].x,o=l[e]-t,g=(0,h.e)(o);g*(0,h.e)(i)<0&&Math.abs(o)>m&&(l[e]-=g*a)}for(let t=0;t<o;t++){const n=t<<1;s[e+t].x=l[n],s[e+t].y=l[n+1]}e+=o}}}function Lr(e,t,s,n){(0,i.g)(0)}function zr(e,t,s){let n=t.getPointCount();if(!n)return!1;const r=t.getImpl(),i=r.getAttributeStreamRef(0);let o=null;const a=e.getInputSR(),m=e.getOutputSR();a.getVCS(),m.getVCS();const l=a.getOneDegreeGCSUnit(),g=m.getOneDegreeGCSUnit(),c=e.isVertical();c&&t.hasAttribute(1)&&(o=r.getAttributeStreamRef(1));const u=e.getDatumTransformation(),_=!!u&&1===u.getType();if(_||null===o||(Lr(o.getArray()),o=null),!u||0===u.count()){const e=a.getGcsUnitFactor()/m.getGcsUnitFactor(),t=(a.getPrimeMeridian()-m.getPrimeMeridian())*g,s=-90*l,o=90*l;let c=0;const u=i.getArray(),_=[0];for(let e=1,t=2*n;e<t;)_[0]=u[e],c|=(0,h.aD)(_,s,o)?1:0,u[e]=_[0],e+=2;if(0!==t||1!==e){c=1;const s=i.getArray();for(let r=0,i=2*n;r<i;){let n=s[r];n*=e,n+=t,s[r]=n,s[r+1]*=e,r+=2}}return 0!==c&&r.notifyModifiedFlags(2001),!!c}let p=Math.min(n,1e3);const d=(0,h.d)(p,Number.NaN),f=(0,h.d)(p,Number.NaN);let x=null;null!==o&&(x=new Float64Array(p));let P=0,E=Number.NaN,y=Number.NaN;const S=360*g,C=g/l;s&&(y=90*g,E=89.9*l,f.fill(0));let I=!0,v=0;for(;n;){let e=!1;const t=i.readRange(2*P,2*p);for(let e=0;e<p;e++)d[e]=t[e<<1];if(s)for(let s=0;s<p;s++){const n=1+(s<<1),r=Math.abs(t[n])-E;if(r>0){const i=t[n];t[n]=(0,h.f)(E,i),f[s]=(0,h.f)(r,i),e=!0}}const r=t[0];if(_){const e=u;x&&o.queryRange(P,p,x,!0,1),e.transform(!1,t,x,p),x&&o.writeRangeFromArray(P,p,x,!0,1)}else u.transform(!1,t,p);I&&(v=t[0]-C*r,I=!1);for(let e=0;e<p;e++){const s=e<<1,n=t[s]-d[e]*C-v;Math.abs(n)>200&&(t[s]+=n>0?-S:S)}if(e){for(let e=0;e<p;e++)if(f[e]){const s=1+(e<<1);t[s]+=C*f[e],t[s]>y?t[s]=y:t[s]<-y&&(t[s]=-y)}f.fill(0)}i.writeRangeFromArray(2*P,2*p,t,!0,1),c&&o&&o.writeRangeFromArray(P,p,x,!0,1),P+=p,n-=p,p=Math.min(n,1e3)}return r.notifyModifiedFlags(2001),!0}function Wr(e,t,s){switch(t.getGeometryType()){case i.G.enumLine:return function(e,t,s){const n=[t.getStartXY(),t.getEndXY()];let r=null;t.hasAttribute(1)&&(r=[0,0],r[0]=t.getAttributeAsDbl(0,1,0),r[1]=t.getAttributeAsDbl(1,1,0));const i=Jr(e,n,r,2,s);return t.setStartXY(n[0]),t.setEndXY(n[1]),r&&(t.setStartAttribute(1,0,r[0]),t.setEndAttribute(1,0,r[1])),t.normalizeAfterEndpointChange(),i}(e,t,s);case i.G.enumBezier:return function(e,t,s){const n=(0,h.m)(h.P,4);t.queryControlPoints(n);let r=null;t.hasAttribute(1)&&(r=[0,0,0,0],r[0]=t.getAttributeAsDbl(0,1,0),r[3]=t.getAttributeAsDbl(1,1,0),r[1]=(0,h.q)(r[0],r[3],.5),r[2]=r[1]);const i=Jr(e,n,r||null,n.length,s);return t.setControlPoints(n),r&&(t.setStartAttribute(1,0,r[0]),t.setEndAttribute(1,0,r[3])),t.normalizeAfterEndpointChange(),i}(e,t,s);case i.G.enumEllipticArc:return function(e,t,s){if(0===t.projectionBehavior())return function(e,t,s){const n=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()];let r=4;t.isDegenerateToLine()&&(r=2);const i=[0,0,0,0];let o=null;if(t.hasAttribute(1)){o=i,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);const e=(0,h.q)(o[0],o[1],.5);o[2]=e,o[3]=e}const a=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),m=Jr(e,n,o,r,s);return a?t.constructCircleCenterAndPoint(n[3],n[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(n[0],n[1]):t.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),m}(e,t,s);const n=t.getStartXY().equals(t.getEndXY()),r=(0,h.m)(h.P,3),i=(0,h.m)(h.P,3);let o=null;r[0].assign(t.getStartXY()),r[1].assign(n?t.getCenter():t.getEndXY());let a=!1;t.hasAttribute(1)&&(o=[0,0,0],o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0),o[2]=(0,h.q)(o[0],o[1],.5),n&&(o[1]=o[2])),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]);const l=new m.T;if(n||t.isDegenerateToLine())a=Jr(e,i,o,2,s),l.initializeFromTwoPoints(r[0],r[1],i[0],i[1]);else{const n=new h.P;t.queryCoord2D(.5,n),r[2].setCoordsPoint2D(n),i[2].setCoordsPoint2D(n),a=Jr(e,i,o,3,s),l.setFromTwoTriangles(r,i)}return l.isIdentity()||(t.applyTransformation(l),t.setStartXY(i[0]),t.setEndXY(n?i[0]:i[1]),t.normalizeAfterEndpointChange()),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,n?o[0]:o[1])),a}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return(0,i.g)(0),!1;default:(0,i.d)("")}}function jr(e,t,s){if(!t.hasNonLinearSegments())return zr(e,t,s);if(t.isEmpty())return!1;const n=t.createInstance();n.reserveParts(t.getPointCount(),t.getPathCount());const r=t.getImpl(),i=new o.S;for(let o=0,m=t.getPathCount();o<m;++o){let t=!0,m=-1;const l=r.getPathStart(o),g=l+r.getSegmentCountPath(o);r.isClosedPath(o)&&(m=g-1);const c=new h.P;for(let o=l;o<g;++o){if(r.getSegmentBuffer(o,i,!1),Wr(e,i.get(),s),t||i.get().getStartXY().equals(c)||i.get().moveTo(c),o!==m)n.addSegment(i.get(),t);else{if(t){const e=new a.P;i.get().queryStart(e),n.startPathPoint(e)}n.closeLastPathWithSegment(i.get())}c.assign(i.get().getEndXY()),t=!1}}return t.assignMove(n),!0}function Zr(e,t,s,n,r,i){if(e.isIdentityGeogToGeog()){const s=90*e.getInputSR().getOneDegreeGCSUnit();let r=0;const i=[0];for(let e=0;e<n;e++)i[0]=t[e].y,r|=(0,h.aD)(i,-s,s)?1:0,t[e].y=i[0];return r}const o=e.getInputSR(),a=e.getOutputSR(),m=o.getVCS(),l=a.getVCS(),g=o.getOneDegreeGCSUnit(),c=90*g,u=a.getOneDegreeGCSUnit(),_=e.isVertical(),p=e.getDatumTransformation(),d=!!p&&1===p.getType();if(_||(s=null),!p||0===p.count()){let e=0;const r=[0];for(let s=0;s<n;s++)r[0]=t[s].y,e|=(0,h.aD)(r,-c,c)?1:0,t[s].y=r[0];return e|=$n(o.getGCS(),m,a.getGCS(),l,t,s,n)?1:0,e}d||null===s||Lr();let f=Math.min(n,1024);const x=(0,h.d)(f,Number.NaN),P=(0,h.d)(f,Number.NaN);let E=0,y=Number.NaN,S=Number.NaN;const C=360*u,I=u/g;r&&(S=90*u,y=89.9*g);let v=!0,b=0,G=n;for(;G;){let e=!1;for(let e=0;e<f;e++)x[e]=t[e+E].x;if(r)for(let s=0;s<f;s++){const n=Math.abs(t[s+E].y)-y;if(n>0){const r=t[s+E].y;t[s+E].y=(0,h.f)(y,r),P[s]=(0,h.f)(n,r),e=!0}}const n=t[0].x;d?p.transform(!1,t,s,f):p.transform(!1,t,f),v&&(b=t[0].x-I*n,v=!1);for(let e=0;e<f;e++){const s=t[E+e].x-x[e]*I-b;Math.abs(s)>200&&(s>0?t[E+e].x-=C:t[E+e].x+=C)}if(e){for(let e=0;e<f;e++)P[e]&&(t[E+e].y+=I*P[e],t[E+e].y>S?t[E+e].y=S:t[E+e].y<-S&&(t[E+e].y=-S));P.fill(0,0,f)}E+=f,G-=f,f=Math.min(G,1024)}return 1}function Kr(e,t,s,n,r){return(0,i.g)(0),0}function Qr(e,t,s,n,r){(0,i.g)(null===n),(0,i.g)(t<2147483647);const o=Array.isArray(s);let a;a=o?(0,h.aH)(s):s;const m=Io.geogToGeog(e,t,a,null,r);return o&&(0,h.aI)(a,s),m}function Jr(e,t,s,n,r,i){let o=0,a=!0,h=0;for(let i=0;i<n;++i)t[i].isNAN()?a||(o|=Zr(e,t.slice(h,i-h),s?s.slice(h,i-h):null,i-h,r),h=i,a=!0):a&&(h=i,a=!1);return a||(o|=Zr(e,0===h?t:t.slice(h),s?0===h?s:s.slice(h):null,n-h,r)),0!==o}function $r(e,t,s,n){Hr(e,t,s,n)}function ei(e,t,s,n){Xr(e,t,s,n);const i=new r.Envelope2D;i.setFromPoints(s,n);const o=e.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(i.width()>h){for(let e=0;e<n;e++)for(;s[e].x<t;)s[e].x+=a;if(i.setFromPoints(s,n),i.xmax>h+t)for(let e=0;e<n;e++)s[e].x-=a}}function ti(e,t,s,n,r){const i=(0,h.m)(h.P,3);let o=0,a=!1,m=!1;const l=n.isDegenerateToLine();l?(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(a=!0,m=!n.isClockwise(),i[0].assign(n.getStartXY()),i[1].assign(n.getCenter()),i[2].setCoords(0,0),o=2):(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].assign(n.getInteriorPoint()),o=3),e?$r(t,i,o,r):ei(t,s,i,o),l?n.constructLineCircularArc(i[0],i[1]):a?n.constructCircleCenterAndPoint(i[1],i[0],m):n.constructCircularArcThreePoint(i[0],i[1],i[2])}function si(e,t,s){const n=(0,o.a8)(e),r=(0,o.a8)(t),i=(0,o.a4)(n,r),a=(0,o.a4)(n,(0,o.a8)(s));return 0===a||i>0&&a>0&&a<=i||i<0&&a<0&&a>=i}function ni(e,t,s,r,o){const a={stack:[],error:void 0,hasError:!1};try{const m=s.clone(),l=r.clone();if(2===o){const e=[0,0];return V(0,t,m,l,0,e),e[0]}if(m.y>l.y){const e=new h.P;e.assign(m),m.assign(l),l.assign(e)}const g=(0,n.mS)(a,new Eo,!1),c=(0,n.mS)(a,new Eo,!1),u=(0,n.mS)(a,new Eo,!1),_=new h.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;wo.geodeticDistance(e,t,m.x,m.y,l.x,l.y,c,g,null,o);const p=c.val;let d=0,f=1;const x=m.clone();for(;p*(f-d)>1e-12*e;){const s=.5*(d+f);if(wo.geodeticCoordinate(e,t,m.x,m.y,p*s,g.val,c,u,o),x.x=c.val,x.y=u.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,i.g)(!1),Number.NaN;d=s}}return x.x}catch(e){a.error=e,a.hasError=!0}finally{(0,n.hk)(a)}}function ri(e,t,s,n){const r=new h.E;r.setCoords(t,s);const i=n.width();let o=Math.floor((e-t)/i)*i+e;const a=r.getCenter();for(;Math.abs(o-a)>Math.abs(o+i-a);)o+=i;return o}class ii extends c.G{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}class oi{constructor(e,t=!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=h.P.getNAN(),this.m_southPole=h.P.getNAN(),this.m_polesUpdated=0,this.m_domain=r.Envelope2D.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=r.Envelope2D.constructEmpty(),this.m_pannableExtentGCS=r.Envelope2D.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=e,this.m_WKID=yo.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_r(e,0,!0),this.m_hashCode=(0,h.aA)(this.m_canonicalWkt)):this.m_hashCode=(0,h.B)(this.m_WKID);const s=this.m_peCoordSys.getType();this.m_csType=s===So.PE_TYPE_PROJCS?2:1,(0,i.g)(s===So.PE_TYPE_PROJCS||s===So.PE_TYPE_GEOGCS),s===So.PE_TYPE_PROJCS&&(e.loadConstants()||(0,i.a)("PeProjcs.loadConstants failed"));const n=s===So.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();s!==So.PE_TYPE_GEOGCS&&yo.getCode(n),this.m_unit=function(e){const t=Do(null);return e.getType()===So.PE_TYPE_PROJCS||e.getType()===So.PE_TYPE_GEOGCS?t.reset(e.getUnit()):(0,i.a)("PE_coord_sys"),t.get()||(0,i.d)("cannot create units from coord sys"),function(e){return e.getType()===So.PE_TYPE_LINUNIT?new Ti(e):e.getType()===So.PE_TYPE_ANGUNIT?new x(e):void(0,i.a)("peUnit")}(t.get())}(e),this.m_primeMeridian=n.getPrimem().getLongitude();{const e=n.getUnit().getUnitFactor();this.m_gcsUnitFactor=e;let t=Math.PI/(180*e);Math.abs(t-1)<1e-10&&(t=1),this.m_oneDegreeGCS=t}if(s===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=vo.generate(e,vo.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||(0,i.d)("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 e=1/n.getUnit().getUnitFactor(),t=n.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/t*e,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,i.g)(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==So.PE_TYPE_PROJCS)return;let e=!0;const t=this.m_peCoordSys,s=t.getGeogcs(),n=t.horizonGcsGenerate();if(!n)return;(0,i.g)(n.length>0);const g=n[0].getNump(),c=n[0].getKind();let u,_;e=n[0].getInclusive()>0;const p=this.getOneDegreeGCSUnit(),d=90*p,f=360*p,x=370*p,P=180*p*So.PE_HORIZON_DELTA/Math.PI,E=r.Envelope2D.constructEmpty();let y=null;if(g>1)for(let e=1;e<g;e++)if(n[e].getKind()===So.PE_HORIZON_LINE){y||(y=new o.a);const t=n[e].getCoord();y.startPathCoords(t[0][0],t[0][1]),y.lineToCoords(t[1][0],t[1][1])}if(c===So.PE_HORIZON_RECT){const t=n[0].getCoord();if(E.setFromPoints([new h.P(t[0][0],t[0][1]),new h.P(t[1][0],t[1][1])],2),Math.abs(E.ymax-d)<1e-7*P&&(E.ymax=d),Math.abs(E.ymin+d)<1e-7*P&&(E.ymin=-d),E.width()>x){const e=-400*p,t=e+5*f;E.setCoords({xmin:e,ymin:E.ymin,xmax:t,ymax:E.ymax})}const s=new a.E({env2D:E});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const a=Li(s,null,0,1),c=[],x=new h.E;for(let e=0;e<g;e++){if(n[e].getKind()!==So.PE_HORIZON_POLY)continue;u=n[e].getSize();const t=n[e].getCoord(),s=r.Envelope2D.constructEmpty();s.setFromPoints((0,h.aB)(t),u),c.push(new h.E(s.xmin,s.xmax)),s.width(),x.merge(c.at(-1))}let P=!1;const E=new h.E;x.width()>f&&c.length>1?(E.vmin=this.getCentralMeridian()-f,E.vmax=E.vmin+2*f,P=!0,t=!0):(E.vmin=x.vmin,E.vmax=E.vmin+f);const S=e=>{let t=0;for(;c[e].vmin+t<E.vmin;)t+=f;for(;c[e].vmax+t-f>E.vmin;)t-=f;return t};let C=new o.P;if(t){const e=new ii,t=(new mr).executeMany(e,a,null);for(let s=0;s<g;s++){if(n[s].getKind()!==So.PE_HORIZON_POLY)continue;u=n[s].getSize();const r=n[s].getCoord();_=n[s].getInclusive()>0;const i=new o.P;if(i.addPathPoint2D((0,h.aB)(r),u-1,!0),P){const t=S(s),n=c[s].clone();n.move(t);let r=t;const o=new m.T;do{o.setShiftCoords(r,0);const t=i.clone();t.applyTransformation(o),e.tick(t),e.tock(),r+=f,n.move(f)}while(n.vmin<E.vmax)}else e.tick(i),t.tock()}C=t.next()}else{C=new o.P;for(let t=0;t<g;t++){if(n[t].getKind()!==So.PE_HORIZON_POLY)continue;u=n[t].getSize();const s=n[t].getCoord();if(_=n[t].getInclusive()>0,(0,i.g)(_===e),P){const e=new o.P;e.addPathPoint2D((0,h.aB)(s),u-1,!0);const n=S(t),r=c[t].clone();r.move(n);let i=n;const a=new m.T;do{if(0!==i){a.setShiftCoords(i,0);const t=new o.P({copy:e});t.applyTransformation(a),C.addPath(t,0,!0)}else C.addPath(e,0,!0);i+=f,r.move(f)}while(r.vmin<E.vmax)}else C.addPathPoint2D((0,h.aB)(s),u-1,!0)}}P&&(C=(new l.O).execute(C,new r.Envelope2D(E.vmin,-d-p,E.vmax,d+p),a,null)),e?(new sn).accelerateGeometry(C,a,1):(new ar).accelerateGeometry(C,a,1),(new cr).accelerateGeometry(C,a,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=C,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=y)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==So.PE_TYPE_PROJCS)return;const e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();const s=e[0].getKind();e[0].getInclusive();const n=r.Envelope2D.constructEmpty(),m=e[0].getNump();let l=!1;if(s===So.PE_HORIZON_RECT){const s=e[0].getCoord();n.setFromPoints((0,h.aB)(s),2),t=new a.E({env2D:n})}else{let s=-1;for(let t=0;t<m;t++)e[t].getKind()===So.PE_HORIZON_POLY&&(s=t);(0,i.g)(s>=0);const n=e[s].getSize()-1,r=e[s].getCoord(),a=new o.P;t=a,a.addPathPoint2D((0,h.aB)(r),n,!0),l=!0}if(this.getPCSInfo().isDensificationNeeded()){(0,i.g)(s!==So.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new g.O).execute(t,e,0,0,null)}if(l){{const e=new a.E;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}(new sn).accelerateGeometry(t,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=t)}updatePannableExtent(){const e=this.m_peCoordSys.getType();if(e===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),s=e.getGeogcs();s||(0,i.d)("");const n=[t+1/s.getUnit().getUnitFactor()*Math.PI,0];Co.geogToProj(e,1,n);const o=n[0],a=e.getParameters()[So.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=r.Envelope2D.constructEmpty();h.queryEnvelope(m);const l=Math.abs(o-a),g=l+a,c=-1*l+a,u=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:c,ymin:_,xmax:g,ymax:u})}else if(e===So.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else(0,i.d)("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,s=e.getGeogcs();s||(0,i.d)("");const n=1/s.getUnit().getUnitFactor()*Math.PI,o=this.getGCSHorizon(),a=r.Envelope2D.constructEmpty();o.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:t-n,ymin:a.ymin,xmax:t+n,ymax:a.ymax})}else if(e===So.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else(0,i.d)("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=r.Envelope2D.construct(-e,-e,e,e)}else{(0,i.g)(2===this.m_csType);const e=vo.generate(this.m_peCoordSys,vo.PE_PCSINFO_OPTION_DOMAIN);e||(0,i.d)("generate pcs info failed");const t=new r.Envelope2D(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===So.PE_TYPE_PROJCS){const e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];Co.geogToProj(this.m_peCoordSys,2,t);const s=this.getPCSInfo().getNorthPoleLocation()!==vo.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==vo.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(t[0][0],t[0][1]),n&&this.m_southPole.setCoords(t[1][0],t[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===So.PE_TYPE_PROJCS){const e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=t,s[1]=0,s[2]=t+e,s[3]=0;const n=Co.geogToProj(this.m_peCoordSys,2,s);(0,i.g)(2===n);const r=(s[2]-s[0])/e,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(e){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),(0,h.k)(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){const t=[0],s=[0];(function(e,t,s,n){return t<=0?(s[0]=0,n[0]=0,!1):(s[0]=t,n[0]=t,!0)})(this.m_peCoordSys.getType(),this.m_WKID,t,s)||(0,i.d)("query_code_change"),e=t[0]}this.m_oldWKID=e}return e}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(e,t){return!1}static equal_for_projection(e,t){return!1}}class ai{constructor(e,t=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new Ti,this.m_cached=!1}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function hi(e,t,s){return mi(e,t,r.Envelope2D.constructEmpty())}function mi(e,t,s,n){return function(e,t,s,n){return Oi()||(0,i.n)("cannot create projection transformation"),t.hasVCS()&&s.hasVCS()?((0,i.g)(0),{}):function(e,t,s){e&&t||(0,i.a)("!inputSR || !outputSR");const n=e.getLatestID(),o=t.getLatestID();if(3857===n&&4326===o){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return bi()}else if(4326===n&&3857===o&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return Ii||(Ii=bi().getInverse()),Ii;const a=r.Envelope2D.constructEmpty();a.setCoords({env2D:s});const h=e.getCoordinateSystemType(),m=t.getCoordinateSystemType();if(0===h||0===m)return ui(e,t);const l=e.getGCS().getLatestID(),g=t.getGCS().getLatestID();if(l>0&&l===g)return ui(e,t);const c=new yi(e,t,s);{const e=function(e){if(Si.has(e.getHashCode()))return Si.get(e.getHashCode())}(c);if(e)return e}const u=gi(0,e,t,a,1,!0);return function(e,t){return Si.set(e.getHashCode(),t),t}(c,ui(e,t,u.length?u[0]:void 0))}(t,s,n)}(0,e,t,s)}function li(e,t,s,n){return function(e,t,s,n,r){return Oi()||(0,i.n)("cannot create projection transformation"),new di(2,t,s,n,r,void 0)}(0,e,t,s,n)}function gi(e,t,s,r,o,m=!1){if(t&&s||(0,i.a)(""),Oi()||(0,i.n)("cannot obtain geotransformation list"),1===e&&t.hasVCS()&&s.hasVCS())return(0,i.t)("hv xform not impl"),[];{const e=function(e,t,s,r,o){const m=e.getGCS(),l=t.getGCS(),g=m.getPECoordSys(),c=l.getPECoordSys();let u=null;if(!s.isEmpty()){const t=s.clone();if(!t.isEmpty()&&2===e.getCoordinateSystemType()){let s=new a.E({env2D:t});const n=li(e,m,null);s=(new cn).execute(s,n,null),s.queryEnvelope(t)}if(!t.isEmpty()){const e=g.getPrimem().getLongitude(),s=g.getUnit().getUnitFactor();u=new To(t.xmin,t.ymin,t.xmax,t.ymax,e,s)}}let _=r;_>=(0,h.i)()&&(_=0);const p=[];let d=bo.PE_GTLIST_OPTS_COMMON;o||(d&=~bo.PE_GTLIST_OPTS_USABLE);for(let e=0;e<2;e++){const e={stack:[],error:void 0,hasError:!1};try{p.length=0;const t=bo.getGTlist(g,c,2,d,u,_);if(null==t||0===t.length)break;(0,n.mS)(e,{[Symbol.dispose](){Go.destroy(t)}},!1);let s=!1;for(const e of t){const t=Ro(e);if((0,i.g)(t),o&&t.referencesMissingData())s=!0,_=0;else if(p.push(t),p.length===r)break}if(!s)break}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}return u&&u.destroy(),p}(t,s,r,o,m),l=[];for(const t of e)l.push(t);return l}}function ci(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return(0,h.Q)(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&(0,h.Q)(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function ui(e,t,s,n,r){return new di(1,e,t,s,n,r)}function _i(){return{m_extendedParams:ci(),m_extendedParamsInternal:{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return 0!==(this.flagsMask&e)}}}}function pi(){return _i()}class di{constructor(e,t,s,n,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,t&&s||(0,i.a)("!inputSR || !outputSR"),n&&0===n.getType()&&(n.m_bReadOnly=!0),this.m_bNormalize=!1,1!==e&&(a=t.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=t,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,(0,i.g)(!this.m_params),r&&(this.m_params=_i(),this.m_params.m_extendedParams=r),o&&(this.m_params||(this.m_params=_i()),this.m_params.m_extendedParamsInternal=o);let m=!1;const l=null!=n,g=t.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==g&&r){const e=r.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&s.isPannable()){const t=s.getPannableExtent(),n=t.getCenterX();if(n!==e){const s=Math.ceil(t.width());e+s!==n+s&&(m=!0)}}}const u=r&&r.normalizeResultGeometry;if(t.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const _=!l&&t.equalForProjection(s,this.m_bVertical);this.m_bIdentity=_&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==g&&0!==c&&(u&&this.m_outputSR.isPannable()&&(this.m_bNormalize=u),this.m_datumTran=n||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 e=new di(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return e.m_bIdentity=this.m_bIdentity,e.m_bVertical=this.m_bVertical,e.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,e.updateProjector(),e}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:pi().m_extendedParams}equals(e){return(0,i.g)(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return(0,i.g)(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:pi().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:pi().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new mn(this)}}const fi=new Map,xi=new Map,Pi=new Map;function Ei(e){let t=e.getCode();if(t>0)return Ni(t)||wi(yo.coordsys(t));const s=e.getName();if(xi.has(s)){const t=xi.get(s);if(t&&t.deref()){const s=t.deref();if(s.m_peCoordSys.isEqual(e))return s}}return t=yo.getCode(e),wi(t>0?yo.coordsys(t):e)}class yi{constructor(e,t,s){this.m_hashCode=-1,e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=(0,h.at)(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aJ)(this.m_env.xmin)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aJ)(this.m_env.xmax)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aJ)(this.m_env.ymin)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aJ)(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return!(this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR)&&this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR)}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const Si=new Map;let Ci,Ii,vi;function bi(){return Ci||(Ci=li(ao(),mo())),Ci}const Gi=new Map;function wi(e){const t=Do(e),s=e.getCode();if(s>0){const e=Ni(s);if(e)return e}const n=e.getName();let r=xi.get(n);if(r){const t=r.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}const i=new oi(t.release());if(s>0)return i.setCached(),fi.set(s,new WeakRef(i)),xi.set(n,new WeakRef(i)),i;const o=_r(e,0,!1);if(r=Pi.get(o),r){const e=r.deref();if(e)return e}return i.setCached(),Pi.set(o,new WeakRef(i)),i}function Ni(e){const t=fi.get(e);if(t)return t.deref()}class Ti extends d{constructor(e){return void 0===e?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof e?(super(),this.m_factor=e,void(this.m_wkid=0)):(super(e),void(e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=(vi||(vi=yo.unit(9001)),vi))))}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const Di=["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 Vi(e,t,s,n,r){(0,i.g)(n>>5<r.length);let o=t,a=s;for(let t=n;t>=0;t-=2){const s=31&t,n=.5*(a+o);e>=n?(r[t>>5]|=1<<s,o=n):a=n}}let ki=new Set;const Fi=2147483645n,Hi=9007199254740990n,Ai="operation is not supported for unknown coordinate systems";var Mi;function Ui(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function qi(e){!function(e){Vo=e,(0,i.g)(Vo)}(e)}function Oi(){return!!yo}function Yi(){return!!Vo}function Bi(){return!!yo||!!Vo}function Ri(e,t,s){return(0,i.g)(Bi()),_o(e,void 0===t?0:t,0,!1)}function Xi(e,t){(0,i.g)(Bi());const s=new io;let n;return Oi()?(n=function(e){const t=Do(yo.fromString(So.PE_TYPE_COORDSYS,e));return t.get()||(0,i.C)(e),Ei(t.release())}(e),s.setHorzProj_(n),s.m_vertcs=null,s.m_userWKID=n.getLatestID()):(n=ko(e),s.m_unit=n.isPCS?new Ti(n.metersOrRadiansPerUnit):new x(n.metersOrRadiansPerUnit)),go(s.m_precisionDescriptor,n,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=e,s.calculateHashCode(),s.initDbgName(),s}function Li(e,t,s,n,r=!0){let o=null;return t&&((0,i.g)(0),o={}),function(e,t,s,n,r){e||(0,i.a)("!PE_coord_sys");const o=new io;let a;return a=r?Ei(e):new oi(e,!1),go(o.m_precisionDescriptor,a,t,n),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=t,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}(e,o,0,n,r)}function zi(e,t,s=!1){3===e.getCoordinateSystemType()&&(0,i.a)("image spatial reference cannot be altered");const n=new io,r=e;return n.m_peCoordSysVal=r.m_peCoordSysVal,n.m_vertcs=r.m_vertcs,n.m_unit=r.m_unit,n.m_precisionDescriptor.assign(t),n.m_localZToXYFactor=r.m_localZToXYFactor,(Number.isNaN(n.m_precisionDescriptor.m_falseX)||Number.isNaN(n.m_precisionDescriptor.m_falseY))&&(n.m_precisionDescriptor.m_falseX=r.m_precisionDescriptor.m_falseX,n.m_precisionDescriptor.m_falseY=r.m_precisionDescriptor.m_falseY),n.m_precisionDescriptor.snapPrecision(),n.m_precisionDescriptor.fixTolerance(),n.m_userWKID=r.m_userWKID,n.m_precisionDescriptor.equals(r.m_precisionDescriptor)?n.m_bDefaultDescriptor=r.m_bDefaultDescriptor:n.m_bDefaultDescriptor=!1,s&&(n.m_bDefaultDescriptor=!0),n.calculateHashCode(),n.initDbgName(),n}function Wi(e,t,s){void 0===t&&(t=1),(t<=0||!Number.isFinite(t))&&(0,i.a)(""),e||1===t||(0,i.a)("null Unit has to have z_to_xy_factor equal to 1");const n=new io;n.m_unit=e;const r=e||new Ti(9001);return uo(n.m_precisionDescriptor,r,null,1),n.m_bDefaultDescriptor=!0,Number.isNaN(n.m_precisionDescriptor.m_falseX)&&(0,i.a)("NAN false X/Y are not allowed here"),n.m_localZToXYFactor=t,n.calculateHashCode(),n.initDbgName(),n}function ji(e){const t=e.getCoordinateSystemType();return 1===t?e:(3===t&&(0,i.g)(0),e.getGCS())}function Zi(e){return(0,i.g)(Bi()),Yi()?function(e){return(0,i.g)(Yi()),!!Vo(e).isPCS||function(e){return yo&&(0,i.q)("pe has been loaded. no-pe methods should not be used at this point."),fo||Ho(),fo.has(e)}(e)}(e):function(e){if(Gi.has(e))return Gi.get(e);{const t=function(e){return null!==Do(yo.coordsys(e)).get()}(e);return Gi.set(e,t),t}}(e)}function Ki(e){if(Oi()){const t={stack:[],error:void 0,hasError:!1};try{return null!==(0,n.mS)(t,yo.fromString(So.PE_TYPE_COORDSYS,e,!0),!1)}catch(e){t.error=e,t.hasError=!0}finally{(0,n.hk)(t)}}try{return ko(e),!0}catch(e){}return!1}let Qi;function Ji(){return Qi||(Qi=(()=>{const e=Math.trunc(Math.random()*(0,h.i)()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})()),Qi}!function(e){e[e.utmDefault=0]="utmDefault",e[e.utmNorthSouth=1]="utmNorthSouth"}(Mi||(Mi={}));let $i=0;function eo(e=""){let t=`${Ji()}${$i++}`;return""!==e&&(t+=`|${e}`),t}function to(e){return e.startsWith(Ji())}let so,no,ro,io=class e{destroy(){(function(e){xi.delete(e.m_peCoordSys.getName()),Pi.delete(_r(e.m_peCoordSys,0,!1))})(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():(0,i.d)("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 oo,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,lo(this.m_precisionDescriptor),ki&&ki.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ri(this.m_userWKID):Xi(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(1===this.getCoordinateSystemType())return li(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;const s=this.getGCS();t=e?li(this,s,null):li(s,this,null);const n=t;return(e?this.m_srToGcs:this.m_gcsToSr)||(e?this.m_srToGcs=n:this.m_gcsToSr=n,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal();const t=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();e=(0,h.at)(e,t),this.m_hashCode=(0,h.at)(e,s)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType()?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const e=this.getPECoordSys();if(e)switch(e.getType()){case So.PE_TYPE_GEOGCS:return 1;case So.PE_TYPE_PROJCS:return 2;default:return 0}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Ti)return 2;if(this.m_unit instanceof x)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,i.t)("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return(0,i.t)("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){const e=this.getPECoordSys();return e?pr(e):this.m_userWKT??""}getTextExtended(e){const t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?(this.getPEVerticalCoordSys(),(0,i.g)(0),""):pr(t,e):this.m_userWKT??""}getText2(e=-1){const t=this.getPECoordSys();return t?function(e,t){(t>1||t<-1)&&(0,i.a)("verbosity");let s=So.PE_STR_FMT_WKT2;return-1!==t&&(s|=0===t?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL),e.toString(s)}(t,e):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof Ti?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof x?.001/(ko(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):((0,i.q)("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?((0,i.g)(0),""):""}getVerticalUnit(){return(0,i.t)("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)(0,i.q)(Ai);else{if(1===e)return this;3===e&&(0,i.q)("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===ao()||this===ho())t=mo();else{(0,i.g)(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||(0,i.d)(""),t=Li(e,this.m_vertcs,0,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?t=this.m_geogSpatialReference:this.m_geogSpatialReference=t,t}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(0===e.length)return 0;e.length>t.length&&(0,i.a)("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&(0,i.q)(Ai),1===s)return(0,h.aw)(t,e,e.length),e.length;(0,i.g)(this.m_peCoordSysVal);const n=this.getSRToGCSTransform();return(new cn).transform(n,e,e.length,t)}toGeohash(e,t=8){const s=e.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=(0,h.l)(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=(0,h.l)(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*t,r=new Uint32Array(4);return Vi(s.x,-180,180,n-1,r),Vi(s.y,-90,90,n-2,r),function(e,t,s){const n=(0,h.d)(t,"R");let r=0,i=0;for(let s=0;s<t;s++){let o=e[r]>>i&31;if(i+=5,i>31){const t=37-i;o&=(1<<t)-1,i-=32,r++,o|=(e[r]&(1<<i)-1)<<t}const a=Di[o];n[t-1-s]=a}return s>t?n.push(..."0".repeat(s-t)):s<t&&(n.length=s),n.join("")}(r,t,t)}isPannable(){const e=this.getCoordinateSystemType();return 0!==e&&3!==e&&((0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||(0,i.a)("!is_pannable"),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||(0,i.a)("!is_pannable"),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const e=this.getCoordinateSystemType();1!==e&&2!==e&&(0,i.a)("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX))if(Oi()||(0,i.n)("cannot query precision descriptor"),(0,i.g)(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{const t=this.getCoordinateSystemType();0===t?uo(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===t?(0,i.t)("image cs"):go(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}horizontalEqual(e){return function(e,t){return e===t||null!==e&&null!==t&&e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID)}(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return null!==this.m_vertcs==(null!==e.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs))}equals(e){const t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t))return!1;if(!t.m_peCoordSysVal){if((0,i.g)(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==t.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(t.m_unit))return!1;if(this.m_localZToXYFactor!==t.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;(0,i.g)(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){const t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,s=t.ymin}let n=t.m_precisionDescriptor.m_falseX,r=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(n)){const e=t.m_peCoordSysVal.getDomainXY();n=e.xmin,r=e.ymin}return e===n&&s===r}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;const s=this.getCoordinateSystemType(),n=e.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!t||this.getZToXYFactor()===e.getZToXYFactor())&&(!this.getUnit()||!e.getUnit()||this.getUnit().equals(e.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===e.getUnit()||(!t||this.getZToXYFactor()===e.getZToXYFactor())&&this.getUnit().equals(e.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(e);if(function(e,t){return e===t||null!==e&&null!==t&&e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?1===e.m_csType?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID)}(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(null!==this.m_vertcs==(null!==e.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return(0,i.g)(0),!1}equalVerticalVCS(e){return(0,i.g)(0),!1}convergenceAngle(e){return(0,i.g)(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||(0,i.d)("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return(0,i.g)(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&(0,i.a)(Ai)}getPrimeMeridian(){return this.throwIfLocal(),(0,i.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,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const e=new oo;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=zi(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();!function(e,t,s){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-s),e.e2=s*(2-s),e.flattening=s}(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&(0,i.q)(""),(0,i.g)(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.getAreaOfUse();return null===e?new p:new p({geom:e.clone(),sr:Ri(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const t=e.getGeometryType();if((0,i.i)(t))return this.snapMultiVertex_(e);if(t===i.G.enumPoint)return this.snapPoint_(e);if(t===i.G.enumEnvelope)return this.snapEnvelope_(e);if((0,i.f)(t))return this.snapSegment_(e);if(t===i.G.enumGeometryCollection){const t=e;let s=!1;for(let e=0,n=t.getGeometryCount();e<n;++e)s=this.snapGeometry(t.getGeometry(e))||s;return s}(0,i.d)("what else?")}snapMultiVertex_(e){if((0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision()),(0,i.h)(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const t=e.getImpl(),s=t.getDescription();let n=!1;for(let e=0,r=s.getAttributeCount();e<r;e++){const r=s.getSemantics(e),i=t.getAttributeStreamRef(r);n=this.snapAttributes(r,i,0,t.getPointCount())||n}return n&&t.notifyModifiedFlags(2001),n}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){(0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision());const t=new oo;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new h.P;n.x=po(s.x,t.getFalseX(),t.getGridUnitsXY()),n.y=po(s.y,t.getFalseY(),t.getGridUnitsXY());let r=!n.equals(s);const o=e.getEndXY(),a=new h.P;a.x=po(o.x,t.getFalseX(),t.getGridUnitsXY()),a.y=po(o.y,t.getFalseY(),t.getGridUnitsXY()),r||=!a.equals(o),r&&e.changeEndPoints2D(n,a);const m=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=po(i,s,n),a=!(0,h.Q)(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=po(i,s,n),a=!(0,h.Q)(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let l=r?1:0;return e.hasAttribute(1)&&(l|=m(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(l|=m(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!l}snapGeometryWithCurves_(e){(0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new o.S;let n=0;for(let r=0,i=e.getPathCount();r<i;++r){const i=e.getSegmentCountPath(r);if(0===i){if(t.addPath(e,r,!0),1===t.getPathSize(r)){const e=new a.P;t.getPointByVal(t.getPointCount()-1,e),n|=this.snapGeometry(e)?1:0,t.setPointByVal(t.getPointCount()-1,e)}continue}const o=e.isClosedPath(r);for(let a=0,h=o?i-1:i;a<h;++a)e.getSegmentFromPath(r,a,s,!1),n|=this.snapGeometry(s.get())?1:0,t.addSegment(s.get(),0===a);o&&(e.getSegmentFromPath(r,i-1,s,!1),n|=this.snapGeometry(s.get())?1:0,1===i?t.addPathFromClosedSegment(s.get(),!1):t.closeLastPathWithSegment(s.get()))}return n&&t.copyTo(e),!!n}snapAttributes(t,s,n,r){let i=!1;const o=new oo;if(this.queryPrecisionDescriptor(o),0===t){const t=s;for(let s=n;s<r;s++){const n=t.read(2*s),r=e.s_SnapValue(n,o.getFalseX(),o.getGridUnitsXY()),a=t.read(2*s+1),h=e.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());i=i||r!==n||h!==a,i&&(t.write(2*s,r),t.write(2*s+1,h))}}else if(1===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseZ(),o.getGridUnitsZ());i=i||!(0,h.Q)(r,n),i&&t.write(s,r)}}else if(2===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseM(),o.getGridUnitsM());i=i||!(0,h.Q)(r,n),i&&t.write(s,r)}}return i}static s_SnapValue(e,t,s){return(0,h.ax)((e-t)*s)/s+t}};class oo{constructor(){const e=Hi,t=1e-4,s=.001,n=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(e)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let e=7777,t=7777;return t=(0,h.at)(t,this.m_falseM),t=(0,h.at)(t,this.m_unitsM),e=(0,h.at)(e,this.m_unitsXY),t=(0,h.at)(t,this.m_toleranceXY),e=(0,h.at)(e,this.m_falseZ),t=(0,h.at)(t,this.m_toleranceZ),e=(0,h.at)(e,this.m_unitsZ),t=(0,h.at)(t,this.m_toleranceM),e=(0,h.at)(e,this.m_precision),(0,h.at)(e,t)}clone(){const e=new oo;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(2===this.m_precision)return 0;switch(e){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 e=new r.Envelope2D;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 2:e.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:e.setEmpty(),(0,i.d)("")}return e}getZGridRange(){const e=new h.E;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),(0,i.d)("")}return e}getMGridRange(){const e=new h.E;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),(0,i.d)("")}return e}setTolerance(e,t){switch(t<0&&(0,i.a)("tol < 0"),Number.isFinite(t)||(0,i.a)("tol is not finite"),e){case 0:this.m_toleranceXY=t;break;case 1:this.m_toleranceZ=t;break;case 2:this.m_toleranceM=t;break;default:(0,i.a)("cannot set tolerance for this attribute")}}setGridParams(e,t,s){Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(s)||(0,i.a)("grid params are not finite"),s<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=s}setZParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||(0,i.a)("grid params are not finite"),t<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseZ=e,this.m_unitsZ=t}setMParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||(0,i.a)("grid params are not finite"),t<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||(0,h.Q)(this.m_falseX,e.m_falseX)&&(0,h.Q)(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(2===this.m_precision)return;const e=(e,t,s,n)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const r=Number(e)/s;return Math.trunc((t+r-t)*s)>e&&(s=e/(t+r-t)),Math.max(1,s)},t=Number(0===this.m_precision?Fi:Hi);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const e=(e,t,s,n)=>{if(s<1)return!1;if(!Number.isFinite(t)||!Number.isFinite(s))return!1;if(!n)return!0;const r=Number(e)/s;return!(BigInt((t+r-t)*s)>e)},t=0===this.m_precision?Fi:Hi;return!!(e(t,this.m_falseX,this.m_unitsXY,!0)&&e(t,this.m_falseY,this.m_unitsXY,!0)&&e(t,this.m_falseZ,this.m_unitsZ,!1)&&e(t,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(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,s){}setBestMDomainFromMRange(e,t,s){}}function ao(){return(!so||Oi()&&null===so.getPECoordSys())&&(so=_o(3857,0,0,!0)),so}function ho(){return(!no||Oi()&&null===no.getPECoordSys())&&(no=_o(102100,0,0,!0)),no}function mo(){return(!ro||Oi()&&null===ro.getPECoordSys())&&(ro=_o(4326,0,0,!0)),ro}function lo(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=100*(0,h.O)(),e.m_toleranceZ=100*(0,h.O)(),e.m_toleranceM=100*(0,h.O)(),e.m_precision=2}function go(e,t,s,n){const r=t instanceof oi;lo(e),e.m_precision=n,e.m_falseX=Number.NaN,e.m_falseY=Number.NaN;const o=1e-4,a=.001,h=r?t.m_csType:t.isPCS?2:1;if(1===h){const s=(0===n?1/18e5:1e-9)*(r?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180);e.m_unitsXY=1/s}else if(2===h){const s=(0===n?a:o)*(r?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit);e.m_unitsXY=1/s}else(0,i.a)("unrecognized cs type");e.m_falseM=-1e5,e.m_unitsM=1/(0===n?a:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let m=0,l=0;0!==n&&1!==n||(m=2/e.m_unitsXY,l=2/e.m_unitsM),e.m_toleranceXY=Math.max(m,r?t.getUnitsPerMillimeter():2===h?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(a,l),co(e,s)}function co(e,t){const s=1e-4,n=.001;if(e.m_falseZ=-1e5,t){const r=(0===e.m_precision?n:s)*t.getOneMeter();e.m_unitsZ=1/r}else e.m_unitsZ=1/(0===e.m_precision?n:s);e.m_unitsZ=Math.max(1,e.m_unitsZ);let r=0;0!==e.m_precision&&1!==e.m_precision||(r=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*n:n,r)}function uo(e,t,s,n){lo(e),e.m_precision=n;const r=0===n?Fi:Hi,i=1e-4,o=.001;let a=1,h=1,m=.001;t&&(h=t.getUnitToBaseFactor()),t&&1===t.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===n?o:i)*Number(r)*.5,m=o/h),a/=h,e.m_falseX=-a,e.m_falseY=-a,e.m_unitsXY=Number(r)/(2*a),e.m_falseM=-1e5,e.m_unitsM=1/(0===n?o:i),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let l=0,g=0;0!==e.m_precision&&1!==e.m_precision||(g=2/e.m_unitsM,l=2/e.m_unitsXY),e.m_toleranceXY=Math.max(l,m),e.m_toleranceM=Math.max(o,g),co(e,s)}function _o(e,t,s,n){if(!n&&t<=0){if(3857===e)return ao();if(102100===e)return ho();if(4326===e)return mo()}const r=new io;let o,a=null;return Oi()?(o=function(e){e<=0&&(0,i.D)(e);{const t=Ni(e);if(t)return t}const t=Do(yo.coordsys(e));t.get()||(0,i.D)(e);const s=wi(t.release());return s.getLatestID()!==e&&fi.set(e,new WeakRef(s)),s}(e),t>0?a=null:t=0,r.setHorzProj_(o),r.m_vertcs=a):(o=ko(e),r.m_unit=o.isPCS?new Ti(o.metersOrRadiansPerUnit):new x(o.metersOrRadiansPerUnit)),go(r.m_precisionDescriptor,o,a,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=e,r.calculateHashCode(),r.initDbgName(),r}function po(e,t,s){return(0,h.ax)((e-t)*s)/s+t}let fo=null;const xo=3552713678800501e-30;function Po(e,t){return function(e,t,s){return e===t||Math.abs(e-t)<=s*(1+(Math.abs(e)+Math.abs(t))/2)}(e,t,xo)}let Eo,yo,So,Co,Io,vo,bo,Go,wo,No,To;function Do(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){const e=this._this;return this._this=null,e}}}let Vo=null;function ko(e){(0,i.g)(Vo);const t=Vo(e);return t.semiMajor=t.isPCS?Number.NaN:function(e){if(yo&&(0,i.q)("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof e){const t=e.match(Fo);t&&2===t.length||(0,i.a)("bad gcs wkt");const s=Number.parseFloat(t[1]);return Number.isFinite(s)||(0,i.a)("bad gcs wkt"),s}return fo||Ho(),fo.has(e)||(0,i.q)("gcs wkid not found"),fo.get(e)}(e),t}const Fo=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Ho(){fo=new Map;for(const e in f){const t=Number.parseFloat(e),s=f[e];if(Array.isArray(s))for(const e of s)fo.set(e,t);else fo.set(s,t)}!function(){for(const e in f)delete f[e]}()}function Ao(e,t){const s=yo.geogtran(e);return s||(0,i.D)(e),new Yo(s,t)}function Mo(e,t){const s=yo.fromString(So.PE_TYPE_GEOGTRAN,e);return s||(0,i.C)(e),new Yo(s,t)}function Uo(e,t){return new Yo(e,t)}const qo=(0,h.au)(0),Oo=(0,h.au)(1);class Yo{constructor(e,t){if(e instanceof Yo)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=(0,h.at)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Oo:qo));this.m_geogTranWrapper=new Jn(e),this.m_bInverted=t,this.m_hashCode=(0,h.at)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Oo:qo)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===e)return this.m_geogTranWrapper.getGeogtran().toString();{const t=0===e?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=So.PE_STR_FMT_WKT2;return-1!==e&&(t|=0===e?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(t)}getName(){return this.m_geogTranWrapper&&this.m_geogTranWrapper.getGeogtran()?this.m_geogTranWrapper.getGeogtran().getName():""}getInputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getOutputSr(!1):this.m_geogTranWrapper.getInputSr(!1)}getOutputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getInputSr(!1):this.m_geogTranWrapper.getOutputSr(!1)}getInverse(){return new Yo(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){const t=e;return t===this||this.m_bInverted===t.m_bInverted&&(this.GetPeGeogtran()===t.GetPeGeogtran()||this.getID()===t.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Bo(){return new Xo([],null,null,null)}function Ro(e){const t=new Lo,s=e.getSteps();if(s){const n=e.getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection();let r;const i=n[e].getGeogtran().getCode();if(i>=0)r=yo.geogtran(i);else{const t=n[e].getGeogtran().toString(So.PE_STR_FMT_WKT);r=yo.fromString(So.PE_TYPE_GEOGTRAN,t)}if(null==r)return null;const o=Uo(r,s);t.add(o)}return t.create()}return null}class Xo{constructor(e,t,s,n){this.m_bReadOnly=!0,this.m_name="",this.m_fastTrack=-1,this.m_bNameIsSet=!1,this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=s,this.m_outputSr=n}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=(0,h.at)(e,this.m_transforms[t].getHashCode());return e}equals(e){return(0,i.g)(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return(0,i.g)(0),!1}validateTransformation(e,t){return(0,i.g)(0),!1}nameIsSet(){return(0,i.g)(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&(0,i.r)(""),this.m_transforms[e]}getInverse(){const e=new Lo;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,s){if(0===this.count())return;let n=this.m_inputSr,r=this.m_outputSr;if(e&&(r=(0,h.c)(n,n=r)),0===this.m_transforms.length)return void $n(n,null,r,null,t,null,s);let i=this.m_fastTrack;if(1===i)return void(0,o.a9)(e,this.m_transforms,n=>{!function(e,t,s,n,r){const i=e.getVerttran(),o=e.getGeogtran();if(r>0){e.prepareOrThrow();const n=t?So.PE_TRANSFORM_2_TO_1:So.PE_TRANSFORM_1_TO_2;i?Kr():Qr(o,r,s,null,n)}}(n.getWrapper(),e!==n.isInverted(),t,0,s)});const a=Qn();-1===i&&a.initFromGcsAndVcs(n,null);const m=Qn();let l=e?this.m_transforms.length-1:0;const g=e?-1:1;for(let r=0,o=this.m_transforms.length;r<o;r++,l+=g){if(0===r){const r=this.m_transforms[l];er(n.getPECoordSys(),null,r.getWrapper(),e!==r.isInverted(),t,null,s,m),-1===i&&(a.equals(m)||(i=0)),a.assign(m)}else{const n=this.m_transforms[l-g],r=this.m_transforms[l];tr(a,n.getWrapper(),e!==n.isInverted(),r.getWrapper(),e!==r.isInverted(),t,null,s,m),-1===i&&(a.equals(m)||(i=0)),a.assign(m)}const o=this.m_transforms[l];sr(a,o.getWrapper(),e!==o.isInverted(),t,null,s,m),a.assign(m)}const c=this.m_transforms[l-g];(function(e,t,s,n,r,i,o,a){const h=Qn();h.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),h.processUnitParams(e);let m=null;n&&(m=n.getPECoordSys());const l=Qn();l.initFromGcsAndVcsPe(m,null),l.processUnitParams(h),h.processUnitParams(l),a>0&&Kn(h,l,i,null,a)})(a,c.getWrapper(),e!==c.isInverted(),r,0,t,0,s),-1===i&&(m.initFromGcsAndVcs(r,null),a.equals(m)||(i=0)),this.m_fastTrack=0===i?0:1}}class Lo{constructor(){this.m_transforms=[],this.m_inputGCS=null,this.m_outputGCS=null,this.m_name="",this.m_bNameIsSet=!1}getInputSpatialReference(){return null!==this.m_inputGCS?this.m_inputGCS:this.count()>0?this.m_transforms[0].getInputSpatialReference():null}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&(0,i.r)(""),this.m_transforms[e]}setStep(e,t){(0,i.g)(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let t=e.count()-1;t>=0;--t)this.add(e.getStep(t).getInverse());else for(let t=0;t<e.count();++t)this.add(e.getStep(t))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){(0,i.g)(0)}create(){const e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),s=new Xo(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return s.m_bReadOnly=!0,this.clear(),s}}const zo=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:io,SpatialReferencePrecisionDescriptor:oo,create:Ri,createFromWKT:Xi,createImplFromPe:Li,createLocal:Wi,createWithNewPrecision:zi,createWithNewVCS:function(e,t,s){return{}},getGCS:ji,getTempName:eo,hasNoPe:Yi,hasPe:Oi,injectNoPe:qi,injectPe:function(e){if(yo)return;!function(e){const t=e;yo=t.PeFactory,(0,i.g)(yo),To=t.PeGCSExtent,(0,i.g)(To),wo=t.PeLineType,(0,i.g)(wo),No=t.PeMath,(0,i.g)(No),Eo=t.PeDouble,(0,i.g)(Eo),So=t.PeDefs,(0,i.g)(So),Co=t.PeCSTransformations,(0,i.g)(Co),Io=t.PeGTTransformations,(0,i.g)(Io),vo=t.PePCSInfo,(0,i.g)(vo),bo=t.PeGTlistExtended,(0,i.g)(bo),yo.initialize(),Go=t.PeGTlistExtendedEntry,(0,i.g)(Go),So.PE_TYPE_ANGUNIT=512,So.PE_STR_AUTH_ALL=2,vo.PE_POLE_LINE_STRAIGHT=2,vo.PE_POLE_LINE_CURVED=3,So.PE_PARM_LAM0=2,So.PE_PARM_PHI0=6,So.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,So.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,So.PE_PRJ_ALBERS=43007,So.PE_PRJ_CYLINDRICAL_EQAREA=43034,So.PE_TYPE_VERTCS=8,So.PE_LINETYPE_GEODESIC=0,So.PE_LINETYPE_LOXODROME=1,So.PE_LINETYPE_GREAT_ELLIPTIC=2,So.PE_LINETYPE_NORMAL_SECTION=3,bo.PE_GTLIST_OPTS_USABLE=1,Vo=null}(e);const t=ki;ki=null,t.forEach(e=>{const t=e.deref();t&&t.attachToPe()})},isInitialized:Bi,isTempName:to,isValidWkid:Zi,isValidWkt:Ki,makeSpheroidData:Ui,snapGeometry:function(e,t){return e.snapGeometry(t)},webMercator:ao,webMercator102100:ho,wgs84:mo},Symbol.toStringTag,{value:"Module"}))}}]);
|
|
1
|
+
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4383,5756],{31139(e,t,s){s.d(t,{O:()=>u,a:()=>g,c:()=>m});var n=s(61691),r=s(55537),i=s(95213),o=s(79187),a=s(88885),h=s(83661);function m(e,t,s,n,r){return l(e,t,null,s,n,r)}function l(e,t,s,n,a,h){const l=e.getGeometryType();if(l===r.G.enumPoint){const s=e.getXY();return t.contains(s)?e:e.createInstance()}if(l===r.G.enumEnvelope){const s=o.Envelope2D.constructEmpty();if(e.queryEnvelope(s),s.intersect(t)){const t=e.clone();return t.setEnvelope(s),t}return e.createInstance()}if(e.isEmpty())return e;if(t.isEmpty())return e.createInstance();const g=t.clone();{const t=new o.Envelope2D;if(e.queryLooseEnvelope(t),g.containsEnvelope(t))return e;if(!g.isIntersecting(t))return e.createInstance();0===a&&(t.intersect(g),t.inflate(Math.max(.1*t.maxDimension(),1)),t.intersect(g),g.assign(t))}let u=n;if((null!==s||Number.isNaN(u))&&(u=(0,i.c)(s,g,!1).total()),l===r.G.enumGeometryCollection){const t=e,s=e.createInstance();for(let e=0,n=t.getGeometryCount();e<n;e++){const n=t.getGeometry(e);if(n.isEmpty())continue;const r=m(n,g,u,a,h);r.isEmpty()||(r===n?s.addGeometry(r.clone()):s.addGeometry(r))}return s}(0,r.i)(l)||(0,r.a)("Clip: geometry not supported");const _=e.getImpl().getAccelerators();if(null!==_){const e=_.getRasterizedGeometry();(0,r.g)(null===e)}switch(l){case r.G.enumMultiPoint:{const t=e;let s;const n=t.getPointCount(),i=t.getImpl().getAttributeStreamRef(0);let o=0;for(let e=0;e<n;e++){const n=i.readPoint2D(2*e);g.contains(n)||(0===o&&(s=t.createInstance()),o<e&&s.addPoints(t,o,e),o=e+1)}return o>0&&s.addPoints(t,o,n),0===o?t:((0,r.g)(null!==s),s)}case r.G.enumPolygon:case r.G.enumPolyline:return function(e,t,s,n,r){return new c(t,r).clipMultiPath2(e,s,n)}(e,g,u,a,h);default:(0,r.d)("")}}function g(e,t,s,n,r,i){const a=new c(t,i),h=new o.Envelope2D;return e.queryLooseEnvelope(h),t.containsEnvelope(h)?e:t.isIntersecting(h)?a.clipPolesOut(e,r):e.createInstance()}class c{constructor(e,t){this.m_shape=new a.E,this.m_geometry=a.n,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new o.Envelope2D(e),this.m_progressTracker=t}progress_(){}clipMultiPath2(e,t,s){return e.getGeometryType()===r.G.enumPolygon?this.clipPolygonOrProjectedPolyline2(e,s):this.clipPolyline(e,t)}clipPolygonOrProjectedPolyline2(e,t){const s=e.getGeometryType()===r.G.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return e.createInstance();const n=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(n),this.m_geometry=s?this.m_shape.addGeometry(e):this.m_shape.addGeometry(e,this.m_extent);const i=o.Envelope2D.constructEmpty(),m=o.Envelope2D.constructEmpty(),l=new h.P,g=new h.P,u=(0,h.d)(9,Number.NaN),_=(0,h.d)(9,Number.NaN),p=(0,h.m)(h.P,9);let d=null;const f=new a.L,x=[];let P=!1;for(let e=0;!P&&e<4;e++){let t=!1;const o=!!(1&e);let h=0;switch(e){case 0:h=this.m_extent.xmin,t=n.xmin<=h&&n.xmax>=h;break;case 1:h=this.m_extent.ymin,t=n.ymin<=h&&n.ymax>=h;break;case 2:h=this.m_extent.xmax,t=n.xmin<=h&&n.xmax>=h;break;case 3:h=this.m_extent.ymax,t=n.ymin<=h&&n.ymax>=h}if(t){P=!0;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;){let n=!0,E=-1,y=-1;const S=this.m_shape.getFirstVertex(t);let C=S;do{this.progress_(),d=this.m_shape.getSegment(C);let t=d;if(null===t){const e=this.m_shape.getNextVertex(C);if(e===a.n){(0,r.g)(s),0===E&&x.push(C);break}this.m_shape.queryXY(C,l),f.setStartXY(l),this.m_shape.queryXY(e,g),f.setEndXY(g),t=f}t.queryLooseEnvelope(i);let S=c.checkSegmentIntersection(i,e,h);t.isCurve()&&0===S&&t.isCurve()&&(f.setStartXY(t.getStartXY()),f.setEndXY(t.getEndXY()),this.m_shape.replaceCurveWithLine(C),t=f,f.queryEnvelope(i),S=c.checkSegmentIntersection(i,e,h));let I=0,v=a.n;if(-1===S){const s=t.intersectionWithAxis2D(o,h,u,_);if(s>0){let e=null;if(t.isCurve()){e=p,(0,r.g)(s<=9);for(let e=0;e<s;e++)o?p[e].setCoords(u[e],h):p[e].setCoords(h,u[e]);I=this.m_shape.splitSegmentAxisAware(C,_,s,e,o?1:0)}else I=this.m_shape.splitSegmentAxisAware(C,_,s,null,-1)}else I=0;I+=1;let i=C,a=this.m_shape.getNextVertex(i);t=null;for(let t=0;t<I;t++){this.m_shape.queryXY(i,l),this.m_shape.queryXY(a,g),d=this.m_shape.getSegment(i);let t=d;null===t&&(f.setStartXY(l),f.setEndXY(g),t=f),t.queryEnvelope(m);let s=c.checkSegmentIntersection(m,e,h);t.isCurve()&&0===s&&(this.m_shape.replaceCurveWithLine(i),f.setStartXY(l),f.setEndXY(g),t=f,t.queryEnvelope(m),s=c.checkSegmentIntersection(m,e,h)),-1===s&&(o?Math.abs(l.y-h)<Math.abs(g.y-h)?(l.y=h,this.m_shape.setXY(i,l)):(g.y=h,this.m_shape.setXY(a,g)):Math.abs(l.x-h)<Math.abs(g.x-h)?(l.x=h,this.m_shape.setXY(i,l)):(g.x=h,this.m_shape.setXY(a,g)),d=this.m_shape.getSegment(i),t=d,null===t&&(f.setStartXY(l),f.setEndXY(g),t=f),t.queryEnvelope(m),s=c.checkSegmentIntersection(m,e,h),-1===s&&(s=c.checkSegmentIntersectionLoose(m,e,h)));const r=E;E=s,-1===y&&(y=E),0===r&&1===E||1===r&&0===E||0===r&&0===E&&x.push(i),1===E&&(P=!1,n=!1),i=a,v=i,a=this.m_shape.getNextVertex(a)}}if(0===I){const e=E;E=S,-1===y&&(y=E),0===e&&E>=1||e>=1&&0===E||0===e&&0===E&&x.push(C),1===E&&(P=!1,n=!1),v=this.m_shape.getNextVertex(C)}if(C=v,x.length>=256){for(let e=1,t=x.length-1;e<t;e++){const t=x[e];s?this.m_shape.snapVertexForPoleClipping(t,h):this.m_shape.removeVertex(t,!1)}x[1]=x.at(-1),x.length=2}}while(C!==S);if(!n){0!==y||!s&&0!==E&&2!==E||x.push(S);for(let e=0,t=x.length;e<t;e++){const t=x[e];s?this.m_shape.snapVertexForPoleClipping(t,h):this.m_shape.removeVertex(t,!1)}}x.length=0,t=n||0===this.m_shape.getPathSize(t)?this.m_shape.removePath(t):this.m_shape.getNextPath(t)}}}if(P)return e.createInstance();d=null,s?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),t>0&&this.densifyAlongClipExtent(t);const E=this.m_shape.getGeometry(this.m_geometry);return E.getGeometryType()===r.G.enumPolygon&&E.setFillRule(e.getFillRule()),E}clipPolyline(e,t){const s=o.Envelope2D.constructEmpty(),n=o.Envelope2D.constructEmpty(),r=(0,h.d)(9,Number.NaN),i=(0,h.d)(9,Number.NaN),m=new a.S;let l=e;const g=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(g);for(let t=0;t<4;t++){let o=!1;const a=!!(1&t);let u=0;switch(t){case 0:u=this.m_extent.xmin,o=g.xmin<=u&&g.xmax>=u;break;case 1:u=this.m_extent.ymin,o=g.ymin<=u&&g.ymax>=u;break;case 2:u=this.m_extent.xmax,o=g.xmin<=u&&g.xmax>=u;break;case 3:u=this.m_extent.ymax,o=g.ymin<=u&&g.ymax>=u}if(!o)continue;const _=l;l=e.createInstance();const p=_.getImpl().querySegmentIterator();p.resetToFirstPath();const d=new h.P,f=new h.P;for(;p.nextPath();){let e=-1,o=!0;for(;p.hasNextSegment();){this.progress_();const h=p.nextSegment(),g=h.isDegenerate(0);h.queryLooseEnvelope(s);const _=c.checkSegmentIntersection(s,t,u);if(-1===_){const s=h.intersectionWithAxis2D(a,u,r,i);let _=0;d.assign(h.getStartXY());for(let p=0;p<=s;p++){const x=p<s?i[p]:1;if(_===x)continue;h.queryCut(_,x,m,!1);const P=m.get();let E=!1;if(P.getStartXY().equals(d)||(P.setStartXY(d),E=!0),p<s&&(a?(f.x=r[p],f.y=u):(f.x=u,f.y=r[p]),P.getEndXY().equals(f)||(P.setEndXY(f),E=!0)),E&&P.normalizeAfterEndpointChange(),!g&&P.isDegenerate(0))continue;P.queryEnvelope(n);let y=c.checkSegmentIntersection(n,t,u);if(-1===y){const e=P.getStartXY(),s=P.getEndXY();E=!1,a?Math.abs(e.y-u)<Math.abs(s.y-u)?(e.y=u,P.setStartXY(e),e.equals(P.getStartXY())||(P.setStartXY(e),E=!0)):(s.y=u,s.equals(P.getEndXY())||(P.setEndXY(s),E=!0)):Math.abs(e.x-u)<Math.abs(s.x-u)?(e.x=u,e.equals(P.getStartXY())||(P.setStartXY(e),E=!0)):(s.x=u,s.equals(P.getEndXY())||(P.setEndXY(s),E=!0)),E&&P.normalizeAfterEndpointChange(),P.queryEnvelope(n),y=c.checkSegmentIntersection(n,t,u),-1===y&&(y=c.checkSegmentIntersectionLoose(n,t,u))}d.assign(P.getEndXY()),_=x,e=y,e>=1?(l.addSegment(P,o),o=!1):o=!0}}else e=_,e>=1?(l.addSegment(h,o),o=!1):o=!0}}}return l}static checkSegmentIntersection(e,t,s){switch(t){case 0:return e.xmin<s&&e.xmax<=s?0:e.xmin>=s?e.xmax===s?2:1:-1;case 1:return e.ymin<s&&e.ymax<=s?0:e.ymin>=s?e.ymax===s?2:1:-1;case 2:return e.xmin>=s&&e.xmax>s?0:e.xmax<=s?e.xmin===s?2:1:-1;case 3:return e.ymin>=s&&e.ymax>s?0:e.ymax<=s?e.ymin===s?2:1:-1}return(0,r.d)(""),0}static checkSegmentIntersectionLoose(e,t,s){switch(t){case 0:{const t=Math.abs(e.xmin-s),n=Math.abs(e.xmax-s);return e.xmin<s?t>n?0:1:((0,r.d)(""),1)}case 1:{const t=Math.abs(e.ymin-s),n=Math.abs(e.ymax-s);return e.ymin<s?t>n?0:1:((0,r.d)(""),1)}case 2:{const t=Math.abs(e.xmin-s),n=Math.abs(e.xmax-s);return e.xmax>s?t<n?0:1:((0,r.d)(""),1)}case 3:{const t=Math.abs(e.ymin-s),n=Math.abs(e.ymax-s);return e.ymax>s?t<n?0:1:((0,r.d)(""),1)}}return(0,r.d)(""),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 e=new h.P;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let n=0,r=this.m_shape.getPathSize(t);n<r;n++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,e),this.m_extent.xmin!==e.x&&this.m_extent.xmax!==e.x&&this.m_extent.ymin!==e.y&&this.m_extent.ymax!==e.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(e){const t=new h.P(0,0),s=new h.P(0,0),n=(0,h.d)(2048,Number.NaN);for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==a.n;i=this.m_shape.getNextPath(i)){const o=this.m_shape.getFirstVertex(i);let a=o;do{const i=this.m_shape.getNextVertex(a);this.m_shape.queryXY(a,t);let o=-1;if(t.x===this.m_extent.xmin?(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmin&&(o=1)):t.x===this.m_extent.xmax&&(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmax&&(o=1)),t.y===this.m_extent.ymin?(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymin&&(o=0)):t.y===this.m_extent.ymax&&(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymax&&(o=0)),-1===o){a=i;continue}if(this.isCurve(a)){a=i;continue}const m=t.clone(),l=new h.P(0,0);if(o){const n=t.y-this.m_extent.ymin;l.y=(0,h.e)(s.y-t.y),m.y=e*(0,h.f)(Math.floor(Math.abs(n)/e),n)+this.m_extent.ymin,l.y<0&&(m.y+=e)}else{const n=t.x-this.m_extent.xmin;l.x=(0,h.e)(s.x-t.x),m.x=e*(0,h.f)(Math.floor(Math.abs(n)/e),n)+this.m_extent.xmin,l.x<0&&(m.x+=e)}const g=o?s.y-t.y:s.x-t.x,c=Math.abs(g);if(c/e>65536&&(0,r.d)(""),c>0){const s=Math.trunc(c/e)+2;n.length<s&&(n.length=s);let i=0;for(let s=0;;s++){const a=m.add(l.mul(s*e)),h=(o?a.y-t.y:a.x-t.x)/g;if(h>=1)break;h<=0||((0,r.g)(i<=n.length),n[i]=h,i++)}0!==i&&this.m_shape.splitSegment(a,n,i)}a=i}while(a!==o)}}splitSegments(e,t){let s=-1;const n=new h.P,r=[];for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==a.n;i=this.m_shape.getNextPath(i)){let o=this.m_shape.getFirstVertex(i),h=a.n;for(let a=0,m=this.m_shape.getPathSize(i);a<m;a++,o=h)if(this.progress_(),h=this.m_shape.getNextVertex(o),this.m_shape.queryXY(o,n),(e?n.y===t:n.x===t)&&(this.m_shape.queryXY(h,n),e?n.y===t:n.x===t)){if(this.isCurve(o))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(o,s)&&(r.push(o),this.m_shape.setUserIndex(o,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(r.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),r.length<3)return;r.sort((e,t)=>this.compareVertices(e,t));const i=new h.P,o=new h.P,m=new h.P;o.setNAN();let l=-1,g=[],c=[];const u=this.m_shape.createUserIndex(),_=this.m_shape.createUserIndex();for(let s=0,a=r.length;s<a;s++){const a=r[s];if(this.m_shape.queryXY(a,n),!n.isEqualPoint2D(o)){if(-1===l){l=s,o.setCoordsPoint2D(n);continue}for(let n=l;n<s;n++){const s=r[n],a=this.m_shape.getNextVertex(s),h=this.m_shape.getPrevVertex(s);let m=!1;this.m_shape.queryXY(a,i),o.compare(i)<0&&(e?i.y===t:i.x===t)&&(this.isCurve(s)||(g.push(s),m=!0,this.m_shape.setUserIndex(s,_,1))),this.m_shape.queryXY(h,i),o.compare(i)<0&&(e?i.y===t:i.x===t)&&(this.isCurve(h)||(m||g.push(s),this.m_shape.setUserIndex(s,u,1)))}for(let e=0,t=g.length;e<t;e++){const t=g[e],s=this.m_shape.getUserIndex(t,u),r=this.m_shape.getUserIndex(t,_);if(1===s){const e=this.m_shape.getPrevVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(n)){const r=h.P.distance(o,m);s=h.P.distance(m,n)/r,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const i=this.m_shape.getPrevVertex(t);this.m_shape.setXY(i,n),c.push(i),this.m_shape.setUserIndex(i,u,1),this.m_shape.setUserIndex(i,_,-1)}}if(1===r){const e=this.m_shape.getNextVertex(t);this.m_shape.queryXY(e,m);let s=0;if(!m.isEqualPoint2D(n)){const e=h.P.distance(o,m);s=h.P.distance(o,n)/e,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const r=this.m_shape.getNextVertex(t);this.m_shape.setXY(r,n),c.push(r),this.m_shape.setUserIndex(r,u,-1),this.m_shape.setUserIndex(r,_,1)}}}const a=g;g=c,c=a,c.length=0,l=s,o.setCoordsPoint2D(n)}}this.m_shape.removeUserIndex(u),this.m_shape.removeUserIndex(_)}resolveOverlaps(e,t){const s=new h.P,n=[];let i=-1;for(let r=0,o=this.m_verticesOnExtent.length;r<o;r++){this.progress_();const o=this.m_verticesOnExtent[r];if(o===a.n)continue;const h=this.m_shape.getNextVertex(o);if(this.m_shape.queryXY(o,s),(e?s.y===t:s.x===t)&&(this.m_shape.queryXY(h,s),e?s.y===t:s.x===t)){if(this.isCurve(o))continue;-1===i&&(i=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(o,i)&&(n.push(o),this.m_shape.setUserIndex(o,i,-2)),-2!==this.m_shape.getUserIndex(h,i)&&(n.push(h),this.m_shape.setUserIndex(h,i,-2))}}if(0===n.length)return void(-1!==i&&this.m_shape.removeUserIndex(i));(0,r.g)(-1!==i),n.sort((e,t)=>this.compareVertices(e,t));for(let e=0,t=n.length;e<t;e++){const t=n[e];this.m_shape.setUserIndex(t,i,e)}const o=new h.P,m=new h.P;m.setNAN();let l=-1;for(let r=0,h=n.length;r<h;r++){this.progress_();const h=n[r];if(h!==a.n&&(this.m_shape.queryXY(h,s),!s.isEqualPoint2D(m))){if(-1!==l)for(;;){let s=!1;const h=r;for(let g=l;g<h;g++){const h=n[g];if(h===a.n)continue;let l=a.n;const c=this.m_shape.getNextVertex(h);this.m_shape.queryXY(c,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(h)||(l=c));let u=a.n;const _=this.m_shape.getPrevVertex(h);if(this.m_shape.queryXY(_,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(_)||(u=_)),l===a.n||u===a.n){if(l!==a.n||u!==a.n){for(let c=g+1;c<r;c++){const r=n[c];if(r===a.n)continue;const g=this.m_shape.getNextVertex(r);let _=a.n;this.m_shape.queryXY(g,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(r)||(_=g));const p=this.m_shape.getPrevVertex(r);let d=a.n;if(this.m_shape.queryXY(p,o),m.compare(o)<0&&(e?o.y===t:o.x===t)&&(this.isCurve(p)||(d=p)),_!==a.n&&d!==a.n){this.beforeRemoveVertex(r,n,i),this.m_shape.removeVertex(r,!1),this.beforeRemoveVertex(_,n,i),this.m_shape.removeVertex(_,!1),s=!0;break}if(l!==a.n&&d!==a.n){this.removeOverlap(n,h,l,r,d,i),s=!0;break}if(u!==a.n&&_!==a.n){this.removeOverlap(n,r,_,h,u,i),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(h,n,i),this.m_shape.removeVertex(h,!1),this.beforeRemoveVertex(l,n,i),this.m_shape.removeVertex(l,!1),s=!0}if(!s)break}l=r,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(i)}beforeRemoveVertex(e,t,s){let n=this.m_shape.getUserIndex(e,s);(0,r.g)(n>=0),t[n]=a.n,n=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),(0,r.g)(n>=0),this.m_verticesOnExtent[n]=a.n;const i=this.m_shape.getPathFromVertex(e);i!==a.n&&this.m_shape.getFirstVertex(i)===e&&(this.m_shape.setFirstVertex(i,a.n),this.m_shape.setLastVertex(i,a.n))}removeOverlap(e,t,s,n,r,i){this.m_shape.setNextVertex(t,n),this.m_shape.setPrevVertex(n,t),this.m_shape.setPrevVertex(s,r),this.m_shape.setNextVertex(r,s),this.beforeRemoveVertex(n,e,i),this.m_shape.removeVertexInternal(n,!1),this.beforeRemoveVertex(r,e,i),this.m_shape.removeVertexInternal(r,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(e){for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;t=this.m_shape.getNextPath(t)){const s=this.m_shape.getPathSize(t);if(s<3)continue;let n=this.m_shape.getFirstVertex(t);const r=new h.P;this.m_shape.queryXY(n,r);let i=r.y===e&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const o=new h.P;this.m_shape.queryXY(n,o);let a=o.y===e&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const m=new h.P;for(let t=0,h=s-2;t<h;t++,n=this.m_shape.getNextVertex(n)){this.progress_(),this.m_shape.queryXY(n,m);const t=m.y===e;a&&i&&t&&(o.x-r.x)*(m.x-o.x)<=0?(this.m_shape.removeVertex(this.m_shape.getPrevVertex(n),!1),o.setCoordsPoint2D(m),a=t&&!this.isCurve(n)):(r.setCoordsPoint2D(o),i=a,o.setCoordsPoint2D(m),a=t&&!this.isCurve(n))}}}fixPaths(){for(let e=0,t=this.m_verticesOnExtent.length;e<t;e++){const t=this.m_verticesOnExtent[e];t!==a.n&&this.m_shape.setPathToVertex(t,a.n)}const e=this.m_shape.hasCurves();let t=0,s=0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==a.n;){const n=this.m_shape.getFirstVertex(e);if(n===a.n||e!==this.m_shape.getPathFromVertex(n)){const t=e;e=this.m_shape.getNextPath(e),this.m_shape.setFirstVertex(t,a.n),this.m_shape.removePathOnly(t);continue}let r=n,i=0;do{this.m_shape.setPathToVertex(r,e),i++,r=this.m_shape.getNextVertex(r)}while(r!==n);this.m_shape.setRingAreaValid(e,!1),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(n)),this.m_shape.setPathSize(e,i),s+=i,t++,e=this.m_shape.getNextPath(e)}for(let n=0,i=this.m_verticesOnExtent.length;n<i;n++){let i=this.m_verticesOnExtent[n];if(i===a.n)continue;let o=this.m_shape.getPathFromVertex(i);if(o!==a.n)continue;o=this.m_shape.insertPath(this.m_geometry,a.n);let h=!1,m=0;const l=i;do{this.m_shape.setPathToVertex(i,o),m++,e&&m<=2&&(h||=this.isCurve(i)),i=this.m_shape.getNextVertex(i)}while(i!==l);if(h?0===m:m<=2){let e=this.m_shape.getUserIndex(l,this.m_verticesOnExtentIndex);(0,r.g)(e>=0),this.m_verticesOnExtent[e]=a.n;const t=this.m_shape.removeVertex(l,!1);2===m&&(e=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),e>=0&&(this.m_verticesOnExtent[e]=a.n),this.m_shape.removeVertex(t,!1));const s=o;o=this.m_shape.getNextPath(o),this.m_shape.setFirstVertex(s,a.n),this.m_shape.removePathOnly(s);continue}this.m_shape.setClosedPath(o,!0),this.m_shape.setPathSize(o,m),this.m_shape.setFirstVertex(o,l),this.m_shape.setLastVertex(o,this.m_shape.getPrevVertex(l)),this.m_shape.setRingAreaValid(o,!1),s+=m,t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let n=0;for(let e=this.m_shape.getFirstGeometry();e!==a.n;e=this.m_shape.getNextGeometry(e))n+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(n)}dbgCheckPathFirst(){}isCurve(e){return null!==this.m_shape.getSegment(e)}compareVertices(e,t){const s=new h.P;this.m_shape.queryXY(e,s);const n=new h.P;return this.m_shape.queryXY(t,n),s.compare(n)}clipPolesOut(e,t){return this.clipPolygonOrProjectedPolyline2(e,t)}}class u{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new _(e,t,s,n)}execute(e,t,s,n){return function(e,t,s,n){return l(e,t,s,Number.NaN,0,n)}(e,t,s,n)}}class _ extends n.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,e||(0,r.a)(""),this.m_envelope=t,this.m_inputGeometryCursor=e,this.m_spatialRefImpl=s,this.m_tolerance=(0,i.c)(s,t,!1).total()}next(){let e;return(e=this.m_inputGeometryCursor.next())?((0,r.c)(e),this.m_index=this.m_inputGeometryCursor.getGeometryID(),m(e,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},24383(e,t,s){s.d(t,{NonSimpleResult:()=>n});class n{assign(e){this.m_reason=e.m_reason,this.m_vertexIndex1=e.m_vertexIndex1,this.m_vertexIndex2=e.m_vertexIndex2}constructor(e,t,s){void 0!==e?(this.m_reason=e,this.m_vertexIndex1=t,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}}},5247(e,t,s){s.d(t,{O:()=>h});var n=s(61691),r=s(55537),i=s(88885),o=i.D;class a extends n.G{constructor(e,t,s,n,r,i){super(),this.m_densificator=new o(t,s,n,i,!1,r),this.m_index=-1,this.m_inputGeoms=e}tock(){return!0}getRank(){return 1}next(){let e=null;for(;e=this.m_inputGeoms.next();)return(0,r.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.densify(e);return null}getGeometryID(){return this.m_index}densify(e){return this.m_densificator.densify(e)}}class h{getOperatorType(){return 10202}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}executeMany(e,t,s,n,r,i=12e3){return new a(e,t,s,n,i,r)}execute(e,t,s,n,r,o=12e3){return(0,i.d)(e,t,s,n,r,o)}}},15756(e,t,s){s.d(t,{$:()=>No,C:()=>cs,I:()=>Lo,J:()=>Ao,K:()=>Mo,L:()=>Bo,M:()=>Eo,N:()=>wo,O:()=>cn,Q:()=>v,R:()=>Hr,S:()=>Xr,T:()=>ks,U:()=>C,V:()=>kr,W:()=>Nr,X:()=>Gr,Y:()=>ts,Z:()=>w,_:()=>Ui,a:()=>li,a0:()=>Co,a1:()=>_n,a2:()=>Sr,a3:()=>Ar,a4:()=>pn,a5:()=>Wi,a6:()=>P,a7:()=>ii,a8:()=>qn,a9:()=>br,aD:()=>eo,aE:()=>Xi,aF:()=>yo,aG:()=>Fr,aH:()=>F,aI:()=>Ki,aJ:()=>Zi,aK:()=>jn,aL:()=>Ri,aM:()=>oo,aN:()=>zi,aO:()=>p,aP:()=>zo,aa:()=>Po,ab:()=>Un,ac:()=>xn,ad:()=>Pn,ae:()=>dn,af:()=>fn,ag:()=>On,ao:()=>So,as:()=>Ae,at:()=>Me,au:()=>rr,av:()=>ir,aw:()=>as,ax:()=>Ns,b:()=>mi,c:()=>hi,f:()=>Js,g:()=>sn,h:()=>Oi,i:()=>qi,j:()=>or,k:()=>cr,l:()=>es,m:()=>ci,n:()=>nr,o:()=>ar,p:()=>mr,q:()=>gi,r:()=>$e,s:()=>Us,t:()=>Ys,u:()=>ls,v:()=>ms,w:()=>os,x:()=>vs,y:()=>Gs});var n=s(5482),r=s(79187),i=s(55537),o=s(88885),a=s(95213),h=s(83661),m=s(11878),l=s(31139),g=s(5247),c=s(61691),u=s(76061),_=s(24383);class p{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move)return this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,void(e.move.m_sr=null);if(e.copy)return this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,void(this.m_sr=e.copy.m_sr);e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){const s=e;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,t))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new p({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class d{constructor(e){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():""}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&(0,i.a)("unit type mismatch"),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return(0,h.at)((0,h.au)(this.getUnitType()),(0,h.au)(this.getUnitToBaseFactor()))}equals(e){return!!e&&this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName()}static isValidWkid(e){return!1}}const f={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,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,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,104220,104221,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,10635,10636,10735,10736,10758,37e3,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,10898,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,104032,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 x extends d{constructor(e){if("number"==typeof e)return super(),this.m_factor=e,void(this.m_wkid=0);super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function P(e){return new Ti}class E{constructor(e,t,s){void 0===e?(this.x=new h.H,this.y=new h.H,this.z=new h.H):e instanceof a.f?(this.x=new h.H(e.x),this.y=new h.H(e.y),this.z=new h.H(e.z)):e instanceof h.H?(this.x=e.clone(),this.y=t.clone(),this.z=s.clone()):(0,i.a)("EPoint3D constructor")}dotProduct(e){return this.x.mulE(e.x).addE(this.y.mulE(e.y)).addE(this.z.mulE(e.z))}crossProduct(e){return new E(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){const t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),s=e.x.mulE(this.z).subE(this.x.mulE(e.z)),n=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new E(t,s,n)}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(e,t){return e.sub(t).length()}negate(){return new E(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new E(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new E(this.x.subE(e.x),this.y.subE(e.y),this.z.subE(e.z))}subThis(e){return this.x.subThisE(e.x),this.y.subThisE(e.y),this.z.subThisE(e.z),this}addThis(e){return this.x.addThisE(e.x),this.y.addThisE(e.y),this.z.addThisE(e.z),this}mul(e){return new E(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new E(this.x.divE(e),this.y.divE(e),this.z.divE(e))}eq(e){return this.x.eq(e.x)&&this.y.eq(e.y)&&this.z.eq(e.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return a.f.construct(this.x.value(),this.y.value(),this.z.value())}}class y{constructor(e){if(this.m_origin=new a.f,this.m_normal=new a.f,this.m_axisX=new a.f,this.m_axisY=new a.f,!e)return this.m_origin=new a.f,this.m_normal=new a.f(0,0,1),this.m_axisX=new a.f(1,0,0),void(this.m_axisY=new a.f(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):(0,i.g)(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return(0,i.g)(0),this}set(e,t,s,n){(0,i.g)(0)}setFromPoints(e,t,s){let n=t.sub(e);const r=s.sub(e);this.m_normal=n.crossProductVector(r);let i=!0;if(this.m_normal.isZero()){if(i=!1,n.isZero()&&(n=r),n.isZero()){const t=0,s=1;return this.m_normal.setCoords(t,t,s),this.m_axisX.setCoords(s,t,t),this.m_axisY.setCoords(t,s,t),this.m_origin=e,!1}this.m_axisX=n.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}else this.m_normal.normalizeThis(),this.m_axisX=n.getUnitVector();return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,i}getCoord(e,t){return(0,i.g)(0),{}}getCoord2D(e){return(0,i.g)(0),{}}getCoordX(e,t){return(0,i.g)(0),0}getCoordY(e,t){return(0,i.g)(0),0}getCoordZ(e,t){return(0,i.g)(0),0}setPreferredAxisX(e){(0,i.g)(0)}getOrigin(){return(0,i.g)(0),{}}getNormal(){return(0,i.g)(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){(0,i.g)(0)}setAxisY(e,t=!1){(0,i.g)(0)}recalculateAxisY(){(0,i.g)(0)}setOrigin(e){(0,i.g)(0)}setNormal(e,t){(0,i.g)(0)}intersect(e,t){return(0,i.g)(0),!1}intersectLine(e){return(0,i.g)(0),0}intersectLineEx(e,t){return(0,i.g)(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new h.P;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return(0,i.g)(0),{}}signedDistance(e){return(0,i.g)(0),0}distance(e){return(0,i.g)(0),0}}function S(e,t){return!1}function C(e,t,s,n,r=100,o=S){let a,m,l,g,c,u,_,p,d;(0,i.g)(n>0);let f,x,P,E=0,y=0;const C=(0,h.aq)();t>s&&(s=(0,h.c)(t,t=s));const I=e(t),v=e(s);I<v?(a=m=l=t,g=c=u=I):(a=m=l=s,g=c=u=v);let b=0;for(;b<r&&(P=.5*(s-t),d=t+P,f=n*(Math.abs(a)+.25),x=2*f,!(o(a,g)||Math.abs(a-d)<=x-P));++b){if(Math.abs(y)>f){const e=(a-m)*(g-u);let n=(a-l)*(g-c),r=(a-l)*n-(a-m)*e;n=2*(n-e),n>0&&(r=-r),n=Math.abs(n);const i=y;y=E,Math.abs(r)>=Math.abs(n*i*.5)||r<=n*(t-a)||r>=n*(s-a)?(y=a>=d?t-a:s-a,E=(0,h.aq)()*y):(E=r/n,p=a+E,(p-t<x||s-p<x)&&(E=d-a<0?-Math.abs(f):Math.abs(f)))}else y=a>=d?t-a:s-a,E=y*C;p=a+E,_=e(p),_<g?(p>=a?t=a:s=a,l=m,m=a,a=p,u=c,c=g,g=_):(p<a?t=p:s=p,_<=c||m===a?(l=m,m=p,u=c,c=_):(_<=u||l===a||l===m)&&(l=p,u=_))}return(0,h.k)(a,g)}function I(e,t,s){return e>s?e-=Math.ceil((e-s)/h.p)*h.p:e<t&&(e+=Math.ceil((t-e)/h.p)*h.p),e}function v(e,t,s){return function(e,t,s){const n=s.x,r=s.y;return b(e,t,Math.cos(n),Math.sin(n),Math.cos(r),Math.sin(r),0)}(e,t,s)}function b(e,t,s,n,r,i,o){const h=e/Math.sqrt(1-t*i*i),m=h+o,l=m*r*s,g=m*r*n,c=(h*(1-t)+o)*i;return a.f.construct(l,g,c)}function G(e,t,s){const n=new h.H,r=new h.H,i=new h.H,o=new h.H;n.setCos(s.x),r.setSin(s.x),i.setCos(s.y),o.setSin(s.y);const a=o.negate().mulE(o.mul(t)).add(1).sqrt(),m=new h.H(e).divE(a),l=m.mulE(i).mulE(n),g=m.mulE(i).mulE(r),c=m.mul(1-t).mulE(o);return new E(l,g,c)}function w(e,t,s){const n=s.x,r=s.y,i=s.z,o=Math.atan2(r,n),a=Math.sqrt(n*n+r*r),m=Math.atan2(i,(1-t)*a);return h.P.construct(o,m)}function N(e,t,s){const n=1-t,r=e/Math.sqrt((0,h.a)(s.x)+(0,h.a)(s.y)+(0,h.a)(s.z)/n);return s.mul(r)}function T(e,t,s,n,r){const i=v(e,t,s),o=v(e,t,n);return w(0,t,a.f.lerp(i,o,r))}function D(e,t,s,r,o,m=0,l){if(2===m||3===m)return function(e,t,s,n,r,i=!1,o){const m=N(e,t,s);if(i){const i=new y({pt0:new a.f(0,0,0),pt1:n,pt2:r}),l=i.closestCoordinate(s),g=i.closestCoordinate(n),c=i.closestCoordinate(r),u=h.P.getClosestCoordinate(g,c,l),_=N(e,t,a.f.lerp(n,r,u)),p=a.f.distance(_,m);return o&&o.assign(_),(0,h.k)(u,p)}const l=s=>{const i=N(e,t,a.f.lerp(n,r,s));return a.f.distance(i,m)},g=a.f.distance(n,r);if(g>0){const s=A(e,g),{first:i,second:m}=C(l,0,1,s);return o&&o.assign(N(e,t,a.f.lerp(n,r,i))),(0,h.k)(i,m)}{const e=a.f.distance(s,n);return o&&o.assign(s),(0,h.k)(.5,e)}}(e,t,s,r,o,3===m,l);const g=w(0,t,s),c=s=>{const h=w(0,t,a.f.lerp(r,o,s));return function(e,t,s,r,o){switch((0,i.g)(s.isFinite()&&r.isFinite()),o){case 0:return function(e,t,s,r){const i={stack:[],error:void 0,hasError:!1};try{const o=(0,n.mS)(i,new Eo,!1);return wo.geodeticDistance(e,t,s.x,s.y,r.x,r.y,o,null,null,So.PE_LINETYPE_GEODESIC),o.val}catch(e){i.error=e,i.hasError=!0}finally{(0,n.hk)(i)}}(e,t,s,r);case 1:return function(e,t,s){const r={stack:[],error:void 0,hasError:!1};try{const i=(0,n.mS)(r,new Eo,!1);return wo.greatEllipticDistance(e,t,s.x,s.y,s.x,s.y,i,null,null),i.val}catch(e){r.error=e,r.hasError=!0}finally{(0,n.hk)(r)}}(e,t,s);case 2:case 3:{const n=v(e,t,s),i=v(e,t,r);return a.f.distance(n,i)}default:(0,i.t)("")}}(e,t,g,h,m)},u=a.f.distance(r,o);if(u>0){const s=A(e,u),{first:n,second:i}=C(c,0,1,s);return l&&l.assign(N(e,t,a.f.lerp(r,o,n))),(0,h.k)(n,i)}{const e=c(0);return l&&l.assign(r),(0,h.k)(.5,e)}}function V(e,t,s,n,r,i){if(i[0]=Number.NaN,i[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>h.o||Math.abs(n.y)>h.o)return 0;if((Math.abs(s.y)===h.o||Math.abs(n.y)===h.o)&&s.x!==n.x)return 0;if(Math.abs(r)>=h.o)return 0;if(s.y>0&&n.y>0&&s.y>r&&n.y>r||s.y<0&&n.y<0&&s.y<r&&n.y<r)return 0;const a=o._.constructPoint2D(s),m=o._.constructPoint2D(n),l=G(1,t,a),g=G(1,t,m),c=l.crossProductVector(g);if(c.z.isZero())return h.E.construct(s.y,n.y).containsCoordinate(r)?(i[0]=s.x,1):0;const u=c.x.divE(c.z.negate()),_=c.y.divE(c.z.negate()),p=u.mulE(u).addE(_.mulE(_)).sqrt();if(p.isZero()||u.isZero()&&_.isZero())return 0===r?(i[0]=s.x,i[1]=n.x,2):0;const d=(1-t)*Math.tan(r)/p.value();if(Math.abs(d)>1)return 0;const f=Math.acos(d),x=Math.atan2(_.value(),u.value()),P=x-f;let E=x+f;const y=Math.min(s.x,n.x),S=Math.max(s.x,n.x);I(P,y,S),0!==r?I(E,y,S):E=P;let C=0;return y<=P&&P<=S&&(i[C]=P,C++),E!==P&&y<=E&&E<=S&&(i[C]=E,C++),C}function k(e,t){t[0]>.5*Math.PI?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<.5*-Math.PI&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),(0,i.g)(t[0]>=.5*-Math.PI&&t[0]<=.5*Math.PI)}function F(e,t,s,n,r){n=(0,h.s)(n,-h.o,h.o),r=(0,h.s)(r,-h.o,h.o);const i=h.o-.03;let o;return o=n>i&&r>i||n<-i&&r<-i?function(e,t,s){let n=1;if(t<0&&(n=-1,t=-t,s=-s),0!==e){const r=e*e,i=r*e,o=[1,(1+11*e)/12,(1+118*e+241*r)/360,(1+1089*e+10419*r+8651*i)/20160,(1+9836*e+318246*r+1027436*i+i*e*458881)/1814400],a=t=>{let s=0;const n=(0,h.a)(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-(0,h.a)(t/(1-e)),s},m=a(h.o-t);return(a(h.o-s)-m)*n}{const e=h.o-t,r=h.o-s,i=-4*(0,h.a)(Math.sin(e/2));return(-4*(0,h.a)(Math.sin(r/2))-i)*n}}(e,n,r):H(e,r)-H(e,n),.5*(s-t)*o*function(e){return 1-e}(e)}function H(e,t){if(0===t)return 0;const s=Math.sin(t);let n=s,r=s;if(0!==e){n/=1-e*s*s;const t=Math.sqrt(e);r=s*(0,h.y)(t*s)}return n+r}function A(e,t){if(0!==t){const s=e*(0,h.aJ)()/t;return Math.min(s,1e-10)}return 0}class M{constructor(e){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return M.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 U(e){return 1n<<(0x3fn&BigInt(e))}function q(e){return e>>6}class O{constructor(e){this.m_bits=[],void 0!==e&&e.copy&&(this.m_bits=e.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(e){const t=U(e),s=q(e);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&t)}setBit(e){const t=U(e),s=q(e);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=t}clearBit(e){}flipBit(e){const t=U(e),s=q(e);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=t,0n!==(this.m_bits[s]&t)}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(2&e)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((s,n)=>{t|=s===e.m_bits[n]?2:1}),!(1&t||(e.m_bits.forEach((e,s)=>{t|=e===this.m_bits[s]?2:1}),1&t))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>(0,h.az)(e,t),(0,h.au)(0))}getUnorderedBitIterator(){return new M(this)}}class Y{constructor(e,t){this.m_map=new Map,this.m_hf=e,this.m_ef=t}add(e){const t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;const s=this.m_map.get(t);return s instanceof Array?s.find(t=>this.m_ef(t,e))||s.push(e):this.m_ef(s,e)||this.m_map.set(t,[s,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){const t=this.m_hf(e);if(!this.m_map.has(t))return!1;const s=this.m_map.get(t);return s instanceof Array?void 0!==s.find(t=>this.m_ef(t,e)):this.m_ef(s,e)}get(e){const t=this.m_hf(e),s=this.m_map.get(t);if(void 0!==s)return s instanceof Array?s.find(t=>this.m_ef(t,e)):s}get size(){let e=0;for(const t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[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 B extends a.a6{constructor(e){super(),this.m_bufferLeft=new o.S,this.m_bufferRight=new o.S,this.m_intervalLeft=h.E.constructEmpty(),this.m_intervalRight=h.E.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=e}compare(e,t,s){const n=t,r=e.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(r,this.m_bufferRight);const i=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(i.getStartX(),i.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=i.getStartY()===i.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(i.getStartY()===o.getStartY()&&i.getStartX()===o.getStartX())return a?1:-1;if(i.getEndY()===o.getEndY()&&i.getEndX()===o.getEndX())return a?-1:1}let m=i.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const e=i.getEndY(),t=o.getEndY(),s=Math.min(e,t);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),m=i.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(e){this.m_yScanline=e}}class R{constructor(e){this.m_segmentBuffer=new o.S,this.m_point=h.P.getNAN(),this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){const s=e.getElement(t);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),r=new h.E;if(r.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<r.vmin)return-1;if(this.m_point.x>r.vmax)return 1;const i=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<i?-1:this.m_point.x>i?1:0}}var X,L,z;function W(e,t){return{parentage:e,rank:t}}function j(e,t){const s=e.length;if(s!==t.length)return!1;const n=e[0].parentage;if(n!==t[0].parentage)return!1;if(-1===n)return!0;for(let n=1;n<s;++n)if(e[n].parentage!==t[n].parentage)return!1;return!0}function Z(e,t,s){s.length=0;let n=!1;{let r=e.getHalfEdgeVertexIterator(t);for(;r!==o.n;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(W(o,i)),r=e.incrementVertexIterator(r)}}{let r=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;r!==o.n;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(W(o,i)),r=e.incrementVertexIterator(r)}}n&&s.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:e.parentage>t.parentage?1:0),-1===s[0].parentage&&(s.length=1)}(z=X||(X={}))[z.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",z[z.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",z[z.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding",function(e){e[e.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",e[e.enumPathBreakNode=2]="enumPathBreakNode"}(L||(L={}));class K{constructor(){this.m_shape=null,this.m_clusterData=new a.S(8),this.m_clusterVertices=new a.S(2),this.m_firstCluster=o.n,this.m_lastCluster=o.n,this.m_halfEdgeData=new a.S(8),this.m_chainData=new a.S(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(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,s=!0,n=!1){n?this.setEditShapeImpl3D_(e,X.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,X.enumInputModeBuildGraph,null,t,s)}setAndSimplifyEditShapeAlternate(e,t,s=null,n=!1){const r=[];r.push(t),this.m_simplifiedGeometry=t,n?this.setEditShapeImpl3D_(e,X.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(e,X.enumInputModeSimplifyAlternate,r,s,e.getGeometryType(t)===i.G.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,s=null){const n=[];n.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,X.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=o.n,this.m_lastCluster=o.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=o.n,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){const s=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(e,t){(0,i.g)(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){const s=this.getClusterIndex_(e),n=this.m_clusterIndices[t];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1),r.write(n,s)}hasClusterUserIndexFlags(e,t,s){if(-1===t)return!1;const n=this.getClusterUserIndex(e,t);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,s|i)}clearClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,~s&i)}createUserIndexForClusters(e=-1){const t=new a.a(this.m_clusterData.capacity(),e);for(let e=0,s=this.m_clusterIndices.length;e<s;e++)if(null===this.m_clusterIndices[e])return this.m_clusterIndices[e]=t,e;return this.m_clusterIndices.push(t),this.m_clusterIndices.length-1}deleteUserIndexForClusters(e){this.m_clusterIndices[e]=null}getHalfEdgeOrigin(e){return this.m_halfEdgeData.getField(e,1)}getHalfEdgeTo(e){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(e))}getHalfEdgeTwin(e){return this.m_halfEdgeData.getField(e,4)}getHalfEdgePrev(e){return this.m_halfEdgeData.getField(e,5)}getHalfEdgeNext(e){return this.m_halfEdgeData.getField(e,6)}getHalfEdgeChain(e){return this.m_halfEdgeData.getField(e,2)}getHalfEdgeFaceParentage(e){return this.getChainParentage(this.getHalfEdgeChain(e))}getHalfEdgeVertexIterator(e){return this.m_halfEdgeData.getField(e,7)}getHalfEdgeFromXY(e,t){this.queryXY(this.getHalfEdgeOrigin(e),t)}getHalfEdgeToXY(e,t){this.queryXY(this.getHalfEdgeTo(e),t)}isHalfEdgeCurve(e){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}getHalfEdgeFromXYZ(e,t){(0,i.g)(0)}getHalfEdgeToXYZ(e,t){(0,i.g)(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&K.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){const s=this.getHalfEdgeIndex_(e),n=this.m_edgeIndices[t];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(e,t,s){const n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];r.size()<=n&&r.resize(this.m_halfEdgeData.size(),-1),r.write(n,s)}createUserIndexForHalfEdges(e){void 0===e&&(e=-1);const t=new a.a(this.m_halfEdgeData.capacity(),e);for(let e=0,s=this.m_edgeIndices.length;e<s;e++)if(null===this.m_edgeIndices[e])return this.m_edgeIndices[e]=t,e;this.m_edgeIndices.push(t);const s=this.m_edgeIndices.length-1;return(0,i.g)(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.getHalfEdgeChain(s),r=this.getHalfEdgeTwin(s),i=this.getHalfEdgeChain(r);this.setChainHalfEdge_(n,o.n),this.setChainHalfEdge_(i,o.n),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return(0,i.g)(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonInterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonExterior(e,t){return(0,i.g)(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return(0,i.g)(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){const t=this.getChainIndex_(e);let s=this.m_chainAreas.read(t);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(e),s=this.m_chainAreas.read(t)),s}getChainPerimeter(e){return(0,i.g)(0),0}getChainUserIndex(e,t){const s=this.getChainIndex_(e),n=this.m_chainIndices[t];return n.size()<=s?-1:n.read(s)}setChainUserIndex(e,t,s){const n=this.getChainIndex_(e),r=this.m_chainIndices[t];r.size()<=n&&r.resize(this.m_chainData.size(),-1),r.write(n,s)}createUserIndexForChains(){const e=new a.a(this.m_chainData.capacity(),-1);for(let t=0,s=this.m_chainIndices.length;t<s;t++)if(null===this.m_chainIndices[t])return this.m_chainIndices[t]=e,t;return this.m_chainIndices.push(e),this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,s,n){const r=t===o.n?e.createGeometry(i.G.enumPolygon):t,a=new o.S;this.extractPolygonPathFromChain_(e,r,s,n,a);for(let t=this.getChainFirstIsland(s);t!==o.n;t=this.getChainNextInParent(t))this.extractPolygonPathFromChain_(e,r,t,n,a);return r}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return(0,i.g)(t>=0),1<<Math.min(t,31)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_clusterIndex)}getHalfEdgeFromVertex(e){return this.m_shape.getUserIndex(e,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(e){if((0,i.g)(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);(0,i.g)(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){(0,i.g)(this.m_bBuildGeometryParentageSets);const t=new O,s=e=>{const s=this.getChainHalfEdge(e);let n=s;do{const e=this.getEdgeBitSet_(n);null!==e&&t.assignOr(e);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&t.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(e);for(let t=this.getChainFirstIsland(e);t!==o.n;t=this.getChainNextInParent(t))s(e);return t}getChainPolygons(e){return(0,i.g)(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||null===e)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==o.n;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}const t=[],s=e.getUnorderedBitIterator();for(let e=s.next();e!==M.npos();e=s.next())(0,i.g)(this.m_geometryMapID.has(e)),t.push(this.m_geometryMapID.get(e));return t}getVertexDominant(e,t){if(t===o.n)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==o.n){let s=o.n;for(let n=this.getClusterVertexIterator(e);n!==o.n;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===o.n&&(s=e);const r=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(r)===t){s=e;break}}return s}{const t=this.getClusterVertexIterator(e);return t!==o.n?this.getVertexFromVertexIterator(t):o.n}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode)}setBreakNode(e,t){(0,i.g)(-1!==this.m_clusterBreakNodeIndex),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode)}setStrongPathNode(e,t){if(-1===this.m_clusterBreakNodeIndex){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,L.enumPathBreakNode)}getSegmentParentage(e){if(-1===this.m_segmentParentageIndex)return-1;const t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){const t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(s);return e!==this.getHalfEdgeTwin(n)}isCrossroadBehind(e){return(0,i.g)(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===o.n)return o.n;let n=s,r=o.n,i=o.n;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===o.n){if(r=this.getClusterHalfEdge(t),r===o.n)return o.n;i=r}if(this.getHalfEdgeTo(i)===e)return n=this.getHalfEdgeTwin(i),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(n!==s&&i!==r);return o.n}querySegmentXY(e,t){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const e=this.m_shape.getSegmentFromIndex(s);t.copyFrom(e,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);t.copyFrom(n,!0),t.get().reverse()}return}}t.createLine();const s=t.get(),n=h.P.getNAN();this.getHalfEdgeFromXY(e,n),s.setStartXY(n),this.getHalfEdgeToXY(e,n),s.setEndXY(n)}isCurveEdge(e){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}compareEdgeAnglesCurveHelper_(e,t,s){const n=new o.S,r=new o.S;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const a=n.get(),m=r.get();if(a.equals(m))return 0;const l=new h.P;this.getHalfEdgeFromXY(e,l);const g=new h.P;this.getHalfEdgeToXY(e,g);const c=new h.P;return this.getHalfEdgeToXY(t,c),(0,i.g)(!g.isEqualPoint2D(c)),(0,o.R)(a,m)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=h.P.getNAN();this.getHalfEdgeToXY(e,n);const r=h.P.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=h.P.getNAN();this.getHalfEdgeFromXY(e,i);const o=h.P.getNAN();o.setSub(n,i);const a=h.P.getNAN();return a.setSub(r,i),!s||a.y>=0&&o.y>0?h.P.compareVectors(o,a):0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return(0,i.g)(0),0}compareEdgeAnglesForPair3D_(e,t){return(0,i.g)(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);(0,i.g)(n===t),(0,i.g)(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=o.n));const a=this.getChainIndex_(t),h=this.m_chainAreas.read(a);Number.isNaN(h)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const m=this.getChainHalfEdge(t);m!==e&&m!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==o.n?t:this.getClusterHalfEdge(e);if(n===o.n)return o.n;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return o.n;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==o.n;s=this.getNextCluster(s)){let n=o.n;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===o.n)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));let i=r;for(;;){const s=this.getHalfEdgeNext(i),a=this.getHalfEdgePrev(i),h=this.getHalfEdgeTwin(i);if(a===h){if(this.deleteEdgeInternal_(i),e=!0,n!==i&&n!==h||(n=o.n),i===r||a===r){if(r=s,i===r||a===r)break;i=s;continue}}else this.setHalfEdgeUserIndex(i,t,1);if(i=s,i===r)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){const e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){const e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);const t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){const e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return(0,i.g)(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){const s=t?o.n:e;for(let t=this.getHalfEdgeVertexIterator(e);t!==o.n;t=this.incrementVertexIterator(t)){const e=this.getVertexFromVertexIterator(t);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==o.n&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);const s=this.getChainFirstIsland(t);this.setChainNextInParent_(e,s),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){const s=this.getChainIndex_(e);this.m_chainAreas.write(s,t)}setChainPerimeter_(e,t){const s=this.getChainIndex_(e);this.m_chainPerimeters.write(s,t)}updateChainAreaAndPerimeter_(e){const t=this.m_shape.hasCurves(),s=new h.K(0),n=new h.K(0),r=this.getChainHalfEdge(e),i=h.P.getNAN(),a=h.P.getNAN(),m=h.P.getNAN();this.getHalfEdgeFromXY(r,i),a.setCoordsPoint2D(i);let l=r;do{this.getHalfEdgeToXY(l,m),t&&this.isCurveEdge(l)||n.pe(h.P.distance(a,m)),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==e&&s.pe((m.x-i.x-(a.x-i.x))*(m.y-i.y+(a.y-i.y))*.5),a.setCoordsPoint2D(m),l=this.getHalfEdgeNext(l)}while(l!==r);if(t){const t=new o.S;l=r;do{this.getHalfEdgeToXY(l,m);const r=this.isCurveEdge(l);if(r&&(this.querySegmentXY(l,t),n.pe(t.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==e&&r){const e=t.get().calculateArea2DHelper();s.pe(e)}l=this.getHalfEdgeNext(l)}while(l!==r)}const g=this.getChainIndex_(e);this.m_chainAreas.write(g,s.getResult()),this.m_chainPerimeters.write(g,n.getResult())}getChainTopmostEdge_(e){return(0,i.g)(0),0}planeSweepParentage_(e,t){const s=new B(this),n=new a.T;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let m=null;const l=h.P.getNAN();for(let h=this.getFirstCluster();h!==o.n;h=this.getNextCluster(h)){this.progress_(t);const g=this.getClusterHalfEdge(h);if(g!==o.n){if(r.length=0,!this.tryOptimizedInsertion_(n,i,r,h,g)){this.queryXY(h,l),s.setY(l.y);let e=g;do{const t=this.getHalfEdgeUserIndex(e,i);-1!==t&&(n.deleteNode(t),this.setHalfEdgeUserIndex(e,i,a.S.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(g!==e);e=g;do{if(-1===this.getHalfEdgeUserIndex(e,i)){const t=n.addElement(e);r.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(g!==e)}for(let t=r.length-1;t>=0;t--){const s=r[t],o=n.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,i,s),this.planeSweepParentagePropagateParentage_(n,s,e)}}else if(this.getClusterChain(h)===o.n){null===m&&(m=new R(this)),this.queryXY(h,l),m.setPointXY(l);const e=n.searchLowerBound(m);let t=this.m_universeChain;if(-1!==e){let s=n.getElement(e);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,e)),s!==o.n&&(t=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(t,h)}}this.deleteUserIndexForHalfEdges(i)}planeSweepParentagePropagateParentage_(e,t,s){const n=e.getElement(t),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==o.n)return;const a=this.getLeftSkipPolylines_(e,t),h=this.getHalfEdgeTwin(n),m=this.getHalfEdgeChain(h);let l=this.getChainParent(r),g=this.getChainParent(m);if(a===o.n)l===o.n&&(m===r?(this.setChainParent_(m,this.m_universeChain),g=this.m_universeChain,l=g):(g===o.n&&(this.setChainParent_(m,this.m_universeChain),g=this.m_universeChain),this.setChainParent_(r,m),l=m));else{const e=this.getHalfEdgeChain(a);if(g===o.n){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(m,t),g=t}else this.setChainParent_(m,e),g=e;m===r&&(l=g)}}l===o.n&&(this.trySetChainParentFromTwin_(r,m),l=this.getChainParent(r)),(0,i.g)(l!==o.n),s===X.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,a):s===X.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,a,h,r,m):s===X.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,a,h,r,m)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===o.n?(i=e.getNext(i),r=this.getHalfEdgeChain(s)):r=this.getHalfEdgeChain(n);let a=null,h=this.getChainParentage(r);for(this.m_bBuildGeometryParentageSets&&(a=this.getChainBitSet(r));-1!==i;i=e.getNext(i)){const t=e.getElement(i),s=this.getHalfEdgeTwin(t);r=this.getHalfEdgeChain(t);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(n);e=new O({copy:e}),e.assignOr(a),this.setChainBitSet_(n,e);let s=this.getChainBitSet(r);const i=this.getLeftEdgeBitSet_(t),o=new O({copy:a});if(o.assignSubtract(i),o.isZero())break;s=new O({copy:s}),s.assignOr(o),this.setChainBitSet_(r,s),a=s}const o=this.getChainParentage(n),m=o|h;m!==o&&this.setChainParentage_(n,m);let l=this.getChainParentage(r);const g=h&~this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft);if(g&&(l|=g,this.setChainParentage_(r,l)),0===g)break;h=l}}propagateParentageWinding_(e,t,s,n,r,a,h){if(a===h)return;let m=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);m+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let l=0;const g=[],c=[];c.push(0);for(let s=e.getFirst();s!==t;s=e.getNext(s)){const t=e.getElement(s),n=this.getHalfEdgeTwin(t),r=this.getHalfEdgeChain(t),a=this.getHalfEdgeChain(n);if(r!==a){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),l+=e;let s=!1;0!==g.length&&g.at(-1)===a&&(c.pop(),g.pop(),s=!0),(0,i.g)(this.getChainParent(a)!==o.n),s&&this.getChainParent(a)===r||(c.push(l),g.push(r))}}if(l+=m,0!==g.length&&g.at(-1)===h&&(c.pop(),g.pop()),0!==l){if(0===c.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}else if(0!==c.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}propagateParentageAlternate_(e,t,s,n,r,i,a){const h=this.m_simplifiedGeometry,m=this.getGeometryID(h);if(n===o.n)this.setChainParentage_(a,this.m_universeGeomID),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,m):this.setChainParentage_(i,this.m_universeGeomID);else{const e=this.getChainParentage(a);if(0===e){const e=this.getHalfEdgeChain(n),t=this.getChainParentage(e);this.setChainParentage_(a,t),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,t===m?this.m_universeGeomID:m):this.setChainParentage_(i,t)}else 1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,e===m?this.m_universeGeomID:m):this.setChainParentage_(i,e)}}tryOptimizedInsertion_(e,t,s,n,r){let i=r,h=-1,m=o.n,l=0;do{if(2===l)return!1;const e=this.getHalfEdgeUserIndex(i,t);if(-1!==e){if(-1!==h)return!1;h=e}else{if(m!==o.n)return!1;m=i}l++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return m!==o.n&&-1!==h&&(this.setHalfEdgeUserIndex(e.getElement(h),t,a.S.impossibleIndex2()),e.setElement(h,m),s.push(h),!0)}trySetChainParentFromTwin_(e,t){const s=this.getChainArea(e);if(0===s)return!1;const n=this.getChainArea(t);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(e,t),!0;{const s=this.getChainParent(t);if(s!==o.n)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=t.size();s<n;s++){const n=t.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),a=this.m_shape.getPathFromVertex(n),h=this.m_shape.getGeometryFromPath(a),m=this.m_shape.getGeometryType(h);if((0,i.h)(m)){const t=this.m_shape.getNextVertex(n);if(t===o.n)continue;const s=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(r===s)continue;const a=this.newHalfEdgePair_(),l=this.getHalfEdgeTwin(a),g=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(g,0,n),this.m_clusterVertices.setField(g,1,-1),this.setHalfEdgeVertexIterator_(a,g),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,a),this.setHalfEdgeOrigin_(a,r);const c=this.getClusterHalfEdge(r);if(c===o.n)this.setClusterHalfEdge_(r,a),this.setHalfEdgePrev_(a,l),this.setHalfEdgeNext_(l,a);else{const e=this.getHalfEdgePrev(c);this.setHalfEdgePrev_(c,l),this.setHalfEdgeNext_(l,c),this.setHalfEdgeNext_(e,a),this.setHalfEdgePrev_(a,e)}this.setHalfEdgeOrigin_(l,s);const u=this.getClusterHalfEdge(s);if(u===o.n)this.setClusterHalfEdge_(s,l),this.setHalfEdgeNext_(a,l),this.setHalfEdgePrev_(l,a);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,a),this.setHalfEdgeNext_(a,u),this.setHalfEdgeNext_(e,l),this.setHalfEdgePrev_(l,e)}const _=this.getGeometryID(h);if(e===X.enumInputModeBuildGraph){const e=m===i.G.enumPolygon?_:0;if(this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new O,t=this.m_shape.getGeometryUserIndex(h,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(a,e),this.setEdgeBitSet_(l,null),this.setLeftEdgeBitSet_(l,e),this.setLeftEdgeBitSet_(a,null)}}else if(e===X.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(n),s=this.m_shape.getXY(t);let r=0,i=0;e.compare(s)<0?r=1:i=-1,this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,r),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,i)}else e===X.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const p=m===i.G.enumPolygon?K.c_EdgeBitMask:0;this.setHalfEdgeParentage_(a,_|p),this.setHalfEdgeParentage_(l,_|p)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,s=t.size();e<s;e++){const s=t.read(e);if(this.m_shape.getSegment(s)){const e=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);e!==o.n&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{const s=this.getHalfEdgeVertexIterator(t);if(s!==o.n){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,o.n)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==o.n){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,o.n)}}if(-1!==this.m_segmentIndexHe){let r=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==r){if(-2===r){const s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,s)}if(r=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===r){const e=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){const t=[];for(let s=this.getFirstCluster();s!==o.n;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==o.n){let r=n;do{t.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(t.length>1){let r=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=(0,h.c)(t[0],t[0]=t[1]):r=!1;let i=t[0],a=i,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a),g=o.n;for(let s=1,n=t.length;s<n;s++){const n=t[s],r=this.getHalfEdgeTwin(n),h=this.getHalfEdgeOrigin(r);if(h!==m||n===a)this.updateVertexToHalfEdgeConnection_(g,!1),g=o.n,a=n,m=h,l=r;else{if(e===X.enumInputModeBuildGraph){const e=this.getHalfEdgeParentageMask_(a)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(a,e),this.setHalfEdgeParentage_(l,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(l,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(l,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,s;e=this.getEdgeBitSet_(a),t=this.getEdgeBitSet_(n),s=new O({copy:e}),s.assignOr(t),this.setEdgeBitSet_(a,s),e=this.getEdgeBitSet_(l),t=this.getEdgeBitSet_(r),s=new O({copy:e}),s.assignOr(t),this.setEdgeBitSet_(l,s),e=this.getLeftEdgeBitSet_(a),t=this.getLeftEdgeBitSet_(n),s=new O({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(a,s),e=this.getLeftEdgeBitSet_(l),t=this.getLeftEdgeBitSet_(r),s=new O({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(l,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const e=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const e=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(a,n),this.deleteEdgeImpl_(n),g=a,t[s]=o.n,n===i&&(t[0]=o.n,i=o.n)}}if(this.updateVertexToHalfEdgeConnection_(g,!1),g=o.n,!r){i=o.n;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==o.n){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=o.n;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===o.n)continue;if(i===o.n){i=s,a=i,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a);continue}if(s===a)continue;const n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(l,s),this.setHalfEdgePrev_(s,l),a=s,m=r,l=n}this.setClusterHalfEdge_(s,i)}}}}sortHalfEdgesByAngle3D_(e){(0,i.g)(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,o.n);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==o.n;e=this.getNextCluster(e)){const n=this.getClusterHalfEdge(e);if(n!==o.n){let e=n;do{if(1!==this.getHalfEdgeUserIndex(e,s)){const n=this.newChain_();this.setChainHalfEdge_(n,e),this.setChainPrev_(n,t),this.setChainNext_(t,n);let r=null;this.m_bBuildGeometryParentageSets&&(r=new O),t=n;let i=0,o=e;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(i|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&r.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,n),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==e);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(n,r),this.setChainParentage_(n,i)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==n)}}this.m_chainAreas=new a.A(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new a.A(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_(e){(0,i.g)(0)}simplifyAlternate_(){(0,i.g)(0)}simplifyWinding_(){(0,i.g)(0)}setEditShapeImpl_(e,t,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let m=this.m_shape.getTotalPointCount();if(s){m=0;for(let e=0,t=s.length;e<t;e++)m+=this.m_shape.getPointCount(s[e])}const l=new a.a(0);let g=0,c=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==o.n;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,c++);for(let t=this.m_shape.getFirstPath(e);t!==o.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,n=this.m_shape.getPathSize(t);s<n;s++)l.add(e),e=this.m_shape.getNextVertex(e)}(0,i.e)(this.m_shape.getGeometryType(e))||(g+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:o.n,t++):e=this.m_shape.getNextGeometry(e)}}this.m_universeGeomID=1<<Math.min(c,31),this.m_pointCount=l.size(),this.m_shape.sortVerticesSimpleByY(l,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,g)),this.m_clusterIndex=this.m_shape.createUserIndex();const u=h.P.getNAN();let _=0;const p=h.P.getNAN();for(let e=0;e<=this.m_pointCount;e++){if(e<this.m_pointCount){const t=l.read(e);this.m_shape.queryXY(t,p)}else p.setNAN();if(!u.isEqualPoint2D(p)){if(_<e){const t=this.newCluster_();let s=o.n,n=-1;for(let r=_;r<e;r++){n=l.read(r),this.m_shape.setUserIndex(n,this.m_clusterIndex,t);const e=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(e,0,n),this.m_clusterVertices.setField(e,1,s),s=e;const i=this.m_shape.getPathFromVertex(n),o=this.m_shape.getGeometryFromPath(i),a=this.getGeometryID(o);this.setClusterParentage_(t,this.getClusterParentage(t)|a)}this.setClusterVertexIterator_(t,s),this.setClusterVertexIndex_(t,this.m_shape.getVertexIndex(n)),this.m_lastCluster!==o.n&&this.setNextCluster_(this.m_lastCluster,t),this.setPrevCluster_(t,this.m_lastCluster),this.m_lastCluster=t,this.m_firstCluster===o.n&&(this.m_firstCluster=t)}_=e,u.setCoordsPoint2D(p)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){const t=l.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){const e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(n,!0);{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==o.n;){for(let t=this.m_shape.getFirstPath(e);t!==o.n;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){const e=this.m_shape.getFirstVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(t)){const e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}}null!=s?(e=t<s.length?s[t]:o.n,t++):e=this.m_shape.getNextGeometry(e)}}if(t===X.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===X.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===X.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,l),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(t),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,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_(e,t,s,n,r){(0,i.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,i.g)(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){const t=this.getHalfEdgeNext(e),s=this.getHalfEdgePrev(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeNext(n),i=this.getHalfEdgePrev(n);t!==n&&(this.setHalfEdgeNext_(i,t),this.setHalfEdgePrev_(t,i)),s!==n&&(this.setHalfEdgeNext_(s,r),this.setHalfEdgePrev_(r,s));const a=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(a)===e&&(r!==e?this.setClusterHalfEdge_(a,r):this.setClusterHalfEdge_(a,o.n));const h=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(h)===n&&(t!==n?this.setClusterHalfEdge_(h,t):this.setClusterHalfEdge_(h,o.n)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(e,t){let s=t;for(;;){if(s=e.getPrev(s),-1===s)return o.n;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=(0,h.a)(this.m_checkDirtyPlanesweepTolerance),t=new h.P,s=new h.P,n=new h.P,r=new h.P,i=new h.P;for(let a=this.getFirstCluster();a!==o.n;a=this.getNextCluster(a)){const h=this.getClusterHalfEdge(a);if(h!==o.n){let o=h;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,s),n.setSub(s,t);let a=n.sqrLength();do{const h=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==h){this.getHalfEdgeToXY(o,r),i.setSub(r,t);const h=i.sqrLength(),m=i.crossProduct(n),l=m*m/(h*a);if(Math.min(h,a)*l<=e&&i.dotProduct(n)>=0)return!1;n.assign(i),a=h,s.assign(r)}}while(o!==h)}}return!0}extractPolygonPathFromChain_(e,t,s,n,r){const i=this.m_shape.hasSegmentParentage(),h=this.getChainHalfEdge(s);let m=h,l=o.n;const g=new a.P;do{const a=this.getHalfEdgeTwin(m);if(this.getHalfEdgeChain(a)!==s){let s=o.n;const a=this.getHalfEdgeOrigin(m);if(n===o.n){const e=this.getClusterVertexIterator(a);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(a);e!==o.n;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===o.n&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let h;if(l===o.n&&(l=e.insertPath(t,o.n),e.setClosedPath(l,!0)),this.m_shape===e?h=e.addVertex(l,s):(this.m_shape.queryPoint(s,g),h=e.addPoint(l,g)),this.isHalfEdgeCurve(m)&&(this.querySegmentXY(m,r),e.setSegmentToIndex(e.getVertexIndex(h),r.get().clone())),i){const t=this.getSegmentParentage(m);e.setSegmentParentageAndBreak(h,t,this.isBreakNode(a))}}m=this.getHalfEdgeNext(m)}while(m!==h)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;(0,i.g)(-1!==this.m_clusterBreakNodeIndex),(0,i.g)(-1===this.m_segmentParentageIndex);for(let e=this.getFirstCluster();e!==o.n;e=this.getNextCluster(e)){let t=0;const s=this.getClusterHalfEdge(e);if(s!==o.n){let e=s;do{t++,e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==s&&t<3)}2!==t&&this.setBreakNode(e,!0)}let e=[],t=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==o.n;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==o.n){let n=!1,i=r;do{let r=i;for(;-1===this.getHalfEdgeUserIndex(r,s);){const i=this.getHalfEdgeNext(r),o=this.getHalfEdgeTwin(r);Z(this,r,t);const a=t.at(-1).parentage;if(!n){const t=this.getHalfEdgeOrigin(r);if(!this.isBreakNode(t)){const t=this.getHalfEdgePrev(r);r!==t&&(Z(this,t,e),n=!0)}}if(n&&!j(t,e)){const e=this.getHalfEdgeOrigin(r);this.setBreakNode(e,!0)}e=(0,h.c)(t,t=e),n=!0;const m=this.getHalfEdgeOrigin(i);this.isBreakNode(m)&&(n=!1),this.setHalfEdgeUserIndex(r,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(r,s,1),this.setHalfEdgeUserIndex(o,s,1),r=i}i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==r)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(e){return null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=new Y(e=>e.getHashCode(),(e,t)=>e.equals(t)),this.m_uniqueBitSets.add(this.getEmptySet())),null===e?this.getEmptySet():this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return(0,i.g)(t>=0),(0,i.g)(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return(0,i.g)(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setLeftEdgeBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setChainBitSet_(e,t){(0,i.g)(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(e,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=t:(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new O),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_(e){}dbgVerifyEdgeSegment(e){}}K.c_EdgeParentageMask=~(1<<31),K.c_EdgeBitMask=1<<31;class Q{freeNode_(e){this.m_listNodes.deleteElement(e)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){this.m_lists.deleteElement(e)}newList_(){return this.m_lists.newElement()}Init_(e){(0,i.g)(0)}constructor(e){this.m_listNodes=new a.S(2),this.m_listOfLists=Q.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new a.S(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==Q.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,e),this.m_listOfLists=e),e}deleteList(e){let t=this.getFirst(e);for(;t!==Q.st_nullNode();){const e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==Q.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==Q.st_nullNode()&&this.m_lists.setField(s,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);const s=this.m_lists.getField(e,1),n=this.newNode_();return s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,n)):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,n)),this.m_listNodes.setField(n,0,t),n}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,s){t!==Q.st_nullNode()?(this.m_listNodes.setField(t,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,t)):(this.m_lists.setField(e,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,Q.st_nullNode())),this.freeNode_(s)}deleteElementSearch(e,t){let s=-1,n=this.getFirst(e);for(;n!==t;)s=n,n=this.getNext(n);this.deleteElementDirect(e,s,t)}concatenateLists(e,t){const s=this.m_lists.getField(e,1),n=this.m_lists.getField(t,0);if(n!==Q.st_nullNode()&&(s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==Q.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==Q.st_nullNode()&&this.m_lists.setField(s,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){(0,i.g)(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){const t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=Q.st_nullNode()}isEmpty(e){return(0,i.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(e){return this.m_lists.getField(e,3)}}function J(e=-1){return{m_value:e,m_line:new o.L,m_segment:null,m_segmentInfo:new o.a7(-1),m_env:new h.E(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class $ extends a.a6{constructor(e,t,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new _.NonSimpleResult,this.m_tempSimpleEdge1=J(),this.m_tempSimpleEdge2=J(),this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.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 h.P,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*e.getTotalPointCount()/2,67)),r=Math.min(7,n);this.m_simpleEdgesCache.length=r}tryGetCachedEdge_(e){const t=this.m_simpleEdgesCache[(e&(0,h.j)())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&(0,h.j)())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[t];s&&s.m_value===e&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){const t=(e&(0,h.j)())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[t];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=J(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=e,this.m_simpleEdgesCache[t]=s,s)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=null!==e.m_segment,e.m_bCurve){const t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){const s=e.getStartXY(),n=e.getEndXY(),r=t.getStartXY(),i=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(r)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(i)<0?n:i);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-r)>this.m_tolerance)return s<r?-1:1}const o=s.compare(r)<0?r:s,a=n.compare(i)<0?n:i;let m=0,l=0;for(let s=1;s<5;s++){(0,h.U)(o,a,s/5,this.m_ptSweep);const n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=Math.abs(n-r);i>m&&(m=i,l=n<r?-1:1)}return 0===l?this.errorCracking():l}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);const s=this.compareNonHorizontalLowerEnd_(e,t),n=this.compareNonHorizontalUpperEnd_(e,t);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(e,t){const s=h.P.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=h.P.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=h.P.getNAN();r.setSub(e.getEndXY(),t.getStartXY());const i=n.dotProduct(s),o=r.dotProduct(s),a=Math.abs(i),m=Math.abs(o);if(a<m){if(a<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return i<0&&o<0?-1:i>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let s=1;if(e.m_line.getStartY()<t.m_line.getStartY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getStartX()-r.getStartX(),o=t.m_dxdy*(n.getStartY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}compareNonHorizontalUpperEnd_(e,t){let s=1;if(t.m_line.getEndY()<e.m_line.getEndY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getEndX()-r.getStartX(),o=t.m_dxdy*(n.getEndY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new _.NonSimpleResult(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const e=6;this.m_nonSimpleResult=new _.NonSimpleResult(e,this.m_vertex1,this.m_vertex2)}else this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n;return-1}compareSegments_(e,t,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 e=s.m_bHorizontal?1:0;return e|=n.m_bHorizontal?2:0,0===e?this.compareNonHorizontal_(s,n):1===e?this.compareHorizontal1_(s.m_line,n.m_line):2===e?-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 i,a;if(r&&e===this.m_prev1?i=this.m_prevX1:(i=Number.NaN,this.m_prev1=o.n),r&&t===this.m_prev2?a=this.m_prevX2:(a=Number.NaN,this.m_prev2=o.n),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(i)){this.m_prev1=e;const t=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);i=t,this.m_prevX1=t}if(Number.isNaN(a)){this.m_prev2=t;const e=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=e,this.m_prevX2=e}const h=(0,o.Y)(!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(i-a)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):i<a?-1:i>a?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=t;return this.m_currentNode=s,this.compareSegments(r,r,n,n)}compareSegments(e,t,s,n){let r=this.tryGetCachedEdge_(e);null===r?this.m_vertex1===t?r=this.m_tempSimpleEdge1:(this.m_vertex1=t,r=this.tryCreateCachedEdge_(e),null===r&&(r=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(r,t)):this.m_vertex1=t;let i=this.tryGetCachedEdge_(s);return null===i?this.m_vertex2===n?i=this.m_tempSimpleEdge2:(this.m_vertex2=n,i=this.tryCreateCachedEdge_(s),null===i&&(i=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(i,n)):this.m_vertex2=n,this.compareSegments_(t,n,r,i)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class ee{constructor(e,t){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=h.P.getNAN(),this.m_line1=new o.L,this.m_seg1=null,this.m_env=h.E.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){const s=e.getElement(t);return this.compareVertex(e,t,s)}compareVertex(e,t,s){let n,i=this.m_shape.getSegment(s),a=!0;if(null==i)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),i=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=r.Envelope2D.constructEmpty();i.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),n=0===e.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=t,this.m_bIntersectionDetected=!0,0;let m=0;if(a){(0,o.a0)(this.m_line1);const e=this.m_line1.getStartXY(),t=new h.P;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new h.P;s.setSub(this.m_pointOfInterest,e),m=t.dotProduct(s),m/=t.length()}else m=i.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x;return m<10*-this.m_tolerance?-1:m>10*this.m_tolerance?1:(i.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(m)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=m),this.m_bIntersectionDetected=!0),m<0?-1:m>0?1:0)}}class te{constructor(e,t){this.m_lists=new Q(!1),this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(te.st_nullNode()),this.m_bitFilter=new Int32Array(10*e+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=t%this.m_hashBuckets.length;let r=this.m_hashBuckets[n];return r===Q.st_nullNode()&&(r=this.m_lists.createList(),this.m_hashBuckets[n]=r),this.m_lists.addElement(r,e)}deleteElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%this.m_hashBuckets.length,n=this.m_hashBuckets[s];n===Q.st_nullNode()&&(0,i.a)("");let r=this.m_lists.getFirst(n),o=Q.st_nullNode();for(;r!==Q.st_nullNode();){const t=this.m_lists.getData(r),i=this.m_lists.getNext(r);t===e?(this.m_lists.deleteElementDirect(n,o,r),this.m_lists.getFirst(n)===Q.st_nullNode()&&(this.m_lists.deleteList(n),this.m_hashBuckets[s]=Q.st_nullNode())):o=r,r=i}}getFirstInBucket(e){const t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(31&t)))return Q.st_nullNode();const s=e%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===Q.st_nullNode()?Q.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){const t=this.m_hash.getHash(e);let s=this.getFirstInBucket(t);for(;s!==Q.st_nullNode();){const t=this.m_lists.getData(s);if(this.m_hash.equal(t,e))return s;s=this.m_lists.getNext(s)}return Q.st_nullNode()}deleteNode(e){const t=this.getElement(e),s=this.m_hash.getHash(t)%this.m_hashBuckets.length,n=this.m_hashBuckets[s];n===Q.st_nullNode()&&(0,i.a)(""),this.m_lists.deleteElementSearch(n,e),this.m_lists.getFirst(n)===Q.st_nullNode()&&(this.m_lists.deleteList(n),this.m_hashBuckets[s]=Q.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return Q.st_nullNode()}clear(){(0,i.g)(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function se(e,t,s,n,r){const i=new ae(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=n,i.m_bHasSegmentParentage=e.hasSegmentParentage(),i.clusterNonReciprocal()}function ne(e,t,s,n,r){const i=e-s,o=t-n;return i*i+o*o<=r}function re(e,t,s,n,r,i){const o={pt:new h.P,weight:0,rank:0,bMerged:!1},a=s+r;let m=!1,l=e.x;e.x!==t.x&&(n===i&&(l=(e.x*s+t.x*r)/a),m=!0);let g=e.y;return e.y!==t.y&&(n===i&&(g=(e.y*s+t.y*r)/a),m=!0),n!==i?n>i?(o.rank=n,o.weight=s,o.pt=e):(o.rank=i,o.weight=r,o.pt=t):(o.pt.setCoords(l,g),o.weight=a,o.rank=n),o.bMerged=m,o}function ie(e,t){const s=(0,h.aK)(e);return(0,h.aF)(s,t)}class oe{constructor(e,t,s,n,r){this.m_workPt=new h.P,this.m_shape=e,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=t.clone(),this.m_hashValues=r}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);const t=this.m_workPt.x-this.m_origin.x,s=Math.trunc(t*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return ie(s,Math.trunc(n*this.m_invCellSize+.5))}equal(e,t){return(0,i.g)(0),!1}}class ae{constructor(e){this.m_origin=h.P.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=o.n,this.m_bucketArray=(0,h.d)(4,Number.NaN),this.m_bucketHash=(0,h.d)(4,Number.NaN),this.m_dbgCandidateCheckCount=0,this.m_nsr=new _.NonSimpleResult,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new Q,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){const s=h.P.getNAN();this.m_shape.queryXY(e,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,r=(s.y-this.m_origin.y)*this.m_invCellSize,i=Math.trunc(n),o=Math.trunc(r);let a=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1){const s=ie(i+e,o+t),n=this.m_hashTable.getFirstInBucket(s);n!==te.st_nullNode()&&(this.m_bucketArray[a]=n,this.m_bucketHash[a]=s,a++)}for(let e=a-1;e>=1;e--){const t=this.m_bucketArray[e];for(let s=e-1;s>=0;s--)if(t===this.m_bucketArray[s]){this.m_bucketHash[s]=-1,a--,e!==a&&(this.m_bucketHash[e]=this.m_bucketHash[a],this.m_bucketArray[e]=this.m_bucketArray[a]);break}}for(let n=0;n<a;n++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[n],s,this.m_bucketArray[n],t)}collectNearestNeighbourCandidates(e,t,s,n,r){const i=h.P.getNAN();for(let o=n;o!==te.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);e===n||-1!==t&&this.m_shape.getUserIndex(n,this.m_hashValues)!==t||(this.m_shape.queryXY(n,i),ne(s.x,s.y,i.x,i.y,this.m_sqrTolerance)&&r.push(o))}}mergeClusters(e,t,s){let n=this.m_shape.getUserIndex(e,this.m_newClusters);const r=this.m_shape.getUserIndex(t,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,e),this.m_shape.setUserIndex(e,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,t):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(t,this.m_newClusters,a.S.impossibleIndex2());const i=this.mergeVertices(e,t);if(s){const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return i}mergeVertices(e,t){const s=h.P.getNAN();this.m_shape.queryXY(e,s);const n=h.P.getNAN();this.m_shape.queryXY(t,n);const r=this.m_shape.getRank(e),i=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),a=this.m_shape.getWeight(t);let m,l,g,c,u=!1;if(r===i?(m=r,l=o+a,g=s.x,s.x!==n.x&&(g=(s.x*o+n.x*a)/l,u=!0),c=s.y,s.y!==n.y&&(c=(s.y*o+n.y*a)/l,u=!0)):(r>i?(g=s.x,c=s.y,l=o,m=r):(g=n.x,c=n.y,l=a,m=i),u=!s.equals(n)),u&&(this.m_shape.setXYMonotonic(e,g,c),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,s),this.m_shape.setSegmentParentageBreakVertex(t,s)}return this.m_shape.setWeight(e,l),this.m_shape.setRank(e,m),u}needsClustering(){const e={stack:[],error:void 0,hasError:!1};try{(0,n.mS)(e,(0,h.h)(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);const t=this.m_shape.getSelectedCount(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const r=Math.max(s.height(),s.width())/((0,h.i)()-1);this.m_cellSize<r&&(this.m_cellSize=r,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 oe(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new te(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==o.n;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===a.S.impossibleIndex2())continue;let s;if(0===e?(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,t),0!==t.length){for(let e=0,s=t.length;e<s;e++){this.progress_();const s=t[e],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new _.NonSimpleResult(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return i}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}clusterNonReciprocal(){const e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();const s=Math.max(t.height(),t.width())/((0,h.i)()-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 oe(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new te(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==o.n;t=e.next()){this.progress_();const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{const e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=t.next();s!==o.n;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===a.S.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,t);let r=!1;for(;this.collectClusterCandidates(s,e),0!==e.length;){let t=0;for(let n=0,r=e.length;n<r;n++){this.progress_();const i=e[n],o=this.m_hashTable.getElement(i);this.m_hashTable.deleteNode(i);const a=n+1===r;t|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==t,n||=0!==t,e.length=0,!t)break}r&&(t=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,t)}e.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 e=h.P.getNAN();for(let t=this.m_clusters.getFirstList();t!==Q.st_nullNode();t=this.m_clusters.getNextList(t)){let s=this.m_clusters.getFirst(t);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,e);const r=this.m_shape.getRank(n),i=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==Q.st_nullNode();s=this.m_clusters.getNext(s)){const t=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(n,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,i),this.m_shape.setRank(t,r)}}}}class he{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 a.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_(e,t,s,n,r,i,o,a,h,m){return function(e,t,s,n,r,i,o,a,h,m){return{segmentIndex:e,weightStart:t,rankStart:s,weightEnd:n,rankEnd:r,weightInterior:i,rankInterior:o,segmentParentage:m,u:me(a,h)}}(e,t,s,n,r,i,o,a,h,m)}pushSegment(e,t,s,n,r,i,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,s,n,r,i,o,a,h,m)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?0===e?this.m_param1.length-1:this.m_param2.length-1:0===e?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return 0===e?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return 0===e?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){2!==this.m_inputSegments.length&&(0,i.d)(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=(0,h.a)(e*he.c_smallToleranceFactor);let n=!1;const r=this.m_inputParts[0],a=this.m_inputParts[1],m=this.m_inputSegments[r.segmentIndex],l=this.m_inputSegments[a.segmentIndex];if(t||5&(0,o.Q)(!0,m,l,e,!0)){const t=(0,o.Z)(!0,m,l,null,this.m_param1,this.m_param2,e);0===t&&(0,i.d)("");const g=new Array(t);for(let e=0;e<t;++e)g[e]=h.P.getNAN();const c=new Float64Array(t),u=new Int32Array(t),_=new Array(t),p=new Array(t);for(let e=0;e<t;++e)_[e]=le(),p[e]=le();for(let e=0;e<t;e++){const t=this.m_param1[e],i=this.m_param2[e];let o,d=r.rankInterior,f=r.weightInterior;0===t?(d=r.rankStart,f=r.weightStart,o=r.u.bBreakStart):1===t?(d=r.rankEnd,f=r.weightEnd,o=r.u.bBreakEnd):(this.m_changed1=!0,o=!1);let x,P=a.rankInterior,E=a.weightInterior;0===i?(P=a.rankStart,E=a.weightStart,x=a.u.bBreakStart):1===i?(P=a.rankEnd,E=a.weightEnd,x=a.u.bBreakEnd):(this.m_changed2=!0,x=!1);const y=d,S=P;let C=1,I=0,v=h.P.getNAN();if(y===S){const n=m.getCoord2D(t),r=l.getCoord2D(i);C=f+E,I=d,(0,h.U)(n,r,E/C,v);const o=h.P.sqrDistance(v,n),a=h.P.sqrDistance(v,r);_[e].bBigMove=o>s,p[e].bBigMove=a>s,this.m_changed1||n.equals(v)||(this.m_changed1=!0),this.m_changed2||r.equals(v)||(this.m_changed2=!0)}else if(y>S){v=m.getCoord2D(t);const n=l.getCoord2D(i);C=f,I=d;const r=h.P.sqrDistance(v,n);_[e].bBigMove=!1,p[e].bBigMove=r>s,this.m_changed2||n.equals(v)||(this.m_changed2=!0)}else{v=l.getCoord2D(i),C=E,I=P;const n=m.getCoord2D(t),r=h.P.sqrDistance(v,n);_[e].bBigMove=r>s,p[e].bBigMove=!1,this.m_changed1||n.equals(v)||(this.m_changed1=!0)}g[e].assign(v),c[e]=C,u[e]=I,_[e].bIsBreak=o||x,p[e].bIsBreak=o||x,n||=_[e].bBigMove||p[e].bBigMove}const d=r.rankInterior,f=r.weightInterior;let x=0,P=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param1[s]:1;if(n!==x){const i=this.allocResultSegment(),o=this.m_resultSegments[i];let a,l,p,E;m.queryCut(x,n,o,!1),o.get().snapControlPoints(e*e);let y=!1,S=!1,C=!1,I=!1,v=!1,b=h.P.getNAN(),G=h.P.getNAN();-1!==P?(l=u[P],a=c[P],y=_[P].bBigMove,b.assign(g[P]),C=_[P].bIsBreak,v=!0):(a=r.weightStart,l=r.rankStart,b=o.get().getStartXY(),C=r.u.bBreakStart),s<t?(E=u[s],p=c[s],S=_[s].bBigMove,G.assign(g[s]),I=_[s].bIsBreak,v=!0):(p=r.weightEnd,E=r.rankEnd,G=o.get().getEndXY(),I=r.u.bBreakEnd),v&&o.get().setCoordsForIntersector(b,G,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,a,l,p,E,f,d,C,I,r.segmentParentage));const w=this.m_resultParts1.at(-1);w.u.bBigMoveStart=y,w.u.bBigMoveEnd=S,x=n,P=s}else-1===P&&(P=s)}const E=(0,h.d)(t,0);for(let e=0;e<t;e++)E[e]=e;t>2?(E.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:this.m_param2[e]>this.m_param2[t]?1:0),(0,h.v)(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=(0,h.c)(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),E[1]=(0,h.c)(E[0],E[0]=E[1]));const y=a.rankInterior,S=a.weightInterior;x=0,P=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param2[s]:1;if(n!==x){const r=this.allocResultSegment(),i=this.m_resultSegments[r];let o,m,_,d;l.queryCut(x,n,i,!1),i.get().snapControlPoints(e*e);let f=h.P.getNAN(),C=h.P.getNAN(),I=!1,v=!1,b=!1,G=!1,w=!1;if(-1!==P){const e=E[P];o=c[e],m=u[e],f.assign(g[e]),b=p[e].bBigMove,I=p[e].bIsBreak,w=!0}else o=a.weightStart,m=a.rankStart,f=i.get().getStartXY(),I=a.u.bBreakStart;if(s!==t){const e=E[s];_=c[e],d=u[e],C.assign(g[e]),G=p[e].bBigMove,v=p[e].bIsBreak,w=!0}else _=a.weightEnd,d=a.rankEnd,C=i.get().getEndXY(),v=a.u.bBreakEnd;w&&i.get().setCoordsForIntersector(f,C,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,o,m,_,d,S,y,I,v,a.segmentParentage));const N=this.m_resultParts2.at(-1);N.u.bBigMoveStart=b,N.u.bBigMoveEnd=G,x=n,P=s}else-1===P&&(P=s)}return n?3:2}return 0}intersectLines3D(e,t,s,n){return(0,i.g)(0),1}intersect2D(e,t){const s=this.m_inputParts[0],n=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[n.segmentIndex].getGeometryType();return r!==i.G.enumLine||o!==i.G.enumLine?new _e(this).intersectCurves(e,t):this.intersectLines(e,t)}intersect2DEx(e,t,s,n,r){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&(0,i.d)(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const o=(0,h.a)(e*he.c_smallToleranceFactor);let a=!1;const m=this.m_inputParts[0],l=this.m_inputSegments[m.segmentIndex];if(r||l.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=(0,h.d)(16,Number.NaN);const r=l.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let i=m.rankInterior,g=m.weightInterior;0===r?(i=m.rankStart,g=m.weightStart):1===r?(i=m.rankEnd,g=m.weightEnd):this.m_changed1=!0;let c=i;const u=s,_=n;c===u&&l.isCurve()&&(c=u+1);let p=1,d=0;const f=new h.P;if(c===u){const e=l.getCoord2D(r),s=t.getXY();p=g+_,d=i,(0,h.U)(e,s,_/p,f),this.m_changed1||e.equals(f)||(this.m_changed1=!0),this.m_changed2||s.equals(f)||(this.m_changed2=!0),a=h.P.sqrDistance(f,e)>o}else c>u?(f.assign(l.getCoord2D(r)),p=g,d=i,this.m_changed2||f.equals(t.getXY())||(this.m_changed2=!0)):(f.assign(l.getCoord2D(r)),p=_,d=u,this.m_changed1||f.equals(t.getXY())||(this.m_changed1=!0),a=h.P.sqrDistance(f,t.getXY())>o);let x=0,P=-1;const E=1;for(let t=0;t<=E;t++){const s=t<E?this.m_param1[0]:1;if(s!==x){const n=this.allocResultSegment(),r=this.m_resultSegments[n];l.queryCut(x,s,r),r.get().snapControlPoints(e*e);let i=m.weightStart,o=m.weightEnd,a=m.rankStart,h=m.rankEnd;const g=m.rankInterior,c=m.weightInterior;let u=m.u.bBreakStart,_=m.u.bBreakEnd;-1!==P&&(i=p,a=d,u=!0,r.get().setCoordsForIntersector(f,r.get().getEndXY(),!0)),t!==E&&(o=p,h=d,_=!0,r.get().setCoordsForIntersector(r.get().getStartXY(),f,!0)),x=s,this.m_resultParts1.push(this.newIntersectionPart_(n,i,a,o,h,c,g,u,_,m.segmentParentage))}P=t}return this.m_point.setXY(f),this.m_pointWeight=p,this.m_pointRank=d,a?3:2}return 0}intersect3D(e,t,s,n){return(0,i.g)(0),1}intersect3DEx(e,t,s,n,r,o,a){return(0,i.g)(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new o.S,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new o.S({copy:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new o.S({segment:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}}function me(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function le(){return{bBigMove:!1,bIsBreak:!1}}he.maxWeight=.1*Number.MAX_VALUE,he.c_smallToleranceFactor=.01,he.c_maxGeometryTypeToRankDelta=8;let ge=class{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(e,t,s){if(1===t.getDescription().getAttributeCount())return;const n=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),i=new a.P;t.queryStart(i),s?(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i)):(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)),t.queryEnd(i),s?(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)):(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i))}copyFromWhenOverlap(e,t,s){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,s?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class ce{constructor(){this.hash=0,this.pt=new h.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(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;null!==e.prevEqual;e=e.prevEqual);return e}}function ue(e,t,s,n){return{edge1:e,edge2:t,recursion:s,bIsIntersecting:n}}class _e{constructor(e){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 h.P,this.m_cell=new h.P,this.parent=e}addSegment(e,t,s,n,r,o,a,h,m,l,g){const c=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,m),u=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,o,l);this.newEdge(c,u,e,a,h,g),null===this.m_chainOrigin1?this.m_chainOrigin1=c:null===this.m_chainOrigin2?this.m_chainOrigin2=c:(0,i.g)(0)}intersectCurvesHelper(e,t,s,n,r){const a=this.getSegment(e).get(),m=this.getSegment(t).get();if(a.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(e,t,s,n);if(0!==l)return l;const g=(0,h.a)(.01*s);let c=!1,u=this.processSharpCorners(a,m,s,r>4);const _=u>0;if(!_){if(!(n||5&(0,o.Y)(!0,!1,a,m,s,!0)))return 0;u=(0,o.Z)(!0,a,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===u&&(0,i.d)("");const p=a.getGeometryType(),d=m.getGeometryType(),f=(0,h.m)(h.P,u),x=(0,h.m)(h.P,u),P=(0,h.d)(u,Number.NaN),E=(0,h.d)(u,Number.NaN),y=(0,h.d)(u,Number.NaN),S=(0,h.d)(u,Number.NaN),C=(0,h.n)(le,u),I=(0,h.n)(le,u);let v=!1,b=!1;for(let n=0;n<u;n++){const r=this.parent.m_param1[n],i=this.parent.m_param2[n];let o=e.rank,l=e.weight,u=!0,G=!1;0===r?(o=e.start.rank,l=e.start.weight,G=e.start.bIsBreak):1===r?(o=e.end.rank,l=e.end.weight,G=e.end.bIsBreak):(v=!0,u=!1);let w=t.rank,N=t.weight,T=!1,D=!0;0===i?(w=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===i?(w=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(b=!0,D=!1);let V=o,k=w;if(V===k&&(V*=he.c_maxGeometryTypeToRankDelta,k*=he.c_maxGeometryTypeToRankDelta,V+=pe(p,a,!1),k+=pe(d,m,!1)),u&&D&&k===V){const e=a.getCoord2D(r),t=m.getCoord2D(i);e.equals(t)&&(k=V-1)}let F=1,H=0,A=1,M=0;const U=new h.P,q=new h.P,O=a.getCoord2D(r),Y=m.getCoord2D(i);if(_&&h.P.distance(O,Y)>s)U.setCoordsPoint2D(O),q.setCoordsPoint2D(Y),F=l,A=N,H=o,M=w,C[n].bBigMove=!1,I[n].bBigMove=!1,G=!0,T=!0;else if(V===k){A=F=l+N,M=H=o,(0,h.U)(O,Y,N/F,U),q.setCoordsPoint2D(U);const e=h.P.sqrDistance(U,O),t=h.P.sqrDistance(U,Y);C[n].bBigMove=e>g,I[n].bBigMove=t>g,v||O.equals(U)||(v=!0),b||Y.equals(q)||(b=!0)}else if(V>k){U.setCoordsPoint2D(O),q.setCoordsPoint2D(U),A=F=l,M=H=o;const e=h.P.sqrDistance(U,Y);C[n].bBigMove=!1,I[n].bBigMove=e>g,b||Y.equals(q)||(b=!0)}else{q.setCoordsPoint2D(Y),U.setCoordsPoint2D(q),A=F=N,M=H=w;const e=h.P.sqrDistance(U,O);C[n].bBigMove=e>g,I[n].bBigMove=!1,v||O.equals(U)||(v=!0)}f[n].assign(U),x[n].assign(q),P[n]=F,E[n]=A,y[n]=H,S[n]=M,C[n].bIsBreak=G||T,I[n].bIsBreak=G||T,c||=C[n].bBigMove||I[n].bBigMove,n>0&&(r!==this.parent.m_param1[n-1]&&i!==this.parent.m_param2[n-1]||(y[n]<=y[n-1]?(f[n].assign(x[n-1]),P[n]=E[n-1],y[n]=S[n-1],x[n].assign(x[n-1]),E[n]=E[n-1],S[n]=S[n-1],C[n].bBigMove||=C[n-1].bBigMove,I[n].bBigMove||=I[n-1].bBigMove,C[n].bIsBreak||=C[n-1].bIsBreak,I[n].bIsBreak||=I[n-1].bIsBreak):(f[n-1].assign(f[n]),P[n-1]=P[n],y[n-1]=y[n],x[n-1].assign(x[n]),E[n-1]=E[n],S[n-1]=S[n],C[n-1].bBigMove||=C[n].bBigMove,I[n-1].bBigMove||=I[n].bBigMove,C[n-1].bIsBreak||=C[n].bIsBreak,I[n-1].bIsBreak||=I[n].bIsBreak)))}if(!(v||b||2!==u||p===i.G.enumLine&&d===i.G.enumLine)){if(this.processDoublyConnectedEdges(e,t,r+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;(0,i.g)(0)}this.parent.m_changed1||=v,this.parent.m_changed2||=b;let G=e,w=e.end.weight,N=e.end.rank,T=e.end.bBigMove,D=e.end.bIsBreak,V=0,k=-1;for(let t=0;t<=u;t++){const n=t<u?this.parent.m_param1[t]:1;if(n!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,m,l,g;a.queryCut(V,n,i,!1),i.get().snapControlPoints(s*s);let c=!1,_=!1,p=!1,d=!1;const x=new h.P,E=new h.P;-1!==k?(m=y[k],o=P[k],p=C[k].bBigMove,c=C[k].bIsBreak,x.assign(f[k])):(o=e.start.weight,m=e.start.rank,p=e.start.bBigMove,c=e.start.bIsBreak,x.assign(i.get().getStartXY())),t<u?(g=y[t],l=P[t],d=C[t].bBigMove,_=C[t].bIsBreak,E.assign(f[t])):(l=w,g=N,d=T,_=D,E.assign(i.get().getEndXY()));let S=G;n<1&&(this.splitEdgeInPlace(G),S=G.getNextInChain()),this.updateSegmentOnly(G,r),0===G.start.hash||G.start.pt.equals(x)||(this.m_newNodes.push(G.start),this.removeNodeFromHash(G.start),G.start.hash=0),0===G.end.hash||G.end.pt.equals(E)||(this.m_newNodes.push(G.end),this.removeNodeFromHash(G.end),G.end.hash=0),G.start.pt.assign(x),G.end.pt.assign(E),G.start.bBigMove||=p,G.end.bBigMove||=d,G.start.bIsBreak||=c,G.end.bIsBreak||=_,G.start.weight=o,G.start.rank=m,G.end.weight=l,G.end.rank=g,G=S,V=n,k=t}else-1===k&&(k=t)}const F=G.getNextInChain(),H=[];H.length=u;for(let e=0;e<u;e++)H[e]=e;u>2?(H.sort((e,t)=>(0,h.a7)(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(h.a7)):2===u&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=(0,h.c)(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),H[1]=(0,h.c)(H[0],H[0]=H[1])),G=t,w=t.end.weight,N=t.end.rank,T=t.end.bBigMove,D=t.end.bIsBreak,V=0,k=-1;for(let e=0;e<=u;e++){const n=e<u?this.parent.m_param2[e]:1;if(n!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,l,g;m.queryCut(V,n,i,!1),i.get().snapControlPoints(s*s);const c=new h.P,_=new h.P;let p=!1,d=!1,f=!1,P=!1;if(-1!==k){const e=H[k];o=E[e],a=S[e],c.assign(x[e]),f=I[e].bBigMove,p=I[e].bIsBreak}else o=t.start.weight,a=t.start.rank,f=t.start.bBigMove,p=t.start.bIsBreak,c.assign(i.get().getStartXY());if(e!==u){const t=H[e];l=E[t],g=S[t],_.assign(x[t]),P=I[t].bBigMove,d=I[t].bIsBreak}else l=w,g=N,P=T,d=D,_.assign(i.get().getEndXY());let y=G;n<1&&(this.splitEdgeInPlace(G),y=G.getNextInChain()),this.updateSegmentOnly(G,r),0===G.start.hash||G.start.pt.equals(c)||(this.m_newNodes.push(G.start),this.removeNodeFromHash(G.start),G.start.hash=0),0===G.end.hash||G.end.pt.equals(_)||(this.m_newNodes.push(G.end),this.removeNodeFromHash(G.end),G.end.hash=0),G.start.pt.assign(c),G.end.pt.assign(_),G.start.bBigMove||=f,G.end.bBigMove||=P,G.start.bIsBreak||=p,G.end.bIsBreak||=d,G.start.weight=o,G.start.rank=a,G.end.weight=l,G.end.rank=g,G=y,V=n,k=e}else-1===k&&(k=e)}const A=G.getNextInChain();return this.postProcessResultPartsForCurves(e,F,t,A,r+1),c?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&(0,i.d)(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=(0,h.av)(16);const s=r.Envelope2D.constructEmpty();for(let e=0;e<2;e++){const t=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex]),n=r.Envelope2D.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex].queryLooseEnvelope(n),s.mergeEnvelope2D(n);const i=this.parent.m_inputParts[e];this.addSegment(t,0,i.weightStart,i.rankStart,i.weightEnd,i.rankEnd,i.weightInterior,i.rankInterior,i.u.bBreakStart,i.u.bBreakEnd,i.segmentParentage)}s.inflateCoords(100*e,100*e),this.m_origin.assign(s.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(ue(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let n=0,o=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),(0,i.g)(t.recursion>=0),(0,i.g)(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);o&&(o=!1,n=s)}for(let e=0;e<2;e++){const t=0===e?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let s=(0===e?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=s;s=s.getNextInChain())t.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)),t.at(-1).u.bBigMoveStart=s.start.bBigMove,t.at(-1).u.bBigMoveEnd=s.end.bBigMove}return n}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),a=this.parent.m_resultSegments[t.segmentIndex].get(),m=r.getStartXY().equals(a.getStartXY())&&r.getEndXY().equals(a.getEndXY()),l=r.getStartXY().equals(a.getEndXY())&&r.getEndXY().equals(a.getStartXY());if(!m&&!l)return 0;const g=(0,o.a1)(r,a,!0);if(0!==g&&(0,o.a2)(r,a)&&e.segmentParentage===t.segmentParentage){let e=!1;if(g>0)e=r.equals(a);else{(0,i.g)(-1===g);const t=new o.S({segment:a});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const c=s*he.c_smallToleranceFactor;let u=!1;if(0===g){const e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,n=e.length;t<n;++t){const n=e[t],i=new h.P;r.queryCoord2D(n,i);const o=a.getClosestCoordinate(i,!1),m=new h.P;a.queryCoord2D(o,m);const l=h.P.distance(i,m);if(l>s)return 0;u||=l>c}for(let t=0,n=e.length;t<n;++t){const n=e[t],i=new h.P;a.queryCoord2D(n,i);const o=r.getClosestCoordinate(i,!1),m=new h.P;r.queryCoord2D(o,m);const l=h.P.distance(i,m);if(l>s)return 0;u||=l>c}}let _=e.rank,p=t.rank;return _===p&&(_*=he.c_maxGeometryTypeToRankDelta,p*=he.c_maxGeometryTypeToRankDelta,_+=pe(r.getGeometryType(),r,!0),p+=pe(a.getGeometryType(),a,!0)),_>p?(t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,r,m)):p>_?(e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,r,m)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)),u?3:2}postProcessResultPartsForCurves(e,t,s,n,r){r===(0,h.aC)()&&(0,i.d)("curve_helper");for(let s=e;s!==t;s=s.getNextInChain())this.updateSegmentToNodes(s);for(let e=s;e!==n;e=e.getNextInChain())this.updateSegmentToNodes(e);for(let o=e;o!==t;o=o.getNextInChain()){const e=o.end.pt.sub(o.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(o.start.pt.equals(t.start.pt)&&o.end.pt.equals(t.end.pt)?s=1:o.start.pt.equals(t.end.pt)&&o.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=o.start.pt.equals(t.start.pt)?1:0;if(s||(s=o.end.pt.equals(t.end.pt)?2:0,s||(s=o.end.pt.equals(t.start.pt)?3:0,s||(s=o.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),a=e.dotProduct(n);let h;switch(s){case 1:case 2:h=a>0;break;case 3:case 4:h=a<0;break;default:(0,i.d)("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(ue(o,t,r,!1))}continue}const n=this.parent.m_resultSegments[o.segmentIndex],a=this.parent.m_resultSegments[t.segmentIndex],m=[.5,.25,.75];for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new h.P;n.get().queryCoord2D(t,r);const i=a.get().getClosestCoordinate(r,!1),o=new h.P;if(a.get().queryCoord2D(i,o),h.P.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ue(o,t,r,!1));continue}for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new h.P;a.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),o=new h.P;if(n.get().queryCoord2D(i,o),h.P.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ue(o,t,r,!1));continue}o.equalEdge=t,t.equalEdge=o;let l=o.rank,g=t.rank;l===g&&(l*=he.c_maxGeometryTypeToRankDelta,g*=he.c_maxGeometryTypeToRankDelta,l+=pe(n.get().getGeometryType(),n.get(),!0),g+=pe(a.get().getGeometryType(),a.get(),!0)),l>g||l===g&&o.segmentParentage<=t.segmentParentage?(n.copyTo(a,!1),t.segmentParentage=o.segmentParentage,-1===s&&a.get().reverse()):(a.copyTo(n,!1),o.segmentParentage=t.segmentParentage,-1===s&&n.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(s.start),n&&this.updateAttachedEdgesAfterNodeChange(n.start)}processDoublyConnectedEdges(e,t,s,n){s===(0,h.aC)()&&(0,i.d)("curve_helper");const r=this.getSegment(e).get(),a=this.getSegment(t).get(),m=r.getStartXY().equals(a.getStartXY())&&r.getEndXY().equals(a.getEndXY())?1:r.getEndXY().equals(a.getStartXY())&&r.getStartXY().equals(a.getEndXY())?-1:0;if(0!==m){const i=new o.S;r.queryCut(0,.5,i),i.get().snapControlPoints(n*n);const h=new o.S;r.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=i.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(i),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let l=a.getClosestCoordinate(e.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),a.queryCut(0,l,i),i.get().snapControlPoints(n*n),a.queryCut(l,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=i.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(i),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),m>0?(this.m_pairs.push(ue(e,t,s,!1)),this.m_pairs.push(ue(e.getNextInChain(),t.getNextInChain(),s,!1))):(this.m_pairs.push(ue(e,t.getNextInChain(),s,!1)),this.m_pairs.push(ue(e.getNextInChain(),t,s,!1))),!0}return!1}newNode(e,t,s,n){const r=new ce;return this.m_newNodes.push(r),r.pt=e,r.rank=s,r.weight=t,r.bIsBreak=n,r}newEdge(e,t,s,n,r,i){const o=new ge;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=s,o.segmentParentage=i,o.rank=r,o.weight=n,o}splitEdgeInPlace(e){e.segmentIndex=-1;const t=new ge,s=new ce;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=t,s.prevInChain=e,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=e.weight,s.rank=e.rank,s.bIsBreak=!1,s.bBigMove=!1,t.start=s,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=s,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();null!==t;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){const t=e.prevInChain;if(t&&t.hasSegment()){const s=this.getSegment(t).get();e.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(t.start.pt,t.end.pt,!1),s.ensureXYMonotone())}const s=e.nextInChain;if(s&&s.hasSegment()){const t=this.getSegment(s).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(s.start.pt,s.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){const t=this.getSegment(e).get();e.start.pt.equals(t.getStartXY())&&e.end.pt.equals(t.getEndXY())||(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1;const s=[],n=[],r=[];for(let e=0,t=this.m_newNodes.length;e<t;e++){const s=this.m_newNodes[e];if(null===s)continue;let n=s;for(let r=e+1;r<t;r++){const e=this.m_newNodes[r];null!==e&&s.pt.equals(e.pt)&&(n.nextInHash=e,e.prevInHash=n,n=e,this.m_newNodes[r]=null)}}for(let i=0,o=this.m_newNodes.length;i<o;i++){const o=this.m_newNodes[i];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const i=(0,h.av)(4),a=this.hashTableBinsToCheck(o,i);for(let t=0;t<a;t++)if(null!==i[t])for(let a=i[t];null!==a;){const t=a.nextInHash;h.P.distance(o.pt,a.pt)<=e&&(s.push(a),this.removeNodeFromHash(a),a.hash=0,r.push(a),n.push(a)),a=t}let m=!1;for(const e of s)if(!o.pt.equals(e.pt)){const s=re(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,m=!0,t=!0}if(s.length=0,!m)break;o.hash=this.calculateHash(o.pt)}r.push(o),n.push(o);for(let e=o.nextInHash;null!==e;){e.prevInHash=null;const t=e.nextInHash;e.nextInHash=null,r.push(e),n.push(e),e=t}const a=o.hash;let m=null,l=null;for(const e of n)o!==e&&(e.hash=a,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=m,m&&(m.nextInHash=e),e.prevEqual=l,e.nextEqual=null,l&&(l.nextEqual=e),l=e,m=e;const g=a%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[g],null!==this.m_hashTableOfEquals[g]&&(this.m_hashTableOfEquals[g].prevInHash=m),this.m_hashTableOfEquals[g]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(const e of r)this.updateAttachedEdgesAfterNodeChange(e)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=(0,h.av)(2*e.length),this.m_hashTableOfEqualsSize=0;for(const t of e){let e=t;for(;e;){const t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){const t=e.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[t];e.nextInHash=s,null!==s&&(s.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){const t=e.hash%this.m_hashTableOfEquals.length,s=e.prevInHash,n=e.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[t]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){const s=(e.pt.x-this.m_origin.x)/this.m_cell.x,n=(e.pt.y-this.m_origin.y)/this.m_cell.y,r=(0,h.i)()-1,i=Math.round((0,h.s)(s,-r,r)),o=Math.round((0,h.s)(n,-r,r));let a=i|o<<32;a=(0,h.au)(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let m=i+1|o<<32;m=(0,h.au)(m);let l=1;t[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(l=2);let g=i+1|o+1<<32;g=(0,h.au)(g),t[l]=this.m_hashTableOfEquals[g%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}l++;let c=i|o+1<<32;c=(0,h.au)(c),t[l]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}return l++,l}calculateHash(e){const t=(e.x-this.m_origin.x)/this.m_cell.x,s=(e.y-this.m_origin.y)/this.m_cell.y,n=(0,h.i)()-1;let r=Math.round((0,h.s)(t,-n,n))|Math.round((0,h.s)(s,-n,n))<<32;return r=(0,h.au)(r),0===r&&(r=1),r}processSharpCorners(e,t,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,0,0,s,2,r,i,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return a+1}}if(e.getEndXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,1,1,s,2,r,i,n);if(a){for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),a+1}}if(e.getStartXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,0,1,s,2,r,i,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return a+1}}if(e.getEndXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],a=(0,o.a3)(e,t,1,0,s,2,r,i,n);if(a){for(let e=0;e<a;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),a+1}}return 0}}function pe(e,t,s){let n=0;switch(e){case i.G.enumLine:n=0;break;case i.G.enumBezier:n=2;break;case i.G.enumRationalBezier2:n=3;break;case i.G.enumBezier2:n=1;break;case i.G.enumEllipticArc:n=0===t.projectionBehavior()?5:4;break;default:(0,i.d)("")}return s?5-n:n}class de extends ${constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=this.m_parent.getEdgeOriginVertices(t),i=this.m_parent.m_edgeVertices.getFirstElement(r),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(t,i,n,a)}}class fe extends ee{constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;const s=e.getElement(t),n=this.m_parent.getEdgeOriginVertices(s),r=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=t,this.compareVertex(e,t,r)}}class xe extends a.a6{constructor(e){super(),this.pt1=h.P.getNAN(),this.pt2=h.P.getNAN(),this.m_shape=e}compare(e,t,s){this.m_shape.queryXY(t,this.pt1);const n=e.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class Pe{constructor(e){this.m_point=h.P.getNAN(),this.m_pt=h.P.getNAN(),this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){const s=e.getElement(t);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Ee{constructor(e,t){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new a.S(8),this.m_clusters=new a.S(5),this.m_clusterVertices=new Q(!1),this.m_edgeVertices=new Q(!1),this.m_helperPoint=new a.P,this.m_eventQ=new a.T,this.m_sweepStructure=new a.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 he,this.m_segBuf1=new o.S,this.m_segBuf2=new o.S,this.m_sweepPoint=new h.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=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){const s=new m.T;s.setSwapCoordinates(),e.applyTransformation(s),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let n=this.sweepImpl_();return e.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,o.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(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,s){this.m_edges.setField(e,0+t,s)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,s){this.m_edges.setField(e,3+t,s)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+s)}setNextEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+n,s)}getPrevEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+s)}setPrevEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+n,s)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){const t=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(t,s),e!==o.n&&(this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){const s=this.getClusterVertices(e);this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){const t=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,s),-1!==e&&this.m_edgeVertices.addElement(s,e),t}addVertexToEdge_(e,t){const s=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(s,t)}deleteEdge_(e){this.m_edges.deleteElement(e);const t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&(0,h.ay)(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){-1===this.getEdgeCluster(e,0)?this.setEdgeCluster_(e,0,t):-1===this.getEdgeCluster(e,1)?this.setEdgeCluster_(e,1,t):(0,i.d)(""),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){const s=this.getClusterFirstEdge(t);if(-1!==s){const n=this.getNextEdge(s,t);this.setPrevEdge_(n,t,e),this.setNextEdge_(e,t,n),this.setNextEdge_(s,t,e),this.setPrevEdge_(e,t,s)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);const s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1));let n=this.getClusterFirstEdge(e),r=this.getClusterFirstEdge(t);if(-1!==r){let s=r,i=r,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,t),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===e){this.disconnectEdge_(s);const e=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(s),s===a){r=-1;break}r===s&&(r=this.getClusterFirstEdge(t),i=a,o=!0)}s=a}while(s!==i||o);if(-1!==r){do{const n=this.getEdgeEnd(s,t),r=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,e),s=r}while(s!==i);if(n=this.getClusterFirstEdge(e),-1!==n){const t=this.getNextEdge(n,e),s=this.getNextEdge(r,e);t===n?(this.setClusterFirstEdge_(e,r),this.addEdgeToClusterImpl_(n,e),this.setClusterFirstEdge_(e,n)):s===r&&this.addEdgeToClusterImpl_(r,e),this.setNextEdge_(r,e,t),this.setPrevEdge_(t,e,r),this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n)}else this.setClusterFirstEdge_(e,r)}}const i=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(o);-1!==t;t=this.m_clusterVertices.getNext(t)){const s=this.m_clusterVertices.getElement(t);this.m_shape.setUserIndex(s,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(i,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);const s=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),a=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,a),t===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,e),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(s===r&&n===i||n===r&&s===i)){const e=this.getClusterXY(s),t=this.getClusterXY(r);e.isEqualPoint2D(t)?(s!==r&&this.mergeClusters_(s,r),n!==i&&this.mergeClusters_(n,i)):(n!==r&&this.mergeClusters_(n,r),s!==i&&this.mergeClusters_(s,i))}this.dbgCheckEdge_(e)}disconnectEdge_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,s)}disconnectEdgeFromCluster_(e,t){const s=this.getNextEdge(e,t),n=this.getPrevEdge(e,t),r=this.getClusterFirstEdge(t);s!==e?(this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n),r===e&&this.setClusterFirstEdge_(t,s)):this.setClusterFirstEdge_(t,-1)}applyIntersectorToEditShape_(e,t,s){let n=this.m_edgeVertices.getFirst(e);const r=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(r),o=this.m_shape.getNextVertex(r),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(r),m=this.m_shape.getXY(o);let l=!1,g=!1;const c=t.getResultSegment(s,0).getStartXY(),u=t.getResultSegment(s,t.getResultSegmentCount(s)-1).getEndXY();h.equals(c)||(l=!0),m.equals(u)||(g=!0),this.m_shape.splitSegmentWithIntersector(r,t,s,!0,!0);const _=this.m_bTrackChanges&&t.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(r,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const e=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(e)===i;this.m_shape.splitSegmentWithIntersector(e,t,s,r,!0),_&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(l&&this.updateClusterXY(!0,i,c,t.getResultSegmentStartPointWeight(s,0),t.getResultSegmentStartPointRank(s,0)),g){const e=t.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,u,t.getResultSegmentEndPointWeight(s,e),t.getResultSegmentEndPointRank(s,e))}}createEdgesAndClustersFromSplitEdge_(e,t,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(e),r=this.getEdgeCluster(e,0),i=this.getEdgeCluster(e,1);let o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);const h=a.S.impossibleIndex3();this.setEdgeSweepNode_(o,h),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,r);const m=t.getResultSegmentCount(s);for(let e=1;e<m;e++){const e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);const t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,h),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,i);for(let e=this.m_edgeVertices.getFirst(n);-1!==e;e=this.m_edgeVertices.getNext(e)){let t=this.m_edgeVertices.getElement(e);if(this.getClusterFromVertex(t)===r){let e=0;const s=this.m_tempEdgeBuffer.length;do{if(e>0){const s=this.m_tempEdgeBuffer[e-1];this.addVertexToCluster_(s,t)}const s=this.m_tempEdgeBuffer[e];e+=2,this.addVertexToEdge_(s,t),t=this.m_shape.getNextVertex(t)}while(e<s)}else{let e=this.m_tempEdgeBuffer.length-1;do{if(e<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[e+1];this.addVertexToCluster_(s,t)}const s=this.m_tempEdgeBuffer[e];e-=2,this.addVertexToEdge_(s,t),t=this.m_shape.getNextVertex(t)}while(e>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,s){const n=this.getEdgeCluster(t,0),r=this.getClusterXY(n),i=this.getEdgeCluster(t,1),o=this.getClusterXY(i),h=s.getResultSegmentCount(e);let m=s.getResultSegment(e,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 e=r.compare(o),t=m.getEndXY();(r.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(e,h-1);const g=m.getEndXY();o.isEqualPoint2D(g)||(this.m_bComplications||o.compare(this.m_sweepPoint)*g.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(i,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(i)),this.m_tempEdgeBuffer.push(t);for(let e=0,s=this.m_tempEdgeBuffer.length;e<s;e++){const s=this.m_tempEdgeBuffer[e],n=this.getEdgeSweepNode(s);a.S.isValidElement(n)&&(this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(s,-1));const r=a.S.impossibleIndex3();s!==t&&this.getEdgeSweepNode(s)!==r&&(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){const s=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,s,t),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0)}fixIntersection_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e),n=this.m_sweepStructure.getElement(t);let r=null,i=null;const o=this.getEdgeOriginVertices(s),a=this.m_edgeVertices.getFirstElement(o),h=this.getEdgeOriginVertices(n),m=this.m_edgeVertices.getFirstElement(h);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),g=this.m_shape.getWeight(a),c=this.m_shape.getSegmentParentageBreakVertex(a),u=this.m_shape.getWeight(l),_=this.m_shape.getSegmentParentageBreakVertex(l),p=this.m_shape.getSegmentWeight(a),d=this.m_shape.getRank(a),f=this.m_shape.getRank(l),x=this.m_shape.getSegmentRank(a),P=this.m_shape.getSegmentParentage(a);this.m_shape.querySegment(m,this.m_segBuf2,!1,!1),i=this.m_segBuf2.get();const E=this.m_shape.getNextVertex(m),y=this.m_shape.getWeight(m),S=this.m_shape.getSegmentParentageBreakVertex(m),C=this.m_shape.getWeight(E),I=this.m_shape.getSegmentParentageBreakVertex(E),v=this.m_shape.getSegmentWeight(m),b=this.m_shape.getRank(m),G=this.m_shape.getRank(E),w=this.m_shape.getSegmentRank(m),N=this.m_shape.getSegmentParentage(m);this.m_segmentIntersector.pushSegment(r,g,d,u,f,p,x,c,_,P),this.m_segmentIntersector.pushSegment(i,y,b,C,G,v,w,S,I,N),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,n,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t);let n=null;const r=this.getEdgeOriginVertices(s),i=this.m_edgeVertices.getFirstElement(r);this.m_shape.querySegment(i,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(i),a=this.m_shape.getWeight(i),h=this.m_shape.getSegmentParentageBreakVertex(i),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),g=this.m_shape.getSegmentWeight(i),c=this.m_shape.getRank(i),u=this.m_shape.getRank(o),_=this.m_shape.getSegmentRank(i),p=this.m_shape.getSegmentParentage(i),d=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(n,a,c,m,u,g,_,h,l,p),this.m_shape.queryPoint(d,this.m_helperPoint);const f=this.m_shape.getWeight(d),x=this.m_shape.getRank(d);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=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())||t>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);a.S.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==a.S.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(e),-1===s){const t=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(t);return this.mergeEdges_(s,e),!1}if(this.setEdgeSweepNode_(e,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,s),!0}return!1}isEdgeOnSweepLine_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1),n=this.getClusterXY(t),r=this.getClusterXY(s);if(h.P.sqrDistance(n,r)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const i=n.compare(this.m_sweepPoint),o=r.compare(this.m_sweepPoint);return i<=0&&o>0?s:o<=0&&i>0?t:i>0&&o>0?a.S.impossibleIndex2():-1}fillEventQueue(){const e=new a.a(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let s=t.next();s!==o.n;s=t.next())-1!==this.m_shape.getUserIndex(s,this.m_vertexClusterIndex)&&e.add(s);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(e.size()),this.m_eventQ.setComparator(new xe(this.m_shape));const s=h.P.getNAN();s.setNAN();let n=-1;for(let t=0,r=e.size();t<r;t++){const r=e.read(t);if(this.m_shape.getXY(r).isEqualPoint2D(s)){const e=this.m_shape.getUserIndex(r,this.m_vertexClusterIndex);this.mergeClusters_(n,e);continue}n=this.getClusterFromVertex(r),this.m_shape.queryXY(r,s);const i=this.m_eventQ.addBiggestElement(r);this.setClusterEventQNode_(n,i)}}fillEventQueuePass2(){const e=new a.a(0);for(let t=this.m_eventQ.getFirst();-1!==t;t=this.m_eventQ.getNext(t)){const s=this.m_eventQ.getElement(t);e.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,s=e.size();t<s;t++){const s=e.read(t),n=this.getClusterFromVertex(s),r=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,r)}}getAffectedEdges(e,t){const s=this.getClusterFirstEdge(e);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);a.S.isValidElement(s)&&t.push(n),n=this.getNextEdge(n,e)}while(n!==s)}updateClusterXY(e,t,s,n,r){const i=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(i);-1!==t;t=this.m_clusterVertices.getNext(t)){const i=this.m_clusterVertices.getElement(t);this.m_shape.setXYMonotonicPoint2D(i,s),this.m_shape.setWeight(i,n),this.m_shape.setRank(i,r),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}}splitEdge_(e,t,s,n){this.dbgCheckEdge_(e),-1!==t&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),-1!==t&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,n),-1!==t&&this.processSplitHelper1_(1,t,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){const t=this.m_modifiedClusters[e],s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1))}const r=this.getEdgeOriginVertices(e),i=-1!==t?this.getEdgeOriginVertices(t):-1;if(this.applyIntersectorToEditShape_(r,n,0),-1!==i)this.applyIntersectorToEditShape_(i,n,1);else{const e=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,e,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,n,0),-1!==t&&this.createEdgesAndClustersFromSplitEdge_(t,n,1),this.m_edgeVertices.deleteList(r),this.deleteEdge_(e),-1!==t&&(this.m_edgeVertices.deleteList(i),this.deleteEdge_(t));for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){const t=this.m_modifiedClusters[e];t===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let s=this.getClusterEventQNode(t);if(-1===s){const e=this.getClusterFirstVertex(t);if(s=this.m_eventQ.addUniqueElement(e),-1===s){const e=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(e),n=this.getClusterFromVertex(s);this.mergeClusters_(n,t)}else this.setClusterEventQNode_(t,s)}}this.m_modifiedClusters.length=0}getClusterXY(e){const t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new de(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const e=[];let t=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=a.S.impossibleIndex2(),r=a.S.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 t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===t,!a){let s=t;do{const t=this.getEdgeSweepNode(s);-1===t?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):t!==r&&e.push(t),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=1===e.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let t=0,s=e.length;t<s;t++){const s=this.m_sweepStructure.getElement(e[t]);this.setEdgeSweepNode_(s,n)}let t=n,s=n;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(t===n){const e=this.m_sweepStructure.getPrev(i);if(-1!==e){const s=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(s)!==n&&(t=e)}else t=-1}if(s===n){const e=this.m_sweepStructure.getNext(i);if(-1!==e){const t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==n&&(s=e)}else s=-1}if(t!==n&&s!==n)break}for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_sweepStructure.getElement(s);this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(n,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=s,-1!==t&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,s):-1===t&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===t&&(t=new fe(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.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 Pe(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_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==o.n;t=this.m_shape.getNextGeometry(t))if((0,i.h)(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==o.n;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===o.n)continue;let r=this.m_shape.getNextVertex(n);if(r===o.n||r===n)continue;let i=-1;e.selected(n)&&(i=this.newCluster_(n));let a=-1;-1!==i&&e.selected(r)&&(a=this.newEdge_(n),this.addEdgeToCluster(a,i));let h=a;for(let e=0,s=t-2;e<s;e++){const e=this.m_shape.getNextVertex(r);let t=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==h&&this.addEdgeToCluster(h,s),this.m_shape.selected(e)&&(t=this.newEdge_(r),this.addEdgeToCluster(t,s))}h=t,r=e}if(this.m_shape.isClosedPath(s)){const e=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const t=this.newCluster_(r);if(-1!==h&&this.addEdgeToCluster(h,t),this.m_shape.selected(e)){const e=this.newEdge_(r);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,i)}}}else{let e=-1;this.m_shape.selected(r)&&(e=this.newCluster_(r),-1!==h&&this.addEdgeToCluster(h,e))}}else for(let e=this.m_shape.getFirstPath(t);e!==o.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n;s++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function ye(e,t,s){return{vertex0:e,vertex1:t,dir:s}}class Se{constructor(e){this.m_shape=null,this.m_spikes=[],this.m_points=new a.a(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let s=e.getFirstPath(t);s!==o.n;s=e.getNextPath(s)){let t=e.getFirstVertex(s);for(let n=0,r=e.getPathSize(s);n<r;n++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let t=0,s=this.m_points.size();t<s;++t)e.setUserIndex(this.m_points.read(t),this.m_pointsIndex,t);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const n=e.getXY(s);let r=1,a=0;const h=[];for(let t=1;t<this.m_points.size();t++){const i=this.m_points.read(t);if(i===o.n)continue;if(-1===e.getUserIndex(i,this.m_pointsIndex))continue;const m=e.getXY(i);if(m.isEqualPoint2D(n))r++;else{if(r>1){for(let s=a;s<t;s++){const t=this.m_points.read(s);if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const r=e.getNextVertex(t),i=e.getPrevVertex(t);if(t!==r&&!e.isEqualXYPoint2D(r,n)){const e=ye(t,r,1);h.push(e)}if(t!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=ye(t,i,-1);h.push(e)}}h.length>0&&this.processBunch_(h,n)}s=i,n.assign(m),r=1,a=t}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let m=e.getPointCount(t);for(let t=0;t<this.m_points.size();t++){const s=this.m_points.read(t);if(s===o.n)continue;if(-1!==e.getUserIndex(s,this.m_pointsIndex)){e.setUserIndex(s,this.m_pointsIndex,-1);continue}const n=e.getPathFromVertex(s);e.getFirstVertex(n)===s&&e.setFirstVertex(n,o.n),e.freeVertex(s),this.m_points.write(t,o.n),m--}const l=e.createPathUserIndex();let g=e.getPathCount(t);for(let s=0,n=this.m_points.size();s<n;++s){if(this.m_points.read(s)===o.n)continue;let n=this.m_points.read(s);if(-1!==e.getUserIndex(n,this.m_pointsIndex))continue;let r=e.getPathFromVertex(n),a=-1;if(2===e.getPathUserIndex(r,l)){r=o.n;for(let t=e.getNextVertex(n);t!==n;t=e.getNextVertex(t)){const s=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(s,l)){r=s,n=t;break}}r===o.n&&(r=e.insertPath(t,o.n),e.setClosedPath(r,!0),g++),(0,i.g)(r!==o.n)}e.setPathUserIndex(r,l,2),a=e.getFirstVertex(r);let h=0,m=!1,c=n;do{a===c&&(m=!0),e.setUserIndex(c,this.m_pointsIndex,1);const t=e.getPathFromVertex(c);t!==r&&(2!==e.getPathUserIndex(t,l)&&(e.setPathUserIndex(t,l,1),e.setFirstVertex(t,o.n)),e.setPathToVertex(c,r)),h++,c=e.getNextVertex(c)}while(c!==n);m||e.setFirstVertex(r,n),e.setPathSize(r,h)}for(let s=e.getFirstPath(t);s!==o.n;){const t=e.getNextPath(s);1!==e.getPathUserIndex(s,l)&&e.getFirstVertex(s)!==o.n||(e.removePathOnly(s),g--),s=t}e.setGeometryVertexCount(t,m),e.setGeometryPathCount(t,g),e.removePathUserIndex(l),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,s)=>{const n=this.m_shape.getXY(e.vertex1).sub(t),r=this.m_shape.getXY(s.vertex1).sub(t),i=h.P.compareVectors(n,r);return 0===i?e.dir<s.dir?-1:1:i});let s=0;const n=this.m_shape.getXY(e[0].vertex1);let r=1;const i=this.m_shape.hasCurves();for(let t=1,o=e.length;t<o;t++){const a=this.m_shape.getXY(e[t].vertex1);if(!(a.isEqualPoint2D(n)&&(r++,t+1<o))){if(2===r){const t=e[s],n=e[s+1],r=t.dir;if(r!==n.dir){let e=!0;if(i&&(e=!this.m_shape.isCurve(1===t.dir?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),e){if(1===r){const e=t.vertex0,s=n.vertex0;this.m_shape.setNextVertex(e,s),this.m_shape.setPrevVertex(s,e),this.m_shape.getPrevVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setPrevVertex(r,i),this.m_shape.setNextVertex(i,r),this.m_shape.getNextVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}else{const e=t.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(s,e),this.m_shape.getNextVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setNextVertex(r,i),this.m_shape.setPrevVertex(i,r),this.m_shape.getPrevVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(a),s=t,r=1}}e.length=0}}function Ce(e){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))if((0,i.h)(e.getGeometryType(t)))return!0;return!1}function Ie(e,t,s,n,r){if(!Ce(t))return!1;let i=new be(r);if(i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n,i.needsCrackingImpl_())return n&&n.assign(i.m_nonSimpleResult),!0;const o=new m.T;o.setSwapCoordinates(),t.applyTransformation(o),i=new be(r),i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n;const a=i.needsCrackingImpl_();return t.applyTransformation(o),!!a&&(n&&n.assign(i.m_nonSimpleResult),!0)}function ve(e,t){return{t:e,index:t}}class be{crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){const t=new m.T;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1;const t=new o.S,s=new o.S,n=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty(),m=!1,l=new a.P,g=new he,c=this.m_shape.getTotalPointCount(),u=c*c*2,_=this.m_shape.queryVertexIteratorOnSelection();for(let r=_.next();r!==o.n;r=_.next()){const a=this.m_shape.getGeometryType(_.currentGeometry());let c=1,p=1,d=1,f=0,x=0,P=0;const E=this.m_shape.getSegmentParentage(r);let y=!1,S=!1,C=null,I=!1;if((0,i.e)(a))c=this.m_shape.getWeight(r),f=this.m_shape.getRank(r);else{if(C=this.getSegment_(r,t),null===C)continue;const e=this.m_shape.getVertexIndex(r);c=this.m_shape.getWeightWithIndex(e),f=this.m_shape.getRankWithIndex(e),d=this.m_shape.getSegmentWeightWithIndex(e),P=this.m_shape.getSegmentRankWithIndex(e),y=this.m_shape.getSegmentParentageBreakVertex(r);{const e=this.m_shape.getNextVertex(r);p=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(n),n.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const v=new o.X({copy:_});let b=v.next();b!==o.n&&(b=v.next());let G=0;for(;b!==o.n;b=v.next()){if(0!==G){G--;continue}if(this.m_shape.getTotalPointCount()>u)return e;this.progress_();const a=this.m_shape.getGeometryType(v.currentGeometry());let w=null,N=!1,T=0,D=0,V=0,k=0,F=0,H=0,A=!1,M=!1;const U=this.m_shape.getSegmentParentage(b);if((0,i.e)(a))T=this.m_shape.getWeight(b),k=this.m_shape.getRank(b);else{if(w=this.getSegment_(b,s),null===w)continue;const e=this.m_shape.getVertexIndex(b);T=this.m_shape.getWeightWithIndex(e),k=this.m_shape.getRankWithIndex(e),V=this.m_shape.getSegmentWeightWithIndex(e),H=this.m_shape.getSegmentRankWithIndex(e),A=this.m_shape.getSegmentParentageBreakVertex(b);{const e=this.m_shape.getNextVertex(b);D=this.m_shape.getWeight(e),F=this.m_shape.getRank(e),M=this.m_shape.getSegmentParentageBreakVertex(e)}if(w.queryLooseEnvelope(h),w.isDegenerate(this.m_tolerance)){if(!w.isDegenerate(0))continue;N=!0,w=null}}let q=0,O=0;if(null!==C&&null!==w)n.isIntersectingNe(h)&&0!==(0,o.Y)(!0,!0,C,w,this.m_tolerance,!0)&&(g.pushSegment(C,c,f,p,x,d,P,y,S,E),g.pushSegment(w,T,k,D,F,V,H,A,M,U),g.intersect2D(this.m_tolerance,!0),e||=g.getSegmentChanged(0)||g.getSegmentChanged(1),q=g.getResultSegmentCount(0),O=g.getResultSegmentCount(1),q+O>0&&(this.m_shape.splitSegmentWithIntersector(r,g,0,!0,!0),this.m_shape.splitSegmentWithIntersector(b,g,1,!0,!0),this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(r,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(b,!0))),O>1&&(G+=O-1),g.clear());else if(null!==C){const t=this.m_shape.getXY(b);if(n.contains(t)){if(g.pushSegment(C,c,f,p,x,d,P,y,S,E),this.m_shape.queryPoint(b,l),g.intersect2DEx(this.m_tolerance,l,k,T,m),e||=g.getSegmentChanged(0)||g.getResultPointChanged(),q=g.getResultSegmentCount(0),q>0)if(this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(r,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(b,!0)),this.m_shape.splitSegmentWithIntersector(r,g,0,!0,!0),N){let e=o.n;for(let t=this.m_shape.getNextVertex(b);t!==o.n&&t!==b&&(w=this.getSegment_(t,s),e=t,null!=w&&w.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=b;t!==o.n&&(this.m_shape.setPoint(t,g.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(b,g.getResultPoint(),!0);g.clear()}}else{if(null===w)continue;{const t=this.m_shape.getXY(r);if(h.inflateCoords(this.m_tolerance,this.m_tolerance),h.contains(t)){if(g.pushSegment(w,T,k,D,F,V,H,A,M,U),this.m_shape.queryPoint(r,l),g.intersect2DEx(this.m_tolerance,l,f,c,m),e||=g.getSegmentChanged(0)||g.getResultPointChanged(),O=g.getResultSegmentCount(0),O>0)if(this.m_bTrackChanges&&(g.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(b,!0),g.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(r,!0)),this.m_shape.splitSegmentWithIntersector(b,g,0,!0,!0),G+=O-1,I){let e=o.n;for(let t=this.m_shape.getNextVertex(r);t!==o.n&&t!==r&&(w=this.getSegment_(t,s),e=t,null!=w&&w.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=r;t!==o.n&&(this.m_shape.setPoint(t,g.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(r,g.getResultPoint(),!0);g.clear()}}}if(q+O!==0&&0!==q){let e=!1;for(;C=this.getSegment_(r,t),null!=C&&(C.queryEnvelope(n),C.isDegenerate(this.m_tolerance));){if(!(q>1)){e=!0;break}r=_.next(),q--,(0,i.g)(r!==o.n)}if(e)break}}}return e}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Ee(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1;const t=new a.a(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let e=0,n=s.next();n!==o.n;++e,n=s.next())t.write(e,n);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(o.n);const n=this.m_shape.createUserIndex(),r=this.m_shape.createUserIndex();this.m_sweepComparator=new $(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let m=null;const l=[],g=[];let c=0;const u=new h.P;for(let s=t.read(c++);s!==o.n;){this.m_shape.queryXY(s,u);let a=!1;do{let e=this.m_shape.getNextVertex(s),i=this.m_shape.getPrevVertex(s);a||=e!==o.n||i!==o.n,e===o.n||this.m_shape.selected(e)||(e=o.n),i===o.n||this.m_shape.selected(i)||(i=o.n),e!==o.n&&this.m_shape.compareVerticesSimpleY(s,e)<0&&(g.push(s),g.push(e)),i!==o.n&&this.m_shape.compareVerticesSimpleY(s,i)<0&&(g.push(i),g.push(i));const h=this.m_shape.getUserIndex(s,n);-1!==h&&(l.push(h),this.m_shape.setUserIndex(s,n,-1));const m=this.m_shape.getUserIndex(s,r);-1!==m&&(l.push(m),this.m_shape.setUserIndex(s,r,-1)),s=t.read(c++)}while(s!==o.n&&this.m_shape.isEqualXYPoint2D(s,u));if(!a&&(null===m&&(m=new ee(this.m_shape,this.m_tolerance)),m.setPoint(u),this.m_sweepStructure.searchUpperBound(m),m.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&((0,i.d)("needsCrackingIMpl_"),this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1));break}let p=1===l.length&&2===g.length;const d=32;l.length>d&&(0,h.v)(l);let f=-1,x=-1;if(!p)for(let t=0,s=l.length;t<s;t++){const s=l[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===l.indexOf(n))if(-1===f)f=n;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1)}const r=this.m_sweepStructure.getNext(s);if(-1!==r&&-1===l.indexOf(r))if(-1===x)x=r;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new _.NonSimpleResult(6,-1,-1)}if(-1!==f&&-1!==x)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(u.y,u.x),!p){for(let e=0,t=l.length;e<t;e++){const t=l[e];this.m_sweepStructure.deleteNode(t)}l.length=0}if(!p&&-1!==f&&-1!==x&&this.checkForIntersections_(f,x)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,s=g.length;t<s;t+=2){const s=g[t],i=g[t+1];let o;if(p?(o=this.m_sweepStructure.replaceElementAtPosition(l[0],s,!0,!0),l.length=0,p=!1):o=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}-1===this.m_shape.getUserIndex(i,n)?this.m_shape.setUserIndex(i,n,o):this.m_shape.setUserIndex(i,r,o)}if(e)break;g.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(r),e}checkForIntersections_(e,t){const s=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,s,t);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(e,t){return be.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,s){return e.querySegment(t,s,!1,!1)?s.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,s){const n=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(n);const m=r.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(m),m.inflateCoords(s,s),!m.isIntersecting(n))return e;const l=e.getImpl(),g=l.getAccelerators();let c=null,u=null;g&&(u=g.getQuadTree()),function(e,t){const s=e.getPointCount();if(s<16)return!1;return 2*s+Math.log(s)/Math.log(2)*1*t<1*s*t}(e,(0,i.v)(t))&&(c=(0,a.H)(l,m),u=c);const _=u?u.getIteratorForQT():null,p=t.querySegmentIterator(),d=e.querySegmentIterator(),f=(0,h.d)(15,Number.NaN),x=[];for(;p.nextPath();)for(;p.hasNextSegment();){const e=p.nextSegment();if(u){_.resetIterator(e,s);for(let t=_.next();-1!==t;t=_.next()){this.progress_();const n=u.getElement(t);if(d.resetToVertex(n,-1),d.hasNextSegment()){const t=d.nextSegment().intersect(e,null,f,null,s);for(let e=0;e<t;e++){const t=f[e];if(0===t||1===t)continue;const s=ve(t,d.getStartPointIndex());x.push(s)}}}}else{const t=r.Envelope2D.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(s,s),!n.isIntersecting(t))continue;for(d.resetToFirstPath();d.nextPath();)for(;d.hasNextSegment();){const n=d.nextSegment(),i=r.Envelope2D.constructEmpty();if(n.queryLooseEnvelope(i),!i.isIntersecting(t))continue;const o=n.intersect(e,null,f,null,s);for(let e=0;e<o;e++){const t=f[e];if(0===t||1===t)continue;const s=ve(t,d.getStartPointIndex());x.push(s)}}}}if(0===x.length)return e;x.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:e.t>t.t?1:0);const P=e.createInstance();for(P.getGeometryType()===i.G.enumPolygon&&P.setFillRule(e.getFillRule()),d.resetToFirstPath();d.nextPath()&&!d.hasNextSegment(););(0,i.g)(d.hasNextSegment());let E=d.nextSegment();const y=new o.S;let S=-1;for(let e=0,t=x.length;e<t;){const s=x[e].index;let n=e+1;for(;n<t&&x[n].index===s;)++n;for(;d.getStartPointIndex()<s;){this.progress_();const e=d.hasNextSegment(),t=d.getPathIndex();if((e||!d.isClosingSegment()||d.isCurve())&&((0,i.g)(null!==E),P.addSegment(E,S!==t)),S=t,!e){for(d.isPathClosed();d.nextPath()&&!d.hasNextSegment(););(0,i.g)(d.hasNextSegment())}E=d.nextSegment()}let r=0;for(let t=e;t<n;t++){const e=x[t].t;if(e===r)continue;(0,i.g)(null!==E),E.queryCut(r,e,y),r=e;const s=d.getPathIndex();P.addSegment(y.get(),S!==s),S=s}const o=d.hasNextSegment();if((o||!d.isClosingSegment()||d.isCurve())&&((0,i.g)(null!=E),E.queryCut(r,1,y),P.addSegment(y.get(),!1)),o)E=d.nextSegment();else{for(;d.nextPath()&&!d.hasNextSegment(););E=d.hasNextSegment()?d.nextSegment():null}e=n}if(null!==E){const e=d.getPathIndex();(d.hasNextSegment()||!d.isClosingSegment()||d.isCurve())&&P.addSegment(E,S!==e),S=e}let C=d.hasNextSegment();for(;;){if(!C){for(;d.nextPath()&&(C=d.hasNextSegment(),!C););if(!C)break}E=d.nextSegment();const e=d.getPathIndex();C=d.hasNextSegment(),(C||!d.isClosingSegment()||d.isCurve())&&P.addSegment(E,S!==e),S=e}return P}constructor(e){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new _.NonSimpleResult,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 a.T,this.m_progressTracker=e}}be.s_bForceBruteForce=!0;class Ge{constructor(e,t){this.m_monotoneParts=(0,h.m)(o.S,16),this.m_xOrds=(0,h.d)(16,Number.NaN),this.m_inputPoint=h.P.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY())))return void(this.m_bBreak=!0);if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const t=Math.min(e.getStartX(),e.getEndX()),s=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let t=!1;const s=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>s)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){const n=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);t=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){const t=e.getClosestCoordinate(this.m_inputPoint,!1),s=e.getCoord2D(t);return h.P.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){const t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let s=0;if(e.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=e.getMonotonicParts(this.m_monotoneParts,!0),(0,i.g)(this.m_monotoneParts.length>=s)),s>0)for(let e=0;e<s;e++){const t=this.m_monotoneParts[e].get(),s=h.E.construct(t.getStartY(),t.getEndY());if(!(s.vmin>this.m_inputPoint.y||s.vmax<this.m_inputPoint.y)&&(this._DoOne(t),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return(0,i.g)(0),2}}function we(e,t,s){if(e.isEmpty())return 0;const n=r.Envelope2D.constructEmpty();if(e.queryLooseEnvelope(n),n.inflateCoords(s,s),!n.contains(t))return 0;const o=e.getImpl().getAccelerators();if(o){o.getRasterizedGeometry()&&(0,i.g)(0);const n=o.getQuadTree();if(n)return function(e,t,s,n){const i=new r.Envelope2D;e.queryLooseEnvelope(i),i.inflateCoords(n,n);const o=0===e.getFillRule(),a=new Ge(o,n);a.setInputPoint(s);const h=i.clone();h.xmax=s.x+n,h.ymin=s.y-n,h.ymax=s.y+n;const m=e.getImpl().querySegmentIterator(),l=t.getIterator(h,n);for(let e=l.next();-1!==e;e=l.next())if(m.resetToVertex(t.getElement(e),-1),m.hasNextSegment()){const e=m.nextSegment();if(a.processSegment(e))return-1}return a._Result()?1:0}(e,n,t,s)}return function(e,t,s){const n=0===e.getFillRule(),r=new Ge(n,s);r.setInputPoint(t);const i=e.getImpl().querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(r.processSegment(e))return-1}return r._Result()?1:0}(e,t,s)}function Ne(e,t){const s=e.getPointCount();return!(s<16)&&2*s+Math.log(s)/Math.log(2)*1*t<1*s*t}class Te{getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?s:t}constructor(e){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),s=this.getEnd2(e);this.m_shape.getPrevVertex(t)===s&&(s=(0,h.c)(t,t=s));const n=h.P.getNAN(),r=h.P.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),(0,i.g)(!n.equals(r)),n.y<r.y}getStart(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?t:s}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(-1!==this.m_firstFree){const t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}const t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let De=class extends a.a6{constructor(e){super(),this.m_line1=new o.L,this.m_line2=new o.L,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges;let o;this.m_leftElm===t?o=this.m_leftx:(this.m_seg1=r.getSegment(t),this.m_seg1?o=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,o=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=o,this.m_leftElm=t);let a,h=r.getSegment(n);if(h?a=h.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(n),this.m_line2,!0),h=this.m_line2,a=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),o===a){const e=r.isBottomUp(t),s=r.isBottomUp(n),m=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=s?h.getEndY():h.getStartY(),g=Math.min(m,l);let c=.5*(g+this.m_helper.m_yScanline);c===this.m_helper.m_yScanline&&(c=g),o=this.m_seg1.intersectionOfYMonotonicWithAxisX(c,0),a=h.intersectionOfYMonotonicWithAxisX(c,0),o===a&&(0,i.w)("")}return o<a?-1:o>a?1:0}reset(){this.m_leftElm=-1}};class Ve{constructor(e){this.m_node=-1,this.m_index=0,this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const e=this.m_node;if(-1===e)return o.n;const t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){const e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return o.n}}class ke{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new a.T,this.m_yScanline=0,this.m_geometry=o.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=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new De(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const e=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||(this.m_edges=new Te(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let s=0,n=e.length;s<n;s++)-1!==e[s]&&t++;(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let t=0,s=e.length;t<s;t++){const s=e[t];s!==o.n&&this.insertEdge_(s,-1)}for(let e=0;e<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;e++){const s=this.m_unknownNodes[e],n=this.m_AET.getElement(s),r=this.m_edges.getPath(n),h=this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex);let m=o.n;if(0===h){let e=this.m_AET.getPrev(s),n=s,r=!1;for(;e!==a.T.st_nullNode();){const t=this.m_AET.getElement(e),s=this.m_edges.getPath(t);if(0!==this.m_shape.getPathUserIndex(s,this.m_pathOrientationIndex)){m=s;break}n=e,e=this.m_AET.getPrev(e)}if(e===a.T.st_nullNode())r=!0,e=n;else{const t=this.m_AET.getElement(e);r=this.m_edges.isBottomUp(t),e=this.m_AET.getNext(e),r=!r}do{const s=this.m_AET.getElement(e),o=this.m_edges.getPath(s);if(0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(s)){const e=this.m_shape.getFirstVertex(o);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(o,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(o,this.m_pathOrientationIndex,r?3:2),!r){let e=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex);2===e?(m=this.m_shape.getPathUserIndex(m,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex),(0,i.g)(3===e)):(0,i.g)(3===e);const t=this.m_shape.getPathUserIndex(m,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(m,this.m_pathParentageIndex,o),this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(o,this.m_pathParentsIndex,m)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}m=o,n=e,e=this.m_AET.getNext(e),r=!r}while(n!==s)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),r=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const e=this.m_AET.getElement(n);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==r){const e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let i=-1;-1!==n&&-1!==r?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(r),e[t]=o.n):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=o.n)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=h.P.getNAN(),n=h.P.getNAN();this.m_shape.queryXY(e,s);const r=this.m_shape.getNextVertex(e);this.m_shape.queryXY(r,n);let i=!1;if(s.y<n.y){i=!0;const s=this.m_edges.newEdge(e);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s)),-1===this.m_shape.getUserIndex(r,this.m_node1UserIndex)?this.m_shape.setUserIndex(r,this.m_node1UserIndex,n):this.m_shape.setUserIndex(r,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,n),s.y<n.y){i=!0;const s=this.m_edges.newEdge(o);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s)),-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,n):this.m_shape.setUserIndex(o,this.m_node2UserIndex,n);const r=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return i}fixRingSelfTangency_(){const e=[],t=[];let s=-1,n=-1;const r=new h.P;let a=o.n,m=o.n,l=-1;const g=new Ve(this);for(let i=g.next();i!==o.n;i=g.next()){const o=new h.P;this.m_shape.queryXY(i,o);const g=this.m_shape.getPathFromVertex(i);r.equals(o)&&m===g?(-1===n&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),n=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,n,-1)),-1===l&&(l=t.length,this.m_shape.setUserIndex(a,n,l),t.push(1),-1===this.m_shape.getPathUserIndex(g,s)&&(this.m_shape.setPathUserIndex(g,s,a),e.push(g))),this.m_shape.setUserIndex(i,n,l),t[t.length-1]++):(l=-1,r.assign(o)),a=i,m=g}if(0===e.length)return!1;(0,i.g)(-1!==s);for(let r=0,i=e.length;r<i;r++){const i=e[r];let o=this.m_shape.getPathUserIndex(i,s);const a=this.m_shape.getUserIndex(o,n),h=[],m=[];h.push(o),m.push(a);for(let e=this.m_shape.getNextVertex(o);e!==o;e=this.m_shape.getNextVertex(e)){const s=e,r=this.m_shape.getUserIndex(s,n);if(-1!==r){if(0===m.length){m.push(r),h.push(s);continue}if(m.at(-1)===r){const i=h.at(-1);this.m_shape.peelALoopIntoAPath(i,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,m.pop(),h.pop()),o=i,e=i}else h.push(e),m.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const e={stack:[],error:void 0,hasError:!1};try{let t,s=!1;const r=(0,n.mS)(e,(0,h.h)(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new a.a(0);for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e)){let s=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)t.add(s),s=this.m_shape.getNextVertex(s)}this.m_shape.sortVerticesSimpleByY(t,0,e),this.progress_(!0),this.m_sortedVerticesArray=t}else r.bForget=!0;if(this.m_bFixSelfTangency&&(s=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){const t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!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 e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const m=h.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 l=new Ve(this);for(let e=l.next();e!==o.n&&(this.progress_(),this.m_shape.queryXY(e,m),m.y!==this.m_yScanline&&i.length&&(s=this.processBunchForRingOrientationTest_(i)||s,this.m_sweepComparator.reset(),i.length=0),i.push(e),this.m_yScanline=m.y,0!==this.m_unknownRingOrientationCount);e=l.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(i)||s,i.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==o.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){this.m_shape.setExterior(t,!0);for(let s=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);s!==o.n;){const n=this.m_shape.getPathUserIndex(s,this.m_pathParentageIndex);e.push(s),this.m_shape.setExterior(s,!1),this.m_shape.setPathUserIndex(s,this.m_pathParentageIndex,t),s=n}let s=t,n=e.length;for(let e=this.m_shape.getNextPath(t);n>0&&e!==o.n;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=o.n;break}s=e}if(0!==n){s=t;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,a.a7),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}e.length=0,t=this.m_shape.getNextPath(s)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const e=this.m_shape.createPathUserIndex();let t=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==o.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,e,t),t++;for(let e=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e!==o.n;){const t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,n),e=t}let r=n,i=s.length,h=t;for(let t=this.m_shape.getNextPath(n);i>0&&t!==o.n;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=o.n;break}r=t,this.m_shape.setPathUserIndex(t,e,-h),h++}if(0!==i){r=n,h=t;for(let t=0,n=s.length;t<n;t++){const n=s[t];this.m_shape.setPathUserIndex(n,e,-h),h++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,a.a7)}r=n}t=h,s.length=0,n=this.m_shape.getNextPath(r)}else n=this.m_shape.getNextPath(n);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function Fe(e,t,s,n,r,i){const o=new He(i);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=r,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class He{constructor(e){this.m_shape=null,this.m_geometry=o.n,this.m_sortedVertices=new a.R,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_sorterSegmentBuffer1=null,this.m_sorterSegmentBuffer2=null,this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=o.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=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=new h.P;this.m_shape.queryXY(s,n);const r=new h.P,o=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(o,r),n.equals(r))return 0;const a=this.m_bunchEdgeCenterPoints[e],m=new h.P;this.m_shape.queryXY(a,m);const l=this.m_bunchEdgeCenterPoints[t],g=new h.P;this.m_shape.queryXY(l,g);const c=new h.P;c.setSub(n,m);const u=new h.P;return u.setSub(r,g),(c.isZero()||u.isZero())&&(0,i.w)(""),h.P.compareVectors(c,u)}compareAnglesCurves_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeEndPoints[t],r=this.m_bunchEdgeCenterPoints[e],i=this.m_bunchEdgeCenterPoints[t],a=this.m_shape.getNextVertex(r)===s,h=this.m_shape.getNextVertex(i)===n,m=a?this.m_shape.isCurve(r):this.m_shape.isCurve(s),l=h?this.m_shape.isCurve(i):this.m_shape.isCurve(n);return m||l?(this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new o.S),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new o.S),a?this.m_shape.querySegment(r,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(s,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),h?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse()),(0,o.R)(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())):this.compareAnglesLines_(e,t)}beforeRemoveVertex_(e,t){const s=this.m_shape.getUserIndex(e,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_(e),t){const t=this.m_shape.getPathFromVertex(e);if(t!==o.n&&this.m_shape.getFirstVertex(t)===e){const s=this.m_shape.getNextVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s);{const s=this.m_shape.getPrevVertex(e);if(s!==e&&this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s)}}this.m_shape.setFirstVertex(t,o.n),this.m_shape.setLastVertex(t,o.n)}}}processBunch_(){let e=!1;const t=new h.P(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,n=0,r=!0;for(;s!==this.m_nextVertexToProcess;){const e=this.m_sortedVertices.getData(s);r&&(this.m_shape.queryXY(e,t),r=!1);const i=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex)!==a.a7&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,a.a7),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==a.a7&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,a.a7),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),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((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e],s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,e)}const i=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e];if(-1===t)continue;const s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!i)break;e=!0}return e}processCrossOvers_(e){let t=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,o=this.m_bunchEdgeIndices.length;i<o&&-1!==n&&-1!==r&&n!==r;i++){const i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[r],a=this.m_bunchEdgeEndPoints[i],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a),l=!0);let g=this.m_shape.getNextVertex(h),c=!1;this.m_shape.isEqualXYPoint2D(g,e)||(g=this.m_shape.getPrevVertex(h),c=!0);const u=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=c?this.m_shape.getPrevVertex(g):this.m_shape.getNextVertex(g);let p=!1;(this.removeSpike_(m)||this.removeSpike_(g)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(u)||this.removeSpike_(_))&&(p=!0),m!==g&&(!p&&this.m_shape.isEqualXY(a,h)&&(p=this.resolveOverlap_(l,c,m,a,g,h)),!p&&this.m_shape.isEqualXY(u,_)&&(p=this.resolveOverlap_(!l,!c,m,u,g,_)),!p&&this.m_shape.isEqualXY(a,_)&&(p=this.resolveOverlap_(l,!c,m,a,g,_)),!p&&this.m_shape.isEqualXY(u,h)&&(p=this.resolveOverlap_(!l,c,m,u,g,h))),p&&(t=!0),s||=p,n=p?this.getNextEdgeIndex_(n):r,r=this.getNextEdgeIndex_(n)}}if(!t){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let r=0,i=this.m_bunchEdgeIndices.length;r<i&&-1!==s&&-1!==n&&s!==n;r++){const r=this.m_bunchEdgeIndices[s],i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[r],a=this.m_bunchEdgeEndPoints[i];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),g=this.getDirection_(m,a),c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),u=g?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,g,o,h,c,a,m,u);1!==_?0===_?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):t=!0}}return t}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===i.G.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)&&new ks(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const t=this.m_shape.getPointCount(this.m_geometry),s=new a.a(0);this.m_shape.dbgVerifyMonotone();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==o.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(s,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let e=0;e<t;e++){const t=s.read(e),n=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,t);this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,n)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let n=0,r=!1;do{r=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new h.P(0,0);this.m_firstCoincidentVertex!==a.R.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,o=this.m_firstCoincidentVertex;for(;o!==a.R.st_nullNode()&&(o=this.m_sortedVertices.getNext(o),o!==a.R.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(o),n=h.P.getNAN();if(this.m_shape.queryXY(e,n),t.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=o;const e=this.processBunch_();o=this.m_nextVertexToProcess,o!==a.R.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(o),n),e&&(r=!0)}t.setCoordsPoint2D(n),this.m_firstCoincidentVertex=o,s=0}}this.m_nextVertexToProcess=-1,s>0&&this.processBunch_()&&(r=!0),n++>10&&(0,i.d)(""),r&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(r=!0),e||=r}while(r);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=function(e,t,s,n,r){const i=new ke(r);return i.m_shape=e,i.m_geometry=t,i.m_sortedVertices=s,i.m_bFixSelfTangency=n,i.fixRingOrientation_()}(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,s,n,r,i,o,a){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(i),-1;const m=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),g=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),c=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),u=(0,h.d)(8,Number.NaN),_=(0,h.d)(4,Number.NaN);u[0]=0,_[0]=m,u[1]=0,_[1]=l,u[2]=1,_[2]=g,u[3]=1,_[3]=c;for(let e=1;e<4;e++){const t=_[e],s=u[e];let n=e-1;for(;n>=0&&_[n]>t;)_[n+1]=_[n],u[n+1]=u[n],n--;_[n+1]=t,u[n+1]=s}let p=0;if(u[0]&&(p|=1),u[1]&&(p|=2),u[2]&&(p|=4),u[3]&&(p|=8),5!==p&&10!==p)return 0;if(e!==t&&(a=(0,h.c)(i,i=a)),e)this.m_shape.setNextVertex(a,n),this.m_shape.setPrevVertex(n,a),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,n),this.m_shape.setNextVertex(n,a),this.m_shape.setPrevVertex(r,o),this.m_shape.setNextVertex(o,r),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const r=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,r),this.m_shape.setSegmentToIndex(t,s)}}return 1}resolveOverlap_(e,t,s,n,r,i){return this.resolveOverlapOddEven_(e,t,s,n,r,i)}resolveOverlapOddEven_(e,t,s,n,r,i){if(e!==t){e||(r=(0,h.c)(s,s=r),i=(0,h.c)(n,n=i));const t=this.m_shape.getNextVertex(r),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,t),this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(s),t=this.m_shape.getVertexIndex(r),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(s),t=this.m_shape.getSegmentParentage(r);this.m_shape.setSegmentParentageAndBreak(s,t,!0),this.m_shape.setSegmentParentageAndBreak(r,e,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}this.removeSpike_(r)}else{const o=e?s:n,a=t?r:i,h=e?n:s,m=t?i:r;let l=null;if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);const t=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(t,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let g=-1;this.m_bHasSegmentParentage&&(g=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 u=m;for(;u!==a;){const e=this.m_shape.getPrevVertex(u),t=this.m_shape.getNextVertex(u);if(this.m_shape.setPrevVertex(u,t),this.m_shape.setNextVertex(u,e),c||=u===o,this.m_bHasSegments&&u!==o){const e=this.m_shape.getVertexIndex(t),s=l;l=this.m_shape.getSegmentFromIndex(e),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(e,s)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,g),g=e}u=t}let _=null;if(!c){const e=this.m_shape.getPrevVertex(a),t=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,t),this.m_shape.setNextVertex(a,e),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let p=-1,d=-1;if(this.m_bHasSegmentParentage&&(p=c?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),d=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,p,!0),this.m_shape.setSegmentParentageAndBreak(h,d,!0)),_){const e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,_)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==o.n;){const s=this.m_shape.getNextPath(t);let n=this.m_shape.getFirstVertex(t);for(let s=0,r=this.m_shape.getPathSize(t);s<r&&r>1;){this.progress_();const{v:i,bModified:a}=this.checkAndCleanupSpike_(t,n);if(i===o.n)break;a?(e=!0,n=i,s=0,r=this.m_shape.getPathSize(t)):(n=i,s++)}t=s}return e}checkAndCleanupSpike_(e,t){const s={v:o.n,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=o.n,a=o.n;for(;this.m_shape.isEqualXY(n,r)&&(i=n,a=r,r!==t);)n=this.m_shape.getPrevVertex(n),r=this.m_shape.getNextVertex(r);if(i===o.n)return s.v=r,s;s.bModified=!0;for(let e=this.m_shape.getNextVertex(i);this.beforeRemoveVertex_(e,!1),e!==a;e=this.m_shape.getNextVertex(e));if(i===t)return this.m_polylineDegeneracies!==o.n?this.m_shape.movePath(this.m_polylineDegeneracies,o.n,e):this.m_shape.removePath(e),s.v=o.n,s;{const e=this.m_shape.peelALoopIntoAPath(i,a);this.m_polylineDegeneracies!==o.n?this.m_shape.movePath(this.m_polylineDegeneracies,o.n,e):this.m_shape.removePath(e)}return s.v=i,s}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(e),n=o.n,r=o.n;for(;this.m_shape.isEqualXY(t,s)&&(n=t,r=s,s!==e);)t=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(s);if(n===o.n)return!1;if(this.m_shape.peelALoop(n,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===o.n)for(let e=this.m_shape.getNextVertex(r);;){const t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(e),null),this.m_shape.removeVertexInternal(e,!1),e===r)break;e=t}else{for(let e=r;;){const t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!1),e=t,e===r)break}const e=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,o.n,r,r,e)}return!0}fixOrphanVertices_(){let e=0;for(let e=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==e;e=this.m_sortedVertices.getNext(e)){const t=this.m_sortedVertices.getData(e);this.m_shape.setPathToVertex(t,o.n)}let t=0;for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==o.n;){const n=this.m_shape.getFirstVertex(s);if(n===o.n||this.m_shape.getPathFromVertex(n)!==o.n){const e=s;s=this.m_shape.getNextPath(s),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(n,s);let r=1;for(let e=this.m_shape.getNextVertex(n);e!==n;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,s),r++;this.m_shape.setRingAreaValid(s,!1),this.m_shape.setPathSize(s,r),this.m_shape.setLastVertex(s,this.m_shape.getPrevVertex(n)),t+=r,e++,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 n=this.m_sortedVertices.getData(s);if(this.m_shape.getPathFromVertex(n)!==o.n)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,o.n,n,n,r);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let s=0;for(let e=this.m_shape.getFirstGeometry();e!==o.n;e=this.m_shape.getNextGeometry(e))s+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}getPrevEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}transferVertexData_(e,t){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(e){const t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);-1!==t&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function Ae(e,t,s,n,m,l=!0){switch(Me(n)){case 0:break;case 1:(0,i.a)("relation string length has to be 9 characters");break;default:(0,i.a)("relation string")}if(l){const r=function(e,t,s){return function(e){return"T*F**FFF*"===e}(e)?3:function(e){return"FF*FF****"===e}(e)?4:function(e,t,s){return!(0===t&&0===s||(2===t&&2===s?"F***T****"!==e:2!==t&&1!==t||0!==s||"F**T*****"!==e))}(e,t,s)?8:function(e,t,s){return t>s?"T*****T**"===e:1===t&&1===s&&"0********"===e}(e,t,s)?16:function(e){return"T**FF*FF*"===e}(e)?64:function(e){return"T*****FF*"===e}(e)?1:function(e,t,s){return t===s&&(1!==t?"T*T***T**"===e:"1*T***T**"===e)}(e,t,s)?32:0}(n,e.getDimension(),t.getDimension());if(0!==r)return $e(e,t,s,r,m)}let g=0;if("number"==typeof s)g=s;else{const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n);const i=r.Envelope2D.constructEmpty();t.queryEnvelope(i);const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(i),g=(0,a.d)(s,o,!1)}const c=je(e,g),u=je(t,g);if(c.isEmpty()||u.isEmpty())return function(e,t,s){const n=(0,h.d)(9,-1);if(e.isEmpty()&&t.isEmpty())return Xe(n,s);let a,m=!1;e.isEmpty()?(a=t,m=!0):a=e,n[0]=-1,n[1]=-1,n[3]=-1,n[4]=-1,n[6]=-1,n[7]=-1,n[8]=2;const l=a.getGeometryType();if((0,i.h)(l))if(l===i.G.enumPolygon)if(0!==a.calculateArea2D())n[2]=2,n[5]=1;else{n[5]=-1;const e=r.Envelope2D.constructEmpty();a.queryEnvelope(e),n[2]=e.height()||e.width()?1:0}else{const e=0!==a.calculateLength2D();n[2]=e?1:0,n[5]=(0,o.K)(a)?0:-1}else n[2]=0,n[5]=-1;return m&&We(n),Xe(n,s)}(c,u,n);const _=c.getGeometryType(),p=u.getGeometryType();let d=!1;switch(_){case i.G.enumPolygon:switch(p){case i.G.enumPolygon:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaAreaPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaAreaDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPolyline:d=Ue(c,u,g,n,m);break;case i.G.enumPoint:d=Ye(c,u,g,n);break;case i.G.enumMultiPoint:d=qe(c,u,g,n,m)}break;case i.G.enumPolyline:switch(p){case i.G.enumPolygon:d=Ue(u,c,g,Ze(n),m);break;case i.G.enumPolyline:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setLineLinePredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.lineLineDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),Le(r,h.m_topoGraph,h.m_clusterIndexA),Le(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPoint:d=Be(c,u,g,n,m);break;case i.G.enumMultiPoint:d=Oe(c,u,g,n,m)}break;case i.G.enumPoint:switch(p){case i.G.enumPolygon:d=Ye(u,c,g,Ze(n));break;case i.G.enumPolyline:d=Be(u,c,g,Ze(n),m);break;case i.G.enumPoint:d=function(e,t,s,n){const r=e.getXY(),i=t.getXY(),o=(0,h.d)(9,-1);return h.P.sqrDistance(r,i)<=s*s?o[0]=0:(o[2]=0,o[6]=0),o[8]=2,Xe(o,n)}(c,u,g,n);break;case i.G.enumMultiPoint:d=Re(u,c,g,Ze(n))}break;case i.G.enumMultiPoint:switch(p){case i.G.enumPolygon:d=qe(u,c,g,Ze(n),m);break;case i.G.enumPolyline:d=Oe(u,c,g,Ze(n),m);break;case i.G.enumMultiPoint:d=function(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setPointPointPredicates_();const m=new r.Envelope2D,l=new r.Envelope2D;e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.pointPointDisjointPredicates_(),g=!0),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}(c,u,g,n,m);break;case i.G.enumPoint:d=Re(c,u,g,n)}break;default:d=!1}return d}function Me(e){if(9!==e.length)return 1;for(let t=0;t<9;t++){const s=e[t];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function Ue(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaLinePredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaLineDisjointPredicates_(e,t),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),Le(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function qe(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setAreaPointPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.areaPointDisjointPredicates_(e),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function Oe(e,t,s,n,i){const h=new ze;h.resetMatrix_(),h.setPredicates_(n),h.setLinePointPredicates_();const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let g=!1;if(tt(m,l,s)&&(h.linePointDisjointPredicates_(e),g=!0),g||st(e,t),!g){const n=new o.E,r=n.addGeometry(e),m=n.addGeometry(t);h.setEditShapeCrackAndCluster_(n,new a.C(s,0),i),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),Le(r,h.m_topoGraph,h.m_clusterIndexA),h.computeMatrixTopoGraphClusters_(r,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.removeShape()}return Xe(h.m_matrix,h.m_scl)}function Ye(e,t,s,n,i){const o=new ze;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a);const h=t.getXY();let m=!1;if(nt(h,a,s)&&(o.areaPointDisjointPredicates_(e),m=!0),!m){const t=es(e,h,s);if(1===t)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===t)if(o.m_matrix[6]=-1,0!==e.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 t=r.Envelope2D.constructEmpty();e.queryEnvelope(t),o.m_matrix[2]=t.height()||t.width()?1:-1}else o.areaPointDisjointPredicates_(e)}return Xe(o.m_matrix,n)}function Be(e,t,s,n,i){const a=new ze;a.resetMatrix_(),a.setPredicates_(n),a.setLinePointPredicates_();const h=r.Envelope2D.constructEmpty();e.queryEnvelope(h);let m=!1;if(nt(t.getXY(),h,s)&&(a.linePointDisjointPredicates_(e),m=!0),!m){let n=null,r=!1,h=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&($e(e,t,s,4,i)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(n=(0,o.c)(e),h=!$e(n,t,s,4,i),r=!0,a.m_matrix[0]=h?-1:0),a.m_matrix[6]=-1)),a.m_performPredicates[3]&&(null!==n&&n.isEmpty()?a.m_matrix[3]=-1:(r||(null==n&&(n=(0,o.c)(e)),h=!$e(n,t,s,4,i),r=!0),a.m_matrix[3]=h?0:-1)),a.m_performPredicates[5])if(null!==n&&n.isEmpty())a.m_matrix[5]=-1;else if(r&&!h)a.m_matrix[5]=0;else{null===n&&(n=(0,o.c)(e));const r=$e(n,t,s,3,i);a.m_matrix[5]=r?-1:0}if(a.m_performPredicates[2])if(0!==e.calculateLength2D())a.m_matrix[2]=1;else{const n=new o.M({vd:e.getDescription()});n.addPoints(e,0,e.getPointCount());const r=$e(n,t,s,3,i);a.m_matrix[2]=r?-1:0}}return Xe(a.m_matrix,a.m_scl)}function Re(e,t,s,n,i){const o=new ze;o.resetMatrix_(),o.setPredicates_(n),o.setPointPointPredicates_();const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a);const m=t.getXY(),l=new h.P;let g=!1;if(nt(m,a,s)&&(o.pointPointDisjointPredicates_(),g=!0),!g){let t=!1,n=!0;const r=s*s;for(let s=0;s<e.getPointCount()&&(e.queryXY(s,l),h.P.sqrDistance(l,m)<=r?t=!0:n=!1,!t||n);s++);t?(o.m_matrix[0]=0,o.m_matrix[2]=n?-1:0,o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[2]=0,o.m_matrix[6]=0)}return Xe(o.m_matrix,n)}function Xe(e,t){for(let s=0;s<9;s++)switch(t[s]){case"T":if(-1===e[s])return!1;break;case"F":if(-1!==e[s])return!1;break;case"0":if(0!==e[s])return!1;break;case"1":if(1!==e[s])return!1;break;case"2":if(2!==e[s])return!1}return!0}function Le(e,t,s){const n=t.getGeometryID(e);for(let e=t.getFirstCluster();e!==o.n;e=t.getNextCluster(e)){if(0===(t.getClusterParentage(e)&n))continue;const r=t.getClusterHalfEdge(e);if(r===o.n){t.setClusterUserIndex(e,s,0);continue}let i=r,a=0;do{const e=i;0!==(t.getHalfEdgeParentage(e)&n)&&a++,i=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(i!==r);t.setClusterUserIndex(e,s,a)}}class ze{nullFunc(){return(0,i.d)("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new K,this.m_matrix=(0,h.d)(9,0),this.m_maxDim=(0,h.d)(9,0),this.m_performPredicates=(0,h.d)(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_(e){this.m_scl=e;for(let e=0;e<9;e++)"*"!==this.m_scl[e]?(this.m_performPredicates[e]=!0,this.m_predicateCount++):this.m_performPredicates[e]=!1}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&-2===this.m_matrix[e]&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return!(-2===this.m_matrix[e]||(-1===this.m_matrix[e]?(this.m_performPredicates[e]=!1,this.m_predicateCount--,0):"T"!==this.m_scl[e]&&"F"!==this.m_scl[e]&&this.m_matrix[e]<this.m_maxDim[e]||(this.m_performPredicates[e]=!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_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,s,n,i){const o=-1!==t,a=-1!==n;if(o||a)if(("T"!==s&&"F"!==s&&o||"T"!==i&&"F"!==i&&a)&&0===e.calculateArea2D()){if(a&&(this.m_matrix[n]=-1),o){const s=r.Envelope2D.constructEmpty();e.queryEnvelope(s),this.m_matrix[t]=s.height()||s.width()?1:0}}else o&&(this.m_matrix[t]=2),a&&(this.m_matrix[n]=1)}areaAreaContainsPredicates_(e){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_(e,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(e){this.areaAreaContainsPredicates_(e),We(this.m_matrix)}areaLineDisjointPredicates_(e,t){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 e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=(0,o.K)(t);this.m_matrix[7]=e?0:-1}this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){const e=this.m_scl[0],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const e=(0,o.K)(t);this.m_matrix[1]=e?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_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){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_(e,t){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 t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=(0,o.K)(e);this.m_matrix[5]=t?0:-1}if(this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=(0,o.K)(t);this.m_matrix[7]=e?0:-1}}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=(0,o.K)(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,s,3);const t=this.isPredicateKnown_(3);n&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,s);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,s,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,s,t,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(7);n&&=r}return n}lineLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,s,t,this.m_clusterIndexB,this.m_clusterIndexA,3);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,s,this.m_clusterIndexA,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,s,t,this.m_clusterIndexB,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(6);n&&=r}return n}pointPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}return n}interiorAreaInteriorArea_(e,t,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(n&t)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(e,t,s,n){if(2===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(n&t)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(e),r=this.m_topoGraph.getClusterParentage(n);if(0!==(r&t)&&0!==(r&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(r&s)&&0===(i&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(e,t,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[1]=0)}}}interiorAreaExteriorLine_(e,t,s){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getHalfEdgeParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,s,n){if(1===this.m_matrix[3])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(r&t)||0===(r&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(e,t,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);0!==(n&t)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(e),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(s&t)&&0===(n&t)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)&&0===(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[7]=0)}}}interiorLineInteriorLine_(e,t,s,n,r){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(i&t)||0===(i&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2==0&&t%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(e,t,s,n,r,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&t)&&0!==(a&s)){const e=this.m_topoGraph.getClusterUserIndex(o,n),t=this.m_topoGraph.getClusterUserIndex(o,r);if(e%2==0&&t%2!=0)return void(this.m_matrix[i]=0)}}}interiorLineExteriorLine_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(e,t,s,n,r){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2!=0&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(e,t,s,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const t=this.m_topoGraph.getHalfEdgeTo(e);if(0===(this.m_topoGraph.getClusterParentage(t)&s)&&this.m_topoGraph.getClusterUserIndex(t,n)%2!=0)return void(this.m_matrix[r]=0)}}interiorAreaInteriorPoint_(e,t){if(0!==this.m_matrix[0]&&0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0!==(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(e,t){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(e,t){1!==this.m_matrix[5]&&0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(0!==this.m_matrix[6]&&0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0===(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[0])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0===(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2!=0||(this.m_matrix[0]=0)}interiorLineExteriorPoint_(e,t,s,n){if(1!==this.m_matrix[2])if(-1===this.m_topoGraph.getClusterHalfEdge(e)){if(0!==this.m_matrix[2]&&0===(this.m_topoGraph.getClusterParentage(e)&s))return void(this.m_matrix[2]=0)}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[3])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0===(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2==0||(this.m_matrix[3]=0)}boundaryLineExteriorPoint_(e,t,s,n){if(0===this.m_matrix[5])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||this.m_topoGraph.getClusterUserIndex(e,n)%2==0||(this.m_matrix[5]=0)}exteriorLineInteriorPoint_(e,t,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(e);0!==(n&t)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(e,t,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(e,t,s,n){if(0===this.m_matrix[n])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(e,n,r),s))break;continue}let i=t;do{let e=i;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(e,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==i&&!s);if(s)break;i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(i!==t);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);for(let e=this.m_topoGraph.getFirstCluster();e!==o.n&&(s=this.m_predicatesCluster(e,n,r),!s);e=this.m_topoGraph.getNextCluster(e));s||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,s){let n=0;if(e.hasCurves()){const r=new cs,i=e.getEnvelope2D(s),o=ms(t.total(),i);n=gs(o,0),os(e,o,t.total(),0,r,null,s),r.clearStitcher(e)}_s(e,t.add(n),s,!1,!1),e.filterClosePoints(0,!0,!0,!1,o.n);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,!1,o.n,s);this.setEditShape_(e,s)}}function We(e){const t=e[1],s=e[2],n=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=s,e[7]=n}function je(e,t,s){const n=e.getGeometryType();if((0,i.f)(n)){const t=new o.a({vd:e.getDescription()});return t.addSegment(e,!0),t}if(n===i.G.enumEnvelope){const s=e,n=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),n.height()<=t&&n.width()<=t){const t=new a.P({vd:e.getDescription()});return s.getCenter(t),t}if(n.height()<=t||n.width()<=t){const t=new o.a({vd:e.getDescription()}),n=new a.P;return s.queryCornerByVal(0,n),t.startPathPoint(n),s.queryCornerByVal(2,n),t.lineToPoint(n),t}const i=new o.P({vd:e.getDescription()});return i.addEnvelope(s,!1),i}return e}function Ze(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Ke{nullFunc(){return(0,i.d)("should not be called"),!1}constructor(e,t,s,n=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=r.Envelope2D.constructEmpty(),this.m_envInter=r.Envelope2D.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const o=e.getAccelerators();let h=null;null!=o&&(h=n?o.getQuadTreeForPaths():o.getQuadTree());const m=t.getAccelerators();let l=null;if(null!=m&&(l=n?m.getQuadTreeForPaths():m.getQuadTree()),null===h&&null===l&&!n){const n=e.getPointCount(),o=t.getPointCount();if(n>10&&o>10){const m=r.Envelope2D.constructEmpty(),g=r.Envelope2D.constructEmpty(),c=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(m),t.queryLooseEnvelope(g),m.inflateCoords(s,s),g.inflateCoords(s,s),c.setCoords({env2D:m}),c.intersect(g),n>=o?h=(0,i.h)(e.getGeometryType())?(0,a.H)(e,c):(0,a._)(e,c):l=(0,i.h)(t.getGeometryType())?(0,a.H)(t,c):(0,a._)(t,c)}}this.construct_(e,h,t,l,s,n)}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,i.h)(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,i.h)(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,i.q)(""),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,i.q)(""),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_(e,t,s,n,o,h){const m=r.Envelope2D.constructEmpty(),l=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(m),s.queryLooseEnvelope(l),m.inflateCoords(o,o),l.inflateCoords(o,o),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=s;const g=e.getGeometryType(),c=s.getGeometryType();this.m_bPaths=h,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.G.enumUnknown,this.m_bQuadTree=!1,null!==t&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,(0,i.h)(c)?(this.m_queryType=c,this.m_function=this.nextPath_,h?this.m_pathIndex=s.getPathCount():this.m_segIter=s.querySegmentIterator()):(this.m_queryType=c,this.m_function=this.nextPoint_,this.m_pointIndex=s.getPointCount())),this.m_bQuadTree||null!==n&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=n,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,(0,i.h)(g)?(this.m_queryType=g,this.m_function=this.nextPath_,h?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=g,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(h&&(0,i.h)(g)&&(0,i.h)(c)?this.m_intersector=(0,a.a2)(e,s,o):(0,i.h)(g)&&(0,i.h)(c)?(this.m_intersector=(0,a.$)(e,s,o),this.m_bSwapElements=!1):(0,i.h)(g)&&!(0,i.h)(c)?(this.m_intersector=(0,a.a0)(e,s,o),this.m_bSwapElements=!1):!(0,i.h)(g)&&(0,i.h)(c)?(this.m_intersector=(0,a.a0)(s,e,o),this.m_bSwapElements=!0):(this.m_intersector=(0,a.a1)(e,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 e=this.m_segIter.nextSegment(),t=new r.Envelope2D;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const e=new h.P;if(this.m_bSwapElements){const t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{const t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(r.Envelope2D.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&((0,i.h)(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Qe(e){return 2===e?1:1===e?2:128===e?64:64===e?128:e}function Je(e,t,s){let n;if(e instanceof io||null===e){const i=r.Envelope2D.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(s),n=(0,a.d)(e,i,!1)}else n=e;return n}function $e(e,t,s,n,m){if(e.isEmpty()||t.isEmpty())return 4===n;(0,i.c)(e),(0,i.c)(t);let g=e.getGeometryType(),c=t.getGeometryType();if(g===i.G.enumEnvelope){if(c===i.G.enumEnvelope)return function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return 4===n;const i=r.Envelope2D.constructEmpty();e.queryEnvelope(i);const o=r.Envelope2D.constructEmpty();t.queryEnvelope(o);const a=Je(s,i,o);switch(n){case 4:return tt(i,o,a);case 2:return Tt(o,i,a,!1);case 128:return Tt(o,i,a,!0);case 1:return Tt(i,o,a,!1);case 64:return Tt(i,o,a,!0);case 3:return Nt(i,o,a);case 8:return function(e,t,s){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;const n=new r.Envelope2D;return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.intersect(t),!(!n.isEmpty()&&n.height()>s&&n.width()>s||(n.setCoords({env2D:e}),n.inflateCoords(s,s),n.intersect(t),n.isEmpty()))}(i,o,a);case 32:return function(e,t,s){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;if(kt(e,t,s))return!1;if(kt(t,e,s))return!1;const n=new r.Envelope2D;return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.intersect(t),!n.isEmpty()&&(n.height()>s||n.width()>s)}(i,o,a);case 16:return!1}return!1}(e,t,s,n);if(c===i.G.enumPoint)return et(t,e,s,Qe(n))}else if(g===i.G.enumPoint){if(c===i.G.enumEnvelope)return et(e,t,s,n);if(c===i.G.enumPoint)return function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=t.getXY();let m;if(s instanceof io||null===s){const e=r.Envelope2D.constructEmpty();e.setCoords({pt:i}),e.merge(o),m=(0,a.d)(s,e,!1)}else m=s;switch(n){case 4:return function(e,t,s){return h.P.sqrDistance(e,t)>s*s}(i,o,m);case 2:case 128:return wt(o,i,m);case 1:case 64:return wt(i,o,m);case 3:return Gt(i,o,m)}return!1}(e,t,s,n)}const u=r.Envelope2D.constructEmpty();e.queryEnvelope(u);const _=r.Envelope2D.constructEmpty();t.queryEnvelope(_);const p=Je(s,u,_);if(tt(u,_,p))return 4===n;let d=!1,f=null,x=null,P=null,E=null;switch((0,i.f)(g)?(f=new o.a({vd:e.getDescription()}),f.addSegment(e,!0),P=f,g=i.G.enumPolyline):P=e,(0,i.f)(c)?(x=new o.a({vd:t.getDescription()}),x.addSegment(t,!0),E=x,c=i.G.enumPolyline):E=t,g!==i.G.enumEnvelope&&c!==i.G.enumEnvelope?(P.getDimension()<E.getDimension()||g===i.G.enumPoint&&c===i.G.enumMultiPoint)&&(n=Qe(n)):g!==i.G.enumPolygon&&c!==i.G.enumEnvelope&&(n=Qe(n)),g){case i.G.enumPolygon:switch(c){case i.G.enumPolygon:d=function(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return st(e,t,0,!0),1===Dt(e,t,s,!0)}(e,t,s);case 2:return _t(t,e,s,r);case 128:return pt(t,e,s);case 1:return _t(e,t,s,r);case 64:return pt(e,t,s);case 3:return ut(e,t,s,r);case 8:return function(e,t,s){return st(e,t),Lt(e,t,s,null)}(e,t,s);case 32:return function(e,t,s,n){return st(e,t),zt(e,t,s,n)}(e,t,s,r)}return!1}(P,E,p,n,m);break;case i.G.enumPolyline:d=rt(P,E,p,n,m);break;case i.G.enumPoint:d=it(P,E,p,n);break;case i.G.enumMultiPoint:d=ot(P,E,p,n);break;case i.G.enumEnvelope:d=at(P,E,p,n,m)}break;case i.G.enumPolyline:switch(c){case i.G.enumPolygon:d=rt(E,P,p,n,m);break;case i.G.enumPolyline:d=function(e,t,s,n,i){switch(n){case 4:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl();return!new Ke(n,r,s,!0).next()||!Ot(e,t,s)}(e,t,s);case 2:return Et(t,e,s,i);case 128:return yt(t,e,s,i);case 1:return Et(e,t,s,i);case 64:return yt(e,t,s,i);case 3:return function(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!Nt(i,o,s)&&(st(e,t),!!At(e,t,s)||(e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"**F**FFF*",n,!1):Ut(e,t,s,!1)))}(e,t,s,i);case 8:return function(e,t,s,n){st(e,t);const i=[],a=Yt(e,t,s,i);if(-2===a){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=(0,l.c)(e,a,s,0,n),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=(0,l.c)(t,a,s,0,n),m.isEmpty())return!1}else m=t;return Ae(h,m,s,"F********",n,!1)}if(0!==a)return!1;const h=new o.M;for(let e=0;e<i.length;e+=2){const t=i[e],s=i[e+1];h.addXY(t,s)}const m=e.getBoundary(),g=t.getBoundary();return m.addPoints(g,0,g.getPointCount()),!m.isEmpty()&&Ct(m,h,s)}(e,t,s,i);case 32:return function(e,t,s,n){st(e,t);const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=Ht(i,o,s),h=Ht(o,i,s),m=e.hasNonLinearSegments(),g=t.hasNonLinearSegments(),c=Yt(e,t,s,null);if(-1===c)return!1;if(1===c){if(a&&h)return!0;if(!m&&!g)return a&&!h?!qt(t,e,s,!1):h&&!a?!qt(e,t,s,!1):!qt(e,t,s,!1)&&!qt(t,e,s,!1)}const u=r.Envelope2D.constructEmpty(),_=r.Envelope2D.constructEmpty(),p=r.Envelope2D.constructEmpty();let d,f;u.setCoords({env2D:i}),u.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:o}),_.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:u}),p.intersect(_);let x="";if(x+="1*",a){if(t.getPointCount()>10){if(f=(0,l.c)(t,p,s,0,n),f.isEmpty())return!1}else f=t;x+="****"}else f=t,x+="T***";if(h){if(e.getPointCount()>10){if(d=(0,l.c)(e,p,s,0,n),d.isEmpty())return!1}else d=e;x+="***"}else d=e,x+="T**";return Ae(d,f,s,x,n,!1)}(e,t,s,i);case 16:return function(e,t,s,n){st(e,t);const i=[],a=Yt(e,t,s,i);if(-2===a){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=(0,l.c)(e,a,s,0,n),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=(0,l.c)(t,a,s,0,n),m.isEmpty())return!1}else m=t;return Ae(h,m,s,"0********",n,!1)}if(0!==a)return!1;const h=new o.M;for(let e=0;e<i.length;e+=2){const t=i[e],s=i[e+1];h.addXY(t,s)}const m=e.getBoundary(),g=t.getBoundary();return m.addPoints(g,0,g.getPointCount()),!!m.isEmpty()||!Ct(m,h,s)}(e,t,s,i)}return!1}(P,E,p,n,m);break;case i.G.enumPoint:d=ht(P,E,p,n);break;case i.G.enumMultiPoint:d=mt(P,E,p,n);break;case i.G.enumEnvelope:d=lt(P,E,p,n,m)}break;case i.G.enumPoint:switch(c){case i.G.enumPolygon:d=it(E,P,p,n);break;case i.G.enumPolyline:d=ht(E,P,p,n);break;case i.G.enumMultiPoint:d=gt(E,P,p,n)}break;case i.G.enumMultiPoint:switch(c){case i.G.enumPolygon:d=ot(E,P,p,n);break;case i.G.enumPolyline:d=mt(E,P,p,n);break;case i.G.enumMultiPoint:d=function(e,t,s,n){switch(n){case 4:return function(e,t,s){const n=e,r=t,i=new Ke(n,r,s,!1),o=s*s,a=new h.P,m=new h.P;for(;i.next();){const e=i.getRedElement(),t=i.getBlueElement();if(n.queryXY(e,a),r.queryXY(t,m),h.P.sqrDistance(a,m)<=o)return!1}return!0}(e,t,s);case 2:case 128:return Ct(t,e,s);case 1:case 64:return Ct(e,t,s);case 3:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!!Nt(n,i,s)&&(!!function(e,t,s){if(e.getPointCount()!==t.getPointCount())return!1;const n=new h.P,r=new h.P;let i=!0;const o=s*s;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,n),t.queryXY(s,r),h.P.sqrDistance(n,r)>o){i=!1;break}return!!i}(e,t,s)||Mt(e,t,s,!1,!0,!1))}(e,t,s);case 32:return function(e,t,s){return Mt(e,t,s,!1,!1,!0)}(e,t,s)}return!1}(P,E,p,n);break;case i.G.enumPoint:d=gt(P,E,p,n);break;case i.G.enumEnvelope:d=ct(P,E,p,n)}break;case i.G.enumEnvelope:switch(c){case i.G.enumPolygon:d=at(E,P,p,n,m);break;case i.G.enumPolyline:d=lt(E,P,p,n,m);break;case i.G.enumMultiPoint:d=ct(E,P,p,n)}}return d}function et(e,t,s,n,i){if(e.isEmpty()||t.isEmpty())return 4===n;const o=e.getXY(),h=r.Envelope2D.constructEmpty();t.queryEnvelope(h);const m=function(e,t,s){let n;if(e instanceof io||null===e){const i=r.Envelope2D.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(s),n=(0,a.d)(e,i,!1)}else n=e;return n}(s,o,h);switch(n){case 4:return nt(o,h,m);case 2:case 128:return function(e,t,s){if(t.height()<=s||t.width()<=s)return!1;const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.containsExclusive(e)}(o,h,m);case 1:case 64:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D;return n.setCoords({pt:e}),Nt(n,t,s)}(o,h,m);case 8:return function(e,t,s){if(t.height()<=s||t.width()<=s)return!1;const n=new r.Envelope2D,i=new r.Envelope2D;return n.setCoords({env2D:t}),n.inflateCoords(s,s),!!n.contains(e)&&(i.setCoords({env2D:t}),i.inflateCoords(-s,-s),!i.containsExclusive(e))}(o,h,m)}return!1}function tt(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!e.isIntersecting(n)}function st(e,t,s,n=!1){const r=e.getGeometryType(),o=t.getGeometryType();if((0,i.i)(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();(0,i.g)(null===e)}}if((0,i.i)(o)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();(0,i.g)(null===t)}}return 0}function nt(e,t,s,n){const i=r.Envelope2D.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(s,s),!i.contains(e)}function rt(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t,0,!0),1===Dt(e,t,s,!0)}(e,t,s);case 1:return function(e,t,s,n){const i=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(h),!!kt(i,h,s)&&(st(e,t),function(e,t,s,n){const i=[!1],h=Vt(e,t,s,i);if(i[0])return h;const m=r.Envelope2D.constructEmpty();let g;if(t.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(g=(0,l.c)(e,m,s,0,n),g.isEmpty())return!1}else g=e;return function(e,t,s,n){const i=new ze;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaLinePredicates_();const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let l=!1;if(tt(h,m,s)&&(i.areaLineDisjointPredicates_(e,t),l=!0),l||st(e,t),l)return Xe(i.m_matrix,i.m_scl);const g=new o.E,c=g.addGeometry(e),u=g.addGeometry(t);return i.setEditShapeCrackAndCluster_(g,new a.C(s,0),n),0!==g.getPointCount(c)&&(i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape(),Xe(i.m_matrix,i.m_scl))}(g,t,s,n)}(e,t,s,n))}(e,t,s,i);case 64:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!!kt(n,i,s)&&(st(e,t),2===Dt(e,t,s,!1))}(e,t,s);case 8:return dt(e,t,s,i);case 16:return function(e,t,s){return st(e,t),function(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),m=o.querySegmentIterator(),g=(0,h.d)(2,Number.NaN),c=(0,h.d)(2,Number.NaN),u=new Ke(i,o,s);let _=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();a.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=a.nextSegment(),r=m.nextSegment();let i=0;if(Kt(n,r)?!_&&r.isIntersecting(n,s)&&(_=!0):i=r.intersect(n,null,c,g,s),2===i)_=!0;else if(i){const e=g[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return!0;_=!0}}if(!_)return!1;const p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty(),f=r.Envelope2D.constructEmpty(),x=r.Envelope2D.constructEmpty(),P=r.Envelope2D.constructEmpty();if(e.queryEnvelope(p),t.queryEnvelope(d),Ht(d,p,s)){let r,i;if(f.setCoords({env2D:p}),f.inflateCoords(1e3*s,1e3*s),x.setCoords({env2D:d}),x.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:f}),P.intersect(x),e.getPointCount()>10){if(r=(0,l.c)(e,P,s,0,n),r.isEmpty())return!1}else r=e;if(t.getPointCount()>10){if(i=(0,l.c)(t,P,s,0,n),i.isEmpty())return!1}else i=t;return Ae(r,i,s,"T********",n,!1)}return Ae(e,t,s,"T*****T**",n,!1)}(e,t,s,null)}(e,t,s)}return!1}function it(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return 0===$t(e,t,s)}(e,t,s);case 1:case 64:return function(e,t,s){return function(e,t,s){return 1===es(e,t,s)}(e,t.getXY(),s)}(e,t,s);case 8:return function(e,t,s){return function(e,t,s){return 2===es(e,t,s)}(e,t.getXY(),s)}(e,t,s)}return!1}function ot(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t),1===function(e,t,s){const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n),n.inflateCoords(s,s);const i=new h.P,a=e.getImpl(),m=new o.P;let l=e,g=!1,c=!1,u=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,i),n.contains(i)){const e=es(l,i,s);if(1===e)return c=!0,4;if(2===e)return 4;u=!0}else u=!0;g||(!Ne(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return c?u?4:2:1}(e,t,s)}(e,t,s);case 1:return ft(e,t,s,!1);case 64:return ft(e,t,s,!0);case 8:return function(e,t,s){st(e,t);const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n),n.inflateCoords(s,s);const i=new h.P;let a=!1;const m=e.getImpl(),l=new o.P;let g=e,c=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,i),n.contains(i)){const e=es(g,i,s);if(2===e)a=!0;else if(1===e)return!1}c||(!Ne(e,t.getPointCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),c=!0)}return!!a}(e,t,s);case 16:return function(e,t,s){st(e,t);const n=new r.Envelope2D,i=new r.Envelope2D,a=new r.Envelope2D;e.queryEnvelope(n),t.queryEnvelope(a),i.setCoords({env2D:n}),i.inflateCoords(s,s);let m=!1,l=!1;const g=new h.P,c=e.getImpl(),u=new o.P;let _=e,p=!1;for(let n=0;n<t.getPointCount();n++){if(t.queryXY(n,g),i.contains(g)){const e=es(_,g,s);0===e?l=!0:1===e&&(m=!0)}else l=!0;if(m&&l)return!0;p||(!Ne(e,t.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),_=u),p=!0)}return!1}(e,t,s)}return!1}function at(e,t,s,n,i){if(function(e,t,s){st(e,t);const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();return e.queryEnvelope(n),t.queryEnvelope(i),!kt(i,n,s)&&0===es(e,i.getLowerLeft(),0)&&!i.contains(e.getXY(0))&&!Xt(e,i,s)}(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return xt(e,t,s,!1);case 128:return xt(e,t,s,!0);case 1:return Pt(e,t,s,!1,i);case 64:return Pt(e,t,s,!0,i);case 3:return function(e,t,s,n){const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),!Nt(i,a,s))return!1;const h=new o.P;return h.addEnvelope(t,!1),ut(e,h,s,n)}(e,t,s,i);case 8:return function(e,t,s,n){st(e,t);const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),kt(a,i,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new o.P;return h.addEnvelope(t,!1),Lt(e,h,s,n)}(e,t,s,i);case 32:return function(e,t,s,n){st(e,t);const i=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(i),t.queryEnvelope(a),kt(a,i,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new o.P;return h.addEnvelope(t,!1),zt(e,h,s,n)}(e,t,s,i);case 16:return!1}return!1}function ht(e,t,s,n,r){switch(n){case 4:return function(e,t,s){return st(e,t),!Rt(e,t.getXY(),s)}(e,t,s);case 1:case 64:return function(e,t,s){return st(e,t),function(e,t,s){return Rt(e,t,s)&&!Zt(e,t,s)}(e,t.getXY(),s)}(e,t,s);case 8:return function(e,t,s){return st(e,t),Zt(e,t.getXY(),s)}(e,t,s)}return!1}function mt(e,t,s,n,i){switch(n){case 4:return function(e,t,s){return st(e,t),!Bt(e,t,s,!1)}(e,t,s);case 1:case 64:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),t.queryEnvelope(i),!kt(n,i,s))return!1;st(e,t);const o=Bt(e,t,s,!0);if(!o)return o;const a=e.getBoundary();return a.isEmpty()?o:!Ct(a,t,s)}(e,t,s);case 8:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl(),i=new o.M,a=new Ke(n,r,s,!1),h=n.querySegmentIterator();let m=!1;for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();h.resetToVertex(e,-1);const n=h.nextSegment(),o=r.getXY(t);n.isIntersectingPoint(o,s)&&(m=!0,i.addPoint2D(o))}if(!m)return!1;const l=e.getBoundary();return!l.isEmpty()&&Ct(l,i,s)}(e,t,s);case 16:return function(e,t,s){st(e,t);const n=e.getImpl(),r=t.getImpl(),i=r.getPointCount(),a=(0,h.d)(i,!1),m=new Ke(n,r,s,!1),l=n.querySegmentIterator();let g=!1;for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();l.resetToVertex(e,-1);const n=l.nextSegment(),i=r.getXY(t);n.isIntersectingPoint(i,s)&&(g=!0,a[t]=!0)}if(!g)return!1;let c=!1;for(let e=0;e<i;e++)if(!a[e]){c=!0;break}if(!c)return!1;const u=e.getBoundary();if(u.isEmpty())return!0;const _=new o.M;for(let e=0;e<i;e++)a[e]&&_.addPoint2D(r.getXY(e));return!Ct(u,_,s)}(e,t,s)}return!1}function lt(e,t,s,n,a){if(function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();e.queryEnvelope(n),t.queryEnvelope(i);const o=function(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)?1073741824:n.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}(i,n,s);return 0===o?!Xt(e,i,s):4===o}(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return St(e,t,s,!1);case 128:return St(e,t,s,!0);case 1:case 64:case 32:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;return e.queryEnvelope(n),t.queryEnvelope(i),!(i.height()>s&&i.width()>s)&&Nt(n,i,s)}(e,t,s);case 8:return function(e,t,s,n){const a=new r.Envelope2D,m=new r.Envelope2D;if(e.queryEnvelope(a),t.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;const l=new r.Envelope2D,g=new r.Envelope2D;if(l.setCoords({env2D:m}),g.setCoords({env2D:m}),l.inflateCoords(s,s),g.inflateCoords(-s,-s),g.containsEnvelope(a)||!a.isIntersecting(l))return!1;const c=e.getImpl().querySegmentIterator();c.stripAttributes();const u=e.getImpl().getAccelerators();let _=null,p=null;null!==u&&(_=u.getQuadTree(),null!==_&&(p=_.getIterator(m,s))),p||c.nextPath()||(0,i.d)("relational_operations");let d=!1,f=null;const x=new h.P,P=new h.P,E=e.hasNonLinearSegments();let y=!1;for(;;){if(null!==p){const e=p.next();if(-1===e)break;c.resetToVertex(_.getElement(e),-1),f=c.nextSegment()}else{for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;f=c.nextSegment()}if(E&&f.getGeometryType()!==i.G.enumLine){const e=new r.Envelope2D;if(f.queryEnvelope(e),g.containsEnvelope(e))return!1;if(l.isIntersecting(e)){y=!0;break}}else{x.assign(f.getStartXY()),P.assign(f.getEndXY());let e=g.clipLine(x,P);if(0!==e)return!1;d||(e=l.clipLine(x,P),0!==e&&(d=!0))}}if(!y)return d;const S=new o.P;return S.addEnvelope(m,!1),dt(S,e,s,n)}(e,t,s,a);case 16:return function(e,t,s){const n=new r.Envelope2D,a=new r.Envelope2D;if(e.queryEnvelope(n),t.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;const m=new r.Envelope2D;if(m.setCoords({env2D:a}),m.inflateCoords(s,s),m.containsEnvelope(n))return!1;const l=new r.Envelope2D;if(l.setCoords({env2D:a}),l.inflateCoords(-s,-s),!l.isIntersecting(n))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const c=e.getImpl().getAccelerators();let u=null,_=null;if(null!==c&&(u=c.getQuadTree(),null!==u&&(_=u.getIterator(a,s))),!_){const e=g.nextPath();(0,i.g)(e)}let p=!1,d=null;const f=new h.P,x=new h.P;let P=null,E=null,y=null,S=null;for(e.hasNonLinearSegments()&&(P=new o.L,E=new o.L,y=new o.L,S=new o.L,l.querySide(0,P),l.querySide(1,E),l.querySide(2,y),l.querySide(3,S));;){if(null!==_){const e=_.next();if(-1===e)break;g.resetToVertex(u.getElement(e),-1),d=g.nextSegment()}else{for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;d=g.nextSegment()}if(d.getGeometryType()===i.G.enumLine){if(f.assign(d.getStartXY()),x.assign(d.getEndXY()),0!==l.clipLine(f,x)){p=!0;break}}else{if(P.isIntersecting(d,s)){p=!0;break}if(E.isIntersecting(d,s)){p=!0;break}if(y.isIntersecting(d,s)){p=!0;break}if(S.isIntersecting(d,s)){p=!0;break}}}return p&&!0}(e,t,s)}return!1}function gt(e,t,s,n,r){switch(n){case 4:return vt(e,t,s);case 2:case 128:return function(e,t,s){return It(e,t,s)}(e,t,s);case 1:case 64:return function(e,t,s){return!vt(e,t,s)}(e,t,s);case 3:return It(e,t,s)}return!1}function ct(e,t,s,n,i){switch(n){case 4:return function(e,t,s){const n=r.Envelope2D.constructEmpty(),i=r.Envelope2D.constructEmpty();if(e.queryEnvelope(n),t.queryEnvelope(i),kt(i,n,s))return!1;const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.inflateCoords(s,s);const a=new h.P;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,a),o.contains(a))return!1;return!0}(e,t,s);case 2:return bt(e,t,s,!1);case 128:return bt(e,t,s,!0);case 1:case 64:return!1;case 3:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;return e.queryEnvelope(n),t.queryEnvelope(i),!(i.height()>s||i.width()>s)&&Nt(n,i,s)}(e,t,s);case 8:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D,o=new r.Envelope2D;if(t.queryEnvelope(n),n.height()<=s||n.width()<=s)return!1;i.setCoords({env2D:n}),o.setCoords({env2D:n}),i.inflateCoords(s,s),o.inflateCoords(-s,-s);const a=new h.P;let m=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,a),i.contains(a)){if(o.containsExclusive(a))return!1;m=!0}return m}(e,t,s);case 16:return function(e,t,s){const n=new r.Envelope2D,i=new r.Envelope2D;if(e.queryEnvelope(n),t.queryEnvelope(i),kt(i,n,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new r.Envelope2D,a=new r.Envelope2D;o.setCoords({env2D:i}),o.inflateCoords(-s,-s),a.setCoords({env2D:i}),a.inflateCoords(s,s);const m=new h.P;let l=!1,g=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,m),!l&&o.containsExclusive(m)&&(l=!0),g||a.contains(m)||(g=!0),l&&g)return!0;return!1}(e,t,s)}return!1}function ut(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!Nt(i,o,s))return!1;if(st(e,t),At(e,t,s))return!0;const a=e.calculateLength2D(),h=t.calculateLength2D(),m=Math.max(e.getPointCount(),t.getPointCount());return!(Math.abs(a-h)>4*m*s)&&(e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"**F**FFF*",n,!1):Ut(e,t,s,!0))}function _t(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),Wt(e,t,s,n))}function pt(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),2===Dt(e,t,s,!1))}function dt(e,t,s,n){return st(e,t),function(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),m=o.querySegmentIterator(),g=(0,h.d)(2,Number.NaN),c=(0,h.d)(2,Number.NaN),u=new Ke(i,o,s);let _=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();a.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=a.nextSegment(),r=m.nextSegment();let i=0;if(Kt(n,r)?!_&&r.isIntersecting(n,s)&&(_=!0):i=r.intersect(n,null,c,g,s),2===i)_=!0;else if(i){const e=g[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return!1;_=!0}}if(!_)return!1;const p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty(),f=r.Envelope2D.constructEmpty();let x,P;if(e.queryEnvelope(p),t.queryEnvelope(d),p.inflateCoords(1e3*s,1e3*s),d.inflateCoords(1e3*s,1e3*s),f.setCoords({env2D:p}),f.intersect(d),e.getPointCount()>10){if(x=(0,l.c)(e,f,s,0,n),x.isEmpty())return!1}else x=e;if(t.getPointCount()>10){if(P=(0,l.c)(t,f,s,0,n),P.isEmpty())return!1}else P=t;return Ae(x,P,s,"F********",n,!1)}(e,t,s,n)}function ft(e,t,s,n,i){const a=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(m),!kt(a,m,s))return!1;st(e,t);let l=!1;const g=new h.P,c=e.getImpl(),u=new o.P;let _=e,p=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,g),!a.contains(g))return!1;const i=es(_,g,s);if(1===i)l=!0;else if(0===i)return!1;if(n&&2===i)return!1;p||(!Ne(e,t.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),_=u),p=!0)}return l}function xt(e,t,s,n,i){const o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();return e.queryEnvelope(o),t.queryEnvelope(a),n?Ft(a,o,s):kt(a,o,s)}function Pt(e,t,s,n,i){const a=r.Envelope2D.constructEmpty(),h=r.Envelope2D.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(h),!kt(a,h,s))return!1;st(e,t);const m=new o.P;return m.addEnvelope(t,!1),n?2===Dt(e,m,s,!1):Wt(e,m,s,i)}function Et(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()?Ae(e,t,s,"******FF*",n,!1):qt(t,e,s,!1))}function yt(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&(st(e,t),Ae(e,t,s,"T**FF*FF*",n,!1))}function St(e,t,s,n,a){const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();if(e.queryEnvelope(h),t.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;if(n)return Ft(m,h,s);if(!kt(m,h,s))return!1;const l=r.Envelope2D.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-s,-s);const g=r.Envelope2D.constructEmpty();if(g.setCoords({env2D:m}),g.inflateCoords(s,s),l.containsEnvelope(h))return!0;const c=e.getImpl().querySegmentIterator();c.stripAttributes(),c.nextPath()||(0,i.d)("relational_operations");let u,_,p,d,f,x,P=!1;const E=e.hasNonLinearSegments();for(E&&(p=new o.L,d=new o.L,f=new o.L,x=new o.L,l.querySide(0,p),l.querySide(1,d),l.querySide(2,f),l.querySide(3,x));;){for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;const e=c.nextSegment();if(E&&e.getGeometryType()!==i.G.enumLine){if(e.isIntersecting(p,s)){P=!0;break}if(e.isIntersecting(d,s)){P=!0;break}if(e.isIntersecting(f,s)){P=!0;break}if(e.isIntersecting(x,s)){P=!0;break}}else if(u=e.getStartXY(),_=e.getEndXY(),0!==l.clipLine(u,_)){P=!0;break}}return P}function Ct(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!kt(i,o,s)&&Mt(t,e,s,!0,!1,!1)}function It(e,t,s,n){const i=r.Envelope2D.constructEmpty(),o=r.Envelope2D.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),Nt(i,o,s)}function vt(e,t,s,n){return jt(e,t.getXY(),s)}function bt(e,t,s,n,i){const o=r.Envelope2D.constructEmpty(),a=r.Envelope2D.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;if(n)return Ft(a,o,s);if(!kt(a,o,s))return!1;let m=!1;const l=r.Envelope2D.constructEmpty(),g=r.Envelope2D.constructEmpty();l.setCoords({env2D:a}),g.setCoords({env2D:a}),l.inflateCoords(-s,-s),g.inflateCoords(s,s);const c=new h.P;for(let t=0;t<e.getPointCount();t++){if(e.queryXY(t,c),!g.contains(c))return!1;l.containsExclusive(c)&&(m=!0)}return m}function Gt(e,t,s,n){return h.P.sqrDistance(e,t)<=s*s}function wt(e,t,s,n){return Gt(e,t,s)}function Nt(e,t,s,n){return kt(e,t,s)&&kt(t,e,s)}function Tt(e,t,s,n,i){if(e.height()<=s||e.width()<=s)return!1;if(n)return Ft(e,t,s);if(!kt(e,t,s))return!1;const o=r.Envelope2D.constructEmpty();return o.setCoords({env2D:e}),o.inflateCoords(-s,-s),o.intersect(t),!o.isEmpty()}function Dt(e,t,s,n,a){const m=new h.P,l=new h.P,g=r.Envelope2D.constructEmpty(),c=r.Envelope2D.constructEmpty(),u=e.getImpl(),_=t.getImpl(),p=_.getGeometryType(),d=new Ke(u,_,s,!0);if(!d.next())return 1;if(Ot(e,t,s))return n?4:0;const f=new o.P;let x=e;const P=new o.P;let E=null;p===i.G.enumPolygon&&(E=t);const y=p===i.G.enumPolygon?(0,h.d)(u.getPathCount(),!1):[],S=(0,h.d)(_.getPathCount(),!1);let C=!1,I=!1,v=!1,b=!1,G=!1,w=!1;do{if(v&&G||b&&w)break;if(v&&b)break;const r=d.getRedElement(),o=d.getBlueElement();if(!S[o]&&(l.assign(t.getXY(t.getPathStart(o))),g.setCoords({env2D:d.getRedEnvelope()}),g.inflateCoords(s,s),g.contains(l))){if(0!==es(x,l,0)){if(b=!0,n)return 4}else w=!0;S[o]=!0}if(p===i.G.enumPolygon&&!y[r]&&(m.assign(e.getXY(e.getPathStart(r))),c.setCoords({env2D:d.getBlueEnvelope()}),c.inflateCoords(s,s),c.contains(m))){if(0!==es(E,m,0)){if(v=!0,n)return 4}else G=!0;y[r]=!0}if(C||(!Ne(e,t.getPathCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?x=e:(e.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),C=!0),p===i.G.enumPolygon&&!I){const s=t;!Ne(s,e.getPathCount()-1)||null!==_.getAccelerators()&&null!==_.getAccelerators().getQuadTree()?E=t:(s.copyTo(P),P.getImpl().buildQuadTreeAccelerator(1),E=P),I=!0}}while(d.next());if(!v&&!b)return 1;if(!G||!w){if(p===i.G.enumPolygon)for(let e=0,t=u.getPathCount();e<t;e++)if(!y[e]){G=!0;break}for(let e=0,t=_.getPathCount();e<t;e++)if(!S[e]){w=!0;break}}return v&&G||b&&w||v&&b?4:b?2:3}function Vt(e,t,s,n,a){n[0]=!1;const h=e.getImpl(),m=t.getImpl(),l=h.querySegmentIterator(),g=m.querySegmentIterator(),c=[0,0],u=[0,0],_=new Ke(h,m,s);let p=!1;for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement();l.resetToVertex(e,-1),g.resetToVertex(t,-1);const r=l.nextSegment(),i=g.nextSegment();let o=0;if(Kt(r,i)?!p&&i.isIntersecting(r,s)&&(p=!0):o=i.intersect(r,null,u,c,s),0!==o&&(p=!0,1===o)){const e=c[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return n[0]=!0,!1}}if(!p){n[0]=!0;const a=r.Envelope2D.constructEmpty();e.queryEnvelope(a),a.inflateCoords(s,s);const l=new o.P;let g=e,c=!1;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)>0){const n=r.Envelope2D.constructEmpty();if(t.queryPathEnvelope(s,n),!a.isIntersecting(n))return!1;{const e=we(g,t.getXY(t.getPathStart(s)),0);if((0,i.g)(-1!==e),0===e)return!1}c||(!Ne(e,t.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),c=!0)}if(1===e.getPathCount()||t.getGeometryType()===i.G.enumPolyline)return!0;const u=t,_=r.Envelope2D.constructEmpty();u.queryEnvelope(_),_.inflateCoords(s,s);const p=new o.P;let d=u,f=!1;for(let t=0,s=e.getPathCount();t<s;t++)if(e.getPathSize(t)>0){const s=r.Envelope2D.constructEmpty();if(e.queryPathEnvelope(t,s),_.isIntersecting(s)){const s=we(d,e.getXY(e.getPathStart(t)),0);if((0,i.g)(-1!==s),1===s)return!1}f||(!Ne(u,e.getPathCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?d=u:(u.copyTo(p),p.getImpl().buildQuadTreeAccelerator(1),d=p),f=!0)}return!0}return!1}function kt(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)}function Ft(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),e.containsExclusiveEnvelope(n)}function Ht(e,t,s){const n=r.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!(n.contains(e.getLowerLeft())&&n.contains(e.getLowerRight())&&n.contains(e.getUpperLeft())&&n.contains(e.getUpperRight()))}function At(e,t,s,n){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);const r=new h.P,i=new h.P;let o=!0;const a=s*s;for(let s=0;s<e.getPathCount();s++){if(e.getPathEnd(s)!==t.getPathEnd(s)){o=!1;break}for(let n=e.getPathStart(s);n<t.getPathEnd(s);n++)if(e.queryXY(n,r),t.queryXY(n,i),h.P.sqrDistance(r,i)>a){o=!1;break}if(!o)break}return!!o}function Mt(e,t,s,n,r,i,o){const a=e.getImpl(),m=t.getImpl(),l=a.getPointCount(),g=m.getPointCount(),c=(0,h.d)(l,!1),u=r||i?(0,h.d)(g,!1):[],_=s*s,p=new Ke(a,m,s);for(;p.next();){const e=p.getRedElement(),t=p.getBlueElement(),s=a.getXY(e),n=m.getXY(t);h.P.sqrDistance(s,n)<=_&&(c[e]=!0,(r||i)&&(u[t]=!0))}let d=!1,f=!1;for(let e=0;e<l;e++){const t=c[e];if(d||=!t,f||=t,(r||n)&&d)return!1}if(n)return!0;let x=!1,P=!1;for(let e=0;e<g;e++){const t=u[e];if(x||=!t,P||=t,r&&x)return!1}return!!r||d&&f&&x&&P}function Ut(e,t,s,n){return qt(e,t,s,n)&&qt(t,e,s,n)}function qt(e,t,s,n){if((0,i.p)(e),(0,i.p)(t),t.isEmpty())return!1;let o=!0;const m=(0,h.d)(2,Number.NaN),l=(0,h.d)(2,Number.NaN),g=[],c=new Jt;let u;const _=r.Envelope2D.constructEmpty(),p=r.Envelope2D.constructEmpty(),d=r.Envelope2D.constructEmpty();e.queryEnvelope(_),t.queryEnvelope(p),_.inflateCoords(s,s),p.inflateCoords(s,s),d.setCoords({env2D:_}),d.intersect(p);const f=e.getImpl().querySegmentIterator(),x=t.getImpl().querySegmentIterator(),P=t.getImpl().getAccelerators();let E=null,y=null,S=null,C=null;if(null!==P&&(E=P.getQuadTree(),y=P.getQuadTreeForPaths(),null!==y&&(C=y.getIteratorForQT())),null===E){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(E=(0,a.H)(t.getImpl(),d))}for(null!==E&&(S=E.getIteratorForQT());f.nextPath();)for(;f.hasNextSegment();){let e=f.nextSegment();if(e.queryEnvelope(_),!_.isIntersecting(d))return o=!1,!1;if(null!==C&&(C.resetIterator(_,s),-1===C.next()))continue;let t=0,r=null;if(null!=S)S.resetIterator(e,s);else if(x.resetToFirstPath(),!x.nextPath())return o=!1,!1;do{if(t=0,null!==S){const n=S.next();if(-1===n)return o=!1,!1;x.resetToVertex(E.getElement(n),-1),r=x.nextSegment(),t=e.intersect(r,null,m,l,s)}else{for(;!x.hasNextSegment();)if(!x.nextPath())return o=!1,!1;r=x.nextSegment(),r.queryEnvelope(p),p.inflateCoords(s,s),_.isIntersecting(p)&&(t=e.intersect(r,null,m,l,s))}}while(2!==t||0!==m[0]||n&&!(l[0]<=l[1]));let h=Number.NaN,P=!1;do{let n=!1;if(1===m[1]){if(!f.hasNextSegment()){P=!0;break}e=f.nextSegment(),n=!0}if(1===l[1]&&l[0]<=l[1]){if(-1===h)break;if(h=1,!x.hasNextSegment())break;r=x.nextSegment(),n=!0}if(0===l[1]&&l[0]>l[1]){if(1===h)break;if(Number.isNaN(h)){if(!x.hasPreviousSegment())break;x.previousSegment(),h=-1}if(!x.hasPreviousSegment())break;r=x.previousSegment(),n=!0}if(!n)break;t=e.intersect(r,null,m,l,s)}while(2===t&&(!n||l[0]<=l[1]));if(P)continue;const y=e.calculateLength2D();e.queryEnvelope(_),g.length=0,c.m_overlapEvents.length=0;let I=!1,v=!1,b=0;const G=(0,a.d)(null,_,!0);for(null!==S?S.resetIterator(e,s):(x.resetToFirstPath(),x.nextPath()||(0,i.d)("relational_operations"));;){if(t=0,null!==S){const n=S.next();if(-1===n)break;x.resetToVertex(E.getElement(n),-1),r=x.nextSegment(),t=e.intersect(r,null,m,l,s)}else{for(;!x.hasNextSegment()&&x.nextPath(););if(!x.hasNextSegment())break;r=x.nextSegment(),r.queryEnvelope(p),p.inflateCoords(s,s),_.isIntersecting(p)&&(t=e.intersect(r,null,m,l,s))}if(2===t&&(!n||l[0]<=l[1])){const e=f.getStartPointIndex(),t=f.getPathIndex(),n=x.getStartPointIndex(),r=x.getPathIndex();if(u=Qt(e,t,m[0],m[1],n,r,l[0],l[1]),c.m_overlapEvents.push(u),g.push(g.length),!(I||u.m_scalarA0<b&&u.m_scalarA1<b))if(0===b&&y*(u.m_scalarA0-b)>s)I=!0;else if(0!==b&&y*(u.m_scalarA0-b)>G)I=!0;else if(b=u.m_scalarA1,y*(1-b)<=s||1===b){v=!0;break}}}if(!v){if(!I)return o=!1,!1;g.length>1&&g.sort((e,t)=>c.compareOverlapEvents(e,t)),b=0;for(let e=0;e<c.m_overlapEvents.length;e++)if(u=c.m_overlapEvents[g[e]],!(u.m_scalarA0<b&&u.m_scalarA1<b)){if(0===b&&y*(u.m_scalarA0-b)>s)return o=!1,!1;if(0!==b&&y*(u.m_scalarA0-b)>G)return o=!1,!1;if(b=u.m_scalarA1,y*(1-b)<=s||1===b)break}if(y*(1-b)>s)return o=!1,!1;g.length=0,c.m_overlapEvents.length=0}}return o}function Ot(e,t,s){const n=e.getImpl(),r=t.getImpl(),i=n.querySegmentIterator(),o=r.querySegmentIterator(),a=new Ke(n,r,s);for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();i.resetToVertex(e,-1),o.resetToVertex(t,-1);const n=i.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function Yt(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),m=(0,h.d)(2,Number.NaN),l=new Ke(r,i,s);let g=!1,c=-1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const r=o.nextSegment(),i=a.nextSegment();let u=0;if(Kt(r,i)){if(i.isIntersecting(r,s))return-2}else u=r.intersect(i,null,m,null,s);if(u)if(2===u){const e=r.calculateLength2D(),t=m[0];if(e*(m[1]-t)>s)return c=1,c;g=!0}else if(c=0,n){const e=m[0],t=new h.P;r.queryCoord2D(e,t),n.push(t.x),n.push(t.y)}}return g?-2:c}function Bt(e,t,s,n){const r=e.getImpl(),i=t,o=i.getPointCount(),a=n?(0,h.d)(o,!1):[],m=new Ke(r,i,s,!1),l=r.querySegmentIterator();for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();l.resetToVertex(e,-1);const r=l.nextSegment(),o=i.getXY(t);if(r.isIntersectingPoint(o,s)){if(!n)return!0;a[t]=!0}}if(!n)return!1;for(let e=0;e<o;e++)if(!a[e])return!1;return!0}function Rt(e,t,s){const n=new h.P,i=s*s,o=e.querySegmentIterator(),a=e.getImpl().getAccelerators();if(null!==a){const e=a.getQuadTree();if(null!==e){const a=r.Envelope2D.constructEmpty();a.setCoords({pt:t});const m=e.getIterator(a,s);for(let s=m.next();-1!==s;s=m.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,n),h.P.sqrDistance(t,n)<=i)return!0}return!1}}const m=r.Envelope2D.constructEmpty();for(;o.nextPath();)for(;o.hasNextSegment();){const e=o.nextSegment();if(e.queryEnvelope(m),m.inflateCoords(s,s),!m.contains(t))continue;const r=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(r,n),h.P.sqrDistance(t,n)<=i)return!0}return!1}function Xt(e,t,s,n){const a=e.querySegmentIterator(),m=e.getImpl().getAccelerators(),l=e.hasNonLinearSegments();let g=null,c=null,u=null,_=null;if(null!==m){const e=m.getQuadTree();if(null!==e){const n=e.getIterator(t,s);l&&(g=new o.L,c=new o.L,u=new o.L,_=new o.L,t.querySide(0,g),t.querySide(1,c),t.querySide(2,u),t.querySide(3,_));const h=r.Envelope2D.constructEmpty();h.setCoords({env2D:t}),h.inflateCoords(s,s);for(let r=n.next();-1!==r;r=n.next())if(a.resetToVertex(e.getElement(r),-1),a.hasNextSegment()){const e=a.nextSegment();if(e.getGeometryType()===i.G.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(h.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(g,s))return!0;if(e.isIntersecting(c,s))return!0;if(e.isIntersecting(u,s))return!0;if(e.isIntersecting(_,s))return!0}return!1}}if(l){g=new o.L,c=new o.L,u=new o.L,_=new o.L,t.querySide(0,g),t.querySide(1,c),t.querySide(2,u),t.querySide(3,_);const n=e.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const e=n.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(g,s))return!0;if(e.isIntersecting(c,s))return!0;if(e.isIntersecting(u,s))return!0;if(e.isIntersecting(_,s))return!0}}else{const n=r.Envelope2D.constructEmpty();n.setCoords({env2D:t}),n.inflateCoords(s,s);const i=e.getImpl(),o=i.getAttributeStreamRef(0),a=new h.P;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0;const s=new h.P,r=new h.P,m=new h.P,l=i.getPathStart(e),g=new h.P;for(let h=l,c=i.getPathEnd(e);h<c;h++)if(t)o.queryPoint2D(2*h,s),g.assign(s),t=!1;else{if(o.queryPoint2D(2*h,a),r.setCoordsPoint2D(s),m.setCoordsPoint2D(a),n.clipLine(r,m))return!0;s.assign(a)}if(i.isClosedPath(e)&&!t&&(r.setCoordsPoint2D(s),m.setCoordsPoint2D(g),n.clipLine(r,m)))return!0}}return!1}function Lt(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),m=[0],g=(0,a.Y)(i.getIsSimple(0,m))&&(0,a.Y)(o.getIsSimple(0,m)),c=i.querySegmentIterator(),u=o.querySegmentIterator(),_=(0,h.d)(2,0),p=(0,h.d)(2,0),d=new Ke(i,o,s);let f=!1;for(;d.next();){const e=d.getRedElement(),t=d.getBlueElement();c.resetToVertex(e,-1),u.resetToVertex(t,-1);const n=c.nextSegment(),r=u.nextSegment();let i=0;if(Kt(n,r)){if(r.isIntersecting(n,s)){f=!0;break}}else i=r.intersect(n,null,p,_,s);if(2===i){const e=_[0],t=_[1],r=n.calculateLength2D();if(g&&(t-e)*r>s)return!1;f=!0}else if(i){const e=_[0],t=p[0];if(e>0&&e<1&&t>0&&t<1)return!1;f=!0}}if(!f)return!1;const x=r.Envelope2D.constructEmpty(),P=r.Envelope2D.constructEmpty(),E=r.Envelope2D.constructEmpty();let y,S;if(e.queryEnvelope(x),t.queryEnvelope(P),x.inflateCoords(1e3*s,1e3*s),P.inflateCoords(1e3*s,1e3*s),E.setCoords({env2D:x}),E.intersect(P),e.getPointCount()>10){if(y=(0,l.c)(e,E,s,0,n),y.isEmpty())return!1}else y=e;if(t.getPointCount()>10){if(S=(0,l.c)(t,E,s,0,n),S.isEmpty())return!1}else S=t;return Ae(y,S,s,"F********",n,!1)}function zt(e,t,s,n){const i=e.getImpl(),o=t.getImpl(),m=[0],g=(0,a.Y)(i.getIsSimple(0,m))&&(0,a.Y)(o.getIsSimple(0,m)),c=r.Envelope2D.constructEmpty(),u=r.Envelope2D.constructEmpty(),_=r.Envelope2D.constructEmpty();e.queryEnvelope(c),t.queryEnvelope(u);let p=!1;const d=Ht(c,u,s),f=Ht(u,c,s),x=i.querySegmentIterator(),P=o.querySegmentIterator(),E=(0,h.d)(2,Number.NaN),y=(0,h.d)(2,Number.NaN),S=new Ke(i,o,s);for(;S.next();){const e=S.getRedElement(),t=S.getBlueElement();x.resetToVertex(e,-1),P.resetToVertex(t,-1);const n=x.nextSegment(),r=P.nextSegment();let i=0;if(Kt(n,r)){if(r.isIntersecting(n,s))break}else i=r.intersect(n,null,y,E,s);if(2===i){const e=E[0],t=E[1],r=n.calculateLength2D();if(g&&(t-e)*r>s&&(p=!0,d&&f))return!0}else if(i){const e=E[0],t=y[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const C=r.Envelope2D.constructEmpty(),I=r.Envelope2D.constructEmpty();let v,b;C.setCoords({env2D:c}),C.inflateCoords(1e3*s,1e3*s),I.setCoords({env2D:u}),I.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:C}),_.intersect(I);let G="";if(G+=p?"**":"T*",d){if(t.getPointCount()>10){if(b=(0,l.c)(t,_,s,0,n),b.isEmpty())return!1}else b=t;G+="****"}else b=t,G+="T***";if(f){if(e.getPointCount()>10){if(v=(0,l.c)(e,_,s,0,n),v.isEmpty())return!1}else v=e;G+="***"}else v=e,G+="T**";return Ae(v,b,s,G,n,!1)}function Wt(e,t,s,n){const i=[!1],h=Vt(e,t,s,i);if(i[0])return h;const m=r.Envelope2D.constructEmpty();let g;if(t.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(g=(0,l.c)(e,m,s,0,n),g.isEmpty())return!1}else g=e;return function(e,t,s,n){const i=new ze;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaAreaPredicates_();const h=r.Envelope2D.constructEmpty(),m=r.Envelope2D.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let l=!1;if(tt(h,m,s)&&(i.areaAreaDisjointPredicates_(e,t),l=!0),l||st(e,t),l)return Xe(i.m_matrix,i.m_scl);let g=new o.E,c=g.addGeometry(e),u=g.addGeometry(t),_=null,p=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){_=new cs;const e=ms(s,g.getEnvelope2D(n));p=gs(e,0),os(g,e,s,0,_,null,n)}_s(g,new a.C(s,0).add(p),n,!1,!1);const d=g.getGeometry(u).getBoundary();if(g.filterClosePoints(0,!0,!0,!1,o.n),Fe(g,c,-1,!1,o.n,n),0===g.getPointCount(c))return!1;Fe(g,u,-1,!1,o.n,n),i.setEditShape_(g,n);const f=0===g.getPointCount(u);if(!f){i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape();const e=Xe(i.m_matrix,i.m_scl);if(!e)return e}const x=g.getGeometry(c);return g=new o.E,c=g.addGeometry(x),u=g.addGeometry(d),i.setEditShape_(g,n),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(f?"T*****F**":"******F**"),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(c,u),i.m_topoGraph.removeShape(),Xe(i.m_matrix,i.m_scl)}(g,t,s,n)}function jt(e,t,s,n){const r=new h.P,i=s*s;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,r),h.P.sqrDistance(r,t)<=i)return!1;return!0}function Zt(e,t,s){const n=e.getBoundary();return!n.isEmpty()&&!jt(n,t,s)}function Kt(e,t){return e.getGeometryType()!==i.G.enumLine||t.getGeometryType()!==i.G.enumLine}function Qt(e,t,s,n,r,i,o,a){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:s,m_scalarA1:n,m_ivertexB:r,m_ipathB:i,m_scalarB0:o,m_scalarB1:a}}class Jt{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(e,t){const s=this.m_overlapEvents[e],n=this.m_overlapEvents[t];if(s.m_ipathA<n.m_ipathA)return-1;if(s.m_ipathA===n.m_ipathA){if(s.m_ivertexA<n.m_ivertexA)return-1;if(s.m_ivertexA===n.m_ivertexA){if(s.m_scalarA0<n.m_scalarA0)return-1;if(s.m_scalarA0===n.m_scalarA0){if(s.m_scalarA1<n.m_scalarA1)return-1;if(s.m_scalarA1===n.m_scalarA1&&s.m_ivertexB<n.m_ivertexB)return-1}}}return 1}}function $t(e,t,s){const n=function(e,t,s){return t.isEmpty()?0:we(e,t.getXY(),s)}(e,t,s);return n?1===n?1:2:0}function es(e,t,s){const n=we(e,t,s);return n?1===n?1:2:0}function ts(e,t,s,n,o){if(e.getGeometryType()===i.G.enumPolygon)!function(e,t,s,n,r){for(let i=0;i<s;i++)r[i]=es(e,t[i],n)}(e,t,s,n,o);else if(e.getGeometryType()===i.G.enumEnvelope){const i=r.Envelope2D.constructEmpty();e.queryEnvelope(i),function(e,t,s,n,r){if(e.isEmpty()){for(let e=0;e<s;e++)r[e]=0;return}const i=e.clone();i.inflateCoords(.5*-n,.5*-n);const o=e.clone();o.inflateCoords(.5*n,.5*n);for(let e=0;e<s;e++)i.contains(t[e])?r[e]=1:o.contains(t[e])?r[e]=2:r[e]=0}(i,t,s,n,o)}else(0,i.q)("")}function ss(e,t,s,n,o){const h=e.getGeometryType();h===i.G.enumPolyline?function(e,t,s,n,o){const h=e.getImpl(),m=h.getAccelerators();let l=null;m&&(l=m.getRasterizedGeometry());let g=s;for(let e=0;e<s;e++)o[e]=1,l&&(0,i.g)(0);if(g){if(m){let e=null;null!==m&&null!==m.getQuadTree()&&(e=m.getQuadTree());const i=h.getPointCount();if(null===e&&i>20&&i*s>4*i+Math.log(i)*s&&(e=(0,a.H)(h)),e){let i=null;const a=h.querySegmentIterator(),m=new r.Envelope2D;for(let r=0;r<s&&g;r++)if(1===o[r]){m.setCoords(t[r]),null===i?i=e.getIterator(m,n):i.resetIterator(m,n);let s=-1;for(let h=i.next();-1!==h;h=i.next()){if(a.resetToVertex(e.getElement(h),s),s=a.getPathIndex(),a.nextSegment().isIntersectingPoint(t[r],n)){o[r]=2,g--;break}o[r]=0}}return}}const e=h.querySegmentIterator();for(;e.nextPath()&&g;)for(;e.hasNextSegment()&&g;){const r=e.nextSegment();for(let e=0;e<s&&g;e++)1===o[e]&&r.isIntersectingPoint(t[e],n)&&(o[e]=2,g--)}}for(let e=0;e<s;e++)1===o[e]&&(o[e]=0)}(e,t,s,n,o):(0,i.f)(h)?(0,i.g)(0):(0,i.q)("")}function ns(){return Number.isNaN(this.radius.value())}function rs(e,t,s,n){return{pt:e.clone(),t,err:s,checkCount:n}}class is{constructor(e,t,s,n,r){this.m_left=e,this.m_tracker=r,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 h.P,ptEnd:new h.P,center:new o._,radius:new h.H,fcenter:new o.a5,fradius2:new h.M,maxError:Number.NaN,isLine:ns}}closeToCircularArc(e,t,s,n,r,i){if(this.m_circleCheckCounter++,i.maxError=0,!is.checkSweepAngle(e,t))return!1;if(i.ptStart.setCoordsPoint2D(s),i.ptEnd.setCoordsPoint2D(r),e.isCircular()){const t=e;return i.fradius2=h.M.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),i.radius.set(t.getSemiMajorAxis()),i.fcenter.assignPoint2D(t.getCenter()),i.center.set(t.getCenter()),!0}const a=i.ptEnd.sub(i.ptStart).clone();if(a.leftPerpendicularThis(),a.normalize(),Math.abs(a.dotProduct(n.sub(i.ptStart)))<=this.m_eps)return!!this.confirmIsLine(i,a)&&(i.radius.set(Number.NaN),i.center.setCoords(0,0),!0);{const s=i.ptEnd.sub(i.ptStart),r=n.sub(i.ptStart),o=s.crossProduct(r);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*r.sqrLength();let m=a*r.y-h*s.y;m/=o;let l=s.x*h-r.x*a;l/=o;const g=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*g>this.m_eps)return!1;const c=m+i.ptStart.x,u=l+i.ptStart.y;i.radius.set(g),i.center.setCoords(c,u);const _=this.maxCircleApproximationError(e,t,i);if(_>this.m_eps)return i.maxError=_,!1}const m=(new o.a5).assignPoint2D(i.ptStart),l=(new o.a5).assignPoint2D(i.ptEnd).sub(m),g=(new o.a5).assignPoint2D(n).sub(m),c=l.crossProduct(g);if(c.isZero())return!1;const u=l.sqrLength().mulDouble(.5),_=g.sqrLength().mulDouble(.5),p=u.mul(g.y).sub(_.mul(l.y)),d=l.x.mul(_).sub(g.x.mul(u)),f=p.mul(p).add(d.mul(d)),x=c.clone();x.invertThis(),i.fradius2=f.mul(x).mul(x),i.fcenter.setCoords(p.mul(x).add(m.x),d.mul(x).add(m.y)),i.center.setWithEps(i.fcenter.asPoint2D()),i.radius.setWithEps(Math.sqrt(i.fradius2.toDouble()));const P=o._.constructPoint2D(i.ptStart).subE(i.center),E=o._.constructPoint2D(i.ptEnd).subE(i.center);if(!P.dotProduct(E).gt(h.J))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.G.enumEllipticArc){const s=e,n=(0,o.a6)(s,t.vmin),r=(0,o.a6)(s,t.vmax);return!(Math.abs(r-n)>.5*h.o)}return!0}confirmIsLine(e,t){const s=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(s.mul(.25)))>this.m_eps||Math.abs(t.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,s){const n=[.25,.75],r=[.1,.25,.75,.9];let o,a;e.getGeometryType()===i.G.enumEllipticArc?(o=n,a=n.length):(o=r,a=r.length);let m=0;for(let n=0;n<a;++n){const r=new h.P;e.queryCoord2D((0,h.q)(t.vmin,t.vmax,o[n]),r);const i=r.sub(s.center.value()).length(),a=Math.abs(i-s.radius.value());a>m&&(m=a)}return m}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=(0,h.d)(9,Number.NaN);let r;e?r=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,r=2);const i=[],o=[],a=new h.P(0,0);for(let e=1;e<r;e++){const r=new h.E(n[e-1],n[e]);for(this.m_bReversedLeft=!is.goodOrientation(this.m_left,r),this.m_bReversedLeft?(i.push(rs(a,r.vmin,0,0)),i.push(rs(a,r.vmax,0,0))):(i.push(rs(a,r.vmax,0,0)),i.push(rs(a,r.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t);i.length>1;){this.progress_();const e=i.at(-1);let n=e.checkCount,r=e.err;const a=e.pt.clone(),m=e.t,l=i[i.length-2].t,g=.5*(m+l),c=this.m_left.getCoord2D(g);if(r<=this.m_eps||n>=5){const e=new h.E;if(e.setCoords(m,l),this.closeToCircularArc(this.m_left,e,a,c,i[i.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(m):t.push(l)),s++,i.pop();continue}n=0,r=this.m_leftArc.maxError}e.t=g,e.pt.setCoordsPoint2D(c),r*=.125,n++,e.err=r,e.checkCount=n,i.push(rs(a,m,r,n))}this.m_bReversedLeft&&t&&(t.length=t.length+o.length,(0,h.b)(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new o.a,s=[];if(!this.approximateWithCirclesImpl(!0,s))return t;let n=0;const r=this.m_left.getStartXY();t.startPath(r);for(let i=1;i<s.length;++i)if(e)t.lineTo(this.m_left.getCoord2D(s[i]));else{const e=new h.P;this.m_left.queryCoord2D(s[i],e);const a=new h.P;this.m_left.queryCoord2D(.5*(s[i]+n),a);const m=new o.l;m.constructCircularArcThreePoint(r,e,a),t.addSegment(m,!1),r.assign(e),n=s[i]}return t}static goodOrientation(e,t){const s=e.getCoord2D(t.vmin),n=e.getCoord2D(t.vmax);return s.compare(n)<0}progress_(e=!1){}}function os(e,t,s,n,r,i,o){(function(e,t,s,n,r,i){e.hasCurves()?(e.setCurveStitcherPointer(n),n.m_impl=new us(i,!1,null),n.m_impl.buildMonotonicCurveParentage(e,t,s,r)):n.m_impl=null})(e,t,s,r,i,o),ds(e,s,o)}function as(e,t,s,n){if(!(0,i.h)(e.getGeometryType()))return e;const r=e.getImpl();if(!r.hasNonLinearSegments())return e;const h=e.createInstance();h.getGeometryType()===i.G.enumPolygon&&h.setFillRule(e.getFillRule()),new o.E;const m=new a.P,l=new o.S,g=[],c=[],u=[],_=e.getDescription().getAttributeCount()>1,p=r.querySegmentIterator();for(;p.nextPath();){let e=!0;for(;p.hasNextSegment();){const n=p.isClosingSegment(),r=p.nextSegment();if(!r.isCurve()){h.addSegment(r,e,n),e=!1;continue}let a,d=!1;const f=!0,x=!0;switch(r.getGeometryType()){case i.G.enumEllipticArc:case i.G.enumRationalBezier2:a=(0,o.O)(r,t,s,f,x,c,u,g),d=!0;break;default:a=(0,o.N)(r,t,s,!0,f,c,g)}const P=d?2:3;c[1].isNAN()?(l.createLine(),l.get().construct(c[0],c[P])):d?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c,u)):(l.createCubicBezier(),l.get().constructPoints(c)),_&&e&&(r.queryCoord(g[0],m),l.get().setStart(m)),_&&(r.queryCoord(g[1],m),l.get().setEnd(m)),h.addSegment(l.get(),e,n&&1===a),e=!1;for(let e=1,t=a,s=P;e<t;++e,s+=P)c[s+1].isNAN()?(l.createLine(),l.get().construct(c[s],c[s+P])):d?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c.slice(s),u.slice(s))):(l.createCubicBezier(),l.get().constructPoints(c.slice(s))),_&&(r.queryCoord(g[e+1],m),l.get().setEnd(m)),h.addSegment(l.get(),!1,n&&e+1===t)}}return h}function hs(e){if(!e.hasSegmentParentage())return;const t=e.queryVertexIteratorOnSelection();for(let s=t.next();s!==o.n;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==o.n?e.getSegmentParentage(t):-1,r=e.getSegmentParentage(s);-1!==r&&-1!==n&&r!==n&&e.setSegmentParentageBreakVertex(s,!0)}}function ms(e,t){return t||(t=r.Envelope2D.constructEmpty()),function(e,t){let s=t.isEmpty()?e:(0,a.c)(null,t,!0).total();return s>e&&(s=e),.125*s}(e,t)}function ls(e,t){return.125*e}function gs(e,t){return 3*e+3*t}class cs{constructor(){this.m_impl=null}stitchCurves(e,t,s,n){this.m_impl&&(this.m_impl.stitchCurves(e,t,s),n&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&(this.m_impl.clearStitcher(e),this.m_impl=null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class us{constructor(e,t,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=e,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,s,n){const r=!1;if(!e.hasCurves())return;(0,i.g)(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=s;const h=new a.P,m=new o.S,l=[],g=[],c=[];for(let n=e.getFirstGeometry();n!==o.n;n=e.getNextGeometry(n))for(let a=e.getFirstPath(n);a!==o.n;a=e.getNextPath(a)){let n=e.getPathSize(a),u=e.getFirstVertex(a),p=0,d=-1;for(let f=0;f<n;f++){let x=e.getNextVertex(u);if(!e.querySegment(u,m,!0,!1)){u=x;continue}if(0===p){d=e.getVertexIndex(u);const t=us.regularizeCurve(e,m.get(),u,s);if(t>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new _.NonSimpleResult(13,d,-1)),p=t,n=e.getPathSize(a),x=e.getNextVertex(u);const s=e.querySegment(u,m,!0,!1);(0,i.g)(s)}}else p--;const P=e.getVertexIndex(u);let E;-1!==this.m_originalVertexIndex&&e.setUserIndex(u,this.m_originalVertexIndex,d),e.setSegmentToIndex(P,null);let y=!1;switch(m.get().getGeometryType()){case i.G.enumEllipticArc:case i.G.enumRationalBezier2:E=(0,o.O)(m.get(),t,s,r,!0,g,c,l),y=!0;break;default:{const e=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();E=(0,o.N)(m.get(),t,s,e,r,g,l)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(u,S,!0),!g[1].isNAN()){let t=null;t=y?new o.T({points:g,weights:c}):new o.y({cp:g}),t.snapControlPoints(s*s),e.setSegmentToIndex(P,t)}const C=y?2:3;for(let t=1,n=E,r=C;t<n;++t,r+=C){m.get().queryCoord(l[t],h);const n=e.insertVertex(a,x,h);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,d),!g[r+1].isNAN())if(y){const t=new o.T({points:g.slice(r),weights:c.slice(r)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(n),t)}else{const t=new o.y({cp:g.slice(r)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(n),t)}e.setSegmentParentageAndBreak(n,S,!1)}E>1&&(f+=E-1,n=e.getPathSize(a)),this.m_originalPlanarSegments.push(m.releaseSegment()),u=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;(0,i.g)(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const h=new a.P,m=new o.S,l=new o.D(0,t,0,this.m_progressTracker,!1,n),g=[];for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))for(let n=e.getFirstPath(t);n!==o.n;n=e.getNextPath(n)){let t=e.getPathSize(n),r=e.getFirstVertex(n);for(let o=0;o<t;o++){let o=e.getNextVertex(r);if(!e.querySegment(r,m,!0,!1)){r=o;continue}if(us.regularizeCurve(e,m.get(),r,s)>=0){t=e.getPathSize(n),o=e.getNextVertex(r);const s=e.querySegment(r,m,!0,!1);(0,i.g)(s)}const a=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,a),e.setSegmentToIndex(a,null),g.length=0,l.densifySegment(m.get(),g),this.progress_();const c=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,c,!0);for(let t=1,s=g.length-1;t<s;++t){m.get().queryCoord(g[t],h);const s=e.insertVertex(n,o,h);e.setSegmentParentageAndBreak(s,c,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(s,this.m_originalVertexIndex,a)}this.m_originalPlanarSegments.push(m.releaseSegment()),r=o}}e.clearSegments()}stitchCurves(e,t,s){us.st_stitchCurvesImpl(this,e,t,s,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){us.st_stitchCurvesImpl(null,e,o.n,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==o.n?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.G.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case i.G.enumBezier:return 2;case i.G.enumBezier2:return 3;case i.G.enumLine:return-1;case i.G.enumRationalBezier2:return 4;default:(0,i.t)("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,a,m){if(t===s&&0===n)return(0,i.g)(e.getNextVertex(t)===o.n),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const l=e.getNextVertex(t),g=e.getXY(t),c=e.getXY(s);let u,_=0;{let t=2,r=g;for(let n=l;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);_+=h.P.distance(s,r),r=s,t++}_+=h.P.distance(c,r),(0,i.g)(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(l,s);const p=m;let d=r.getClosestCoordinate(g,!1),f=r.getClosestCoordinate(c,!1);const x=r.calculateLength2D();let P=r.tToLength(d),E=r.tToLength(f);const y=Math.abs(P)>10*p&&Math.abs(P-x)>10*p,S=Math.abs(E)>10*p&&Math.abs(E-x)>10*p,C=e=>{const t=e.calculateLength2D();return Math.abs(t-_)>Math.max(.2*_,4*p)?null:e};let I=r.isClosed();if(!I){const e=h.P.distance(r.getStartXY(),r.getEndXY());e<=p&&x>5*e&&(I=!0)}if(I){let o,a,m=new h.P;if(2===n)m=h.P.lerp(g,c,.5),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o);else{let s=e.getNextNthVertex(t,(n-1)/2);m=e.getXY(s),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o);let i=Math.abs(a)>10*p&&Math.abs(a-x)>10*p;if(!i&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),o=r.getClosestCoordinate(m,!1),a=r.tToLength(o),i=Math.abs(a)>10*p&&Math.abs(a-x)>10*p),!i))return}let l=!1;const _=P===E;if(_){const s=0;let i=2,o=4;n-1<=4&&(i=s+1,o=s+2);const a=g,m=e.getXY(e.getNextNthVertex(t,i)),c=e.getXY(e.getNextNthVertex(t,o));l=-h.P.orientationNonRobust(a,m,c)*(0,h.e)(r.calculateArea2DHelper())>0}else S?y?l=a>P:a<E?(P=0,d=0):(P=x,d=1):a>P?(E=x,f=1):(E=0,f=0);if(_)u=r.clone(),u.dropAllAttributes(),l||u.reverse(),(0,i.g)(g.equals(c));else{let e=!1;d>f&&(e=!0,[d,f]=[f,d]),u=r.cut(d,f,!0),u.getDescription().getAttributeCount(),e&&u.reverse()}u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}else if(y||S){if((!y||!S)&&h.P.distance(r.getStartXY(),r.getEndXY())<10*p){const n=[(0,h.k)(d,f),(0,h.k)(d,f),(0,h.k)(d,f)];y?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],o=[0,0,0];let a=Number.MAX_VALUE,m=0;for(let e=0;e<3;e++){let t=!1;if(n[e].first>n[e].second){t=!0;const s=n[e].first;n[e].first=n[e].second,n[e].second=s}i[e]=r.cut(n[e].first,n[e].second,!0),i[e].dropAllAttributes(),t&&i[e].reverse(),i[e].setCoordsForIntersector(g,c,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(_-o[e]);s<a&&(a=s,m=e)}return u=i[m],u=C(u),void(u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u)))}let n=!1;d>f&&(n=!0,[d,f]=[f,d]),u=r.cut(d,f,!0),u.dropAllAttributes(),n&&u.reverse(),u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}else{if(u=r.clone(),u.dropAllAttributes(),P>E&&u.reverse(),_<Math.max(.75*x,x-this.m_densificationDeviation*(n-1))){const e=d>f?f:d,t=u.tToLength(e)+_;let s=u.lengthToT(t);s=(0,h.s)(s,e,1),u=u.cut(e,s,!0)}u.setCoordsForIntersector(g,c,!1),u=C(u),u&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),u))}}processSpanCurves_(e,t,s,n,r,a,h){if(t===s&&0===n)return(0,i.g)(e.getNextVertex(t)===o.n),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const m=e.getNextVertex(t);{let t=2;for(let n=m;n!==s;n=e.getNextVertex(n))t++;(0,i.g)(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(m,s);const l=e.getXY(t),g=e.getXY(s);if(r.isClosed()){if(l.isEqualPoint2D(g)&&l.isEqualPoint2D(r.getStartXY())){let i;if(i=this.verifySegmentFitnessCurves(e,t,s,n,r,a,h)){const n=r.clone();return n.dropAllAttributes(),i<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(l.isEqualPoint2D(r.getStartXY())){if(g.isEqualPoint2D(r.getEndXY())){const o=r.clone();o.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,o,a,h);if(m)return(0,i.g)(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),o)}}else if(g.isEqualPoint2D(r.getStartXY())&&l.isEqualPoint2D(r.getEndXY())){const o=r.getReversed();o.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,o,a,h);if(m)return(0,i.g)(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),o)}this.processSpanSplitSegmentCurves(e,t,s,n,r,a,h)}processSpan_(e,t,s,n,r,i,o){return 0===this.m_type?void this.processSpanSmartTe_(e,t,s,n,r,i,o):void this.processSpanCurves_(e,t,s,n,r,i,o)}processSpanSplitSegmentCurves(e,t,s,n,r,i,o){if(r.isLine())return;if(this.fitSegmentToSpanCurves(e,t,s,n,r,i,o))return;const a=o*o;let m=n,l=t;const g=e.getXY(t);let c=r.getClosestCoordinate(g,!1);const u=r.getCoord2D(c);let _=!1;const p=h.P.sqrDistance(g,u);if(p>a){const n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),n===s)return;l=n,_=!0,m-=1}let d=s;const f=e.getXY(s);c=r.getClosestCoordinate(f,!1);const x=r.getCoord2D(c);let P=!1;const E=h.P.sqrDistance(f,x);if(E>a){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===l)return;d=t,P=!0,m-=1}if((_||P)&&this.fitSegmentToSpanCurves(e,l,d,m,r,i,o))return;let y=!1;if(!_&&p>0){const s=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),s===d)return;l=s,_=!0,y=!0,m-=1}if(!P&&E>0){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===l)return;d=t,P=!0,y=!0,m-=1}if(y&&this.fitSegmentToSpanCurves(e,l,d,m,r,i,o))return;let S=l;for(;;){const t=e.getNextVertex(S);if(this.approximateSpanSectionCurves(e,S,r,i,o),S=t,S===d)return}}fitSegmentToSpanCurves(e,t,s,n,r,i,a){const m=[];m.push(e.getXY(t));let l=t;const g=new o.S;for(;;){e.querySegment(l,g,!1,!0);const t=[.1,.25,.4,.5,.6,.75,.9,1];let r=0;for(const e of t)(2===n||1&r)&&m.push(g.get().getCoord2D(e)),r++;if(l=e.getNextVertex(l),l===s)break}const c=(()=>{let e=m[0].compare(m.at(-1));if(0===e){const t=new h.K(0);(function(e,t,s){if(s.reset(),t<3)return;const n=e[0].clone(),r=n.x,i=n.y,o=e[1].clone(),a=new h.P;for(let r=2;r<t;r++)a.assign(e[r]),s.pe((a.x-n.x)*(o.y-i)),n.assign(o),o.assign(a);s.pe((r-n.x)*(o.y-i))})(m,m.length,t),e=t.getResult()>=0?-1:1}return e>0})();c&&m.reverse();const u=r.clone();if(u.dropAllAttributes(),c&&u.reverse(),u.setSegmentFromCoordsForStitcher(m,m.length),c&&u.reverse(),u.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,s,n,u,i,a)){this.removeSpanBetween(e,t,s);const n=e.getVertexIndex(t);return e.setSegmentToIndex(n,u),!0}return!1}approximateSpanSectionCurves(e,t,s,n,r){const m=new o.S;if(!e.querySegment(t,m,!0,!1))return;const l=s.getGeometryType();if(l!==m.get().getGeometryType()){if(l===i.G.enumEllipticArc){if(m.get().getGeometryType()!==i.G.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];!function(e,t,s,n,r){const i=(0,o.$)(t),a=Math.max(4*i,s);new is(t,null,a,Number.NaN,r).approximateWithCirclesImpl(!1,n)}(0,m.get(),r,s,this.m_progressTracker);const n=e.getNextVertex(t),i=e.getPathFromVertex(t),l=new a.P;let g=t;for(let t=1,r=s.length;t<r;t++){const r=s[t],a=m.get().getCoord2D(s[t-1]),c=m.get().getCoord2D((0,h.q)(s[t-1],r,.5));m.get().queryCoord(r,l);const u=l.getXY(),_=new o.l;_.constructCircularArcThreePoint(a,u,c);let p=o.n;r<1&&(p=e.insertVertex(i,n,l)),e.setSegmentToIndex(e.getVertexIndex(g),_),g=p}return}{const s=(0,h.m)(h.P,3);m.get().queryControlPoints(s);const n=[0,0,0];m.get().queryWeights(n);const r=(0,o.U)(n),i=new o.l;return(0,o.V)(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}(0,i.d)("approximate_span_section_")}}verifySegmentFitnessCurves(e,t,s,n,r,i,a){const m=e.getXY(t),l=e.getXY(s);if(!m.isEqualPoint2D(r.getStartXY())||!l.isEqualPoint2D(r.getEndXY()))return 0;let g=0;if(r.isClosed()){const e=r.getCoord2D(.1).sub(m);g=r.getCoord2D(.7).sub(m).crossProduct(e)>=0?1:-1}const c=(0,h.d)(o.W.s_maxMonotonicPartParams,Number.NaN);let u=r.getMonotonicPartParams(c.length,c);u--;const _=new o.L,p=[1,.5,.75,.25];let d=0,f=t;const x=m.clone();for(;;){const t=e.getNextVertex(f);let n=e.getSegment(f);null===n&&(e.queryLineConnector(f,_,!0),n=_);for(let e=t===s?1:0;e<p.length;e++){const t=n.getCoord2D(p[e]);if(!r.isCloserThanDistance(t,h.E.unit(),a))return 0}if(u>1)for(let e=1;e<u;){const t=r.getCoord2D(c[e]);n.isCloserThanDistance(t,h.E.unit(),a)?(c[u-1]=(0,h.c)(c[e],c[e]=c[u-1]),u--):e++}if(g){const e=n.getCoord2D(.25);d+=e.sub(m).crossProduct(x.sub(m)),x.assign(e),e.assign(n.getCoord2D(.75)),d+=e.sub(m).crossProduct(x.sub(m)),x.assign(e)}if(f=t,f===s)return u>1?0:g?d<0?-g:g:1}}removeSpanBetween(e,t,s){e.setSegmentToIndex(e.getVertexIndex(t),null);const n=e.getNextVertex(t);n!==s&&e.removeVertices(n,s)}static st_stitchCurvesImpl(e,t,s,n,r){if(!t.hasSegmentParentage())return;hs(t);let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;)if((0,i.l)(t.getGeometryType(a))){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);const h=t.isClosedPath(s);h&&(a+=1);let m=t.getFirstVertex(s);const l=t.getSegmentParentage(m);if(h){if(-1!==l&&!t.getSegmentParentageBreakVertex(m)){let e=t.getPrevVertex(m);const s=m;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(l!==r){(0,i.g)(-1===r);break}if(m=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){m=s,t.setSegmentParentageBreakVertex(m,!0);break}e=t.getPrevVertex(e),(0,i.g)(n<a)}}}else(0,i.g)(-1===l||t.getSegmentParentageBreakVertex(m));let g=m;for(let s=0;s<a&&g!==o.n;){const h=t.getSegmentParentage(g);if(-1===h){if(s++,g=t.getNextVertex(g),g===m)break;continue}let l=0,c=o.n;const u=g;l=1;let _=t.getNextVertex(u);for(;s<a&&_!==o.n;){s++,c=_,l++;const e=t.getSegmentParentage(_);if(-1===e||t.getSegmentParentageBreakVertex(_))break;(0,i.g)(e===h),_=t.getNextVertex(_)}if(c===o.n){(0,i.g)(0);break}if(!r){const s=e.m_originalPlanarSegments[h];e.processSpan_(t,u,c,l,s,h,n)}if(g=c,g===m)break}}if(s!==o.n)break;a=t.getNextGeometry(a)}else a=s===o.n?t.getNextGeometry(a):o.n}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);t.isClosedPath(s)&&(a+=1);let h=!0,m=!1;const l=t.getFirstVertex(s);let g=l;for(let s=0;s<a&&g!==o.n;){let c=t.getSegmentParentage(g);if(-1===c||h){h=!1,s++,g=t.getNextVertex(g),m=!0;continue}let u,_,p=0;if(m?(u=t.getPrevVertex(g),_=g,(0,i.g)(u!==o.n),(0,i.g)(_!==u),(0,i.g)(-1===t.getSegmentParentage(u)||l===u)):(u=g,_=t.getNextVertex(u),s++,(0,i.g)(_!==o.n),(0,i.g)(_!==u),c=t.getSegmentParentage(_)),p=2,m=!1,-1===c||t.getSegmentParentageBreakVertex(_)){g=_;continue}let d=t.getNextVertex(_);for(s++;s<a&&d!==o.n;){_=d,p++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;(0,i.g)(e===c),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[c];e.processSpan_(t,u,_,p,s,c,n)}g=_}}if(s!==o.n)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let a=s===o.n?t.getFirstGeometry():s;for(;a!==o.n;)if((0,i.l)(t.getGeometryType(a))){for(let s=t.getFirstPath(a);s!==o.n;s=t.getNextPath(s)){let a=t.getPathSize(s);const h=t.isClosedPath(s);h&&(a+=1);let m=t.getFirstVertex(s);if(h){if(-1!==t.getSegmentParentage(m)){let e=m;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===a){m=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else(0,i.g)(-1===t.getSegmentParentage(m)||t.getSegmentParentageBreakVertex(m));let l=m;for(let s=0;s<a&&l!==o.n;){const h=t.getSegmentParentage(l);if(-1===h){s++,l=t.getNextVertex(l);continue}let m=0,g=o.n;const c=l;m=1;let u=t.getNextVertex(c);for(;s<a&&u!==o.n;){s++,g=u,m++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;(0,i.g)(e===h),u=t.getNextVertex(u)}if(g===o.n)break;if(!r){const s=e.m_originalPlanarSegments[h];e.processSpan_(t,c,g,m,s,h,n)}l=g}}if(s!==o.n)break;a=t.getNextGeometry(a)}else a=s===o.n?t.getNextGeometry(a):o.n}static regularizeCurve(e,t,s,n){let r=t.snapControlPoints(n*n);if(r){const n=e.getVertexIndex(s),r=t.clone();e.setSegmentToIndex(n,r)}if(t.getGeometryType()===o.y.type){const i=[],o=t.calculateSpecialPointsForCracking(n,i);if(o>0){const a=[];if(o>1)for(let e=0;e<o;e++)if(a.push(t.getCoord2D(i[e])),e>0){const t=(Math.abs(a[e].x)+Math.abs(a[e].y))*(0,h.g)(),s=h.P.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new h.P;(0,h.U)(a[e-1],a[e],.5,t),a[e-1]=t,a[e]=t}}e.splitSegment(s,i,o),r=e.snapControlPoints(s,o+1,n*n)||r;for(let t=0;t<o;t++)s=e.getNextVertex(s),e.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function _s(e,t,s,n,r){return new xs(e,s,t,n,r).do_()}function ps(e,t,s=1,n=1,r=1,i=1){if(n>i)return e;if(i>n)return t;const o=new a.P;return function(e,t,s,n,r,i,o,a,h){const m=e.equals(t);if(n>i)return o.assignCopy(e),h[0]=n,a[0]=s,m;if(i>n)return o=t,h[0]=i,a[0]=r,m;o.assignCopy(e);const l=re(e.getXY(),t.getXY(),s,n,r,i);o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank}(e,t,s,n,r,i,o,[0],[0]),o}function ds(e,t,s){return xs.fixCurveTwoPointLoops(e,t,s)}function fs(e){return(0,a.h)(e)}class xs{constructor(e,t,s,n,r){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=r,this.m_progressCounter=0}do_(){const e=new a.C(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=fs(e);let s=(0,a.U)(e);const n=1.00001*s;s*=1.000001;let r=!1;const m=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),l=this.m_shape.hasPointFeatures();for(let e=0;;e++){this.m_shape.dbgCheckSelection(),e>m&&(0,i.d)("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let a=-1;0===e&&(a=this.firstCrack_(),r||=a>0);const h=this.cluster_(t);if(this.m_shape.dbgVerifyMonotone(),r||=h,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(t,!0,!1,this.m_bTrackChanges,o.n);r||=e,this.m_shape.dbgVerifyMonotone()}const g=this.m_shape.snapControlPointsOnSelection(n*n);r||=g,this.m_shape.dbgCheckSelection();let c=!1;if((0===e&&-1===a||l||Ie(!0,this.m_shape,s,null,this.m_progressTracker))&&(c=this.crack_(n),r||=c,this.m_shape.dbgVerifyMonotone()),!c&&!xs.fixCurveTwoPointLoops(this.m_shape,t,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return r&&function(e){if(!e.hasSegmentParentage())return;hs(e);const t=new a.a(0),s=e.queryVertexIteratorOnSelection();for(let e=s.next();e!==o.n;e=s.next())t.add(e);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(o.n);const n=h.P.getNAN();e.queryXY(t.read(0),n);let r=0;const i=h.P.getNAN();for(let s=1,a=t.size();s<a;s++){{const n=t.read(s);n!==o.n?e.queryXY(n,i):i.setNAN()}if(!i.isEqualPoint2D(n)){if(s-r>1){let n=!1;for(let i=r;i<s;++i){const s=t.read(i);if(e.getSegmentParentageBreakVertex(s)){n=!0;break}}if(!n){const i=(t,s,n)=>{const r=e.getPrevVertex(t),i=e.getNextVertex(t);r!==o.n?s.assign(e.getXY(r)):s.setNAN(),i!==o.n?n.assign(e.getXY(i)):n.setNAN()},a=new h.P,m=new h.P;i(t.read(r),a,m);for(let e=r+1;e<s;++e){const s=t.read(e);if(s===o.n)continue;const r=new h.P,l=new h.P;i(s,r,l);const g=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if(!(g(r,a)&&g(l,m)||g(l,a)&&g(r,m))){n=!0;break}}}if(n)for(let n=r;n<s;++n)e.setSegmentParentageBreakVertex(t.read(n),!0)}n.setCoordsPoint2D(i),r=s}}}(this.m_shape),r}cluster_(e){return se(this.m_shape,e,o.n,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return function(e,t,s,n){if(!Ce(e))return!1;const r=new be(n);r.m_shape=e,r.m_tolerance=t,r.m_bTrackChanges=s;let i=!1;const o=e.hasCurves()?5:15;return i=e.getTotalPointCount()<o?r.crackBruteForce_():r.crackerPlaneSweep_(),i}(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,s){if(!e.hasCurves())return!1;e.dbgVerifyCurves();const n=e.createUserIndexUninitialized(),r=new a.a(0),m=e.queryVertexIteratorOnSelection();for(let t=m.next();t!==o.n;t=m.next())r.add(t),e.setUserIndex(t,n,-1);if(0===r.size())return!1;r.add(o.n),e.sortVerticesSimpleByY(r,0,r.size()-1);let l=0;const g=e.getXY(r.read(l)),c=new h.P(Number.NaN,Number.NaN),u=[];for(let t=1,s=r.size();t<s;++t){const s=r.read(t),i=s!==o.n?e.getXY(s):c;if(i.equals(g))continue;const a=[];for(let s=l;s<t;s++){const t=r.read(s),i=e.getPrevVertex(t);if(i!==o.n&&-1===e.getUserIndex(i,n)){const t=Ps(e.getXY(i),e.getSegment(i));0!==h.P.sqrDistance(g,t.otherPt)&&(t.vert=i,t.dir=-1,a.push(t)),e.setUserIndex(i,n,1)}const m=e.getNextVertex(t);if(m!==o.n&&-1===e.getUserIndex(t,n)){const s=Ps(e.getXY(m),e.getSegment(t));0!==h.P.sqrDistance(g,s.otherPt)&&(s.vert=t,s.dir=1,a.push(s)),e.setUserIndex(t,n,1)}}if(a.length>1){a.sort((e,t)=>ys(e,t));const e=Ps(c.clone(),null);a.push(e);let t=0;for(let e=1,s=a.length;e<s;e++)if(!a[e].otherPt.equals(a[e-1].otherPt)){if(e-t>1&&null!==a[t].seg){let s=!1;const n=t;for(let r=t+1;r<e;r++)if(!Es(a[n],a[r])){s=!0;break}if(s)for(let s=t;s<e&&null!==a[s].seg;s++)u.push(a[s].vert)}t=e}}l=t,g.setCoordsPoint2D(i)}for(const s of u){const n=e.getSegment(s);(0,i.g)(null!==n);const r=e.getXY(s),o=e.getXY(e.getNextVertex(s));if(h.P.distance(r,o)<3*t)e.setSegmentToIndex(e.getVertexIndex(s),null);else{const t=n.lengthToT(.5*n.calculateLength2D());e.splitSegment(s,[t],1)}}return e.removeUserIndex(n),u.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=(0,a.c)(null,e,!0).total();if(4*t<this.m_tolerance.total()){let e=!1;const s=1.1*t,n=t,r=this.cluster_(s);e||=r;let i=0;this.m_bFilterDegenerateSegments&&(i=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,o.n));const a=this.crack_(n);return e||=a,e?1:i?2:0}return-1}progress_(e=!1){this.m_progressCounter++,!e&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function Ps(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function Es(e,t){if((0,i.g)(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const s=e.seg.getGeometryType();if(s!==t.seg.getGeometryType())return!1;if(s===i.G.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=(0,h.c)(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=(0,h.c)(o,o=a)),r.equals(o)&&i.equals(a)}if(s===i.G.enumRationalBezier2){const s=e.seg,n=t.seg,r=s.getControlPoint1(),i=n.getControlPoint1();if(!r.equals(i))return!1;const o=[0,0,0];s.queryWeights(o),-1===e.dir&&(o[2]=(0,h.c)(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=(0,h.c)(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}(0,i.d)("")}function ys(e,t){const s=e.otherPt.compare(t.otherPt);return 0!==s?s:function(e,t){if(null===e.seg||null===t.seg)return null!==e.seg?-1:null!==t.seg?1:0;const s=e.seg.getGeometryType(),n=t.seg.getGeometryType();return s<n?-1:s>n?1:0}(e,t)}var Ss=i.h,Cs=i.f,Is=i.z;function vs(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:(0,i.g)(0,"unrecognized cut side")}return 3}function bs(e,t,s,n,r,o,h){const m=new ks(r);m.m_bOGCOutput=!0;const l=e.getGeometryType()===i.G.enumPolygon&&1===e.getFillRule()&&!(0,a.Y)(n);return m.planarSimplifyImpl_(e,t,l,s,n,r,o,h)}function Gs(e,t,s,n,r,i,o,a){return new ks(i).planarSimplifyImpl_(e,t,s,n,r,i,o,a)}function ws(e,t,s){return function(e,t,s){const n=e.createInstance(),r=(0,h.m)(h.P,100),o=new Array(100),a=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&(0,i.d)("");for(let i=0;i<a;){const a=e.queryCoordinates(r,r.length,i,-1)-i;l?ts(t,r,a,s.total(),o):ss(t,r,a,s.total(),o);let h=0;for(let t=0;t<a;t++)0===o[t]&&(m&&(m=!1,n.addPoints(e,0,i)),h!==t&&n.addPoints(e,i+h,i+t),h=t+1);m||h===a||n.addPoints(e,i+h,i+a),i+=a}return m?e:n}(e,t,s)}function Ns(e,t,s,n){if(e.getDimension()>t.getDimension())return Fs(Hs(e),e,0,"^");if(e.getDimension()<t.getDimension())return Fs(Hs(t),e,0,"^");if(e.isEmpty())return Fs(Hs(t),e,0,"^");if(t.isEmpty())return Fs(Hs(e),e,0,"^");const h=new r.Envelope2D;e.queryEnvelope(h);const m=new r.Envelope2D;t.queryEnvelope(m);const l=new r.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=new ks(n),u=new o.E,_=u.addGeometry(Hs(e)),p=u.addGeometry(Hs(t));let d=0,f=null;if(u.hasCurves()){f=new cs;const e=u.getEnvelope2D(n);d=ls(g.total()),os(u,ms(g.total(),e),g.total(),0,f,null,n)}c.setEditShapeCrackAndCluster(u,g);const x=c.symmetricDifference(_,p);null!==f&&f.stitchCurves(u,x,d,!0);const P=Fs(u.getGeometry(x),e,0,"^");return Ss(P.getGeometryType())&&(P.getImpl().setIsSimple(4,g.total()),P.getGeometryType()===i.G.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Ts(e,t,s){return function(e,t,s){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return e.createInstance();const n=[new h.P],r=[0],o=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&(0,i.d)(""),n[0]=e.getXY(),o?ts(t,n,1,s.total(),r):ss(t,n,1,s.total(),r),0===r[0]?e.createInstance():e}(e,t,s)}function Ds(e,t,s,n,r,h=!1){0===t&&(0,i.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=t;s<n;s++)m=Math.max(e[s].getDimension(),m);if(2===m||1===m)return new ks(n).dissolveMultiPaths_(m,!1,e,t,s,r,h);let l=0,g=-1;for(let s=0,n=t;s<n;s++)e[s].getDimension()===m&&(-1===g&&(g=s),e[s].isEmpty()||(g=s,l++));if(l<2)return Hs(e[g]);const c=a.p.constructEmpty(),u=new o.E;let _=o.n;for(let s=0,n=t;s<n;s++)if(e[s].getDimension()===m&&!e[s].isEmpty()){_===o.n?_=u.addGeometry(Hs(e[s])):u.appendGeometry(_,Hs(e[s]));const t=a.p.constructEmpty();e[s].queryLooseEnvelope(t),c.mergeEnv3D(t)}const p=(0,a.c)(s,c.getEnvelope2D(),!0),d=new ks(n);if(h){const e=(0,a.Z)(s,c.getEnvelopeZs(),!0);return d.planarSimplify3DImpl_(u,p,e,0,!0)}return d.m_bOGCOutput=!0,d.planarSimplifyMultiPoints(u,p,!1,-1)}function Vs(e,t,s,n,r,h=!1){t<2&&(0,i.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=t;s<n;s++)m=Math.max(e[s].getDimension(),m);if(2===m||1===m)return new ks(n).dissolveMultiPaths_(m,!0,e,t,s,r,h);const l=a.p.constructEmpty(),g=new o.E;let c=o.n,u=0,_=-1;for(let s=0,n=t;s<n;s++)if(e[s].getDimension()===m&&(-1===_&&(_=s),!e[s].isEmpty())){_=s,c===o.n?c=g.addGeometry(Hs(e[s])):g.appendGeometry(c,Hs(e[s]));const t=a.p.constructEmpty();e[s].queryLooseEnvelope(t),l.mergeEnv3D(t),u++}if(u<2)return Hs(e[_]);const p=0===m?s:null,d=(0,a.c)(p,l.getEnvelope2D(),!0),f=new ks(n);if(h){const e=(0,a.Z)(p,l.getEnvelopeZs(),!0);return f.m_bOGCOutput=!0,f.planarSimplify3DImpl_(g,d,e,0,!0)}return f.planarSimplifyMultiPoints(g,d,!0,-1)}class ks{constructor(e){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=h.P.getNAN(),this.m_dummyPt2=h.P.getNAN(),this.m_fromEdgeForPolylines=o.n,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=e}linesToPolygonsImpl(e,t){let s=0,n=0,r=null;if(e.hasCurves()){r=new cs;const i=e.getEnvelope2D(this.m_progressTracker);n=ls(t.total());const o=ms(t.total(),i);s=gs(o,n),os(e,o,t.total(),0,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(s));const i=this.m_topoGraph.createUserIndexForChains(),a=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(a,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(a);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);const h=[];for(let t=this.m_topoGraph.getFirstChain();t!==o.n;t=this.m_topoGraph.getChainNext(t)){if(1===this.m_topoGraph.getChainUserIndex(t,i))continue;this.m_topoGraph.setChainUserIndex(t,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);if(0===this.m_topoGraph.getChainArea(t))continue;const s=this.m_topoGraph.extractPolygonFromChainAndIslands(e,o.n,t,o.n);null!=r&&r.stitchCurves(e,s,n,!1);const a=e.getGeometry(s);h.push(a)}return new u.S(h)}autoCompleteImpl(e,t,s){let n=0,r=0,i=null;if(e.hasCurves()){i=new cs;const t=e.getEnvelope2D(this.m_progressTracker);r=ls(s.total());const o=ms(s.total(),t);n=gs(o,r),os(e,o,s.total(),0,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,s.add(n));const a=this.m_topoGraph.getGeometryID(t),h=this.m_topoGraph.createUserIndexForChains(),m=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(m,h,1);for(let e=this.m_topoGraph.getChainFirstIsland(m);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,h,1);const l=[];for(let t=this.m_topoGraph.getFirstChain();t!==o.n;t=this.m_topoGraph.getChainNext(t)){if(1===this.m_topoGraph.getChainUserIndex(t,h))continue;this.m_topoGraph.setChainUserIndex(t,h,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==o.n;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,h,1);if(0!==this.m_topoGraph.getChainParentage(t))continue;const s=this.m_topoGraph.getChainHalfEdge(t);let n=s,m=!1;do{const e=this.m_topoGraph.getHalfEdgeTwin(n);if(this.m_topoGraph.getHalfEdgeChain(e)!==t&&0!==(this.m_topoGraph.getHalfEdgeParentage(n)&a)){m=!0;break}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==s);if(!m)continue;if(0===this.m_topoGraph.getChainArea(t))continue;const g=this.m_topoGraph.extractPolygonFromChainAndIslands(e,o.n,t,o.n);null!==i&&i.stitchCurves(e,g,r,!1);const c=e.getGeometry(g);l.push(c)}return new u.S(l)}setEditShape(e,t=!1){null===this.m_topoGraph&&(this.m_topoGraph=new K),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){_s(e,t,this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,this.m_bOGCOutput,o.n,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==o.n;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==o.n;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===o.n)continue;let r=s.getNextVertex(n);for(;r!==o.n;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),a=this.m_topoGraph.getHalfEdgeConnector(t,i);if(a!==o.n){const t=this.m_topoGraph.getHalfEdgeTwin(a);this.m_topoGraph.setHalfEdgeUserIndex(a,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}n=r,r=s.getNextVertex(n)}}}flushVertices_(e,t){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),r=new o.S,i=s.insertPath(e,o.n);t.push(t[0]);const a=t.length;let h=o.n;for(let e=0;e<a;e++){const o=t[e];if(h=s.addVertex(i,o),!n)continue;const m=this.m_topoGraph.getClusterFromVertex(o);if(e>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(h,!0),e<a-1){const n=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(t[e+1])),i=this.m_topoGraph.getSegmentParentage(n);s.setSegmentParentageAndBreak(h,i,e>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,r),s.setSegmentToIndex(s.getVertexIndex(h),r.get().clone()))}}if(n){const e=this.m_topoGraph.getClusterFromVertex(t[a-1]);this.m_topoGraph.isBreakNode(e)&&s.setSegmentParentageBreakVertex(h,!0)}s.setClosedPath(i,!0)}processPolygonCuts_(e,t,s,n){const r=this.m_topoGraph.getGeometryID(s),a=this.m_topoGraph.getGeometryID(n),h=[],m=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);if(n===o.n)continue;let g=n;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(g,l)){let s=g,n=g,o=!1,c=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,l,1),o||0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&r)&&(n=s,o=!0),o){const t=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(n);h.push(r),-1!==e&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&(c|=this.m_topoGraph.getHalfEdgeUserIndex(s,e))}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==n);if(o&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(n))>0){const e=m.createGeometry(i.G.enumPolygon);this.flushVertices_(e,h),-1!==t&&m.setGeometryUserIndex(e,t,c)}h.length=0}g=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(g))}while(g!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(e,t,s,n){this.m_topoGraph.removeSpikes_();let r=-1;-1!==e&&(r=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(r,s)),this.processPolygonCuts_(r,e,t,s),-1!==r&&(this.m_topoGraph.deleteUserIndexForHalfEdges(r),r=-1);const i=this.m_topoGraph.getShape();for(let e=i.getFirstGeometry();e!==o.n;e=i.getNextGeometry(e))e!==t&&e!==s&&n.push(e);n.sort((e,t)=>{const s=i.getFirstPath(e),n=i.getRingArea(s),r=i.getFirstPath(t),o=i.getRingArea(r);return n<o?-1:n>o?1:0})}cut(e,t,s,n,r){const o=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(n),h=(0,i.z)(o),m=(0,i.z)(a);if(2!==h||1!==m){if(1===h&&1===m)return void new Ms(this,e,t,s,n,r).Do();(0,i.d)("")}else this.cutPolygonPolyline_(t,s,n,r)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){const t=e.getGeometryType();if(t===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.G.enumPoint){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if((0,i.f)(t)){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.G.enumMultiPoint&&t!==i.G.enumPolyline&&t!==i.G.enumPolygon&&(0,i.a)("Unexpected geometry type"),e}dissolveNonSimplePolygons(e,t,s,n){(0,i.g)(t>0);const r=new o.E;let a=0,h=-1;for(let s=0,n=t;s<n;s++)2===e[s].getDimension()&&(-1===h&&(h=s),e[s].isEmpty()||(a++,r.addGeometry(e[s])));return 0===a?((0,i.g)(h>=0),this.normalizeInputGeometry(e[h])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,s,n,m,l,g){(0,i.g)(e>=1&&e<=2),(0,i.g)(n>0);const c=8&l?1:2,u=a.p.constructEmpty();let _=0,p=-1,d=!0;for(let t=0,r=n;t<r;t++)if(s[t].getDimension()===e&&(-1===p&&(p=t),!s[t].isEmpty())){p=t,_++;const n=a.p.constructEmpty();if(s[t].queryLooseEnvelope(n),u.mergeEnv3D(n),2===e&&d&&s[t].getGeometryType()===i.G.enumPolygon)if(16&l){const e=[0],n=s[t].getImpl().getIsSimple(0,e),r=this.m_bOGCOutput?5===n:(0,a.i)(n);d&&=r}else{const e=(0,a.k)(s[t],0);d&&=e}}if(_<2&&((0,i.g)(p>=0),0===_||!(16&l)))return this.normalizeInputGeometry(s[p]);if(!d){const e=(0,a.c)(t?null:m,u.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,n,e,l)}const f=s.slice(0,n),x=(0,a.c)(m,u.getEnvelope2D(),!0),P=10*(0,a.h)(x);let E=new a.C(0,0);if(g&&(E=(0,a.Z)(m,u.getEnvelopeZs(),!0)),1===_&&1===e&&2===c&&!t)return g?((0,i.g)(0),{}):this.m_bOGCOutput?bs(f[p],x,!1,-1,this.m_progressTracker,c,!1):Gs(f[p],x,!1,!1,-1,this.m_progressTracker,c,!1);const y=new a.a3;y.startConstruction();let S=2===e?3:4,C=0;for(let s=0,o=n;s<o;s++){if(f[s].getDimension()!==e||f[s].isEmpty())continue;let n=f[s].getGeometryType();if(n!==i.G.enumEnvelope){if((0,i.f)(n)?(f[s]=this.normalizeInputGeometry(f[s]),n=i.G.enumPolyline):(0,i.g)((0,i.h)(n)),1===e){(0,i.g)(n===i.G.enumPolyline);let e=-1;if(g)(0,i.g)(0,"3d not implemented yet");else{const t=[0];e=f[s].getImpl().getIsSimple(x.total(),t)}if(this.m_bOGCOutput?5!==e:!(0,a.i)(e))if(t)S=-1;else{g?(0,i.g)(0,"3d not implemented yet"):this.m_bOGCOutput?f[s]=bs(f[s],x,!1,-1,this.m_progressTracker,c,!1):f[s]=Gs(f[s],x,!1,!1,-1,this.m_progressTracker,c,!1);const e=[0];(0,i.g)((0,a.i)(f[s].getImpl().getIsSimple(x.total(),e)))}}else{(0,i.g)(n===i.G.enumPolygon);const e=[0],t=f[s].getImpl().getIsSimple(0,e);(0,i.g)((0,a.Y)(t))}const o=f[s].getImpl();for(let e=0,t=o.getPathCount();e<t;e++){const t=r.Envelope2D.constructEmpty();o.queryLoosePathEnvelope(e,t),t.inflateCoords(P,P),y.addEnvelope(C,t),C++}}else{(0,i.g)(n===i.G.enumEnvelope);const e=r.Envelope2D.constructEmpty();f[s].queryLooseEnvelope(e),e.inflateCoords(P,P),y.addEnvelope(C,e),C++,S=-1}}y.endConstruction();const I=C,v=(0,h.d)(I,-2147483647),b=(0,h.d)(I,-1);let G=0;p=-1,C=0;for(let t=0,s=n;t<s;t++){if(f[t].getDimension()!==e)continue;if(-1===p&&(p=t),f[t].isEmpty())continue;p=t,G++;const s=f[t].getGeometryType();if((0,i.h)(s))for(let e=0,s=f[t].getPathCount();e<s;e++)b[C]=t,v[C]=-e-1,C++;else(0,i.g)(s===i.G.enumEnvelope),b[C]=t,v[C]=-1,C++}if(G<2&&2===e)return(0,i.g)(p>=0),this.normalizeInputGeometry(f[p]);let w=I;for(;y.next()&&w>0;){this.progress_();const e=y.getHandleA(),t=y.getHandleB(),s=y.getElement(e),n=y.getElement(t);b[s]!==b[n]&&(v[s]<0&&(w--,v[s]=-(v[s]+1)),v[n]<0&&(w--,v[n]=-(v[n]+1)))}const N=new o.E;let T,D=!1,V=0;for(let t=0,s=n;t<s;t++){if(f[t].getDimension()!==e||f[t].isEmpty())continue;const s=f[t].getGeometryType(),n=V;let r=0,a=0;const h=(0,i.h)(s)?f[t]:null;for(let e=n,s=v.length;e<s&&b[e]===t;e++)v[e]>=0&&(r++,a+=h?h.getPathSize(v[e]):(0,i.v)(f[t])),V++;if(a>.95*(0,i.v)(f[t])){N.addGeometry(this.normalizeInputGeometry(f[t]));for(let e=n;e<V;e++)v[e]<0&&(v[e]=-(v[e]+1))}else{if(0===r){D=!0;continue}{D=!0,(0,i.g)((0,i.h)(s)),(0,i.g)(null!=h);const e=new o.P({vd:f[t].getDescription()}),r=new o.a({vd:f[t].getDescription()}),a=s===i.G.enumPolygon?e:r;for(let e=n;e<V;e++)v[e]>=0&&a.addPath(h,v[e],!0);N.addGeometry(a)}}}if(N.getFirstGeometry()!==o.n){const s=2===e,n=t?(0,a.c)(null,u.getEnvelope2D(),!0):x;let r=new a.C(0,0);if(g&&(r=t?(0,a.Z)(null,u.getEnvelopeZs(),!0):E),2===e&&!(2&l)){N.collapseAllGeometriesToFirst();let e=0,t=null;if(N.hasCurves()&&!N.hasSegmentParentage()){t=new cs;const s=N.getEnvelope2D(this.m_progressTracker);e=ls(n.total()),os(N,ms(n.total(),s),n.total(),0,t,null,this.m_progressTracker)}(function(e,t,s,n){s>0&&se(e,s,t,!1,n),new Se(n).executeImpl_(e,t)})(N,N.getFirstGeometry(),n.total(),this.m_progressTracker),null!==t&&t.stitchCurves(N,o.n,e,!0)}if(g)T=this.planarSimplify3DImpl_(N,n,r,c,!0);else if(2===e)T=this.planarSimplifyPolygons(N,n,s,t,-1,!1);else{const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=c,T=this.planarSimplifyPolylines(N,n,t,e,-1)}if(!D){const e=[0];S=T.getImpl().getIsSimple(n.total(),e)}}else(0,i.g)(D),(0,i.g)(p>=0),T=2===e?new o.P({vd:f[p].getDescription()}):new o.a({vd:f[p].getDescription()});if(D){let e=0;for(let t=0,s=v.length;t<s;t++){const s=b[t];if(!(s<0)&&v[t]<0){const n=f[s].getGeometryType(),r=(0,i.h)(n)?f[s]:null;if(r){const s=-(v[t]+1);e+=r.getPathSize(s)}else e+=4}}T.reserve(T.getPointCount()+e);for(let e=0,t=v.length;e<t;e++){const t=b[e];if(!(t<0)&&v[e]<0){const s=f[t].getGeometryType(),n=(0,i.h)(s)?f[t]:null;if(n){const t=-(v[e]+1);T.addPath(n,t,!0)}else s===i.G.enumEnvelope?T.addEnvelope(f[t],!1):((0,i.g)((0,i.f)(s)),T.addSegment(f[t],!0))}}}let k=0;if(2===e?-1!==S&&(S=3,k=t?0:x.total()):((0,i.g)(1===e),t||-1===S||(k=x.total())),g||T.getImpl().setIsSimple(S,k),!t&&D)if(2===e){if(!g)return(new Js).execute(T,m,!1,this.m_progressTracker);(0,i.g)(0,"3d not yet implemented")}else 1===e&&1!==c&&(T=g?((0,i.g)(0),{}):function(e,t,s,n){const r=new ks(n),a=new o.E,h=a.addGeometry(t),m=r.planarSimplifyNoCrackingAndCluster(e,a,h,s);return(0,i.g)(m,"planar_simplify_no_cracking_and_cluster"),a.getGeometry(h)}(this.m_bOGCOutput,T,c,this.m_progressTracker),T.getImpl().setIsSimple(S,k));return T}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==o.n)do{if(this.progress_(),1!==this.m_topoGraph.getHalfEdgeUserIndex(r,e)){const s=this.m_topoGraph.getHalfEdgeTwin(r);this.m_topoGraph.setHalfEdgeUserIndex(s,e,1),this.m_topoGraph.setHalfEdgeUserIndex(r,e,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(r);if(this.isGoodParentage(n)){const e=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(e)&&t.push(r)}}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,s,n){let r=(0,h.j)(),a=o.n;for(let n=this.m_topoGraph.getClusterVertexIterator(e);n!==o.n;n=this.m_topoGraph.incrementVertexIterator(n)){const e=this.m_topoGraph.getVertexFromVertexIterator(n),i=t.getUserIndex(e,s);i>=0&&i<r&&(r=i,a=e)}(0,i.g)(a!==o.n);let m=t.getUserIndex(a,n);return m>0&&(t.setUserIndex(a,n,--m),0===m&&t.setUserIndex(a,s,-1)),a}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,s,n,r){const a=this.m_topoGraph.getShape();if(a.getGeometryType(e)!==i.G.enumPolygon)return;const h=a.hasSegmentParentage(),m=new o.S;for(let i=a.getFirstPath(e);i!==o.n;i=a.getNextPath(i)){const e=a.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);const l=this.m_topoGraph.getHalfEdgeFromVertex(e);if(l===o.n)continue;const g=this.m_topoGraph.getHalfEdgeUserIndex(l,s);if(1===g||2===g)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 u=a.insertPath(t,o.n);a.setClosedPath(u,!0);let _=l,p=e,d=this.m_topoGraph.getClusterFromVertex(p),f=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(p,r),t=a.addVertex(u,e);if(this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,m),a.setSegmentToIndex(a.getVertexIndex(t),m.get().clone())),h){const e=this.m_topoGraph.getSegmentParentage(_);a.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(d))}let i,l;-1!==n&&this.m_topoGraph.setClusterUserIndex(d,n,1),this.m_topoGraph.setHalfEdgeUserIndex(_,s,1),_=this.m_topoGraph.getHalfEdgeNext(_);do{i=1===f?a.getNextVertex(p):a.getPrevVertex(p),l=i!==o.n?this.m_topoGraph.getClusterFromVertex(i):o.n}while(l===d);const g=this.m_topoGraph.getHalfEdgeOrigin(_);if(g!==l){do{i=1===f?a.getPrevVertex(p):a.getNextVertex(p),l=i!==o.n?this.m_topoGraph.getClusterFromVertex(i):o.n}while(l===d);if(g!==l){l=g;const e=this.m_topoGraph.getClusterVertexIterator(l);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else f=-f}d=l,p=i}while(_!==l)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==o.n&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==o.n&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const a=new o.S,h=this.m_topoGraph.getShape();h.dbgVerifyCurves();const m=h.hasSegmentParentage();for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n)continue;let l=t;do{this.progress_();const e=this.m_topoGraph.getHalfEdgeUserIndex(l,r);if(1!==e&&2!==e){const e=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(e)){const e=h.insertPath(s,o.n);h.setClosedPath(e,!0);let t=l;do{const s=this.m_topoGraph.getHalfEdgeVertexIterator(t);let l=o.n;if(s!==o.n)l=this.m_topoGraph.getVertexFromVertexIterator(s);else{const e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(t));l=this.m_topoGraph.getVertexFromVertexIterator(e),l=h.getNextVertex(l)}const g=this.chooseVertexFromVertexCluster_(l,n),c=h.addVertex(e,g);if(m){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);h.setSegmentParentageAndBreak(c,e,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,a),h.setSegmentToIndex(h.getVertexIndex(c),a.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(t,r,1),-1!==i){const e=this.m_topoGraph.getClusterFromVertex(g);this.m_topoGraph.setClusterUserIndex(e,i,1)}t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,r,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==t)}}topoOperationPolygonPolygon_(e,t,s,n=!1){this.dissolveTopoGraphCommonEdges_();const r=this.m_topoGraph.getShape(),a=r.createGeometry(i.G.enumPolygon),h=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,a,s,h,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(h),n||Fe(r,a,3,this.m_bOGCOutput,o.n,this.m_progressTracker),a}topoOperationPolyline_(e,t){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(o.n,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.G.enumMultiPoint),s=e.insertPath(t,o.n);for(let t=this.m_topoGraph.getFirstCluster();t!==o.n;t=this.m_topoGraph.getNextCluster(t)){const n=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(n)){let n=o.n;for(let s=this.m_topoGraph.getClusterVertexIterator(t);s!==o.n;s=this.m_topoGraph.incrementVertexIterator(s)){const t=this.m_topoGraph.getVertexFromVertexIterator(s);n===o.n&&(n=t);const r=e.getGeometryFromPath(e.getPathFromVertex(t)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){n=t;break}}e.addVertex(s,n)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=(0,i.z)(s),a=(0,i.z)(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=o.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===a?this.topoOperationPolygonPolygon_(e,t,l):1===r&&a>0||1===a&&r>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===r||0===a?this.topoOperationMultiPoint_():void(0,i.d)("")}topoOperationPolygonPolygonEx(e,t,s){const n=this.m_topoGraph.getShape(),r=n.createGeometry(i.G.enumPolygon),a=n.createGeometry(i.G.enumPolyline),h=n.createGeometry(i.G.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=o.n;const l=this.m_topoGraph.createUserIndexForHalfEdges(),g=this.m_topoGraph.createUserIndexForClusters();n.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,r,s,l,g),n.dbgVerifyCurves();const c=n.hasSegmentParentage(),u=new o.S;for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){const t=this.m_topoGraph.getClusterHalfEdge(e);if(t===o.n)continue;let r=t;do{let t=this.m_topoGraph.getHalfEdgeUserIndex(r,l),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(r),l),h=t|i;if(2===h){let m=this.m_topoGraph.getHalfEdgeParentage(r);if(this.isGoodParentage(m)){const _=n.insertPath(a,o.n);let p=r;const d=this.chooseVertexFromCluster_(e,s);let f=n.addVertex(_,d);if(c){const e=this.m_topoGraph.getSegmentParentage(r),t=this.m_topoGraph.getHalfEdgeOrigin(r);n.setSegmentParentageAndBreak(f,e,this.m_topoGraph.isBreakNode(t))}this.m_topoGraph.isHalfEdgeCurve(r)&&(this.m_topoGraph.querySegmentXY(r,u),n.setSegmentToIndex(n.getVertexIndex(f),u.get().clone())),this.m_topoGraph.setClusterUserIndex(e,g,1);do{this.progress_();const e=this.m_topoGraph.getHalfEdgeTo(p),o=this.chooseVertexFromCluster_(e,s);if(f=n.addVertex(_,o),c){const e=this.m_topoGraph.getSegmentParentage(r),t=this.m_topoGraph.getHalfEdgeOrigin(r);n.setSegmentParentageAndBreak(f,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.setHalfEdgeUserIndex(p,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l,1),this.m_topoGraph.setClusterUserIndex(e,g,1),p=this.m_topoGraph.getHalfEdgeNext(p),t=this.m_topoGraph.getHalfEdgeUserIndex(p,l),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l),h=t|i,2!==h)break;if(m=this.m_topoGraph.getHalfEdgeParentage(p),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(p,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(p),l,1);break}this.m_topoGraph.isHalfEdgeCurve(r)&&p!==r&&(this.m_topoGraph.querySegmentXY(r,u),n.setSegmentToIndex(n.getVertexIndex(f),u.get().clone()))}while(p!==r)}else this.m_topoGraph.setHalfEdgeUserIndex(r,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(r),l,1)}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==t)}for(let e=this.m_topoGraph.getFirstCluster();e!==o.n;e=this.m_topoGraph.getNextCluster(e)){if(this.progress_(),1===this.m_topoGraph.getClusterUserIndex(e,g))continue;const t=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(t)){m===o.n&&(m=n.insertPath(h,o.n));const t=this.m_topoGraph.getClusterVertexIterator(e);let r=o.n;if(t!==o.n){r=this.m_topoGraph.getVertexFromVertexIterator(t);const e=this.chooseVertexFromVertexCluster_(r,s);n.addVertex(m,e)}}}this.m_topoGraph.deleteUserIndexForClusters(g),this.m_topoGraph.deleteUserIndexForHalfEdges(l),n.dbgVerifyCurves(),Fe(n,r,3,this.m_bOGCOutput,o.n,this.m_progressTracker);const _=[o.n,o.n,o.n];return _[0]=h,_[1]=a,_[2]=r,_}topoOperationPolylinePolylineOrPolygonEx(e,t){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(o.n,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.G.enumMultiPoint),s=e.insertPath(t,o.n);for(let t=this.m_topoGraph.getFirstCluster();t!==o.n;t=this.m_topoGraph.getNextCluster(t)){const n=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(n)){let n=o.n;for(let s=this.m_topoGraph.getClusterVertexIterator(t);s!==o.n;s=this.m_topoGraph.incrementVertexIterator(s)){const t=this.m_topoGraph.getVertexFromVertexIterator(s);n===o.n&&(n=t);const r=e.getGeometryFromPath(e.getPathFromVertex(t)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){n=t;break}}e.addVertex(s,n)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Is(s),a=Is(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=o.n;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===a)return this.topoOperationPolygonPolygonEx(e,t,l);if(1===r&&a>0||1===a&&r>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[t,e]}if(0===r||0===a){const e=[];return e.push(this.topoOperationMultiPoint()),e}(0,i.d)("")}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){const s=this.getCombinedHalfEdgeParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t),r=this.m_topoGraph.getHalfEdgeTo(t);let i=0,a=0;for(let h=this.m_topoGraph.getClusterVertexIterator(n);h!==o.n;h=this.m_topoGraph.incrementVertexIterator(h)){const n=this.m_topoGraph.getVertexFromVertexIterator(h),m=e.getPathFromVertex(n),l=e.getGeometryFromPath(m),g=this.m_topoGraph.getGeometryID(l),c=e.getFirstVertex(m),u=0!==(g&s);u&&c===n&&(this.m_fromEdgeForPolylines=t);const _=e.getNextVertex(n);if(_!==o.n&&this.m_topoGraph.getClusterFromVertex(_)===r){if(i++,u){if(this.m_fromEdgeForPolylines===o.n&&c===_){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}a++}}else{const s=e.getPrevVertex(n);if(s!==o.n&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===o.n&&c===s){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}a--}}}return this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(r,this.m_dummyPt2),(0!==a?a:i)*h.P.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(e,t){const s=this.m_topoGraph.getHalfEdgePrev(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return o.n;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=o.n;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==o.n)return o.n;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(r))}return i}tryMoveThroughCrossroadForward(e,t){const s=this.m_topoGraph.getHalfEdgeNext(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){const t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return o.n;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=o.n;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==o.n)return o.n;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(r))}return i}isOnALoop(e,t){let s=e;const n=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let r=0;r<n;r++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,t))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===e)return!0}(0,i.d)("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,a,m,l,g,c){(0,i.g)(r===o.n&&a>=0&&m>=0||-1===a&&-1===m),(0,i.g)(-1===l&&1!==c.unsplitBehavior||-1!==l&&1===c.unsplitBehavior);const u=c.ogcRule,_=c.allCrossRoadsImpassable,p=1===c.unsplitBehavior,d=0===c.unsplitBehavior,f=this.m_topoGraph.getShape(),x=f.hasSegmentParentage();let P=e,E=this.m_topoGraph.getHalfEdgeTwin(P);const y=new o.S;this.m_fromEdgeForPolylines=o.n;let S=this.prevailingDirection(f,P),C=P,I=o.n,v=!1,b=!1,G=!1;if(!p)for(;;){const t=this.m_topoGraph.getHalfEdgePrev(P);if(t===E){G=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(E);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){v=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(_){v=!0;break}if(P=this.tryMoveThroughCrossroadBackwards(P,!0),P===o.n){v=!0;break}E=this.m_topoGraph.getHalfEdgeTwin(P)}else P=t,E=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){G=!0;break}if(P===e){I=e,b=!0;break}const r=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(r))break;C=P,S+=this.prevailingDirection(f,P)}if(I===o.n){for(P=e,E=this.m_topoGraph.getHalfEdgeTwin(P),I=P;;){const e=this.m_topoGraph.getHalfEdgeNext(P),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){v=!0;break}if(e===E){G=!0;break}if(-1!==l){const e=this.m_topoGraph.getHalfEdgeOrigin(E);if(1===this.m_topoGraph.getClusterUserIndex(e,l)){v=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(E);if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(t||_){v=!0;break}if(P=this.tryMoveThroughCrossroadForward(P,!0),P===o.n){v=!0;break}E=this.m_topoGraph.getHalfEdgeTwin(P)}else P=e,E=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){G=!0;break}const r=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(r))break;I=P,S+=this.prevailingDirection(f,P)}const t=this.m_topoGraph.getHalfEdgeOrigin(C);b=this.m_topoGraph.getHalfEdgeTo(I)===t}else if(this.m_fromEdgeForPolylines!==o.n){C=e,I=this.tryMoveThroughCrossroadBackwards(C,!1),(0,i.g)(I!==o.n);const t=this.m_topoGraph.getHalfEdgeTwin(C);this.m_topoGraph.getHalfEdgeNext(t)}let w=b;b||G||g&&(w=this.isOnALoop(e,s),w||(w=this.isOnALoop(E,s)));const N=S>=0;let T=!1;w&&v&&(b?(T=u,N&&(T||p||d)&&C!==e&&((0,i.g)(!p),C=e,T=!1)):(p||N&&d)&&(C=e));let D=0;for(P=C;E=this.m_topoGraph.getHalfEdgeTwin(P),this.m_topoGraph.setHalfEdgeUserIndex(P,s,1),this.m_topoGraph.setHalfEdgeUserIndex(E,s,1),D++,P!==I;)P=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1);N||(I=(0,h.c)(C,C=I),I=this.m_topoGraph.getHalfEdgeTwin(I),C=this.m_topoGraph.getHalfEdgeTwin(C));let V=f.insertPath(t,o.n);P=C;const k=this.m_topoGraph.getHalfEdgeOrigin(C);let F;F=-1!==a?this.chooseVertexByOrder(k,f,a,m):this.chooseVertexFromCluster_(k,r),this.m_topoGraph.isStrongPathNode(k)&&f.setStrongPathStart(V,!0);let H=f.addVertex(V,F),A=H;-1!==n&&this.m_topoGraph.setClusterUserIndex(k,n,1);let M=0;const U=T?Math.trunc((D+1)/2):-1;let q=o.n,O=!0,Y=o.n;for(;;){if(x){const e=this.m_topoGraph.getSegmentParentage(P),t=this.m_topoGraph.getHalfEdgeOrigin(P);f.setSegmentParentageAndBreak(A,e,O||this.m_topoGraph.isBreakNode(t))}O=!1,this.m_topoGraph.isHalfEdgeCurve(P)&&(this.m_topoGraph.querySegmentXY(P,y),f.setSegmentToIndex(f.getVertexIndex(A),y.get().clone())),q!==o.n&&-1!==m&&f.addToUserIndex(q,m,-1);const e=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1),s=this.m_topoGraph.getHalfEdgeTo(P);let i;if(i=-1!==a?this.chooseVertexByOrder(s,f,a,m):this.chooseVertexFromCluster_(s,r),H=f.addVertex(V,i),Y=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),x&&this.m_topoGraph.isBreakNode(s)&&f.setSegmentParentageBreakVertex(H,!0),q=i,M++,T&&M===U&&(V=f.insertPath(t,o.n),H=f.addVertex(V,i),O=!0,-1!==m&&f.addToUserIndex(i,m,-1),q=o.n),P===I)break;P=e,A=H}Y!==o.n&&this.m_topoGraph.isStrongPathNode(Y)&&f.setStrongPathEnd(V,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,s,n){(0,i.g)(t===o.n||e===o.n);const r=this.m_topoGraph.getShape(),a=t=>e===o.n?t===o.n?r.getFirstGeometry():r.getNextGeometry(t):t===o.n?e:o.n,m=r.createGeometry(i.G.enumPolyline);let l=-1;s&&(l=this.m_topoGraph.createUserIndexForClusters());const g=this.m_topoGraph.createUserIndexForHalfEdges(),c=t===o.n?r.createUserIndex():-1,u=t===o.n?r.createUserIndex():-1;let _=-1;if(1===n.unsplitBehavior){_=this.m_topoGraph.createUserIndexForClusters();for(let e=a(o.n);e!==o.n;e=a(e))for(let t=r.getFirstPath(e);t!==o.n;t=r.getNextPath(t)){{const e=r.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,_,1)}if(!r.isClosedPath(t)){const e=r.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,_,1)}}}if(t===o.n){let e=0;for(let t=a(o.n);t!==o.n;t=a(t))for(let s=r.getFirstPath(t);s!==o.n;s=r.getNextPath(s))if(r.isClosedPath(s)){let t=r.getFirstVertex(s);for(let n=0,i=r.getPathSize(s);n<i;n++,t=r.getNextVertex(t))r.setUserIndex(t,c,e++),r.setUserIndex(t,u,2)}else{const t=r.getFirstVertex(s);r.setUserIndex(t,c,e++),r.setUserIndex(t,u,1);let n=r.getNextVertex(t);for(let t=1,i=r.getPathSize(s)-1;t<i;++t)r.setUserIndex(n,c,e++),r.setUserIndex(n,u,2),n=r.getNextVertex(n);r.setUserIndex(n,c,e++),r.setUserIndex(n,u,1)}}for(let e=a(o.n);e!==o.n;e=a(e))for(let s=r.getFirstPath(e);s!==o.n;s=r.getNextPath(s)){let e=r.getFirstVertex(s);for(let i=0,a=r.getPathSize(s);i<a;i++,e=r.getNextVertex(e)){const s=this.m_topoGraph.getHalfEdgeFromVertex(e);if(s===o.n)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,g))continue;const r=this.getCombinedHalfEdgeParentage(s);if(this.isGoodParentage(r)){const e=0===i;this.restorePolylineParts(s,m,g,l,t,c,u,_,e,n)}}}let p=o.n;if(s){p=r.createGeometry(i.G.enumMultiPoint);let e=o.n;for(let s=this.m_topoGraph.getFirstCluster();s!==o.n;s=this.m_topoGraph.getNextCluster(s))if(this.progress_(),1!==this.m_topoGraph.getClusterUserIndex(s,l)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===o.n&&(e=r.insertPath(p,o.n));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==o.n){let i;this.m_topoGraph.getVertexFromVertexIterator(n),i=-1!==c?this.chooseVertexByOrder(s,r,c,u):this.chooseVertexFromCluster_(s,t),r.addVertex(e,i)}}}}return-1!==u&&r.removeUserIndex(u),-1!==c&&r.removeUserIndex(c),-1!==l&&r.removeUserIndex(l),this.m_topoGraph.deleteUserIndexForHalfEdges(g),(0,h.k)(m,p)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=(0,i.z)(s),a=(0,i.z)(n);if(r>a)return e;const h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,2===r&&2===a){let s=o.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===r&&2===a){const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}if(1===r&&1===a){const t={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,o.n,!1,t).first}if(0===r)return this.topoOperationMultiPoint_();(0,i.d)("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Is(s),a=Is(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);return(0,i.g)(h>=0),(0,i.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,this.m_maskLookup[h]=!0,this.m_maskLookup[m]=!0,2===r&&2===a?this.topoOperationPolygonPolygon_(e,t,o.n):1===r&&1===a?this.topoOperationPolyline_(o.n,this.m_bOGCOutput):0===r&&0===a?this.topoOperationMultiPoint():void(0,i.d)("")}planarSimplifyNoCrackingAndCluster(e,t,s,n){this.m_bOGCOutput=e,this.m_topoGraph=new K;const r=t.getFillRule(s),a=t.getGeometryType(s);if(1!==r||a===i.G.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const h=this.m_topoGraph.getGeometryID(s);if((0,i.g)(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=h+1,this.m_maskLookup[h]=!0,t.getGeometryType(s)===i.G.enumPolygon||1===r&&t.getGeometryType(s)!==i.G.enumMultiPoint){t.setFillRule(s,0);const i=this.topoOperationPolygonPolygon_(s,o.n,o.n);if(t.swapGeometry(i,s),t.removeGeometry(i),1===r&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,s,n)}else if(t.getGeometryType(s)===i.G.enumPolyline){const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=n;const r=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(r,s),t.removeGeometry(r)}else if(t.getGeometryType(s)===i.G.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,s),t.removeGeometry(e)}else(0,i.d)("");return!0}unsplitPolylineExact(e){return(0,i.g)(0),new o.a}planarSimplifyPolylines(e,t,s,n,r){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const s=e.getGeometryType(t);(0,i.g)(s===i.G.enumPolyline)}let a=0,h=0,m=null;if(e.hasCurves()&&!e.hasSegmentParentage()){m=new cs;const s=e.getEnvelope2D(this.m_progressTracker);h=ls(t.total());const n=ms(t.total(),s);a=gs(n,h),os(e,n,t.total(),0,m,null,this.m_progressTracker)}{const s=fs(t.add(a));e.filterClosePoints(s,!1,!1,!1,o.n)}if(this.m_topoGraph=new K,4!==r&&5!==r)if(null===m&&s){const n=new Ee(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(_s(e,t,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else _s(e,t.add(a),this.m_progressTracker,!0,!1),s=!1;else s=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const l=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(s&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,n,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(l);(0,i.g)(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const c=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),n);null!==m&&m.stitchCurves(e,c,h,!0);const u=e.getGeometry(c);return s||u.getImpl().setIsSimple(4,t.total()),u}planarSimplifyMultiPoints(e,t,s,n){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const s=e.getGeometryType(t);(0,i.g)(s===i.G.enumMultiPoint)}this.m_topoGraph=new K,4!==n&&5!==n?(_s(e,t,this.m_progressTracker,!0,!1),s=!1):s=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const r=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,r,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const a=this.m_topoGraph.getGeometryID(r);(0,i.g)(a>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=a+1,this.m_maskLookup[a]=!0;const h=this.topoOperationMultiPoint(),m=e.getGeometry(h);return s||m.getImpl().setIsSimple(4,t.total()),m}planarSimplifyPolygons(e,t,s,n,r,a){for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t)){const n=e.getGeometryType(t);(0,i.g)(n===i.G.enumPolygon||n===i.G.enumPolyline&&s)}let h=0,m=0,l=null;if(e.hasCurves()&&!e.hasSegmentParentage()){l=new cs;const s=e.getEnvelope2D(this.m_progressTracker);m=ls(t.total());const n=ms(t.total(),s);h=gs(n,m),os(e,n,t.total(),0,l,null,this.m_progressTracker)}if(a){_s(e,t.add(h),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==o.n;t=e.getNextGeometry(t))e.getGeometryType(t)===i.G.enumPolygon&&Fe(e,t,-1,!1,o.n,this.m_progressTracker)}if(this.m_topoGraph=new K,a||4===r||5===r)n=!1;else if(null===l&&n){const s=new Ee(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(_s(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else _s(e,t.add(h),this.m_progressTracker,!0,!1),n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,i.g)(n&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const c=this.m_topoGraph.getGeometryID(g);(0,i.g)(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0,e.setFillRule(g,0);const u=this.m_bOGCOutput&&s,_=u;let p=this.topoOperationPolygonPolygon_(g,o.n,o.n,_);u&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(g),this.m_topoGraph=new K,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,p,this.m_progressTracker),p=this.topoOperationPolygonPolygon_(p,o.n,o.n,!1)),null!==l&&l.stitchCurves(e,p,m,!0);const d=e.getGeometry(p);return d.setFillRule(0),n?d.getImpl().setIsSimple(3,0):(d.getImpl().setIsSimple(4,t.total()),d.getImpl().updateOGCFlagsProtected()),d}planarSimplify3DImpl_(e,t,s,n,r){return(0,i.g)(0),{}}planarSimplifyImpl_(e,t,s,n,r,h,m,l){if(e.isEmpty())return e.clone();const g=e.getGeometryType(),c=new o.E,u=c.addGeometry(e);if((0,a.Y)(r)&&g===i.G.enumPolygon&&(s=!1,c.setFillRule(u,0)),l&&(e.hasAttribute(1)&&c.replaceNaNs(1,0),c.removeNaNVertices()),g===i.G.enumPolygon||g===i.G.enumPolyline&&s)return this.planarSimplifyPolygons(c,t,s,n,r,!1);if(g===o.a.type){const e={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=m,this.planarSimplifyPolylines(c,t,n,e,r)}if(g===i.G.enumMultiPoint)return this.planarSimplifyMultiPoints(c,t,n,r);(0,i.d)("what else?")}}function Fs(e,t,s,n){const r=e.getGeometryType();if(r===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(r===i.G.enumPoint&&("|"===n||"^"===n)){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(r===i.G.enumLine){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(r===i.G.enumMultiPoint&&"-"===n&&t.getGeometryType()===i.G.enumPoint){const t=new a.P({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(r===i.G.enumMultiPoint&&"&"===n&&t.getGeometryType()===i.G.enumPoint){const t=new a.P({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function Hs(e){const t=e.getGeometryType();if(t===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.G.enumPoint){const t=new o.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(Cs(t)){const t=new o.a({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.G.enumMultiPoint&&t!==i.G.enumPolyline&&t!==i.G.enumPolygon&&(0,i.a)("Unexpected geometry type"),e}function As(e,t,s,n){const r=s===o.n?e.getClusterHalfEdge(t):s;let a=r;(0,i.g)(e.getHalfEdgeOrigin(r)===t);do{n(a),a=e.getHalfEdgeNext(e.getHalfEdgeTwin(a))}while(a!==r)}class Ms{constructor(e,t,s,n,r,i){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(r),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=r,this.m_rCutHandles=i,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){let t=0;const s=this.m_rShape.getPathSize(e);for(let n=this.m_rShape.getFirstVertex(e);t<s;t++,n=this.m_rShape.getNextVertex(n))this.m_rShape.setUserIndex(n,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(n)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return 8|e}classifyStandardCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),a=r===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),h=i===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),l=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));let g=1,c=32,u=32;if(As(this.m_rTopoGraph,t,l,e=>{e===m&&(g=2),e===a&&(c=g),e===h&&(u=g)}),this.m_bConsiderTouch)32!==c&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|c),32!==u&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u);else{if(32===c||32===u)return 1;if(c===u&&a!==m&&a!==l&&h!==m&&h!==l)return 1;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|c),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u)}return 0}classifyTouchCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),a=r===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),h=i===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=s===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),l=n===o.n?o.n:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let t;return(t=m===a||l===a)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=m===h||l===h)&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),t?0:1}if(a===o.n)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===o.n)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(l!==o.n){if(a===l)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===l)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=1;As(this.m_rTopoGraph,t,l,t=>{if(t===a){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=2}else if(t===h){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=2}})}else{if(a===m)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h===m)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=2;As(this.m_rTopoGraph,t,m,t=>{if(t===a){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=1}else if(t===h){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=1}})}return 0}classifyCutVertex(e,t){let s=0,n=0;for(let r=this.m_rTopoGraph.getClusterVertexIterator(t);r!==o.n;r=this.m_rTopoGraph.incrementVertexIterator(r)){const i=this.m_rTopoGraph.getVertexFromVertexIterator(r);if(this.m_rShape.getGeometryFromVertex(i)===this.m_cutter){n++;const r=this.m_rShape.getPrevVertex(i),a=this.m_rShape.getNextVertex(i);s+=r===o.n||a===o.n?this.classifyTouchCut(e,t,r,a):this.classifyStandardCut(e,t,r,a)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,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 e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){const t=this.m_rShape.getPathSize(e);let s=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,0);s=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,s=this.m_rShape.getNextVertex(s)){const e=this.m_rTopoGraph.getClusterFromVertex(s);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(s,e)}}const e=(e,t)=>{let s=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==o.n;t=this.m_rShape.getNextPath(t)){let s=this.m_rShape.getFirstVertex(t);const n=this.m_rShape.isClosedPath(t),r=this.m_rShape.getPathSize(t)+(n?1:0);let i=1,o=32;for(let t=this.m_rShape.getNextVertex(s);i<r;++i,s=t,t=this.m_rShape.getNextVertex(t)){const n=e(s,t);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=n),32!==o&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,o|n)}s=this.m_rShape.getLastVertex(t);let a=32;i=1;for(let t=this.m_rShape.getPrevVertex(s);i<r;++i,s=t,t=this.m_rShape.getPrevVertex(t)){const n=e(t,s);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=n),32!==a&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,a|n)}}let t=o.n,s=o.n,n=32;const r=this.m_rShape.hasSegmentParentage(),a=new o.S;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==o.n;e=this.m_rShape.getNextPath(e)){const h=this.m_rShape.isClosedPath(e),m=this.m_rShape.getPathSize(e)+(h?1:0);let l=1,g=this.m_rShape.getFirstVertex(e),c=o.n,u=!0;for(let e=this.m_rShape.getNextVertex(g);l<m;++l,e=this.m_rShape.getNextVertex(e)){let h=this.m_rShape.getUserIndex(g,this.m_cutteeBreadcrumbsIndex);8===h?h=3:(h&=-9,4&h?h=4:3&~h||(h=3)),h!==n?(t!==o.n&&(c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n)),t=this.m_rShape.createGeometry(i.G.enumPolyline),s=this.m_rShape.insertPath(t,o.n),n=h,u=!0):this.m_rShape.getUserIndex(g,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==h&&(c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),s=this.m_rShape.insertPath(t,o.n),u=!0),c=this.m_rShape.addVertex(s,g);const m=this.m_rTopoGraph.getClusterFromVertex(g);!u&&r&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(c,!0);const l=this.m_rTopoGraph.getHalfEdgeFromVertex(g);if(r){const e=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(c,e,u||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,a),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(c),a.get().clone())),g=e,u=!1}c=this.m_rShape.addVertex(s,g),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(g))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n),t=o.n,s=o.n,n=32}}}function Us(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=new r.Envelope2D;return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Us(i,t,s,n,h)}(0,i.B)(m),(0,i.i)(m)||(0,i.t)("OGC simplify is not implemented for this geometry type");const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if(5===c||0===c)return c;const u=new Qs(e,t,c,h,!0);return m===i.G.enumMultiPoint||m===i.G.enumPolyline||m===i.G.enumPolygon?(c=u.isSimplePlanarImpl(),(0,a.i)(c)&&(c=5)):(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}function qs(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=r.Envelope2D.constructEmpty();return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),qs(i,t,s,n,h)}const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if(-1!==c)return c;const u=new Qs(e,t,c,h,!1);return m===i.G.enumMultiPoint?c=u.multipointIsSimpleAsFeature():m===i.G.enumPolyline?c=u.polylineIsSimpleAsFeature():m===i.G.enumPolygon?c=u.polygonIsSimpleAsFeature():(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}function Os(e,t,s,n){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.G.enumPoint){const t=new _.NonSimpleResult;if(Bs(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.G.enumEnvelope){const s=(0,a.e)(t,e,!0).total(),n=e,i=r.Envelope2D.constructEmpty();return n.queryEnvelope(i),i.isDegenerate(s)?n.createInstance():e}if((0,i.f)(h)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Os(i,t,s,n)}(0,i.B)(h);const m=(0,a.e)(t,e,!1).total(),l=e.getImpl().getIsSimple(m,[0]),g=s?-1:l;if((0,a.i)(g)){if(h===i.G.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((h===i.G.enumMultiPoint||h===i.G.enumPolyline)&&g>=1)return e;const c=new Qs(e,t,g,n,!1);let u;return h===i.G.enumMultiPoint?u=c.multipointSimplifyAsFeature():h===i.G.enumPolyline?u=c.polylineSimplifyAsFeature():h===i.G.enumPolygon?u=c.polygonSimplifyAsFeature():(0,i.d)(""),u}function Ys(e,t,s,n){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.G.enumPoint){const t=new _.NonSimpleResult;if(Bs(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.G.enumEnvelope){const s=e,n=new r.Envelope2D;s.queryEnvelope(n);const i=(0,a.e)(t,e,!0).total();return n.isDegenerate(i)?s.createInstance():e}if((0,i.f)(h)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),Ys(i,t,s,n)}(0,i.B)(h),(0,i.i)(h)||(0,i.t)("OGC simplify is not implemented for this geometry type");const m=(0,a.e)(t,e,!1).total(),l=e.getImpl().getIsSimple(m,[0]),g=s?-1:l;if(5===g){if(h===i.G.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return bs(e,(0,a.e)(t,e,!0),!1,g,n,0,!0)}function Bs(e,t){const s=e.getX(),n=e.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){const s=e.getZ();if(!Number.isFinite(s))return t&&(t.m_reason=Number.isNaN(s)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class Rs{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(e){this.m_flags&=-2,this.m_flags=this.m_flags|(e?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function Xs(e,t,s,n,r){return{x:e,y:t,ipath:s,ivertex:n,ipolygon:r}}function Ls(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function zs(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function Ws(e,t,s,n,r,i){return{x:e,y:t,ipath:s,ivertex:n,bBoundary:r,bEndPoint:i}}function js(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.bBoundary=t.bBoundary,e.bEndPoint=t.bEndPoint}class Zs extends a.a6{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*n);return r<0?-1:r>0?1:0}}class Ks extends a.a6{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges[t],i=this.m_helper.m_edges[n],o=r.getReversed(),a=i.getReversed();let h=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const e=o?r.m_segment.getStartY():r.m_segment.getEndY(),t=a?i.m_segment.getStartY():i.m_segment.getEndY(),s=Math.min(e,t);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),h=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return h<m?-1:h>m?1:0}}class Qs{constructor(e,t,s,n,r){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new a.R,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new a.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 _.NonSimpleResult,this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=e,this.m_knownSimpleResult=s,this.m_sr=t;const i=(0,a.e)(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=(0,a.h)(i),this.m_toleranceIsSimpleCracking=(0,a.U)(i),this.m_toleranceSimplify=(0,a.e)(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=r,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 e=this.m_geometry.getGeometryType();return(0,i.h)(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?(0,i.h)(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.G.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return(0,i.g)(0),7}generateSortedPairs(e){let t=null;(0,i.h)(e.getGeometryType())&&(t=e);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==t,n=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new a.a(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let e=0;e<n;e++)if(this.m_pairs.push(2*e),this.m_pairs.push(2*e+1),this.m_pairIndices.add(2*e),this.m_pairIndices.add(2*e+1),s){for(;e>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const o=new a.B,m={parent:this,workPt:new h.P,userSort(e,t,n){n.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,s))},getValue(e){const t=this.parent.m_pairs[e],s=t>>1;return this.parent.m_xy.queryPoint2D(2*s,this.workPt),this.workPt.y+(1&t?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};o.sort(this.m_pairIndices,0,2*n,m)}_TestToleranceDistancePlanar(e,t){const s=this.m_xy.read(2*e),n=this.m_xy.read(2*e+1),r=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1);return!ne(s,n,r,i,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||0!==this.m_geometry.getDimension()&&s===r&&n===i}checkStructure(){const e=this.m_geometry.getGeometryType();if((0,i.h)(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.G.enumPolygon?3:2;for(let s=0,n=e.getPathCount();s<n;s++)if(e.getPathSize(s)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(s)&&e.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new _.NonSimpleResult(1,s,0),!1}}if((0,i.i)(e)){const e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let s=0,n=e.getPointCount();s<n;s++)if(!t.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new _.NonSimpleResult(2,s,0),!1;if(this.m_geometry.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(!Number.isFinite(e))return Number.isNaN(e)?this.m_nonSimpleResult=new _.NonSimpleResult(3,s,0):this.m_nonSimpleResult=new _.NonSimpleResult(2,s,0),!1}}}return!0}checkDegenerateSegments(e){const t=this.m_geometry.getImpl(),s=t.querySegmentIterator(),n=t.hasAttribute(1),r=n?(0,a.W)(this.m_sr,t,!1).total():0,i=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment();let a=t.calculateLowerLength2D();if(!(a>o||i&&t.isCurve()&&(a=t.calculateLength2D(),a>o))){if(e&&n){const e=t.getStartAttributeAsDbl(1,0),s=t.getEndAttributeAsDbl(1,0);if(Math.abs(s-e)>r)continue}return this.m_nonSimpleResult=new _.NonSimpleResult(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return(0,i.g)(0),!1}_CheckClustering(){const e=this.m_geometry.getImpl();this.generateSortedPairs(e);const t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new Zs(this)),this.m_AET.setCapacity(t);for(let e=0,s=2*t;e<s;e++){this.progress_();const t=this.m_pairIndices.read(e),s=this.m_pairs[t],n=s>>1;if(1&s){const e=this.m_AET.search(n),t=this.m_AET.getPrev(e),s=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==a.T.st_nullNode()&&s!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new _.NonSimpleResult(5,this.m_AET.getElement(t),this.m_AET.getElement(s)),!1}else{const e=this.m_AET.addElement(n),t=this.m_AET.getPrev(e);if(t!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),n))return this.m_nonSimpleResult=new _.NonSimpleResult(5,n,this.m_AET.getElement(t)),!1;const s=this.m_AET.getNext(e);if(s!==a.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new _.NonSimpleResult(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new o.E,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new cs;const e=r.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(e);const t=ms(this.m_toleranceSimplify.total(),e),s=new _.NonSimpleResult;if(function(e,t,s,n,r,i,o,a){e.hasCurves()?(e.setCurveStitcherPointer(i),i.m_impl=new us(a,!0,r),i.m_impl.buildMonotonicCurveParentage(e,t,s,null),ds(e,s,a)):i.m_impl=null}(this.m_editShape,t,this.m_toleranceSimplify.total(),0,s,this.m_curveStitcher,0,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!1}const e=new _.NonSimpleResult;return Ie(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(null!=this.m_curveStitcher?(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null):(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){s.resetTo(t);do{for(;s.hasNextSegment();){const n=s.nextSegment(),r=(0,o.Q)(!0,e,n,this.m_toleranceIsSimpleCracking,!0);if(r){const e=2===r?7:6;return this.m_nonSimpleResult=new _.NonSimpleResult(e,t.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const t=[],s=e.getPointCount();let n=Number.NaN,r=0;for(let e=0,i=2*s;e<i;e++){this.progress_();const s=this.m_pairIndices.read(e),i=this.m_pairs[s];if(1&i)continue;const o=i>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(t.length&&(a!==n||h!==r)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),n=a,r=h}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){const e=this.m_geometry.getImpl(),t=[];for(let s=0,n=e.getPathCount();s<n;s++)t.push(e.isClosedPathInXYPlane(s));const s={x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1};let n,r,i;{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];n=t[m],r=e.getPathStart(m),i=e.getPathEnd(m)-1,s.bEndPoint=a===r||a===i,this.m_bOGCRestrictions?s.bBoundary=!n&&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 m=h>>1,l=this.m_xy.readPoint2D(2*m),g=this.m_pathsForOGCTests[m];let c;g!==s.ipath&&(n=t[g],r=e.getPathStart(g),i=e.getPathEnd(g)-1);const u=m===r||m===i;c=this.m_bOGCRestrictions?!n&&u:u;const p=Ws(l.x,l.y,g,m,c,u);if(p.x===s.x&&p.y===s.y)if(this.m_bOGCRestrictions){if(!(p.bBoundary&&s.bBoundary||p.ipath===s.ipath&&p.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new _.NonSimpleResult(10,p.ivertex,s.ivertex),!1}else if(!p.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new _.NonSimpleResult(7,p.ivertex,s.ivertex),!1;js(s,p)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return(0,i.g)(0),!1}checkSelfIntersectionsPolygonsOGC(){const e=this.m_geometry.getImpl(),t=[];let s=-1,n=!1;for(let r=0,i=e.getPathCount();r<i;r++)e.isExteriorRingOGC(r)&&(n=!1,s++,r<i-1&&(e.isExteriorRingOGC(r+1)||(n=!0))),t.push(n?s:-1);const r={x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1};{const e=this.m_pairIndices.read(0),s=this.m_pairs[e]>>1,n=this.m_xy.readPoint2D(2*s),i=this.m_pathsForOGCTests[s];r.ipath=i,r.x=n.x,r.y=n.y,r.ivertex=s,r.ipolygon=t[i]}const i=[];for(let e=1,s=this.m_pairIndices.size();e<s;e++){const s=this.m_pairIndices.read(e),n=this.m_pairs[s];if(1&n)continue;const o=n>>1,a=this.m_xy.readPoint2D(2*o),h=this.m_pathsForOGCTests[o],m=Xs(a.x,a.y,h,o,t[h]);if(m.x===r.x&&m.y===r.y){if(m.ipath===r.ipath)return this.m_nonSimpleResult=new _.NonSimpleResult(11,m.ivertex,r.ivertex),!1;t[m.ipath]>=0&&t[m.ipath]===t[r.ipath]&&(0!==i.length&&Ls(i.at(-1),r)||i.push({...r}),i.push(m))}zs(r,m)}if(0===i.length)return!0;const o=new a.R(!0);t.fill(-1);let m=-1;const l=new h.P;for(let e=0,s=i.length;e<s;e++){const s=i[e];s.x===l.x&&s.y===l.y||(m=o.createList(0),l.x=s.x,l.y=s.y);let n=t[s.ipath];-1===n&&(n=o.createList(2),t[s.ipath]=n),o.addElement(n,m),o.addElement(m,n)}const g=[];for(let e=o.getFirstList();-1!==e;e=o.getNextList(e)){const s=o.getListData(e);if(1&s||!(2&s))continue;let n=-1;for(g.push(e),g.push(-1);g.length;){const e=g.at(-1);g.pop();const t=g.at(-1);g.pop();const s=o.getListData(t);if(1&s){n=2&s?t:e;break}o.setListData(t,1|s);for(let s=o.getFirst(t);-1!==s;s=o.getNext(s)){const n=o.getData(s);n!==e&&(g.push(n),g.push(t))}}if(-1!==n){const e=t.indexOf(n);return this.m_nonSimpleResult=new _.NonSimpleResult(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){const e=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new _.NonSimpleResult(8,1===e.getPathCount()?1:-1,-1),0;if(1===e.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new a.b(e.getPathCount(),0),this.m_pathParentage=new a.a(e.getPathCount(),-1);let t=-1,s=0;for(let n=0,r=e.getPathCount();n<r;n++){const r=e.calculateRingArea2D(n);if(this.m_pathOrientations.write(n,r<0?0:8),r>0)t=n,s=r;else{if(0===r)return this.m_nonSimpleResult=new _.NonSimpleResult(8,n,-1),0;if((t<0||s<Math.abs(r))&&(this.m_nonSimpleResult=new _.NonSimpleResult(9,n,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(n,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;const n=e.getPointCount();this.m_yScanline=Number.NaN;const r=[];this.m_xyToNode1=new a.a(n,a.T.st_nullNode()),this.m_xyToNode2=new a.a(n,a.T.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new Ks(this));for(let e=0,t=2*n;this.m_unknownOrientationPathCount>0&&e<t;e++){const t=this.m_pairIndices.read(e),s=this.m_pairs[t];if(1&s)continue;const n=s>>1,i=this.m_xy.read(2*n+1);if(i!==this.m_yScanline&&r.length){if(!this.processBunchForRingOrientationTest(r))return 0;r.length=0}r.push(n),this.m_yScanline=i}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(r)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(e){if(1===e.length)return!0;for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();-1===t&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let e=0,s=this.m_edges.length;e<s;e++)this.m_crossOverHelperList.addElement(t,e);let s=!0,n=-1,r=-1;for(;s;){s=!1;let e=this.m_crossOverHelperList.getFirst(t);if(-1===e)break;let i=this.m_crossOverHelperList.getNext(e);for(;-1!==i;){const o=this.m_crossOverHelperList.getData(e),a=this.m_crossOverHelperList.getData(i);if(n=this.m_edges[o].m_vertexIndex,r=this.m_edges[a].m_vertexIndex,n!==r)e=i,i=this.m_crossOverHelperList.getNext(e);else if(s=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(i),i=this.m_crossOverHelperList.deleteElement(t,i),-1===i||-1===e)break}}const i=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),i>0)return this.m_nonSimpleResult=new _.NonSimpleResult(7,n,r),!1;for(let t=0,s=e.length;t<s;t++)this.recycleEdge(this.m_edges[t]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,s=e.length;t<s;t++){const s=e[t];let n=this.m_xyToNode1.read(s);if(n!==a.T.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(s,a.T.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==a.T.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(s,a.T.st_nullNode())}}for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===a.T.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();if(r.getStartY()<r.getEndY()){const e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=t):(n=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(n);this.m_xyToNode1.read(e)===a.T.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}}for(let e=0,t=this.m_newEdges.length;e<t&&this.m_unknownOrientationPathCount>0;e++){const t=this.m_newEdges[e],s=this.m_AET.getElement(t),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let e=-1,s=this.m_AET.getPrev(t),n=t,r=0;{let t=-1,i=null,o=-1,h=0;for(;s!==a.T.st_nullNode()&&(t=this.m_AET.getElement(s),i=this.m_edges[t],o=i.m_pathIndex,h=this.m_pathOrientations.read(o),!(3&h));)n=s,s=this.m_AET.getPrev(s);s===a.T.st_nullNode()?(r=1,s=n):(e=1==(3&h)?o:this.m_pathParentage.read(o),r=i.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const t=this.m_AET.getElement(s),i=this.m_edges[t],o=i.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(r!==i.getRightSide())return this.m_nonSimpleResult=new _.NonSimpleResult(8,o,-1),!1;const t=r&&!i.getReversed()?1:2;if(a=-4&a|t,this.m_pathOrientations.write(o,a),2===t&&0===this.m_nonSimpleResult.m_reason){const t=this.m_pathParentage.read(o);if(t!==e&&(this.m_nonSimpleResult=new _.NonSimpleResult(9,o,t),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}e=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),r=r?0:1}while(n!==t)}}return this.m_newEdges.length=0,!0}createEdge(e,t,s,n){let r;return e.getGeometryType()===i.G.enumLine?r=this.createEdgeLine(e):(r=new Rs,r.m_segment=e.clone()),r.m_vertexIndex=t,r.m_pathIndex=s,r.m_flags=0,r.setReversed(n),r}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new Rs,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.G.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,s,n){let r=e.calculateLowerLength2D();if(r<=s){let i=!0;if(e.isCurve()&&(r=e.calculateLength2D(),i=r<=s),i){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let s=e.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-t)<=n}return!0}return!1}return!1}static isShortSegmentPoints(e,t,s,n,r){if(s){const s=e.getXYZ(),i=t.getXYZ();return(0,a.X)(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return h.P.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),o=e.querySegmentIterator();o.resetToPath(t),(0,i.g)(o.nextPath());const m=this.m_toleranceSimplify.total();let l=!1,g=!0;const c=new a.P,u=new a.P,_=new h.P;for(;o.hasNextSegment();){this.progress_();const e=o.nextSegment();if(Qs.isShortSegment(e,r,m,s))if(l){if(e.queryEnd(u),Qs.isShortSegmentPoints(c,u,r,m,s))continue;g&&(n.startPathPoint(c),g=!1),e.queryEnd(c),n.lineToPoint(c),l=!1}else _.assign(e.getStartXY()),e.queryStart(c),l=!0;else if(l)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(_,e.getEndXY(),!1),t.setStart(c),Qs.isShortSegment(t,r,m,s))continue;n.addSegment(t,g),g=!1,l=!1}else{if(e.queryEnd(u),Qs.isShortSegmentPoints(c,u,r,m,s))continue;g&&(n.startPathPoint(c),g=!1),n.lineToPoint(u),l=!1}else n.addSegment(e,g),g=!1}if(g)return;if(!l)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),c):e.getPointByVal(e.getPathEnd(t)-1,c);const p=n.querySegmentIterator();p.resetToLastPath(),p.resetToLastSegment();const d=n.getDescription().getAttributeCount()>1;for((0,i.g)(p.previousPath());p.hasPreviousSegment();){const e=p.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),c.getXY(),!1),!Qs.isShortSegment(t,r,m,s)){d&&t.setEnd(c);const e=p.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.addSegment(t,!1)}}else if(e.queryStart(u),!Qs.isShortSegmentPoints(u,c,r,m,s)){const e=p.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(c)}}n.removePath(n.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;const t=e.getPointCount(),s=(0,h.d)(t,0);for(let e=0;e<t;e++)s[e]=e;s.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let e=1;e<t;e++)if(0===this.compareVerticesMultiPoint(s[e-1],s[e]))return this.m_nonSimpleResult=new _.NonSimpleResult(5,s[e-1],s[e]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl();const t=Qs.hasNanZs(e);let s,n=this.m_geometry;t&&(s=this.m_geometry.clone(),e=s.getImpl(),s.replaceNaNs(1,a.V.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=(0,h.d)(r,0);for(let e=0;e<r;e++)i[e]=e;i.sort((e,t)=>this.compareVerticesMultiPoint(e,t));const o=new Array(r);o.fill(!1);let m=-1;for(let t=0;t<r;t++){const s=i[t];e.getXY(s).isFinite()&&((m<0||0!==this.compareVerticesMultiPoint(m,s))&&(o[s]=!0),m=s)}const l=this.m_geometry.createInstance();let g=0,c=0;for(let e=0;e<r;e++)o[e]?c=e+1:(g<c&&l.addPoints(n,g,c),g=e+1);return g<c&&l.addPoints(n,g,c),l.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),l}polylineSimplifyAsFeature(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator(),n=this.m_geometry.createInstance(),r=this.m_geometry,i=e.hasAttribute(1),o=i?(0,a.W)(this.m_sr,e,!0).total():0,m=[],l=[];let g=null;i&&(g=e.getAttributeStreamRef(1));const c=new a.P,u=e.hasNonLinearSegments(),_=this.m_toleranceSimplify.total();for(;t.nextPath();){if(s.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(u&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,n);continue}s.resetToLastSegment();let a=0,p=0,d=!0,f=!0;for(;t.hasNextSegment();){this.progress_();const n=t.nextSegment(),r=s.previousSegment();if(t.getStartPointIndex()>s.getStartPointIndex())break;if(d){const s=t.getStartPointIndex();e.getXY(s).isNAN()||(d=!1,m.push(s))}if(f){const t=s.getEndPointIndex();e.getXY(t).isNAN()||(l.push(t),f=!1)}if(!d){const s=m.at(-1),r=t.getEndPointIndex();if(r-s>1){const t=new h.P;t.setSub(e.getXY(s),e.getXY(r)),a=t.length()}else a=n.calculateLength2D();if(a>_)m.push(r),a=0;else if(i){let e=g.read(s);Number.isNaN(e)&&(e=0);let t=g.read(r);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(m.push(r),a=0)}}if(!f){const t=l.at(-1),n=s.getStartPointIndex();if(n-t>1){const s=new h.P;s.setSub(e.getXY(t),e.getXY(n)),p=s.length()}else p=r.calculateLength2D();if(p>_)l.push(n),p=0;else if(i){let e=g.read(t);Number.isNaN(e)&&(e=0);let s=g.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-e)>o&&(l.push(n),p=0)}}}if(m.length>0&&l.length>0&&(m.at(-1)<l.at(-1)?m.length>l.length?m.pop():l.pop():(m.at(-1)===l.at(-1)||l.pop(),l.pop())),l.length+m.length>=2){let e=!1;for(let t=0,s=m.length;t<s;t++)r.getPointByVal(m[t],c),e?n.lineToPoint(c):(n.startPathPoint(c),e=!0);for(let t=l.length-1;t>0;t--)r.getPointByVal(l[t],c),e?n.lineToPoint(c):(n.startPathPoint(c),e=!0);r.isClosedPath(t.getPathIndex())?n.closePathWithLine():l.length>0&&(r.getPointByVal(l[0],c),n.lineToPoint(c))}m.length=0,l.length=0}return i&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,_),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!(0,a.Y)(this.m_knownSimpleResult))return Gs(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new o.E;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),0!==e.getTotalPointCount()){let t=null,s=0,n=0;if(e.hasCurves()){t=new cs;const i=r.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(i);const o=ms(this.m_toleranceSimplify.total(),i);s=ls(this.m_toleranceSimplify.total()),n=gs(o,s),os(e,o,this.m_toleranceSimplify.total(),0,t,null,this.m_progressTracker)}(0,a.Y)(this.m_knownSimpleResult)||_s(e,this.m_toleranceSimplify.add(n),this.m_progressTracker,!0,!1),this.m_geometry.getGeometryType()===i.G.enumPolygon&&Fe(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==t&&t.stitchCurves(e,e.getFirstGeometry(),s,!0)}const t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===i.G.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,s){if(e===t)return 0;const n=this.m_pairs[e],r=this.m_pairs[t],i=n>>1,o=r>>1,a=this.m_xy.readPoint2D(2*i);a.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=this.m_xy.readPoint2D(2*o);m.y+=1&r?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const l=a.compare(m);if(0===l&&s){const e=this.m_pathsForOGCTests[i]-this.m_pathsForOGCTests[o];return(0,h.e)(e)}return l}compareVerticesMultiPoint(e,t){if(e===t)return 0;const s=this.m_multiVertexGeom.getXY(e),n=this.m_multiVertexGeom.getXY(t),r=!s.isFinite(),i=!n.isFinite();if(r||i)return r<i?-1:r>i?1:0;if(s.y<n.y)return-1;if(s.y>n.y)return 1;if(s.x<n.x)return-1;if(s.x>n.x)return 1;for(let s=1;s<this.m_attributeCount;s++){const n=this.m_description.getSemantics(s),r=a.V.getComponentCount(n);for(let s=0;s<r;s++){const r=this.m_multiVertexGeom.getAttributeAsDbl(n,e,s),i=this.m_multiVertexGeom.getAttributeAsDbl(n,t,s),o=(0,h.r)(r,i);if(0!==o)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;const s=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&s.negateThis();const n=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&n.negateThis();const r=s.getQuarter(),i=n.getQuarter();if(i===r){const e=s.crossProduct(n);return e<0?1:e>0?-1:0}return r<i?-1:1}}class Js{getOperatorType(){return 10103}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,s,n,r){const i=qs(e,t,s,n,r);return(0,a.Q)(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,h){const m=function(e,t,s,n,h){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.G.enumPoint)return Bs(e,n);const l=(0,a.e)(t,e,!1).total();if(m===i.G.enumEnvelope){const t=e,s=new r.Envelope2D;return t.queryEnvelope(s),s.isDegenerate(l)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if((0,i.f)(m)){const r=e,i=new o.a({vd:r.getDescription()});return i.addSegment(r,!0),qs(i,t,s,n,h)}const g=e.getImpl().getIsSimple(l,[0]);let c=s?-1:g;if((0,a.i)(c)||0===c)return c;const u=new Qs(e,t,c,h,!1);return m===i.G.enumMultiPoint||m===i.G.enumPolyline||m===i.G.enumPolygon?c=u.isSimplePlanarImpl():(0,i.d)(""),e.getImpl().setIsSimple(c,l),n&&n.assign(u.m_nonSimpleResult),c}(e,t,s,n,h);return(0,a.i)(m)}executeMany(e,t,s,n){return new $s(e,t,s,n)}execute(e,t,s,n){const r=new u.S([e]),o=this.executeMany(r,t,s,n).next();return o||(0,i.d)("null geometry"),o}}class $s extends c.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||(0,i.a)(""),e.getGeometryType()===i.G.enumGeometryCollection){const t=(0,o.g)(e,-1),s=(new Js).executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=e.createInstance();for(let e=s.next();null!=e;e=s.next())n.addGeometry(e);return n}return Os(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}class en{constructor(e,t,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=e,this.m_sr=t,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const s=(0,a.g)(this.m_intersectorGeom,e),n=(0,a.c)(this.m_sr,s,!0).total(),m=r.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const g=r.Envelope2D.constructEmpty();e.queryEnvelope(g),m.inflateCoords(2*n,2*n),m.intersect(g),m.inflateCoords(100*n,100*n);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),u=(0,l.c)(e,m,0,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,h.c)(u,u=c)),function(e,t,s,n){const h=r.Envelope2D.constructEmpty();e.queryEnvelope(h);const m=r.Envelope2D.constructEmpty();t.queryEnvelope(m);const l=r.Envelope2D.constructEmpty();l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=new r.Envelope2D(m),u=(0,a.h)(g);if(c.inflateCoords(u,u),!h.isIntersecting(c)){if(e.getDimension()<=t.getDimension())return Fs(Hs(e.createInstance()),e,0,"&");if(e.getDimension()>t.getDimension())return Fs(Hs(t.createInstance()),e,0,"&")}const _=new ks(n),p=new o.E,d=p.addGeometry(Hs(e)),f=p.addGeometry(Hs(t));let x=0,P=0,E=null;if(p.hasCurves()){E=new cs;const e=p.getEnvelope2D(n);P=ls(g.total());const t=ms(g.total(),e);x=gs(t,P),os(p,t,g.total(),0,E,null,n)}_.setEditShapeCrackAndCluster(p,g.add(x));const y=_.intersection(d,f);null!==E&&E.stitchCurves(p,y,P,!0);const S=Fs(p.getGeometry(y),e,0,"&");return Ss(S.getGeometryType())&&(S.getImpl().setIsSimple(4,g.total()),S.getGeometryType()===i.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}(u,c,this.m_sr,this.m_progressTracker)}intersectEx(e){const t=this.tryFastImplementation(e);if(null!==t){const s=[];return s.length=3,s[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,s)}const s=(0,a.g)(this.m_intersectorGeom,e),n=(0,a.c)(this.m_sr,s,!0).total(),m=r.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const g=r.Envelope2D.constructEmpty();e.queryEnvelope(g),m.inflateCoords(2*n,2*n),m.intersect(g),m.inflateCoords(100*n,100*n);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),u=(0,l.c)(e,m,0,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,h.c)(u,u=c));const _=function(e,t,s,n){const h=new Array(3),m=r.Envelope2D.constructEmpty();e.queryEnvelope(m);const l=r.Envelope2D.constructEmpty();t.queryEnvelope(l);const g=r.Envelope2D.constructEmpty();g.setCoords({env2D:m}),g.mergeEnvelope2D(l);const c=(0,a.c)(s,g,!0),u=new r.Envelope2D(l),_=(0,a.h)(c);if(u.inflateCoords(_,_),!m.isIntersecting(u)){if(e.getDimension()<=t.getDimension()){const t=Fs(Hs(e.createInstance()),e,0,"&");return h[t.getDimension()]=t,h}if(e.getDimension()>t.getDimension()){const s=Fs(Hs(t.createInstance()),e,0,"&");return h[s.getDimension()]=s,h}}const p=new ks(n),d=new o.E,f=d.addGeometry(Hs(e)),x=d.addGeometry(Hs(t));let P=0,E=0,y=null;if(d.hasCurves()){y=new cs;const e=d.getEnvelope2D(n);E=ls(c.total());const t=ms(c.total(),e);P=gs(t,E),os(d,t,c.total(),0,y,null,n)}p.setEditShapeCrackAndCluster(d,c.add(P)),d.dbgVerifyCurves();const S=p.intersectionEx(f,x);for(const t of S){null!==y&&y.stitchCurves(d,t,E,!1);const s=Fs(d.getGeometry(t),e,0,"&");Ss(s.getGeometryType())&&(s.getImpl().setIsSimple(4,c.total()),s.getGeometryType()===i.G.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),h[s.getDimension()]=s}return null!==y&&y.clearStitcher(d),h}(u,c,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,_)}init(e,t,s,n=null){(0,i.g)(0)}static intersectPoints(e,t,s){const n=(0,a.g)(e,t);return function(e,t,s){return e.isEmpty()||t.isEmpty()?e.createInstance():function(e,t,s){const n=(0,a.h)(e);return ne(t.getX(),t.getY(),s.getX(),s.getY(),(0,h.a)(n))}(s,e,t)?new a.P({copy:ps(e,t)}):e.createInstance()}(e,t,(0,a.c)(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===i.G.enumPoint&&t===i.G.enumPoint){const t=en.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new o.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.G.enumEnvelope&&this.m_intersectorGeomType===i.G.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new a.E({copy:t});return n.intersect(s),n}const s=(0,a.g)(e,this.m_intersectorGeom),n=(0,a.c)(this.m_sr,s,!0),h=e.isEmpty(),m=this.m_intersectorGeom.isEmpty();let g=h||m;if(!g){const t=function(e,t,s){const n=new r.Envelope2D;e.queryEnvelope(n);const o=new r.Envelope2D;t.queryEnvelope(o);const a=new r.Envelope2D(o);if(a.inflate(2*s),!a.isIntersecting(n))return 4;const h=e.getGeometryType(),m=t.getGeometryType();if(h===i.G.enumEnvelope&&n.containsEnvelope(a))return 1;if(m===i.G.enumEnvelope){const e=new r.Envelope2D(n);if(e.inflate(2*s),o.containsEnvelope(e))return 2}return 0}(this.m_intersectorGeom,e,n.total());if(4===t)g=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(g){const s=(0,i.z)(t),n=(0,i.z)(this.m_intersectorGeomType);return s<n?en.ReturnEmpty(e,h):s>n||0===s&&t===i.G.enumMultiPoint&&this.m_intersectorGeomType===i.G.enumPoint?this.ReturnEmptyIntersector():en.ReturnEmpty(e,h)}if(t===i.G.enumEnvelope&&0===(0,i.z)(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.G.enumEnvelope&&0===(0,i.z)(t)){const s=t===i.G.enumEnvelope?e:this.m_intersectorGeom,o=t===i.G.enumEnvelope?this.m_intersectorGeom:e,a=r.Envelope2D.constructEmpty();return s.queryEnvelope(a),(0,l.c)(o,a,n.total(),0,this.m_progressTracker)}if(0===(0,i.z)(t)&&(0,i.z)(this.m_intersectorGeomType)>0||(0,i.z)(t)>0&&0===(0,i.z)(this.m_intersectorGeomType)){if(t===i.G.enumMultiPoint)return ws(e,this.m_intersectorGeom,n);if(t===i.G.enumPoint)return Ts(e,this.m_intersectorGeom,n);if(this.m_intersectorGeomType===i.G.enumMultiPoint)return ws(this.m_intersectorGeom,e,n);if(this.m_intersectorGeomType===i.G.enumPoint)return Ts(this.m_intersectorGeom,e,n);(0,i.d)("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,s){let n=0;return 1&t?(s[0]||(s[0]=new o.M({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new o.a({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new o.P({vd:e})):s.splice(n,1),new u.S(s)}}class tn extends c.G{constructor(e,t,s,n,r){super(),this.m_smallCursor=null,this.m_progressTracker=n,this.m_geomIntersector=t.next(),this.m_intersector=new en(this.m_geomIntersector,s,r,n),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=r,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&(0,i.a)("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let e;if(null!==this.m_smallCursor){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();)return(0,i.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask?this.m_intersector.intersect(e):(this.m_smallCursor=this.m_intersector.intersectEx(e),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class sn{getOperatorType(){return 1e4}accelerateGeometry(e,t,s){if(!this.canAccelerateGeometry(e))return!1;(0,a.e)(t,e,!0);let n=0;return e.getGeometryType()!==i.G.enumPolygon&&e.getGeometryType()!==i.G.enumPolyline||!(0,o.I)(e)||0===s||(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),!!n}canAccelerateGeometry(e){return(0,o.I)(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new tn(e,t,s,n,r)}execute(e,t,s,n){if(e.getGeometryType()===i.G.enumPoint&&t.getGeometryType()===i.G.enumPoint)return en.intersectPoints(e,t,s);const r=new u.S([e]),o=new u.S([t]),a=this.executeMany(r,o,s,n,-1).next();return a||(0,i.d)("null output"),a}}function nn(e,t,s){return t.m_projector.project(e,s)}function rn(e,t,s,n,r){return e.m_projector.transformInPlaceZ(t,null,s,n,null,r)}function on(e,t,s,n){if(e&&t&&t.isPannable()||(0,i.a)("fold_into_360_range_geodetic"),e.isEmpty())return e;if(4===s)return an(e,t,n);let h=e;const m=h.getGeometryType();if((0,i.h)(m)){h=Gr(e,t);const n=new r.Envelope2D;h.queryEnvelope(n);const i=(0,a.c)(t,n,!1).total(),o=t.getPannableExtent();let m=Math.floor((n.xmin-o.xmin)/o.width())*o.width()+o.xmin,l=h;for(;m<n.xmax;)m>n.xmin+i&&m<n.xmax-i&&(l=vr(l,t,s,!0,m)),m+=o.width();h=l}else{if(m===i.G.enumEnvelope){const e=new o.P({vd:h.getDescription()});return e.addEnvelope(h,!1),on(e,t,s,n)}if((0,i.f)(m)){const e=new o.a({vd:h.getDescription()});return e.addSegment(h,!0),on(e,t,s,n)}}return an(h,t,n)}function an(e,t,s){if(e&&t&&t.isPannable()||(0,i.a)(""),e.isEmpty())return e;let n;const r=e.getGeometryType();if(r===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});t.addEnvelope(e,!1),n=t}else if((0,i.f)(r)){const t=new o.a({vd:e.getDescription()});t.addSegment(e,!0),n=t}else n=e;const a=Gr(n,t);return a.isEmpty()?a:Er(a,t,0,a!==e,0,s)}function hn(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let m=new h.E,g=new h.E;i&&(m=t.getZGridRange()),o&&(g=t.getMGridRange());let c=(new l.O).execute(e,r,s,n);if(i){const t=c.queryInterval(1,0);m.contains(t)||(e===c&&(c=c.clone()),(0,a.a5)(c,m,1,0))}if(o){const t=c.queryInterval(2,0);g.contains(t)||(e===c&&(c=c.clone()),(0,a.a5)(c,g,2,0))}return c}class mn{constructor(e){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,e||(0,i.a)(""),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;const t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.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(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const s=e.getGeometryType();if(s===i.G.enumPoint)return this.projectPoint(e,t);const n=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),a=this.m_projTransform.getOutputSR();if(0===n&&n===r){const t=gn(o,a),s=e.clone();return s.applyTransformation(t),s}switch(s){case i.G.enumPolyline:case i.G.enumPolygon:return this.projectMultiPath(e,t);case i.G.enumMultiPoint:return this.projectMultiPoint(e,t);case i.G.enumEnvelope:return this.projectEnvelope(e,t);case i.G.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:(0,i.d)("")}}projectPoint(e,t){const s=[e.getXY()];let n,r=null;(n=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(s,r,1,s,r,null);const i=e.clone();return i.setXY(s[0]),n&&i.setZ(r[0]),i}projectMultiPoint(e,t){let s=new o.M({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),h=r.getCoordinateSystemType();if(3===a&&(0,i.g)(0),s=kr(s,n,this.m_inputPCSHorizonClipOption,t),s.isEmpty())return s;2===a&&Or(n,0,s),zr(this.m_projTransform,s,!1);let m=0;3===h&&(0,i.g)(0);const l=2===h;return l?m=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(m=this.m_centralMeridianOfOutputGCS),l&&0!==this.m_outputPCSHorizonClipOption||(s=Er(s,ji(r),m,!1,0,t)),l&&(s=dr(s,r,this.m_outputPCSHorizonClipOption,t),Mr(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const s=e.getGeometryType();return s===i.G.enumPolygon?this.projectPolygon(e,t):s===i.G.enumPolyline?this.projectPolyline(e,t):void(0,i.d)("project_multi_path_")}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&e.hasAttribute(1);let n=h.E.constructEmpty();if(s&&(n=e.queryInterval(1,0)),n.width()>0){const s=e.clone();s.setInterval(1,0,n.vmin,n.vmin);const r=this.projectEnvelopeHelper(s,t);s.setInterval(1,0,n.vmax,n.vmax);const i=this.projectEnvelopeHelper(s,t);return r.merge(i),r}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){(0,i.g)(e.getGeometryType()===i.G.enumPolygon),(0,i.g)(!this.m_projTransform.isIdentity()),(0,i.g)(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),a=s.getCoordinateSystemType(),h=n.getCoordinateSystemType(),m=new o.P({copy:e});3===a&&(0,i.g)(0),3===h&&(0,i.g)(0);const c=2===a,u=2===h,_=c?s.getGCS():s,p=u?n.getGCS():n,d=!u&&!this.m_bDontHackPolesInGeogToGeog;let f=!1,x=kr(m,s,this.m_inputPCSHorizonClipOption,t);if(x.isEmpty())return x;let P=this.m_densificationStepInput;const E=!Number.isNaN(P);let y;E&&(x=(new g.O).execute(x,P,0,0,t));let S=u?n.getPCSInfo():null,C=Number.NaN;c&&(C=s.getCentralMeridian());const I=null!==n.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=x;if(c&&(Rr(s,C,e),E)){const e=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,e,d),E){const e=s.getGCS().getUnitsPerMillimeter();P*=n.getGCS().getUnitsPerMillimeter()/e}y=e}else{let e=new o.a({vd:x.getDescription()});if(e.addAndExplicitlyOpenAllPaths(x,!1),c){if(Rr(s,C,e),E){const e=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),i=n.getSouthPoleGeometry()===vo.PE_POLE_LINE_CURVED,o=n.getNorthPoleGeometry()===vo.PE_POLE_LINE_CURVED;if(i||o){const s=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*_.getOneDegreeGCSUnit();i&&(s.ymin=-n),o&&(s.ymax=n),e=(0,l.a)(e,s,_,0,0,t)}}}if(jr(this.m_projTransform,e,d),E){const e=ji(s).getUnitsPerMillimeter();P*=ji(n).getUnitsPerMillimeter()/e}let i=Number.NaN;u?(S=n.getPCSInfo(),i=n.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=ln(s)|ln(n),h=10*p.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(a=3,h=10*p.getTolerance(0)),y=function(e,t,s,n,r,i,o,a,h){return new zn(e,null,s,t,n,r,o,a,i).geoNormalizePolygonGeometry(h)}(x,s,e,p,i,t,a,h,this.m_bNormalizeOutputGeometry),a=0}if(I&&((0,i.g)(!n.isPannable()),y=ur(y,n,t)),u){if(!f){const e=p.getPannableExtent().width();if(y.queryInterval(0,0).width()>=e-10*p.getTolerance(0)){const e=S.getNorthPoleLocation(),t=S.getSouthPoleLocation(),s=S.getNorthPoleGeometry(),n=S.getSouthPoleGeometry();let r=0;s===vo.PE_POLE_POINT&&e!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(r=1),n===vo.PE_POLE_POINT&&t!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(r|=2),f||=0!==r}}y=dr(y,n,this.m_outputPCSHorizonClipOption,t),E&&(y=(new g.O).execute(y,P,0,0,t)),qr(n,y,this.m_bNormalizeOutputGeometry)}return y.isEmpty()||f&&(y=(new Js).execute(y,n,!1,t)),y}projectPolyline(e,t){(0,i.g)(e.getGeometryType()===i.G.enumPolyline),(0,i.g)(!this.m_projTransform.isIdentity()),(0,i.g)(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),r=s.getCoordinateSystemType(),a=n.getCoordinateSystemType(),h=new o.a({copy:e});3===r&&(0,i.g)(0),3===a&&(0,i.g)(0);const m=2===r,l=2===a;m&&s.getGCS();const c=l?n.getGCS():n,u=!l&&!this.m_bDontHackPolesInGeogToGeog;let _=kr(h,s,this.m_inputPCSHorizonClipOption,t);if(_.isEmpty())return _;let p=Number.NaN;m&&(p=s.getCentralMeridian());const d=null!==n.getGCSSplitLines();let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let P;if(x&&(_=(new g.O).execute(_,f,0,0,t)),this.m_bDontGeonormalizePolygon){if(m&&(Rr(s,p,_),x)){const e=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,_,u),x){const e=s.getGCS().getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}P=_}else{const e=new o.a({vd:_.getDescription()});if(e.addAndExplicitlyOpenAllPaths(_,!1),m&&(Rr(s,p,e),x)){const e=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/e}if(jr(this.m_projTransform,e,u),x){const e=s.getGCS().getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}let r=Number.NaN;l?r=n.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=ln(s)|ln(n),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,a=0),P=function(e,t,s,n,r,i,o,a,h){return new zn(e,null,s,t,n,r,o,a,i).geoNormalizePolylineGeometry(h)}(_,s,e,c,r,t,i,a,this.m_bNormalizeOutputGeometry),i=0}return d&&((0,i.g)(!n.isPannable()),P=ur(P,n,t)),l&&(P=dr(P,n,this.m_outputPCSHorizonClipOption,t),x&&(P=(new g.O).execute(P,f,0,0,t)),qr(n,P,this.m_bNormalizeOutputGeometry)),P.isEmpty(),P}projectGeometryCollection(e,t){return(0,i.g)(0),{}}projectEnvelopeHelper(e,t){const s=(e.height()+e.width())/400;if(0!==s){const n=(new g.O).execute(e,s,0,0,t),i=this.projectMultiPath(n,t),h=new a.E({vd:e.getDescription()});if(i.isEmpty()){const s=Math.min(e.height(),e.width()),i=(0,a.e)(this.m_projTransform.getInputSR(),e,!0).total();if(s>100*i){const e=r.Envelope2D.constructEmpty(),t=(0,a.c)(this.m_projTransform.getOutputSR(),e,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(i,t*n))return h}const m=new o.a;m.addAndExplicitlyOpenAllPaths(n,!1),this.projectMultiPath(m,t).queryEnvelope(h);const l=new o.M({vd:e.getDescription()});l.reserve(4);const g=new a.P;for(let t=0;t<4;t++)e.queryCornerByVal(t,g),l.add(g);const c=this.projectMultiPoint(l,t),u=new a.E;return c.queryEnvelope(u),h.merge(u),h}return i.queryEnvelope(h),h}{const s=e.getCenterXY(),n=new a.P(s),r=this.projectPoint(n,t),i=new a.E({vd:e.getDescription()});if(r.isEmpty())i.setEmpty();else{e.copyTo(i);const t=r.getXY();i.setCoords(t.x,t.y,t.x,t.y)}return i}}transformInPlace(e,t,s,n){return(0,i.g)(0),0}transformInPlaceZ(e,t,s,n,r,o){if(this.m_projTransform.isIdentity())return e!==n&&(0,h.aw)(n,e,s),t!==r&&(0,h.b)(r,t,0,0,s),s;const a=this.m_projTransform,m=a.getInputSR(),l=a.getOutputSR(),g=m.getCoordinateSystemType(),c=l.getCoordinateSystemType();if(0===g&&g===c)return gn(m,l).transformPoints2D(e,s,n),a.isVertical()&&(0,i.g)(0),s;3===g&&(0,i.t)("image: transform_in_place_"),3===c&&(0,i.t)("image: transform_in_place_"),function(e,t,s,n,r){const o=n.getCoordinateSystemType();if(2===o){if(0===r)s!==e&&(0,h.aw)(s,e,t),function(e,t,s){const n=e.getPCSHorizon();if(n.getGeometryType()===i.G.enumPolygon){const r=e.getDefaultPrecisionSR().getTolerance(0),i=n;for(let e=0;e<s;e++)1!==es(i,t[e],r)&&t[e].setNAN();return}if(n.getGeometryType()===i.G.enumEnvelope){const e=n;for(let n=0;n<s;n++)e.contains(t[n])||t[n].setNAN();return}(0,i.a)("")}(n,s,t);else if(s!==e&&(0,h.aw)(s,e,t),n.isPannable()){const e=n.getTolerance(0);(function(e,t,s,n){for(let r=0;r<t;r++){if(e[r].y<s.ymin||e[r].y>s.ymax){e[r].setNAN();continue}const t=e[r].x;e[r].x=Cr(t,s,n)}})(s,t,n.getPannableExtent(),e),yr(s,t,n,0)}}else{(0,i.g)(1===o);const r=n.getTolerance(0),a=n.getPannableExtent();for(let n=0;n<t;n++)s[n].assign(Vr(e[n],a,r))}}(e,s,n,m,this.m_inputPCSHorizonClipOption),r!==t&&(0,h.b)(r,t,0,0,s),2===g&&Xr(m,0,n,s),Jr(this.m_projTransform,n,r,s,!1);let u=0;const _=2===c;_?u=l.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(u=this.m_centralMeridianOfOutputGCS),_&&0!==this.m_outputPCSHorizonClipOption||yr(n,s,l.getGCS(),u),_&&(Pr(n,s,l,this.m_outputPCSHorizonClipOption),Hr(l,n,s,!1));let p=s;for(let e=0;e<s;++e)n[e].isNAN()&&(r&&(r[e]=Number.NaN),p--);return p}}function ln(e){if(2!==e.getCoordinateSystemType())return 0;let t=0;const s=e.getPCSInfo(),n=s.getNorthPoleLocation(),r=s.getSouthPoleLocation(),i=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return i===vo.PE_POLE_POINT&&n!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===vo.PE_POLE_POINT&&r!==vo.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function gn(e,t){const s=e.getHorzUnitFactor(),n=t.getHorzUnitFactor();let r=1,i=1;const o=20015077/180;1===e.getUnit().getUnitType()&&(r=o),1===t.getUnit().getUnitType()&&(i=o);const a=s/n*(r!==i?r/i:1),h=new m.T;return h.setScaleCoords(a,a),h}class cn{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s){return!t||t.isIdentity()?e:new un(e,t,s)}execute(e,t,s){return t.isIdentity()?e:nn(e,t,s)}transform(e,t,s,n,r=!0){return r?function(e,t,s,n){e.m_projector.transformInPlaceZ(t,null,s,n,null,null);const r=n.slice(0,s).filter(e=>!e.isNAN());for(let e=0,t=r.length;e<t;++e)n[e].assign(r[e]);return r.length}(e,t,s,n):rn(e,t,s,n,null)}transform3D(e,t,s,n,r=!0){return(0,i.g)(0),0}foldInto360Range(e,t){return an(e,t,null)}foldInto360RangeGeodetic(e,t,s){return on(e,t,s,null)}normalizeGeometryEx(e,t,s,n,r=0){return function(e,t,s,n,r){if(!t.isPannable()||e.isEmpty())return e;const l=e.getGeometryType();l===i.G.enumGeometryCollection&&(0,i.t)("not yet impl for geometry collection");const g=t.getPannableExtent();Number.isNaN(s)&&(s=g.getCenterX());const c=g.width(),u=.5*c,_=r>0,p=e.queryInterval(0,0);if(!_&&p.width()<u||!(0,i.i)(e.getGeometryType())){const t=p.getCenter();if(Math.abs(t-s)<=u)return e;{const n=new m.T,r=(0,h.ax)((s-t)/c)*c;n.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(n),i}}if(l===i.G.enumPolygon){let i=new o.a({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),_&&(i=_n(i,t,2,r,Number.NaN,null,!0));const m=[];if(!n){{let s=e;_&&(s=new o.P,s.add(i,!1));const n=function(e,t,s){const n=Ui();t.querySpheroidData(n);const r=t.getGCS()!==t?t.getSRToGCSTransform():null,i=(0,h.m)(h.P,100),o=new a.f(0,0,0),m=e.getPointCount(),l=t.getGCS().getUnit().getUnitToBaseFactor();for(let t=0,s=m;t<s;){const a=Math.min(100,s-t);e.queryCoordinates(i,a,t,t+a),r&&(new cn).transform(r,i,a,i,!1);for(let e=0;e<a;e++){if(i[e].isNAN())continue;i[e].scale(l);const t=v(n.majorSemiAxis,n.e2,i[e]);o.addThis(t)}t+=a}const g=w(n.majorSemiAxis,n.e2,o);g.scale(1/l);const c=e;if(!new On(t.getGCS(),g).project(c))return 0;s.length=e.getPathCount();const u=c.calculateArea2D()<0;for(let t=0,n=e.getPathCount();t<n;t++){const e=c.calculateRingArea2D(t),n=u?e<0:e>0;s[t]=n}return u?-1:1}(e,t,m);if(n)n<0&&i.reverseAllPaths();else{const e=s.getPathCount();for(let t=0;t<e;t++)m.push(s.calculateRingArea2D(t)>0)}}n=m}return new zn(null,n,i,null,t,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(l===i.G.enumPolyline){let n=new o.a({vd:e.getDescription()});return n.addAndExplicitlyOpenAllPaths(e,!1),_&&(n=_n(n,t,2,r,Number.NaN,null,!0)),new zn(null,null,n,null,t,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(l===i.G.enumMultiPoint){const t=e,n=t.getAttributeStreamRef(0);let r,i=null,o=s,a=0;const m=.1*c;for(let s=0,l=t.getPointCount();s<l;s++){const t=n.read(2*s);let l=t-o;if(Math.abs(l)>u&&(l=(0,h.ax)(l/c)*c,a-=l,Math.abs(a)<m&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const n=t+a;i.write(2*s,n)}o=t}return i?(r.notifyModified(),r):e}(0,i.d)("")}(e,t,s,n,r)}normalizeGeometry(e,t,s){return function(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,o=e.queryInterval(0,0);if(o.width()<r||!(0,i.i)(e.getGeometryType())){if(Number.isNaN(s))return e;const t=o.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new m.T,i=(0,h.ax)((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const a=e.getGeometryType(),l=e,g=l.getAttributeStreamRef(0),c=e.clone(),u=c.getAttributeStreamRef(0);let _=0,p=0,d=0,f=(0,i.h)(a)?0:-1;const x=h.E.constructEmpty();let P=!1;for(let e=0,t=l.getPointCount();e<t;e++){const t=g.read(2*e);e===p&&((0,i.h)(a)?(0===f&&Number.isNaN(s)&&(P=!0),f>0&&Number.isNaN(s)&&(s=x.getCenter(),P=!1),p=l.getPathEnd(f),f++):p=l.getPointCount(),Number.isNaN(s)?d=t:(d=s,_=0));let o=t-d;Math.abs(o)>r&&(o=(0,h.ax)(o/n)*n,_-=o,Math.abs(_)<.1*n&&(_=0));const m=t+_;u.write(2*e,m),P&&x.mergeCoordinate(m),d=t}return c.notifyModified(),c}(e,t,s)}clipToSpatialReference(e,t,s,n=0){return function(e,t,s,n){const o=t.getCoordinateSystemType();if(0===o){const n=new oo;return t.queryPrecisionDescriptor(n),hn(e,n,t,s)}let a=e;2!==n&&3!==n||!t.isPannable()||(a=an(a,t,s));const h=new oo;if(t.queryPrecisionDescriptor(h),a=hn(a,h,t,s),0===n||a.isEmpty())return a;if(1===o){if(1===n){const e=new r.Envelope2D;a.queryLooseEnvelope(e);const n=t.getPannableExtent(),i=.01*n.width();return n.xmin=e.xmin-i,n.xmax=e.xmax+i,(new l.O).execute(a,n,t,s)}return a}if(2===o){const e=t.getPCSHorizon();if(1===n||2===n){const n=(new sn).execute(a,e,t,s);return n===e?n.clone():n}return a}if(3===o)return a;(0,i.d)("missing implementation")}(e,t,s,n)}}class un extends c.G{constructor(e,t,s){super(),this.m_projTrans=t,this.m_progressTracker=s,this.m_index=-1,e||(0,i.a)(""),this.m_inputGeoms=e}next(){const e=this.m_inputGeoms.next();return null!=e?((0,i.p)(e),(0,i.c)(e),this.m_index=this.m_inputGeoms.getGeometryID(),nn(e,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function _n(e,t,s,n,r,a,h=!1){e||(0,i.a)("Geometry.Geodetic_densify.densify");let m=e.getGeometryType();if((0,i.c)(e),e.isEmpty()||(0,i.e)(m))return e;const l=new En;l.m_sr=t,l.m_gcs=t.getGCS(),l.m_transform=l.m_gcs!==t?t.getSRToGCSTransform():null,l.m_progressTracker=a;const g=Ui();let c,u,_;if(l.m_gcs.querySpheroidData(g),l.m_a=g.majorSemiAxis,l.m_eSquared=g.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=n,l.m_maxDeviation=r,l.m_curveType=s,m===i.G.enumEnvelope){const t=new o.P({vd:e.getDescription()});t.addEnvelope(e,!1),c=t,m=i.G.enumPolygon}else if((0,i.f)(m)){const t=new o.a({vd:e.getDescription()});t.addSegment(e,!0),c=t,m=i.G.enumPolyline}else c=e;if(4!==l.m_curveType){if((0,i.g)((0,i.h)(m)),u=l.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(c),u.isEmpty())return u;u=pn(l.m_rpu,u);let e=l.geodeticDensify(u);h||(e=(new cn).foldInto360RangeGeodetic(e,l.m_gcs,l.m_curveType)),_=l.m_transform&&!l.m_transform.isIdentity()?(new cn).execute(e,l.m_transform.getInverse(),a):e}else{let e;if((0,i.g)((0,i.h)(m)),t.isPannable())e=Gr(c,t);else{const s=t.getPCSHorizon();e=(new sn).execute(c,s,t,a),e===s&&(e=s.clone())}if(u=e,u.isEmpty())return u;_=l.shapePreservingDensify(u)}return _}function pn(e,t){const s=new r.Envelope2D;if(t.queryLooseEnvelope(s),s.width()*e<Math.PI)return t;let n=!1;const i=t.querySegmentIterator(),o=new h.P,m=new h.P;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment();if(o.setCoordsPoint2D(t.getStartXY()),m.setCoordsPoint2D(t.getEndXY()),o.scale(e),m.scale(e),Math.abs(o.x-m.x)>Math.PI){if(!fn(o,m)){n=!0;break}if(Math.abs(o.x-m.x)>2*Math.PI){n=!0;break}}}if(!n)return t;const l=t.createInstance();l.reserve(t.getPointCount());const g=t.getDescription().getAttributeCount()>1,c=new h.P,u=new h.P,_=new h.P(0,0),p=new h.P(0,0),d=new a.P;for(i.resetToFirstPath();i.nextPath();){let t=Number.NaN,s=0;for(;i.hasNextSegment();){const n=i.nextSegment();if(o.setCoordsPoint2D(n.getStartXY()),m.setCoordsPoint2D(n.getEndXY()),o.scale(e),m.scale(e),Number.isNaN(t)?(s=Vn(o.x,Number.NaN,s),_.setCoordsPoint2D(o)):_.setCoordsPoint2D(p),t=_.x,fn(o,m)){if(m.x-o.x>2*Math.PI)for(;m.x-o.x>2*Math.PI;)m.x-=2*Math.PI;else if(m.x-o.x<2*-Math.PI)for(;m.x-o.x<2*-Math.PI;)m.x+=2*Math.PI;s=Vn(m.x,Number.NaN,s),p.setCoordsPoint2D(m)}else c.setCoordsPoint2D(m),Mn(c),s=Vn(c.x,t,s),p.setCoords(s+c.x,c.y);if(Math.abs(p.x-m.x)<.5&&p.setCoordsPoint2D(m),g)n.queryCoord(0,d),u.setCoordsPoint2D(_),u.scale(1/e),d.setXY(u),i.isFirstSegmentInPath()?l.startPathPoint(d):l.lineToPoint(d),i.isLastSegmentInPath()&&!i.isPathClosed()&&(n.queryCoord(1,d),u.setCoordsPoint2D(p),u.scale(1/e),d.setXY(u),l.lineToPoint(d));else{i.isFirstSegmentInPath()&&l.insertPath2D(-1,null,0,0,!0);const t=l.getPathCount()-1;u.setCoordsPoint2D(_),u.scale(1/e),l.insertPoint2D(t,-1,u),i.isLastSegmentInPath()&&!i.isPathClosed()&&(u.setCoordsPoint2D(p),u.scale(1/e),l.insertPoint2D(t,-1,u))}}}return l}function dn(e,t,s,n,r,i,o,a,m,l,g,c){const u=new h.P,_=new h.P,p=n.compare(r)>0;Tn(p,n,r,u,_);const d=Cn(e,t,s,u,_,i,o,a,m,l,null,g,c);return p&&Nn(m,l,null,g),d}function fn(e,t){return!(!Po(e.y,h.o)||!Po(t.y,h.o))||!(!Po(e.y,-h.o)||!Po(t.y,-h.o))}function xn(e,t){return!(!Po(e.y,h.o)||Po(t.y,h.o))||!(!Po(e.y,-h.o)||Po(t.y,-h.o))}function Pn(e,t){return!(!Po(t.y,h.o)||Po(e.y,h.o))||!(!Po(t.y,-h.o)||Po(e.y,-h.o))}class En{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(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new o.S,a=e.getDescription().getAttributeCount()>1;for(;s.nextPath();){const e=[0];for(;s.hasNextSegment();){const o=s.nextSegment(),m=o.getStartXY(),l=o.getEndXY();m.scale(this.m_rpu),l.scale(this.m_rpu);const g=new h.P,c=new h.P,u=m.compare(l)>0;Tn(u,m,l,g,c),n.length=0,r.length=0,this.m_maxLength>0?Cn(this.m_a,this.m_eSquared,this.m_curveType,g,c,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,a?r:null,n,e):In(),u&&Nn(null,null,a?r:null,n),n[0].setCoordsPoint2D(o.getStartXY()),n.at(-1).setCoordsPoint2D(o.getEndXY());const _=1/this.m_rpu;for(let e=1,t=n.length-1;e<t;e++)n[e].scale(_);if(a){const e=Dn(u,o,i);Sn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),o,e,r,n,t)}else yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}}return t}shapePreservingDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new o.S,a=e.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment(),o=e.getStartXY(),h=e.getEndXY(),m=o.compare(h)>0,l=Dn(m,e,i);n.length=0,r.length=0,wn(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,a?r:null,n),m&&Nn(null,null,a?r:null,n),a?Sn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),e,l,r,n,t):yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){const t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Gr(e,this.m_gcs),!t))return e;const s=e.createInstance();s.reserveParts(e.getPointCount(),e.getPathCount());for(let t=0,n=e.getPathCount();t<n;++t){let n=new o.M;const r=e.getPathStart(t),i=e.getPathEnd(t);n.addPoints(e,r,i);const h=e.isClosedPath(t);let m=!1;if(h&&i-r===1&&e.hasNonLinearSegmentsPath(t)){const t=new a.P;e.getPointByVal(r,t),n.add(t),m=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(h&&!m){const t=new a.P;e.getPointByVal(r,t),n.add(t)}if(n=(new cn).execute(n,this.m_transform,this.m_progressTracker),h&&n.getPointCount()>1){const e=n.getXY(0),t=n.getXY(n.getPointCount()-1);e.equals(t)&&n.removePoint(n.getPointCount()-1)}}n.getPointCount()>1&&(s.addPathMultiPoint(n,0,-1,!0),h&&s.closePathWithLine())}return s}}function yn(e,t,s,n){e&&n.insertPath2D(-1,null,0,0,!0);const r=n.getPathCount()-1;n.insertPointsFromPoints(r,-1,s,0,s.length-1,!0),t&&n.insertPoint2D(r,-1,s.at(-1))}function Sn(e,t,s,n,r,i,o){o.reserve(o.getPointCount()+i.length-1);const h=new a.P;if(s.queryStart(h),e?o.startPathPoint(h):o.lineToPoint(h),i.length>2){const e=n.calculateLength2D();for(let t=1;t<i.length-1;t++){const s=n.lengthToT(r[t]*e);n.queryCoord(s,h),h.setXY(i[t]),o.lineToPoint(h)}}t&&(s.queryEnd(h),o.lineToPoint(h))}function Cn(e,t,s,r,i,o,a,m,l,g,c,u,_){const p={stack:[],error:void 0,hasError:!1};try{const d=(0,n.mS)(p,new Eo,!1),f=(0,n.mS)(p,new Eo,!1),x=(0,n.mS)(p,new Eo,!1);wo.geodeticDistance(e,t,r.x,r.y,i.x,i.y,x,d,f,s);const P=x.val,E=d.val,y=f.val;let S=E,C=y;S<0&&(S+=2*Math.PI),C<0&&(C+=2*Math.PI),l&&(l[0]=S),g&&(g[0]=C);let I=Number.NaN,v=Number.NaN;if(null!==c){const s=No.q90(e,t),n=No.q(e,t,r.y);I=(s-n)/P,v=(s+n)/P}const b=xn(r,i),G=Pn(r,i),w=b||G,N=function(e,t,s){return!(!An(e,t,s)||Po(e.y,h.o)||Po(e.y,-h.o)||Po(t.y,h.o)||Po(t.y,-h.o))}(r,i,m),T=(0,n.mS)(p,new h.S(new Eo,new Eo),!1),D=new h.P,V=new h.P,k=new h.P;_[0]=Vn(r.x,Number.NaN,_[0]);let F=_[0];if(P<=o)return u.push(r.clone()),_[0]=Vn(i.x,Number.NaN,_[0]),null!=c&&c.push(0),w?(b&&kn(r,i,c,u),G&&Fn(r,i,c,u)):N?Hn(r,i,E,I,v,c,u):a>0&&(V.setCoords(r.x-F,r.y),D.setCoords(i.x-_[0],i.y),F=vn()),u.push(i.clone()),P;const H=1+Math.ceil(P/o),A=P/(H-1),M=new h.P;u.push(r.clone()),M.setCoordsPoint2D(r),V.setCoords(r.x-_[0],r.y),null!==c&&c.push(0);for(let n=1;n<H;n++){let o;if(n<H-1){const i=n*A;wo.geodeticCoordinate(e,t,r.x,r.y,i,E,T.at(0),T.at(1),s),D.setCoords(T.at(0).val,T.at(1).val),_[0]=Vn(D.x,M.x,_[0]),k.setCoords(_[0]+D.x,D.y),o=n/(H-1)}else _[0]=Vn(i.x,Number.NaN,_[0]),D.setCoords(i.x-_[0],i.y),k.setCoordsPoint2D(i),o=1;w?(1===n&&b&&kn(r,k,c,u),n===H-1&&G&&Fn(M,i,c,u)):N?An(M,k,m)&&(r.x<i.x?M.x>k.x&&(_[0]+=2*Math.PI,k.setCoords(_[0]+D.x,D.y)):M.x<k.x&&(_[0]-=2*Math.PI,k.setCoords(_[0]+D.x,D.y)),Hn(M,k,E,I,v,c,u)):a>0&&vn(),u.push(k.clone()),null!=c&&c.push(o),M.setCoordsPoint2D(k),V.setCoordsPoint2D(D),F=_[0]}return P}catch(e){p.error=e,p.hasError=!0}finally{(0,n.hk)(p)}}function In(e,t,s,n,r,o,a,h,m,l){(0,i.g)(0)}function vn(e,t,s,n,r,o,a,h,m,l,g,c,u,_,p){return(0,i.g)(0),0}function bn(e,t,s,n){const r=v(e,t,s),i=v(e,t,n);return a.f.distance(r,i)}function Gn(e,t,s,n,r,o,m,l){const g=new Array,c=(0,h.m)(Array,8);let u=2,_=r.getCoord2D(o);c[0][0]=_.x,c[0][1]=_.y,_=r.getCoord2D(m),c[1][0]=_.x,c[1][1]=_.y;const p=e=>{if(null!==s){const t=Co.projToGeog(s,e,c);(0,i.g)(t===e)}for(const e of c)e[0]*=n,e[1]*=n};p(2),g.push(v(e,t,new h.P(c[0][0],c[0][1]))),g.push(v(e,t,new h.P(c[1][0],c[1][1])));let d=a.f.distance(g[0],g[1]);if(d>l)return d;let f=0;for(u=3;u<=17;){const s=1/(u-1);let n=0;for(let e=1;e<u;++e)if(1&e){const t=(0,h.q)(o,m,e*s);r.queryCoord2D(t,_),c[n][0]=_.x,c[n][1]=_.y,n++}p(n);let x=1;for(let s=0;s<n;++s)g.splice(x,0,v(e,t,new h.P(c[s][0],c[s][1]))),x++;x=0;let P=g[x];x++;let E=0;for(;x!==g.length;++x){const e=g[x];E+=a.f.distance(P,e),P=e}if(E>l)return E;if(f=E-d,(0,i.g)(f>=0||Math.abs(f)<1e-14*E),f<0&&(f=0),d=E,E+f<=l)return E+f;u=2*u-1}return d+f}function wn(e,t,s,n,r,o,a,m,l){const g=n.isCurve(),c=function(e,t){return e*Math.sqrt(1-t)}(e,t)*Math.PI*179/180;let u=o;o>0&&!(o>c)||(u=c);const _=a,p=_>0;let d=Number.NaN;p&&(d=function(e,t,s){const n=s/(2*function(e,t){return(1-t)*e}(e,t)),r=n*n;return s*(1-r*(.16666666666666666-.008333333333333333*r))}(e,t,_));const f=1===r.getCoordinateSystemType();let x=null;f||(x=r.getPECoordSys());const P=r.getTolerance(0),E=n.getStartXY(),y=n.getEndXY(),S=new h.P,C=new h.P;if(f)S.setCoordsPoint2D(E),S.scale(s),C.setCoordsPoint2D(y),C.scale(s);else{const e=[E.x,E.y,y.x,y.y];Co.projToGeog(x,2,e),S.setCoords(e[0],e[1]),S.scale(s),C.setCoords(e[2],e[3]),C.scale(s)}let I=0,b=0;const G=[],w=[],N=[];G.push(y.clone()),w.push(C.clone()),N.push(1),l.push(E.clone()),null!==m&&m.push(b);const V=r.isPannable(),k=E.clone(),F=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let H=5;g||(p?(F[0]=.5,F[1]=.25,F[2]=.75,H=3):H=1),(0,i.g)(u>0);const A=e=>{if(e=e.clone(),null!==x){const t=[e.x,e.y];Co.projToGeog(x,1,t),e.setCoords(t[0],t[1])}return e.scale(s),e};for(;w.length>0;){const o=G.at(-1).clone();C.assign(w.at(-1));const a=N.at(-1);let c=!1,_=Number.NaN;const E=Gn(e,t,x,s,n,b,a,u);let y=u>=E&&Math.abs(S.y-C.y)<.9*Math.PI;f&&y&&(y=Math.abs(S.x-C.x)<.9*Math.PI);const M=new h.P,U=new h.P;let q=!1;if(!p&&y&&y&&(q=!0),n.calculateSubLength(b,a)<=P&&(q=!0),!q)for(let m=0;m<H;m++){const l=(0,h.q)(b,a,F[m]),u=new h.P;n.queryCoord2D(l,u);const x=A(u);if(0===m&&(_=l,M.setCoordsPoint2D(u),U.setCoordsPoint2D(x),!y)){c=!0;break}if((0,i.g)(p),f&&Math.abs(S.x-x.x)>=Math.PI){c=!0;break}let P=new h.P,E=new h.P;g?(P=h.P.lerp(k,o,F[m]),E=A(P)):(P=u.clone(),E=x.clone());const I=T(e,t,S,C,F[m]),G=I.clone();if(f?(G.x/=s,G.y/=s):(G.x/=s,G.y/=s,rn(r.getGCSToSRTransform(),[G],1,[G],null)),G.isNAN()){const s=v(e,t,x),n=v(e,t,S),r=v(e,t,C),{second:i}=D(e,t,s,n,r,2,null);if(i>d){c=!0;break}}else{if(V){const e=r.getPannableExtent().width(),t=(0,h.q)(n.getStartX(),n.getEndX(),.5);for(;G.x<t-.5*e;)G.x+=e;for(;G.x>=t+.5*e;)G.x-=e}const s=n.getClosestCoordinateOnInterval(G,new h.E(b,a),-1);let i=n.getCoord2D(s);i=A(i);let o=bn(e,t,i,I);if(o>d){if(o<4*d){const s=v(e,t,i),n=v(e,t,S),r=v(e,t,C),{second:a}=D(e,t,s,n,r,2,null);o=a}if(o>d){c=!0;break}}else if(g){let s=v(e,t,x);const n=v(e,t,S),r=v(e,t,C);let{second:i}=D(e,t,s,n,r,3,null);if(i<=d){s=v(e,t,E);const{second:o}=D(e,t,s,n,r,3,null);i=o}if(i>d){c=!0;break}}}}c?(G.push(M.clone()),w.push(U.clone()),N.push(_)):(G.pop(),w.pop(),N.pop(),l.push(o.clone()),I+=E,null!==m&&m.push(I),k.setCoordsPoint2D(o),S.setCoordsPoint2D(C),b=a)}if(null!==m){const e=1/I;for(let t=0;t<m.length;t++)m[t]*=e}}function Nn(e,t,s,n){if(n.reverse(),null!==s&&s.reverse(),e){const s=e[0],n=t[0];e[0]=n,t[0]=s}}function Tn(e,t,s,n,r){e?(n.setCoordsPoint2D(s),r.setCoordsPoint2D(t)):(n.setCoordsPoint2D(t),r.setCoordsPoint2D(s))}function Dn(e,t,s){return e?(s.create(t.getGeometryType()),t.copyTo(s.get()),s.get().reverse(),s.get()):t}function Vn(e,t,s){if(Number.isNaN(t)){for(;s-e>Math.PI;)s-=2*Math.PI;for(;e-s>Math.PI;)s+=2*Math.PI;return s}return s+e-t>Math.PI?s-=2*Math.PI:t-(s+e)>Math.PI&&(s+=2*Math.PI),s}function kn(e,t,s,n){if(e.y>0){const r=new h.P;r.setCoords(t.x,h.o),Po(e.x,r.x)||Po(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new h.P;r.setCoords(t.x,-h.o),Po(e.x,r.x)||Po(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}}function Fn(e,t,s,n){if(t.y>0){const r=new h.P;r.setCoords(e.x,h.o),Po(t.x,r.x)||Po(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new h.P;r.setCoords(e.x,-h.o),Po(t.x,r.x)||Po(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}}function Hn(e,t,s,n,r,i,o){if(function(e){return function(e,t){return 0===e||Math.abs(e)<=t}(e,xo)}(s)){if(h.o-e.y>0){const t=new h.P;t.setCoords(e.x,h.o),o.push(t),null!==i&&i.push(n)}if(h.o-t.y>0){const e=new h.P;e.setCoords(t.x,h.o),o.push(e),null!==i&&i.push(n)}}else{if(h.o+e.y>0){const t=new h.P;t.setCoords(e.x,-h.o),o.push(t),null!==i&&i.push(r)}if(h.o+t.y>0){const e=new h.P;e.setCoords(t.x,-h.o),o.push(e),null!==i&&i.push(r)}}}function An(e,t,s){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=s}function Mn(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=2*Math.PI;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=2*Math.PI}function Un(e,t,s,r){const i={stack:[],error:void 0,hasError:!1};try{const o=[s.x],a=[s.y-r],h=[s.x],m=[s.y+r];k(o,a),k(h,m);const l=(0,n.mS)(i,new Eo,!1),g=(0,n.mS)(i,new Eo,!1);return wo.greatEllipticDistance(e,t,s.x,s.y,o[0],a[0],l,null,null),wo.greatEllipticDistance(e,t,s.x,s.y,h[0],m[0],g,null,null),Math.min(l.val,g.val)}catch(e){i.error=e,i.hasError=!0}finally{(0,n.hk)(i)}}function qn(e,t,s,n,i){const o=new r.Envelope2D;s.queryEnvelope(o);const h=(0,a.e)(null,s,!0).total();if(t.xmin-o.xmin<=h&&o.xmax-t.xmax<=h)return s;const g=t.width();let c=0;for(;t.xmin+c*g<o.xmin;)c++;for(;t.xmin+c*g>o.xmin;)c--;const u=c*g,_=new m.T;_.setShiftCoords(-u,0);const p=s;p.applyTransformation(_);const d=new r.Envelope2D;p.queryEnvelope(d);let f=null;if(d.xmax>t.xmax){let s=0;const n=new r.Envelope2D;n.setCoords({env2D:t}),n.ymin-=1,n.ymax+=1;let o=p;for(;n.xmin<d.xmax;){d.xmax>n.xmax&&(o=vr(o,e,2,!0,n.xmax));const r=(0,a.j)(o,n),h=(0,a.c)(null,r,!0).total(),m=(0,l.c)(o,n,h,Number.NaN,i);null===f?f=m===o?m.clone():m:(_.setShiftCoords(-s*g,0),m.applyTransformation(_),f.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=t.xmax+s*g}}else f=p;return f}class On{constructor(e,t){this.m_basisX=new a.f,this.m_basisY=new a.f,this.m_normal=new a.f,(0,i.g)(1===e.getCoordinateSystemType()),this.m_gcs=e;const s=Ui();e.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);const n=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,o=Math.cos(n),m=Math.sin(n),l=Math.cos(r),g=Math.sin(r);this.m_cartCenter3D=function(e,t,s,n,r,i){return b(e,t,s,n,r,i,0)}(this.m_a,this.m_e2,o,m,l,g),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),a.f.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(h.P.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(h.P.construct(0,.5*-Math.PI/this.m_rpu))}project(e){const t=e.getGeometryType();if((0,i.i)(t)){(0,i.p)(e);const t=e;return this.projectMultiVertex(t)}(0,i.a)("Gnomonic.project")}unproject(e,t,s){const n=e.getGeometryType();if((0,i.i)(n)){(0,i.p)(e);let m=e;const l=[];if(n===i.G.enumPolygon){const e=m.getPathCount();for(let t=0;t<e;t++){const e=m.calculateRingArea2D(t);l.push(e)}}return this.unprojectMultiVertex(t,m),(0,i.h)(n)?(function(e,t,s){const n=e.getPannableExtent(),r=h.P.construct(0,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new h.P;a.setNAN();let m=Number.NaN;for(let e=0;e<s.getPathCount();e++)for(let t=s.getPathStart(e);t<s.getPathEnd(e);t++){const r=s.getXY(t),h=Po(r.y,n.ymax)||Po(n.ymin,r.y);t===s.getPathStart(e)?(a.setNAN(),m=0):a.isNAN()||h||(m=Rn(r.x,a.x,o,i,m)),r.x+=m,s.setXYNoCurves(t,r),h||a.setCoordsPoint2D(r)}s.getImpl().notifyModifiedFlags(2001)}(this.m_gcs,0,m),function(e,t,s,n,m){const l=n.getGeometryType(),g=t.getPannableExtent();let c=n,u=!1,_=!1;if(l===i.G.enumPolygon){const s=new r.Envelope2D,n=h.P.construct(0,0);s.setCoords({env2D:g}),s.centerAt(n),u=function(e,t,s,n,i){const a=function(e,t){const s=new r.Envelope2D;t.queryEnvelope(s);const n=Po(e.ymax,s.ymax),i=Po(e.ymin,s.ymin),a=n||i;return!!a&&(function(e,t){const s=new o.P,n=new r.Envelope2D;for(let r=0;r<t.getPathCount();r++){t.queryPathEnvelope(r,n);let i=Po(e.ymax,n.ymax),o=Po(e.ymin,n.ymin);if(!i&&!o){s.addPath(t,r,!0);continue}s.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(r),m=t.getPathEnd(r),l=m-a;let g=-1;for(g=a;g<m;g++){const s=t.getXY(g);if(i=Po(e.ymax,s.y),o=Po(e.ymin,s.y),!i&&!o)break}let c=g,u=!1,_=Number.NaN;do{const n=t.getXY(c);i=Po(e.ymax,n.y),o=Po(e.ymin,n.y);const m=a+(c+1-a)%l;if(i||o){let i=h.P.construct(_,n.y);s.insertPoint2D(r,-1,i);const o=t.getXY(m),a=Po(e.ymax,o.y),l=Po(e.ymin,o.y);a||l||(i=h.P.construct(o.x,n.y),u?s.setXYNoCurves(s.getPointCount()-1,i):s.insertPoint2D(r,-1,i)),u=!0}else s.insertPoint2D(r,-1,n),_=n.x,u=!1;c=m}while(c!==g)}t.setEmpty(),t.add(s,!1)}(e,t),a)}(s,n),m=function(e,t,s,n,r){const i=[],a=[],h=.5*s.width();for(let o=0;o<n.getPathCount();o++){const m=n.getXY(n.getPathStart(o)),l=n.getXY(n.getPathEnd(o)-1),g=e[o]<0;if(Math.abs(m.x-l.x)>h){const e=Yn(g,t,s,o,n,r);i.push(e),a.push(o)}else if(!g&&n.calculateRingArea2D(o)<0){const e=Bn(t,s,o,n,r);i.push(e),a.push(o)}}if(0===i.length)return!1;const m=new o.P({vd:n.getDescription()});let l=0,g=a[l];for(let e=0;e<n.getPathCount();e++)e===g?(m.add(i[l],!1),l++,l<a.length&&(g=a[l])):m.addPath(n,e,!0);return n.setEmpty(),n.add(m,!1),!0}(e,t,s,n,i);return a||m}(e,t,s,c,m);const i=function(e,t,s,n){const i=new r.Envelope2D;s.queryEnvelope(i);const o=(0,a.e)(null,s,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return s;const h=s.createInstance();let m=s.createInstance();const l=new r.Envelope2D,g=s.getPathCount();for(let r=0;r<g;r++)s.queryPathEnvelope(r,l),t.xmin-l.xmin<=o&&l.xmax-t.xmax<=o?h.addPath(s,r,!0):(m.setEmpty(),m.addPath(s,r,!0),m=qn(e,t,m,0,n),h.add(m,!0));return h}(t,s,c,m);i!==c&&(_=!0),c=i}else c=(new cn).foldInto360RangeGeodetic(c,t,2);l===i.G.enumPolygon&&(u||_)&&(c=(new Js).execute(c,t,!1,m)),c!==n&&(n.setEmpty(),n.add(c,!1))}(l,this.m_gcs,0,m,s)):m=Er(m,this.m_gcs,0,!0,0,s),m}(0,i.a)("Gnomonic.unproject")}projectPoint(e){const t=e.mul(this.m_rpu),s=v(this.m_a,this.m_e2,t),n=this.m_normal.dotProduct(s);if(n<=0)return h.P.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new h.P;return o.x=this.m_basisX.dotProduct(i),o.y=this.m_basisY.dotProduct(i),o}unprojectPoint(e){const t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return w(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){const t=e.getImpl();let s=!0;const n=new h.P,r=new h.P;for(let e=0,i=t.getPointCount();e<i;e++)t.queryXY(e,n),n.y*this.m_rpu>.5*Math.PI?r.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?r.assign(this.m_southPolePcs):r.assign(this.projectPoint(n)),t.setXYNoCurves(e,r),r.isNAN()&&(s=!1);return t.notifyModifiedFlags(2001),s}unprojectMultiVertex(e,t){const s=t.getImpl(),n=e*e,r=!this.m_northPolePcs.isNAN(),i=!this.m_southPolePcs.isNAN();for(let e=0,t=s.getPointCount();e<t;e++){const t=s.getXY(e);let o=new h.P;r&&h.P.sqrDistance(t,this.m_northPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*Math.PI),o.scale(1/this.m_rpu)):i&&h.P.sqrDistance(t,this.m_southPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),o.scale(1/this.m_rpu)):o=this.unprojectPoint(t),s.setXYNoCurves(e,o)}s.notifyModifiedFlags(2001)}}function Yn(e,t,s,n,i,g){const c=new o.P,u=new o.P,_=new m.T,p=i.getXY(i.getPathStart(n)),d=i.getXY(i.getPathEnd(n)-1),f=s.width(),x=.5*f,P=new r.Envelope2D;i.queryEnvelope(P);const E=Math.ceil(P.width()/f)+1;let y,S;p.x>d.x?(y=-f,S=e?s.ymin:s.ymax):(y=f,S=e?s.ymax:s.ymin),_.setShiftCoords(y,0),c.addPath(i,n,!0),u.add(c,!1);const C=new a.P;for(let e=0;e<E;e++)u.applyTransformation(_),u.getPointByVal(0,C),c.lineToPoint(C),c.addSegmentsFromPath(u,0,0,u.getSegmentCount()-1,!1);const I=c.getXY(0),v=c.getXY(c.getPointCount()-1);I.y=S,v.y=S,c.lineTo(v);const b=new h.P;for(b.setCoordsPoint2D(v),b.x-=.5*y;Math.abs(b.x-I.x)>x;)c.lineTo(b),b.x-=.5*y;c.lineTo(I);const G=s.getCenter().x,w=new r.Envelope2D;c.queryEnvelope(w);let N=0;const T=w.getCenter().x;T-G>x?N=-Math.ceil((T-G-x)/f):G-T>x&&(N=Math.ceil((G-T-x)/f)),0!==N&&(_.setShiftCoords(N*f,0),c.applyTransformation(_));const D=new o.E,V=D.addGeometry(c);br(D,V,t,0,2,!0,s.xmin),br(D,V,t,0,2,!0,s.xmax);const k=D.getGeometry(V),F=(0,a.j)(k,s);F.inflateCoords(0,1);const H=(0,a.c)(null,F,!0);return(0,l.c)(k,s,H.total(),Number.NaN,g)}function Bn(e,t,s,n,i){const g=t.width(),c=.5*g,u=t.getCenter().x,_=new r.Envelope2D;n.queryPathEnvelope(s,_);let p,d=0,f=_.getCenter().x;if(f-u>c?d=-Math.ceil((f-u-c)/g):u-f>c&&(d=Math.ceil((u-f-c)/g)),0!==d){const e=new m.T;e.setShiftCoords(d*g,0),n.getImpl().applyTransformationToPath(e,s),n.queryPathEnvelope(s,_),f=_.getCenter().x}const x=new r.Envelope2D;t.containsExclusiveEnvelope(_)?(p=!1,x.setCoords({env2D:t})):(p=!0,x.setCoords({env2D:t}),x.xmin-=g,x.xmax+=g);let P=n.createInstance();P.addPathPoint2D(null,0,!0);const E=new h.P;if(E.setCoords(x.xmin,x.ymin),P.insertPoint2D(0,-1,E),E.setCoords(x.xmin,x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(.5*(x.xmin+x.xmax),x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(x.xmax,x.ymax),P.insertPoint2D(0,-1,E),E.setCoords(x.xmax,x.ymin),P.insertPoint2D(0,-1,E),E.setCoords(.5*(x.xmin+x.xmax),x.ymin),P.insertPoint2D(0,-1,E),p){P.addPath(n,s,!0);const r=new m.T;f<u?r.setShiftCoords(g,0):r.setShiftCoords(-g,0),n.getImpl().applyTransformationToPath(r,s),P.addPath(n,s,!0);const h=new o.E,c=h.addGeometry(P);br(h,c,e,0,2,!0,t.xmin),br(h,c,e,0,2,!0,t.xmax),P=h.getGeometry(c);const _=(0,a.j)(P,t);_.inflateCoords(0,1);const p=(0,a.c)(null,_,!0).total();P=(0,l.c)(P,t,p,Number.NaN,i)}else P.addPath(n,s,!0);return P}function Rn(e,t,s,n,r){return r+e-t>s?r-=n:t-(r+e)>s&&(r+=n),r}function Xn(e,t,s,n,r,i){const m=t.getAttributeStreamRef(0),l=t.getPointCount();let g=!1;const c=new h.P;for(let e=0;e<l;++e){if(m.queryPoint2D(2*e,c),1&i&&c.y>=s){g=!0;break}if(2&i&&c.y<=-s){g=!0;break}}if(!g)return!1;let u=!1;e&&(u=t.getImpl().isClosedPathInXYPlane(0));const _=new o.E,p=_.addGeometry(t),d=_.getFirstPath(p);let f=-1,x=!0;const P=new h.P,E=new a.P;let y=o.n;const S=Ln*r/360;for(let e=_.getFirstVertex(d);e!==o.n;e=_.getNextVertex(e)){_.queryXY(e,c);let t=1&i&&c.y>=s?1:0;if(t|=2&i&&c.y<=-s?2:0,f>0&&f!==t){if(P.x!==c.x){const t=_.getPrevVertex(e);_.queryPoint(t,E);const s=_.insertVertex(d,e,E);P.x=c.x,_.setXY(s,P)}if(u){let t=y!==o.n?_.getNextVertex(y):_.getFirstVertex(d);const s=_.getPrevVertex(e);for(;t!==s;)t=_.removeVertex(t,!1);if(y!==o.n){const e=_.getXY(y),t=_.getXY(s);if(Math.abs(e.x-t.x)>S){_.queryPoint(y,E);const n=_.insertVertex(d,s,E);e.x=(0,h.q)(e.x,t.x,.5),_.setXY(n,e)}}}y=o.n}if(t&&(c.y=(0,h.f)(n,c.y),_.setXY(e,c),!x&&f!==t))if(c.x!==P.x){_.queryPoint(e,E);const t=_.insertVertex(d,e,E);_.setXYCoords(t,P.x,c.y),y=t}else y=e;f=t,P.assign(c),x=!1}if(u){if(y!==o.n){let e=_.getNextVertex(y);for(;e!==o.n;)e=_.removeVertex(e,!1)}const e=_.getFirstVertex(d);let t=_.getLastVertex(d);const s=_.getXY(e),n=_.getXY(t);if(!s.equals(n)&&(_.queryPoint(e,E),t=_.insertVertex(d,o.n,E),Math.abs(s.x-n.x)>S)){const e=_.insertVertex(d,t,E);s.x=(0,h.q)(s.x,n.x,.5),_.setXY(e,s)}}return t.assignCopy(_.getGeometry(p)),!0}const Ln=210;class zn{constructor(e,t,s,n,r,o,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=function(e,t){const s=e.getPannableExtent();return Number.isNaN(t)||s.centerAtCoords(t,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=Ln*this.m_degree,(0,i.g)(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,r,m,l){let g=s;const c=new o.a({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Xn(!0,c,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(g=!1));let u=-1;g&&(u=this.m_originalGeometry.getPathStart(e));const _=c.getAttributeStreamRef(0),p=c.getPointCount();let d=0,f=_.read(0),x=0;const P=3*this.m_pannableSR.getTolerance(0);let E=!1;const y=new h.P,S=new h.P;let C=!1;const I=c.hasNonLinearSegments(),v=new h.P;for(let e=1;e<p;++e){_.queryPoint2D(2*e,v);const t=v.x;let s=t+d;const r=s-f;if(v.x=s,Math.abs(r)>this.m_GCSLargeDelta){if(g){const t=u+e-1,s=u+(e+1<p?e:0),i=m.read(2*t),o=(m.read(2*s)-i)*n;Math.abs(r-o)>1*this.m_degree&&(g=!1)}g||(d-=(0,h.f)(this.m_width360,s-f),s=t+d,++x,C=0!==d,v.x=s)}else E||(0,a.a4)(y,S,v,P)&&(E=!0);C&&(I&&(0,i.d)("error in geonormalize_ring_ for curves"),_.write(2*e,s)),f=s,y.setCoordsPoint2D(S),S.setCoordsPoint2D(v)}x&&c.notifyModified();const b=c.getXY(0),G=c.getXY(p-1);if(h.P.distance(b,G)<P){const e=this.finalizeGeoNormalizeClosedRing(c,E,r);l.add(e,!1)}else{t<0&&(null!==this.m_originalGeometry?((0,i.g)(null!==this.m_originalGeometry),t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0):t=1);const s=this.finalizeGeoNormalizeOpenedRing(t>0,c);l.add(s,!1)}}geoNormalizePolygonGeometry(e){(0,i.g)(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),(0,i.g)(this.m_pannableSR.isPannable());let t=null,s=Number.NaN;const n=!!this.m_originalSR&&this.m_originalSR.isPannable();n&&(t=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const a=new o.P({vd:this.m_inputPoly.getDescription()});for(let r=0,i=this.m_inputPoly.getPathCount();r<i;++r){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[r]?1:0:-1;this.geonormalizeRing(r,i,n,s,e,t,a)}const h=this.m_pannableSR.getTolerance(0),m=this.m_pannableExtent.width()/180;Dr(a,this.m_pannableExtent,.1*h,!1);const c=r.Envelope2D.constructEmpty();if(c.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=r.Envelope2D.constructEmpty();for(let s=0,n=a.getPathCount();s<n;s++)if(a.queryPathEnvelope(s,t),!(c.xmin<=t.xmin&&c.xmax>=t.xmax||t.xmin>=c.xmax||t.xmax<=c.xmin)){e=!1;break}if(e)break;c.move(.5*this.m_width360,0)}e||c.setCoords({env2D:this.m_pannableExtent})}let u=(0,l.c)(a,c,h,m,this.m_progressTracker),_=a!==u;const p=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,d=u.calculateArea2D();let f=0;if(d>0&&p<0)f=1;else if(d<=0&&p>0)if(0===d){if(this.m_originalSR){let e=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?e=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(e=this.m_originalSR.getPannableExtent().getArea()),p>.99*e&&(f=-1)}}else f=-1;if(0!==f){const e=function(e,t){let s=new o.P({vd:e});s.addEnvelope(t,!1);const n=t.width()/180;return s=(new g.O).execute(s,n,0,0,null),s}(u.getDescription(),c);e.add(u,!1),_=!0,u=e}return _&&(u=(new Js).execute(u,this.m_pannableSR,!1,this.m_progressTracker)),u}geoNormalizePolylineGeometry(e){(0,i.g)(this.m_pannableSR.isPannable());let t=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let n=1;s&&((0,i.g)(this.m_originalGeometry),n=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const a=this.m_pannableExtent.width(),g=a*(0,h.O)()*4;let c=e,u=Number.NaN;const _=h.E.constructEmpty();this.m_bAdjustedAtPoles=0;let p=new o.a({vd:this.m_inputPoly.getDescription()});for(let e=0,l=this.m_inputPoly.getPathCount();e<l;++e){let l=s;const d=new o.a({vd:this.m_inputPoly.getDescription()});d.addPath(this.m_inputPoly,e,!0);const f=this.m_inputPoly.isClosedPath(e);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Xn(f,d,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,a,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(l=!1));let x=-1;const P=d.getPointCount();let E=!1;l&&(x=this.m_originalGeometry.getPathStart(e),E=this.m_originalGeometry.isClosedPath(e));const y=d.getAttributeStreamRef(0);let S=0,C=y.read(0),I=0;const v=new h.P,b=new h.P;let G=!1;const w=d.hasNonLinearSegments(),N=new h.P;for(let e=1;e<P;++e){y.queryPoint2D(2*e,N);const s=N.x;let r=s+S;const o=r-C;if(N.x=r,Math.abs(o)>this.m_GCSLargeDelta){if(l){const s=x+e-1;let r=x;(!E||e+1<P)&&(r+=e);const i=t.read(2*s),a=(t.read(2*r)-i)*n;Math.abs(o-a)>1*this.m_degree&&(l=!1)}l||(S-=(0,h.f)(this.m_width360,r-C),r=s+S,++I,G=0!==S,N.x=r)}G&&(w&&(0,i.d)("error in geonormalize_ring_ for curves"),y.write(2*e,r)),C=r,v.setCoordsPoint2D(b),b.setCoordsPoint2D(N)}if(I&&d.notifyModified(),c){let e=!1;if(!d.isEmpty()){const t=r.Envelope2D.constructEmpty();if(d.queryEnvelope(t),t.width()>=a||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(u)){const e=this.m_centralLongitude-.5*a;u=t.xmin,u+=Math.round((e-t.xmin)/a)*a,u>e&&(u-=a),(0,i.g)(u<=e),u<e&&(u+=a),(0,i.g)(u>=e)}let s=Math.round((u-t.xmin)/a)*a;if(t.xmin+s>u+g&&(s-=a),t.xmin+s<u-g&&(s+=a),_.mergeCoordinate(t.xmin+s),_.mergeCoordinate(t.xmax+s),e=_.width()>=a,!e){const e=new m.T;e.setShiftCoords(s,0),d.applyTransformation(e)}}}p.add(d,!1),e&&(p=(()=>{const e=new o.a({vd:p.getDescription()});for(let t=0,s=p.getPathCount();t<s;++t){const s=new o.a({vd:p.getDescription()});s.addPath(p,t,!0);const n=Er(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(n,!1)}return e})(),c=!1)}else{const e=Er(d,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);p.add(e,!1)}}if(c)return p;const d=this.m_pannableSR.getTolerance(0),f=this.m_pannableExtent.width()/180;return Dr(p,this.m_pannableExtent,.1*d,!1),(0,l.c)(p,this.m_pannableExtent,d,f,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const s=t.getPointCount(),n=t.getXY(0),a=t.getXY(s-1);{const e=Math.abs(a.x-n.x),t=Math.round(e/this.m_width360)*this.m_width360;(0,i.g)(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const l=(0,h.e)(a.x-n.x),g=r.Envelope2D.constructEmpty();t.queryLooseEnvelope(g);const c=this.m_pannableExtent.getCenterX();let u=0,_=c-this.m_width360,p=c+this.m_width360;if(l>=0){let e=Math.ceil((_-g.xmin)/this.m_width360);for(e*=this.m_width360;_>g.xmin+e;)e+=this.m_width360;for(;_<g.xmax+e;)e-=this.m_width360;for(u=e,g.width()>720&&(p=_+360*Math.ceil(g.width()/360));p<g.xmax;)p+=this.m_width360}else{let e=Math.ceil((p-g.xmax)/this.m_width360);for(e*=this.m_width360;p<g.xmax+e;)e-=this.m_width360;for(;p>g.xmin+e;)e+=this.m_width360;for(u=e,g.width()>720&&(_=p-360*Math.ceil(g.width()/360));_>g.xmin;)_-=this.m_width360}const d=Math.round(Math.abs(a.x-n.x)/this.m_width360)*this.m_width360,f=l*d,x=g.clone();x.move(u,0);const P=new h.P(0,0),E=new m.T;E.setShiftCoords(u,0),t.applyTransformation(E);const y=new o.a({vd:t.getDescription()});y.add(t,!1),P.assign(t.getXY(s-1));let S=0,C=y.getXY(0).x;for(;l>0?x.xmax<p:x.xmin>_;)x.move(f,0),E.xd=f,t.applyTransformation(E),C+=f,this.m_pannableExtent.xmin<=C&&this.m_pannableExtent.xmax>=C&&(S=y.getPointCount()-1),t.setXY(0,P),P.assign(t.getXY(s-1)),y.addSegmentsFromPath(t,0,0,s-1,!1);const I=new o.P({vd:y.getDescription()});I.add(y,!1);const v=y.getXY(0),b=y.getXY(y.getPointCount()-1),G=l<0?e:!e,w=I.getPointCount()-1;if(G){const e=new h.P(b.x,this.m_pannableExtent.ymax);I.lineTo(e);const t=new h.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);I.lineTo(t);const s=new h.P(v.x,this.m_pannableExtent.ymax);I.lineTo(s)}else{const e=new h.P(b.x,this.m_pannableExtent.ymin);I.lineTo(e);const t=new h.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);I.lineTo(t);const s=new h.P(v.x,this.m_pannableExtent.ymin);I.lineTo(s)}if(I.interpolateAttributesPath(0,w,0),I.getImpl().changeRingStartPoint(S),d>this.m_width360){const e=new o.P({copy:I});E.setShiftCoords(this.m_width360,0),e.applyTransformation(E),I.add(e,!1)}return I}finalizeGeoNormalizeClosedRing(e,t,s){const n=new o.P({vd:e.getDescription()});if(n.add(e,!1),n.hasNonLinearSegments()&&(()=>{const e=n.getPointCount()-2;return n.getSegmentType(e)!==i.G.enumLine})()){const e=new o.S,t=n.getPointCount()-2;n.getSegmentBuffer(t,e,!1),n.removePointFromPath(0,t+1),n.closeLastPathWithSegment(e.get())}else n.removePointFromPath(0,n.getPointCount()-1);const a=r.Envelope2D.constructEmpty();n.queryLooseEnvelope(a);let l=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(l*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+l;)l+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+l;)l-=this.m_width360;if(l+=this.m_width360,0!==l){a.move(l,0);const e=new m.T;e.setShiftCoords(l,0),n.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){const e=n.calculateArea2D(),t=(new Js).execute(n,this.m_pannableSR,!0,this.m_progressTracker);if(t!==n){const s=t.calculateArea2D();(0,h.e)(e)!==(0,h.e)(s)&&t.reverseAllPaths(),n.assignMove(t)}}let e;if(e=new o.P(s?{copy:n}:{move:n}),s)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const t=new m.T;t.setShiftCoords(this.m_width360,0),n.applyTransformation(t),e.add(n,!1)}return e}let g=new o.P({vd:e.getDescription()});g.add(n,!1);const c=t||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 e=new m.T;e.setShiftCoords(this.m_width360,0),n.applyTransformation(e),g.add(n,!1)}if(c){const e=g.calculateArea2D();g.setFillRule(1),g=(new Js).execute(g,this.m_pannableSR,!0,this.m_progressTracker);const t=g.calculateArea2D();(0,h.e)(e)!==(0,h.e)(t)&&g.reverseAllPaths()}return g}geonormalize_ring_(e,t,s,n,r,o,a){(0,i.g)(0)}}function Wn(e){(0,i.g)(0);const t=function(e){const t=new ai({},!0);return t.m_WKID=e,t}(e),s=new Zn;return s.setVertProj_(t),s}function jn(e){return!1}class Zn{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new Ti,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return(0,i.g)(0),0}getID(){return(0,i.g)(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return(0,i.g)(0),""}getTextExtended(e){return(0,i.g)(0),""}getText2(e){return(0,i.g)(0),""}getUnit(){return(0,i.g)(0),{}}equals(e){return(0,i.g)(0),!1}equalForProjection(e){return(0,i.g)(0),!1}getPeVertcsCopy(){return(0,i.g)(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return(0,i.g)(0),0}isDepth(){return(0,i.g)(0),!1}getVerticalShift(){return(0,i.g)(0),0}isCustomWkid(){return!!this.m_peVertSysVal&&this.m_peVertSysVal.isCustomWkid()}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Kn(e,t,s,n,r){if(e.equals(t))return!1;if(n){let s=1,i=0,o=1,a=1,h=0,m=1;Number.isNaN(e.m_heightMetersPerUnit)||(s=e.m_heightMetersPerUnit,i=e.m_heightZ0,o=e.m_heightSign,a=t.m_heightMetersPerUnit,h=t.m_heightZ0,m=t.m_heightSign);const l=o*m*s/a;for(let e=0;e<r;e++)n[e]=(n[e]-i)*l+h}let i=1,a=0;if(Number.isNaN(e.m_XYToRadians)||(i=e.m_XYToRadians/t.m_XYToRadians,a=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,0!==a&&(a=(0,o.b)(a),a/=t.m_XYToRadians)),Array.isArray(s)){const e=s;for(let t=0;t<r;t++)e[t][0]=e[t][0]*i+a,e[t][1]=e[t][1]*i}else{const e=s;for(let t=0;t<r;t++){const s=t<<1;e[s]=e[s]*i+a,e[s+1]=e[s+1]*i}}return!0}function Qn(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(e){this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0,this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees},equals(e){return(0,h.Q)(this.m_heightSign,e.m_heightSign)&&(0,h.Q)(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&(0,h.Q)(this.m_heightZ0,e.m_heightZ0)&&(0,h.Q)(this.m_XYToRadians,e.m_XYToRadians)&&(0,h.Q)(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,t&&(0,i.g)(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){const s=e?e.getPECoordSys():null,n=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Jn{constructor(e){this.m_constantsLoaded=-1,this.m_isUsable=-1,this.m_inputSR=null,this.m_outputSR=null,this.m_inputSRHorz=null,this.m_outputSRHorz=null,this.m_inputVCS=null,this.m_outputVCS=null,this.m_hashCode=0,this.m_areaOfUse=new a.E,this.m_inputUnitParams=Qn(),this.m_outputUnitParams=Qn(),(0,i.g)(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=yo.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const t=this.m_geogTran.getGeogcs1();yo.getCode(t);const s=this.m_geogTran.getGeogcs2();yo.getCode(s),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():((0,i.g)(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||(0,i.d)("vcs not impl");const t=this.m_geogTran.getParameters();null!==t[So.PE_PARM_ND]&&(e=0===t[So.PE_PARM_ND].getValue())}t=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=t}return 0!==t}isUsable(){let e=this.m_isUsable;return-1===e&&(this.m_geogTran?this.m_isUsable=e=this.m_geogTran?1:0:this.m_isUsable=e=this.m_vertTran?1:0),1===e}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return 0===e&&(e=this.m_latestID>0?(0,h.au)(this.m_latestID):(0,h.aA)(this.getText()),0===e&&(e=345),this.m_hashCode=e),e}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():((0,i.t)("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,s,n,r,o;if(this.m_geogTran){const i=this.m_geogTran.getGeogcs1(),a=Ei(i),h=this.m_geogTran.getGeogcs2(),m=Ei(h);let l=-1,g=-1;l=a.getVcsCode(),g=m.getVcsCode(),s=Li(i,null,0,1),n=Li(h,null,0,1),l>0&&g>0?(r=Wn(l),o=Wn(g),e={},t={}):(e=s,t=n)}else(0,i.g)(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=s,this.m_outputSRHorz=n,this.m_inputVCS=r,this.m_outputVCS=o)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=Number.NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_outputUnitParams.m_XYToRadians=Number.NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_vertTran)(0,i.g)(0);else if(this.m_geogTran){const e=this.m_geogTran;let t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function $n(e,t,s,n,r,i,o){let a=null;t&&(a=t.getPEVerticalCoordSys());let h=null;e&&(h=e.getPECoordSys());let m=null;n&&(m=n.getPEVerticalCoordSys());let l=null;if(s&&(l=s.getPECoordSys()),!(h||a||l||m))return!1;const g=Qn();g.initFromGcsAndVcsPe(h,a);const c=Qn();return c.initFromGcsAndVcsPe(l,m),Kn(g,c,r,i,o)}function er(e,t,s,n,r,i,o,a){const h=t,m=e,l=Qn();l.initFromGcsAndVcsPe(m,h),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Kn(l,a,r,i,o)}function tr(e,t,s,n,r,i,o,a,h){const m=Qn(),l=Qn();m.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),l.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),m.processUnitParams(e),l.processUnitParams(m),m.processUnitParams(l),a>0&&Kn(m,l,i,o,a),h.assign(l)}function sr(e,t,s,n,r,i,o){const a=t.getVerttran(),h=t.getGeogtran();if(o.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),i>0){t.prepareOrThrow();const e=s?So.PE_TRANSFORM_2_TO_1:So.PE_TRANSFORM_1_TO_2;a?Kr():Qr(h,i,n,r,e)}}class nr{supportsCurves(){return!0}accelerateGeometry(e,t,s){return rr(e,t,s)}canAccelerateGeometry(e){return ir(e)}}function rr(e,t,s){if(!ir(e))return!1;(0,a.N)(t,e,!1);let n=0;const r=e.getGeometryType();return(0,i.h)(r)&&(0,o.I)(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),(0,i.h)(r)&&(0,o.J)(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function ir(e){return(0,o.I)(e)||(0,o.J)(e)}class or extends nr{getOperatorType(){return 8}execute(e,t,s,n){return $e(e,t,s,1,n)}}class ar{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new hr(e,t,s,n)}execute(e,t,s,n){return this.executeMany(new u.S([e]),new u.S([t]),s,n).next()}}class hr extends c.G{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=s;const r=t.next();this.m_geomSubtractor=r||new o.P}next(){const e=this.m_inputGeoms.next();return e?((0,i.c)(e),(0,i.y)(e),this.m_index=this.m_inputGeoms.getGeometryID(),function(e,t,s,n){if(e.isEmpty()||t.isEmpty())return e;const m=e.getDimension(),g=t.getDimension();if(m>g)return e;const c=e.getGeometryType(),u=t.getGeometryType(),_=new r.Envelope2D,p=new r.Envelope2D,d=new r.Envelope2D;e.queryEnvelope(_),t.queryEnvelope(p),d.setCoords({env2D:_}),d.mergeEnvelope2D(p);const f=(0,a.c)(s,d,!0),x=(0,a.h)(f),P=new r.Envelope2D;if(P.setCoords({env2D:_}),P.inflateCoords(x,x),!P.isIntersecting(p))return e;if(1===m&&2===g){const h=function(e,t,s,n,h){const m=new a.E;e.queryEnvelope(m);const l=new r.Envelope2D;t.queryEnvelope(l),m.merge(l);const g=.1*m.width(),c=.1*m.height();m.inflateCoords(g,c);const u=new o.P;u.addEnvelope(m,!1);const _=u.getImpl();if(s===i.G.enumPolygon){const e=t.getImpl();_.add(e,!0)}else _.addEnvelope(t,!0);return new en(u,n,-1,h).tryFastImplementation(e)}(e,t,u,s,n);if(h)return h}if(c===i.G.enumPoint){let s;switch((0,i.f)(u)?(s=new o.a({vd:t.getDescription()}),s.addSegment(t,!0)):s=t,u){case i.G.enumPolygon:return function(e,t,s){return 0===$t(t,e,s.total())?e:e.createInstance()}(e,s,f);case i.G.enumPolyline:return function(e,t,s){const n=e.getXY(),i=t.querySegmentIterator(),o=(0,a.h)(s),m=o*o;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment(),a=new r.Envelope2D;if(t.queryEnvelope(a),a.inflateCoords(o,o),!a.contains(n))continue;if(t.isIntersectingPoint(n,s.total()))return e.createInstance();let l=t.getStartXY();if(h.P.sqrDistance(n,l)<=m)return e.createInstance();if(l=t.getEndXY(),h.P.sqrDistance(n,l)<=m)return e.createInstance()}return e}(e,s,f);case i.G.enumMultiPoint:return function(e,t,s){const n=t.getImpl().getAttributeStreamRef(0),r=t.getPointCount(),i=e.getXY(),o=(0,a.h)(s),m=o*o,l=new h.P;for(let t=0;t<r;t++)if(n.queryPoint2D(2*t,l),h.P.sqrDistance(l,i)<=m)return e.createInstance();return e}(e,s,f);case i.G.enumEnvelope:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getXY();return n.contains(i)?e.createInstance():e}(e,s,f);case i.G.enumPoint:return function(e,t,s){const n=(0,a.h)(s),r=n*n,i=e.getXY(),o=t.getXY();return h.P.sqrDistance(i,o)<=r?e.createInstance():e}(e,s,f);default:(0,i.a)("invalid shape type")}}else if(c===i.G.enumMultiPoint)switch(u){case i.G.enumPolygon:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getPointCount();let o=!1;const a=(0,h.d)(i,!1),m=new h.P;for(let r=0;r<i;r++)e.queryXY(r,m),n.contains(m)&&0!==es(t,m,s.total())&&(o=!0,a[r]=!0);if(!o)return e;const l=e.createInstance();for(let t=0;t<i;t++)a[t]||l.addPoints(e,t,t+1);return l}(e,t,f);case i.G.enumEnvelope:return function(e,t,s){const n=new r.Envelope2D;t.queryEnvelope(n),n.inflate(s.total());const i=e.getPointCount();let o=!1;const a=(0,h.d)(i,!1),m=new h.P;for(let t=0;t<i;t++)e.queryXY(t,m),n.contains(m)&&(o=!0,a[t]=!0);if(!o)return e;const l=e.createInstance();for(let t=0;t<i;t++)a[t]||l.addPoints(e,t,t+1);return l}(e,t,f);case i.G.enumPoint:return function(e,t,s){const n=e.getImpl().getAttributeStreamRef(0),r=e.getPointCount(),i=t.getXY();let o=!1;const m=(0,h.d)(r,!1),l=(0,a.h)(s),g=l*l,c=new h.P;for(let e=0;e<r;e++)n.queryPoint2D(2*e,c),h.P.sqrDistance(c,i)<=g&&(o=!0,m[e]=!0);if(!o)return e;const u=e.createInstance();for(let t=0;t<r;t++)m[t]||u.addPoints(e,t,t+1);return u}(e,t,f)}const E=new r.Envelope2D(_);return E.inflate(100*f.total()),function(e,t,s,n){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return Fs(Hs(e),e,0,"-");const h=new r.Envelope2D;e.queryEnvelope(h);const m=new r.Envelope2D;t.queryEnvelope(m);const l=new r.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const g=(0,a.c)(s,l,!0),c=m.clone(),u=(0,a.h)(g);if(c.inflateCoords(u,u),!h.isIntersecting(c))return Fs(Hs(e),e,0,"-");const _=new ks(n),p=new o.E,d=p.addGeometry(Hs(e)),f=p.addGeometry(Hs(t));let x=0,P=0,E=null;if(p.hasCurves()){E=new cs;const e=p.getEnvelope2D(n);P=ls(g.total());const t=ms(g.total(),e);x=gs(t,P),os(p,t,g.total(),0,E,null,n)}_.setEditShapeCrackAndCluster(p,g.add(x));const y=_.difference(d,f);null!==E&&E.stitchCurves(p,y,P,!0);const S=Fs(p.getGeometry(y),e,0,"-");return Ss(S.getGeometryType())&&(S.getImpl().setIsSimple(4,g.total()),S.getGeometryType()===i.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}(e,(0,l.c)(t,E,0,0,n),s,n)}(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class mr{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n=0){return new gr(e,t,s,n)}execute(e,t,s,n){const r=new u.S([e,t]),o=new gr(r,s,n,0).next();return o||(0,i.d)("null output"),o}}class lr{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>function(e,t){return h.P.compareZorder(e.location,t.location)?-1:e.location.equals(t.location)?0:1}(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class gr extends c.G{constructor(e,t,s,n,r=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=(0,h.av)(4),this.m_dimGeomCounts=(0,h.d)(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=(0,h.d)(4,!1),this.m_complexUnionGeoms=(0,h.av)(4),this.m_totalNonEmptyGeomCounters=(0,h.d)(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=n,this.m_bIs3D=r}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 e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?(0,i.g)(0):this.m_complexUnionGeoms[e]=(new ar).execute(this.m_complexUnionGeoms[e],this.m_complexUnionGeoms[t],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&(0,i.d)(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.G.enumPoint){const e=new o.M({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}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(e){return this.m_readyGeoms[e]}finishDim(e,t,s){let n=t;if(!s)return 16&this.m_options?(n=Ds([n],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),n):n;if(1&this.m_options)return n;if(1===e)if(8&this.m_options||!(16&this.m_options||this.m_totalNonEmptyGeomCounters[e]>1))1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?(0,i.g)(0):n=(new Js).execute(n,this.m_spatialReference,!1,this.m_progressTracker));else{n=Ds([n],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=n.getImpl().getIsSimple(0,e);(0,i.g)(this.m_bIs3D||(0,a.i)(t))}else this.m_bIs3D?(0,i.g)(0):n=(new Js).execute(n,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&n.getGeometryType()===i.G.enumPoint){const e=new o.M({vd:n.getDescription()});n.isEmpty()||e.add(n),n=e}return n}static getLevel(e){const t=(0,i.v)(e);let s=t>0?(Math.log(t)-Math.log(32))/Math.log(4):0;return s<0&&(s=0),Math.floor(s)}step_(){if(this.m_bDone)return!0;let e;if(this.m_inputGeoms?(e=this.m_inputGeoms.next(),null===e?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,null!==e){const t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let e=0;e<=this.m_maxDimension;e++){for(;this.m_dimGeomCounts[e]>1;){const t=this.collectGeometriesToUnion(e);if(null===t)break;{let s;s=1&this.m_options?Ds(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Vs(t,t.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(e,!0,s)}}if(this.m_bDone&&((0,i.g)(this.m_dimGeomCounts[e]<=1),0!==this.m_dimGeomCounts[e])){const t=this.m_unionBins[e].entries().next().value,s=t[1].geomPairs()[0].geom,n=t[1].geomPairs()[0].bUnioned;this.m_unionBins[e].clear(),this.m_readyGeoms[e]=this.finishDim(e,s,n)}}return this.m_bDone}addGeom(e,t,s){const n={geom:null,vertexCount:-1,bUnioned:!1,location:new h.P};n.geom=s;const o=(0,i.v)(s);n.vertexCount=o;const a=r.Envelope2D.constructEmpty();s.queryEnvelope(a),n.location=o>0?a.getCenter():new h.P(0,0);const m=gr.getLevel(s);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let l=null;const g=this.m_unionBins[e].get(m);g&&(l=g),null===l&&(l=new lr,this.m_unionBins[e].set(m,l)),n.bUnioned=t,l.addPair(n),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(1&this.m_options&&!this.m_bDone)return null;let t=null;const s=[];for(const t of this.m_unionBins[e].keys())s.push(t);(0,h.v)(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const r=this.m_unionBins[e].get(s[n]);{const i=5e3,o=4,a=r.getBinVertexCount()>i&&r.geomCount()>=o;if(this.m_bDone||a){for(let r=0;r<n;r++){if(-1===s[r])continue;const n=this.m_unionBins[e].get(s[r]);n.sort(),this.m_dimGeomCounts[e]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const e of n.geomPairs())t||(t=new Array),t.push(e.geom);n.clear(),this.m_unionBins[e].delete(s[r]),s[r]=-1}r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(const e of r.geomPairs())t||(t=new Array),t.push(e.geom);if(r.clear(),this.m_unionBins[e].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&(0,i.A)(),e.hasAttribute(1)||(0,i.a)("Geometry must have Zs")),(0,i.c)(e)}}class cr extends nr{getOperatorType(){return 3}execute(e,t,s,n=null){return $e(e,t,s,4,n)}}function ur(e,t,s){const n=t.getGCSSplitLines();if(null===n)return e;const l=t.getGCS(),g=l.getPannableExtent().width(),c=r.Envelope2D.constructEmpty();e.queryLooseEnvelope(c);const u=h.E.constructEmpty();c.queryIntervalX(u);const _=n.querySegmentIterator();let p=null;const d=new m.T;for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment(),t=e.queryInterval(0,0),s=h.E.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>u.vmin;)s.move(-g),n--;for(;s.vmin<=u.vmax;){if(s.isIntersecting(u)){null===p&&(p=new o.a);const t=new o.L({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(d.setShiftCoords(n*g,0),t.applyTransformation(d)),p.addSegment(t,!0)}s.move(g),++n}}if(null!==p){const t=(0,a.e)(l,p,!0);return function(e,t,s,n){const r=t.getGeometryType();if((0,i.h)(r))return new be(n).crackAWithBMultiPath_(e,t,s);(0,i.t)("crack_A_with_B")}(e,p,(0,a.h)(t),s)}return e}function _r(e,t,s){let n=e.getName();return to(n)||(s||t>0?(n=e.toString(So.PE_STR_NAME_CANON|So.PE_STR_AUTH_NONE),n=function(e){return e.toLocaleUpperCase("en-US")}(n)):n=e.toString(So.PE_STR_AUTH_TOP)),n}function pr(e,t=-1){if((t>1||t<-1)&&(0,i.a)("verbosity"),-1===t)return e.toString();{const s=0===t?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL;return e.toString(s)}}function dr(e,t,s,n){if(e.isEmpty()||1===s)return e;const o=e.getGeometryType();if(o===i.G.enumPoint){const n=e,r=n.getXY();return 0===Pr([r],1,t,s)||r.isNAN()?n.setEmpty():n.setXY(r),e}if(o===i.G.enumMultiPoint){const n=e,r=e.createInstance(),i=n.getPointCount();r.reserve(i);const o=n.getAttributeStreamRef(0),h=n.getDescription().getAttributeCount()>1,m=new a.P,l=Float64Array.from(o.getArray());if(Pr(l,i,t,s)>0)for(let e=0,t=2*i;e<t;e+=2)Number.isNaN(l[e])||(h?(n.getPointByVal(e>>1,m),m.setXYCoords(l[e],l[e+1]),r.add(m)):r.addXY(l[e],l[e+1]));return r}let h=e;const g=t.getOneDegreeGCSUnit(),c=90*g,u=180*g,_=360*g,p=t.getCentralMeridian(),d=.5*g,f=r.Envelope2D.constructEmpty();h.queryEnvelope(f);const x=t.getGCSHorizon(),P=t.getGCSHorisonIsInclusive(),E=x.getGeometryType()===i.G.enumEnvelope,y=r.Envelope2D.constructEmpty();x.queryEnvelope(y);const S=t.getGCS();if(2!==s&&4!==s||(y.xmin=p-u,y.xmax=y.xmin+_),4===s){if(!(f.width()>_-g)){const e=r.Envelope2D.constructEmpty();e.setCoords({xmin:f.xmin-g,ymin:y.ymin,xmax:f.xmax+g,ymax:y.ymax}),h=(new l.O).execute(h,e,S,n);let t=Math.floor((p-f.getCenterX())/_);for(f.move(t*_,0);f.xmin>y.xmax;)t-=1,f.move(-_,0);for(;f.xmin<y.xmin;)t+=1,f.move(_,0);if(0!==t){const e=new m.T;e.setShiftCoords(t*_,0),h.applyTransformation(e)}return h}s=2}if(2===s&&(y.xmin=p-u,y.xmax=y.xmin+_),f.ymin<-c||f.ymax>c){const e=r.Envelope2D.constructEmpty();if(e.setCoords({xmin:f.xmin-g,ymin:-c,xmax:f.xmax+g,ymax:c}),h=(new l.O).execute(h,e,S,n),h.isEmpty())return h;h.queryEnvelope(f)}if(P&&(y.ymax<f.ymin||y.ymin>f.ymax))return h.createInstance();f.width()>_&&(h=Nr(h,p-u,_,S,!0,0,!0,n),h.queryEnvelope(f));let C=function(e,t,s,n,r){return e>=s&&t<=n?0:wr(.5*(t+e),s,n,r)}(f.xmin,f.xmax,y.xmin,y.xmax,_);if(0!==C&&f.move(C,0),f.xmax>y.xmax||f.xmin<y.xmin){if(f.xmax>y.xmax)for(;f.xmin>=y.xmax;)f.move(-_,0),C-=_;for(;f.xmin<y.xmax-_;)f.move(_,0),C+=_}const I=(0,a.N)(S,x,!1);if(0!==C){const e=new m.T;e.setShiftCoords(C,0),h.applyTransformation(e),C=0}if(P){if(E&&y.containsEnvelope(f))return h;const e=new Array(2);for(let t=0;t<2;t++){let s;if(E?s=(0,i.h)(o)?(0,l.c)(h,y,I,d,n):(0,l.c)(h,y,I,0,n):(s=(new sn).execute(h,x,S,n),s===x&&(s=s.clone())),y.xmin<=f.xmin&&y.xmax>=f.xmax)return s;if(y.xmin>=f.xmin&&y.xmax<=f.xmax)return s;if(e[t]=s,0===t){f.move(-_,0);const e=new m.T;e.setShiftCoords(-_,0),h.applyTransformation(e)}}return(0,i.h)(o)?e[0].add(e[1],!1):(0,i.d)("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(y.ymax<f.ymin||y.ymin>f.ymax)return h;let e=0;for(;!h.isEmpty()&&f.xmax>y.xmin;){if(0!==e){const t=new m.T;t.setShiftCoords(e,0),h.applyTransformation(t)}if((new cr).execute(h,x,S,n)||(h=(new ar).execute(h,x,S,n),x===h&&(h=h.clone())),0!==e){const t=new m.T;t.setShiftCoords(-e,0),h.applyTransformation(t)}e-=_,f.move(-_,0)}return h}}function fr(e,t,s,r,i,m){const l={stack:[],error:void 0,hasError:!1};try{if(2===m)return function(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>h.o||Math.abs(n.y)>h.o)return Number.NaN;if((Math.abs(s.y)===h.o||Math.abs(n.y)===h.o)&&s.x!==n.x)return Number.NaN;const{first:i,second:m}=(0,h.aE)(s.x,n.x);let l=r;if(l=I(l,i,m),!h.E.construct(s.x,n.x).containsCoordinate(l))return Number.NaN;const g=o._.constructPoint2D(s),c=o._.constructPoint2D(n),u=G(1,t,g),_=G(1,t,c),p=u.crossProductVector(_);if(p.z.isZero())return s.y;const d=p.x.divE(p.z.negate()),f=p.y.divE(p.z.negate()),x=d.mulE(d).addE(f.mulE(f)).sqrt();if(x.isZero()||d.isZero()&&f.isZero())return s.y;const P=Math.atan2(f.value(),d.value());let E=Math.atan2(x.value()*Math.cos(P-l),1-t);const y=v(1,t,h.P.construct(l,E)),S=a.f.construct(y.x,y.y,-y.z),C=p.value().dotProduct(y),b=p.value().dotProduct(S);return Math.abs(b)<Math.abs(C)&&(E=-E),E}(0,t,s,r,i);if(Math.abs(s.x-r.x)>=Math.PI||!si(s.x,r.x,i))return Number.NaN;s.x>r.x&&(r=(0,h.c)(s,s=r));const g=(0,n.mS)(l,new Eo,!1),c=(0,n.mS)(l,new Eo,!1),u=(0,n.mS)(l,new Eo,!1),_=s.clone();wo.geodeticDistance(e,t,s.x,s.y,r.x,r.y,c,g,null,m);const p=c.val;let d=0,f=1;for(;p*(f-d)>1e-12*e;){const n=.5*(d+f);if(wo.geodeticCoordinate(e,t,s.x,s.y,p*n,g.val,c,u,m),_.x=c.val,_.y=u.val,_.x===i)return _.y;if(si(s.x,_.x,i))f=n;else{if(!si(r.x,_.x,i))return Number.NaN;d=n}}return _.y}catch(e){l.error=e,l.hasError=!0}finally{(0,n.hk)(l)}}function xr(e,t,s,n){for(let r=0,i=0;r<n;r++,i+=2)t[s+r].x=e[i],t[s+r].y=e[i+1]}function Pr(e,t,s,n){if(0===t||1===n)return t;const o=function(e,t){let s;if(Array.isArray(e)){const n=e;s=new Float64Array(2*t);for(let e=0,r=0;e<t;e++,r+=2)s[r]=n[e].x,s[r+1]=n[e].y}else s=e;return s}(e,t);if(2===n){const n=s.getPannableExtentInGCS();let r=t;for(let e=0,s=2*t;e<s;e+=2)(o[e+1]>n.ymax||o[e+1]<n.ymin)&&(o[e]=Number.NaN,r--);return r?(Tr(o,t,n.xmin,n.width(),!0),e!==o&&xr(o,e,0,t),r):(e!==o&&xr(o,e,0,t),0)}const m=s.getOneDegreeGCSUnit(),l=90*m,g=180*m,c=360*m;let u=t;for(let e=0,s=2*t;e<s;e+=2)(o[e+1]>l||o[e+1]<-l)&&(o[e]=Number.NaN,u--);if(!u)return e!==o&&xr(o,e,0,t),0;const _=r.Envelope2D.constructEmpty();_.setFromPoints(o,t);const p=s.getGCSHorizon(),d=s.getGCSHorisonIsInclusive(),f=p.getGeometryType()===i.G.enumEnvelope,x=r.Envelope2D.constructEmpty();if(p.queryEnvelope(x),d&&(x.ymax<_.ymin||x.ymin>_.ymax))return e!==o&&xr(o,e,0,t),0;if(d)if(Tr(o,t,x.getCenterX()-g,c,!0),u=t,f)for(let e=0,s=2*t;e<s;e+=2)x.containsCoords(o[e],o[e+1])||(o[e]=Number.NaN,u--);else{const e=(0,a.N)(s.getGCS(),p,!1),n=new h.P;for(let s=0,r=2*t;s<r;s+=2)n.setCoords(o[s],o[s+1]),0!==es(p,n,e)||(o[s]=Number.NaN,u--)}else{Tr(o,t,-g,c,!0),u=t;const e=(0,a.N)(s.getGCS(),p,!1),n=new h.P;for(let s=0,r=2*t;s<r;s+=2){n.setCoords(o[s],o[s+1]),n.isNAN()&&u--;const t=wr(n.x,x.xmin,x.xmax,c);n.x+=t,0!==es(p,n,e)&&(o[s]=Number.NaN,u--)}}return e!==o&&xr(o,e,0,t),u}function Er(e,t,s,n,r,o){if(t.isPannable()||(0,i.a)("fold_into_360_degree_range"),e.isEmpty())return e;let a,h;if(2===t.getCoordinateSystemType()){const e=t.getPannableExtent();h=e.xmin,a=e.width()}else{const e=t.getOneDegreeGCSUnit();a=360*e,h=s-180*e}return Nr(e,h,a,t,n,r,!0,o)}function yr(e,t,s,n){let r,i;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();r=e.xmin,i=e.width()}else{const e=s.getOneDegreeGCSUnit();i=360*e,r=n-180*e}Tr(e,t,r,i)}function Sr(e,t){const s=t.width();let n=(0,h.l)(e-t.vmin,s);return n<0&&(n+=s),t.snapClip(n+t.vmin)}function Cr(e,t,s){return e>t.xmax&&e-t.xmax<s?t.xmax:e<t.xmin&&t.xmin-e<s?t.xmin:e}function Ir(e,t,s){if(e[0]<t.vmin||e[0]>t.vmax||s&&e[0]===t.vmax){const s=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/s)*s,e[0]=t.snapClip(e[0]),!0}return!1}function vr(e,t,s,n,r){const i=new o.E,h=i.addGeometry(e);return br(i,h,t,(0,a.N)(t,e,!1),s,n,r),i.getGeometry(h)}function br(e,t,s,r,a,m,l){const g={stack:[],error:void 0,hasError:!1};try{(0,i.g)(Oi()),s.isPannable()||(0,i.q)("insert_geodetic_points");const c=s.getPannableExtent(),u=s.getGCS(),_=Ui();u.querySpheroidData(_);const p=u.getUnit().getUnitToBaseFactor(),d=_.majorSemiAxis,f=_.e2;let x=0;const P=new h.E;c.queryIntervalX(P);let E=null;const y=(0,h.d)(4,Number.NaN);2===s.getCoordinateSystemType()?(E=s.getPECoordSys(),m?(y[0]=Sr(l,P),y[1]=c.getCenterY(),Co.projToGeog(E,1,y),x=y[0]*p):(y[0]=c.getCenterX(),y[1]=l,Co.projToGeog(E,1,y),x=y[1]*p)):x=l*p,m||0===x||2===a||(0,i.q)("insert_geodetic_points: 1");const S=(0,n.mS)(g,new Eo,!1),C=new h.P,I=new h.P,v=new h.P,b=new h.P,G=new h.P,w=new h.P;for(let n=e.getFirstPath(t);n!==o.n;n=e.getNextPath(n)){const t=e.getFirstVertex(n);e.queryXY(t,v);let i=!1;const g=e.getNextVertex(t);for(let t=g;t!==o.n;t=e.getNextVertex(t)){if(t===g){if(i)break;i=!0}if(e.queryXY(t,b),m&&(r<l-v.x&&b.x-l>r||r<l-b.x&&v.x-l>r)||!m&&(0!==l||r<-v.y&&b.y>r||r<-b.y&&v.y>r))do{if(Math.abs(v.x-b.x)>=.5*P.width())break;2===s.getCoordinateSystemType()?(y[0]=Sr(v.x,P),y[1]=v.y,y[2]=Sr(b.x,P),y[3]=b.y,Br(E,2,y,0),G.x=y[0]*p,G.y=y[1]*p,w.y=y[3]*p):(G.x=v.x*p,G.y=v.y*p,w.y=b.y*p),w.x=(b.x-v.x)*Math.PI*2/P.width()+G.x;let n=0;const r=(0,h.m)(h.P,2);if(m){if(I.x=x,I.y=fr(d,f,G,w,x,a),Number.isNaN(I.y))break;r[0]=I,n=1}else if(2===a){const e=[0,0];if(n=V(0,f,G,w,x,e),!n)break;r[0].x=e[0],r[0].y=x,2===n&&(r[1].x=e[1],r[1].y=x)}else{if(I.x=ni(d,f,G,w,a),Number.isNaN(I.x))break;I.y=0,r[0]=I,n=1}let i=-1;for(let o=0;o<n;o++){wo.geodeticDistance(d,f,G.x,G.y,w.x,w.y,S,null,null,a);const n=S.val;wo.geodeticDistance(d,f,G.x,G.y,r[o].x,r[o].y,S,null,null,a);const g=S.val;2===s.getCoordinateSystemType()?(y[0]=r[o].x/p,y[1]=r[o].y/p,Co.geogToProj(E,1,y),m?(C.y=y[1],C.x=l):(C.x=ri(y[0],v.x,b.x,P),C.y=l)):m?(C.x=l,C.y=r[o].y/p):(C.x=ri(r[o].x/p,v.x,b.x,P),C.y=l);const c=n>0?(0,h.s)(g/n,0,1):.5;if(0===c||1===c)continue;if(i>c)continue;const u=e.getPrevVertex(t);e.splitSegment(u,[c],1);const _=e.getNextVertex(u);e.setXYCoords(_,C.x,C.y),i=c}}while(0);v.setCoordsPoint2D(b)}}}catch(e){g.error=e,g.hasError=!0}finally{(0,n.hk)(g)}}function Gr(e,t){(0,i.g)(t.isPannable());const s=t.getPannableExtent();if(e.getGeometryType()===i.G.enumPoint){const t=e.getY();return s.ymin<=t&&t<=s.ymax?e:e.createInstance()}const n=r.Envelope2D.constructEmpty();e.queryEnvelope(n);const o=r.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.xmin=n.xmin,o.xmax=n.xmax,o.inflateCoords(.01*o.height(),0);const h=(0,a.d)(t,n,!1);let m;return m=o.containsEnvelope(n)?e:(0,l.c)(e,o,h,0,null),m}function wr(e,t,s,n){return(0,h.ax)((.5*(s+t)-e)/n)*n}function Nr(e,t,s,n,a,g,c,u){const _=e.getGeometryType(),p=h.E.constructEmpty();p.setCoords(t,t+s);const d=[0];if(_===i.G.enumPoint){const t=e;if(d[0]=t.getX(),Ir(d,p,c)){const t=a?e:e.clone();return t.setX(d[0]),t}return e}const f=r.Envelope2D.constructEmpty();if(e.queryEnvelope(f),f.isEmpty())return e;if(_===i.G.enumMultiPoint){const t=a?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let i=!1;for(let e=0;e<r;e+=2)d[0]=n.read(e),Ir(d,p,c)&&(n.write(e,d[0]),i=!0);return i&&s.notifyModifiedFlags(2001),t}const x=h.E.constructEmpty();if(f.queryIntervalX(x),p.contains(x))return p.vmax,x.vmax,e;const P=r.Envelope2D.constructEmpty();if(P.setCoords({env2D:f}),0===x.width()){let t=x.vmin;t+=Math.ceil((p.vmin-t)/s)*s,t=p.snapClip(t);const n=a?e:e.clone();return n.setAttributeBasic(0,0,t),n}if(_===i.G.enumEnvelope){const t=a?e:e.clone();return f.intersect(P),t.setEnvelope(f),t}const E=.1*Math.max(f.height(),f.width())*1;P.inflateCoords(0,E);let y=e;const S=n.getTolerance(0),C=new m.T;for(;;){const e=Math.floor((x.vmin-t)/s),r=Math.ceil((x.vmax-t)/s);if(!(r-e>3))break;{const o=Math.floor(.5*(r+e));P.xmin=f.xmin-E,P.xmax=t+s*o;const a=(0,l.c)(y,P,S,g,u);P.xmin=P.xmax,P.xmax=f.xmax+E;const h=(0,l.c)(y,P,S,g,u);C.setShiftCoords((o-r)*s,0),h.applyTransformation(C),_===i.G.enumPolygon?y=(new mr).execute(a,h,n,u):(y=a,y.add(h,!1)),y.queryEnvelope(f),f.queryIntervalX(x)}}P.xmin=t,P.xmax=t+s;const I=r.Envelope2D.constructEmpty();I.setCoords({env2D:P}),I.inflateCoords(S,0);const v=Math.floor((f.xmin-P.xmin)/s)*s;let b;v?(P.move(v,0),C.setShiftCoords(-v,0)):C.setIdentity(),b=_===i.G.enumPolyline?new o.a({vd:y.getDescription()}):new o.P({vd:y.getDescription()});const G=r.Envelope2D.constructEmpty(),w=r.Envelope2D.constructEmpty();for(;f.xmax>P.xmin;){const e=(0,l.c)(y,P,S,0,u);e.queryEnvelope(w);let t=!1;t=_===i.G.enumPolyline?!e.isEmpty()&&(w.width()>S||w.height()>S):!e.isEmpty()&&(_!==i.G.enumPolygon||w.width()>S),t&&(e.applyTransformation(C),e.queryEnvelope(w),b.queryEnvelope(G),G.inflateCoords(S,S),G.isIntersecting(w)&&_===i.G.enumPolygon?b=(new mr).execute(b,e,n,u):b.add(e,!1)),P.move(s,0),C.shiftCoords(-s,0)}return b}function Tr(e,t,s,n,r=!0){const i=new h.E;i.setCoords(s,s+n);const o=[0];if(Array.isArray(e)){const s=e;for(let e=0;e<t;e++)i.containsRightExclusive(s[e].x)||(o[0]=s[e].x,Ir(o,i,r),s[e].x=o[0])}else{const s=e;for(let e=0;e<t;e++){const t=e<<1;i.containsRightExclusive(s[t])||(o[0]=s[t],Ir(o,i,r),s[t]=o[0])}}}function Dr(e,t,s,n=!0){if(e.isEmpty())return;const o=e.getGeometryType();if(!n||o!==i.G.enumPolygon)if((0,i.i)(o)){let n=!1;if((0,i.h)(o)&&e.hasNonLinearSegments()){const r=e.getImpl(),o=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();(0,i.g)(null!==a);for(let e=0,i=r.getPathCount();e<i;e++){let i=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);h&&r.getPathSize(e)>0&&(i=1==(31&a.read(m-1)));for(let h=r.getPathStart(e);h<m;h++)if(1==(31&a.read(h))){if(i){const e=o.read(2*h),r=Cr(e,t,s);r!==e&&(n=!0,o.write(2*h,r))}i=!0}else i=!1}}else{const r=e.getImpl(),i=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){const r=i.read(2*e),o=Cr(r,t,s);o!==r&&(n=!0,i.write(2*e,o))}}n&&e.getImpl().notifyModifiedFlags(2001)}else if(o===i.G.enumEnvelope){const n=e,i=r.Envelope2D.constructEmpty();n.queryEnvelope(i),i.xmin=Cr(i.xmin,t,s),i.xmax=Cr(i.xmax,t,s),n.setEnvelope(i)}else if(o===i.G.enumPoint){const n=e;n.setX(Cr(n.getX(),t,s))}else(0,i.d)("")}function Vr(e,t,s){const n=new h.P;return n.x=Cr(e.x,t,s),n.y=e.y,n}function kr(e,t,s,n){const o=e.getGeometryType();(0,i.g)(o===i.G.enumPolygon||o===i.G.enumPolyline||o===i.G.enumMultiPoint);const m=t.getCoordinateSystemType();if(2===m){let m=e;if(0===s){const s=function(e,t){if(t.isEmpty())return 0;const s=e.getPECoordSys();if(s.getProjection().getCode()===So.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Ui();e.querySpheroidData(n);const i=s.getParameters();if(null===i[So.PE_PARM_LAM0])return 0;if(null===i[So.PE_PARM_PHI0])return 0;const o=[i[So.PE_PARM_LAM0].getValue(),i[So.PE_PARM_PHI0].getValue()];Co.geogToProj(s,1,o);const a=new h.P(o[0],o[1]),m=r.Envelope2D.constructEmpty();t.queryEnvelope(m);const l=(0,h.m)(h.P,4);m.queryCorners(l);let g=0;const c=e.getOneMeter();let u=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,_=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;_-=u/180,u*=c,_*=c;for(let e=0;e<4;e++){const t=h.P.distance(l[e],a);if(t>u)g++;else if(t>_)return-1}if(0===g)return 1;if(4===g){const e=r.Envelope2D.constructEmpty();return e.setCoords({center:a,width:u,height:u}),m.isIntersectingNe(e)?-1:0}return-1}return-1}(t,e);if(0===s)return e.createInstance();if(1===s)return e;const o=t.getPCSHorizon(),g=o.getGeometryType(),c=t.getDefaultPrecisionSR();if(g===i.G.enumEnvelope){const s=r.Envelope2D.constructEmpty();o.queryEnvelope(s);const i=(0,a.d)(c,s,!1);m=(0,l.c)(e,s,i,5e4*t.getOneMeterPCSUnit(),n)}else(new or).execute(o,e,c,n)||(m=(new sn).execute(m,o,c,n),m===o&&(m=m.clone()))}else if(t.isPannable()){const e=r.Envelope2D.constructEmpty();m.queryEnvelope(e);const a=t.getPannableExtent();a.containsEnvelope(e)||(Dr(m,a,t.getTolerance(0)),2!==s&&4!==s||(m=Gr(m,t)),4!==s?m=Er(m,t,0,!0,1e5*t.getOneMeterPCSUnit(),n):o===i.G.enumPolygon&&e.width()>2*a.width()&&(m=Nr(m,-2*a.width(),2*a.width(),t,!0,0,!0,n)))}return m}if((0,i.g)(1===m),o===i.G.enumMultiPoint)return Dr(e,t.getPannableExtent(),t.getTolerance(0)),e;{const s=r.Envelope2D.constructEmpty();e.queryEnvelope(s);let a=e;const h=t.getPannableExtent();if(s.ymin<h.ymin||s.ymax>h.ymax){const e=Math.max(1,s.calculateToleranceFromEnvelope()),i=new r.Envelope2D(s.xmin-e,h.ymin,s.xmax+e,h.ymax);if(a=(new l.O).execute(a,i,t,n),a.isEmpty())return a}return o===i.G.enumPolygon&&s.width()>2*h.width()&&(a=Nr(a,-2*h.width(),2*h.width(),t,!0,0,!0,n)),a}}function Fr(e,t){const s=t.getPointCount();if(!s)return;const n=t.getImpl(),r=n.getAttributeStreamRef(0),i=e;Co.geogToProj(i,s,r.getArray()),n.notifyModifiedFlags(2001)}function Hr(e,t,s,n){if(!s)return;const r=e.getPECoordSys();if(1===s){if(t[0].isNAN())return;const s=[t[0].x,t[0].y];if(Co.geogToProj(r,1,s),n){const{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(t[0].x-e.getCentralMeridian())+r}return void t[0].setCoords(s[0],s[1])}const i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let m=0;i&&(m=e.getCentralMeridian());const l=new Float64Array(512);for(let g=0;g<s;){for(let e=g;e<s&&t[e].isNAN();++e)g++;let c=Math.min(256,s-g);if(c>0){for(let e=1,s=g+1;e<c;++e,++s)if(t[s].isNAN()){c=e;break}for(let e=0;e<c;++e){const s=e<<1;l[s]=t[g+e].x,l[s+1]=t[g+e].y}if(Co.geogToProj(r,c,l),n){const{first:s,second:n}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<c;++e)l[e<<1]=s*(t[g+e].x-m)+n}if(i)for(let e=0,s=g;e<c;e++,s++){const n=e<<1,r=l[n],i=(0,h.e)(r),g=t[s].x-m;i*(0,h.e)(g)<0&&Math.abs(r)>a&&(l[n]-=i*o)}xr(l,t,g,c),g+=c}}}function Ar(e,t,s,n){const i=new o.M({vd:t.getDescription()});let a;i.addPoints(t,0,-1),a=(new cn).execute(i,e,n);const h=t.getPointCount();if(s.setEmpty(),e.getInputSR().isPannable()){if(h!==a.getPointCount())return!1;const n=new r.Envelope2D;t.queryEnvelope(n);const i=new r.Envelope2D;a.queryEnvelope(i);const o=n.width(),m=i.width();if(0!==o&&0!==m){const t=m/o,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==o||0!==m)return!1;s.add(t,!1);for(let e=0;e<h;e++){const t=a.getXY(e);s.setXY(e,t)}return!0}return!1}function Mr(e,t,s){(0,i.g)(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),o=r.getAttributeStreamRef(0),a=e.getPECoordSys();let m=0;const l=o.readRange(0,2*n);let g=()=>{Co.geogToProj(a,n,l)};const c=e.isPannable()&&!s,u=c?e.getPannableExtent().width():0,_=179*u/360;if(e.isPannable()&&(m=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;g=()=>{Co.geogToProj(a,n,l);for(let e=0;e<n;e++){const t=e<<1,n=o.read(t),i=s*(n-m)+r;l[t]=i}}}if(g(),c)for(let e=0;e<n;e++){const t=e<<1,s=l[t],n=(0,h.e)(s),r=o.read(t)-m;n*(0,h.e)(r)<0&&Math.abs(s)>_&&(l[t]+=-n*u)}o.writeRangeFromArray(0,2*n,l,!0,1),r.notifyModifiedFlags(2001)}function Ur(e,t,s){switch(t.getGeometryType()){case i.G.enumLine:return void function(e,t,s){const n=[t.getStartXY(),t.getEndXY()];Hr(e,n,2,s),t.setStartXY(n[0]),t.setEndXY(n[1]),t.normalizeAfterEndpointChange()}(e,t,s);case i.G.enumBezier:return void function(e,t,s){const n=(0,h.m)(h.P,4);t.queryControlPoints(n),$r(e,n,4,s),t.setControlPoints(n)}(e,t,s);case i.G.enumEllipticArc:return void function(e,t,s){if(0===t.projectionBehavior())!function(e,t,s){ti(!0,e,0,t,s)}(e,t,s);else{const n=t.isClosed()&&t.isMajor(),r=[t.getStartXY(),n?t.getCenter():t.getEndXY()],i=[r[0].clone(),r[1].clone()];$r(e,i,2,s);const o=new m.T;o.initializeFromTwoPointsArray(r,i),t.applyTransformation(o);const a=n?0:1;t.setCoordsForIntersector(i[0],i[a],!1)}}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return void(0,i.g)(0);default:(0,i.d)("")}}function qr(e,t,s){if(!t.hasNonLinearSegments())return void Mr(e,t,s);if((0,i.g)(!s||e.isPannable()),t.isEmpty())return;const n=e.getPECoordSys(),r=e.isPannable(),m=r?e.getPannableExtent().width():0,l=179*m/360;let g=0;r&&(g=e.getCentralMeridian());const c=t.createInstance();c.reserveParts(t.getPointCount(),t.getPathCount());const u=t.getImpl(),_=new o.S;for(let i=0,o=t.getPathCount();i<o;++i)if(u.hasNonLinearSegmentsPath(i)){let t=!0,n=-1;const r=u.getPathStart(i),o=r+u.getSegmentCountPath(i);u.isClosedPath(i)&&(n=o-1);const m=new h.P;for(let i=r;i<o;++i){if(u.getSegmentBuffer(i,_,!1),Ur(e,_.get(),s),t||_.get().getStartXY().equals(m)||_.get().moveTo(m),i!==n)c.addSegment(_.get(),t);else{if(t){const e=new a.P;_.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(_.get())}m.assign(_.get().getEndXY()),t=!1}}else{const e=1024;let s,o=u.getPathSize(i),a=Math.min(o,e);c.insertPath(-1,t,i,!0);const _=u.getAttributeStreamRef(0),p=c.getAttributeStreamRef(0);for(let t=u.getPathStart(i),c=u.getPathEnd(i);t<c;){if(s=_.readRange(t,a),Co.geogToProj(n,a,s),r)for(let e=0;e<a;e++){const t=e<<1,n=s[t],r=(0,h.e)(n),i=_.read(2*(0+e))-g;r*(0,h.e)(i)<0&&Math.abs(n)>l&&(s[t]+=-r*m)}p.writeRangeFromArray(t,a,s,!0,1),t+=a,o-=a,a=Math.min(o,e)}}t.assignMove(c)}function Or(e,t,s){let n=s.getPointCount();if(!n)return;const r=s.getImpl(),i=r.getAttributeStreamRef(0);let o=Math.min(n,1e3),a=0;const m=e.getPECoordSys();Number.isNaN(t)&&(t=0);const l=e.isPannable(),g=e.getOneDegreeGCSUnit(),c=360*g,u=179*g;let _;for(;n;){if(_=i.readRange(2*a,2*o),Br(m,o,_,t),l)for(let e=0;e<o;e++){const s=e<<1,n=_[s]-t,r=(0,h.e)(n),o=i.read(2*(a+e));r*(0,h.e)(o)<0&&Math.abs(n)>u&&(_[s]+=-r*c)}i.writeRangeFromArray(2*a,2*o,_,!0,1),a+=o,n-=o,o=Math.min(n,1e3)}r.notifyModifiedFlags(2001)}function Yr(e,t,s){switch(s.getGeometryType()){case i.G.enumLine:return void function(e,t,s){const n=[s.getStartXY(),s.getEndXY()];Xr(e,t,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}(e,t,s);case i.G.enumBezier:return void function(e,t,s){const n=(0,h.m)(h.P,4);s.queryControlPoints(n),ei(e,t,n,4),s.setControlPoints(n)}(e,t,s);case i.G.enumEllipticArc:return void function(e,t,s){if(0===s.projectionBehavior())!function(e,t,s){ti(!1,e,t,s,!1)}(e,t,s);else{const n=s.isClosed()&&s.isMajor(),r=[s.getStartXY(),n?s.getCenter():s.getEndXY()],i=[r[0].clone(),r[1].clone()];ei(e,t,i,2);const o=new m.T;o.initializeFromTwoPointsArray(r,i),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(i[0],i[a],!1)}}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return void(0,i.g)(0);default:(0,i.d)("")}}function Br(e,t,s,n){const r=Co.projToGeogCenter(e,t,s,n);for(let e=0;e<t;++e){const t=e<<1;(0,i.g)(Number.isFinite(s[t]+s[t+1]))}return r}function Rr(e,t,s){if(!s.hasNonLinearSegments())return void Or(e,t,s);if(s.isEmpty())return;const n=e.getPECoordSys();Number.isNaN(t)&&(t=0);const r=e.isPannable(),i=e.getOneDegreeGCSUnit(),m=360*i,l=179*i,g=s.createInstance();g.reserveParts(s.getPointCount(),s.getPathCount());const c=s.getImpl(),u=new o.S;for(let i=0,o=s.getPathCount();i<o;++i)if(c.hasNonLinearSegmentsPath(i)){let s=!0,n=-1;const r=c.getPathStart(i),o=r+c.getSegmentCountPath(i);c.isClosedPath(i)&&(n=o-1);const m=new h.P;for(let i=r;i<o;++i){if(c.getSegmentBuffer(i,u,!1),Yr(e,t,u.get()),s||u.get().getStartXY().equals(m)||u.get().moveTo(m),i!==n)g.addSegment(u.get(),s);else{if(s){const e=new a.P;u.get().queryStart(e),g.startPathPoint(e)}g.closeLastPathWithSegment(u.get())}m.assign(u.get().getEndXY()),s=!1}}else{const e=1e3;let o,a=c.getPathSize(i),u=Math.min(a,e);g.insertPath(-1,s,i,!0);const _=c.getAttributeStreamRef(0),p=g.getAttributeStreamRef(0);for(let s=c.getPathStart(i),g=c.getPathEnd(i);s<g;){if(o=_.readRange(2*s,2*u),Br(n,u,o,t),r)for(let e=0;e<u;e++){const n=e<<1,r=o[n]-t,i=(0,h.e)(r),a=_.read(2*s);i*(0,h.e)(a)<0&&Math.abs(r)>l&&(o[n]+=-i*m)}p.writeRangeFromArray(2*s,2*u,o,!0,1),s+=u,a-=u,u=Math.min(a,e)}}s.assignMove(g)}function Xr(e,t,s,n){const r=e.getPECoordSys();Number.isNaN(t)&&(t=0);const i=e.isPannable(),o=e.getOneDegreeGCSUnit(),a=360*o,m=179*o,l=new Float64Array(512);for(let e=0;e<n;){for(let t=e;t<n&&s[t].isNAN();++t)e++;let o=Math.min(256,n-e);if(o>0){for(let t=1,n=e+1;t<o;++t,++n)if(s[n].isNAN()){o=t;break}for(let t=0;t<o;t++){const n=t<<1;l[n]=s[e+t].x,l[n+1]=s[e+t].y}if(Br(r,o,l,t),i)for(let n=0,r=e;n<o;++n,++r){const e=n<<1,i=s[r].x,o=l[e]-t,g=(0,h.e)(o);g*(0,h.e)(i)<0&&Math.abs(o)>m&&(l[e]-=g*a)}for(let t=0;t<o;t++){const n=t<<1;s[e+t].x=l[n],s[e+t].y=l[n+1]}e+=o}}}function Lr(e,t,s,n){(0,i.g)(0)}function zr(e,t,s){let n=t.getPointCount();if(!n)return!1;const r=t.getImpl(),i=r.getAttributeStreamRef(0);let o=null;const a=e.getInputSR(),m=e.getOutputSR();a.getVCS(),m.getVCS();const l=a.getOneDegreeGCSUnit(),g=m.getOneDegreeGCSUnit(),c=e.isVertical();c&&t.hasAttribute(1)&&(o=r.getAttributeStreamRef(1));const u=e.getDatumTransformation(),_=!!u&&1===u.getType();if(_||null===o||(Lr(o.getArray()),o=null),!u||0===u.count()){const e=a.getGcsUnitFactor()/m.getGcsUnitFactor(),t=(a.getPrimeMeridian()-m.getPrimeMeridian())*g,s=-90*l,o=90*l;let c=0;const u=i.getArray(),_=[0];for(let e=1,t=2*n;e<t;)_[0]=u[e],c|=(0,h.aD)(_,s,o)?1:0,u[e]=_[0],e+=2;if(0!==t||1!==e){c=1;const s=i.getArray();for(let r=0,i=2*n;r<i;){let n=s[r];n*=e,n+=t,s[r]=n,s[r+1]*=e,r+=2}}return 0!==c&&r.notifyModifiedFlags(2001),!!c}let p=Math.min(n,1e3);const d=(0,h.d)(p,Number.NaN),f=(0,h.d)(p,Number.NaN);let x=null;null!==o&&(x=new Float64Array(p));let P=0,E=Number.NaN,y=Number.NaN;const S=360*g,C=g/l;s&&(y=90*g,E=89.9*l,f.fill(0));let I=!0,v=0;for(;n;){let e=!1;const t=i.readRange(2*P,2*p);for(let e=0;e<p;e++)d[e]=t[e<<1];if(s)for(let s=0;s<p;s++){const n=1+(s<<1),r=Math.abs(t[n])-E;if(r>0){const i=t[n];t[n]=(0,h.f)(E,i),f[s]=(0,h.f)(r,i),e=!0}}const r=t[0];if(_){const e=u;x&&o.queryRange(P,p,x,!0,1),e.transform(!1,t,x,p),x&&o.writeRangeFromArray(P,p,x,!0,1)}else u.transform(!1,t,p);I&&(v=t[0]-C*r,I=!1);for(let e=0;e<p;e++){const s=e<<1,n=t[s]-d[e]*C-v;Math.abs(n)>200&&(t[s]+=n>0?-S:S)}if(e){for(let e=0;e<p;e++)if(f[e]){const s=1+(e<<1);t[s]+=C*f[e],t[s]>y?t[s]=y:t[s]<-y&&(t[s]=-y)}f.fill(0)}i.writeRangeFromArray(2*P,2*p,t,!0,1),c&&o&&o.writeRangeFromArray(P,p,x,!0,1),P+=p,n-=p,p=Math.min(n,1e3)}return r.notifyModifiedFlags(2001),!0}function Wr(e,t,s){switch(t.getGeometryType()){case i.G.enumLine:return function(e,t,s){const n=[t.getStartXY(),t.getEndXY()];let r=null;t.hasAttribute(1)&&(r=[0,0],r[0]=t.getAttributeAsDbl(0,1,0),r[1]=t.getAttributeAsDbl(1,1,0));const i=Jr(e,n,r,2,s);return t.setStartXY(n[0]),t.setEndXY(n[1]),r&&(t.setStartAttribute(1,0,r[0]),t.setEndAttribute(1,0,r[1])),t.normalizeAfterEndpointChange(),i}(e,t,s);case i.G.enumBezier:return function(e,t,s){const n=(0,h.m)(h.P,4);t.queryControlPoints(n);let r=null;t.hasAttribute(1)&&(r=[0,0,0,0],r[0]=t.getAttributeAsDbl(0,1,0),r[3]=t.getAttributeAsDbl(1,1,0),r[1]=(0,h.q)(r[0],r[3],.5),r[2]=r[1]);const i=Jr(e,n,r||null,n.length,s);return t.setControlPoints(n),r&&(t.setStartAttribute(1,0,r[0]),t.setEndAttribute(1,0,r[3])),t.normalizeAfterEndpointChange(),i}(e,t,s);case i.G.enumEllipticArc:return function(e,t,s){if(0===t.projectionBehavior())return function(e,t,s){const n=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()];let r=4;t.isDegenerateToLine()&&(r=2);const i=[0,0,0,0];let o=null;if(t.hasAttribute(1)){o=i,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);const e=(0,h.q)(o[0],o[1],.5);o[2]=e,o[3]=e}const a=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),m=Jr(e,n,o,r,s);return a?t.constructCircleCenterAndPoint(n[3],n[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(n[0],n[1]):t.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),m}(e,t,s);const n=t.getStartXY().equals(t.getEndXY()),r=(0,h.m)(h.P,3),i=(0,h.m)(h.P,3);let o=null;r[0].assign(t.getStartXY()),r[1].assign(n?t.getCenter():t.getEndXY());let a=!1;t.hasAttribute(1)&&(o=[0,0,0],o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0),o[2]=(0,h.q)(o[0],o[1],.5),n&&(o[1]=o[2])),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]);const l=new m.T;if(n||t.isDegenerateToLine())a=Jr(e,i,o,2,s),l.initializeFromTwoPoints(r[0],r[1],i[0],i[1]);else{const n=new h.P;t.queryCoord2D(.5,n),r[2].setCoordsPoint2D(n),i[2].setCoordsPoint2D(n),a=Jr(e,i,o,3,s),l.setFromTwoTriangles(r,i)}return l.isIdentity()||(t.applyTransformation(l),t.setStartXY(i[0]),t.setEndXY(n?i[0]:i[1]),t.normalizeAfterEndpointChange()),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,n?o[0]:o[1])),a}(e,t,s);case i.G.enumBezier2:case i.G.enumRationalBezier2:return(0,i.g)(0),!1;default:(0,i.d)("")}}function jr(e,t,s){if(!t.hasNonLinearSegments())return zr(e,t,s);if(t.isEmpty())return!1;const n=t.createInstance();n.reserveParts(t.getPointCount(),t.getPathCount());const r=t.getImpl(),i=new o.S;for(let o=0,m=t.getPathCount();o<m;++o){let t=!0,m=-1;const l=r.getPathStart(o),g=l+r.getSegmentCountPath(o);r.isClosedPath(o)&&(m=g-1);const c=new h.P;for(let o=l;o<g;++o){if(r.getSegmentBuffer(o,i,!1),Wr(e,i.get(),s),t||i.get().getStartXY().equals(c)||i.get().moveTo(c),o!==m)n.addSegment(i.get(),t);else{if(t){const e=new a.P;i.get().queryStart(e),n.startPathPoint(e)}n.closeLastPathWithSegment(i.get())}c.assign(i.get().getEndXY()),t=!1}}return t.assignMove(n),!0}function Zr(e,t,s,n,r,i){if(e.isIdentityGeogToGeog()){const s=90*e.getInputSR().getOneDegreeGCSUnit();let r=0;const i=[0];for(let e=0;e<n;e++)i[0]=t[e].y,r|=(0,h.aD)(i,-s,s)?1:0,t[e].y=i[0];return r}const o=e.getInputSR(),a=e.getOutputSR(),m=o.getVCS(),l=a.getVCS(),g=o.getOneDegreeGCSUnit(),c=90*g,u=a.getOneDegreeGCSUnit(),_=e.isVertical(),p=e.getDatumTransformation(),d=!!p&&1===p.getType();if(_||(s=null),!p||0===p.count()){let e=0;const r=[0];for(let s=0;s<n;s++)r[0]=t[s].y,e|=(0,h.aD)(r,-c,c)?1:0,t[s].y=r[0];return e|=$n(o.getGCS(),m,a.getGCS(),l,t,s,n)?1:0,e}d||null===s||Lr();let f=Math.min(n,1024);const x=(0,h.d)(f,Number.NaN),P=(0,h.d)(f,Number.NaN);let E=0,y=Number.NaN,S=Number.NaN;const C=360*u,I=u/g;r&&(S=90*u,y=89.9*g);let v=!0,b=0,G=n;for(;G;){let e=!1;for(let e=0;e<f;e++)x[e]=t[e+E].x;if(r)for(let s=0;s<f;s++){const n=Math.abs(t[s+E].y)-y;if(n>0){const r=t[s+E].y;t[s+E].y=(0,h.f)(y,r),P[s]=(0,h.f)(n,r),e=!0}}const n=t[0].x;d?p.transform(!1,t,s,f):p.transform(!1,t,f),v&&(b=t[0].x-I*n,v=!1);for(let e=0;e<f;e++){const s=t[E+e].x-x[e]*I-b;Math.abs(s)>200&&(s>0?t[E+e].x-=C:t[E+e].x+=C)}if(e){for(let e=0;e<f;e++)P[e]&&(t[E+e].y+=I*P[e],t[E+e].y>S?t[E+e].y=S:t[E+e].y<-S&&(t[E+e].y=-S));P.fill(0,0,f)}E+=f,G-=f,f=Math.min(G,1024)}return 1}function Kr(e,t,s,n,r){return(0,i.g)(0),0}function Qr(e,t,s,n,r){(0,i.g)(null===n),(0,i.g)(t<2147483647);const o=Array.isArray(s);let a;a=o?(0,h.aG)(s):s;const m=Io.geogToGeog(e,t,a,null,r);return o&&(0,h.aH)(a,s),m}function Jr(e,t,s,n,r,i){let o=0,a=!0,h=0;for(let i=0;i<n;++i)t[i].isNAN()?a||(o|=Zr(e,t.slice(h,i-h),s?s.slice(h,i-h):null,i-h,r),h=i,a=!0):a&&(h=i,a=!1);return a||(o|=Zr(e,0===h?t:t.slice(h),s?0===h?s:s.slice(h):null,n-h,r)),0!==o}function $r(e,t,s,n){Hr(e,t,s,n)}function ei(e,t,s,n){Xr(e,t,s,n);const i=new r.Envelope2D;i.setFromPoints(s,n);const o=e.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(i.width()>h){for(let e=0;e<n;e++)for(;s[e].x<t;)s[e].x+=a;if(i.setFromPoints(s,n),i.xmax>h+t)for(let e=0;e<n;e++)s[e].x-=a}}function ti(e,t,s,n,r){const i=(0,h.m)(h.P,3);let o=0,a=!1,m=!1;const l=n.isDegenerateToLine();l?(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(a=!0,m=!n.isClockwise(),i[0].assign(n.getStartXY()),i[1].assign(n.getCenter()),i[2].setCoords(0,0),o=2):(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].assign(n.getInteriorPoint()),o=3),e?$r(t,i,o,r):ei(t,s,i,o),l?n.constructLineCircularArc(i[0],i[1]):a?n.constructCircleCenterAndPoint(i[1],i[0],m):n.constructCircularArcThreePoint(i[0],i[1],i[2])}function si(e,t,s){const n=(0,o.a9)(e),r=(0,o.a9)(t),i=(0,o.a4)(n,r),a=(0,o.a4)(n,(0,o.a9)(s));return 0===a||i>0&&a>0&&a<=i||i<0&&a<0&&a>=i}function ni(e,t,s,r,o){const a={stack:[],error:void 0,hasError:!1};try{const m=s.clone(),l=r.clone();if(2===o){const e=[0,0];return V(0,t,m,l,0,e),e[0]}if(m.y>l.y){const e=new h.P;e.assign(m),m.assign(l),l.assign(e)}const g=(0,n.mS)(a,new Eo,!1),c=(0,n.mS)(a,new Eo,!1),u=(0,n.mS)(a,new Eo,!1),_=new h.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;wo.geodeticDistance(e,t,m.x,m.y,l.x,l.y,c,g,null,o);const p=c.val;let d=0,f=1;const x=m.clone();for(;p*(f-d)>1e-12*e;){const s=.5*(d+f);if(wo.geodeticCoordinate(e,t,m.x,m.y,p*s,g.val,c,u,o),x.x=c.val,x.y=u.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,i.g)(!1),Number.NaN;d=s}}return x.x}catch(e){a.error=e,a.hasError=!0}finally{(0,n.hk)(a)}}function ri(e,t,s,n){const r=new h.E;r.setCoords(t,s);const i=n.width();let o=Math.floor((e-t)/i)*i+e;const a=r.getCenter();for(;Math.abs(o-a)>Math.abs(o+i-a);)o+=i;return o}class ii extends c.G{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}class oi{constructor(e,t=!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=h.P.getNAN(),this.m_southPole=h.P.getNAN(),this.m_polesUpdated=0,this.m_domain=r.Envelope2D.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=r.Envelope2D.constructEmpty(),this.m_pannableExtentGCS=r.Envelope2D.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=e,this.m_WKID=yo.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_r(e,0,!0),this.m_hashCode=(0,h.aA)(this.m_canonicalWkt)):this.m_hashCode=(0,h.B)(this.m_WKID);const s=this.m_peCoordSys.getType();this.m_csType=s===So.PE_TYPE_PROJCS?2:1,(0,i.g)(s===So.PE_TYPE_PROJCS||s===So.PE_TYPE_GEOGCS),s===So.PE_TYPE_PROJCS&&(e.loadConstants()||(0,i.a)("PeProjcs.loadConstants failed"));const n=s===So.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();s!==So.PE_TYPE_GEOGCS&&yo.getCode(n),this.m_unit=function(e){const t=Do(null);return e.getType()===So.PE_TYPE_PROJCS||e.getType()===So.PE_TYPE_GEOGCS?t.reset(e.getUnit()):(0,i.a)("PE_coord_sys"),t.get()||(0,i.d)("cannot create units from coord sys"),function(e){return e.getType()===So.PE_TYPE_LINUNIT?new Ti(e):e.getType()===So.PE_TYPE_ANGUNIT?new x(e):void(0,i.a)("peUnit")}(t.get())}(e),this.m_primeMeridian=n.getPrimem().getLongitude();{const e=n.getUnit().getUnitFactor();this.m_gcsUnitFactor=e;let t=Math.PI/(180*e);Math.abs(t-1)<1e-10&&(t=1),this.m_oneDegreeGCS=t}if(s===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=vo.generate(e,vo.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||(0,i.d)("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 e=1/n.getUnit().getUnitFactor(),t=n.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/t*e,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,i.g)(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==So.PE_TYPE_PROJCS)return;let e=!0;const t=this.m_peCoordSys,s=t.getGeogcs(),n=t.horizonGcsGenerate();if(!n)return;(0,i.g)(n.length>0);const g=n[0].getNump(),c=n[0].getKind();let u,_;e=n[0].getInclusive()>0;const p=this.getOneDegreeGCSUnit(),d=90*p,f=360*p,x=370*p,P=180*p*So.PE_HORIZON_DELTA/Math.PI,E=r.Envelope2D.constructEmpty();let y=null;if(g>1)for(let e=1;e<g;e++)if(n[e].getKind()===So.PE_HORIZON_LINE){y||(y=new o.a);const t=n[e].getCoord();y.startPathCoords(t[0][0],t[0][1]),y.lineToCoords(t[1][0],t[1][1])}if(c===So.PE_HORIZON_RECT){const t=n[0].getCoord();if(E.setFromPoints([new h.P(t[0][0],t[0][1]),new h.P(t[1][0],t[1][1])],2),Math.abs(E.ymax-d)<1e-7*P&&(E.ymax=d),Math.abs(E.ymin+d)<1e-7*P&&(E.ymin=-d),E.width()>x){const e=-400*p,t=e+5*f;E.setCoords({xmin:e,ymin:E.ymin,xmax:t,ymax:E.ymax})}const s=new a.E({env2D:E});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const a=Li(s,null,0,1),c=[],x=new h.E;for(let e=0;e<g;e++){if(n[e].getKind()!==So.PE_HORIZON_POLY)continue;u=n[e].getSize();const t=n[e].getCoord(),s=r.Envelope2D.constructEmpty();s.setFromPoints((0,h.aB)(t),u),c.push(new h.E(s.xmin,s.xmax)),s.width(),x.merge(c.at(-1))}let P=!1;const E=new h.E;x.width()>f&&c.length>1?(E.vmin=this.getCentralMeridian()-f,E.vmax=E.vmin+2*f,P=!0,t=!0):(E.vmin=x.vmin,E.vmax=E.vmin+f);const S=e=>{let t=0;for(;c[e].vmin+t<E.vmin;)t+=f;for(;c[e].vmax+t-f>E.vmin;)t-=f;return t};let C=new o.P;if(t){const e=new ii,t=(new mr).executeMany(e,a,null);for(let s=0;s<g;s++){if(n[s].getKind()!==So.PE_HORIZON_POLY)continue;u=n[s].getSize();const r=n[s].getCoord();_=n[s].getInclusive()>0;const i=new o.P;if(i.addPathPoint2D((0,h.aB)(r),u-1,!0),P){const t=S(s),n=c[s].clone();n.move(t);let r=t;const o=new m.T;do{o.setShiftCoords(r,0);const t=i.clone();t.applyTransformation(o),e.tick(t),e.tock(),r+=f,n.move(f)}while(n.vmin<E.vmax)}else e.tick(i),t.tock()}C=t.next()}else{C=new o.P;for(let t=0;t<g;t++){if(n[t].getKind()!==So.PE_HORIZON_POLY)continue;u=n[t].getSize();const s=n[t].getCoord();if(_=n[t].getInclusive()>0,(0,i.g)(_===e),P){const e=new o.P;e.addPathPoint2D((0,h.aB)(s),u-1,!0);const n=S(t),r=c[t].clone();r.move(n);let i=n;const a=new m.T;do{if(0!==i){a.setShiftCoords(i,0);const t=new o.P({copy:e});t.applyTransformation(a),C.addPath(t,0,!0)}else C.addPath(e,0,!0);i+=f,r.move(f)}while(r.vmin<E.vmax)}else C.addPathPoint2D((0,h.aB)(s),u-1,!0)}}P&&(C=(new l.O).execute(C,new r.Envelope2D(E.vmin,-d-p,E.vmax,d+p),a,null)),e?(new sn).accelerateGeometry(C,a,1):(new ar).accelerateGeometry(C,a,1),(new cr).accelerateGeometry(C,a,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=C,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=y)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==So.PE_TYPE_PROJCS)return;const e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();const s=e[0].getKind();e[0].getInclusive();const n=r.Envelope2D.constructEmpty(),m=e[0].getNump();let l=!1;if(s===So.PE_HORIZON_RECT){const s=e[0].getCoord();n.setFromPoints((0,h.aB)(s),2),t=new a.E({env2D:n})}else{let s=-1;for(let t=0;t<m;t++)e[t].getKind()===So.PE_HORIZON_POLY&&(s=t);(0,i.g)(s>=0);const n=e[s].getSize()-1,r=e[s].getCoord(),a=new o.P;t=a,a.addPathPoint2D((0,h.aB)(r),n,!0),l=!0}if(this.getPCSInfo().isDensificationNeeded()){(0,i.g)(s!==So.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new g.O).execute(t,e,0,0,null)}if(l){{const e=new a.E;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}(new sn).accelerateGeometry(t,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=t)}updatePannableExtent(){const e=this.m_peCoordSys.getType();if(e===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),s=e.getGeogcs();s||(0,i.d)("");const n=[t+1/s.getUnit().getUnitFactor()*Math.PI,0];Co.geogToProj(e,1,n);const o=n[0],a=e.getParameters()[So.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=r.Envelope2D.constructEmpty();h.queryEnvelope(m);const l=Math.abs(o-a),g=l+a,c=-1*l+a,u=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:c,ymin:_,xmax:g,ymax:u})}else if(e===So.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else(0,i.d)("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===So.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,s=e.getGeogcs();s||(0,i.d)("");const n=1/s.getUnit().getUnitFactor()*Math.PI,o=this.getGCSHorizon(),a=r.Envelope2D.constructEmpty();o.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:t-n,ymin:a.ymin,xmax:t+n,ymax:a.ymax})}else if(e===So.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else(0,i.d)("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=r.Envelope2D.construct(-e,-e,e,e)}else{(0,i.g)(2===this.m_csType);const e=vo.generate(this.m_peCoordSys,vo.PE_PCSINFO_OPTION_DOMAIN);e||(0,i.d)("generate pcs info failed");const t=new r.Envelope2D(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===So.PE_TYPE_PROJCS){const e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];Co.geogToProj(this.m_peCoordSys,2,t);const s=this.getPCSInfo().getNorthPoleLocation()!==vo.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==vo.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(t[0][0],t[0][1]),n&&this.m_southPole.setCoords(t[1][0],t[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===So.PE_TYPE_PROJCS){const e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=t,s[1]=0,s[2]=t+e,s[3]=0;const n=Co.geogToProj(this.m_peCoordSys,2,s);(0,i.g)(2===n);const r=(s[2]-s[0])/e,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(e){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),(0,h.k)(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){const t=[0],s=[0];(function(e,t,s,n){return t<=0?(s[0]=0,n[0]=0,!1):(s[0]=t,n[0]=t,!0)})(this.m_peCoordSys.getType(),this.m_WKID,t,s)||(0,i.d)("query_code_change"),e=t[0]}this.m_oldWKID=e}return e}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(e,t){return!1}static equal_for_projection(e,t){return!1}}class ai{constructor(e,t=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new Ti,this.m_cached=!1}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function hi(e,t,s){return mi(e,t,r.Envelope2D.constructEmpty())}function mi(e,t,s,n){return function(e,t,s,n){return Oi()||(0,i.n)("cannot create projection transformation"),t.hasVCS()&&s.hasVCS()?((0,i.g)(0),{}):function(e,t,s){e&&t||(0,i.a)("!inputSR || !outputSR");const n=e.getLatestID(),o=t.getLatestID();if(3857===n&&4326===o){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return bi()}else if(4326===n&&3857===o&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return Ii||(Ii=bi().getInverse()),Ii;const a=r.Envelope2D.constructEmpty();a.setCoords({env2D:s});const h=e.getCoordinateSystemType(),m=t.getCoordinateSystemType();if(0===h||0===m)return ui(e,t);const l=e.getGCS().getLatestID(),g=t.getGCS().getLatestID();if(l>0&&l===g)return ui(e,t);const c=new yi(e,t,s);{const e=function(e){if(Si.has(e.getHashCode()))return Si.get(e.getHashCode())}(c);if(e)return e}const u=gi(0,e,t,a,1,!0);return function(e,t){return Si.set(e.getHashCode(),t),t}(c,ui(e,t,u.length?u[0]:void 0))}(t,s,n)}(0,e,t,s)}function li(e,t,s,n){return function(e,t,s,n,r){return Oi()||(0,i.n)("cannot create projection transformation"),new di(2,t,s,n,r,void 0)}(0,e,t,s,n)}function gi(e,t,s,r,o,m=!1){if(t&&s||(0,i.a)(""),Oi()||(0,i.n)("cannot obtain geotransformation list"),1===e&&t.hasVCS()&&s.hasVCS())return(0,i.t)("hv xform not impl"),[];{const e=function(e,t,s,r,o){const m=e.getGCS(),l=t.getGCS(),g=m.getPECoordSys(),c=l.getPECoordSys();let u=null;if(!s.isEmpty()){const t=s.clone();if(!t.isEmpty()&&2===e.getCoordinateSystemType()){let s=new a.E({env2D:t});const n=li(e,m,null);s=(new cn).execute(s,n,null),s.queryEnvelope(t)}if(!t.isEmpty()){const e=g.getPrimem().getLongitude(),s=g.getUnit().getUnitFactor();u=new To(t.xmin,t.ymin,t.xmax,t.ymax,e,s)}}let _=r;_>=(0,h.i)()&&(_=0);const p=[];let d=bo.PE_GTLIST_OPTS_COMMON;o||(d&=~bo.PE_GTLIST_OPTS_USABLE);for(let e=0;e<2;e++){const e={stack:[],error:void 0,hasError:!1};try{p.length=0;const t=bo.getGTlist(g,c,2,d,u,_);if(null==t||0===t.length)break;(0,n.mS)(e,{[Symbol.dispose](){Go.destroy(t)}},!1);let s=!1;for(const e of t){const t=Ro(e);if((0,i.g)(t),o&&t.referencesMissingData())s=!0,_=0;else if(p.push(t),p.length===r)break}if(!s)break}catch(t){e.error=t,e.hasError=!0}finally{(0,n.hk)(e)}}return u&&u.destroy(),p}(t,s,r,o,m),l=[];for(const t of e)l.push(t);return l}}function ci(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return(0,h.Q)(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&(0,h.Q)(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function ui(e,t,s,n,r){return new di(1,e,t,s,n,r)}function _i(){return{m_extendedParams:ci(),m_extendedParamsInternal:{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return 0!==(this.flagsMask&e)}}}}function pi(){return _i()}class di{constructor(e,t,s,n,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,t&&s||(0,i.a)("!inputSR || !outputSR"),n&&0===n.getType()&&(n.m_bReadOnly=!0),this.m_bNormalize=!1,1!==e&&(a=t.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=t,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,(0,i.g)(!this.m_params),r&&(this.m_params=_i(),this.m_params.m_extendedParams=r),o&&(this.m_params||(this.m_params=_i()),this.m_params.m_extendedParamsInternal=o);let m=!1;const l=null!=n,g=t.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==g&&r){const e=r.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&s.isPannable()){const t=s.getPannableExtent(),n=t.getCenterX();if(n!==e){const s=Math.ceil(t.width());e+s!==n+s&&(m=!0)}}}const u=r&&r.normalizeResultGeometry;if(t.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const _=!l&&t.equalForProjection(s,this.m_bVertical);this.m_bIdentity=_&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==g&&0!==c&&(u&&this.m_outputSR.isPannable()&&(this.m_bNormalize=u),this.m_datumTran=n||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 e=new di(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return e.m_bIdentity=this.m_bIdentity,e.m_bVertical=this.m_bVertical,e.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,e.updateProjector(),e}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:pi().m_extendedParams}equals(e){return(0,i.g)(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return(0,i.g)(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:pi().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:pi().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new mn(this)}}const fi=new Map,xi=new Map,Pi=new Map;function Ei(e){let t=e.getCode();if(t>0)return Ni(t)||wi(yo.coordsys(t));const s=e.getName();if(xi.has(s)){const t=xi.get(s);if(t&&t.deref()){const s=t.deref();if(s.m_peCoordSys.isEqual(e))return s}}return t=yo.getCode(e),wi(t>0?yo.coordsys(t):e)}class yi{constructor(e,t,s){this.m_hashCode=-1,e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=(0,h.at)(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aI)(this.m_env.xmin)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aI)(this.m_env.xmax)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aI)(this.m_env.ymin)),this.m_hashCode=(0,h.at)(this.m_hashCode,(0,h.aI)(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return!(this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR)&&this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR)}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const Si=new Map;let Ci,Ii,vi;function bi(){return Ci||(Ci=li(ao(),mo())),Ci}const Gi=new Map;function wi(e){const t=Do(e),s=e.getCode();if(s>0){const e=Ni(s);if(e)return e}const n=e.getName();let r=xi.get(n);if(r){const t=r.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}const i=new oi(t.release());if(s>0)return i.setCached(),fi.set(s,new WeakRef(i)),xi.set(n,new WeakRef(i)),i;const o=_r(e,0,!1);if(r=Pi.get(o),r){const e=r.deref();if(e)return e}return i.setCached(),Pi.set(o,new WeakRef(i)),i}function Ni(e){const t=fi.get(e);if(t)return t.deref()}class Ti extends d{constructor(e){return void 0===e?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof e?(super(),this.m_factor=e,void(this.m_wkid=0)):(super(e),void(e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=(vi||(vi=yo.unit(9001)),vi))))}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const Di=["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 Vi(e,t,s,n,r){(0,i.g)(n>>5<r.length);let o=t,a=s;for(let t=n;t>=0;t-=2){const s=31&t,n=.5*(a+o);e>=n?(r[t>>5]|=1<<s,o=n):a=n}}let ki=new Set;const Fi=2147483645n,Hi=9007199254740990n,Ai="operation is not supported for unknown coordinate systems";var Mi;function Ui(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function qi(e){!function(e){Vo=e,(0,i.g)(Vo)}(e)}function Oi(){return!!yo}function Yi(){return!!Vo}function Bi(){return!!yo||!!Vo}function Ri(e,t,s){return(0,i.g)(Bi()),_o(e,void 0===t?0:t,0,!1)}function Xi(e,t){(0,i.g)(Bi());const s=new io;let n;return Oi()?(n=function(e){const t=Do(yo.fromString(So.PE_TYPE_COORDSYS,e));return t.get()||(0,i.C)(e),Ei(t.release())}(e),s.setHorzProj_(n),s.m_vertcs=null,s.m_userWKID=n.getLatestID()):(n=ko(e),s.m_unit=n.isPCS?new Ti(n.metersOrRadiansPerUnit):new x(n.metersOrRadiansPerUnit)),go(s.m_precisionDescriptor,n,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=e,s.calculateHashCode(),s.initDbgName(),s}function Li(e,t,s,n,r=!0){let o=null;return t&&((0,i.g)(0),o={}),function(e,t,s,n,r){e||(0,i.a)("!PE_coord_sys");const o=new io;let a;return a=r?Ei(e):new oi(e,!1),go(o.m_precisionDescriptor,a,t,n),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=t,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}(e,o,0,n,r)}function zi(e,t,s=!1){3===e.getCoordinateSystemType()&&(0,i.a)("image spatial reference cannot be altered");const n=new io,r=e;return n.m_peCoordSysVal=r.m_peCoordSysVal,n.m_vertcs=r.m_vertcs,n.m_unit=r.m_unit,n.m_precisionDescriptor.assign(t),n.m_localZToXYFactor=r.m_localZToXYFactor,(Number.isNaN(n.m_precisionDescriptor.m_falseX)||Number.isNaN(n.m_precisionDescriptor.m_falseY))&&(n.m_precisionDescriptor.m_falseX=r.m_precisionDescriptor.m_falseX,n.m_precisionDescriptor.m_falseY=r.m_precisionDescriptor.m_falseY),n.m_precisionDescriptor.snapPrecision(),n.m_precisionDescriptor.fixTolerance(),n.m_userWKID=r.m_userWKID,n.m_precisionDescriptor.equals(r.m_precisionDescriptor)?n.m_bDefaultDescriptor=r.m_bDefaultDescriptor:n.m_bDefaultDescriptor=!1,s&&(n.m_bDefaultDescriptor=!0),n.calculateHashCode(),n.initDbgName(),n}function Wi(e,t,s){void 0===t&&(t=1),(t<=0||!Number.isFinite(t))&&(0,i.a)(""),e||1===t||(0,i.a)("null Unit has to have z_to_xy_factor equal to 1");const n=new io;n.m_unit=e;const r=e||new Ti(9001);return uo(n.m_precisionDescriptor,r,null,1),n.m_bDefaultDescriptor=!0,Number.isNaN(n.m_precisionDescriptor.m_falseX)&&(0,i.a)("NAN false X/Y are not allowed here"),n.m_localZToXYFactor=t,n.calculateHashCode(),n.initDbgName(),n}function ji(e){const t=e.getCoordinateSystemType();return 1===t?e:(3===t&&(0,i.g)(0),e.getGCS())}function Zi(e){return(0,i.g)(Bi()),Yi()?function(e){return(0,i.g)(Yi()),!!Vo(e).isPCS||function(e){return yo&&(0,i.q)("pe has been loaded. no-pe methods should not be used at this point."),fo||Ho(),fo.has(e)}(e)}(e):function(e){if(Gi.has(e))return Gi.get(e);{const t=function(e){return null!==Do(yo.coordsys(e)).get()}(e);return Gi.set(e,t),t}}(e)}function Ki(e){if(Oi()){const t={stack:[],error:void 0,hasError:!1};try{return null!==(0,n.mS)(t,yo.fromString(So.PE_TYPE_COORDSYS,e,!0),!1)}catch(e){t.error=e,t.hasError=!0}finally{(0,n.hk)(t)}}try{return ko(e),!0}catch(e){}return!1}let Qi;function Ji(){return Qi||(Qi=(()=>{const e=Math.trunc(Math.random()*(0,h.i)()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})()),Qi}!function(e){e[e.utmDefault=0]="utmDefault",e[e.utmNorthSouth=1]="utmNorthSouth"}(Mi||(Mi={}));let $i=0;function eo(e=""){let t=`${Ji()}${$i++}`;return""!==e&&(t+=`|${e}`),t}function to(e){return e.startsWith(Ji())}let so,no,ro,io=class e{destroy(){(function(e){xi.delete(e.m_peCoordSys.getName()),Pi.delete(_r(e.m_peCoordSys,0,!1))})(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():(0,i.d)("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 oo,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,lo(this.m_precisionDescriptor),ki&&ki.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ri(this.m_userWKID):Xi(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(1===this.getCoordinateSystemType())return li(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;const s=this.getGCS();t=e?li(this,s,null):li(s,this,null);const n=t;return(e?this.m_srToGcs:this.m_gcsToSr)||(e?this.m_srToGcs=n:this.m_gcsToSr=n,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal();const t=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();e=(0,h.at)(e,t),this.m_hashCode=(0,h.at)(e,s)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType()?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const e=this.getPECoordSys();if(e)switch(e.getType()){case So.PE_TYPE_GEOGCS:return 1;case So.PE_TYPE_PROJCS:return 2;default:return 0}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Ti)return 2;if(this.m_unit instanceof x)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,i.t)("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return(0,i.t)("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){const e=this.getPECoordSys();return e?pr(e):this.m_userWKT??""}getTextExtended(e){const t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?(this.getPEVerticalCoordSys(),(0,i.g)(0),""):pr(t,e):this.m_userWKT??""}getText2(e=-1){const t=this.getPECoordSys();return t?function(e,t){(t>1||t<-1)&&(0,i.a)("verbosity");let s=So.PE_STR_FMT_WKT2;return-1!==t&&(s|=0===t?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL),e.toString(s)}(t,e):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof Ti?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof x?.001/(ko(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):((0,i.q)("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?((0,i.g)(0),""):""}getVerticalUnit(){return(0,i.t)("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)(0,i.q)(Ai);else{if(1===e)return this;3===e&&(0,i.q)("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===ao()||this===ho())t=mo();else{(0,i.g)(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||(0,i.d)(""),t=Li(e,this.m_vertcs,0,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?t=this.m_geogSpatialReference:this.m_geogSpatialReference=t,t}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(0===e.length)return 0;e.length>t.length&&(0,i.a)("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&(0,i.q)(Ai),1===s)return(0,h.aw)(t,e,e.length),e.length;(0,i.g)(this.m_peCoordSysVal);const n=this.getSRToGCSTransform();return(new cn).transform(n,e,e.length,t)}toGeohash(e,t=8){const s=e.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=(0,h.l)(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=(0,h.l)(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*t,r=new Uint32Array(4);return Vi(s.x,-180,180,n-1,r),Vi(s.y,-90,90,n-2,r),function(e,t,s){const n=(0,h.d)(t,"R");let r=0,i=0;for(let s=0;s<t;s++){let o=e[r]>>i&31;if(i+=5,i>31){const t=37-i;o&=(1<<t)-1,i-=32,r++,o|=(e[r]&(1<<i)-1)<<t}const a=Di[o];n[t-1-s]=a}return s>t?n.push(..."0".repeat(s-t)):s<t&&(n.length=s),n.join("")}(r,t,t)}isPannable(){const e=this.getCoordinateSystemType();return 0!==e&&3!==e&&((0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||(0,i.a)("!is_pannable"),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||(0,i.a)("!is_pannable"),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const e=this.getCoordinateSystemType();1!==e&&2!==e&&(0,i.a)("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX))if(Oi()||(0,i.n)("cannot query precision descriptor"),(0,i.g)(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{const t=this.getCoordinateSystemType();0===t?uo(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===t?(0,i.t)("image cs"):go(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}horizontalEqual(e){return function(e,t){return e===t||null!==e&&null!==t&&e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID)}(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return null!==this.m_vertcs==(null!==e.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs))}equals(e){const t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t))return!1;if(!t.m_peCoordSysVal){if((0,i.g)(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==t.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(t.m_unit))return!1;if(this.m_localZToXYFactor!==t.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;(0,i.g)(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){const t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,s=t.ymin}let n=t.m_precisionDescriptor.m_falseX,r=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(n)){const e=t.m_peCoordSysVal.getDomainXY();n=e.xmin,r=e.ymin}return e===n&&s===r}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;const s=this.getCoordinateSystemType(),n=e.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!t||this.getZToXYFactor()===e.getZToXYFactor())&&(!this.getUnit()||!e.getUnit()||this.getUnit().equals(e.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===e.getUnit()||(!t||this.getZToXYFactor()===e.getZToXYFactor())&&this.getUnit().equals(e.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(e);if(function(e,t){return e===t||null!==e&&null!==t&&e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?1===e.m_csType?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID)}(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(null!==this.m_vertcs==(null!==e.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return(0,i.g)(0),!1}equalVerticalVCS(e){return(0,i.g)(0),!1}convergenceAngle(e){return(0,i.g)(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||(0,i.d)("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return(0,i.g)(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&(0,i.a)(Ai)}getPrimeMeridian(){return this.throwIfLocal(),(0,i.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,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const e=new oo;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=zi(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();!function(e,t,s){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-s),e.e2=s*(2-s),e.flattening=s}(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&(0,i.q)(""),(0,i.g)(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.getAreaOfUse();return null===e?new p:new p({geom:e.clone(),sr:Ri(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),(0,i.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const t=e.getGeometryType();if((0,i.i)(t))return this.snapMultiVertex_(e);if(t===i.G.enumPoint)return this.snapPoint_(e);if(t===i.G.enumEnvelope)return this.snapEnvelope_(e);if((0,i.f)(t))return this.snapSegment_(e);if(t===i.G.enumGeometryCollection){const t=e;let s=!1;for(let e=0,n=t.getGeometryCount();e<n;++e)s=this.snapGeometry(t.getGeometry(e))||s;return s}(0,i.d)("what else?")}snapMultiVertex_(e){if((0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision()),(0,i.h)(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const t=e.getImpl(),s=t.getDescription();let n=!1;for(let e=0,r=s.getAttributeCount();e<r;e++){const r=s.getSemantics(e),i=t.getAttributeStreamRef(r);n=this.snapAttributes(r,i,0,t.getPointCount())||n}return n&&t.notifyModifiedFlags(2001),n}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){(0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision());const t=new oo;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new h.P;n.x=po(s.x,t.getFalseX(),t.getGridUnitsXY()),n.y=po(s.y,t.getFalseY(),t.getGridUnitsXY());let r=!n.equals(s);const o=e.getEndXY(),a=new h.P;a.x=po(o.x,t.getFalseX(),t.getGridUnitsXY()),a.y=po(o.y,t.getFalseY(),t.getGridUnitsXY()),r||=!a.equals(o),r&&e.changeEndPoints2D(n,a);const m=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=po(i,s,n),a=!(0,h.Q)(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=po(i,s,n),a=!(0,h.Q)(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let l=r?1:0;return e.hasAttribute(1)&&(l|=m(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(l|=m(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!l}snapGeometryWithCurves_(e){(0,i.g)(!e.isEmpty()),(0,i.g)(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new o.S;let n=0;for(let r=0,i=e.getPathCount();r<i;++r){const i=e.getSegmentCountPath(r);if(0===i){if(t.addPath(e,r,!0),1===t.getPathSize(r)){const e=new a.P;t.getPointByVal(t.getPointCount()-1,e),n|=this.snapGeometry(e)?1:0,t.setPointByVal(t.getPointCount()-1,e)}continue}const o=e.isClosedPath(r);for(let a=0,h=o?i-1:i;a<h;++a)e.getSegmentFromPath(r,a,s,!1),n|=this.snapGeometry(s.get())?1:0,t.addSegment(s.get(),0===a);o&&(e.getSegmentFromPath(r,i-1,s,!1),n|=this.snapGeometry(s.get())?1:0,1===i?t.addPathFromClosedSegment(s.get(),!1):t.closeLastPathWithSegment(s.get()))}return n&&t.copyTo(e),!!n}snapAttributes(t,s,n,r){let i=!1;const o=new oo;if(this.queryPrecisionDescriptor(o),0===t){const t=s;for(let s=n;s<r;s++){const n=t.read(2*s),r=e.s_SnapValue(n,o.getFalseX(),o.getGridUnitsXY()),a=t.read(2*s+1),h=e.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());i=i||r!==n||h!==a,i&&(t.write(2*s,r),t.write(2*s+1,h))}}else if(1===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseZ(),o.getGridUnitsZ());i=i||!(0,h.Q)(r,n),i&&t.write(s,r)}}else if(2===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseM(),o.getGridUnitsM());i=i||!(0,h.Q)(r,n),i&&t.write(s,r)}}return i}static s_SnapValue(e,t,s){return(0,h.ax)((e-t)*s)/s+t}};class oo{constructor(){const e=Hi,t=1e-4,s=.001,n=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(e)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let e=7777,t=7777;return t=(0,h.at)(t,this.m_falseM),t=(0,h.at)(t,this.m_unitsM),e=(0,h.at)(e,this.m_unitsXY),t=(0,h.at)(t,this.m_toleranceXY),e=(0,h.at)(e,this.m_falseZ),t=(0,h.at)(t,this.m_toleranceZ),e=(0,h.at)(e,this.m_unitsZ),t=(0,h.at)(t,this.m_toleranceM),e=(0,h.at)(e,this.m_precision),(0,h.at)(e,t)}clone(){const e=new oo;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(2===this.m_precision)return 0;switch(e){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 e=new r.Envelope2D;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 2:e.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:e.setEmpty(),(0,i.d)("")}return e}getZGridRange(){const e=new h.E;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),(0,i.d)("")}return e}getMGridRange(){const e=new h.E;switch(this.m_precision){case 0:{const t=oo.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{const t=Number(oo.getLimit64())/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),(0,i.d)("")}return e}setTolerance(e,t){switch(t<0&&(0,i.a)("tol < 0"),Number.isFinite(t)||(0,i.a)("tol is not finite"),e){case 0:this.m_toleranceXY=t;break;case 1:this.m_toleranceZ=t;break;case 2:this.m_toleranceM=t;break;default:(0,i.a)("cannot set tolerance for this attribute")}}setGridParams(e,t,s){Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(s)||(0,i.a)("grid params are not finite"),s<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=s}setZParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||(0,i.a)("grid params are not finite"),t<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseZ=e,this.m_unitsZ=t}setMParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||(0,i.a)("grid params are not finite"),t<1&&(0,i.a)("grid units cannot be smaller than 1.0"),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||(0,h.Q)(this.m_falseX,e.m_falseX)&&(0,h.Q)(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(2===this.m_precision)return;const e=(e,t,s,n)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const r=Number(e)/s;return Math.trunc((t+r-t)*s)>e&&(s=e/(t+r-t)),Math.max(1,s)},t=Number(0===this.m_precision?Fi:Hi);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const e=(e,t,s,n)=>{if(s<1)return!1;if(!Number.isFinite(t)||!Number.isFinite(s))return!1;if(!n)return!0;const r=Number(e)/s;return!(BigInt((t+r-t)*s)>e)},t=0===this.m_precision?Fi:Hi;return!!(e(t,this.m_falseX,this.m_unitsXY,!0)&&e(t,this.m_falseY,this.m_unitsXY,!0)&&e(t,this.m_falseZ,this.m_unitsZ,!1)&&e(t,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(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,s){}setBestMDomainFromMRange(e,t,s){}}function ao(){return(!so||Oi()&&null===so.getPECoordSys())&&(so=_o(3857,0,0,!0)),so}function ho(){return(!no||Oi()&&null===no.getPECoordSys())&&(no=_o(102100,0,0,!0)),no}function mo(){return(!ro||Oi()&&null===ro.getPECoordSys())&&(ro=_o(4326,0,0,!0)),ro}function lo(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=100*(0,h.O)(),e.m_toleranceZ=100*(0,h.O)(),e.m_toleranceM=100*(0,h.O)(),e.m_precision=2}function go(e,t,s,n){const r=t instanceof oi;lo(e),e.m_precision=n,e.m_falseX=Number.NaN,e.m_falseY=Number.NaN;const o=1e-4,a=.001,h=r?t.m_csType:t.isPCS?2:1;if(1===h){const s=(0===n?1/18e5:1e-9)*(r?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180);e.m_unitsXY=1/s}else if(2===h){const s=(0===n?a:o)*(r?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit);e.m_unitsXY=1/s}else(0,i.a)("unrecognized cs type");e.m_falseM=-1e5,e.m_unitsM=1/(0===n?a:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let m=0,l=0;0!==n&&1!==n||(m=2/e.m_unitsXY,l=2/e.m_unitsM),e.m_toleranceXY=Math.max(m,r?t.getUnitsPerMillimeter():2===h?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(a,l),co(e,s)}function co(e,t){const s=1e-4,n=.001;if(e.m_falseZ=-1e5,t){const r=(0===e.m_precision?n:s)*t.getOneMeter();e.m_unitsZ=1/r}else e.m_unitsZ=1/(0===e.m_precision?n:s);e.m_unitsZ=Math.max(1,e.m_unitsZ);let r=0;0!==e.m_precision&&1!==e.m_precision||(r=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*n:n,r)}function uo(e,t,s,n){lo(e),e.m_precision=n;const r=0===n?Fi:Hi,i=1e-4,o=.001;let a=1,h=1,m=.001;t&&(h=t.getUnitToBaseFactor()),t&&1===t.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===n?o:i)*Number(r)*.5,m=o/h),a/=h,e.m_falseX=-a,e.m_falseY=-a,e.m_unitsXY=Number(r)/(2*a),e.m_falseM=-1e5,e.m_unitsM=1/(0===n?o:i),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let l=0,g=0;0!==e.m_precision&&1!==e.m_precision||(g=2/e.m_unitsM,l=2/e.m_unitsXY),e.m_toleranceXY=Math.max(l,m),e.m_toleranceM=Math.max(o,g),co(e,s)}function _o(e,t,s,n){if(!n&&t<=0){if(3857===e)return ao();if(102100===e)return ho();if(4326===e)return mo()}const r=new io;let o,a=null;return Oi()?(o=function(e){e<=0&&(0,i.D)(e);{const t=Ni(e);if(t)return t}const t=Do(yo.coordsys(e));t.get()||(0,i.D)(e);const s=wi(t.release());return s.getLatestID()!==e&&fi.set(e,new WeakRef(s)),s}(e),t>0?a=null:t=0,r.setHorzProj_(o),r.m_vertcs=a):(o=ko(e),r.m_unit=o.isPCS?new Ti(o.metersOrRadiansPerUnit):new x(o.metersOrRadiansPerUnit)),go(r.m_precisionDescriptor,o,a,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=e,r.calculateHashCode(),r.initDbgName(),r}function po(e,t,s){return(0,h.ax)((e-t)*s)/s+t}let fo=null;const xo=3552713678800501e-30;function Po(e,t){return function(e,t,s){return e===t||Math.abs(e-t)<=s*(1+(Math.abs(e)+Math.abs(t))/2)}(e,t,xo)}let Eo,yo,So,Co,Io,vo,bo,Go,wo,No,To;function Do(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){const e=this._this;return this._this=null,e}}}let Vo=null;function ko(e){(0,i.g)(Vo);const t=Vo(e);return t.semiMajor=t.isPCS?Number.NaN:function(e){if(yo&&(0,i.q)("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof e){const t=e.match(Fo);t&&2===t.length||(0,i.a)("bad gcs wkt");const s=Number.parseFloat(t[1]);return Number.isFinite(s)||(0,i.a)("bad gcs wkt"),s}return fo||Ho(),fo.has(e)||(0,i.q)("gcs wkid not found"),fo.get(e)}(e),t}const Fo=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Ho(){fo=new Map;for(const e in f){const t=Number.parseFloat(e),s=f[e];if(Array.isArray(s))for(const e of s)fo.set(e,t);else fo.set(s,t)}!function(){for(const e in f)delete f[e]}()}function Ao(e,t){const s=yo.geogtran(e);return s||(0,i.D)(e),new Yo(s,t)}function Mo(e,t){const s=yo.fromString(So.PE_TYPE_GEOGTRAN,e);return s||(0,i.C)(e),new Yo(s,t)}function Uo(e,t){return new Yo(e,t)}const qo=(0,h.au)(0),Oo=(0,h.au)(1);class Yo{constructor(e,t){if(e instanceof Yo)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=(0,h.at)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Oo:qo));this.m_geogTranWrapper=new Jn(e),this.m_bInverted=t,this.m_hashCode=(0,h.at)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Oo:qo)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===e)return this.m_geogTranWrapper.getGeogtran().toString();{const t=0===e?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=So.PE_STR_FMT_WKT2;return-1!==e&&(t|=0===e?So.PE_STR_AUTH_TOP:So.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(t)}getName(){return this.m_geogTranWrapper&&this.m_geogTranWrapper.getGeogtran()?this.m_geogTranWrapper.getGeogtran().getName():""}getInputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getOutputSr(!1):this.m_geogTranWrapper.getInputSr(!1)}getOutputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getInputSr(!1):this.m_geogTranWrapper.getOutputSr(!1)}getInverse(){return new Yo(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){const t=e;return t===this||this.m_bInverted===t.m_bInverted&&(this.GetPeGeogtran()===t.GetPeGeogtran()||this.getID()===t.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Bo(){return new Xo([],null,null,null)}function Ro(e){const t=new Lo,s=e.getSteps();if(s){const n=e.getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection();let r;const i=n[e].getGeogtran().getCode();if(i>=0)r=yo.geogtran(i);else{const t=n[e].getGeogtran().toString(So.PE_STR_FMT_WKT);r=yo.fromString(So.PE_TYPE_GEOGTRAN,t)}if(null==r)return null;const o=Uo(r,s);t.add(o)}return t.create()}return null}class Xo{constructor(e,t,s,n){this.m_bReadOnly=!0,this.m_name="",this.m_fastTrack=-1,this.m_bNameIsSet=!1,this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=s,this.m_outputSr=n}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=(0,h.at)(e,this.m_transforms[t].getHashCode());return e}equals(e){return(0,i.g)(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return(0,i.g)(0),!1}validateTransformation(e,t){return(0,i.g)(0),!1}nameIsSet(){return(0,i.g)(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&(0,i.r)(""),this.m_transforms[e]}getInverse(){const e=new Lo;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,s){if(0===this.count())return;let n=this.m_inputSr,r=this.m_outputSr;if(e&&(r=(0,h.c)(n,n=r)),0===this.m_transforms.length)return void $n(n,null,r,null,t,null,s);let i=this.m_fastTrack;if(1===i)return void(0,o.a8)(e,this.m_transforms,n=>{!function(e,t,s,n,r){const i=e.getVerttran(),o=e.getGeogtran();if(r>0){e.prepareOrThrow();const n=t?So.PE_TRANSFORM_2_TO_1:So.PE_TRANSFORM_1_TO_2;i?Kr():Qr(o,r,s,null,n)}}(n.getWrapper(),e!==n.isInverted(),t,0,s)});const a=Qn();-1===i&&a.initFromGcsAndVcs(n,null);const m=Qn();let l=e?this.m_transforms.length-1:0;const g=e?-1:1;for(let r=0,o=this.m_transforms.length;r<o;r++,l+=g){if(0===r){const r=this.m_transforms[l];er(n.getPECoordSys(),null,r.getWrapper(),e!==r.isInverted(),t,null,s,m),-1===i&&(a.equals(m)||(i=0)),a.assign(m)}else{const n=this.m_transforms[l-g],r=this.m_transforms[l];tr(a,n.getWrapper(),e!==n.isInverted(),r.getWrapper(),e!==r.isInverted(),t,null,s,m),-1===i&&(a.equals(m)||(i=0)),a.assign(m)}const o=this.m_transforms[l];sr(a,o.getWrapper(),e!==o.isInverted(),t,null,s,m),a.assign(m)}const c=this.m_transforms[l-g];(function(e,t,s,n,r,i,o,a){const h=Qn();h.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),h.processUnitParams(e);let m=null;n&&(m=n.getPECoordSys());const l=Qn();l.initFromGcsAndVcsPe(m,null),l.processUnitParams(h),h.processUnitParams(l),a>0&&Kn(h,l,i,null,a)})(a,c.getWrapper(),e!==c.isInverted(),r,0,t,0,s),-1===i&&(m.initFromGcsAndVcs(r,null),a.equals(m)||(i=0)),this.m_fastTrack=0===i?0:1}}class Lo{constructor(){this.m_transforms=[],this.m_inputGCS=null,this.m_outputGCS=null,this.m_name="",this.m_bNameIsSet=!1}getInputSpatialReference(){return null!==this.m_inputGCS?this.m_inputGCS:this.count()>0?this.m_transforms[0].getInputSpatialReference():null}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&(0,i.r)(""),this.m_transforms[e]}setStep(e,t){(0,i.g)(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let t=e.count()-1;t>=0;--t)this.add(e.getStep(t).getInverse());else for(let t=0;t<e.count();++t)this.add(e.getStep(t))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){(0,i.g)(0)}create(){const e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),s=new Xo(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return s.m_bReadOnly=!0,this.clear(),s}}const zo=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:io,SpatialReferencePrecisionDescriptor:oo,create:Ri,createFromWKT:Xi,createImplFromPe:Li,createLocal:Wi,createWithNewPrecision:zi,createWithNewVCS:function(e,t,s){return{}},getGCS:ji,getTempName:eo,hasNoPe:Yi,hasPe:Oi,injectNoPe:qi,injectPe:function(e){if(yo)return;!function(e){const t=e;yo=t.PeFactory,(0,i.g)(yo),To=t.PeGCSExtent,(0,i.g)(To),wo=t.PeLineType,(0,i.g)(wo),No=t.PeMath,(0,i.g)(No),Eo=t.PeDouble,(0,i.g)(Eo),So=t.PeDefs,(0,i.g)(So),Co=t.PeCSTransformations,(0,i.g)(Co),Io=t.PeGTTransformations,(0,i.g)(Io),vo=t.PePCSInfo,(0,i.g)(vo),bo=t.PeGTlistExtended,(0,i.g)(bo),yo.initialize(),Go=t.PeGTlistExtendedEntry,(0,i.g)(Go),So.PE_TYPE_ANGUNIT=512,So.PE_STR_AUTH_ALL=2,vo.PE_POLE_LINE_STRAIGHT=2,vo.PE_POLE_LINE_CURVED=3,So.PE_PARM_LAM0=2,So.PE_PARM_PHI0=6,So.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,So.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,So.PE_PRJ_ALBERS=43007,So.PE_PRJ_CYLINDRICAL_EQAREA=43034,So.PE_TYPE_VERTCS=8,So.PE_LINETYPE_GEODESIC=0,So.PE_LINETYPE_LOXODROME=1,So.PE_LINETYPE_GREAT_ELLIPTIC=2,So.PE_LINETYPE_NORMAL_SECTION=3,bo.PE_GTLIST_OPTS_USABLE=1,Vo=null}(e);const t=ki;ki=null,t.forEach(e=>{const t=e.deref();t&&t.attachToPe()})},isInitialized:Bi,isTempName:to,isValidWkid:Zi,isValidWkt:Ki,makeSpheroidData:Ui,snapGeometry:function(e,t){return e.snapGeometry(t)},webMercator:ao,webMercator102100:ho,wgs84:mo},Symbol.toStringTag,{value:"Module"}))}}]);
|