@arcgis/core 5.0.0-next.6 → 5.0.0-next.8
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/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
- package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
- package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
- package/assets/esri/core/workers/chunks/05429f9d292a7a714309.js +316 -0
- package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
- package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
- package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
- package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
- package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
- package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
- package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
- package/assets/esri/core/workers/chunks/{020c8913d8e35d63080b.js → 1d15d1b20dc10fde6def.js} +1 -1
- package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
- package/assets/esri/core/workers/chunks/20975513be0a3a1da286.js +1 -0
- package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
- package/assets/esri/core/workers/chunks/{9fac5a12e878cd745354.js → 28020063048e644f17a5.js} +1 -1
- package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 2a8dff8521e1e6a10cf6.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
- package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
- package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
- package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
- package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
- package/assets/esri/core/workers/chunks/36d067c8d03d7a894f5f.js +1 -0
- package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
- package/assets/esri/core/workers/chunks/{aa54b6f2aba6952af149.js → 38cc18fd93c18815ded0.js} +1 -1
- package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 3afb83f5de033dda89ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
- package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
- package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
- package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
- package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
- package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
- package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 59d3cac32ad6dad941dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/5f402b3c00bc4afc77b2.js +1 -0
- package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
- package/assets/esri/core/workers/chunks/{fd2efd1d1cf9d95a87e6.js → 63a6f3e70d2b6ea57e40.js} +1 -1
- package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{c4e4da69969499a89a2c.js → 695cdef5057e5461078a.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
- package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
- package/assets/esri/core/workers/chunks/{811d4c46c75cf6a63e78.js → 6bb7dbc46787b8e34bd9.js} +1 -1
- package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
- package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{cd1930f08e1fc8b30b14.js → 6ee2f0f708494102a493.js} +1 -1
- package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
- package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
- package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
- package/assets/esri/core/workers/chunks/78694ad8229347903f41.js +1 -0
- package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
- package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
- package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
- package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
- package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
- package/assets/esri/core/workers/chunks/90cbd627d4113db3b686.js +1 -0
- package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
- package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
- package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
- package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
- package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
- package/assets/esri/core/workers/chunks/{6f4bd0ee85e7e5a74340.js → a31635a6366347dcef0f.js} +1 -1
- package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
- package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → a876d6159ca120c1567e.js} +1 -1
- package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
- package/assets/esri/core/workers/chunks/{d1fe816b6990918c13c7.js → afc13d5b842275db7dbc.js} +1 -1
- package/assets/esri/core/workers/chunks/aff8e40a641c6822af1d.js +1 -0
- package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b0365cbc3d2a41969e3b.js} +1 -1
- package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
- package/assets/esri/core/workers/chunks/b548910e820d731ffe8a.js +1 -0
- package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → b708792c84620b73c847.js} +1 -1
- package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
- package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
- package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
- package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
- package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
- package/assets/esri/core/workers/chunks/ce98416437cc1a89d8ea.js +1 -0
- package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
- package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
- package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
- package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
- package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
- package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
- package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → d88f2fe680b8d5603ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
- package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
- package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
- package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
- package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
- package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
- package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
- package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ffd4710d168c2fcfd96.js → ebf23b46db56aaa88841.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
- package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
- package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
- package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
- package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
- package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → fef45bc59c71f88c60b5.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/config.js +1 -1
- package/core/QueueProcessor.js +1 -1
- package/core/SetUtils.js +1 -1
- package/core/has.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/identity/Credential.js +1 -1
- package/identity/IdentityManager.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/interfaces.d.ts +67 -27
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/support/fieldConfigUtils.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/source/DataLayerSource.js +1 -1
- package/package.json +3 -3
- package/popup/FieldInfo.js +1 -1
- package/processRequest.js +5 -0
- package/request.js +1 -1
- package/requestConfig.js +5 -0
- package/requestQueue.js +5 -0
- package/rest/query/executeForCount.js +1 -1
- package/rest/query/executeForExtent.js +1 -1
- package/rest/query/executeForIds.js +1 -1
- package/rest/query/executeQueryJSON.js +1 -1
- package/rest/query/executeQueryPBF.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/support/BaseImageMeasureResultValue.js +5 -0
- package/rest/support/ImageAreaResult.js +1 -1
- package/rest/support/ImageDistanceResult.js +1 -1
- package/rest/support/ImageHeightResult.js +1 -1
- package/rest/support/ImageMeasureResultAngleValue.js +5 -0
- package/rest/support/ImageMeasureResultAreaValue.js +5 -0
- package/rest/support/ImageMeasureResultLengthValue.js +5 -0
- package/rest/support/ImageWithType.js +5 -0
- package/rest/support/imageMeasureUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
- package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
- package/views/3d/glTF/DefaultLoadingContext.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/layers/ElevationLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
- package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/layers/support/fetchTile.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/StreamTextureCollection.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/input/CursorUpdateEvents.js +5 -0
- package/views/draw/input/DrawCompleteEvent.js +5 -0
- package/views/draw/input/VertexAddEvent.js +5 -0
- package/views/draw/input/VertexRemoveEvent.js +5 -0
- package/views/draw/input/VertexUpdateEvent.js +5 -0
- package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
- package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
- package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
- package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
- package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
- package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
- package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
- package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
- package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
- package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
- package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
- package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
- package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
- package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
- package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
- package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
- package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
- package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
- package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
- package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
- package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
- package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
- package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
- package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
- package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
- package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
- package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
- package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
- package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
- package/assets/esri/core/workers/chunks/f4d0ae6be1b3984228d0.js +0 -1
- package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
- package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
- package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
- package/views/3d/support/StreamDataLoader.js +0 -5
- package/views/3d/support/StreamDataRequester.js +0 -5
- package/views/3d/support/downloadSlots.js +0 -5
- package/views/draw/input/DrawEvents.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4383,9117,9187],{5247:(t,e,s)=>{s.d(e,{O:()=>h});var n=s(76061),i=s(55537),r=s(88885),o=r.D;class a extends n.G{constructor(t,e,s,n,i,r){super(),this.m_densificator=new o(e,s,n,r,!1,i),this.m_index=-1,this.m_inputGeoms=t}tock(){return!0}getRank(){return 1}next(){let t=null;for(;t=this.m_inputGeoms.next();)return(0,i.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),this.densify(t);return null}getGeometryID(){return this.m_index}densify(t){return this.m_densificator.densify(t)}}class h{getOperatorType(){return 10202}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}executeMany(t,e,s,n,i,r=12e3){return new a(t,e,s,n,r,i)}execute(t,e,s,n,i,o=12e3){return(0,r.d)(t,e,s,n,i,o)}}},24383:(t,e,s)=>{s.d(e,{NonSimpleResult:()=>n});class n{assign(t){this.m_reason=t.m_reason,this.m_vertexIndex1=t.m_vertexIndex1,this.m_vertexIndex2=t.m_vertexIndex2}constructor(t,e,s){void 0!==t?(this.m_reason=t,this.m_vertexIndex1=e,this.m_vertexIndex2=s):(this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-2)}clear(){this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-1}}},31139:(t,e,s)=>{s.d(e,{O:()=>g,a:()=>u,c:()=>m});var n=s(76061),i=s(55537),r=s(95213),o=s(79187),a=s(88885),h=s(83661);function m(t,e,s,n,i){return l(t,e,null,s,n,i)}function l(t,e,s,n,a,h){const l=t.getGeometryType();if(l===i.G.enumPoint){const s=t.getXY();return e.contains(s)?t:t.createInstance()}if(l===i.G.enumEnvelope){const s=o.Envelope2D.constructEmpty();if(t.queryEnvelope(s),s.intersect(e)){const e=t.clone();return e.setEnvelope(s),e}return t.createInstance()}if(t.isEmpty())return t;if(e.isEmpty())return t.createInstance();const u=e.clone();{const e=new o.Envelope2D;if(t.queryLooseEnvelope(e),u.containsEnvelope(e))return t;if(!u.isIntersecting(e))return t.createInstance();0===a&&(e.intersect(u),e.inflate(Math.max(.1*e.maxDimension(),1)),e.intersect(u),u.assign(e))}let g=n;if((null!==s||Number.isNaN(g))&&(g=(0,r.c)(s,u,!1).total()),l===i.G.enumGeometryCollection){const e=t,s=t.createInstance();for(let t=0,n=e.getGeometryCount();t<n;t++){const n=e.getGeometry(t);if(n.isEmpty())continue;const i=m(n,u,g,a,h);i.isEmpty()||(i===n?s.addGeometry(i.clone()):s.addGeometry(i))}return s}(0,i.i)(l)||(0,i.a)("Clip: geometry not supported");const d=t.getImpl().getAccelerators();if(null!==d){const t=d.getRasterizedGeometry();(0,i.g)(null===t)}switch(l){case i.G.enumMultiPoint:{const e=t;let s;const n=e.getPointCount(),r=e.getImpl().getAttributeStreamRef(0);let o=0;for(let t=0;t<n;t++){const n=r.readPoint2D(2*t);u.contains(n)||(0===o&&(s=e.createInstance()),o<t&&s.addPoints(e,o,t),o=t+1)}return o>0&&s.addPoints(e,o,n),0===o?e:((0,i.g)(null!==s),s)}case i.G.enumPolygon:case i.G.enumPolyline:return function(t,e,s,n,i){return new c(e,i).clipMultiPath2(t,s,n)}(t,u,g,a,h);default:(0,i.d)("")}}function u(t,e,s,n,i,r){const a=new c(e,r),h=new o.Envelope2D;return t.queryLooseEnvelope(h),e.containsEnvelope(h)?t:e.isIntersecting(h)?a.clipPolesOut(t,i):t.createInstance()}class c{constructor(t,e){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(t),this.m_progressTracker=e}progress_(){}clipMultiPath2(t,e,s){return t.getGeometryType()===i.G.enumPolygon?this.clipPolygonOrProjectedPolyline2(t,s):this.clipPolyline(t,e)}clipPolygonOrProjectedPolyline2(t,e){const s=t.getGeometryType()===i.G.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return t.createInstance();const n=o.Envelope2D.constructEmpty();t.queryLooseEnvelope(n),this.m_geometry=s?this.m_shape.addGeometry(t):this.m_shape.addGeometry(t,this.m_extent);const r=o.Envelope2D.constructEmpty(),m=o.Envelope2D.constructEmpty(),l=new h.P,u=new h.P,g=(0,h.d)(9,Number.NaN),d=(0,h.d)(9,Number.NaN),_=(0,h.m)(h.P,9);let p=null;const f=new a.L,x=[];let P=!1;for(let t=0;!P&&t<4;t++){let e=!1;const o=!!(1&t);let h=0;switch(t){case 0:h=this.m_extent.xmin,e=n.xmin<=h&&n.xmax>=h;break;case 1:h=this.m_extent.ymin,e=n.ymin<=h&&n.ymax>=h;break;case 2:h=this.m_extent.xmax,e=n.xmin<=h&&n.xmax>=h;break;case 3:h=this.m_extent.ymax,e=n.ymin<=h&&n.ymax>=h}if(e){P=!0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==a.n;){let n=!0,y=-1,E=-1;const C=this.m_shape.getFirstVertex(e);let v=C;do{this.progress_(),p=this.m_shape.getSegment(v);let e=p;if(null===e){const t=this.m_shape.getNextVertex(v);if(t===a.n){(0,i.g)(s),0===y&&x.push(v);break}this.m_shape.queryXY(v,l),f.setStartXY(l),this.m_shape.queryXY(t,u),f.setEndXY(u),e=f}e.queryLooseEnvelope(r);let C=c.checkSegmentIntersection(r,t,h);e.isCurve()&&0===C&&e.isCurve()&&(f.setStartXY(e.getStartXY()),f.setEndXY(e.getEndXY()),this.m_shape.replaceCurveWithLine(v),e=f,f.queryEnvelope(r),C=c.checkSegmentIntersection(r,t,h));let S=0,b=a.n;if(-1===C){const s=e.intersectionWithAxis2D(o,h,g,d);if(s>0){let t=null;if(e.isCurve()){t=_,(0,i.g)(s<=9);for(let t=0;t<s;t++)o?_[t].setCoords(g[t],h):_[t].setCoords(h,g[t]);S=this.m_shape.splitSegmentAxisAware(v,d,s,t,o?1:0)}else S=this.m_shape.splitSegmentAxisAware(v,d,s,null,-1)}else S=0;S+=1;let r=v,a=this.m_shape.getNextVertex(r);e=null;for(let e=0;e<S;e++){this.m_shape.queryXY(r,l),this.m_shape.queryXY(a,u),p=this.m_shape.getSegment(r);let e=p;null===e&&(f.setStartXY(l),f.setEndXY(u),e=f),e.queryEnvelope(m);let s=c.checkSegmentIntersection(m,t,h);e.isCurve()&&0===s&&(this.m_shape.replaceCurveWithLine(r),f.setStartXY(l),f.setEndXY(u),e=f,e.queryEnvelope(m),s=c.checkSegmentIntersection(m,t,h)),-1===s&&(o?Math.abs(l.y-h)<Math.abs(u.y-h)?(l.y=h,this.m_shape.setXY(r,l)):(u.y=h,this.m_shape.setXY(a,u)):Math.abs(l.x-h)<Math.abs(u.x-h)?(l.x=h,this.m_shape.setXY(r,l)):(u.x=h,this.m_shape.setXY(a,u)),p=this.m_shape.getSegment(r),e=p,null===e&&(f.setStartXY(l),f.setEndXY(u),e=f),e.queryEnvelope(m),s=c.checkSegmentIntersection(m,t,h),-1===s&&(s=c.checkSegmentIntersectionLoose(m,t,h)));const i=y;y=s,-1===E&&(E=y),0===i&&1===y||1===i&&0===y||0===i&&0===y&&x.push(r),1===y&&(P=!1,n=!1),r=a,b=r,a=this.m_shape.getNextVertex(a)}}if(0===S){const t=y;y=C,-1===E&&(E=y),0===t&&y>=1||t>=1&&0===y||0===t&&0===y&&x.push(v),1===y&&(P=!1,n=!1),b=this.m_shape.getNextVertex(v)}if(v=b,x.length>=256){for(let t=1,e=x.length-1;t<e;t++){const e=x[t];s?this.m_shape.snapVertexForPoleClipping(e,h):this.m_shape.removeVertex(e,!1)}x[1]=x.at(-1),x.length=2}}while(v!==C);if(!n){0!==E||!s&&0!==y&&2!==y||x.push(C);for(let t=0,e=x.length;t<e;t++){const e=x[t];s?this.m_shape.snapVertexForPoleClipping(e,h):this.m_shape.removeVertex(e,!1)}}x.length=0,e=n||0===this.m_shape.getPathSize(e)?this.m_shape.removePath(e):this.m_shape.getNextPath(e)}}}if(P)return t.createInstance();p=null,s?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),e>0&&this.densifyAlongClipExtent(e);const y=this.m_shape.getGeometry(this.m_geometry);return y.getGeometryType()===i.G.enumPolygon&&y.setFillRule(t.getFillRule()),y}clipPolyline(t,e){const s=o.Envelope2D.constructEmpty(),n=o.Envelope2D.constructEmpty(),i=(0,h.d)(9,Number.NaN),r=(0,h.d)(9,Number.NaN),m=new a.S;let l=t;const u=o.Envelope2D.constructEmpty();t.queryLooseEnvelope(u);for(let e=0;e<4;e++){let o=!1;const a=!!(1&e);let g=0;switch(e){case 0:g=this.m_extent.xmin,o=u.xmin<=g&&u.xmax>=g;break;case 1:g=this.m_extent.ymin,o=u.ymin<=g&&u.ymax>=g;break;case 2:g=this.m_extent.xmax,o=u.xmin<=g&&u.xmax>=g;break;case 3:g=this.m_extent.ymax,o=u.ymin<=g&&u.ymax>=g}if(!o)continue;const d=l;l=t.createInstance();const _=d.getImpl().querySegmentIterator();_.resetToFirstPath();const p=new h.P,f=new h.P;for(;_.nextPath();){let t=-1,o=!0;for(;_.hasNextSegment();){this.progress_();const h=_.nextSegment(),u=h.isDegenerate(0);h.queryLooseEnvelope(s);const d=c.checkSegmentIntersection(s,e,g);if(-1===d){const s=h.intersectionWithAxis2D(a,g,i,r);let d=0;p.assign(h.getStartXY());for(let _=0;_<=s;_++){const x=_<s?r[_]:1;if(d===x)continue;h.queryCut(d,x,m,!1);const P=m.get();let y=!1;if(P.getStartXY().equals(p)||(P.setStartXY(p),y=!0),_<s&&(a?(f.x=i[_],f.y=g):(f.x=g,f.y=i[_]),P.getEndXY().equals(f)||(P.setEndXY(f),y=!0)),y&&P.normalizeAfterEndpointChange(),!u&&P.isDegenerate(0))continue;P.queryEnvelope(n);let E=c.checkSegmentIntersection(n,e,g);if(-1===E){const t=P.getStartXY(),s=P.getEndXY();y=!1,a?Math.abs(t.y-g)<Math.abs(s.y-g)?(t.y=g,P.setStartXY(t),t.equals(P.getStartXY())||(P.setStartXY(t),y=!0)):(s.y=g,s.equals(P.getEndXY())||(P.setEndXY(s),y=!0)):Math.abs(t.x-g)<Math.abs(s.x-g)?(t.x=g,t.equals(P.getStartXY())||(P.setStartXY(t),y=!0)):(s.x=g,s.equals(P.getEndXY())||(P.setEndXY(s),y=!0)),y&&P.normalizeAfterEndpointChange(),P.queryEnvelope(n),E=c.checkSegmentIntersection(n,e,g),-1===E&&(E=c.checkSegmentIntersectionLoose(n,e,g))}p.assign(P.getEndXY()),d=x,t=E,t>=1?(l.addSegment(P,o),o=!1):o=!0}}else t=d,t>=1?(l.addSegment(h,o),o=!1):o=!0}}}return l}static checkSegmentIntersection(t,e,s){switch(e){case 0:return t.xmin<s&&t.xmax<=s?0:t.xmin>=s?t.xmax===s?2:1:-1;case 1:return t.ymin<s&&t.ymax<=s?0:t.ymin>=s?t.ymax===s?2:1:-1;case 2:return t.xmin>=s&&t.xmax>s?0:t.xmax<=s?t.xmin===s?2:1:-1;case 3:return t.ymin>=s&&t.ymax>s?0:t.ymax<=s?t.ymin===s?2:1:-1}return(0,i.d)(""),0}static checkSegmentIntersectionLoose(t,e,s){switch(e){case 0:{const e=Math.abs(t.xmin-s),n=Math.abs(t.xmax-s);return t.xmin<s?e>n?0:1:((0,i.d)(""),1)}case 1:{const e=Math.abs(t.ymin-s),n=Math.abs(t.ymax-s);return t.ymin<s?e>n?0:1:((0,i.d)(""),1)}case 2:{const e=Math.abs(t.xmin-s),n=Math.abs(t.xmax-s);return t.xmax>s?e<n?0:1:((0,i.d)(""),1)}case 3:{const e=Math.abs(t.ymin-s),n=Math.abs(t.ymax-s);return t.ymax>s?e<n?0:1:((0,i.d)(""),1)}}return(0,i.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 t=new h.P;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==a.n;e=this.m_shape.getNextPath(e)){let s=this.m_shape.getFirstVertex(e);for(let n=0,i=this.m_shape.getPathSize(e);n<i;n++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,t),this.m_extent.xmin!==t.x&&this.m_extent.xmax!==t.x&&this.m_extent.ymin!==t.y&&this.m_extent.ymax!==t.y||(this.m_shape.setUserIndex(s,this.m_verticesOnExtentIndex,this.m_verticesOnExtent.length),this.m_verticesOnExtent.push(s))}this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmin),this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmax),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymin),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymax),this.fixPaths()}densifyAlongClipExtent(t){const e=new h.P(0,0),s=new h.P(0,0),n=(0,h.d)(2048,Number.NaN);for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==a.n;r=this.m_shape.getNextPath(r)){const o=this.m_shape.getFirstVertex(r);let a=o;do{const r=this.m_shape.getNextVertex(a);this.m_shape.queryXY(a,e);let o=-1;if(e.x===this.m_extent.xmin?(this.m_shape.queryXY(r,s),s.x===this.m_extent.xmin&&(o=1)):e.x===this.m_extent.xmax&&(this.m_shape.queryXY(r,s),s.x===this.m_extent.xmax&&(o=1)),e.y===this.m_extent.ymin?(this.m_shape.queryXY(r,s),s.y===this.m_extent.ymin&&(o=0)):e.y===this.m_extent.ymax&&(this.m_shape.queryXY(r,s),s.y===this.m_extent.ymax&&(o=0)),-1===o){a=r;continue}if(this.isCurve(a)){a=r;continue}const m=e.clone(),l=new h.P(0,0);if(o){const n=e.y-this.m_extent.ymin;l.y=(0,h.e)(s.y-e.y),m.y=t*(0,h.f)(Math.floor(Math.abs(n)/t),n)+this.m_extent.ymin,l.y<0&&(m.y+=t)}else{const n=e.x-this.m_extent.xmin;l.x=(0,h.e)(s.x-e.x),m.x=t*(0,h.f)(Math.floor(Math.abs(n)/t),n)+this.m_extent.xmin,l.x<0&&(m.x+=t)}const u=o?s.y-e.y:s.x-e.x,c=Math.abs(u);if(c/t>65536&&(0,i.d)(""),c>0){const s=Math.trunc(c/t)+2;n.length<s&&(n.length=s);let r=0;for(let s=0;;s++){const a=m.add(l.mul(s*t)),h=(o?a.y-e.y:a.x-e.x)/u;if(h>=1)break;h<=0||((0,i.g)(r<=n.length),n[r]=h,r++)}0!==r&&this.m_shape.splitSegment(a,n,r)}a=r}while(a!==o)}}splitSegments(t,e){let s=-1;const n=new h.P,i=[];for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==a.n;r=this.m_shape.getNextPath(r)){let o=this.m_shape.getFirstVertex(r),h=a.n;for(let a=0,m=this.m_shape.getPathSize(r);a<m;a++,o=h)if(this.progress_(),h=this.m_shape.getNextVertex(o),this.m_shape.queryXY(o,n),(t?n.y===e:n.x===e)&&(this.m_shape.queryXY(h,n),t?n.y===e:n.x===e)){if(this.isCurve(o))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(o,s)&&(i.push(o),this.m_shape.setUserIndex(o,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(i.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),i.length<3)return;i.sort((t,e)=>this.compareVertices(t,e));const r=new h.P,o=new h.P,m=new h.P;o.setNAN();let l=-1,u=[],c=[];const g=this.m_shape.createUserIndex(),d=this.m_shape.createUserIndex();for(let s=0,a=i.length;s<a;s++){const a=i[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=i[n],a=this.m_shape.getNextVertex(s),h=this.m_shape.getPrevVertex(s);let m=!1;this.m_shape.queryXY(a,r),o.compare(r)<0&&(t?r.y===e:r.x===e)&&(this.isCurve(s)||(u.push(s),m=!0,this.m_shape.setUserIndex(s,d,1))),this.m_shape.queryXY(h,r),o.compare(r)<0&&(t?r.y===e:r.x===e)&&(this.isCurve(h)||(m||u.push(s),this.m_shape.setUserIndex(s,g,1)))}for(let t=0,e=u.length;t<e;t++){const e=u[t],s=this.m_shape.getUserIndex(e,g),i=this.m_shape.getUserIndex(e,d);if(1===s){const t=this.m_shape.getPrevVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(n)){const i=h.P.distance(o,m);s=h.P.distance(m,n)/i,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const r=this.m_shape.getPrevVertex(e);this.m_shape.setXY(r,n),c.push(r),this.m_shape.setUserIndex(r,g,1),this.m_shape.setUserIndex(r,d,-1)}}if(1===i){const t=this.m_shape.getNextVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(n)){const t=h.P.distance(o,m);s=h.P.distance(o,n)/t,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const i=this.m_shape.getNextVertex(e);this.m_shape.setXY(i,n),c.push(i),this.m_shape.setUserIndex(i,g,-1),this.m_shape.setUserIndex(i,d,1)}}}const a=u;u=c,c=a,c.length=0,l=s,o.setCoordsPoint2D(n)}}this.m_shape.removeUserIndex(g),this.m_shape.removeUserIndex(d)}resolveOverlaps(t,e){const s=new h.P,n=[];let r=-1;for(let i=0,o=this.m_verticesOnExtent.length;i<o;i++){this.progress_();const o=this.m_verticesOnExtent[i];if(o===a.n)continue;const h=this.m_shape.getNextVertex(o);if(this.m_shape.queryXY(o,s),(t?s.y===e:s.x===e)&&(this.m_shape.queryXY(h,s),t?s.y===e:s.x===e)){if(this.isCurve(o))continue;-1===r&&(r=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(o,r)&&(n.push(o),this.m_shape.setUserIndex(o,r,-2)),-2!==this.m_shape.getUserIndex(h,r)&&(n.push(h),this.m_shape.setUserIndex(h,r,-2))}}if(0===n.length)return void(-1!==r&&this.m_shape.removeUserIndex(r));(0,i.g)(-1!==r),n.sort((t,e)=>this.compareVertices(t,e));for(let t=0,e=n.length;t<e;t++){const e=n[t];this.m_shape.setUserIndex(e,r,t)}const o=new h.P,m=new h.P;m.setNAN();let l=-1;for(let i=0,h=n.length;i<h;i++){this.progress_();const h=n[i];if(h!==a.n&&(this.m_shape.queryXY(h,s),!s.isEqualPoint2D(m))){if(-1!==l)for(;;){let s=!1;const h=i;for(let u=l;u<h;u++){const h=n[u];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&&(t?o.y===e:o.x===e)&&(this.isCurve(h)||(l=c));let g=a.n;const d=this.m_shape.getPrevVertex(h);if(this.m_shape.queryXY(d,o),m.compare(o)<0&&(t?o.y===e:o.x===e)&&(this.isCurve(d)||(g=d)),l===a.n||g===a.n){if(l!==a.n||g!==a.n){for(let c=u+1;c<i;c++){const i=n[c];if(i===a.n)continue;const u=this.m_shape.getNextVertex(i);let d=a.n;this.m_shape.queryXY(u,o),m.compare(o)<0&&(t?o.y===e:o.x===e)&&(this.isCurve(i)||(d=u));const _=this.m_shape.getPrevVertex(i);let p=a.n;if(this.m_shape.queryXY(_,o),m.compare(o)<0&&(t?o.y===e:o.x===e)&&(this.isCurve(_)||(p=_)),d!==a.n&&p!==a.n){this.beforeRemoveVertex(i,n,r),this.m_shape.removeVertex(i,!1),this.beforeRemoveVertex(d,n,r),this.m_shape.removeVertex(d,!1),s=!0;break}if(l!==a.n&&p!==a.n){this.removeOverlap(n,h,l,i,p,r),s=!0;break}if(g!==a.n&&d!==a.n){this.removeOverlap(n,i,d,h,g,r),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(h,n,r),this.m_shape.removeVertex(h,!1),this.beforeRemoveVertex(l,n,r),this.m_shape.removeVertex(l,!1),s=!0}if(!s)break}l=i,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(r)}beforeRemoveVertex(t,e,s){let n=this.m_shape.getUserIndex(t,s);(0,i.g)(n>=0),e[n]=a.n,n=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),(0,i.g)(n>=0),this.m_verticesOnExtent[n]=a.n;const r=this.m_shape.getPathFromVertex(t);r!==a.n&&this.m_shape.getFirstVertex(r)===t&&(this.m_shape.setFirstVertex(r,a.n),this.m_shape.setLastVertex(r,a.n))}removeOverlap(t,e,s,n,i,r){this.m_shape.setNextVertex(e,n),this.m_shape.setPrevVertex(n,e),this.m_shape.setPrevVertex(s,i),this.m_shape.setNextVertex(i,s),this.beforeRemoveVertex(n,t,r),this.m_shape.removeVertexInternal(n,!1),this.beforeRemoveVertex(i,t,r),this.m_shape.removeVertexInternal(i,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(t){for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==a.n;e=this.m_shape.getNextPath(e)){const s=this.m_shape.getPathSize(e);if(s<3)continue;let n=this.m_shape.getFirstVertex(e);const i=new h.P;this.m_shape.queryXY(n,i);let r=i.y===t&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const o=new h.P;this.m_shape.queryXY(n,o);let a=o.y===t&&!this.isCurve(n);n=this.m_shape.getNextVertex(n);const m=new h.P;for(let e=0,h=s-2;e<h;e++,n=this.m_shape.getNextVertex(n)){this.progress_(),this.m_shape.queryXY(n,m);const e=m.y===t;a&&r&&e&&(o.x-i.x)*(m.x-o.x)<=0?(this.m_shape.removeVertex(this.m_shape.getPrevVertex(n),!1),o.setCoordsPoint2D(m),a=e&&!this.isCurve(n)):(i.setCoordsPoint2D(o),r=a,o.setCoordsPoint2D(m),a=e&&!this.isCurve(n))}}}fixPaths(){for(let t=0,e=this.m_verticesOnExtent.length;t<e;t++){const e=this.m_verticesOnExtent[t];e!==a.n&&this.m_shape.setPathToVertex(e,a.n)}const t=this.m_shape.hasCurves();let e=0,s=0;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==a.n;){const n=this.m_shape.getFirstVertex(t);if(n===a.n||t!==this.m_shape.getPathFromVertex(n)){const e=t;t=this.m_shape.getNextPath(t),this.m_shape.setFirstVertex(e,a.n),this.m_shape.removePathOnly(e);continue}let i=n,r=0;do{this.m_shape.setPathToVertex(i,t),r++,i=this.m_shape.getNextVertex(i)}while(i!==n);this.m_shape.setRingAreaValid(t,!1),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(n)),this.m_shape.setPathSize(t,r),s+=r,e++,t=this.m_shape.getNextPath(t)}for(let n=0,r=this.m_verticesOnExtent.length;n<r;n++){let r=this.m_verticesOnExtent[n];if(r===a.n)continue;let o=this.m_shape.getPathFromVertex(r);if(o!==a.n)continue;o=this.m_shape.insertPath(this.m_geometry,a.n);let h=!1,m=0;const l=r;do{this.m_shape.setPathToVertex(r,o),m++,t&&m<=2&&(h||=this.isCurve(r)),r=this.m_shape.getNextVertex(r)}while(r!==l);if(h?0===m:m<=2){let t=this.m_shape.getUserIndex(l,this.m_verticesOnExtentIndex);(0,i.g)(t>=0),this.m_verticesOnExtent[t]=a.n;const e=this.m_shape.removeVertex(l,!1);2===m&&(t=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),t>=0&&(this.m_verticesOnExtent[t]=a.n),this.m_shape.removeVertex(e,!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,e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let n=0;for(let t=this.m_shape.getFirstGeometry();t!==a.n;t=this.m_shape.getNextGeometry(t))n+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(n)}dbgCheckPathFirst(){}isCurve(t){return null!==this.m_shape.getSegment(t)}compareVertices(t,e){const s=new h.P;this.m_shape.queryXY(t,s);const n=new h.P;return this.m_shape.queryXY(e,n),s.compare(n)}clipPolesOut(t,e){return this.clipPolygonOrProjectedPolyline2(t,e)}}class g{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,n){return new d(t,e,s,n)}execute(t,e,s,n){return function(t,e,s,n){return l(t,e,s,Number.NaN,0,n)}(t,e,s,n)}}class d extends n.G{constructor(t,e,s,n){super(),this.m_progressTracker=n,this.m_index=-1,t||(0,i.a)(""),this.m_envelope=e,this.m_inputGeometryCursor=t,this.m_spatialRefImpl=s,this.m_tolerance=(0,r.c)(s,e,!1).total()}next(){let t;return(t=this.m_inputGeometryCursor.next())?((0,i.c)(t),this.m_index=this.m_inputGeometryCursor.getGeometryID(),m(t,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},39117:(t,e,s)=>{s.d(e,{$:()=>Zo,A:()=>cr,B:()=>dr,C:()=>ur,D:()=>Ks,E:()=>ri,F:()=>ui,G:()=>en,H:()=>Je,I:()=>si,J:()=>$t,K:()=>oi,L:()=>hi,M:()=>Vs,N:()=>ks,O:()=>un,P:()=>fr,Q:()=>ms,R:()=>hs,S:()=>mo,T:()=>rs,U:()=>Gs,V:()=>Ss,W:()=>us,X:()=>Is,a:()=>lo,a0:()=>ko,a1:()=>Lo,a2:()=>Oo,a3:()=>Ii,a4:()=>Ei,a5:()=>Fi,a6:()=>So,a7:()=>Go,a8:()=>Do,a9:()=>S,aC:()=>Io,aF:()=>Ft,aG:()=>Xt,aH:()=>ni,aI:()=>ii,aJ:()=>os,aK:()=>ws,aU:()=>bo,aV:()=>qi,aW:()=>q,aX:()=>Wn,aY:()=>d,aa:()=>Mi,ab:()=>Hi,ac:()=>C,ad:()=>Gi,ae:()=>wi,af:()=>ts,ag:()=>D,ah:()=>qo,ai:()=>gn,aj:()=>dn,ak:()=>x,al:()=>ir,am:()=>Yn,an:()=>bi,ao:()=>vo,ap:()=>Vn,aq:()=>fn,ar:()=>xn,as:()=>_n,at:()=>pn,au:()=>Rn,b:()=>Or,c:()=>Ur,d:()=>Wr,e:()=>Qr,f:()=>jr,g:()=>Zr,h:()=>$r,i:()=>ao,j:()=>Hr,k:()=>Br,l:()=>Lr,m:()=>kr,n:()=>zr,o:()=>ho,p:()=>Jr,q:()=>to,r:()=>Rr,s:()=>Kr,t:()=>co,u:()=>go,v:()=>ar,w:()=>uo,x:()=>mr,y:()=>hr,z:()=>lr});var n=s(55537),i=s(79187),r=s(88885),o=s(95213),a=s(83661),h=s(31635),m=s(11878),l=s(31139),u=s(5247),c=s(76061),g=s(24383);class d{constructor(t){if(this.m_geom=this.m_sr=null,t){if(t.move)return this.m_geom=t.move.m_geom,t.move.m_geom=null,this.m_sr=t.move.m_sr,void(t.move.m_sr=null);if(t.copy)return this.m_geom=t.copy.m_geom?t.copy.m_geom.clone():null,void(this.m_sr=t.copy.m_sr);t.geom&&(this.m_geom=t.geom),t.sr&&(this.m_sr=t.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(t){this.m_geom=t}setSpatialReference(t){this.m_sr=t}equals(t,e){const s=t;return!(!this.m_sr&&s.m_sr||this.m_sr&&!s.m_sr||!this.m_geom&&s.m_geom||this.m_geom&&!s.m_geom||this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr)||this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,e))}clone(){let t=null;return this.m_geom&&(t=this.m_geom.clone()),new d({geom:t,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class _{constructor(t){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,t&&(this.m_peUnit=t,this.m_factor=t.getUnitFactor(),this.m_wkid=t.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():""}getID(){return this.m_wkid}getConversionFactor(t){return this.getUnitType()!==t.getUnitType()&&(0,n.a)("unit type mismatch"),this.getUnitToBaseFactor()/t.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return(0,a.A)((0,a.B)(this.getUnitType()),(0,a.B)(this.getUnitToBaseFactor()))}equals(t){return!!t&&this.getUnitType()===t.getUnitType()&&this.getUnitToBaseFactor()===t.getUnitToBaseFactor()&&this.getID()===t.getID()&&this.getName()===t.getName()}static isValidWkid(t){return!1}}const p={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,10799,10800,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,10635,10636,10735,10736,10758,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,6377397.155:[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],6377563.396:[4001,4188,4277,4278,4279],6377340.189:[4002,4299,4300],6377492.018:[4005,4273,4817],6377483.865280418:[4006,4293],6378293.645208759:[4007,4157,4302,4738,5464],6378206.4:[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],6378450.047:[4009,4268],6378300.789:[4010,4281],6378249.2:[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],6378249.145:[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104103,104305],6377276.345:[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],6377298.556:[4016,4298],6377304.063:[4018,4245],6378298.3:[4028,4903],6378136.2:4032,6378136.3:4033,6378249.144808011:[4034,4241],20922931.8:[4042,4243],6377301.243:[4044,4145,37203],6377299.151:[4045,4146],6377019.27:[4657,10256,10260,10265],6378306.3696:[4748,4752],6377295.664:[4751,37006],6378136.5:[7682,7683],6371008.7714:104047,6378418.941:[104700,104726,104760],6378586.581:[104701,104743],6378505.809:104702,6378544.823:104703,6378490.569:104704,6378470.757:[104705,104776],6378403.701:[104706,104750],6378434.181:[104707,104724,104739,104764],6378454.907:104708,6378400.653:104709,6378567.378:104710,6378546.957:[104711,104717,104780],6378476.853:[104712,104736],6378411.321:[104713,104728],6378647.541:[104714,104715],6378514.953:[104716,104782],6378421.989:[104718,104770],6378481.425:[104719,104753,104774,104781],6378518.001:[104720,104725],6378521.049:[104721,104723,104731,104745,104748],6378464.661:104722,6378436.619:104727,6378574.389:[104729,104730],6378472.281:[104732,104756],6378498.189:[104733,104746],6378449.421:[104734,104766],6378525.621:[104735,104754],6378466.185:104737,6378496.665:104738,6378643.579:104740,6378559.758:104741,6378414.369:[104742,104763,104772],6378441.801:104744,6378502.761:[104747,104759,104773,104775],6378617.061:104749,6378624.681:[104751,104765],6378468.623:104752,6378445.763:[104755,104758,104761],6378670.401:104757,6378438.753:104762,6378543.909:104767,6378605.783:104768,6378540.861:104769,6378443.325:[104771,104784],6378548.481:104777,6378463.746:104778,6378426.561:104779,6378453.688:104783,6378530.193:104785,6378376.271:[104800,104828],6378471.92:104801,6378472.931:104802,6378411.351:104803,6378380.991:104805,6378414.96:104806,6378345.09:[104807,104819,104844,104870],6378412.542:104808,6378470.401:104809,6378376.331:104810,6378379.031:104811,6378407.621:104812,6378376.811:[104813,104827],6378313.92:104814,6378414.93:104815,6378413.021:104816,6378380.381:104817,6378530.851:104818,6378591.521:104820,6378378.881:104821,6378408.481:[104822,104832],6378375.601:[104823,104838],6378408.041:104824,6378655.071:104825,6378409.151:104826,6378315.7:[104829,104840,104845,104851],6378285.86:[104830,104835,104859],6378379.301:104831,6378560.121:104833,6378531.821:104834,6378500.6:104836,6378376.041:104837,6378406.601:104839,6378438.991:104841,6378345.42:104842,6378593.86:104843,6378381.271:[104846,104847],6378413.671:104848,6378344.377:104849,6378563.891:104850,6378408.091:104852,6378377.671:104853,6378472.751:104854,6378412.511:104855,6378407.281:104856,6378534.451:104857,6378406.051:104858,6378532.921:104860,6378380.091:104861,6378408.941:104862,6378624.171:104863,6378377.411:104864,6378474.591:104865,6378407.141:104866,6378376.871:104867,6378375.251:104868,6378405.971:104869,6378437.651:104871};class f extends _{constructor(t){if("number"==typeof t)return super(),this.m_factor=t,void(this.m_wkid=0);super(t)}getUnitType(){return 1}convertFromRadians(t){return t/this.getUnitToBaseFactor()}convertToRadians(t){return t*this.getUnitToBaseFactor()}}function x(t){return new Ar}class P{constructor(t,e,s){void 0===t?(this.x=new a.X,this.y=new a.X,this.z=new a.X):t instanceof o.d?(this.x=new a.X(t.x),this.y=new a.X(t.y),this.z=new a.X(t.z)):t instanceof a.X?(this.x=t.clone(),this.y=e.clone(),this.z=s.clone()):(0,n.a)("EPoint3D constructor")}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y)).addE(this.z.mulE(t.z))}crossProduct(t){return new P(this.y.mulE(t.z).subE(this.z.mulE(t.y)),this.z.mulE(t.x).subE(this.x.mulE(t.z)),this.x.mulE(t.y).subE(this.y.mulE(t.x)))}crossProductVector(t){const e=this.y.mulE(t.z).subE(t.y.mulE(this.z)),s=t.x.mulE(this.z).subE(this.x.mulE(t.z)),n=this.x.mulE(t.y).subE(t.x.mulE(this.y));return new P(e,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(t,e){return t.sub(e).length()}negate(){return new P(this.x.negate(),this.y.negate(),this.z.negate())}add(t){return new P(this.x.addE(t.x),this.y.addE(t.y),this.z.addE(t.z))}sub(t){return new P(this.x.subE(t.x),this.y.subE(t.y),this.z.subE(t.z))}subThis(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this.z.subThisE(t.z),this}addThis(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this.z.addThisE(t.z),this}mul(t){return new P(this.x.mulE(t),this.y.mulE(t),this.z.mulE(t))}div(t){return new P(this.x.divE(t),this.y.divE(t),this.z.divE(t))}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)&&this.z.eq(t.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return o.d.construct(this.x.value(),this.y.value(),this.z.value())}}class y{constructor(t){if(this.m_origin=new o.d,this.m_normal=new o.d,this.m_axisX=new o.d,this.m_axisY=new o.d,!t)return this.m_origin=new o.d,this.m_normal=new o.d(0,0,1),this.m_axisX=new o.d(1,0,0),void(this.m_axisY=new o.d(0,1,0));t.pt0&&t.pt1&&t.pt2?this.setFromPoints(t.pt0,t.pt1,t.pt2):(0,n.g)(0,`unimplemented constructor options ${JSON.stringify(t)}`)}assign(t){return(0,n.g)(0),this}set(t,e,s,i){(0,n.g)(0)}setFromPoints(t,e,s){let n=e.sub(t);const i=s.sub(t);this.m_normal=n.crossProductVector(i);let r=!0;if(this.m_normal.isZero()){if(r=!1,n.isZero()&&(n=i),n.isZero()){const e=0,s=1;return this.m_normal.setCoords(e,e,s),this.m_axisX.setCoords(s,e,e),this.m_axisY.setCoords(e,s,e),this.m_origin=t,!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=t,r}getCoord(t,e){return(0,n.g)(0),{}}getCoord2D(t){return(0,n.g)(0),{}}getCoordX(t,e){return(0,n.g)(0),0}getCoordY(t,e){return(0,n.g)(0),0}getCoordZ(t,e){return(0,n.g)(0),0}setPreferredAxisX(t){(0,n.g)(0)}getOrigin(){return(0,n.g)(0),{}}getNormal(){return(0,n.g)(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(t,e=!1){(0,n.g)(0)}setAxisY(t,e=!1){(0,n.g)(0)}recalculateAxisY(){(0,n.g)(0)}setOrigin(t){(0,n.g)(0)}setNormal(t,e){(0,n.g)(0)}intersect(t,e){return(0,n.g)(0),!1}intersectLine(t){return(0,n.g)(0),0}intersectLineEx(t,e){return(0,n.g)(0),0}closestCoordinate(t){const e=t.sub(this.m_origin),s=new a.P;return s.x=e.dotProduct(this.m_axisX),s.y=e.dotProduct(this.m_axisY),s}projectVector(t){return(0,n.g)(0),{}}signedDistance(t){return(0,n.g)(0),0}distance(t){return(0,n.g)(0),0}}function E(t,e){return!1}function C(t,e,s,i,r=100,o=E){let h,m,l,u,c,g,d,_,p;(0,n.g)(i>0);let f,x,P,y=0,C=0;const v=(0,a.a1)();e>s&&(s=(0,a.c)(e,e=s));const S=t(e),b=t(s);S<b?(h=m=l=e,u=c=g=S):(h=m=l=s,u=c=g=b);let I=0;for(;I<r&&(P=.5*(s-e),p=e+P,f=i*(Math.abs(h)+.25),x=2*f,!(o(h,u)||Math.abs(h-p)<=x-P));++I){if(Math.abs(C)>f){const t=(h-m)*(u-g);let n=(h-l)*(u-c),i=(h-l)*n-(h-m)*t;n=2*(n-t),n>0&&(i=-i),n=Math.abs(n);const r=C;C=y,Math.abs(i)>=Math.abs(n*r*.5)||i<=n*(e-h)||i>=n*(s-h)?(C=h>=p?e-h:s-h,y=(0,a.a1)()*C):(y=i/n,_=h+y,(_-e<x||s-_<x)&&(y=p-h<0?-Math.abs(f):Math.abs(f)))}else C=h>=p?e-h:s-h,y=C*v;_=h+y,d=t(_),d<u?(_>=h?e=h:s=h,l=m,m=h,h=_,g=c,c=u,u=d):(_<h?e=_:s=_,d<=c||m===h?(l=m,m=_,g=c,c=d):(d<=g||l===h||l===m)&&(l=_,g=d))}return(0,a.l)(h,u)}function v(t,e,s){return t>s?t-=Math.ceil((t-s)/a.p)*a.p:t<e&&(t+=Math.ceil((e-t)/a.p)*a.p),t}function S(t,e,s){return function(t,e,s){const n=s.x,i=s.y;return b(t,e,Math.cos(n),Math.sin(n),Math.cos(i),Math.sin(i),0)}(t,e,s)}function b(t,e,s,n,i,r,a){const h=t/Math.sqrt(1-e*r*r),m=h+a,l=m*i*s,u=m*i*n,c=(h*(1-e)+a)*r;return o.d.construct(l,u,c)}function I(t,e,s){const n=new a.X,i=new a.X,r=new a.X,o=new a.X;n.setCos(s.x),i.setSin(s.x),r.setCos(s.y),o.setSin(s.y);const h=o.negate().mulE(o.mul(e)).add(1).sqrt(),m=new a.X(t).divE(h),l=m.mulE(r).mulE(n),u=m.mulE(r).mulE(i),c=m.mul(1-e).mulE(o);return new P(l,u,c)}function D(t,e,s){const n=s.x,i=s.y,r=s.z,o=Math.atan2(i,n),h=Math.sqrt(n*n+i*i),m=Math.atan2(r,(1-e)*h);return a.P.construct(o,m)}function w(t,e,s){const n=1-e,i=t/Math.sqrt((0,a.a)(s.x)+(0,a.a)(s.y)+(0,a.a)(s.z)/n);return s.mul(i)}function T(t,e,s,n,i){const r=S(t,e,s),a=S(t,e,n);return D(0,e,o.d.lerp(r,a,i))}function N(t,e,s,i,r,m=0,l){if(2===m||3===m)return function(t,e,s,n,i,r=!1,h){const m=w(t,e,s);if(r){const r=new y({pt0:new o.d(0,0,0),pt1:n,pt2:i}),l=r.closestCoordinate(s),u=r.closestCoordinate(n),c=r.closestCoordinate(i),g=a.P.getClosestCoordinate(u,c,l),d=w(t,e,o.d.lerp(n,i,g)),_=o.d.distance(d,m);return h&&h.assign(d),(0,a.l)(g,_)}const l=s=>{const r=w(t,e,o.d.lerp(n,i,s));return o.d.distance(r,m)},u=o.d.distance(n,i);if(u>0){const s=F(t,u),{first:r,second:m}=C(l,0,1,s);return h&&h.assign(w(t,e,o.d.lerp(n,i,r))),(0,a.l)(r,m)}{const t=o.d.distance(s,n);return h&&h.assign(s),(0,a.l)(.5,t)}}(t,e,s,i,r,3===m,l);const u=D(0,e,s),c=s=>{const a=D(0,e,o.d.lerp(i,r,s));return function(t,e,s,i,r){switch((0,n.g)(s.isFinite()&&i.isFinite()),r){case 0:return function(t,e,s,n){const i={stack:[],error:void 0,hasError:!1};try{const r=(0,h.mS)(i,new So,!1);return Go.geodeticDistance(t,e,s.x,s.y,n.x,n.y,r,null,null,Io.PE_LINETYPE_GEODESIC),r.val}catch(t){i.error=t,i.hasError=!0}finally{(0,h.hk)(i)}}(t,e,s,i);case 1:return function(t,e,s){const n={stack:[],error:void 0,hasError:!1};try{const i=(0,h.mS)(n,new So,!1);return Go.greatEllipticDistance(t,e,s.x,s.y,s.x,s.y,i,null,null),i.val}catch(t){n.error=t,n.hasError=!0}finally{(0,h.hk)(n)}}(t,e,s);case 2:case 3:{const n=S(t,e,s),r=S(t,e,i);return o.d.distance(n,r)}default:(0,n.t)("")}}(t,e,u,a,m)},g=o.d.distance(i,r);if(g>0){const s=F(t,g),{first:n,second:h}=C(c,0,1,s);return l&&l.assign(w(t,e,o.d.lerp(i,r,n))),(0,a.l)(n,h)}{const t=c(0);return l&&l.assign(i),(0,a.l)(.5,t)}}function A(t,e,s,n,i,o){if(o[0]=Number.NaN,o[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>a.o||Math.abs(n.y)>a.o)return 0;if((Math.abs(s.y)===a.o||Math.abs(n.y)===a.o)&&s.x!==n.x)return 0;if(Math.abs(i)>=a.o)return 0;if(s.y>0&&n.y>0&&s.y>i&&n.y>i||s.y<0&&n.y<0&&s.y<i&&n.y<i)return 0;const h=r.X.constructPoint2D(s),m=r.X.constructPoint2D(n),l=I(1,e,h),u=I(1,e,m),c=l.crossProductVector(u);if(c.z.isZero())return a.E.construct(s.y,n.y).containsCoordinate(i)?(o[0]=s.x,1):0;const g=c.x.divE(c.z.negate()),d=c.y.divE(c.z.negate()),_=g.mulE(g).addE(d.mulE(d)).sqrt();if(_.isZero()||g.isZero()&&d.isZero())return 0===i?(o[0]=s.x,o[1]=n.x,2):0;const p=(1-e)*Math.tan(i)/_.value();if(Math.abs(p)>1)return 0;const f=Math.acos(p),x=Math.atan2(d.value(),g.value()),P=x-f;let y=x+f;const E=Math.min(s.x,n.x),C=Math.max(s.x,n.x);v(P,E,C),0!==i?v(y,E,C):y=P;let S=0;return E<=P&&P<=C&&(o[S]=P,S++),y!==P&&E<=y&&y<=C&&(o[S]=y,S++),S}function G(t,e){e[0]>.5*Math.PI?(t[0]+=Math.PI,e[0]=Math.PI-e[0]):e[0]<.5*-Math.PI&&(t[0]-=Math.PI,e[0]=-Math.PI-e[0]),(0,n.g)(e[0]>=.5*-Math.PI&&e[0]<=.5*Math.PI)}function q(t,e,s,n,i){n=(0,a.s)(n,-a.o,a.o),i=(0,a.s)(i,-a.o,a.o);const r=a.o-.03;let o;return o=n>r&&i>r||n<-r&&i<-r?function(t,e,s){let n=1;if(e<0&&(n=-1,e=-e,s=-s),0!==t){const i=t*t,r=i*t,o=[1,(1+11*t)/12,(1+118*t+241*i)/360,(1+1089*t+10419*i+8651*r)/20160,(1+9836*t+318246*i+1027436*r+r*t*458881)/1814400],h=e=>{let s=0;const n=(0,a.a)(e)/(t-1);for(let t=o.length-1;t>=0;--t)s=o[t]+s*n;return s*=-(0,a.a)(e/(1-t)),s},m=h(a.o-e);return(h(a.o-s)-m)*n}{const t=a.o-e,i=a.o-s,r=-4*(0,a.a)(Math.sin(t/2));return(-4*(0,a.a)(Math.sin(i/2))-r)*n}}(t,n,i):M(t,i)-M(t,n),.5*(s-e)*o*function(t){return 1-t}(t)}function M(t,e){if(0===e)return 0;const s=Math.sin(e);let n=s,i=s;if(0!==t){n/=1-t*s*s;const e=Math.sqrt(t);i=s*(0,a.y)(e*s)}return n+i}function F(t,e){if(0!==e){const s=t*(0,a.Z)()/e;return Math.min(s,1e-10)}return 0}class X{constructor(t){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=t,this.m_aiSetElts=t.m_bits.flatMap((t,e)=>e)}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return X.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 V(t){return 1n<<(0x3fn&BigInt(t))}function Y(t){return t>>6}class R{constructor(t){this.m_bits=[],void 0!==t&&t.copy&&(this.m_bits=t.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(t){const e=V(t),s=Y(t);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&e)}setBit(t){const e=V(t),s=Y(t);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=e}clearBit(t){}flipBit(t){const e=V(t),s=Y(t);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=e,0n!==(this.m_bits[s]&e)}clear(){this.m_bits.length=0}isZero(){let t=0;return this.m_bits.forEach(e=>{t|=e?2:1}),!(2&t)}equals(t){if(this===t)return!0;if(this.m_bits.length!==t.m_bits.length)return!1;let e=0;return this.m_bits.forEach((s,n)=>{e|=s===t.m_bits[n]?2:1}),!(1&e||(t.m_bits.forEach((t,s)=>{e|=t===this.m_bits[s]?2:1}),1&e))}notEquals(t){return!this.equals(t)}assignOr(t){return t.m_bits.forEach((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]|=t}),this}assignSubtract(t){return t.m_bits.forEach((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=~t)}),this}assignAnd(t){return t.m_bits.forEach((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=t)}),this}assignXor(t){return t.m_bits.forEach((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]^=t}),this}getHashCode(){return this.m_bits.reduce((t,e)=>(0,a.O)(t,e),(0,a.B)(0))}getUnorderedBitIterator(){return new X(this)}}class k{constructor(t,e){this.m_map=new Map,this.m_hf=t,this.m_ef=e}add(t){const e=this.m_hf(t);if(!this.m_map.has(e))return this.m_map.set(e,t),this;const s=this.m_map.get(e);return s instanceof Array?s.find(e=>this.m_ef(e,t))||s.push(t):this.m_ef(s,t)||this.m_map.set(e,[s,t]),this}clear(){this.m_map.clear()}delete(t){return!1}has(t){const e=this.m_hf(t);if(!this.m_map.has(e))return!1;const s=this.m_map.get(e);return s instanceof Array?void 0!==s.find(e=>this.m_ef(e,t)):this.m_ef(s,t)}get(t){const e=this.m_hf(t),s=this.m_map.get(e);if(void 0!==s)return s instanceof Array?s.find(e=>this.m_ef(e,t)):s}get size(){let t=0;for(const e of this.m_map.values())t+=e instanceof Array?e.length:1;return t}forEach(t,e){}[Symbol.iterator](){return(new Set)[Symbol.iterator]()}entries(){return(new Set).entries()}keys(){return(new Set).keys()}values(){return(new Set).values()}get[Symbol.toStringTag](){return"ValueSet"}}class L extends o.F{constructor(t){super(),this.m_bufferLeft=new r.S,this.m_bufferRight=new r.S,this.m_intervalLeft=a.E.constructEmpty(),this.m_intervalRight=a.E.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=t}compare(t,e,s){const n=e,i=t.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(i,this.m_bufferRight);const r=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(r.getStartX(),r.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=r.getStartY()===r.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(r.getStartY()===o.getStartY()&&r.getStartX()===o.getStartX())return a?1:-1;if(r.getEndY()===o.getEndY()&&r.getEndX()===o.getEndX())return a?-1:1}let m=r.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const t=r.getEndY(),e=o.getEndY(),s=Math.min(t,e);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),m=r.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(t){this.m_yScanline=t}}class B{constructor(t){this.m_segmentBuffer=new r.S,this.m_point=a.P.getNAN(),this.m_parent=t}setPointXY(t){this.m_point.assign(t)}compare(t,e){const s=t.getElement(e);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),i=new a.E;if(i.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<i.vmin)return-1;if(this.m_point.x>i.vmax)return 1;const r=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<r?-1:this.m_point.x>r?1:0}}var H,z,U;function O(t,e){return{parentage:t,rank:e}}function W(t,e){const s=t.length;if(s!==e.length)return!1;const n=t[0].parentage;if(n!==e[0].parentage)return!1;if(-1===n)return!0;for(let n=1;n<s;++n)if(t[n].parentage!==e[n].parentage)return!1;return!0}function j(t,e,s){s.length=0;let n=!1;{let i=t.getHalfEdgeVertexIterator(e);for(;i!==r.n;){const e=t.getVertexFromVertexIterator(i),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);n||=o>=0,s.push(O(o,r)),i=t.incrementVertexIterator(i)}}{let i=t.getHalfEdgeVertexIterator(t.getHalfEdgeTwin(e));for(;i!==r.n;){const e=t.getVertexFromVertexIterator(i),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);n||=o>=0,s.push(O(o,r)),i=t.incrementVertexIterator(i)}}n&&s.sort((t,e)=>t.rank>e.rank?-1:t.rank<e.rank?1:t.parentage<e.parentage?-1:t.parentage>e.parentage?1:0),-1===s[0].parentage&&(s.length=1)}(U=H||(H={}))[U.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",U[U.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",U[U.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding",function(t){t[t.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",t[t.enumPathBreakNode=2]="enumPathBreakNode"}(z||(z={}));class Z{constructor(){this.m_shape=null,this.m_clusterData=new o.S(8),this.m_clusterVertices=new o.S(2),this.m_firstCluster=r.n,this.m_lastCluster=r.n,this.m_halfEdgeData=new o.S(8),this.m_chainData=new o.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(t){this.m_checkDirtyPlanesweepTolerance=t}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(t,e,s=!0,n=!1){n?this.setEditShapeImpl3D_(t,H.enumInputModeBuildGraph,null,e,!1):this.setEditShapeImpl_(t,H.enumInputModeBuildGraph,null,e,s)}setAndSimplifyEditShapeAlternate(t,e,s=null,i=!1){const r=[];r.push(e),this.m_simplifiedGeometry=e,i?this.setEditShapeImpl3D_(t,H.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(t,H.enumInputModeSimplifyAlternate,r,s,t.getGeometryType(e)===n.G.enumPolygon)}setAndSimplifyEditShapeWinding(t,e,s=null){const n=[];n.push(e),this.m_simplifiedGeometry=e,this.setEditShapeImpl_(t,H.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=r.n,this.m_lastCluster=r.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=r.n,this.m_chainAreas=null)}getClusterHalfEdge(t){return this.m_clusterData.getField(t,2)}queryXY(t,e){const s=this.getClusterVertexIndex_(t);e.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(t,e){(0,n.g)(0)}getClusterParentage(t){return this.m_clusterData.getField(t,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(t){return this.m_clusterData.getField(t,3)}getNextCluster(t){return this.m_clusterData.getField(t,4)}getClusterChain(t){return this.m_clusterData.getField(t,6)}getClusterVertexIterator(t){return this.m_clusterData.getField(t,7)}incrementVertexIterator(t){return this.m_clusterVertices.getField(t,1)}getVertexFromVertexIterator(t){return this.m_clusterVertices.getField(t,0)}getClusterUserIndex(t,e){const s=this.getClusterIndex_(t),n=this.m_clusterIndices[e];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(t,e,s){const n=this.getClusterIndex_(t),i=this.m_clusterIndices[e];i.size()<=n&&i.resize(this.m_clusterData.size(),-1),i.write(n,s)}hasClusterUserIndexFlags(t,e,s){if(-1===e)return!1;const n=this.getClusterUserIndex(t,e);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(t,e,s){const n=this.getClusterIndex_(t),i=this.m_clusterIndices[e];i.size()<=n&&i.resize(this.m_clusterData.size(),-1);let r=i.read(n);-1===r&&(r=0),i.write(n,s|r)}clearClusterUserIndexFlags(t,e,s){const n=this.getClusterIndex_(t),i=this.m_clusterIndices[e];i.size()<=n&&i.resize(this.m_clusterData.size(),-1);let r=i.read(n);-1===r&&(r=0),i.write(n,~s&r)}createUserIndexForClusters(t=-1){const e=new o.A(this.m_clusterData.capacity(),t);for(let t=0,s=this.m_clusterIndices.length;t<s;t++)if(null===this.m_clusterIndices[t])return this.m_clusterIndices[t]=e,t;return this.m_clusterIndices.push(e),this.m_clusterIndices.length-1}deleteUserIndexForClusters(t){this.m_clusterIndices[t]=null}getHalfEdgeOrigin(t){return this.m_halfEdgeData.getField(t,1)}getHalfEdgeTo(t){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(t))}getHalfEdgeTwin(t){return this.m_halfEdgeData.getField(t,4)}getHalfEdgePrev(t){return this.m_halfEdgeData.getField(t,5)}getHalfEdgeNext(t){return this.m_halfEdgeData.getField(t,6)}getHalfEdgeChain(t){return this.m_halfEdgeData.getField(t,2)}getHalfEdgeFaceParentage(t){return this.getChainParentage(this.getHalfEdgeChain(t))}getHalfEdgeVertexIterator(t){return this.m_halfEdgeData.getField(t,7)}getHalfEdgeFromXY(t,e){this.queryXY(this.getHalfEdgeOrigin(t),e)}getHalfEdgeToXY(t,e){this.queryXY(this.getHalfEdgeTo(t),e)}isHalfEdgeCurve(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}getHalfEdgeFromXYZ(t,e){(0,n.g)(0)}getHalfEdgeToXYZ(t,e){(0,n.g)(0)}getHalfEdgeParentage(t){return this.m_halfEdgeData.getField(t,3)&Z.c_EdgeParentageMask}getHalfEdgeUserIndex(t,e){const s=this.getHalfEdgeIndex_(t),n=this.m_edgeIndices[e];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(t,e,s){const n=this.getHalfEdgeIndex_(t),i=this.m_edgeIndices[e];i.size()<=n&&i.resize(this.m_halfEdgeData.size(),-1),i.write(n,s)}createUserIndexForHalfEdges(t){void 0===t&&(t=-1);const e=new o.A(this.m_halfEdgeData.capacity(),t);for(let t=0,s=this.m_edgeIndices.length;t<s;t++)if(null===this.m_edgeIndices[t])return this.m_edgeIndices[t]=e,t;this.m_edgeIndices.push(e);const s=this.m_edgeIndices.length-1;return(0,n.g)(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(t){this.m_edgeIndices[t]=null}deleteEdgesBreakFaces_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],n=this.getHalfEdgeChain(s),i=this.getHalfEdgeTwin(s),o=this.getHalfEdgeChain(i);this.setChainHalfEdge_(n,r.n),this.setChainHalfEdge_(o,r.n),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(t,e){return(0,n.g)(0),!1}doesHalfEdgeBelongToAPolygonExterior(t,e){return(0,n.g)(0),!1}doesHalfEdgeBelongToAPolygonBoundary(t,e){return(0,n.g)(0),!1}doesHalfEdgeBelongToAPolylineInterior(t,e){return(0,n.g)(0),!1}doesHalfEdgeBelongToAPolylineExterior(t,e){return(0,n.g)(0),!1}doesClusterBelongToAPolygonInterior(t,e){return(0,n.g)(0),!1}doesClusterBelongToAPolygonExterior(t,e){return(0,n.g)(0),!1}doesClusterBelongToAPolygonBoundary(t,e){return(0,n.g)(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(t){return this.m_chainData.getField(t,1)}getChainParentage(t){return this.m_chainData.getField(t,2)}getChainParent(t){return this.m_chainData.getField(t,3)}getChainFirstIsland(t){return this.m_chainData.getField(t,4)}getChainNextInParent(t){return this.m_chainData.getField(t,5)}getChainNext(t){return this.m_chainData.getField(t,7)}getChainArea(t){const e=this.getChainIndex_(t);let s=this.m_chainAreas.read(e);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(t),s=this.m_chainAreas.read(e)),s}getChainPerimeter(t){return(0,n.g)(0),0}getChainUserIndex(t,e){const s=this.getChainIndex_(t),n=this.m_chainIndices[e];return n.size()<=s?-1:n.read(s)}setChainUserIndex(t,e,s){const n=this.getChainIndex_(t),i=this.m_chainIndices[e];i.size()<=n&&i.resize(this.m_chainData.size(),-1),i.write(n,s)}createUserIndexForChains(){const t=new o.A(this.m_chainData.capacity(),-1);for(let e=0,s=this.m_chainIndices.length;e<s;e++)if(null===this.m_chainIndices[e])return this.m_chainIndices[e]=t,e;return this.m_chainIndices.push(t),this.m_chainIndices.length-1}deleteUserIndexForChains(t){this.m_chainIndices[t]=null}extractPolygonFromChainAndIslands(t,e,s,i){const o=e===r.n?t.createGeometry(n.G.enumPolygon):e,a=new r.S;this.extractPolygonPathFromChain_(t,o,s,i,a);for(let e=this.getChainFirstIsland(s);e!==r.n;e=this.getChainNextInParent(e))this.extractPolygonPathFromChain_(t,o,e,i,a);return o}getGeometryID(t){const e=this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex);return(0,n.g)(e>=0),1<<Math.min(e,31)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_clusterIndex)}getHalfEdgeFromVertex(t){return this.m_shape.getUserIndex(t,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(t){if((0,n.g)(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const e=this.getChainUserIndex(t,this.m_chainBitSetIndex);(0,n.g)(e>=0);let s=this.m_chainBitSets.at(e);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(t){(0,n.g)(this.m_bBuildGeometryParentageSets);const e=new R,s=t=>{const s=this.getChainHalfEdge(t);let n=s;do{const t=this.getEdgeBitSet_(n);null!==t&&e.assignOr(t);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&e.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(t);for(let e=this.getChainFirstIsland(t);e!==r.n;e=this.getChainNextInParent(e))s(t);return e}getChainPolygons(t){return(0,n.g)(0),[]}getGeometriesFromBits(t){if(!this.m_bBuildGeometryParentageSets||null===t)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let t=this.m_shape.getFirstGeometry();t!==r.n;t=this.m_shape.getNextGeometry(t))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex),t)}const e=[],s=t.getUnorderedBitIterator();for(let t=s.next();t!==X.npos();t=s.next())(0,n.g)(this.m_geometryMapID.has(t)),e.push(this.m_geometryMapID.get(t));return e}getVertexDominant(t,e){if(e===r.n)return t;const s=this.getClusterFromVertex(t);return this.getVertexDominantFromCluster(s,e)}getVertexDominantFromCluster(t,e){if(e!==r.n){let s=r.n;for(let n=this.getClusterVertexIterator(t);n!==r.n;n=this.incrementVertexIterator(n)){const t=this.getVertexFromVertexIterator(n);s===r.n&&(s=t);const i=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(i)===e){s=t;break}}return s}{const e=this.getClusterVertexIterator(t);return e!==r.n?this.getVertexFromVertexIterator(e):r.n}}isBreakNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumSegmentParentageBreakNode)}setBreakNode(t,e){(0,n.g)(-1!==this.m_clusterBreakNodeIndex),e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumSegmentParentageBreakNode)}isStrongPathNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumPathBreakNode)}setStrongPathNode(t,e){if(-1===this.m_clusterBreakNodeIndex){if(!e)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumPathBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,z.enumPathBreakNode)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getHalfEdgeUserIndex(t,this.m_segmentParentageIndex);return e>=0?e:-1}isCrossroadAhead(t){const e=this.getHalfEdgeNext(t);if(this.isStrongPathNode(this.getHalfEdgeOrigin(e)))return!0;const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeNext(s);return t!==this.getHalfEdgeTwin(n)}isCrossroadBehind(t){return(0,n.g)(0),!1}getHalfEdgeConnector(t,e){const s=this.getClusterHalfEdge(t);if(s===r.n)return r.n;let n=s,i=r.n,o=r.n;do{if(this.getHalfEdgeTo(n)===e)return n;if(i===r.n){if(i=this.getClusterHalfEdge(e),i===r.n)return r.n;o=i}if(this.getHalfEdgeTo(o)===t)return n=this.getHalfEdgeTwin(o),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o))}while(n!==s&&o!==i);return r.n}querySegmentXY(t,e){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const t=this.m_shape.getSegmentFromIndex(s);e.copyFrom(t,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);e.copyFrom(n,!0),e.get().reverse()}return}}e.createLine();const s=e.get(),n=a.P.getNAN();this.getHalfEdgeFromXY(t,n),s.setStartXY(n),this.getHalfEdgeToXY(t,n),s.setEndXY(n)}isCurveEdge(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}compareEdgeAnglesCurveHelper_(t,e,s){const i=new r.S,o=new r.S;this.querySegmentXY(t,i),this.querySegmentXY(e,o);const h=i.get(),m=o.get();if(h.equals(m))return 0;const l=new a.P;this.getHalfEdgeFromXY(t,l);const u=new a.P;this.getHalfEdgeToXY(t,u);const c=new a.P;return this.getHalfEdgeToXY(e,c),(0,n.g)(!u.isEqualPoint2D(c)),(0,r.I)(h,m)}compareEdgeAnglesHelper_(t,e,s){if(t===e)return 0;if(this.isHalfEdgeCurve(t)||this.isHalfEdgeCurve(e))return this.compareEdgeAnglesCurveHelper_(t,e,s);const n=a.P.getNAN();this.getHalfEdgeToXY(t,n);const i=a.P.getNAN();if(this.getHalfEdgeToXY(e,i),n.isEqualPoint2D(i))return 0;const r=a.P.getNAN();this.getHalfEdgeFromXY(t,r);const o=a.P.getNAN();o.setSub(n,r);const h=a.P.getNAN();return h.setSub(i,r),!s||h.y>=0&&o.y>0?a.P.compareVectors(o,h):0}compareEdgeAngles_(t,e){return this.compareEdgeAnglesHelper_(t,e,!1)}compareEdgeAnglesForPair_(t,e){return this.compareEdgeAnglesHelper_(t,e,!0)}compareEdgeAngles3D_(t,e){return(0,n.g)(0),0}compareEdgeAnglesForPair3D_(t,e){return(0,n.g)(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(t,e){}deleteEdgeInternal_(t){const e=this.getHalfEdgeChain(t),s=this.getHalfEdgeTwin(t),i=this.getHalfEdgeChain(s);(0,n.g)(i===e),(0,n.g)(t===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(t));let o=this.getHalfEdgeNext(t);o===s&&(o=this.getHalfEdgeNext(o),o===t&&(o=r.n));const a=this.getChainIndex_(e),h=this.m_chainAreas.read(a);Number.isNaN(h)||(this.setChainArea_(e,Number.NaN),this.setChainPerimeter_(e,Number.NaN));const m=this.getChainHalfEdge(e);m!==t&&m!==s||this.setChainHalfEdge_(e,o),this.updateVertexToHalfEdgeConnection_(t,!0),this.deleteEdgeImpl_(t)}getFirstUnvisitedHalfEdgeOnCluster_(t,e,s){let n=e!==r.n?e:this.getClusterHalfEdge(t);if(n===r.n)return r.n;const i=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const t=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(t===i)return r.n;n=t}}removeSpikes_(){let t=!1;const e=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==r.n;s=this.getNextCluster(s)){let n=r.n;for(;;){let i=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,e);if(i===r.n)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));let o=i;for(;;){const s=this.getHalfEdgeNext(o),a=this.getHalfEdgePrev(o),h=this.getHalfEdgeTwin(o);if(a===h){if(this.deleteEdgeInternal_(o),t=!0,n!==o&&n!==h||(n=r.n),o===i||a===i){if(i=s,o===i||a===i)break;o=s;continue}}else this.setHalfEdgeUserIndex(o,e,1);if(o=s,o===i)break}}}return this.deleteUserIndexForHalfEdges(e),t}progress_(t,e=!1){}newCluster_(){const t=this.m_clusterData.newElement();return this.m_clusterData.setField(t,1,0),t}newHalfEdgePair_(){const t=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0);const e=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0),this.setHalfEdgeTwin_(t,e),this.setHalfEdgeTwin_(e,t),t}newChain_(){const t=this.m_chainData.newElement();return this.m_chainData.setField(t,2,0),t}deleteChain_(t){return(0,n.g)(0),0}getClusterIndex_(t){return this.m_clusterData.elementToIndex(t)}setClusterVertexIterator_(t,e){this.m_clusterData.setField(t,7,e)}setClusterHalfEdge_(t,e){this.m_clusterData.setField(t,2,e)}setClusterParentage_(t,e){this.m_clusterData.setField(t,1,e)}setPrevCluster_(t,e){this.m_clusterData.setField(t,3,e)}setNextCluster_(t,e){this.m_clusterData.setField(t,4,e)}setClusterVertexIndex_(t,e){this.m_clusterData.setField(t,5,e)}getClusterVertexIndex_(t){return this.m_clusterData.getField(t,5)}setClusterChain_(t,e){this.m_clusterData.setField(t,6,e)}addClusterToExteriorChain_(t,e){this.setClusterChain_(e,t)}getHalfEdgeIndex_(t){return this.m_halfEdgeData.elementToIndex(t)}setHalfEdgeOrigin_(t,e){this.m_halfEdgeData.setField(t,1,e)}setHalfEdgeTwin_(t,e){this.m_halfEdgeData.setField(t,4,e)}setHalfEdgePrev_(t,e){this.m_halfEdgeData.setField(t,5,e)}setHalfEdgeNext_(t,e){this.m_halfEdgeData.setField(t,6,e)}setHalfEdgeChain_(t,e){this.m_halfEdgeData.setField(t,2,e)}setHalfEdgeParentage_(t,e){this.m_halfEdgeData.setField(t,3,e)}getHalfEdgeParentageMask_(t){return this.m_halfEdgeData.getField(t,3)}setHalfEdgeVertexIterator_(t,e){this.m_halfEdgeData.setField(t,7,e)}updateVertexToHalfEdgeConnectionHelper_(t,e){const s=e?r.n:t;for(let e=this.getHalfEdgeVertexIterator(t);e!==r.n;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);this.m_shape.setUserIndex(t,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(t,e){t!==r.n&&(this.updateVertexToHalfEdgeConnectionHelper_(t,e),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(t),e))}getChainIndex_(t){return this.m_chainData.elementToIndex(t)}setChainHalfEdge_(t,e){this.m_chainData.setField(t,1,e)}setChainParentage_(t,e){this.m_chainData.setField(t,2,e)}setChainParent_(t,e){this.m_chainData.setField(t,3,e);const s=this.getChainFirstIsland(e);this.setChainNextInParent_(t,s),this.setChainFirstIsland_(e,t)}setChainFirstIsland_(t,e){this.m_chainData.setField(t,4,e)}setChainNextInParent_(t,e){this.m_chainData.setField(t,5,e)}setChainPrev_(t,e){this.m_chainData.setField(t,6,e)}setChainNext_(t,e){this.m_chainData.setField(t,7,e)}setChainArea_(t,e){const s=this.getChainIndex_(t);this.m_chainAreas.write(s,e)}setChainPerimeter_(t,e){const s=this.getChainIndex_(t);this.m_chainPerimeters.write(s,e)}updateChainAreaAndPerimeter_(t){const e=this.m_shape.hasCurves(),s=new a.K(0),n=new a.K(0),i=this.getChainHalfEdge(t),o=a.P.getNAN(),h=a.P.getNAN(),m=a.P.getNAN();this.getHalfEdgeFromXY(i,o),h.setCoordsPoint2D(o);let l=i;do{this.getHalfEdgeToXY(l,m),e&&this.isCurveEdge(l)||n.pe(a.P.distance(h,m)),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==t&&s.pe((m.x-o.x-(h.x-o.x))*(m.y-o.y+(h.y-o.y))*.5),h.setCoordsPoint2D(m),l=this.getHalfEdgeNext(l)}while(l!==i);if(e){const e=new r.S;l=i;do{this.getHalfEdgeToXY(l,m);const i=this.isCurveEdge(l);if(i&&(this.querySegmentXY(l,e),n.pe(e.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(l))!==t&&i){const t=e.get().calculateArea2DHelper();s.pe(t)}l=this.getHalfEdgeNext(l)}while(l!==i)}const u=this.getChainIndex_(t);this.m_chainAreas.write(u,s.getResult()),this.m_chainPerimeters.write(u,n.getResult())}getChainTopmostEdge_(t){return(0,n.g)(0),0}planeSweepParentage_(t,e){const s=new L(this),n=new o.T;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const i=[],h=this.createUserIndexForHalfEdges();let m=null;const l=a.P.getNAN();for(let a=this.getFirstCluster();a!==r.n;a=this.getNextCluster(a)){this.progress_(e);const u=this.getClusterHalfEdge(a);if(u!==r.n){if(i.length=0,!this.tryOptimizedInsertion_(n,h,i,a,u)){this.queryXY(a,l),s.setY(l.y);let t=u;do{const e=this.getHalfEdgeUserIndex(t,h);-1!==e&&(n.deleteNode(e),this.setHalfEdgeUserIndex(t,h,o.S.impossibleIndex2())),t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(u!==t);t=u;do{if(-1===this.getHalfEdgeUserIndex(t,h)){const e=n.addElement(t);i.push(e)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(u!==t)}for(let e=i.length-1;e>=0;e--){const s=i[e],r=n.getElement(s),o=this.getHalfEdgeTwin(r);this.setHalfEdgeUserIndex(o,h,s),this.planeSweepParentagePropagateParentage_(n,s,t)}}else if(this.getClusterChain(a)===r.n){null===m&&(m=new B(this)),this.queryXY(a,l),m.setPointXY(l);const t=n.searchLowerBound(m);let e=this.m_universeChain;if(-1!==t){let s=n.getElement(t);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,t)),s!==r.n&&(e=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(e,a)}}this.deleteUserIndexForHalfEdges(h)}planeSweepParentagePropagateParentage_(t,e,s){const i=t.getElement(e),o=this.getHalfEdgeChain(i);if(this.getChainParent(o)!==r.n)return;const a=this.getLeftSkipPolylines_(t,e),h=this.getHalfEdgeTwin(i),m=this.getHalfEdgeChain(h);let l=this.getChainParent(o),u=this.getChainParent(m);if(a===r.n)l===r.n&&(m===o?(this.setChainParent_(m,this.m_universeChain),u=this.m_universeChain,l=u):(u===r.n&&(this.setChainParent_(m,this.m_universeChain),u=this.m_universeChain),this.setChainParent_(o,m),l=m));else{const t=this.getHalfEdgeChain(a);if(u===r.n){if(this.getChainArea(t)<=0){const e=this.getChainParent(t);this.setChainParent_(m,e),u=e}else this.setChainParent_(m,t),u=t;m===o&&(l=u)}}l===r.n&&(this.trySetChainParentFromTwin_(o,m),l=this.getChainParent(o)),(0,n.g)(l!==r.n),s===H.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(t,e,i,a):s===H.enumInputModeSimplifyWinding?this.propagateParentageWinding_(t,e,i,a,h,o,m):s===H.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(t,e,i,a,h,o,m)}propagateParentageBuildGraph_(t,e,s,n){let i,o=e;n===r.n?(o=t.getNext(o),i=this.getHalfEdgeChain(s)):i=this.getHalfEdgeChain(n);let a=null,h=this.getChainParentage(i);for(this.m_bBuildGeometryParentageSets&&(a=this.getChainBitSet(i));-1!==o;o=t.getNext(o)){const e=t.getElement(o),s=this.getHalfEdgeTwin(e);i=this.getHalfEdgeChain(e);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let t=this.getChainBitSet(n);t=new R({copy:t}),t.assignOr(a),this.setChainBitSet_(n,t);let s=this.getChainBitSet(i);const r=this.getLeftEdgeBitSet_(e),o=new R({copy:a});if(o.assignSubtract(r),o.isZero())break;s=new R({copy:s}),s.assignOr(o),this.setChainBitSet_(i,s),a=s}const r=this.getChainParentage(n),m=r|h;m!==r&&this.setChainParentage_(n,m);let l=this.getChainParentage(i);const u=h&~this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeParentageIndexLeft);if(u&&(l|=u,this.setChainParentage_(i,l)),0===u)break;h=l}}propagateParentageWinding_(t,e,s,i,o,a,h){if(a===h)return;let m=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);m+=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex);let l=0;const u=[],c=[];c.push(0);for(let s=t.getFirst();s!==e;s=t.getNext(s)){const e=t.getElement(s),i=this.getHalfEdgeTwin(e),o=this.getHalfEdgeChain(e),a=this.getHalfEdgeChain(i);if(o!==a){let t=this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeWindingNumberIndex);t+=this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex),l+=t;let s=!1;0!==u.length&&u.at(-1)===a&&(c.pop(),u.pop(),s=!0),(0,n.g)(this.getChainParent(a)!==r.n),s&&this.getChainParent(a)===o||(c.push(l),u.push(o))}}if(l+=m,0!==u.length&&u.at(-1)===h&&(c.pop(),u.pop()),0!==l){if(0===c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(a,e)}}else if(0!==c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(a,e)}}propagateParentageAlternate_(t,e,s,n,i,o,a){const h=this.m_simplifiedGeometry,m=this.getGeometryID(h);if(n===r.n)this.setChainParentage_(a,this.m_universeGeomID),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(o,m):this.setChainParentage_(o,this.m_universeGeomID);else{const t=this.getChainParentage(a);if(0===t){const t=this.getHalfEdgeChain(n),e=this.getChainParentage(t);this.setChainParentage_(a,e),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(o,e===m?this.m_universeGeomID:m):this.setChainParentage_(o,e)}else 1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(o,t===m?this.m_universeGeomID:m):this.setChainParentage_(o,t)}}tryOptimizedInsertion_(t,e,s,n,i){let a=i,h=-1,m=r.n,l=0;do{if(2===l)return!1;const t=this.getHalfEdgeUserIndex(a,e);if(-1!==t){if(-1!==h)return!1;h=t}else{if(m!==r.n)return!1;m=a}l++,a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(i!==a);return m!==r.n&&-1!==h&&(this.setHalfEdgeUserIndex(t.getElement(h),e,o.S.impossibleIndex2()),t.setElement(h,m),s.push(h),!0)}trySetChainParentFromTwin_(t,e){const s=this.getChainArea(t);if(0===s)return!1;const n=this.getChainArea(e);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(t,e),!0;{const s=this.getChainParent(e);if(s!==r.n)return this.setChainParent_(t,s),!0}return!1}createHalfEdges_(t,e){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,i=e.size();s<i;s++){const i=e.read(s),o=this.m_shape.getUserIndex(i,this.m_clusterIndex),a=this.m_shape.getPathFromVertex(i),h=this.m_shape.getGeometryFromPath(a),m=this.m_shape.getGeometryType(h);if((0,n.h)(m)){const e=this.m_shape.getNextVertex(i);if(e===r.n)continue;const s=this.m_shape.getUserIndex(e,this.m_clusterIndex);if(o===s)continue;const a=this.newHalfEdgePair_(),l=this.getHalfEdgeTwin(a),u=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(u,0,i),this.m_clusterVertices.setField(u,1,-1),this.setHalfEdgeVertexIterator_(a,u),this.m_shape.setUserIndex(i,this.m_halfEdgeIndex,a),this.setHalfEdgeOrigin_(a,o);const c=this.getClusterHalfEdge(o);if(c===r.n)this.setClusterHalfEdge_(o,a),this.setHalfEdgePrev_(a,l),this.setHalfEdgeNext_(l,a);else{const t=this.getHalfEdgePrev(c);this.setHalfEdgePrev_(c,l),this.setHalfEdgeNext_(l,c),this.setHalfEdgeNext_(t,a),this.setHalfEdgePrev_(a,t)}this.setHalfEdgeOrigin_(l,s);const g=this.getClusterHalfEdge(s);if(g===r.n)this.setClusterHalfEdge_(s,l),this.setHalfEdgeNext_(a,l),this.setHalfEdgePrev_(l,a);else{const t=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,a),this.setHalfEdgeNext_(a,g),this.setHalfEdgeNext_(t,l),this.setHalfEdgePrev_(l,t)}const d=this.getGeometryID(h);if(t===H.enumInputModeBuildGraph){const t=m===n.G.enumPolygon?d:0;if(this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,t),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft,t),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const t=new R,e=this.m_shape.getGeometryUserIndex(h,this.m_geometryIDIndex);t.setBit(e),this.setEdgeBitSet_(a,t),this.setEdgeBitSet_(l,null),this.setLeftEdgeBitSet_(l,t),this.setLeftEdgeBitSet_(a,null)}}else if(t===H.enumInputModeSimplifyWinding){const t=this.m_shape.getXY(i),s=this.m_shape.getXY(e);let n=0,r=0;t.compare(s)<0?n=1:r=-1,this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,n),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,r)}else t===H.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=m===n.G.enumPolygon?Z.c_EdgeBitMask:0;this.setHalfEdgeParentage_(a,d|_),this.setHalfEdgeParentage_(l,d|_)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let t=0,s=e.size();t<s;t++){const s=e.read(t);if(this.m_shape.getSegment(s)){const t=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);t!==r.n&&(this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(t,e){{const s=this.getHalfEdgeVertexIterator(e);if(s!==r.n){const n=this.getHalfEdgeVertexIterator(t);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(t,s),this.setHalfEdgeVertexIterator_(e,r.n)}}const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeTwin(e);{const t=this.getHalfEdgeVertexIterator(n);if(t!==r.n){const e=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(t,1,e),this.setHalfEdgeVertexIterator_(s,t),this.setHalfEdgeVertexIterator_(n,r.n)}}if(-1!==this.m_segmentIndexHe){let i=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==i){if(-2===i){const s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,s)}if(i=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===i){const t=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,t)}}}}sortHalfEdgesByAngle_(t){const e=[];for(let s=this.getFirstCluster();s!==r.n;s=this.getNextCluster(s)){e.length=0;const n=this.getClusterHalfEdge(s);if(n!==r.n){let i=n;do{e.push(i),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==n);if(e.length>1){let i=!0;e.length>2?(e.sort((t,e)=>this.compareEdgeAngles_(t,e)),e.push(e[0])):this.compareEdgeAnglesForPair_(e[0],e[1])>0?e[1]=(0,a.c)(e[0],e[0]=e[1]):i=!1;let o=e[0],h=o,m=this.getHalfEdgeTo(h),l=this.getHalfEdgeTwin(h),u=r.n;for(let s=1,n=e.length;s<n;s++){const n=e[s],i=this.getHalfEdgeTwin(n),a=this.getHalfEdgeOrigin(i);if(a!==m||n===h)this.updateVertexToHalfEdgeConnection_(u,!1),u=r.n,h=n,m=a,l=i;else{if(t===H.enumInputModeBuildGraph){const t=this.getHalfEdgeParentageMask_(h)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(h,t),this.setHalfEdgeParentage_(l,t),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let t,e,s;t=this.getEdgeBitSet_(h),e=this.getEdgeBitSet_(n),s=new R({copy:t}),s.assignOr(e),this.setEdgeBitSet_(h,s),t=this.getEdgeBitSet_(l),e=this.getEdgeBitSet_(i),s=new R({copy:t}),s.assignOr(e),this.setEdgeBitSet_(l,s),t=this.getLeftEdgeBitSet_(h),e=this.getLeftEdgeBitSet_(n),s=new R({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(h,s),t=this.getLeftEdgeBitSet_(l),e=this.getLeftEdgeBitSet_(i),s=new R({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(l,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),e=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex,t),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,e)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),e=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex,t),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,e)}this.mergeVertexListsOfEdges_(h,n),this.deleteEdgeImpl_(n),u=h,e[s]=r.n,n===o&&(e[0]=r.n,o=r.n)}}if(this.updateVertexToHalfEdgeConnection_(u,!1),u=r.n,!i){o=r.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s!==r.n){o=s;break}}n!==o&&this.setClusterHalfEdge_(s,o);continue}o=r.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s===r.n)continue;if(o===r.n){o=s,h=o,m=this.getHalfEdgeTo(h),l=this.getHalfEdgeTwin(h);continue}if(s===h)continue;const n=this.getHalfEdgeTwin(s),i=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(l,s),this.setHalfEdgePrev_(s,l),h=s,m=i,l=n}this.setClusterHalfEdge_(s,o)}}}}sortHalfEdgesByAngle3D_(t){(0,n.g)(0)}buildChains_(t){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,r.n);let e=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let t=this.getFirstCluster();t!==r.n;t=this.getNextCluster(t)){const n=this.getClusterHalfEdge(t);if(n!==r.n){let t=n;do{if(1!==this.getHalfEdgeUserIndex(t,s)){const n=this.newChain_();this.setChainHalfEdge_(n,t),this.setChainPrev_(n,e),this.setChainNext_(e,n);let i=null;this.m_bBuildGeometryParentageSets&&(i=new R),e=n;let r=0,o=t;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(r|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&i.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,n),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==t);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(n,i),this.setChainParentage_(n,r)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==n)}}this.m_chainAreas=new o.D(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new o.D(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(t){(0,n.g)(0)}simplifyAlternate_(){(0,n.g)(0)}simplifyWinding_(){(0,n.g)(0)}setEditShapeImpl_(t,e,s,i,h){this.removeShape(),this.m_bBuildChains=h,this.m_shape=t,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let m=this.m_shape.getTotalPointCount();if(s){m=0;for(let t=0,e=s.length;t<e;t++)m+=this.m_shape.getPointCount(s[t])}const l=new o.A(0);let u=0,c=0;{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==r.n;){this.m_shape.setGeometryUserIndex(t,this.m_geometryIDIndex,c++);for(let e=this.m_shape.getFirstPath(t);e!==r.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++)l.add(t),t=this.m_shape.getNextVertex(t)}(0,n.e)(this.m_shape.getGeometryType(t))||(u+=this.m_shape.getPathCount(t)),null!=s?(t=e<s.length?s[e]:r.n,e++):t=this.m_shape.getNextGeometry(t)}}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_(i,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,u)),this.m_clusterIndex=this.m_shape.createUserIndex();const g=a.P.getNAN();let d=0;const _=a.P.getNAN();for(let t=0;t<=this.m_pointCount;t++){if(t<this.m_pointCount){const e=l.read(t);this.m_shape.queryXY(e,_)}else _.setNAN();if(!g.isEqualPoint2D(_)){if(d<t){const e=this.newCluster_();let s=r.n,n=-1;for(let i=d;i<t;i++){n=l.read(i),this.m_shape.setUserIndex(n,this.m_clusterIndex,e);const t=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(t,0,n),this.m_clusterVertices.setField(t,1,s),s=t;const r=this.m_shape.getPathFromVertex(n),o=this.m_shape.getGeometryFromPath(r),a=this.getGeometryID(o);this.setClusterParentage_(e,this.getClusterParentage(e)|a)}this.setClusterVertexIterator_(e,s),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(n)),this.m_lastCluster!==r.n&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===r.n&&(this.m_firstCluster=e)}d=t,g.setCoordsPoint2D(_)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let t=0;t<this.m_pointCount;t++){const e=l.read(t);if(this.m_shape.getSegmentParentageBreakVertex(e)){const t=this.getClusterFromVertex(e);this.setBreakNode(t,!0)}}}this.progress_(i,!0);{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==r.n;){for(let e=this.m_shape.getFirstPath(t);e!==r.n;e=this.m_shape.getNextPath(e)){if(this.m_shape.isStrongPathStart(e)){const t=this.m_shape.getFirstVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(e)){const t=this.m_shape.isClosedPath(e)?this.m_shape.getFirstVertex(e):this.m_shape.getLastVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}}null!=s?(t=e<s.length?s[e]:r.n,e++):t=this.m_shape.getNextGeometry(t)}}if(e===H.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),e===H.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),e===H.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(e,l),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(e),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(e),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(e,i),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(t,e,s,i,r){(0,n.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,n.g)(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(t){const e=this.getHalfEdgeNext(t),s=this.getHalfEdgePrev(t),n=this.getHalfEdgeTwin(t),i=this.getHalfEdgeNext(n),o=this.getHalfEdgePrev(n);e!==n&&(this.setHalfEdgeNext_(o,e),this.setHalfEdgePrev_(e,o)),s!==n&&(this.setHalfEdgeNext_(s,i),this.setHalfEdgePrev_(i,s));const a=this.getHalfEdgeOrigin(t);this.getClusterHalfEdge(a)===t&&(i!==t?this.setClusterHalfEdge_(a,i):this.setClusterHalfEdge_(a,r.n));const h=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(h)===n&&(e!==n?this.setClusterHalfEdge_(h,e):this.setClusterHalfEdge_(h,r.n)),this.m_halfEdgeData.deleteElement(t),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(t,e){let s=e;for(;;){if(s=t.getPrev(s),-1===s)return r.n;{const e=t.getElement(s);if(this.getHalfEdgeChain(e)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(e)))return e}}}checkStructureAfterDirtySweep_(){const t=(0,a.a)(this.m_checkDirtyPlanesweepTolerance),e=new a.P,s=new a.P,n=new a.P,i=new a.P,o=new a.P;for(let a=this.getFirstCluster();a!==r.n;a=this.getNextCluster(a)){const h=this.getClusterHalfEdge(a);if(h!==r.n){let r=h;this.getHalfEdgeFromXY(r,e),this.getHalfEdgeToXY(r,s),n.setSub(s,e);let a=n.sqrLength();do{const h=r;if(r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r)),r!==h){this.getHalfEdgeToXY(r,i),o.setSub(i,e);const h=o.sqrLength(),m=o.crossProduct(n),l=m*m/(h*a);if(Math.min(h,a)*l<=t&&o.dotProduct(n)>=0)return!1;n.assign(o),a=h,s.assign(i)}}while(r!==h)}}return!0}extractPolygonPathFromChain_(t,e,s,n,i){const a=this.m_shape.hasSegmentParentage(),h=this.getChainHalfEdge(s);let m=h,l=r.n;const u=new o.P;do{const o=this.getHalfEdgeTwin(m);if(this.getHalfEdgeChain(o)!==s){let s=r.n;const o=this.getHalfEdgeOrigin(m);if(n===r.n){const t=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(t)}else for(let t=this.getClusterVertexIterator(o);t!==r.n;t=this.incrementVertexIterator(t)){const e=this.getVertexFromVertexIterator(t);s===r.n&&(s=e);const i=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(i)===n){s=e;break}}let h;if(l===r.n&&(l=t.insertPath(e,r.n),t.setClosedPath(l,!0)),this.m_shape===t?h=t.addVertex(l,s):(this.m_shape.queryPoint(s,u),h=t.addPoint(l,u)),this.isHalfEdgeCurve(m)&&(this.querySegmentXY(m,i),t.setSegmentToIndex(t.getVertexIndex(h),i.get().clone())),a){const e=this.getSegmentParentage(m);t.setSegmentParentageAndBreak(h,e,this.isBreakNode(o))}}m=this.getHalfEdgeNext(m)}while(m!==h)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;(0,n.g)(-1!==this.m_clusterBreakNodeIndex),(0,n.g)(-1===this.m_segmentParentageIndex);for(let t=this.getFirstCluster();t!==r.n;t=this.getNextCluster(t)){let e=0;const s=this.getClusterHalfEdge(t);if(s!==r.n){let t=s;do{e++,t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==s&&e<3)}2!==e&&this.setBreakNode(t,!0)}let t=[],e=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==r.n;n=this.getNextCluster(n)){const i=this.getClusterHalfEdge(n);if(i!==r.n){let n=!1,r=i;do{let i=r;for(;-1===this.getHalfEdgeUserIndex(i,s);){const r=this.getHalfEdgeNext(i),o=this.getHalfEdgeTwin(i);j(this,i,e);const h=e.at(-1).parentage;if(!n){const e=this.getHalfEdgeOrigin(i);if(!this.isBreakNode(e)){const e=this.getHalfEdgePrev(i);i!==e&&(j(this,e,t),n=!0)}}if(n&&!W(e,t)){const t=this.getHalfEdgeOrigin(i);this.setBreakNode(t,!0)}t=(0,a.c)(e,e=t),n=!0;const m=this.getHalfEdgeOrigin(r);this.isBreakNode(m)&&(n=!1),this.setHalfEdgeUserIndex(i,this.m_segmentParentageIndex,h),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,h),this.setHalfEdgeUserIndex(i,s,1),this.setHalfEdgeUserIndex(o,s,1),i=r}r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==i)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(t){return null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=new k(t=>t.getHashCode(),(t,e)=>t.equals(e)),this.m_uniqueBitSets.add(this.getEmptySet())),null===t?this.getEmptySet():this.m_uniqueBitSets.has(t)?this.m_uniqueBitSets.get(t):(this.m_uniqueBitSets.add(t),t)}getLeftEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);return(0,n.g)(e>=0),(0,n.g)(this.m_edgeBitSets.at(e)),this.m_edgeBitSets.at(e)}getEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);return(0,n.g)(e>=0),this.m_edgeBitSets.at(e)}setEdgeBitSet_(t,e){(0,n.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setLeftEdgeBitSet_(t,e){(0,n.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setChainBitSet_(t,e){(0,n.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(t,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=e:(this.setChainUserIndex(t,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(e))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new R),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(t){}dbgVerifyEdgeSegment(t){}}Z.c_EdgeParentageMask=~(1<<31),Z.c_EdgeBitMask=1<<31;class Q{freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){this.m_lists.deleteElement(t)}newList_(){return this.m_lists.newElement()}Init_(t){(0,n.g)(0)}constructor(t){this.m_listNodes=new o.S(2),this.m_listOfLists=Q.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===t&&(t=!0),this.m_bAllowNavigationBetweenLists=t,this.m_lists=new o.S(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const t=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(t,3,this.m_listOfLists),this.m_listOfLists!==Q.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,t),this.m_listOfLists=t),t}deleteList(t){let e=this.getFirst(t);for(;e!==Q.st_nullNode();){const t=e;e=this.getNext(e),this.freeNode_(t)}if(this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==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)}this.freeList_(t)}reserveLists(t){this.m_lists.setCapacity(t)}addElement(t,e){this.m_lists.getField(t,0);const s=this.m_lists.getField(t,1),n=this.newNode_();return s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(t,1,n)):(this.m_lists.setField(t,0,n),this.m_lists.setField(t,1,n)),this.m_listNodes.setField(n,0,e),n}reserveNodes(t){this.m_listNodes.setCapacity(t)}deleteElementDirect(t,e,s){e!==Q.st_nullNode()?(this.m_listNodes.setField(e,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(t,1)===s&&this.m_lists.setField(t,1,e)):(this.m_lists.setField(t,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(t,1)===s&&this.m_lists.setField(t,1,Q.st_nullNode())),this.freeNode_(s)}deleteElementSearch(t,e){let s=-1,n=this.getFirst(t);for(;n!==e;)s=n,n=this.getNext(n);this.deleteElementDirect(t,s,e)}concatenateLists(t,e){const s=this.m_lists.getField(t,1),n=this.m_lists.getField(e,0);if(n!==Q.st_nullNode()&&(s!==Q.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(t,1,this.m_lists.getField(e,1))):(this.m_lists.setField(t,0,n),this.m_lists.setField(t,1,this.m_lists.getField(e,1)))),this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==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)}return this.freeList_(e),t}getElement(t){return this.m_listNodes.getField(t,0)}getData(t){return this.getElement(t)}setElement(t,e){(0,n.g)(0)}getNext(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getFirstElement(t){const e=this.getFirst(t);return this.getElement(e)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=Q.st_nullNode()}isEmpty(t){return(0,n.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}function K(t=-1){return{m_value:t,m_line:new r.L,m_segment:null,m_segmentInfo:new r.a1(-1),m_env:new a.E(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class $ extends o.F{constructor(t,e,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new g.NonSimpleResult,this.m_tempSimpleEdge1=K(),this.m_tempSimpleEdge2=K(),this.m_prev1=r.n,this.m_prev2=r.n,this.m_vertex1=r.n,this.m_vertex2=r.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 a.P,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=t,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=e,this.m_tolerance10=10*e,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*t.getTotalPointCount()/2,67)),i=Math.min(7,n);this.m_simpleEdgesCache.length=i}tryGetCachedEdge_(t){const e=this.m_simpleEdgesCache[(t&(0,a.j)())%this.m_simpleEdgesCache.length];return e&&e.m_value===t?e:null}tryDeleteCachedEdge_(t){const e=(t&(0,a.j)())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[e];s&&s.m_value===t&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[e]=null)}tryCreateCachedEdge_(t){const e=(t&(0,a.j)())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[e];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=K(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=t,this.m_simpleEdgesCache[e]=s,s)}initSimpleEdge_(t,e){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(t,e)||t.m_bCurve||(this.m_shape.queryLineConnector(e,t.m_line,!0),t.m_segment=t.m_line,t.m_env.setCoordsNoNAN(t.m_line.getStartX(),t.m_line.getEndX()),t.m_env.vmax+=this.m_tolerance,t.m_line.orientBottomUp(),t.m_bHorizontal=t.m_line.getEndY()===t.m_line.getStartY(),t.m_bHorizontal||(t.m_dxdy=(t.m_line.getEndX()-t.m_line.getStartX())/(t.m_line.getEndY()-t.m_line.getStartY())))}initSimpleEdgeHelper_(t,e){if(t.m_segment=this.m_shape.getSegment(e),t.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(e),t.m_bCurve=null!==t.m_segment,t.m_bCurve){const e=t.m_segment.clone();return e.orientBottomUp(),t.m_segment=e,t.m_env=t.m_segment.queryInterval(0,0),t.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(t,e){const s=t.getStartXY(),n=t.getEndXY(),i=e.getStartXY(),r=e.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(i)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(r)<0?n:r);const s=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-i)>this.m_tolerance)return s<i?-1:1}const o=s.compare(i)<0?i:s,h=n.compare(r)<0?n:r;let m=0,l=0;for(let s=1;s<5;s++){(0,a.Q)(o,h,s/5,this.m_ptSweep);const n=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=Math.abs(n-i);r>m&&(m=r,l=n<i?-1:1)}return 0===l?this.errorCracking():l}compareNonHorizontal_(t,e){if(t.m_line.getStartY()===e.m_line.getStartY()&&t.m_line.getStartX()===e.m_line.getStartX())return t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(t,e);if(t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(t,e);const s=this.compareNonHorizontalLowerEnd_(t,e),n=this.compareNonHorizontalUpperEnd_(t,e);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(t,e){if(t.getEndX()>e.getEndX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getEndX()-t.getStartX())<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(t,e){if(t.getStartX()<e.getStartX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getStartX()-t.getEndX())<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(t,e){const s=a.P.getNAN();s.setSub(e.getEndXY(),e.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=a.P.getNAN();n.setSub(t.getStartXY(),e.getStartXY());const i=a.P.getNAN();i.setSub(t.getEndXY(),e.getStartXY());const r=n.dotProduct(s),o=i.dotProduct(s),h=Math.abs(r),m=Math.abs(o);if(h<m){if(h<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return r<0&&o<0?-1:r>0&&o>0?1:this.errorCracking()}compareHorizontal1_(t,e){return t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.compareHorizontal1Case1_(t,e):t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()?this.compareHorizontal1Case2_(t,e):this.compareHorizontal1Case3_(t,e)}compareHorizontal2_(t,e){return t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()&&t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(t,e){let s=1;if(t.m_line.getStartY()<e.m_line.getStartY()){s=-1;const n=t;t=e,e=n}const n=t.m_line,i=e.m_line,r=n.getStartX()-i.getStartX(),o=e.m_dxdy*(n.getStartY()-i.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:i.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}compareNonHorizontalUpperEnd_(t,e){let s=1;if(e.m_line.getEndY()<t.m_line.getEndY()){s=-1;const n=t;t=e,e=n}const n=t.m_line,i=e.m_line,r=n.getEndX()-i.getStartX(),o=e.m_dxdy*(n.getEndY()-i.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:i.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new g.NonSimpleResult(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const t=6;this.m_nonSimpleResult=new g.NonSimpleResult(t,this.m_vertex1,this.m_vertex2)}else this.m_prev1=r.n,this.m_prev2=r.n,this.m_vertex1=r.n,this.m_vertex2=r.n;return-1}compareSegments_(t,e,s,n){if(s.m_env.vmax<n.m_env.vmin)return-1;if(n.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!n.m_bCurve){let t=s.m_bHorizontal?1:0;return t|=n.m_bHorizontal?2:0,0===t?this.compareNonHorizontal_(s,n):1===t?this.compareHorizontal1_(s.m_line,n.m_line):2===t?-1*this.compareHorizontal1_(n.m_line,s.m_line):this.compareHorizontal2_(s.m_line,n.m_line)}if(this.m_bIntersectionDetected)return-1;const i=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let o,a;if(i&&t===this.m_prev1?o=this.m_prevX1:(o=Number.NaN,this.m_prev1=r.n),i&&e===this.m_prev2?a=this.m_prevX2:(a=Number.NaN,this.m_prev2=r.n),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(o)){this.m_prev1=t;const e=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX1=e}if(Number.isNaN(a)){this.m_prev2=e;const t=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=t,this.m_prevX2=t}const h=(0,r.R)(!0,!0,s.m_segment,n.m_segment,this.m_tolerance,!0);return 0!==h?2===h?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(n.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(o-a)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):o<a?-1:o>a?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(t,e){this.m_sweepY=t,this.m_sweepX=e,this.m_prev1=r.n,this.m_prev2=r.n,this.m_vertex1=r.n,this.m_vertex2=r.n}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const n=t.getElement(s),i=e;return this.m_currentNode=s,this.compareSegments(i,i,n,n)}compareSegments(t,e,s,n){let i=this.tryGetCachedEdge_(t);null===i?this.m_vertex1===e?i=this.m_tempSimpleEdge1:(this.m_vertex1=e,i=this.tryCreateCachedEdge_(t),null===i&&(i=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=t),this.initSimpleEdge_(i,e)):this.m_vertex1=e;let r=this.tryGetCachedEdge_(s);return null===r?this.m_vertex2===n?r=this.m_tempSimpleEdge2:(this.m_vertex2=n,r=this.tryCreateCachedEdge_(s),null===r&&(r=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(r,n)):this.m_vertex2=n,this.compareSegments_(e,n,i,r)}onDelete(t){this.tryDeleteCachedEdge_(t)}onSet(t){this.tryDeleteCachedEdge_(t)}onEndSearch(t){this.tryDeleteCachedEdge_(t)}onAddUniqueElementFailed(t){this.tryDeleteCachedEdge_(t)}}class J{constructor(t,e){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=a.P.getNAN(),this.m_line1=new r.L,this.m_seg1=null,this.m_env=a.E.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=t,this.m_tolerance=e}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(t){this.m_pointOfInterest.assign(t)}compare(t,e){const s=t.getElement(e);return this.compareVertex(t,e,s)}compareVertex(t,e,s){let n,o=this.m_shape.getSegment(s),h=!0;if(null==o)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),o=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const t=i.Envelope2D.constructEmpty();o.queryLooseEnvelope(t),t.queryIntervalX(this.m_env),n=0===t.height(),h=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(n)return this.m_currentNode=e,this.m_bIntersectionDetected=!0,0;let m=0;if(h){(0,r.W)(this.m_line1);const t=this.m_line1.getStartXY(),e=new a.P;e.setSub(this.m_line1.getEndXY(),t),e.rightPerpendicularThis();const s=new a.P;s.setSub(this.m_pointOfInterest,t),m=e.dotProduct(s),m/=e.length()}else m=o.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:(o.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(m)<this.m_minDist&&(this.m_currentNode=e,this.m_minDist=m),this.m_bIntersectionDetected=!0),m<0?-1:m>0?1:0)}}class tt{constructor(t,e){this.m_lists=new Q(!1),this.m_hash=e,this.m_hashBuckets=new Int32Array(t),this.m_hashBuckets.fill(tt.st_nullNode()),this.m_bitFilter=new Int32Array(10*t+31>>5)}reserveElements(t){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,t)),this.m_lists.reserveNodes(t)}addElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=e%this.m_hashBuckets.length;let i=this.m_hashBuckets[n];return i===Q.st_nullNode()&&(i=this.m_lists.createList(),this.m_hashBuckets[n]=i),this.m_lists.addElement(i,t)}deleteElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%this.m_hashBuckets.length,i=this.m_hashBuckets[s];i===Q.st_nullNode()&&(0,n.a)("");let r=this.m_lists.getFirst(i),o=Q.st_nullNode();for(;r!==Q.st_nullNode();){const e=this.m_lists.getData(r),n=this.m_lists.getNext(r);e===t?(this.m_lists.deleteElementDirect(i,o,r),this.m_lists.getFirst(i)===Q.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=Q.st_nullNode())):o=r,r=n}}getFirstInBucket(t){const e=t%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[e>>5]&1<<(31&e)))return Q.st_nullNode();const s=t%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===Q.st_nullNode()?Q.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(t){return this.m_lists.getNext(t)}findNode(t){const e=this.m_hash.getHash(t);let s=this.getFirstInBucket(e);for(;s!==Q.st_nullNode();){const e=this.m_lists.getData(s);if(this.m_hash.equal(e,t))return s;s=this.m_lists.getNext(s)}return Q.st_nullNode()}deleteNode(t){const e=this.getElement(t),s=this.m_hash.getHash(e)%this.m_hashBuckets.length,i=this.m_hashBuckets[s];i===Q.st_nullNode()&&(0,n.a)(""),this.m_lists.deleteElementSearch(i,t),this.m_lists.getFirst(i)===Q.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=Q.st_nullNode())}getElement(t){return this.m_lists.getData(t)}static st_nullNode(){return Q.st_nullNode()}clear(){(0,n.g)(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function et(t,e,s,n,i){const r=new ot(i);return r.m_shape=t,r.m_sqrTolerance=e*e,r.m_cellSize=2*e,r.m_invCellSize=1/r.m_cellSize,r.m_geometry=s,r.m_bTrackChanges=n,r.m_bHasSegmentParentage=t.hasSegmentParentage(),r.clusterNonReciprocal()}function st(t,e,s,n,i){const r=t-s,o=e-n;return r*r+o*o<=i}function nt(t,e,s,n,i,r){const o={pt:new a.P,weight:0,rank:0,bMerged:!1},h=s+i;let m=!1,l=t.x;t.x!==e.x&&(n===r&&(l=(t.x*s+e.x*i)/h),m=!0);let u=t.y;return t.y!==e.y&&(n===r&&(u=(t.y*s+e.y*i)/h),m=!0),n!==r?n>r?(o.rank=n,o.weight=s,o.pt=t):(o.rank=r,o.weight=i,o.pt=e):(o.pt.setCoords(l,u),o.weight=h,o.rank=n),o.bMerged=m,o}function it(t,e){const s=(0,a.a2)(t);return(0,a.Y)(s,e)}class rt{constructor(t,e,s,n,i){this.m_workPt=new a.P,this.m_shape=t,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=e.clone(),this.m_hashValues=i}getHash(t){return this.m_shape.getUserIndex(t,this.m_hashValues)}calculateHashFromVertex(t){this.m_shape.queryXY(t,this.m_workPt);const e=this.m_workPt.x-this.m_origin.x,s=Math.trunc(e*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return it(s,Math.trunc(n*this.m_invCellSize+.5))}equal(t,e){return(0,n.g)(0),!1}}class ot{constructor(t){this.m_origin=a.P.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=r.n,this.m_bucketArray=(0,a.d)(4,Number.NaN),this.m_bucketHash=(0,a.d)(4,Number.NaN),this.m_dbgCandidateCheckCount=0,this.m_nsr=new g.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=t}progress_(){}collectClusterCandidates(t,e){const s=a.P.getNAN();this.m_shape.queryXY(t,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,i=(s.y-this.m_origin.y)*this.m_invCellSize,r=Math.trunc(n),o=Math.trunc(i);let h=0;for(let t=0;t<=1;t+=1)for(let e=0;e<=1;e+=1){const s=it(r+t,o+e),n=this.m_hashTable.getFirstInBucket(s);n!==tt.st_nullNode()&&(this.m_bucketArray[h]=n,this.m_bucketHash[h]=s,h++)}for(let t=h-1;t>=1;t--){const e=this.m_bucketArray[t];for(let s=t-1;s>=0;s--)if(e===this.m_bucketArray[s]){this.m_bucketHash[s]=-1,h--,t!==h&&(this.m_bucketHash[t]=this.m_bucketHash[h],this.m_bucketArray[t]=this.m_bucketArray[h]);break}}for(let n=0;n<h;n++)this.collectNearestNeighbourCandidates(t,this.m_bucketHash[n],s,this.m_bucketArray[n],e)}collectNearestNeighbourCandidates(t,e,s,n,i){const r=a.P.getNAN();for(let o=n;o!==tt.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);t===n||-1!==e&&this.m_shape.getUserIndex(n,this.m_hashValues)!==e||(this.m_shape.queryXY(n,r),st(s.x,s.y,r.x,r.y,this.m_sqrTolerance)&&i.push(o))}}mergeClusters(t,e,s){let n=this.m_shape.getUserIndex(t,this.m_newClusters);const i=this.m_shape.getUserIndex(e,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,t),this.m_shape.setUserIndex(t,this.m_newClusters,n)),-1===i?this.m_clusters.addElement(n,e):this.m_clusters.concatenateLists(n,i),this.m_shape.setUserIndex(e,this.m_newClusters,o.S.impossibleIndex2());const r=this.mergeVertices(t,e);if(s){const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e)}return r}mergeVertices(t,e){const s=a.P.getNAN();this.m_shape.queryXY(t,s);const n=a.P.getNAN();this.m_shape.queryXY(e,n);const i=this.m_shape.getRank(t),r=this.m_shape.getRank(e),o=this.m_shape.getWeight(t),h=this.m_shape.getWeight(e);let m,l,u,c,g=!1;if(i===r?(m=i,l=o+h,u=s.x,s.x!==n.x&&(u=(s.x*o+n.x*h)/l,g=!0),c=s.y,s.y!==n.y&&(c=(s.y*o+n.y*h)/l,g=!0)):(i>r?(u=s.x,c=s.y,l=o,m=i):(u=n.x,c=n.y,l=h,m=r),g=!s.equals(n)),g&&(this.m_shape.setXYMonotonic(t,u,c),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(t)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(t,s),this.m_shape.setSegmentParentageBreakVertex(e,s)}return this.m_shape.setWeight(t,l),this.m_shape.setRank(t,m),g}needsClustering(){const t={stack:[],error:void 0,hasError:!1};try{(0,h.mS)(t,(0,a.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 e=this.m_shape.getSelectedCount(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const n=Math.max(s.height(),s.width())/((0,a.i)()-1);this.m_cellSize<n&&(this.m_cellSize=n,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(this.m_shape.getSelectedCount()/3+1),this.m_clusters.reserveNodes(this.m_shape.getSelectedCount()/3+1),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new rt(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new tt(4*e/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let t=0;t<2;t++){const e=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==r.n;n=s.next()){if(this.progress_(),t>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===o.S.impossibleIndex2())continue;let s;if(0===t?(s=this.m_hashFunction.calculateHashFromVertex(n),this.m_shape.setUserIndex(n,this.m_hashValues,s)):s=this.m_shape.getUserIndex(n,this.m_hashValues),this.collectClusterCandidates(n,e),0!==e.length){for(let t=0,s=e.length;t<s;t++){this.progress_();const s=e[t],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new g.NonSimpleResult(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}e.length=0}0===t&&this.m_hashTable.addElement(n,s)}}return i}catch(e){t.error=e,t.hasError=!0}finally{(0,h.hk)(t)}}clusterNonReciprocal(){const t=this.m_shape.getSelectedCount(),e=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=e.getLowerLeft();const s=Math.max(e.height(),e.width())/((0,a.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 rt(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new tt(Math.trunc(4*t/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let e=t.next();e!==r.n;e=t.next()){this.progress_();const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t),this.m_hashTable.addElement(e,t)}}{const t=[],e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=e.next();s!==r.n;s=e.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===o.S.impossibleIndex2())continue;let e=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,e);let i=!1;for(;this.collectClusterCandidates(s,t),0!==t.length;){let e=0;for(let n=0,i=t.length;n<i;n++){this.progress_();const r=t[n],o=this.m_hashTable.getElement(r);this.m_hashTable.deleteNode(r);const a=n+1===i;e|=this.mergeClusters(s,o,a)?1:0}if(i||=0!==e,n||=0!==e,t.length=0,!e)break}i&&(e=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,e)}t.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const t=a.P.getNAN();for(let e=this.m_clusters.getFirstList();e!==Q.st_nullNode();e=this.m_clusters.getNextList(e)){let s=this.m_clusters.getFirst(e);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,t);const i=this.m_shape.getRank(n),r=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==Q.st_nullNode();s=this.m_clusters.getNext(s)){const e=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(e,t)||(this.m_shape.setXYMonotonicPoint2D(e,t),this.m_shape.setGeometryModifiedWithVertex(e,!0)):this.m_shape.setXYMonotonicPoint2D(e,t),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(n,t),this.m_shape.setSegmentParentageBreakVertex(e,t)}this.m_shape.setWeight(e,r),this.m_shape.setRank(e,i)}}}}class at{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 o.P,this.m_pointWeight=1,this.m_maxDensifyLimit=0,this.m_pointRank=0,this.m_changed1=!1,this.m_changed2=!1,this.m_adaptiveDensify=!1}clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(t,e,s,n,i,r,o,a,h,m){return function(t,e,s,n,i,r,o,a,h,m){return{segmentIndex:t,weightStart:e,rankStart:s,weightEnd:n,rankEnd:i,weightInterior:r,rankInterior:o,segmentParentage:m,u:ht(a,h)}}(t,e,s,n,i,r,o,a,h,m)}pushSegment(t,e,s,n,i,r,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,e,s,n,i,r,o,a,h,m)),this.m_inputSegments.push(t),this.m_inputParts.length-1}getResultSegmentCount(t){return this.m_adaptiveDensify?0===t?this.m_param1.length-1:this.m_param2.length-1:0===t?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(t,e){return 0===t?this.m_resultParts1[e]:this.m_resultParts2[e]}getResultSegment(t,e){return this.m_resultSegments[this.getResultPart_(t,e).segmentIndex].get()}getSegmentChanged(t){return 0===t?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(t,e){return this.getResultPart_(t,e).weightStart}getResultSegmentStartPointRank(t,e){return this.getResultPart_(t,e).rankStart}getResultSegmentSegmentParentage(t,e){return this.getResultPart_(t,e).segmentParentage}getResultSegmentStartPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakStart}getResultSegmentEndPointWeight(t,e){return this.getResultPart_(t,e).weightEnd}getResultSegmentEndPointRank(t,e){return this.getResultPart_(t,e).rankEnd}getResultSegmentEndPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakEnd}getResultSegmentInteriorRank(t,e){return this.getResultPart_(t,e).rankInterior}getResultSegmentInteriorWeight(t,e){return this.getResultPart_(t,e).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(t,e){2!==this.m_inputSegments.length&&(0,n.d)(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=t;const s=(0,a.a)(t*at.c_smallToleranceFactor);let i=!1;const o=this.m_inputParts[0],h=this.m_inputParts[1],m=this.m_inputSegments[o.segmentIndex],l=this.m_inputSegments[h.segmentIndex];if(e||5&(0,r.H)(!0,m,l,t,!0)){const e=(0,r.T)(!0,m,l,null,this.m_param1,this.m_param2,t);0===e&&(0,n.d)("");const u=new Array(e);for(let t=0;t<e;++t)u[t]=a.P.getNAN();const c=new Float64Array(e),g=new Int32Array(e),d=new Array(e),_=new Array(e);for(let t=0;t<e;++t)d[t]=mt(),_[t]=mt();for(let t=0;t<e;t++){const e=this.m_param1[t],n=this.m_param2[t];let r,p=o.rankInterior,f=o.weightInterior;0===e?(p=o.rankStart,f=o.weightStart,r=o.u.bBreakStart):1===e?(p=o.rankEnd,f=o.weightEnd,r=o.u.bBreakEnd):(this.m_changed1=!0,r=!1);let x,P=h.rankInterior,y=h.weightInterior;0===n?(P=h.rankStart,y=h.weightStart,x=h.u.bBreakStart):1===n?(P=h.rankEnd,y=h.weightEnd,x=h.u.bBreakEnd):(this.m_changed2=!0,x=!1);const E=p,C=P;let v=1,S=0,b=a.P.getNAN();if(E===C){const i=m.getCoord2D(e),r=l.getCoord2D(n);v=f+y,S=p,(0,a.Q)(i,r,y/v,b);const o=a.P.sqrDistance(b,i),h=a.P.sqrDistance(b,r);d[t].bBigMove=o>s,_[t].bBigMove=h>s,this.m_changed1||i.equals(b)||(this.m_changed1=!0),this.m_changed2||r.equals(b)||(this.m_changed2=!0)}else if(E>C){b=m.getCoord2D(e);const i=l.getCoord2D(n);v=f,S=p;const r=a.P.sqrDistance(b,i);d[t].bBigMove=!1,_[t].bBigMove=r>s,this.m_changed2||i.equals(b)||(this.m_changed2=!0)}else{b=l.getCoord2D(n),v=y,S=P;const i=m.getCoord2D(e),r=a.P.sqrDistance(b,i);d[t].bBigMove=r>s,_[t].bBigMove=!1,this.m_changed1||i.equals(b)||(this.m_changed1=!0)}u[t].assign(b),c[t]=v,g[t]=S,d[t].bIsBreak=r||x,_[t].bIsBreak=r||x,i||=d[t].bBigMove||_[t].bBigMove}const p=o.rankInterior,f=o.weightInterior;let x=0,P=-1;for(let s=0;s<=e;s++){const n=s<e?this.m_param1[s]:1;if(n!==x){const i=this.allocResultSegment(),r=this.m_resultSegments[i];let h,l,_,y;m.queryCut(x,n,r,!1),r.get().snapControlPoints(t*t);let E=!1,C=!1,v=!1,S=!1,b=!1,I=a.P.getNAN(),D=a.P.getNAN();-1!==P?(l=g[P],h=c[P],E=d[P].bBigMove,I.assign(u[P]),v=d[P].bIsBreak,b=!0):(h=o.weightStart,l=o.rankStart,I=r.get().getStartXY(),v=o.u.bBreakStart),s<e?(y=g[s],_=c[s],C=d[s].bBigMove,D.assign(u[s]),S=d[s].bIsBreak,b=!0):(_=o.weightEnd,y=o.rankEnd,D=r.get().getEndXY(),S=o.u.bBreakEnd),b&&r.get().setCoordsForIntersector(I,D,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,h,l,_,y,f,p,v,S,o.segmentParentage));const w=this.m_resultParts1.at(-1);w.u.bBigMoveStart=E,w.u.bBigMoveEnd=C,x=n,P=s}else-1===P&&(P=s)}const y=(0,a.d)(e,0);for(let t=0;t<e;t++)y[t]=t;e>2?(y.sort((t,e)=>this.m_param2[t]<this.m_param2[e]?-1:this.m_param2[t]>this.m_param2[e]?1:0),(0,a.v)(this.m_param2)):2===e&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=(0,a.c)(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),y[1]=(0,a.c)(y[0],y[0]=y[1]));const E=h.rankInterior,C=h.weightInterior;x=0,P=-1;for(let s=0;s<=e;s++){const n=s<e?this.m_param2[s]:1;if(n!==x){const i=this.allocResultSegment(),r=this.m_resultSegments[i];let o,m,d,p;l.queryCut(x,n,r,!1),r.get().snapControlPoints(t*t);let f=a.P.getNAN(),v=a.P.getNAN(),S=!1,b=!1,I=!1,D=!1,w=!1;if(-1!==P){const t=y[P];o=c[t],m=g[t],f.assign(u[t]),I=_[t].bBigMove,S=_[t].bIsBreak,w=!0}else o=h.weightStart,m=h.rankStart,f=r.get().getStartXY(),S=h.u.bBreakStart;if(s!==e){const t=y[s];d=c[t],p=g[t],v.assign(u[t]),D=_[t].bBigMove,b=_[t].bIsBreak,w=!0}else d=h.weightEnd,p=h.rankEnd,v=r.get().getEndXY(),b=h.u.bBreakEnd;w&&r.get().setCoordsForIntersector(f,v,!0),this.m_resultParts2.push(this.newIntersectionPart_(i,o,m,d,p,C,E,S,b,h.segmentParentage));const T=this.m_resultParts2.at(-1);T.u.bBigMoveStart=I,T.u.bBigMoveEnd=D,x=n,P=s}else-1===P&&(P=s)}return i?3:2}return 0}intersectLines3D(t,e,s,i){return(0,n.g)(0),1}intersect2D(t,e){const s=this.m_inputParts[0],i=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[i.segmentIndex].getGeometryType();return r!==n.G.enumLine||o!==n.G.enumLine?new gt(this).intersectCurves(t,e):this.intersectLines(t,e)}intersect2DEx(t,e,s,i,r){this.m_point.assignCopy(e),1!==this.m_inputSegments.length&&(0,n.d)(""),this.m_tolerance=t,this.m_changed1=!1,this.m_changed2=!1;const o=(0,a.a)(t*at.c_smallToleranceFactor);let h=!1;const m=this.m_inputParts[0],l=this.m_inputSegments[m.segmentIndex];if(r||l.isIntersectingPoint(e.getXY(),t,!0)){this.m_param1=(0,a.d)(16,Number.NaN);const n=l.getClosestCoordinate(e.getXY(),!1);this.m_param1[0]=n;let r=m.rankInterior,u=m.weightInterior;0===n?(r=m.rankStart,u=m.weightStart):1===n?(r=m.rankEnd,u=m.weightEnd):this.m_changed1=!0;let c=r;const g=s,d=i;c===g&&l.isCurve()&&(c=g+1);let _=1,p=0;const f=new a.P;if(c===g){const t=l.getCoord2D(n),s=e.getXY();_=u+d,p=r,(0,a.Q)(t,s,d/_,f),this.m_changed1||t.equals(f)||(this.m_changed1=!0),this.m_changed2||s.equals(f)||(this.m_changed2=!0),h=a.P.sqrDistance(f,t)>o}else c>g?(f.assign(l.getCoord2D(n)),_=u,p=r,this.m_changed2||f.equals(e.getXY())||(this.m_changed2=!0)):(f.assign(l.getCoord2D(n)),_=d,p=g,this.m_changed1||f.equals(e.getXY())||(this.m_changed1=!0),h=a.P.sqrDistance(f,e.getXY())>o);let x=0,P=-1;const y=1;for(let e=0;e<=y;e++){const s=e<y?this.m_param1[0]:1;if(s!==x){const n=this.allocResultSegment(),i=this.m_resultSegments[n];l.queryCut(x,s,i),i.get().snapControlPoints(t*t);let r=m.weightStart,o=m.weightEnd,a=m.rankStart,h=m.rankEnd;const u=m.rankInterior,c=m.weightInterior;let g=m.u.bBreakStart,d=m.u.bBreakEnd;-1!==P&&(r=_,a=p,g=!0,i.get().setCoordsForIntersector(f,i.get().getEndXY(),!0)),e!==y&&(o=_,h=p,d=!0,i.get().setCoordsForIntersector(i.get().getStartXY(),f,!0)),x=s,this.m_resultParts1.push(this.newIntersectionPart_(n,r,a,o,h,c,u,g,d,m.segmentParentage))}P=e}return this.m_point.setXY(f),this.m_pointWeight=_,this.m_pointRank=p,h?3:2}return 0}intersect3D(t,e,s,i){return(0,n.g)(0),1}intersect3DEx(t,e,s,i,r,o,a){return(0,n.g)(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(t){this.m_freeSegments.push(t)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new r.S,e=this.m_resultSegments.length;return this.m_resultSegments.push(t),e}allocResultSegmentFromBuffer(t){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new r.S({copy:t}),s=this.m_resultSegments.length;return this.m_resultSegments.push(e),s}allocResultSegmentFromSegment(t){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new r.S({segment:t}),s=this.m_resultSegments.length;return this.m_resultSegments.push(e),s}}function ht(t,e){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:t,bBreakEnd:e}}function mt(){return{bBigMove:!1,bIsBreak:!1}}at.maxWeight=.1*Number.MAX_VALUE,at.c_smallToleranceFactor=.01,at.c_maxGeometryTypeToRankDelta=8;let lt=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(t,e,s){if(1===e.getDescription().getAttributeCount())return;const n=t.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),i=t.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),r=new o.P;e.queryStart(r),s?(r.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(r)):(r.setXY(i),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(r)),e.queryEnd(r),s?(r.setXY(i),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(r)):(r.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(r))}copyFromWhenOverlap(t,e,s){this.equalEdge=e,e.equalEdge=this,this.segmentIndex=t.parent.allocResultSegmentFromBuffer(t.parent.m_resultSegments[e.segmentIndex]),this.segmentParentage=e.segmentParentage,this.weight=e.weight,this.rank=e.rank,s?(this.start.copyFrom(e.start),this.end.copyFrom(e.end)):(this.start.copyFrom(e.end),this.end.copyFrom(e.start),t.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class ut{constructor(){this.hash=0,this.pt=new a.P,this.prevInChain=null,this.nextInChain=null,this.prevInHash=null,this.nextInHash=null,this.prevEqual=null,this.nextEqual=null,this.weight=0,this.rank=0,this.bBigMove=!1,this.bIsBreak=!1}copyFrom(t){this.pt.assign(t.pt),this.weight=t.weight,this.rank=t.rank,this.bBigMove=t.bBigMove,this.bIsBreak=t.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let t=this;for(;null!==t.prevEqual;t=t.prevEqual);return t}}function ct(t,e,s,n){return{edge1:t,edge2:e,recursion:s,bIsIntersecting:n}}class gt{constructor(t){this.m_pairs=[],this.m_chainOrigin1=null,this.m_chainOrigin2=null,this.m_newNodes=[],this.m_hashTableOfEquals=[],this.m_hashTableOfEqualsSize=0,this.m_origin=new a.P,this.m_cell=new a.P,this.parent=t}addSegment(t,e,s,i,r,o,a,h,m,l,u){const c=this.newNode(this.parent.m_resultSegments[t].get().getStartXY(),s,i,m),g=this.newNode(this.parent.m_resultSegments[t].get().getEndXY(),r,o,l);this.newEdge(c,g,t,a,h,u),null===this.m_chainOrigin1?this.m_chainOrigin1=c:null===this.m_chainOrigin2?this.m_chainOrigin2=c:(0,n.g)(0)}intersectCurvesHelper(t,e,s,i,o){const h=this.getSegment(t).get(),m=this.getSegment(e).get();if(h.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(t,e,s,i);if(0!==l)return l;const u=(0,a.a)(.01*s);let c=!1,g=this.processSharpCorners(h,m,s,o>4);const d=g>0;if(!d){if(!(i||5&(0,r.R)(!0,!1,h,m,s,!0)))return 0;g=(0,r.T)(!0,h,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===g&&(0,n.d)("");const _=h.getGeometryType(),p=m.getGeometryType(),f=(0,a.m)(a.P,g),x=(0,a.m)(a.P,g),P=(0,a.d)(g,Number.NaN),y=(0,a.d)(g,Number.NaN),E=(0,a.d)(g,Number.NaN),C=(0,a.d)(g,Number.NaN),v=(0,a.k)(mt,g),S=(0,a.k)(mt,g);let b=!1,I=!1;for(let n=0;n<g;n++){const i=this.parent.m_param1[n],r=this.parent.m_param2[n];let o=t.rank,l=t.weight,g=!0,D=!1;0===i?(o=t.start.rank,l=t.start.weight,D=t.start.bIsBreak):1===i?(o=t.end.rank,l=t.end.weight,D=t.end.bIsBreak):(b=!0,g=!1);let w=e.rank,T=e.weight,N=!1,A=!0;0===r?(w=e.start.rank,T=e.start.weight,N=e.start.bIsBreak):1===r?(w=e.end.rank,T=e.end.weight,N=e.end.bIsBreak):(I=!0,A=!1);let G=o,q=w;if(G===q&&(G*=at.c_maxGeometryTypeToRankDelta,q*=at.c_maxGeometryTypeToRankDelta,G+=dt(_,h,!1),q+=dt(p,m,!1)),g&&A&&q===G){const t=h.getCoord2D(i),e=m.getCoord2D(r);t.equals(e)&&(q=G-1)}let M=1,F=0,X=1,V=0;const Y=new a.P,R=new a.P,k=h.getCoord2D(i),L=m.getCoord2D(r);if(d&&a.P.distance(k,L)>s)Y.setCoordsPoint2D(k),R.setCoordsPoint2D(L),M=l,X=T,F=o,V=w,v[n].bBigMove=!1,S[n].bBigMove=!1,D=!0,N=!0;else if(G===q){X=M=l+T,V=F=o,(0,a.Q)(k,L,T/M,Y),R.setCoordsPoint2D(Y);const t=a.P.sqrDistance(Y,k),e=a.P.sqrDistance(Y,L);v[n].bBigMove=t>u,S[n].bBigMove=e>u,b||k.equals(Y)||(b=!0),I||L.equals(R)||(I=!0)}else if(G>q){Y.setCoordsPoint2D(k),R.setCoordsPoint2D(Y),X=M=l,V=F=o;const t=a.P.sqrDistance(Y,L);v[n].bBigMove=!1,S[n].bBigMove=t>u,I||L.equals(R)||(I=!0)}else{R.setCoordsPoint2D(L),Y.setCoordsPoint2D(R),X=M=T,V=F=w;const t=a.P.sqrDistance(Y,k);v[n].bBigMove=t>u,S[n].bBigMove=!1,b||k.equals(Y)||(b=!0)}f[n].assign(Y),x[n].assign(R),P[n]=M,y[n]=X,E[n]=F,C[n]=V,v[n].bIsBreak=D||N,S[n].bIsBreak=D||N,c||=v[n].bBigMove||S[n].bBigMove,n>0&&(i!==this.parent.m_param1[n-1]&&r!==this.parent.m_param2[n-1]||(E[n]<=E[n-1]?(f[n].assign(x[n-1]),P[n]=y[n-1],E[n]=C[n-1],x[n].assign(x[n-1]),y[n]=y[n-1],C[n]=C[n-1],v[n].bBigMove||=v[n-1].bBigMove,S[n].bBigMove||=S[n-1].bBigMove,v[n].bIsBreak||=v[n-1].bIsBreak,S[n].bIsBreak||=S[n-1].bIsBreak):(f[n-1].assign(f[n]),P[n-1]=P[n],E[n-1]=E[n],x[n-1].assign(x[n]),y[n-1]=y[n],C[n-1]=C[n],v[n-1].bBigMove||=v[n].bBigMove,S[n-1].bBigMove||=S[n].bBigMove,v[n-1].bIsBreak||=v[n].bIsBreak,S[n-1].bIsBreak||=S[n].bIsBreak)))}if(!(b||I||2!==g||_===n.G.enumLine&&p===n.G.enumLine)){if(this.processDoublyConnectedEdges(t,e,o+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;(0,n.g)(0)}this.parent.m_changed1||=b,this.parent.m_changed2||=I;let D=t,w=t.end.weight,T=t.end.rank,N=t.end.bBigMove,A=t.end.bIsBreak,G=0,q=-1;for(let e=0;e<=g;e++){const n=e<g?this.parent.m_param1[e]:1;if(n!==G){const i=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[i];let o,m,l,u;h.queryCut(G,n,r,!1),r.get().snapControlPoints(s*s);let c=!1,d=!1,_=!1,p=!1;const x=new a.P,y=new a.P;-1!==q?(m=E[q],o=P[q],_=v[q].bBigMove,c=v[q].bIsBreak,x.assign(f[q])):(o=t.start.weight,m=t.start.rank,_=t.start.bBigMove,c=t.start.bIsBreak,x.assign(r.get().getStartXY())),e<g?(u=E[e],l=P[e],p=v[e].bBigMove,d=v[e].bIsBreak,y.assign(f[e])):(l=w,u=T,p=N,d=A,y.assign(r.get().getEndXY()));let C=D;n<1&&(this.splitEdgeInPlace(D),C=D.getNextInChain()),this.updateSegmentOnly(D,i),0===D.start.hash||D.start.pt.equals(x)||(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),0===D.end.hash||D.end.pt.equals(y)||(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(x),D.end.pt.assign(y),D.start.bBigMove||=_,D.end.bBigMove||=p,D.start.bIsBreak||=c,D.end.bIsBreak||=d,D.start.weight=o,D.start.rank=m,D.end.weight=l,D.end.rank=u,D=C,G=n,q=e}else-1===q&&(q=e)}const M=D.getNextInChain(),F=[];F.length=g;for(let t=0;t<g;t++)F[t]=t;g>2?(F.sort((t,e)=>(0,a.R)(this.parent.m_param2[t],this.parent.m_param2[e])),this.parent.m_param2.sort(a.R)):2===g&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=(0,a.c)(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),F[1]=(0,a.c)(F[0],F[0]=F[1])),D=e,w=e.end.weight,T=e.end.rank,N=e.end.bBigMove,A=e.end.bIsBreak,G=0,q=-1;for(let t=0;t<=g;t++){const n=t<g?this.parent.m_param2[t]:1;if(n!==G){const i=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[i];let o,h,l,u;m.queryCut(G,n,r,!1),r.get().snapControlPoints(s*s);const c=new a.P,d=new a.P;let _=!1,p=!1,f=!1,P=!1;if(-1!==q){const t=F[q];o=y[t],h=C[t],c.assign(x[t]),f=S[t].bBigMove,_=S[t].bIsBreak}else o=e.start.weight,h=e.start.rank,f=e.start.bBigMove,_=e.start.bIsBreak,c.assign(r.get().getStartXY());if(t!==g){const e=F[t];l=y[e],u=C[e],d.assign(x[e]),P=S[e].bBigMove,p=S[e].bIsBreak}else l=w,u=T,P=N,p=A,d.assign(r.get().getEndXY());let E=D;n<1&&(this.splitEdgeInPlace(D),E=D.getNextInChain()),this.updateSegmentOnly(D,i),0===D.start.hash||D.start.pt.equals(c)||(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),0===D.end.hash||D.end.pt.equals(d)||(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(c),D.end.pt.assign(d),D.start.bBigMove||=f,D.end.bBigMove||=P,D.start.bIsBreak||=_,D.end.bIsBreak||=p,D.start.weight=o,D.start.rank=h,D.end.weight=l,D.end.rank=u,D=E,G=n,q=t}else-1===q&&(q=t)}const X=D.getNextInChain();return this.postProcessResultPartsForCurves(t,M,e,X,o+1),c?3:2}intersectCurves(t,e){2!==this.parent.m_inputSegments.length&&(0,n.d)(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=t,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=(0,a.C)(16);const s=i.Envelope2D.constructEmpty();for(let t=0;t<2;t++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex]),n=i.Envelope2D.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex].queryLooseEnvelope(n),s.mergeEnvelope2D(n);const r=this.parent.m_inputParts[t];this.addSegment(e,0,r.weightStart,r.rankStart,r.weightEnd,r.rankEnd,r.weightInterior,r.rankInterior,r.u.bBreakStart,r.u.bBreakEnd,r.segmentParentage)}s.inflateCoords(100*t,100*t),this.m_origin.assign(s.getLowerLeft()),this.m_cell.setCoords(2*t,2*t),this.m_pairs.push(ct(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,e));let r=0,o=!0;for(;this.m_pairs.length;){const e=this.m_pairs.at(-1);this.m_pairs.pop(),(0,n.g)(e.recursion>=0),(0,n.g)(e.recursion<=256),this.clusterNodes(t);const s=this.intersectCurvesHelper(e.edge1,e.edge2,t,e.bIsIntersecting,e.recursion);o&&(o=!1,r=s)}for(let t=0;t<2;t++){const e=0===t?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let s=(0===t?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=s;s=s.getNextInChain())e.push(this.parent.newIntersectionPart_(s.segmentIndex,s.start.weight,s.start.rank,s.end.weight,s.end.rank,s.weight,s.rank,s.start.bIsBreak,s.end.bIsBreak,s.segmentParentage)),e.at(-1).u.bBigMoveStart=s.start.bBigMove,e.at(-1).u.bBigMoveEnd=s.end.bBigMove}return r}tryOverlapIntersectCurves(t,e,s,i){const o=this.parent.m_resultSegments[t.segmentIndex].get(),h=this.parent.m_resultSegments[e.segmentIndex].get(),m=o.getStartXY().equals(h.getStartXY())&&o.getEndXY().equals(h.getEndXY()),l=o.getStartXY().equals(h.getEndXY())&&o.getEndXY().equals(h.getStartXY());if(!m&&!l)return 0;const u=(0,r.Y)(o,h,!0);if(0!==u&&(0,r.Z)(o,h)&&t.segmentParentage===e.segmentParentage){let t=!1;if(u>0)t=o.equals(h);else{(0,n.g)(-1===u);const e=new r.S({segment:h});e.get().reverse(),t=o.equals(e.get())}if(t)return 1}const c=s*at.c_smallToleranceFactor;let g=!1;if(0===u){const t=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let e=0,n=t.length;e<n;++e){const n=t[e],i=new a.P;o.queryCoord2D(n,i);const r=h.getClosestCoordinate(i,!1),m=new a.P;h.queryCoord2D(r,m);const l=a.P.distance(i,m);if(l>s)return 0;g||=l>c}for(let e=0,n=t.length;e<n;++e){const n=t[e],i=new a.P;h.queryCoord2D(n,i);const r=o.getClosestCoordinate(i,!1),m=new a.P;o.queryCoord2D(r,m);const l=a.P.distance(i,m);if(l>s)return 0;g||=l>c}}let d=t.rank,_=e.rank;return d===_&&(d*=at.c_maxGeometryTypeToRankDelta,_*=at.c_maxGeometryTypeToRankDelta,d+=dt(o.getGeometryType(),o,!0),_+=dt(h.getGeometryType(),h,!0)),d>_?(e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,o,m)):_>d?(t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)):t.segmentParentage<=e.segmentParentage?(t.weight=t.weight+e.weight,e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,o,m)):(e.weight=t.weight+e.weight,t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)),g?3:2}postProcessResultPartsForCurves(t,e,s,i,r){r===(0,a.T)()&&(0,n.d)("curve_helper");for(let s=t;s!==e;s=s.getNextInChain())this.updateSegmentToNodes(s);for(let t=s;t!==i;t=t.getNextInChain())this.updateSegmentToNodes(t);for(let o=t;o!==e;o=o.getNextInChain()){const t=o.end.pt.sub(o.start.pt);for(let e=s;e!==i;e=e.getNextInChain()){let s=0;if(o.start.pt.equals(e.start.pt)&&o.end.pt.equals(e.end.pt)?s=1:o.start.pt.equals(e.end.pt)&&o.end.pt.equals(e.start.pt)&&(s=-1),!s){let s=o.start.pt.equals(e.start.pt)?1:0;if(s||(s=o.end.pt.equals(e.end.pt)?2:0,s||(s=o.end.pt.equals(e.start.pt)?3:0,s||(s=o.start.pt.equals(e.end.pt)?4:0))),s){const i=e.end.pt.sub(e.start.pt),a=t.dotProduct(i);let h;switch(s){case 1:case 2:h=a>0;break;case 3:case 4:h=a<0;break;default:(0,n.d)("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(ct(o,e,r,!1))}continue}const i=this.parent.m_resultSegments[o.segmentIndex],h=this.parent.m_resultSegments[e.segmentIndex],m=[.5,.25,.75];for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new a.P;i.get().queryCoord2D(e,n);const r=h.get().getClosestCoordinate(n,!1),o=new a.P;if(h.get().queryCoord2D(r,o),a.P.distance(n,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ct(o,e,r,!1));continue}for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new a.P;h.get().queryCoord2D(e,n);const r=i.get().getClosestCoordinate(n,!1),o=new a.P;if(i.get().queryCoord2D(r,o),a.P.distance(n,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(ct(o,e,r,!1));continue}o.equalEdge=e,e.equalEdge=o;let l=o.rank,u=e.rank;l===u&&(l*=at.c_maxGeometryTypeToRankDelta,u*=at.c_maxGeometryTypeToRankDelta,l+=dt(i.get().getGeometryType(),i.get(),!0),u+=dt(h.get().getGeometryType(),h.get(),!0)),l>u||l===u&&o.segmentParentage<=e.segmentParentage?(i.copyTo(h,!1),e.segmentParentage=o.segmentParentage,-1===s&&h.get().reverse()):(h.copyTo(i,!1),o.segmentParentage=e.segmentParentage,-1===s&&i.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(t.start),e&&this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(s.start),i&&this.updateAttachedEdgesAfterNodeChange(i.start)}processDoublyConnectedEdges(t,e,s,i){s===(0,a.T)()&&(0,n.d)("curve_helper");const o=this.getSegment(t).get(),h=this.getSegment(e).get(),m=o.getStartXY().equals(h.getStartXY())&&o.getEndXY().equals(h.getEndXY())?1:o.getEndXY().equals(h.getStartXY())&&o.getStartXY().equals(h.getEndXY())?-1:0;if(0!==m){const n=new r.S;o.queryCut(0,.5,n),n.get().snapControlPoints(i*i);const a=new r.S;o.queryCut(.5,1,a),a.get().snapControlPoints(i*i),this.splitEdgeInPlace(t),t.end.pt=n.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(n),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(a);let l=h.getClosestCoordinate(t.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),h.queryCut(0,l,n),n.get().snapControlPoints(i*i),h.queryCut(l,1,a),a.get().snapControlPoints(i*i),this.splitEdgeInPlace(e),e.end.pt=n.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(n),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(a),m>0?(this.m_pairs.push(ct(t,e,s,!1)),this.m_pairs.push(ct(t.getNextInChain(),e.getNextInChain(),s,!1))):(this.m_pairs.push(ct(t,e.getNextInChain(),s,!1)),this.m_pairs.push(ct(t.getNextInChain(),e,s,!1))),!0}return!1}newNode(t,e,s,n){const i=new ut;return this.m_newNodes.push(i),i.pt=t,i.rank=s,i.weight=e,i.bIsBreak=n,i}newEdge(t,e,s,n,i,r){const o=new lt;return o.start=t,o.end=e,t.nextInChain=o,e.prevInChain=o,o.segmentIndex=s,o.segmentParentage=r,o.rank=i,o.weight=n,o}splitEdgeInPlace(t){t.segmentIndex=-1;const e=new lt,s=new ut;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=e,s.prevInChain=t,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=t.weight,s.rank=t.rank,s.bIsBreak=!1,s.bBigMove=!1,e.start=s,e.segmentIndex=-1,e.end=t.end,e.end.prevInChain=e,e.rank=t.rank,e.weight=t.weight,e.segmentParentage=t.segmentParentage,t.end=s,t.equalEdge&&(t.equalEdge.equalEdge=null),t.equalEdge=null}updateSegmentOnly(t,e){t.segmentIndex=e}updateAttachedEdgesAfterNodeChange(t){for(let e=t.equalListHead();null!==e;e=e.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(e)}updateAttachedEdgesAfterNodeChangeImpl(t){const e=t.prevInChain;if(e&&e.hasSegment()){const s=this.getSegment(e).get();t.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(e.start.pt,e.end.pt,!1),s.ensureXYMonotone())}const s=t.nextInChain;if(s&&s.hasSegment()){const e=this.getSegment(s).get();t.pt.equals(e.getStartXY())||(e.setCoordsForIntersector(s.start.pt,s.end.pt,!1),e.ensureXYMonotone())}}updateSegmentToNodes(t){const e=this.getSegment(t).get();t.start.pt.equals(e.getStartXY())&&t.end.pt.equals(e.getEndXY())||(e.setCoordsForIntersector(t.start.pt,t.end.pt,!1),e.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(t.end)}getSegment(t){return this.parent.m_resultSegments[t.segmentIndex]}clusterNodes(t){let e=!1;const s=[],n=[],i=[];for(let t=0,e=this.m_newNodes.length;t<e;t++){const s=this.m_newNodes[t];if(null===s)continue;let n=s;for(let i=t+1;i<e;i++){const t=this.m_newNodes[i];null!==t&&s.pt.equals(t.pt)&&(n.nextInHash=t,t.prevInHash=n,n=t,this.m_newNodes[i]=null)}}for(let r=0,o=this.m_newNodes.length;r<o;r++){const o=this.m_newNodes[r];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const r=(0,a.C)(4),h=this.hashTableBinsToCheck(o,r);for(let e=0;e<h;e++)if(null!==r[e])for(let h=r[e];null!==h;){const e=h.nextInHash;a.P.distance(o.pt,h.pt)<=t&&(s.push(h),this.removeNodeFromHash(h),h.hash=0,i.push(h),n.push(h)),h=e}let m=!1;for(const t of s)if(!o.pt.equals(t.pt)){const s=nt(o.pt,t.pt,o.weight,o.rank,t.weight,t.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,m=!0,e=!0}if(s.length=0,!m)break;o.hash=this.calculateHash(o.pt)}i.push(o),n.push(o);for(let t=o.nextInHash;null!==t;){t.prevInHash=null;const e=t.nextInHash;t.nextInHash=null,i.push(t),n.push(t),t=e}const h=o.hash;let m=null,l=null;for(const t of n)o!==t&&(t.hash=h,t.pt.assign(o.pt),t.rank=o.rank,t.weight=o.weight),t.prevInHash=m,m&&(m.nextInHash=t),t.prevEqual=l,t.nextEqual=null,l&&(l.nextEqual=t),l=t,m=t;const u=h%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[u],null!==this.m_hashTableOfEquals[u]&&(this.m_hashTableOfEquals[u].prevInHash=m),this.m_hashTableOfEquals[u]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,e)for(const t of i)this.updateAttachedEdgesAfterNodeChange(t)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const t=this.m_hashTableOfEquals;this.m_hashTableOfEquals=(0,a.C)(2*t.length),this.m_hashTableOfEqualsSize=0;for(const e of t){let t=e;for(;t;){const e=t.nextInHash;t.nextInHash=null,t.prevInHash=null,this.addNodeToHashImpl(t),t=e}}}}addNodeToHashImpl(t){const e=t.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[e];t.nextInHash=s,null!==s&&(s.prevInHash=t),this.m_hashTableOfEquals[e]=t,this.m_hashTableOfEqualsSize++}removeNodeFromHash(t){const e=t.hash%this.m_hashTableOfEquals.length,s=t.prevInHash,n=t.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[e]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,t.prevInHash=null,t.nextInHash=null}hashTableBinsToCheck(t,e){const s=(t.pt.x-this.m_origin.x)/this.m_cell.x,n=(t.pt.y-this.m_origin.y)/this.m_cell.y,i=(0,a.i)()-1,r=Math.round((0,a.s)(s,-i,i)),o=Math.round((0,a.s)(n,-i,i));let h=r|o<<32;h=(0,a.B)(h),e[0]=this.m_hashTableOfEquals[h%this.m_hashTableOfEquals.length];let m=r+1|o<<32;m=(0,a.B)(m);let l=1;e[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],e[1]!==e[0]&&(l=2);let u=r+1|o+1<<32;u=(0,a.B)(u),e[l]=this.m_hashTableOfEquals[u%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}l++;let c=r|o+1<<32;c=(0,a.B)(c),e[l]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}return l++,l}calculateHash(t){const e=(t.x-this.m_origin.x)/this.m_cell.x,s=(t.y-this.m_origin.y)/this.m_cell.y,n=(0,a.i)()-1;let i=Math.round((0,a.s)(e,-n,n))|Math.round((0,a.s)(s,-n,n))<<32;return i=(0,a.B)(i),0===i&&(i=1),i}processSharpCorners(t,e,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,t.getStartXY().equals(e.getStartXY())){const i=[0,0],o=[0,0],a=(0,r._)(t,e,0,0,s,2,i,o,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let t=0;t<a;t++)this.parent.m_param1.push(i[t]),this.parent.m_param2.push(o[t]);return a+1}}if(t.getEndXY().equals(e.getEndXY())){const i=[0,0],o=[0,0],a=(0,r._)(t,e,1,1,s,2,i,o,n);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(i[t]),this.parent.m_param2.push(o[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),a+1}}if(t.getStartXY().equals(e.getEndXY())){const i=[0,0],o=[0,0],a=(0,r._)(t,e,0,1,s,2,i,o,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let t=0;t<a;t++)this.parent.m_param1.push(i[t]),this.parent.m_param2.push(o[t]);return a+1}}if(t.getEndXY().equals(e.getStartXY())){const i=[0,0],o=[0,0],a=(0,r._)(t,e,1,0,s,2,i,o,n);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(i[t]),this.parent.m_param2.push(o[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),a+1}}return 0}}function dt(t,e,s){let i=0;switch(t){case n.G.enumLine:i=0;break;case n.G.enumBezier:i=2;break;case n.G.enumRationalBezier2:i=3;break;case n.G.enumBezier2:i=1;break;case n.G.enumEllipticArc:i=0===e.projectionBehavior()?5:4;break;default:(0,n.d)("")}return s?5-i:i}class _t extends ${constructor(t){super(t.m_shape,t.m_tolerance,!1),this.m_parent=t}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const n=t.getElement(s),i=this.m_parent.getEdgeOriginVertices(e),r=this.m_parent.m_edgeVertices.getFirstElement(i),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(e,r,n,a)}}class pt extends J{constructor(t){super(t.m_shape,t.m_tolerance),this.m_parent=t}compare(t,e){if(this.m_bIntersectionDetected)return-1;const s=t.getElement(e),n=this.m_parent.getEdgeOriginVertices(s),i=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=e,this.compareVertex(t,e,i)}}class ft extends o.F{constructor(t){super(),this.pt1=a.P.getNAN(),this.pt2=a.P.getNAN(),this.m_shape=t}compare(t,e,s){this.m_shape.queryXY(e,this.pt1);const n=t.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class xt{constructor(t){this.m_point=a.P.getNAN(),this.m_pt=a.P.getNAN(),this.m_shape=t}setPoint(t){this.m_point.setCoordsPoint2D(t)}compare(t,e){const s=t.getElement(e);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Pt{constructor(t,e){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new o.S(8),this.m_clusters=new o.S(5),this.m_clusterVertices=new Q(!1),this.m_edgeVertices=new Q(!1),this.m_helperPoint=new o.P,this.m_eventQ=new o.T,this.m_sweepStructure=new o.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 at,this.m_segBuf1=new r.S,this.m_segBuf2=new r.S,this.m_sweepPoint=new a.P(0,0),this.m_tolerance=0,this.m_toleranceSqr=0,this.m_sweepPointCluster=-1,this.m_vertexClusterIndex=-1,this.m_bCracked=!1,this.m_bSweepPointClusterWasModified=!1,this.m_progressTracker=t,this.m_bTrackChanges=e}hadComplications(){return this.m_bComplications}sweep(t,e){const s=new m.T;s.setSwapCoordinates(),t.applyTransformation(s),this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e;let n=this.sweepImpl_();return t.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(t,e){this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=t.filterClosePoints(e,!0,!1,this.m_bTrackChanges,r.n);this.m_bComplications=1===n,s||=1===n}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(t,e){return this.m_edges.getField(t,0+e)}setEdgeCluster_(t,e,s){this.m_edges.setField(t,0+e,s)}getEdgeOriginVertices(t){return this.m_edges.getField(t,2)}setEdgeOriginVertices_(t,e){this.m_edges.setField(t,2,e)}getNextEdgeEx(t,e){return this.m_edges.getField(t,3+e)}setNextEdgeEx_(t,e,s){this.m_edges.setField(t,3+e,s)}getEdgeSweepNode(t){return this.m_edges.getField(t,7)}setEdgeSweepNode_(t,e){this.m_edges.setField(t,7,e)}getNextEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,3+s)}setNextEdge_(t,e,s){const n=this.getEdgeEnd(t,e);this.m_edges.setField(t,3+n,s)}getPrevEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,5+s)}setPrevEdge_(t,e,s){const n=this.getEdgeEnd(t,e);this.m_edges.setField(t,5+n,s)}getClusterVertices(t){return this.m_clusters.getField(t,0)}setClusterVertices_(t,e){this.m_clusters.setField(t,0,e)}getClusterSweepEdgeList(t){return this.m_clusters.getField(t,2)}setClusterSweepEdgeList_(t,e){this.m_clusters.setField(t,2,e)}getClusterFirstEdge(t){return this.m_clusters.getField(t,1)}setClusterFirstEdge_(t,e){this.m_clusters.setField(t,1,e)}getClusterEventQNode(t){return this.m_clusters.getField(t,3)}setClusterEventQNode_(t,e){this.m_clusters.setField(t,3,e)}newCluster_(t){const e=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(e,s),t!==r.n&&(this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)),e}deleteCluster_(t){this.m_clusters.deleteElement(t)}addVertexToCluster_(t,e){const s=this.getClusterVertices(t);this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)}newEdge_(t){const e=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(e,s),-1!==t&&this.m_edgeVertices.addElement(s,t),e}addVertexToEdge_(t,e){const s=this.getEdgeOriginVertices(t);this.m_edgeVertices.addElement(s,e)}deleteEdge_(t){this.m_edges.deleteElement(t);const e=this.m_edgesToInsertInSweepStructure.findIndex(e=>e===t);e>=0&&(0,a.N)(this.m_edgesToInsertInSweepStructure,e)}addEdgeToCluster(t,e){-1===this.getEdgeCluster(t,0)?this.setEdgeCluster_(t,0,e):-1===this.getEdgeCluster(t,1)?this.setEdgeCluster_(t,1,e):(0,n.d)(""),this.addEdgeToClusterImpl_(t,e)}addEdgeToClusterImpl_(t,e){const s=this.getClusterFirstEdge(e);if(-1!==s){const n=this.getNextEdge(s,e);this.setPrevEdge_(n,e,t),this.setNextEdge_(t,e,n),this.setNextEdge_(s,e,t),this.setPrevEdge_(t,e,s)}else this.setPrevEdge_(t,e,t),this.setNextEdge_(t,e,t),this.setClusterFirstEdge_(e,t)}getEdgeEnd(t,e){return this.getEdgeCluster(t,0)===e?0:1}mergeClusters_(t,e){this.dbgCheckCluster_(t),this.dbgCheckCluster_(e);const s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1));let n=this.getClusterFirstEdge(t),i=this.getClusterFirstEdge(e);if(-1!==i){let s=i,r=i,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,e),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===t){this.disconnectEdge_(s);const t=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(t),this.deleteEdge_(s),s===a){i=-1;break}i===s&&(i=this.getClusterFirstEdge(e),r=a,o=!0)}s=a}while(s!==r||o);if(-1!==i){do{const n=this.getEdgeEnd(s,e),i=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,t),s=i}while(s!==r);if(n=this.getClusterFirstEdge(t),-1!==n){const e=this.getNextEdge(n,t),s=this.getNextEdge(i,t);e===n?(this.setClusterFirstEdge_(t,i),this.addEdgeToClusterImpl_(n,t),this.setClusterFirstEdge_(t,n)):s===i&&this.addEdgeToClusterImpl_(i,t),this.setNextEdge_(i,t,e),this.setPrevEdge_(e,t,i),this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n)}else this.setClusterFirstEdge_(t,i)}}const r=this.getClusterVertices(t),o=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(o);-1!==e;e=this.m_clusterVertices.getNext(e)){const s=this.m_clusterVertices.getElement(e);this.m_shape.setUserIndex(s,this.m_vertexClusterIndex,t)}this.m_clusterVertices.concatenateLists(r,o),this.deleteCluster_(e),this.dbgCheckCluster_(t)}mergeEdges_(t,e){this.dbgCheckEdge_(t),this.dbgCheckEdge_(e);const s=this.getEdgeCluster(t,0),n=this.getEdgeCluster(t,1),i=this.getEdgeCluster(e,0),r=this.getEdgeCluster(e,1),o=this.getEdgeOriginVertices(t),a=this.getEdgeOriginVertices(e);if(this.m_edgeVertices.concatenateLists(o,a),e===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,t),e===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,t),this.disconnectEdge_(e),this.deleteEdge_(e),!(s===i&&n===r||n===i&&s===r)){const t=this.getClusterXY(s),e=this.getClusterXY(i);t.isEqualPoint2D(e)?(s!==i&&this.mergeClusters_(s,i),n!==r&&this.mergeClusters_(n,r)):(n!==i&&this.mergeClusters_(n,i),s!==r&&this.mergeClusters_(s,r))}this.dbgCheckEdge_(t)}disconnectEdge_(t){const e=this.getEdgeCluster(t,0),s=this.getEdgeCluster(t,1);this.disconnectEdgeFromCluster_(t,e),this.disconnectEdgeFromCluster_(t,s)}disconnectEdgeFromCluster_(t,e){const s=this.getNextEdge(t,e),n=this.getPrevEdge(t,e),i=this.getClusterFirstEdge(e);s!==t?(this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n),i===t&&this.setClusterFirstEdge_(e,s)):this.setClusterFirstEdge_(e,-1)}applyIntersectorToEditShape_(t,e,s){let n=this.m_edgeVertices.getFirst(t);const i=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(i),o=this.m_shape.getNextVertex(i),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(i),m=this.m_shape.getXY(o);let l=!1,u=!1;const c=e.getResultSegment(s,0).getStartXY(),g=e.getResultSegment(s,e.getResultSegmentCount(s)-1).getEndXY();h.equals(c)||(l=!0),m.equals(g)||(u=!0),this.m_shape.splitSegmentWithIntersector(i,e,s,!0,!0);const d=this.m_bTrackChanges&&e.getSegmentChanged(s);for(d&&this.m_shape.setGeometryModifiedWithVertex(i,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const t=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(t)===r;this.m_shape.splitSegmentWithIntersector(t,e,s,i,!0),d&&this.m_shape.setGeometryModifiedWithVertex(t,!0)}if(l&&this.updateClusterXY(!0,r,c,e.getResultSegmentStartPointWeight(s,0),e.getResultSegmentStartPointRank(s,0)),u){const t=e.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,g,e.getResultSegmentEndPointWeight(s,t),e.getResultSegmentEndPointRank(s,t))}}createEdgesAndClustersFromSplitEdge_(t,e,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(t),i=this.getEdgeCluster(t,0),r=this.getEdgeCluster(t,1);let a=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(a);const h=o.S.impossibleIndex3();this.setEdgeSweepNode_(a,h),this.m_tempEdgeBuffer.push(a),this.addEdgeToCluster(a,i);const m=e.getResultSegmentCount(s);for(let t=1;t<m;t++){const t=this.newCluster_(-1);this.m_modifiedClusters.push(t),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(a,t);const e=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,h),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(e,t),a=e}this.addEdgeToCluster(a,r);for(let t=this.m_edgeVertices.getFirst(n);-1!==t;t=this.m_edgeVertices.getNext(t)){let e=this.m_edgeVertices.getElement(t);if(this.getClusterFromVertex(e)===i){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_vertexClusterIndex)}processSplitHelper1_(t,e,s){const n=this.getEdgeCluster(e,0),i=this.getClusterXY(n),r=this.getEdgeCluster(e,1),a=this.getClusterXY(r),h=s.getResultSegmentCount(t);let m=s.getResultSegment(t,0);const l=m.getStartXY();if(i.isEqualPoint2D(l)||(this.m_bComplications||i.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)),!this.m_bComplications&&h>1){const t=i.compare(a),e=m.getEndXY();(i.compare(e)!==t||e.compare(a)!==t||e.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(t,h-1);const u=m.getEndXY();a.isEqualPoint2D(u)||(this.m_bComplications||a.compare(this.m_sweepPoint)*u.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(r,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(r)),this.m_tempEdgeBuffer.push(e);for(let t=0,s=this.m_tempEdgeBuffer.length;t<s;t++){const s=this.m_tempEdgeBuffer[t],n=this.getEdgeSweepNode(s);o.S.isValidElement(n)&&(this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(s,-1));const i=o.S.impossibleIndex3();s!==e&&this.getEdgeSweepNode(s)!==i&&(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,i))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(t,e){const s=this.m_sweepStructure.getElement(t);return this.m_sweepComparator.compare(this.m_sweepStructure,s,e),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(t,e),!0)}fixIntersection_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t),n=this.m_sweepStructure.getElement(e);let i=null,r=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),i=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),u=this.m_shape.getWeight(a),c=this.m_shape.getSegmentParentageBreakVertex(a),g=this.m_shape.getWeight(l),d=this.m_shape.getSegmentParentageBreakVertex(l),_=this.m_shape.getSegmentWeight(a),p=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),r=this.m_segBuf2.get();const y=this.m_shape.getNextVertex(m),E=this.m_shape.getWeight(m),C=this.m_shape.getSegmentParentageBreakVertex(m),v=this.m_shape.getWeight(y),S=this.m_shape.getSegmentParentageBreakVertex(y),b=this.m_shape.getSegmentWeight(m),I=this.m_shape.getRank(m),D=this.m_shape.getRank(y),w=this.m_shape.getSegmentRank(m),T=this.m_shape.getSegmentParentage(m);this.m_segmentIntersector.pushSegment(i,u,p,g,f,_,x,c,d,P),this.m_segmentIntersector.pushSegment(r,E,I,v,D,b,w,C,S,T),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_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e);let n=null;const i=this.getEdgeOriginVertices(s),r=this.m_edgeVertices.getFirstElement(i);this.m_shape.querySegment(r,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(r),a=this.m_shape.getWeight(r),h=this.m_shape.getSegmentParentageBreakVertex(r),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),u=this.m_shape.getSegmentWeight(r),c=this.m_shape.getRank(r),g=this.m_shape.getRank(o),d=this.m_shape.getSegmentRank(r),_=this.m_shape.getSegmentParentage(r),p=this.getClusterFirstVertex(t);this.m_segmentIntersector.pushSegment(n,a,c,m,g,u,d,h,l,_),this.m_shape.queryPoint(p,this.m_helperPoint);const f=this.m_shape.getWeight(p),x=this.m_shape.getRank(p);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,t,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let t=!0,e=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||e>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,t=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const i=this.isEdgeOnSweepLine_(s);o.S.isValidElement(i)?(this.insertNewEdgeToSweepStructure_(s,i),e++):i!==o.S.impossibleIndex2()&&(t=!1),this.m_bContinuingSegmentChainOptimization=!1}return t}insertNewEdgeToSweepStructure_(t,e){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,t,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(t),-1===s){const e=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(e);return this.mergeEdges_(s,t),!1}if(this.setEdgeSweepNode_(t,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const t=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===t&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===t&&(this.m_nextNeighbour=-1),this.fixIntersection_(t,s),!0}return!1}isEdgeOnSweepLine_(t){const e=this.getEdgeCluster(t,0),s=this.getEdgeCluster(t,1),n=this.getClusterXY(e),i=this.getClusterXY(s);if(a.P.sqrDistance(n,i)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const r=n.compare(this.m_sweepPoint),h=i.compare(this.m_sweepPoint);return r<=0&&h>0?s:h<=0&&r>0?e:r>0&&h>0?o.S.impossibleIndex2():-1}fillEventQueue(){const t=new o.A(0),e=this.m_shape.queryVertexIteratorOnSelection();for(let s=e.next();s!==r.n;s=e.next())-1!==this.m_shape.getUserIndex(s,this.m_vertexClusterIndex)&&t.add(s);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(t.size()),this.m_eventQ.setComparator(new ft(this.m_shape));const s=a.P.getNAN();s.setNAN();let n=-1;for(let e=0,i=t.size();e<i;e++){const i=t.read(e);if(this.m_shape.getXY(i).isEqualPoint2D(s)){const t=this.m_shape.getUserIndex(i,this.m_vertexClusterIndex);this.mergeClusters_(n,t);continue}n=this.getClusterFromVertex(i),this.m_shape.queryXY(i,s);const r=this.m_eventQ.addBiggestElement(i);this.setClusterEventQNode_(n,r)}}fillEventQueuePass2(){const t=new o.A(0);for(let e=this.m_eventQ.getFirst();-1!==e;e=this.m_eventQ.getNext(e)){const s=this.m_eventQ.getElement(e);t.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(t,0,t.size()),this.progress_(!0);for(let e=0,s=t.size();e<s;e++){const s=t.read(e),n=this.getClusterFromVertex(s),i=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,i)}}getAffectedEdges(t,e){const s=this.getClusterFirstEdge(t);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);o.S.isValidElement(s)&&e.push(n),n=this.getNextEdge(n,t)}while(n!==s)}updateClusterXY(t,e,s,n,i){const r=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(r);-1!==e;e=this.m_clusterVertices.getNext(e)){const r=this.m_clusterVertices.getElement(e);this.m_shape.setXYMonotonicPoint2D(r,s),this.m_shape.setWeight(r,n),this.m_shape.setRank(r,i),t&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}}splitEdge_(t,e,s,n){this.dbgCheckEdge_(t),-1!==e&&this.dbgCheckEdge_(e),this.disconnectEdge_(t),-1!==e&&this.disconnectEdge_(e),this.processSplitHelper1_(0,t,n),-1!==e&&this.processSplitHelper1_(1,e,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t],s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1))}const i=this.getEdgeOriginVertices(t),r=-1!==e?this.getEdgeOriginVertices(e):-1;if(this.applyIntersectorToEditShape_(i,n,0),-1!==r)this.applyIntersectorToEditShape_(r,n,1);else{const t=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,t,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(t,n,0),-1!==e&&this.createEdgesAndClustersFromSplitEdge_(e,n,1),this.m_edgeVertices.deleteList(i),this.deleteEdge_(t),-1!==e&&(this.m_edgeVertices.deleteList(r),this.deleteEdge_(e));for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let s=this.getClusterEventQNode(e);if(-1===s){const t=this.getClusterFirstVertex(e);if(s=this.m_eventQ.addUniqueElement(t),-1===s){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),n=this.getClusterFromVertex(s);this.mergeClusters_(n,e)}else this.setClusterEventQNode_(e,s)}}this.m_modifiedClusters.length=0}getClusterXY(t){const e=this.getClusterFirstVertex(t);return this.m_shape.getXY(e)}getClusterFirstVertex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}dbgCheckEdge_(t){}dbgCheckCluster_(t){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(t){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new _t(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const t=[];let e=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=o.S.impossibleIndex2(),i=o.S.impossibleIndex3();for(let r=this.m_eventQ.getFirst();-1!==r;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(r);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const e=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===e,!a){let s=e;do{const e=this.getEdgeSweepNode(s);-1===e?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,i)):e!==i&&t.push(e),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==e)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),t.length>0){this.m_bContinuingSegmentChainOptimization=1===t.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let e=0,s=t.length;e<s;e++){const s=this.m_sweepStructure.getElement(t[e]);this.setEdgeSweepNode_(s,n)}let e=n,s=n;for(let i=0,r=t.length;i<r;i++){const r=t[i];if(e===n){const t=this.m_sweepStructure.getPrev(r);if(-1!==t){const s=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(s)!==n&&(e=t)}else e=-1}if(s===n){const t=this.m_sweepStructure.getNext(r);if(-1!==t){const e=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(e)!==n&&(s=t)}else s=-1}if(e!==n&&s!==n)break}for(let e=0,s=t.length;e<s;e++){const s=t[e],n=this.m_sweepStructure.getElement(s);this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(n,-1)}t.length=0,this.m_prevNeighbour=e,this.m_nextNeighbour=s,-1!==e&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(e,s):-1===e&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===e&&(e=new pt(this)),e.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(e),e.intersectionDetected()&&(e.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,e.getCurrentNode())));const h=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&h&&-1!==this.m_prevNeighbour&&-1!==this.m_nextNeighbour&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,null===s&&(s=new xt(this.m_shape)),s.setPoint(this.m_sweepPoint),r=this.m_eventQ.searchUpperBound(s)):r=this.m_eventQ.getNext(r)}return this.m_bCracked}setEditShape_(t){this.m_shape=t,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(t.getSelectedCount()+32),this.m_clusters.setCapacity(t.getSelectedCount()),this.m_clusterVertices.reserveLists(t.getSelectedCount()),this.m_clusterVertices.reserveNodes(t.getSelectedCount()),this.m_edgeVertices.reserveLists(t.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(t.getSelectedCount()+32);for(let e=this.m_shape.getFirstGeometry();e!==r.n;e=this.m_shape.getNextGeometry(e))if((0,n.h)(this.m_shape.getGeometryType(e)))for(let s=this.m_shape.getFirstPath(e);s!==r.n;s=this.m_shape.getNextPath(s)){const e=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===r.n)continue;let i=this.m_shape.getNextVertex(n);if(i===r.n||i===n)continue;let o=-1;t.selected(n)&&(o=this.newCluster_(n));let a=-1;-1!==o&&t.selected(i)&&(a=this.newEdge_(n),this.addEdgeToCluster(a,o));let h=a;for(let t=0,s=e-2;t<s;t++){const t=this.m_shape.getNextVertex(i);let e=-1;if(this.m_shape.selected(i)){const s=this.newCluster_(i);-1!==h&&this.addEdgeToCluster(h,s),this.m_shape.selected(t)&&(e=this.newEdge_(i),this.addEdgeToCluster(e,s))}h=e,i=t}if(this.m_shape.isClosedPath(s)){const t=this.m_shape.getNextVertex(i);if(this.m_shape.selected(i)){const e=this.newCluster_(i);if(-1!==h&&this.addEdgeToCluster(h,e),this.m_shape.selected(t)){const t=this.newEdge_(i);this.addEdgeToCluster(t,e),this.addEdgeToCluster(t,o)}}}else{let t=-1;this.m_shape.selected(i)&&(t=this.newCluster_(i),-1!==h&&this.addEdgeToCluster(h,t))}}else for(let t=this.m_shape.getFirstPath(e);t!==r.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++)this.m_shape.selected(e)&&this.newCluster_(e),e=this.m_shape.getNextVertex(e)}this.fillEventQueue()}progress_(t=!1){}dbgCheckSweepStructure_(){}}function yt(t,e,s){return{vertex0:t,vertex1:e,dir:s}}class Et{constructor(t){this.m_shape=null,this.m_spikes=[],this.m_points=new o.A(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=t}executeImpl_(t,e){if(this.m_shape=t,t.getPathCount(e)<2&&t.getPointCount(e)<6)return;this.m_points.resize(0);for(let s=t.getFirstPath(e);s!==r.n;s=t.getNextPath(s)){let e=t.getFirstVertex(s);for(let n=0,i=t.getPathSize(s);n<i;n++,e=t.getNextVertex(e))this.m_points.add(e)}this.m_pointsIndex=t.createUserIndex();for(let e=0,s=this.m_points.size();e<s;++e)t.setUserIndex(this.m_points.read(e),this.m_pointsIndex,e);t.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const i=t.getXY(s);let o=1,a=0;const h=[];for(let e=1;e<this.m_points.size();e++){const n=this.m_points.read(e);if(n===r.n)continue;if(-1===t.getUserIndex(n,this.m_pointsIndex))continue;const m=t.getXY(n);if(m.isEqualPoint2D(i))o++;else{if(o>1){for(let s=a;s<e;s++){const e=this.m_points.read(s);if(-1===t.getUserIndex(e,this.m_pointsIndex))continue;const n=t.getNextVertex(e),r=t.getPrevVertex(e);if(e!==n&&!t.isEqualXYPoint2D(n,i)){const t=yt(e,n,1);h.push(t)}if(e!==r&&r!==n&&!t.isEqualXYPoint2D(r,i)){const t=yt(e,r,-1);h.push(t)}}h.length>0&&this.processBunch_(h,i)}s=n,i.assign(m),o=1,a=e}}if(0===this.m_dissolvedEdges)return t.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let m=t.getPointCount(e);for(let e=0;e<this.m_points.size();e++){const s=this.m_points.read(e);if(s===r.n)continue;if(-1!==t.getUserIndex(s,this.m_pointsIndex)){t.setUserIndex(s,this.m_pointsIndex,-1);continue}const n=t.getPathFromVertex(s);t.getFirstVertex(n)===s&&t.setFirstVertex(n,r.n),t.freeVertex(s),this.m_points.write(e,r.n),m--}const l=t.createPathUserIndex();let u=t.getPathCount(e);for(let s=0,i=this.m_points.size();s<i;++s){if(this.m_points.read(s)===r.n)continue;let i=this.m_points.read(s);if(-1!==t.getUserIndex(i,this.m_pointsIndex))continue;let o=t.getPathFromVertex(i),a=-1;if(2===t.getPathUserIndex(o,l)){o=r.n;for(let e=t.getNextVertex(i);e!==i;e=t.getNextVertex(e)){const s=t.getPathFromVertex(e);if(2!==t.getPathUserIndex(s,l)){o=s,i=e;break}}o===r.n&&(o=t.insertPath(e,r.n),t.setClosedPath(o,!0),u++),(0,n.g)(o!==r.n)}t.setPathUserIndex(o,l,2),a=t.getFirstVertex(o);let h=0,m=!1,c=i;do{a===c&&(m=!0),t.setUserIndex(c,this.m_pointsIndex,1);const e=t.getPathFromVertex(c);e!==o&&(2!==t.getPathUserIndex(e,l)&&(t.setPathUserIndex(e,l,1),t.setFirstVertex(e,r.n)),t.setPathToVertex(c,o)),h++,c=t.getNextVertex(c)}while(c!==i);m||t.setFirstVertex(o,i),t.setPathSize(o,h)}for(let s=t.getFirstPath(e);s!==r.n;){const e=t.getNextPath(s);1!==t.getPathUserIndex(s,l)&&t.getFirstVertex(s)!==r.n||(t.removePathOnly(s),u--),s=e}t.setGeometryVertexCount(e,m),t.setGeometryPathCount(e,u),t.removePathUserIndex(l),t.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,t.dbgVerifyVertexCounts(),t.filterClosePoints(0,!0,!1,!1,e)}processBunch_(t,e){t.sort((t,s)=>{const n=this.m_shape.getXY(t.vertex1).sub(e),i=this.m_shape.getXY(s.vertex1).sub(e),r=a.P.compareVectors(n,i);return 0===r?t.dir<s.dir?-1:1:r});let s=0;const n=this.m_shape.getXY(t[0].vertex1);let i=1;const r=this.m_shape.hasCurves();for(let e=1,o=t.length;e<o;e++){const a=this.m_shape.getXY(t[e].vertex1);if(!(a.isEqualPoint2D(n)&&(i++,e+1<o))){if(2===i){const e=t[s],n=t[s+1],i=e.dir;if(i!==n.dir){let t=!0;if(r&&(t=!this.m_shape.isCurve(1===e.dir?e.vertex0:e.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),t){if(1===i){const t=e.vertex0,s=n.vertex0;this.m_shape.setNextVertex(t,s),this.m_shape.setPrevVertex(s,t),this.m_shape.getPrevVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const i=e.vertex1,r=n.vertex1;this.m_shape.setPrevVertex(i,r),this.m_shape.setNextVertex(r,i),this.m_shape.getNextVertex(i)===r&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}else{const t=e.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(s,t),this.m_shape.getNextVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const i=e.vertex1,r=n.vertex1;this.m_shape.setNextVertex(i,r),this.m_shape.setPrevVertex(r,i),this.m_shape.getPrevVertex(i)===r&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(a),s=e,i=1}}t.length=0}}function Ct(t){for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e))if((0,n.h)(t.getGeometryType(e)))return!0;return!1}function vt(t,e,s,n,i){if(!Ct(e))return!1;let r=new bt(i);if(r.m_shape=e,r.m_tolerance=s,r.m_bAllowCoincident=t,r.m_bNeedsNonSimpleResult=null!==n,r.needsCrackingImpl_())return n&&n.assign(r.m_nonSimpleResult),!0;const o=new m.T;o.setSwapCoordinates(),e.applyTransformation(o),r=new bt(i),r.m_shape=e,r.m_tolerance=s,r.m_bAllowCoincident=t,r.m_bNeedsNonSimpleResult=null!==n;const a=r.needsCrackingImpl_();return e.applyTransformation(o),!!a&&(n&&n.assign(r.m_nonSimpleResult),!0)}function St(t,e){return{t,index:e}}class bt{crackBruteForce_(){let t=this.crackBruteForceImpl_();if(!t&&this.m_shape.hasCurves()){const e=new m.T;e.setSwapCoordinates(),this.m_shape.applyTransformation(e),t=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(e)}return t}crackBruteForceImpl_(){let t=!1;const e=new r.S,s=new r.S,a=i.Envelope2D.constructEmpty(),h=i.Envelope2D.constructEmpty(),m=!1,l=new o.P,u=new at,c=this.m_shape.getTotalPointCount(),g=c*c*2,d=this.m_shape.queryVertexIteratorOnSelection();for(let i=d.next();i!==r.n;i=d.next()){const o=this.m_shape.getGeometryType(d.currentGeometry());let c=1,_=1,p=1,f=0,x=0,P=0;const y=this.m_shape.getSegmentParentage(i);let E=!1,C=!1,v=null,S=!1;if((0,n.e)(o))c=this.m_shape.getWeight(i),f=this.m_shape.getRank(i);else{if(v=this.getSegment_(i,e),null===v)continue;const t=this.m_shape.getVertexIndex(i);c=this.m_shape.getWeightWithIndex(t),f=this.m_shape.getRankWithIndex(t),p=this.m_shape.getSegmentWeightWithIndex(t),P=this.m_shape.getSegmentRankWithIndex(t),E=this.m_shape.getSegmentParentageBreakVertex(i);{const t=this.m_shape.getNextVertex(i);_=this.m_shape.getWeight(t),x=this.m_shape.getRank(t),C=this.m_shape.getSegmentParentageBreakVertex(t)}if(v.queryLooseEnvelope(a),a.inflateCoords(this.m_tolerance,this.m_tolerance),v.isDegenerate(this.m_tolerance)){if(!v.isDegenerate(0))continue;S=!0,v=null}}const b=new r.V({copy:d});let I=b.next();I!==r.n&&(I=b.next());let D=0;for(;I!==r.n;I=b.next()){if(0!==D){D--;continue}if(this.m_shape.getTotalPointCount()>g)return t;this.progress_();const o=this.m_shape.getGeometryType(b.currentGeometry());let w=null,T=!1,N=0,A=0,G=0,q=0,M=0,F=0,X=!1,V=!1;const Y=this.m_shape.getSegmentParentage(I);if((0,n.e)(o))N=this.m_shape.getWeight(I),q=this.m_shape.getRank(I);else{if(w=this.getSegment_(I,s),null===w)continue;const t=this.m_shape.getVertexIndex(I);N=this.m_shape.getWeightWithIndex(t),q=this.m_shape.getRankWithIndex(t),G=this.m_shape.getSegmentWeightWithIndex(t),F=this.m_shape.getSegmentRankWithIndex(t),X=this.m_shape.getSegmentParentageBreakVertex(I);{const t=this.m_shape.getNextVertex(I);A=this.m_shape.getWeight(t),M=this.m_shape.getRank(t),V=this.m_shape.getSegmentParentageBreakVertex(t)}if(w.queryLooseEnvelope(h),w.isDegenerate(this.m_tolerance)){if(!w.isDegenerate(0))continue;T=!0,w=null}}let R=0,k=0;if(null!==v&&null!==w)a.isIntersectingNe(h)&&0!==(0,r.R)(!0,!0,v,w,this.m_tolerance,!0)&&(u.pushSegment(v,c,f,_,x,p,P,E,C,y),u.pushSegment(w,N,q,A,M,G,F,X,V,Y),u.intersect2D(this.m_tolerance,!0),t||=u.getSegmentChanged(0)||u.getSegmentChanged(1),R=u.getResultSegmentCount(0),k=u.getResultSegmentCount(1),R+k>0&&(this.m_shape.splitSegmentWithIntersector(i,u,0,!0,!0),this.m_shape.splitSegmentWithIntersector(I,u,1,!0,!0),this.m_bTrackChanges&&(u.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(i,!0),u.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(I,!0))),k>1&&(D+=k-1),u.clear());else if(null!==v){const e=this.m_shape.getXY(I);if(a.contains(e)){if(u.pushSegment(v,c,f,_,x,p,P,E,C,y),this.m_shape.queryPoint(I,l),u.intersect2DEx(this.m_tolerance,l,q,N,m),t||=u.getSegmentChanged(0)||u.getResultPointChanged(),R=u.getResultSegmentCount(0),R>0)if(this.m_bTrackChanges&&(u.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(i,!0),u.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(I,!0)),this.m_shape.splitSegmentWithIntersector(i,u,0,!0,!0),T){let t=r.n;for(let e=this.m_shape.getNextVertex(I);e!==r.n&&e!==I&&(w=this.getSegment_(e,s),t=e,null!=w&&w.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=I;e!==r.n&&(this.m_shape.setPoint(e,u.getResultPoint(),!0),e!==t);e=this.m_shape.getNextVertex(e));}else this.m_shape.setPoint(I,u.getResultPoint(),!0);u.clear()}}else{if(null===w)continue;{const e=this.m_shape.getXY(i);if(h.inflateCoords(this.m_tolerance,this.m_tolerance),h.contains(e)){if(u.pushSegment(w,N,q,A,M,G,F,X,V,Y),this.m_shape.queryPoint(i,l),u.intersect2DEx(this.m_tolerance,l,f,c,m),t||=u.getSegmentChanged(0)||u.getResultPointChanged(),k=u.getResultSegmentCount(0),k>0)if(this.m_bTrackChanges&&(u.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(I,!0),u.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(i,!0)),this.m_shape.splitSegmentWithIntersector(I,u,0,!0,!0),D+=k-1,S){let t=r.n;for(let e=this.m_shape.getNextVertex(i);e!==r.n&&e!==i&&(w=this.getSegment_(e,s),t=e,null!=w&&w.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=i;e!==r.n&&(this.m_shape.setPoint(e,u.getResultPoint(),!0),e!==t);e=this.m_shape.getNextVertex(e));}else this.m_shape.setPoint(i,u.getResultPoint(),!0);u.clear()}}}if(R+k!==0&&0!==R){let t=!1;for(;v=this.getSegment_(i,e),null!=v&&(v.queryEnvelope(a),v.isDegenerate(this.m_tolerance));){if(!(R>1)){t=!0;break}i=d.next(),R--,(0,n.g)(i!==r.n)}if(t)break}}}return t}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Pt(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let t=!1;const e=new o.A(0);e.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let t=0,n=s.next();n!==r.n;++t,n=s.next())e.write(t,n);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),e.add(r.n);const i=this.m_shape.createUserIndex(),h=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=[],u=[];let c=0;const d=new a.P;for(let s=e.read(c++);s!==r.n;){this.m_shape.queryXY(s,d);let o=!1;do{let t=this.m_shape.getNextVertex(s),n=this.m_shape.getPrevVertex(s);o||=t!==r.n||n!==r.n,t===r.n||this.m_shape.selected(t)||(t=r.n),n===r.n||this.m_shape.selected(n)||(n=r.n),t!==r.n&&this.m_shape.compareVerticesSimpleY(s,t)<0&&(u.push(s),u.push(t)),n!==r.n&&this.m_shape.compareVerticesSimpleY(s,n)<0&&(u.push(n),u.push(n));const a=this.m_shape.getUserIndex(s,i);-1!==a&&(l.push(a),this.m_shape.setUserIndex(s,i,-1));const m=this.m_shape.getUserIndex(s,h);-1!==m&&(l.push(m),this.m_shape.setUserIndex(s,h,-1)),s=e.read(c++)}while(s!==r.n&&this.m_shape.isEqualXYPoint2D(s,d));if(!o&&(null===m&&(m=new J(this.m_shape,this.m_tolerance)),m.setPoint(d),this.m_sweepStructure.searchUpperBound(m),m.intersectionDetected())){t=!0,this.m_bNeedsNonSimpleResult&&((0,n.d)("needsCrackingIMpl_"),this.m_nonSimpleResult=new g.NonSimpleResult(6,-1,-1));break}let _=1===l.length&&2===u.length;const p=32;l.length>p&&(0,a.v)(l);let f=-1,x=-1;if(!_)for(let e=0,s=l.length;e<s;e++){const s=l[e],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===l.indexOf(n))if(-1===f)f=n;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new g.NonSimpleResult(6,-1,-1)}const i=this.m_sweepStructure.getNext(s);if(-1!==i&&-1===l.indexOf(i))if(-1===x)x=i;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new g.NonSimpleResult(6,-1,-1)}if(-1!==f&&-1!==x)break}if(t&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(d.y,d.x),!_){for(let t=0,e=l.length;t<e;t++){const e=l[t];this.m_sweepStructure.deleteNode(e)}l.length=0}if(!_&&-1!==f&&-1!==x&&this.checkForIntersections_(f,x)){t=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let e=0,s=u.length;e<s;e+=2){const s=u[e],n=u[e+1];let r;if(_?(r=this.m_sweepStructure.replaceElementAtPosition(l[0],s,!0,!0),l.length=0,_=!1):r=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),t=!0;break}-1===this.m_shape.getUserIndex(n,i)?this.m_shape.setUserIndex(n,i,r):this.m_shape.setUserIndex(n,h,r)}if(t)break;u.length=0}return this.m_shape.removeUserIndex(i),this.m_shape.removeUserIndex(h),t}checkForIntersections_(t,e){const s=this.m_sweepStructure.getElement(t);this.m_sweepComparator.compare(this.m_sweepStructure,s,e);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(t,e){return bt.st_getSegment(this.m_shape,t,e)}static st_getSegment(t,e,s){return t.querySegment(e,s,!1,!1)?s.get():null}dbgPrintSweepEdge(t){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(t=null){}dbgCheckSweepStructure(){}progress_(t=!1){this.m_progressCounter++}crackAWithBMultiPath_(t,e,s){const h=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(h);const m=i.Envelope2D.constructEmpty();if(e.queryLooseEnvelope(m),m.inflateCoords(s,s),!m.isIntersecting(h))return t;const l=t.getImpl(),u=l.getAccelerators();let c=null,g=null;u&&(g=u.getQuadTree()),function(t,e){const s=t.getPointCount();if(s<16)return!1;return 2*s+Math.log(s)/Math.log(2)*1*e<1*s*e}(t,(0,n.v)(e))&&(c=(0,o.t)(l,m),g=c);const d=g?g.getIteratorForQT():null,_=e.querySegmentIterator(),p=t.querySegmentIterator(),f=(0,a.d)(15,Number.NaN),x=[];for(;_.nextPath();)for(;_.hasNextSegment();){const t=_.nextSegment();if(g){d.resetIterator(t,s);for(let e=d.next();-1!==e;e=d.next()){this.progress_();const n=g.getElement(e);if(p.resetToVertex(n,-1),p.hasNextSegment()){const e=p.nextSegment().intersect(t,null,f,null,s);for(let t=0;t<e;t++){const e=f[t];if(0===e||1===e)continue;const s=St(e,p.getStartPointIndex());x.push(s)}}}}else{const e=i.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(e),e.inflateCoords(s,s),!h.isIntersecting(e))continue;for(p.resetToFirstPath();p.nextPath();)for(;p.hasNextSegment();){const n=p.nextSegment(),r=i.Envelope2D.constructEmpty();if(n.queryLooseEnvelope(r),!r.isIntersecting(e))continue;const o=n.intersect(t,null,f,null,s);for(let t=0;t<o;t++){const e=f[t];if(0===e||1===e)continue;const s=St(e,p.getStartPointIndex());x.push(s)}}}}if(0===x.length)return t;x.sort((t,e)=>t.index<e.index?-1:t.index>e.index?1:t.t<e.t?-1:t.t>e.t?1:0);const P=t.createInstance();for(P.getGeometryType()===n.G.enumPolygon&&P.setFillRule(t.getFillRule()),p.resetToFirstPath();p.nextPath()&&!p.hasNextSegment(););(0,n.g)(p.hasNextSegment());let y=p.nextSegment();const E=new r.S;let C=-1;for(let t=0,e=x.length;t<e;){const s=x[t].index;let i=t+1;for(;i<e&&x[i].index===s;)++i;for(;p.getStartPointIndex()<s;){this.progress_();const t=p.hasNextSegment(),e=p.getPathIndex();if((t||!p.isClosingSegment()||p.isCurve())&&((0,n.g)(null!==y),P.addSegment(y,C!==e)),C=e,!t){for(p.isPathClosed();p.nextPath()&&!p.hasNextSegment(););(0,n.g)(p.hasNextSegment())}y=p.nextSegment()}let r=0;for(let e=t;e<i;e++){const t=x[e].t;if(t===r)continue;(0,n.g)(null!==y),y.queryCut(r,t,E),r=t;const s=p.getPathIndex();P.addSegment(E.get(),C!==s),C=s}const o=p.hasNextSegment();if((o||!p.isClosingSegment()||p.isCurve())&&((0,n.g)(null!=y),y.queryCut(r,1,E),P.addSegment(E.get(),!1)),o)y=p.nextSegment();else{for(;p.nextPath()&&!p.hasNextSegment(););y=p.hasNextSegment()?p.nextSegment():null}t=i}if(null!==y){const t=p.getPathIndex();(p.hasNextSegment()||!p.isClosingSegment()||p.isCurve())&&P.addSegment(y,C!==t),C=t}let v=p.hasNextSegment();for(;;){if(!v){for(;p.nextPath()&&(v=p.hasNextSegment(),!v););if(!v)break}y=p.nextSegment();const t=p.getPathIndex();v=p.hasNextSegment(),(v||!p.isClosingSegment()||p.isCurve())&&P.addSegment(y,C!==t),C=t}return P}constructor(t){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new g.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 o.T,this.m_progressTracker=t}}bt.s_bForceBruteForce=!0;class It{constructor(t,e){this.m_monotoneParts=(0,a.m)(r.S,16),this.m_xOrds=(0,a.d)(16,Number.NaN),this.m_inputPoint=a.P.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=t,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bTestBorder=!!e,this.m_bBreak=!1}_DoOne(t){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(t.getStartXY())||this.m_inputPoint.equals(t.getEndXY())))return void(this.m_bBreak=!0);if(t.getStartY()===this.m_inputPoint.y&&t.getStartY()===t.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const e=Math.min(t.getStartX(),t.getEndX()),s=Math.max(t.getStartX(),t.getEndX());this.m_inputPoint.x>e&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let e=!1;const s=Math.max(t.getStartX(),t.getEndX());if(this.m_inputPoint.x>s)e=!0;else if(this.m_inputPoint.x>=Math.min(t.getStartX(),t.getEndX())){const n=t.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);e=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(e){if(this.m_inputPoint.y===t.getStartY()){if(this.m_inputPoint.y<t.getEndY())return}else if(this.m_inputPoint.y===t.getEndY()&&this.m_inputPoint.y<t.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=t.getStartY()>t.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(t){const e=t.getClosestCoordinate(this.m_inputPoint,!1),s=t.getCoord2D(e);return a.P.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(t){this.m_inputPoint.setCoordsPoint2D(t),this.m_miny=t.y-this.m_tolerance,this.m_maxy=t.y+this.m_tolerance}processSegment(t){const e=t.queryInterval(0,1);if(e.vmin>this.m_maxy||e.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(t))return!0;if(e.vmin>this.m_inputPoint.y||e.vmax<this.m_inputPoint.y)return!1;let s=0;if(t.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=t.getMonotonicParts(this.m_monotoneParts,!0),(0,n.g)(this.m_monotoneParts.length>=s)),s>0)for(let t=0;t<s;t++){const e=this.m_monotoneParts[t].get(),s=a.E.construct(e.getStartY(),e.getEndY());if(!(s.vmin>this.m_inputPoint.y||s.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(t),this.m_bBreak)return!0;return!1}result(){return(0,n.g)(0),2}}function Dt(t,e,s){if(t.isEmpty())return 0;const r=i.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(r),r.inflateCoords(s,s),!r.contains(e))return 0;const o=t.getImpl().getAccelerators();if(o){o.getRasterizedGeometry()&&(0,n.g)(0);const r=o.getQuadTree();if(r)return function(t,e,s,n){const r=new i.Envelope2D;t.queryLooseEnvelope(r),r.inflateCoords(n,n);const o=0===t.getFillRule(),a=new It(o,n);a.setInputPoint(s);const h=r.clone();h.xmax=s.x+n,h.ymin=s.y-n,h.ymax=s.y+n;const m=t.getImpl().querySegmentIterator(),l=e.getIterator(h,n);for(let t=l.next();-1!==t;t=l.next())if(m.resetToVertex(e.getElement(t),-1),m.hasNextSegment()){const t=m.nextSegment();if(a.processSegment(t))return-1}return a._Result()?1:0}(t,r,e,s)}return function(t,e,s){const n=0===t.getFillRule(),i=new It(n,s);i.setInputPoint(e);const r=t.getImpl().querySegmentIterator();for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(i.processSegment(t))return-1}return i._Result()?1:0}(t,e,s)}function wt(t,e){const s=t.getPointCount();return!(s<16)&&2*s+Math.log(s)/Math.log(2)*1*e<1*s*e}class Tt{getDirection_(t){return this.m_shape.getNextVertex(this.getEnd1(t))===this.getEnd2(t)}getEnd_(t){const e=this.getEnd1(t),s=this.getEnd2(t);return this.m_shape.getNextVertex(e)===s?s:e}constructor(t){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=t,this.m_firstFree=-1}getSegment(t){return this.m_shape.getSegment(this.getStart(t))}isBottomUp(t){let e=this.getEnd1(t),s=this.getEnd2(t);this.m_shape.getPrevVertex(e)===s&&(s=(0,a.c)(e,e=s));const i=a.P.getNAN(),r=a.P.getNAN();return this.m_shape.queryXY(e,i),this.m_shape.queryXY(s,r),(0,n.g)(!i.equals(r)),i.y<r.y}getStart(t){const e=this.getEnd1(t),s=this.getEnd2(t);return this.m_shape.getNextVertex(e)===s?e:s}getEnd1(t){return this.m_end1Nodes[t]}getEnd2(t){return this.m_end2Nodes[t]}freeEdge(t){this.m_end1Nodes[t]=this.m_firstFree,this.m_firstFree=t}newEdge(t){if(-1!==this.m_firstFree){const e=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[e],this.m_end1Nodes[e]=t,this.m_end2Nodes[e]=this.m_shape.getNextVertex(t),e}const e=this.m_end1Nodes.length;return this.m_end1Nodes.push(t),this.m_end2Nodes.push(this.m_shape.getNextVertex(t)),e}getShape(){return this.m_shape}getPath(t){return this.m_shape.getPathFromVertex(this.getEnd1(t))}}let Nt=class extends o.F{constructor(t){super(),this.m_line1=new r.L,this.m_line2=new r.L,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=t}compare(t,e,s){const i=t.getElement(s),r=this.m_helper.m_edges;let o;this.m_leftElm===e?o=this.m_leftx:(this.m_seg1=r.getSegment(e),this.m_seg1?o=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(e),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=e);let a,h=r.getSegment(i);if(h?a=h.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(r.getShape().queryLineConnector(r.getStart(i),this.m_line2,!0),h=this.m_line2,a=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),o===a){const t=r.isBottomUp(e),s=r.isBottomUp(i),m=t?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=s?h.getEndY():h.getStartY(),u=Math.min(m,l);let c=.5*(u+this.m_helper.m_yScanline);c===this.m_helper.m_yScanline&&(c=u),o=this.m_seg1.intersectionOfYMonotonicWithAxisX(c,0),a=h.intersectionOfYMonotonicWithAxisX(c,0),o===a&&(0,n.z)("")}return o<a?-1:o>a?1:0}reset(){this.m_leftElm=-1}};class At{constructor(t){this.m_node=-1,this.m_index=0,this.m_sortedVertices=t.m_sortedVertices,this.m_sortedVerticesArray=t.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const t=this.m_node;if(-1===t)return r.n;const e=this.m_sortedVertices.getData(t);return this.m_node=this.m_sortedVertices.getNext(t),e}if(this.m_index<this.m_sortedVerticesArray.size()){const t=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,t}return r.n}}class Gt{constructor(t){this.m_edges=null,this.m_shape=null,this.m_AET=new o.T,this.m_yScanline=0,this.m_geometry=r.n,this.m_unknownRingOrientationCount=-1,this.m_sortedVertices=null,this.m_sortedVerticesArray=null,this.m_unknownNodes=[],this.m_node1UserIndex=-1,this.m_node2UserIndex=-1,this.m_pathOrientationIndex=-1,this.m_pathParentageIndex=-1,this.m_pathParentsIndex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_progressTracker=t,this.m_AET.disableBalancing(),this.m_sweepComparator=new Nt(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const t=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),t}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(t){return this.processBunchForRingOrientationTestOddEven_(t)}processBunchForRingOrientationTestOddEven_(t){let e=!1;if(this.m_edges||(this.m_edges=new Tt(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(t),!this.m_AET.isAutoBalancing()){let e=0;for(let s=0,n=t.length;s<n;s++)-1!==t[s]&&e++;(e>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let e=0,s=t.length;e<s;e++){const s=t[e];s!==r.n&&this.insertEdge_(s,-1)}for(let t=0;t<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;t++){const s=this.m_unknownNodes[t],i=this.m_AET.getElement(s),a=this.m_edges.getPath(i),h=this.m_shape.getPathUserIndex(a,this.m_pathOrientationIndex);let m=r.n;if(0===h){let t=this.m_AET.getPrev(s),i=s,r=!1;for(;t!==o.T.st_nullNode();){const e=this.m_AET.getElement(t),s=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(s,this.m_pathOrientationIndex)){m=s;break}i=t,t=this.m_AET.getPrev(t)}if(t===o.T.st_nullNode())r=!0,t=i;else{const e=this.m_AET.getElement(t);r=this.m_edges.isBottomUp(e),t=this.m_AET.getNext(t),r=!r}do{const s=this.m_AET.getElement(t),o=this.m_edges.getPath(s);if(0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(s)){const t=this.m_shape.getFirstVertex(o);this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(o,this.m_shape.getPrevVertex(t)),e=!0}if(this.m_shape.setPathUserIndex(o,this.m_pathOrientationIndex,r?3:2),!r){let t=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex);2===t?(m=this.m_shape.getPathUserIndex(m,this.m_pathParentsIndex),t=this.m_shape.getPathUserIndex(m,this.m_pathOrientationIndex),(0,n.g)(3===t)):(0,n.g)(3===t);const e=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,e),this.m_shape.setPathUserIndex(o,this.m_pathParentsIndex,m)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return e}m=o,i=t,t=this.m_AET.getNext(t),r=!r}while(i!==s)}}return e}processBunchForRingOrientationRemoveEdges_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),i=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const t=this.m_AET.getElement(n);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==i){const t=this.m_AET.getElement(i);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let o=-1;-1!==n&&-1!==i?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(i),t[e]=r.n):o=-1!==n?n:i,-1!==o&&(this.insertEdge_(s,o)||this.m_AET.deleteNode(o),t[e]=r.n)}}dbgVerifyRingOrientation_(){}insertEdge_(t,e){const s=a.P.getNAN(),n=a.P.getNAN();this.m_shape.queryXY(t,s);const i=this.m_shape.getNextVertex(t);this.m_shape.queryXY(i,n);let r=!1;if(s.y<n.y){r=!0;const s=this.m_edges.newEdge(t);let n;-1===e?n=this.m_AET.addElement(s):(n=e,this.m_AET.setElement(n,s)),-1===this.m_shape.getUserIndex(i,this.m_node1UserIndex)?this.m_shape.setUserIndex(i,this.m_node1UserIndex,n):this.m_shape.setUserIndex(i,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(t);if(this.m_shape.queryXY(o,n),s.y<n.y){r=!0;const s=this.m_edges.newEdge(o);let n;-1===e?n=this.m_AET.addElement(s):(n=e,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 i=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return r}fixRingSelfTangency_(){const t=[],e=[];let s=-1,i=-1;const o=new a.P;let h=r.n,m=r.n,l=-1;const u=new At(this);for(let n=u.next();n!==r.n;n=u.next()){const r=new a.P;this.m_shape.queryXY(n,r);const u=this.m_shape.getPathFromVertex(n);o.equals(r)&&m===u?(-1===i&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),i=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,i,-1)),-1===l&&(l=e.length,this.m_shape.setUserIndex(h,i,l),e.push(1),-1===this.m_shape.getPathUserIndex(u,s)&&(this.m_shape.setPathUserIndex(u,s,h),t.push(u))),this.m_shape.setUserIndex(n,i,l),e[e.length-1]++):(l=-1,o.assign(r)),h=n,m=u}if(0===t.length)return!1;(0,n.g)(-1!==s);for(let n=0,r=t.length;n<r;n++){const r=t[n];let o=this.m_shape.getPathUserIndex(r,s);const a=this.m_shape.getUserIndex(o,i),h=[],m=[];h.push(o),m.push(a);for(let t=this.m_shape.getNextVertex(o);t!==o;t=this.m_shape.getNextVertex(t)){const s=t,n=this.m_shape.getUserIndex(s,i);if(-1!==n){if(0===m.length){m.push(n),h.push(s);continue}if(m.at(-1)===n){const r=h.at(-1);this.m_shape.peelALoopIntoAPath(r,s),this.m_shape.setUserIndex(t,i,-1),e[n]--,1===e[n]&&(e[n]=0,m.pop(),h.pop()),o=r,t=r}else h.push(t),m.push(n)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(i),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(t=!1){}fixRingOrientationImplMain_(){const t={stack:[],error:void 0,hasError:!1};try{let e,s=!1;const n=(0,h.mS)(t,(0,a.h)(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const t=this.m_shape.getPointCount(this.m_geometry);e=new o.A(0);for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==r.n;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let n=0,i=this.m_shape.getPathSize(t);n<i;n++)e.add(s),s=this.m_shape.getNextVertex(s)}this.m_shape.sortVerticesSimpleByY(e,0,t),this.progress_(!0),this.m_sortedVerticesArray=e}else n.bForget=!0;if(this.m_bFixSelfTangency&&(s=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const t=this.m_shape.getFirstPath(this.m_geometry),e=this.m_shape.getRingArea(t);if(this.m_shape.setExterior(t,!0),e<0){const e=this.m_shape.getFirstVertex(t);return this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(e)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==r.n;t=this.m_shape.getNextPath(t))this.m_shape.setPathUserIndex(t,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(t,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const m=a.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 At(this);for(let t=l.next();t!==r.n&&(this.progress_(),this.m_shape.queryXY(t,m),m.y!==this.m_yScanline&&i.length&&(s=this.processBunchForRingOrientationTest_(i)||s,this.m_sweepComparator.reset(),i.length=0),i.push(t),this.m_yScanline=m.y,0!==this.m_unknownRingOrientationCount);t=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(e){t.error=e,t.hasError=!0}finally{(0,h.hk)(t)}}fixRingOrientationImplSimplify_(){const t=[];for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==r.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(e,this.m_pathOrientationIndex)){this.m_shape.setExterior(e,!0);for(let s=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s!==r.n;){const n=this.m_shape.getPathUserIndex(s,this.m_pathParentageIndex);t.push(s),this.m_shape.setExterior(s,!1),this.m_shape.setPathUserIndex(s,this.m_pathParentageIndex,e),s=n}let s=e,n=t.length;for(let t=this.m_shape.getNextPath(e);n>0&&t!==r.n;t=this.m_shape.getNextPath(t),--n){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==e){s=r.n;break}s=t}if(0!==n){s=e;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,o.J),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}t.length=0,e=this.m_shape.getNextPath(s)}else e=this.m_shape.getNextPath(e);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const t=this.m_shape.createPathUserIndex();let e=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==r.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,t,e),e++;for(let t=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);t!==r.n;){const e=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);s.push(t),this.m_shape.setExterior(t,!1),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,n),t=e}let i=n,a=s.length,h=e;for(let e=this.m_shape.getNextPath(n);a>0&&e!==r.n;e=this.m_shape.getNextPath(e),--a){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==n){i=r.n;break}i=e,this.m_shape.setPathUserIndex(e,t,-h),h++}if(0!==a){i=n,h=e;for(let e=0,n=s.length;e<n;e++){const n=s[e];this.m_shape.setPathUserIndex(n,t,-h),h++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,o.J)}i=n}e=h,s.length=0,n=this.m_shape.getNextPath(i)}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),t}}function qt(t,e,s,n,i,r){const o=new Mt(r);return o.m_shape=t,o.m_geometry=e,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=i,o.m_bHasSegmentParentage=t.hasSegmentParentage(),o.m_bHasSegments=t.hasCurves(),o.simplify_()}class Mt{constructor(t){this.m_shape=null,this.m_geometry=r.n,this.m_sortedVertices=new o.I,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=r.n,this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_bHasSegmentParentage=!1,this.m_bHasSegments=!1,this.m_progressTracker=t}compareAngles_(t,e){return this.m_bHasSegments?this.compareAnglesCurves_(t,e):this.compareAnglesLines_(t,e)}compareAnglesLines_(t,e){const s=this.m_bunchEdgeEndPoints[t],i=new a.P;this.m_shape.queryXY(s,i);const r=new a.P,o=this.m_bunchEdgeEndPoints[e];if(this.m_shape.queryXY(o,r),i.equals(r))return 0;const h=this.m_bunchEdgeCenterPoints[t],m=new a.P;this.m_shape.queryXY(h,m);const l=this.m_bunchEdgeCenterPoints[e],u=new a.P;this.m_shape.queryXY(l,u);const c=new a.P;c.setSub(i,m);const g=new a.P;return g.setSub(r,u),(c.isZero()||g.isZero())&&(0,n.z)(""),a.P.compareVectors(c,g)}compareAnglesCurves_(t,e){const s=this.m_bunchEdgeEndPoints[t],n=this.m_bunchEdgeEndPoints[e],i=this.m_bunchEdgeCenterPoints[t],o=this.m_bunchEdgeCenterPoints[e],a=this.m_shape.getNextVertex(i)===s,h=this.m_shape.getNextVertex(o)===n,m=a?this.m_shape.isCurve(i):this.m_shape.isCurve(s),l=h?this.m_shape.isCurve(o):this.m_shape.isCurve(n);return m||l?(this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new r.S),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new r.S),a?this.m_shape.querySegment(i,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(o,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse()),(0,r.I)(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())):this.compareAnglesLines_(t,e)}beforeRemoveVertex_(t,e){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(t),e){const e=this.m_shape.getPathFromVertex(t);if(e!==r.n&&this.m_shape.getFirstVertex(e)===t){const s=this.m_shape.getNextVertex(t);if(s!==t){if(this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s);{const s=this.m_shape.getPrevVertex(t);if(s!==t&&this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s)}}this.m_shape.setFirstVertex(e,r.n),this.m_shape.setLastVertex(e,r.n)}}}processBunch_(){let t=!1;const e=new a.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,i=!0;for(;s!==this.m_nextVertexToProcess;){const t=this.m_sortedVertices.getData(s);i&&(this.m_shape.queryXY(t,e),i=!1);const r=this.m_shape.getPrevVertex(t),a=this.m_shape.getNextVertex(t);this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex)!==o.J&&(this.m_bunchEdgeEndPoints.push(r),this.m_shape.setUserIndex(r,this.m_userIndexSortedAngleIndexToVertex,o.J),this.m_bunchEdgeCenterPoints.push(t),this.m_bunchEdgeIndices.push(n++)),this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex)!==o.J&&(this.m_bunchEdgeEndPoints.push(a),this.m_shape.setUserIndex(a,this.m_userIndexSortedAngleIndexToVertex,o.J),this.m_bunchEdgeCenterPoints.push(t),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((t,e)=>this.compareAngles_(t,e));for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t],s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,t)}const r=this.processCrossOvers_(e);for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t];if(-1===e)continue;const s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!r)break;t=!0}return t}processCrossOvers_(t){let e=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let i=this.getNextEdgeIndex_(n);for(let r=0,o=this.m_bunchEdgeIndices.length;r<o&&-1!==n&&-1!==i&&n!==i;r++){const r=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[i],a=this.m_bunchEdgeEndPoints[r],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a),l=!0);let u=this.m_shape.getNextVertex(h),c=!1;this.m_shape.isEqualXYPoint2D(u,t)||(u=this.m_shape.getPrevVertex(h),c=!0);const g=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),d=c?this.m_shape.getPrevVertex(u):this.m_shape.getNextVertex(u);let _=!1;(this.removeSpike_(m)||this.removeSpike_(u)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(g)||this.removeSpike_(d))&&(_=!0),m!==u&&(!_&&this.m_shape.isEqualXY(a,h)&&(_=this.resolveOverlap_(l,c,m,a,u,h)),!_&&this.m_shape.isEqualXY(g,d)&&(_=this.resolveOverlap_(!l,!c,m,g,u,d)),!_&&this.m_shape.isEqualXY(a,d)&&(_=this.resolveOverlap_(l,!c,m,a,u,d)),!_&&this.m_shape.isEqualXY(g,h)&&(_=this.resolveOverlap_(!l,c,m,g,u,h))),_&&(e=!0),s||=_,n=_?this.getNextEdgeIndex_(n):i,i=this.getNextEdgeIndex_(n)}}if(!e){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let i=0,r=this.m_bunchEdgeIndices.length;i<r&&-1!==s&&-1!==n&&s!==n;i++){const i=this.m_bunchEdgeIndices[s],r=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[i],a=this.m_bunchEdgeEndPoints[r];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,t)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),u=this.getDirection_(m,a),c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),g=u?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),d=this.detectAndResolveCrossOver_(l,u,o,h,c,a,m,g);1!==d?0===d?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):e=!0}}return e}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===n.G.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)&&new Gs(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let t=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const e=this.m_shape.getPointCount(this.m_geometry),s=new o.A(0);this.m_shape.dbgVerifyMonotone();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==r.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let n=0,i=this.m_shape.getPathSize(t);n<i;n++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,e),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(e),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let t=0;t<e;t++){const e=s.read(t),n=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,n)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(t=!0);let i=0,h=!1;do{h=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const e=new a.P(0,0);this.m_firstCoincidentVertex!==o.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),e);let s=0,r=this.m_firstCoincidentVertex;for(;r!==o.I.st_nullNode()&&(r=this.m_sortedVertices.getNext(r),r!==o.I.st_nullNode());){this.progress_();const t=this.m_sortedVertices.getData(r),n=a.P.getNAN();if(this.m_shape.queryXY(t,n),e.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=r;const t=this.processBunch_();r=this.m_nextVertexToProcess,r!==o.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(r),n),t&&(h=!0)}e.setCoordsPoint2D(n),this.m_firstCoincidentVertex=r,s=0}}this.m_nextVertexToProcess=-1,s>0&&this.processBunch_()&&(h=!0),i++>10&&(0,n.d)(""),h&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(h=!0),t||=h}while(h);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),t=function(t,e,s,n,i){const r=new Gt(i);return r.m_shape=t,r.m_geometry=e,r.m_sortedVertices=s,r.m_bFixSelfTangency=n,r.fixRingOrientation_()}(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||t,this.m_shape.dbgVerifyCurves(),t}getDirection_(t,e){return this.m_shape.getNextVertex(e)!==t}detectAndResolveCrossOver_(t,e,s,n,i,r,o,h){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(r),-1;const m=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),u=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),c=this.m_shape.getUserIndex(h,this.m_userIndexSortedAngleIndexToVertex),g=(0,a.d)(8,Number.NaN),d=(0,a.d)(4,Number.NaN);g[0]=0,d[0]=m,g[1]=0,d[1]=l,g[2]=1,d[2]=u,g[3]=1,d[3]=c;for(let t=1;t<4;t++){const e=d[t],s=g[t];let n=t-1;for(;n>=0&&d[n]>e;)d[n+1]=d[n],g[n+1]=g[n],n--;d[n+1]=e,g[n+1]=s}let _=0;if(g[0]&&(_|=1),g[1]&&(_|=2),g[2]&&(_|=4),g[3]&&(_|=8),5!==_&&10!==_)return 0;if(t!==e&&(h=(0,a.c)(r,r=h)),t)this.m_shape.setNextVertex(h,n),this.m_shape.setPrevVertex(n,h),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(h,n),this.m_shape.setNextVertex(n,h),this.m_shape.setPrevVertex(i,o),this.m_shape.setNextVertex(o,i),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(n),e=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,e,!0),this.m_shape.setSegmentParentageAndBreak(o,t,!0)}if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(n),e=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const i=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,i),this.m_shape.setSegmentToIndex(e,s)}}return 1}resolveOverlap_(t,e,s,n,i,r){return this.resolveOverlapOddEven_(t,e,s,n,i,r)}resolveOverlapOddEven_(t,e,s,n,i,r){if(t!==e){t||(i=(0,a.c)(s,s=i),r=(0,a.c)(n,n=r));const e=this.m_shape.getNextVertex(i),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,e),this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(s),e=this.m_shape.getVertexIndex(i),n=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const r=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,r),this.m_shape.setSegmentToIndex(e,n)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(s),e=this.m_shape.getSegmentParentage(i);this.m_shape.setSegmentParentageAndBreak(s,e,!0),this.m_shape.setSegmentParentageAndBreak(i,t,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}this.removeSpike_(i)}else{const o=t?s:n,a=e?i:r,h=t?n:s,m=e?r:i;let l=null;if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null);const e=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(e,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let u=-1;this.m_bHasSegmentParentage&&(u=this.m_shape.getSegmentParentage(m));let c=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(h,m),this.m_shape.setPrevVertex(m,h);let g=m;for(;g!==a;){const t=this.m_shape.getPrevVertex(g),e=this.m_shape.getNextVertex(g);if(this.m_shape.setPrevVertex(g,e),this.m_shape.setNextVertex(g,t),c||=g===o,this.m_bHasSegments&&g!==o){const t=this.m_shape.getVertexIndex(e),s=l;l=this.m_shape.getSegmentFromIndex(t),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(t,s)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(e);this.m_shape.setSegmentParentagePreserveBreak(e,u),u=t}g=e}let d=null;if(!c){const t=this.m_shape.getPrevVertex(a),e=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,e),this.m_shape.setNextVertex(a,t),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(a);d=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null)}}let _=-1,p=-1;if(this.m_bHasSegmentParentage&&(_=c?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(h)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(m,h),this.beforeRemoveVertex_(m,!0),this.m_shape.removeVertexInternal(m,!0),this.removeAngleSortInfo_(h),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,_,!0),this.m_shape.setSegmentParentageAndBreak(h,p,!0)),d){const t=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(t,d)}}return!0}cleanupSpikes_(){let t=!1;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==r.n;){const s=this.m_shape.getNextPath(e);let n=this.m_shape.getFirstVertex(e);for(let s=0,i=this.m_shape.getPathSize(e);s<i&&i>1;){this.progress_();const{v:o,bModified:a}=this.checkAndCleanupSpike_(e,n);if(o===r.n)break;a?(t=!0,n=o,s=0,i=this.m_shape.getPathSize(e)):(n=o,s++)}e=s}return t}checkAndCleanupSpike_(t,e){const s={v:r.n,bModified:!1};let n=this.m_shape.getPrevVertex(e),i=this.m_shape.getNextVertex(e),o=r.n,a=r.n;for(;this.m_shape.isEqualXY(n,i)&&(o=n,a=i,i!==e);)n=this.m_shape.getPrevVertex(n),i=this.m_shape.getNextVertex(i);if(o===r.n)return s.v=i,s;s.bModified=!0;for(let t=this.m_shape.getNextVertex(o);this.beforeRemoveVertex_(t,!1),t!==a;t=this.m_shape.getNextVertex(t));if(o===e)return this.m_polylineDegeneracies!==r.n?this.m_shape.movePath(this.m_polylineDegeneracies,r.n,t):this.m_shape.removePath(t),s.v=r.n,s;{const t=this.m_shape.peelALoopIntoAPath(o,a);this.m_polylineDegeneracies!==r.n?this.m_shape.movePath(this.m_polylineDegeneracies,r.n,t):this.m_shape.removePath(t)}return s.v=o,s}removeSpike_(t){let e=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(t),n=r.n,i=r.n;for(;this.m_shape.isEqualXY(e,s)&&(n=e,i=s,s!==t);)e=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(s);if(n===r.n)return!1;if(this.m_shape.peelALoop(n,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===r.n)for(let t=this.m_shape.getNextVertex(i);;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(t),null),this.m_shape.removeVertexInternal(t,!1),t===i)break;t=e}else{for(let t=i;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===i)break}const t=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,r.n,i,i,t)}return!0}fixOrphanVertices_(){let t=0;for(let t=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==t;t=this.m_sortedVertices.getNext(t)){const e=this.m_sortedVertices.getData(t);this.m_shape.setPathToVertex(e,r.n)}let e=0;for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==r.n;){const n=this.m_shape.getFirstVertex(s);if(n===r.n||this.m_shape.getPathFromVertex(n)!==r.n){const t=s;s=this.m_shape.getNextPath(s),this.m_shape.removePathOnly(t);continue}this.m_shape.setPathToVertex(n,s);let i=1;for(let t=this.m_shape.getNextVertex(n);t!==n;t=this.m_shape.getNextVertex(t))this.m_shape.setPathToVertex(t,s),i++;this.m_shape.setRingAreaValid(s,!1),this.m_shape.setPathSize(s,i),this.m_shape.setLastVertex(s,this.m_shape.getPrevVertex(n)),e+=i,t++,s=this.m_shape.getNextPath(s)}for(let s=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==s;s=this.m_sortedVertices.getNext(s)){const n=this.m_sortedVertices.getData(s);if(this.m_shape.getPathFromVertex(n)!==r.n)continue;const i=[!1],o=this.m_shape.insertClosedPath(this.m_geometry,r.n,n,n,i);e+=this.m_shape.getPathSize(o),t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,e);let s=0;for(let t=this.m_shape.getFirstGeometry();t!==r.n;t=this.m_shape.getNextGeometry(t))s+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(t+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}getPrevEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(this.m_bunchEdgeIndices.length+t-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}transferVertexData_(t,e){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(t,e),this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(t){const e=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);-1!==e&&(this.m_bunchEdgeIndices[e]=-1,this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(t=!1){}}function Ft(t,e,s,h,m,l=!0){switch(Xt(h)){case 0:break;case 1:(0,n.a)("relation string length has to be 9 characters");break;default:(0,n.a)("relation string")}if(l){const n=function(t,e,s){return function(t){return"T*F**FFF*"===t}(t)?3:function(t){return"FF*FF****"===t}(t)?4:function(t,e,s){return!(0===e&&0===s||(2===e&&2===s?"F***T****"!==t:2!==e&&1!==e||0!==s||"F**T*****"!==t))}(t,e,s)?8:function(t,e,s){return e>s?"T*****T**"===t:1===e&&1===s&&"0********"===t}(t,e,s)?16:function(t){return"T**FF*FF*"===t}(t)?64:function(t){return"T*****FF*"===t}(t)?1:function(t,e,s){return e===s&&(1!==e?"T*T***T**"===t:"1*T***T**"===t)}(t,e,s)?32:0}(h,t.getDimension(),e.getDimension());if(0!==n)return $t(t,e,s,n,m)}let u=0;if("number"==typeof s)u=s;else{const n=i.Envelope2D.constructEmpty();t.queryEnvelope(n);const r=i.Envelope2D.constructEmpty();e.queryEnvelope(r);const a=i.Envelope2D.constructEmpty();a.setCoords({env2D:n}),a.mergeEnvelope2D(r),u=(0,o.a)(s,a,!1)}const c=Wt(t,u),g=Wt(e,u);if(c.isEmpty()||g.isEmpty())return function(t,e,s){const o=(0,a.d)(9,-1);if(t.isEmpty()&&e.isEmpty())return Ht(o,s);let h,m=!1;t.isEmpty()?(h=e,m=!0):h=t,o[0]=-1,o[1]=-1,o[3]=-1,o[4]=-1,o[6]=-1,o[7]=-1,o[8]=2;const l=h.getGeometryType();if((0,n.h)(l))if(l===n.G.enumPolygon)if(0!==h.calculateArea2D())o[2]=2,o[5]=1;else{o[5]=-1;const t=i.Envelope2D.constructEmpty();h.queryEnvelope(t),o[2]=t.height()||t.width()?1:0}else{const t=0!==h.calculateLength2D();o[2]=t?1:0,o[5]=(0,r.A)(h)?0:-1}else o[2]=0,o[5]=-1;return m&&Ot(o),Ht(o,s)}(c,g,h);const d=c.getGeometryType(),_=g.getGeometryType();let p=!1;switch(d){case n.G.enumPolygon:switch(_){case n.G.enumPolygon:p=function(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setAreaAreaPredicates_();const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.areaAreaDisjointPredicates_(t,e),u=!0),u||ee(t,e),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.computeMatrixTopoGraphHalfEdges_(i,m),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPolyline:p=Vt(c,g,u,h,m);break;case n.G.enumPoint:p=kt(c,g,u,h);break;case n.G.enumMultiPoint:p=Yt(c,g,u,h,m)}break;case n.G.enumPolyline:switch(_){case n.G.enumPolygon:p=Vt(g,c,u,jt(h),m);break;case n.G.enumPolyline:p=function(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setLineLinePredicates_();const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.lineLineDisjointPredicates_(t,e),u=!0),u||ee(t,e),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),zt(i,h.m_topoGraph,h.m_clusterIndexA),zt(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(i,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPoint:p=Lt(c,g,u,h,m);break;case n.G.enumMultiPoint:p=Rt(c,g,u,h,m)}break;case n.G.enumPoint:switch(_){case n.G.enumPolygon:p=kt(g,c,u,jt(h));break;case n.G.enumPolyline:p=Lt(g,c,u,jt(h),m);break;case n.G.enumPoint:p=function(t,e,s,n){const i=t.getXY(),r=e.getXY(),o=(0,a.d)(9,-1);return a.P.sqrDistance(i,r)<=s*s?o[0]=0:(o[2]=0,o[6]=0),o[8]=2,Ht(o,n)}(c,g,u,h);break;case n.G.enumMultiPoint:p=Bt(g,c,u,jt(h))}break;case n.G.enumMultiPoint:switch(_){case n.G.enumPolygon:p=Yt(g,c,u,jt(h),m);break;case n.G.enumPolyline:p=Rt(g,c,u,jt(h),m);break;case n.G.enumMultiPoint:p=function(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setPointPointPredicates_();const m=new i.Envelope2D,l=new i.Envelope2D;t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.pointPointDisjointPredicates_(),u=!0),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.computeMatrixTopoGraphClusters_(i,m),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPoint:p=Bt(c,g,u,h)}break;default:p=!1}return p}function Xt(t){if(9!==t.length)return 1;for(let e=0;e<9;e++){const s=t[e];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function Vt(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setAreaLinePredicates_();const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.areaLineDisjointPredicates_(t,e),u=!0),u||ee(t,e),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),zt(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(i,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}function Yt(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setAreaPointPredicates_();const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.areaPointDisjointPredicates_(t),u=!0),u||ee(t,e),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.computeMatrixTopoGraphClusters_(i,m),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}function Rt(t,e,s,n,a){const h=new Ut;h.resetMatrix_(),h.setPredicates_(n),h.setLinePointPredicates_();const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(te(m,l,s)&&(h.linePointDisjointPredicates_(t),u=!0),u||ee(t,e),!u){const n=new r.E,i=n.addGeometry(t),m=n.addGeometry(e);h.setEditShapeCrackAndCluster_(n,new o.C(s,0),a),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),zt(i,h.m_topoGraph,h.m_clusterIndexA),h.computeMatrixTopoGraphClusters_(i,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.removeShape()}return Ht(h.m_matrix,h.m_scl)}function kt(t,e,s,n,r){const o=new Ut;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=i.Envelope2D.constructEmpty();t.queryEnvelope(a);const h=e.getXY();let m=!1;if(se(h,a,s)&&(o.areaPointDisjointPredicates_(t),m=!0),!m){const e=Je(t,h,s);if(1===e)o.m_matrix[0]=0,o.m_matrix[2]=2,o.m_matrix[3]=-1,o.m_matrix[5]=1,o.m_matrix[6]=-1;else if(2===e)if(o.m_matrix[6]=-1,0!==t.calculateArea2D())o.m_matrix[0]=-1,o.m_matrix[3]=0,o.m_matrix[2]=2,o.m_matrix[5]=1;else{o.m_matrix[0]=0,o.m_matrix[3]=-1,o.m_matrix[5]=-1;const e=i.Envelope2D.constructEmpty();t.queryEnvelope(e),o.m_matrix[2]=e.height()||e.width()?1:-1}else o.areaPointDisjointPredicates_(t)}return Ht(o.m_matrix,n)}function Lt(t,e,s,n,o){const a=new Ut;a.resetMatrix_(),a.setPredicates_(n),a.setLinePointPredicates_();const h=i.Envelope2D.constructEmpty();t.queryEnvelope(h);let m=!1;if(se(e.getXY(),h,s)&&(a.linePointDisjointPredicates_(t),m=!0),!m){let n=null,i=!1,h=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&($t(t,e,s,4,o)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(n=(0,r.c)(t),h=!$t(n,e,s,4,o),i=!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:(i||(null==n&&(n=(0,r.c)(t)),h=!$t(n,e,s,4,o),i=!0),a.m_matrix[3]=h?0:-1)),a.m_performPredicates[5])if(null!==n&&n.isEmpty())a.m_matrix[5]=-1;else if(i&&!h)a.m_matrix[5]=0;else{null===n&&(n=(0,r.c)(t));const i=$t(n,e,s,3,o);a.m_matrix[5]=i?-1:0}if(a.m_performPredicates[2])if(0!==t.calculateLength2D())a.m_matrix[2]=1;else{const n=new r.M({vd:t.getDescription()});n.addPoints(t,0,t.getPointCount());const i=$t(n,e,s,3,o);a.m_matrix[2]=i?-1:0}}return Ht(a.m_matrix,a.m_scl)}function Bt(t,e,s,n,r){const o=new Ut;o.resetMatrix_(),o.setPredicates_(n),o.setPointPointPredicates_();const h=i.Envelope2D.constructEmpty();t.queryEnvelope(h);const m=e.getXY(),l=new a.P;let u=!1;if(se(m,h,s)&&(o.pointPointDisjointPredicates_(),u=!0),!u){let e=!1,n=!0;const i=s*s;for(let s=0;s<t.getPointCount()&&(t.queryXY(s,l),a.P.sqrDistance(l,m)<=i?e=!0:n=!1,!e||n);s++);e?(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 Ht(o.m_matrix,n)}function Ht(t,e){for(let s=0;s<9;s++)switch(e[s]){case"T":if(-1===t[s])return!1;break;case"F":if(-1!==t[s])return!1;break;case"0":if(0!==t[s])return!1;break;case"1":if(1!==t[s])return!1;break;case"2":if(2!==t[s])return!1}return!0}function zt(t,e,s){const n=e.getGeometryID(t);for(let t=e.getFirstCluster();t!==r.n;t=e.getNextCluster(t)){if(0===(e.getClusterParentage(t)&n))continue;const i=e.getClusterHalfEdge(t);if(i===r.n){e.setClusterUserIndex(t,s,0);continue}let o=i,a=0;do{const t=o;0!==(e.getHalfEdgeParentage(t)&n)&&a++,o=e.getHalfEdgeNext(e.getHalfEdgeTwin(t))}while(o!==i);e.setClusterUserIndex(t,s,a)}}class Ut{nullFunc(){return(0,n.d)("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new Z,this.m_matrix=(0,a.d)(9,0),this.m_maxDim=(0,a.d)(9,0),this.m_performPredicates=(0,a.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_(t){this.m_scl=t;for(let t=0;t<9;t++)"*"!==this.m_scl[t]?(this.m_performPredicates[t]=!0,this.m_predicateCount++):this.m_performPredicates[t]=!1}setRemainingPredicatesToFalse_(){for(let t=0;t<9;t++)this.m_performPredicates[t]&&-2===this.m_matrix[t]&&(this.m_matrix[t]=-1,this.m_performPredicates[t]=!1)}isPredicateKnown_(t){return!(-2===this.m_matrix[t]||(-1===this.m_matrix[t]?(this.m_performPredicates[t]=!1,this.m_predicateCount--,0):"T"!==this.m_scl[t]&&"F"!==this.m_scl[t]&&this.m_matrix[t]<this.m_maxDim[t]||(this.m_performPredicates[t]=!1,this.m_predicateCount--,0)))}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(t,e){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(t,e,s,n,r){const o=-1!==e,a=-1!==n;if(o||a)if(("T"!==s&&"F"!==s&&o||"T"!==r&&"F"!==r&&a)&&0===t.calculateArea2D()){if(a&&(this.m_matrix[n]=-1),o){const s=i.Envelope2D.constructEmpty();t.queryEnvelope(s),this.m_matrix[e]=s.height()||s.width()?1:0}}else o&&(this.m_matrix[e]=2),a&&(this.m_matrix[n]=1)}areaAreaContainsPredicates_(t){this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(t){this.areaAreaContainsPredicates_(t),Ot(this.m_matrix)}areaLineDisjointPredicates_(t,e){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){const t=this.m_scl[6],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const t=(0,r.A)(e);this.m_matrix[7]=t?0:-1}this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(t,e){if(this.m_performPredicates[0]){const t=this.m_scl[0],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const t=(0,r.A)(e);this.m_matrix[1]=t?0:-1}this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(t){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(t){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(t,e){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){const e=this.m_scl[2],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const e=(0,r.A)(t);this.m_matrix[5]=e?0:-1}if(this.m_performPredicates[6]){const t=this.m_scl[6],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const t=(0,r.A)(e);this.m_matrix[7]=t?0:-1}}linePointDisjointPredicates_(t){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const e=this.m_scl[2],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const e=(0,r.A)(t);this.m_matrix[5]=e?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(t,e,s);const i=this.isPredicateKnown_(0);n&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(t,e,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(t,e,s,2);const i=this.isPredicateKnown_(2);n&&=i}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(t,s,3);const e=this.isPredicateKnown_(3);n&&=e}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(t,e,s);const i=this.isPredicateKnown_(4);n&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(t,e,s,5);const i=this.isPredicateKnown_(5);n&&=i}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(t,s,e,6);const i=this.isPredicateKnown_(6);n&&=i}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(t,s,e,7);const i=this.isPredicateKnown_(7);n&&=i}return n}areaLinePredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(t,e,s);const i=this.isPredicateKnown_(0);n&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const i=this.isPredicateKnown_(1);n&&=i}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(t,e,s);const i=this.isPredicateKnown_(2);n&&=i}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(t,e,s,this.m_clusterIndexB);const i=this.isPredicateKnown_(3);n&&=i}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const i=this.isPredicateKnown_(4);n&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(t,e,s);const i=this.isPredicateKnown_(5);n&&=i}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(t,e);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const i=this.isPredicateKnown_(7);n&&=i}return n}lineLinePredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const i=this.isPredicateKnown_(0);n&&=i}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const i=this.isPredicateKnown_(1);n&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(t,e,s,2);const i=this.isPredicateKnown_(2);n&&=i}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(t,s,e,this.m_clusterIndexB,this.m_clusterIndexA,3);const i=this.isPredicateKnown_(3);n&&=i}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const i=this.isPredicateKnown_(4);n&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(t,e,s,this.m_clusterIndexA,5);const i=this.isPredicateKnown_(5);n&&=i}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(t,s,e,6);const i=this.isPredicateKnown_(6);n&&=i}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(t,s,e,this.m_clusterIndexB,7);const i=this.isPredicateKnown_(7);n&&=i}return n}areaPointPredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(t,e,s);const i=this.isPredicateKnown_(3);n&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const i=this.isPredicateKnown_(0);n&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const i=this.isPredicateKnown_(2);n&&=i}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const i=this.isPredicateKnown_(3);n&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const i=this.isPredicateKnown_(5);n&&=i}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(t,e,s);const i=this.isPredicateKnown_(6);n&&=i}return n}pointPointPredicates_(t,e,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(t,e,s);const i=this.isPredicateKnown_(0);n&&=i}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(t,e,s,2);const i=this.isPredicateKnown_(2);n&&=i}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(t,s,e,6);const i=this.isPredicateKnown_(6);n&&=i}return n}interiorAreaInteriorArea_(t,e,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t);0!==(n&e)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));0!==(n&e)&&0!==(i&e)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(t,e,s,n){if(2===this.m_matrix[n])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t);0!==(i&e)&&0===(i&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);if(0===(n&e)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),i=this.m_topoGraph.getClusterParentage(n);if(0!==(i&e)&&0!==(i&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(t,e,s,n){if(1===this.m_matrix[n])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));0===(i&s)&&0===(r&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(t,e,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));0!==(n&e)&&0!==(i&e)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(t,e,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(i);if(0===(r&e)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(t)&e)){const t=this.m_topoGraph.getClusterUserIndex(i,n);if(0!==(r&s)&&t%2!=0)return void(this.m_matrix[1]=0)}}}interiorAreaExteriorLine_(t,e,s){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getHalfEdgeParentage(t)&e)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(t,e,s,n){if(1===this.m_matrix[3])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);if(0===(i&e)||0===(i&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(i);if(0!==(r&e)){const t=this.m_topoGraph.getClusterUserIndex(i,n);if(0!==(r&s)&&t%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(t,e,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(i);if(0!==(r&e)){const t=this.m_topoGraph.getClusterUserIndex(i,n);if(0!==(r&s)&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(t,e,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);0!==(n&e)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(t,e){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(t),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));0===(s&e)&&0===(n&e)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(t,e,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(i);if(0===(r&e)&&0===(this.m_topoGraph.getHalfEdgeFaceParentage(t)&e)){const t=this.m_topoGraph.getClusterUserIndex(i,n);if(0!==(r&s)&&t%2!=0)return void(this.m_matrix[7]=0)}}}interiorLineInteriorLine_(t,e,s,n,i){if(1===this.m_matrix[0])return;const r=this.m_topoGraph.getHalfEdgeParentage(t);if(0===(r&e)||0===(r&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(0!==(o&e)&&0!==(o&s)){const t=this.m_topoGraph.getClusterUserIndex(r,n),e=this.m_topoGraph.getClusterUserIndex(r,i);if(t%2==0&&e%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(t,e,s,n,i,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(t),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&e)&&0!==(a&s)){const t=this.m_topoGraph.getClusterUserIndex(o,n),e=this.m_topoGraph.getClusterUserIndex(o,i);if(t%2==0&&e%2!=0)return void(this.m_matrix[r]=0)}}}interiorLineExteriorLine_(t,e,s,n){if(1===this.m_matrix[n])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);0!==(i&e)&&0===(i&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(t,e,s,n,i){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(0!==(o&e)&&0!==(o&s)){const t=this.m_topoGraph.getClusterUserIndex(r,n),e=this.m_topoGraph.getClusterUserIndex(r,i);if(t%2!=0&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(t,e,s,n,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const e=this.m_topoGraph.getHalfEdgeTo(t);if(0===(this.m_topoGraph.getClusterParentage(e)&s)&&this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[i]=0)}}interiorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[0]&&0===(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(0!==(this.m_topoGraph.getChainParentage(s)&e))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(t,e){2!==this.m_matrix[2]&&0!==(this.m_topoGraph.getClusterParentage(t)&e)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(t,e,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(t);0===(n&e)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(t,e){1!==this.m_matrix[5]&&0!==(this.m_topoGraph.getClusterParentage(t)&e)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[6]&&0===(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(0===(this.m_topoGraph.getChainParentage(s)&e))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(t,e,s,n){if(0===this.m_matrix[0])return;const i=this.m_topoGraph.getClusterParentage(t);0===(i&e)||0===(i&s)||this.m_topoGraph.getClusterUserIndex(t,n)%2!=0||(this.m_matrix[0]=0)}interiorLineExteriorPoint_(t,e,s,n){if(1!==this.m_matrix[2])if(-1===this.m_topoGraph.getClusterHalfEdge(t)){if(0!==this.m_matrix[2]&&0===(this.m_topoGraph.getClusterParentage(t)&s))return void(this.m_matrix[2]=0)}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(t,e,s,n){if(0===this.m_matrix[3])return;const i=this.m_topoGraph.getClusterParentage(t);0===(i&e)||0===(i&s)||this.m_topoGraph.getClusterUserIndex(t,n)%2==0||(this.m_matrix[3]=0)}boundaryLineExteriorPoint_(t,e,s,n){if(0===this.m_matrix[5])return;const i=this.m_topoGraph.getClusterParentage(t);0===(i&e)||0!==(i&s)||this.m_topoGraph.getClusterUserIndex(t,n)%2==0||(this.m_matrix[5]=0)}exteriorLineInteriorPoint_(t,e,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(t);0!==(n&e)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(t,e,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(t);0===(n&e)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(t,e,s,n){if(0===this.m_matrix[n])return;const i=this.m_topoGraph.getClusterParentage(t);0===(i&e)||0!==(i&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(t,e){let s=!1;const n=this.m_topoGraph.getGeometryID(t),i=this.m_topoGraph.getGeometryID(e);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let t=this.m_topoGraph.getFirstCluster();t!==r.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===r.n){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(t,n,i),s))break;continue}let o=e;do{let t=o;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(t,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(t,n,i),s)break;this.m_topoGraph.setHalfEdgeUserIndex(t,this.m_visitedIndex,1),t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==o&&!s);if(s)break;o=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(o!==e);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(t,e){let s=!1;const n=this.m_topoGraph.getGeometryID(t),i=this.m_topoGraph.getGeometryID(e);for(let t=this.m_topoGraph.getFirstCluster();t!==r.n&&(s=this.m_predicatesCluster(t,n,i),!s);t=this.m_topoGraph.getNextCluster(t));s||this.setRemainingPredicatesToFalse_()}setEditShape_(t,e){this.m_topoGraph.setEditShape(t,e)}setEditShapeCrackAndCluster_(t,e,s){let i=0;if(t.hasCurves()){const n=new us,r=t.getEnvelope2D(s),o=hs(e.total(),r);i=ls(o,0),rs(t,o,e.total(),0,n,null,s),n.clearStitcher(t)}gs(t,e.add(i),s,!1,!1),t.filterClosePoints(0,!0,!0,!1,r.n);for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e))t.getGeometryType(e)===n.G.enumPolygon&&qt(t,e,-1,!1,r.n,s);this.setEditShape_(t,s)}}function Ot(t){const e=t[1],s=t[2],n=t[5];t[1]=t[3],t[2]=t[6],t[5]=t[7],t[3]=e,t[6]=s,t[7]=n}function Wt(t,e,s){const a=t.getGeometryType();if((0,n.f)(a)){const e=new r.P({vd:t.getDescription()});return e.addSegment(t,!0),e}if(a===n.G.enumEnvelope){const s=t,n=i.Envelope2D.constructEmpty();if(t.queryEnvelope(n),n.height()<=e&&n.width()<=e){const e=new o.P({vd:t.getDescription()});return s.getCenter(e),e}if(n.height()<=e||n.width()<=e){const e=new r.P({vd:t.getDescription()}),n=new o.P;return s.queryCornerByVal(0,n),e.startPathPoint(n),s.queryCornerByVal(2,n),e.lineToPoint(n),e}const a=new r.a({vd:t.getDescription()});return a.addEnvelope(s,!1),a}return t}function jt(t){return`${t[0]}${t[3]}${t[6]}${t[1]}${t[4]}${t[7]}${t[2]}${t[5]}${t[8]}`}class Zt{nullFunc(){return(0,n.d)("should not be called"),!1}constructor(t,e,s,r=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=i.Envelope2D.constructEmpty(),this.m_envInter=i.Envelope2D.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const a=t.getAccelerators();let h=null;null!=a&&(h=r?a.getQuadTreeForPaths():a.getQuadTree());const m=e.getAccelerators();let l=null;if(null!=m&&(l=r?m.getQuadTreeForPaths():m.getQuadTree()),null===h&&null===l&&!r){const r=t.getPointCount(),a=e.getPointCount();if(r>10&&a>10){const m=i.Envelope2D.constructEmpty(),u=i.Envelope2D.constructEmpty(),c=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(m),e.queryLooseEnvelope(u),m.inflateCoords(s,s),u.inflateCoords(s,s),c.setCoords({env2D:m}),c.intersect(u),r>=a?h=(0,n.h)(t.getGeometryType())?(0,o.t)(t,c):(0,o.u)(t,c):l=(0,n.h)(e.getGeometryType())?(0,o.t)(e,c):(0,o.u)(e,c)}}this.construct_(t,h,e,l,s,r)}next(){if(this.m_bQuadTree){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}return!!this.m_intersector&&this.m_intersector.next()}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):(0,n.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,n.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,n.p)(""),this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_query:this.m_bSwapElements?this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB()):this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA())}getBlueEnvelope(){return this.m_bPaths||(0,n.p)(""),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(t,e,s,r,a,h){const m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(m),s.queryLooseEnvelope(l),m.inflateCoords(a,a),l.inflateCoords(a,a),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(l),this.m_multiVertexImplA=t,this.m_multiVertexImplB=s;const u=t.getGeometryType(),c=s.getGeometryType();this.m_bPaths=h,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=n.G.enumUnknown,this.m_bQuadTree=!1,null!==e&&(this.m_bDone=!1,this.m_tolerance=a,this.m_quadTree=e,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,(0,n.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!==r&&(this.m_bDone=!1,this.m_tolerance=a,this.m_quadTree=r,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,(0,n.h)(u)?(this.m_queryType=u,this.m_function=this.nextPath_,h?this.m_pathIndex=t.getPathCount():this.m_segIter=t.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=t.getPointCount())),this.m_bQuadTree||(h&&(0,n.h)(u)&&(0,n.h)(c)?this.m_intersector=(0,o.y)(t,s,a):(0,n.h)(u)&&(0,n.h)(c)?(this.m_intersector=(0,o.v)(t,s,a),this.m_bSwapElements=!1):(0,n.h)(u)&&!(0,n.h)(c)?(this.m_intersector=(0,o.w)(t,s,a),this.m_bSwapElements=!1):!(0,n.h)(u)&&(0,n.h)(c)?(this.m_intersector=(0,o.w)(s,t,a),this.m_bSwapElements=!0):(this.m_intersector=(0,o.x)(t,s,a),this.m_bSwapElements=!1))}nextPath_(){return this.m_bPaths?-1===--this.m_pathIndex?(this.m_bDone=!0,!1):(this.m_bSwapElements?this.m_multiVertexImplB.queryPathEnvelope(this.m_pathIndex,this.m_query):this.m_multiVertexImplA.queryPathEnvelope(this.m_pathIndex,this.m_query),this.m_qtIter.resetIterator(this.m_query,this.m_tolerance),this.m_function=this.iterate_,!0):this.m_segIter.nextPath()?(this.m_function=this.nextSegment_,!0):(this.m_bDone=!0,!1)}nextSegment_(){if(!this.m_segIter.hasNextSegment())return this.m_function=this.nextPath_,!0;const t=this.m_segIter.nextSegment(),e=new i.Envelope2D;return t.queryLooseEnvelope(e),!e.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(t,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const t=new a.P;if(this.m_bSwapElements){const e=this.m_multiVertexImplB.getXY(this.m_pointIndex);t.setCoordsPoint2D(e)}else{const e=this.m_multiVertexImplA.getXY(this.m_pointIndex);t.setCoordsPoint2D(e)}return!this.m_envInter.contains(t)||(this.m_qtIter.resetIterator(i.Envelope2D.construct(t.x,t.y,t.x,t.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&((0,n.h)(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Qt(t){return 2===t?1:1===t?2:128===t?64:64===t?128:t}function Kt(t,e,s){let n;if(t instanceof mo||null===t){const r=i.Envelope2D.constructEmpty();r.setCoords({env2D:e}),r.mergeEnvelope2D(s),n=(0,o.a)(t,r,!1)}else n=t;return n}function $t(t,e,s,h,m){if(t.isEmpty()||e.isEmpty())return 4===h;(0,n.c)(t),(0,n.c)(e);let u=t.getGeometryType(),c=e.getGeometryType();if(u===n.G.enumEnvelope){if(c===n.G.enumEnvelope)return function(t,e,s,n){if(t.isEmpty()||e.isEmpty())return 4===n;const r=i.Envelope2D.constructEmpty();t.queryEnvelope(r);const o=i.Envelope2D.constructEmpty();e.queryEnvelope(o);const a=Kt(s,r,o);switch(n){case 4:return te(r,o,a);case 2:return Te(o,r,a,!1);case 128:return Te(o,r,a,!0);case 1:return Te(r,o,a,!1);case 64:return Te(r,o,a,!0);case 3:return we(r,o,a);case 8:return function(t,e,s){if(t.height()<=s||t.width()<=s||e.height()<=s||e.width()<=s)return!1;const n=new i.Envelope2D;return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.intersect(e),!(!n.isEmpty()&&n.height()>s&&n.width()>s||(n.setCoords({env2D:t}),n.inflateCoords(s,s),n.intersect(e),n.isEmpty()))}(r,o,a);case 32:return function(t,e,s){if(t.height()<=s||t.width()<=s||e.height()<=s||e.width()<=s)return!1;if(Ge(t,e,s))return!1;if(Ge(e,t,s))return!1;const n=new i.Envelope2D;return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.intersect(e),!n.isEmpty()&&(n.height()>s||n.width()>s)}(r,o,a);case 16:return!1}return!1}(t,e,s,h);if(c===n.G.enumPoint)return Jt(e,t,s,Qt(h))}else if(u===n.G.enumPoint){if(c===n.G.enumEnvelope)return Jt(t,e,s,h);if(c===n.G.enumPoint)return function(t,e,s,n){if(t.isEmpty()||e.isEmpty())return 4===n;const r=t.getXY(),h=e.getXY();let m;if(s instanceof mo||null===s){const t=i.Envelope2D.constructEmpty();t.setCoords({pt:r}),t.merge(h),m=(0,o.a)(s,t,!1)}else m=s;switch(n){case 4:return function(t,e,s){return a.P.sqrDistance(t,e)>s*s}(r,h,m);case 2:case 128:return De(h,r,m);case 1:case 64:return De(r,h,m);case 3:return Ie(r,h,m)}return!1}(t,e,s,h)}const g=i.Envelope2D.constructEmpty();t.queryEnvelope(g);const d=i.Envelope2D.constructEmpty();e.queryEnvelope(d);const _=Kt(s,g,d);if(te(g,d,_))return 4===h;let p=!1,f=null,x=null,P=null,y=null;switch((0,n.f)(u)?(f=new r.P({vd:t.getDescription()}),f.addSegment(t,!0),P=f,u=n.G.enumPolyline):P=t,(0,n.f)(c)?(x=new r.P({vd:e.getDescription()}),x.addSegment(e,!0),y=x,c=n.G.enumPolyline):y=e,u!==n.G.enumEnvelope&&c!==n.G.enumEnvelope?(P.getDimension()<y.getDimension()||u===n.G.enumPoint&&c===n.G.enumMultiPoint)&&(h=Qt(h)):u!==n.G.enumPolygon&&c!==n.G.enumEnvelope&&(h=Qt(h)),u){case n.G.enumPolygon:switch(c){case n.G.enumPolygon:p=function(t,e,s,n,i){switch(n){case 4:return function(t,e,s){return ee(t,e,0,!0),1===Ne(t,e,s,!0)}(t,e,s);case 2:return ge(e,t,s,i);case 128:return de(e,t,s);case 1:return ge(t,e,s,i);case 64:return de(t,e,s);case 3:return ce(t,e,s,i);case 8:return function(t,e,s){return ee(t,e),ze(t,e,s,null)}(t,e,s);case 32:return function(t,e,s,n){return ee(t,e),Ue(t,e,s,n)}(t,e,s,i)}return!1}(P,y,_,h,m);break;case n.G.enumPolyline:p=ne(P,y,_,h,m);break;case n.G.enumPoint:p=ie(P,y,_,h);break;case n.G.enumMultiPoint:p=re(P,y,_,h);break;case n.G.enumEnvelope:p=oe(P,y,_,h,m)}break;case n.G.enumPolyline:switch(c){case n.G.enumPolygon:p=ne(y,P,_,h,m);break;case n.G.enumPolyline:p=function(t,e,s,n,o){switch(n){case 4:return function(t,e,s){ee(t,e);const n=t.getImpl(),i=e.getImpl();return!new Zt(n,i,s,!0).next()||!Re(t,e,s)}(t,e,s);case 2:return Pe(e,t,s,o);case 128:return ye(e,t,s,o);case 1:return Pe(t,e,s,o);case 64:return ye(t,e,s,o);case 3:return function(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!we(r,o,s)&&(ee(t,e),!!Fe(t,e,s)||(t.hasNonLinearSegments()||e.hasNonLinearSegments()?Ft(t,e,s,"**F**FFF*",n,!1):Ve(t,e,s,!1)))}(t,e,s,o);case 8:return function(t,e,s,n){ee(t,e);const o=[],a=ke(t,e,s,o);if(-2===a){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty(),a=i.Envelope2D.constructEmpty();let h,m;if(t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:r}),a.intersect(o),t.getPointCount()>10){if(h=(0,l.c)(t,a,s,0,n),h.isEmpty())return!1}else h=t;if(e.getPointCount()>10){if(m=(0,l.c)(e,a,s,0,n),m.isEmpty())return!1}else m=e;return Ft(h,m,s,"F********",n,!1)}if(0!==a)return!1;const h=new r.M;for(let t=0;t<o.length;t+=2){const e=o[t],s=o[t+1];h.addXY(e,s)}const m=t.getBoundary(),u=e.getBoundary();return m.addPoints(u,0,u.getPointCount()),!m.isEmpty()&&Ce(m,h,s)}(t,e,s,o);case 32:return function(t,e,s,n){ee(t,e);const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o);const a=Me(r,o,s),h=Me(o,r,s),m=t.hasNonLinearSegments(),u=e.hasNonLinearSegments(),c=ke(t,e,s,null);if(-1===c)return!1;if(1===c){if(a&&h)return!0;if(!m&&!u)return a&&!h?!Ye(e,t,s,!1):h&&!a?!Ye(t,e,s,!1):!Ye(t,e,s,!1)&&!Ye(e,t,s,!1)}const g=i.Envelope2D.constructEmpty(),d=i.Envelope2D.constructEmpty(),_=i.Envelope2D.constructEmpty();let p,f;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:o}),d.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:g}),_.intersect(d);let x="";if(x+="1*",a){if(e.getPointCount()>10){if(f=(0,l.c)(e,_,s,0,n),f.isEmpty())return!1}else f=e;x+="****"}else f=e,x+="T***";if(h){if(t.getPointCount()>10){if(p=(0,l.c)(t,_,s,0,n),p.isEmpty())return!1}else p=t;x+="***"}else p=t,x+="T**";return Ft(p,f,s,x,n,!1)}(t,e,s,o);case 16:return function(t,e,s,n){ee(t,e);const o=[],a=ke(t,e,s,o);if(-2===a){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty(),a=i.Envelope2D.constructEmpty();let h,m;if(t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),a.setCoords({env2D:r}),a.intersect(o),t.getPointCount()>10){if(h=(0,l.c)(t,a,s,0,n),h.isEmpty())return!1}else h=t;if(e.getPointCount()>10){if(m=(0,l.c)(e,a,s,0,n),m.isEmpty())return!1}else m=e;return Ft(h,m,s,"0********",n,!1)}if(0!==a)return!1;const h=new r.M;for(let t=0;t<o.length;t+=2){const e=o[t],s=o[t+1];h.addXY(e,s)}const m=t.getBoundary(),u=e.getBoundary();return m.addPoints(u,0,u.getPointCount()),!!m.isEmpty()||!Ce(m,h,s)}(t,e,s,o)}return!1}(P,y,_,h,m);break;case n.G.enumPoint:p=ae(P,y,_,h);break;case n.G.enumMultiPoint:p=he(P,y,_,h);break;case n.G.enumEnvelope:p=me(P,y,_,h,m)}break;case n.G.enumPoint:switch(c){case n.G.enumPolygon:p=ie(y,P,_,h);break;case n.G.enumPolyline:p=ae(y,P,_,h);break;case n.G.enumMultiPoint:p=le(y,P,_,h)}break;case n.G.enumMultiPoint:switch(c){case n.G.enumPolygon:p=re(y,P,_,h);break;case n.G.enumPolyline:p=he(y,P,_,h);break;case n.G.enumMultiPoint:p=function(t,e,s,n){switch(n){case 4:return function(t,e,s){const n=t,i=e,r=new Zt(n,i,s,!1),o=s*s,h=new a.P,m=new a.P;for(;r.next();){const t=r.getRedElement(),e=r.getBlueElement();if(n.queryXY(t,h),i.queryXY(e,m),a.P.sqrDistance(h,m)<=o)return!1}return!0}(t,e,s);case 2:case 128:return Ce(e,t,s);case 1:case 64:return Ce(t,e,s);case 3:return function(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!!we(n,r,s)&&(!!function(t,e,s){if(t.getPointCount()!==e.getPointCount())return!1;const n=new a.P,i=new a.P;let r=!0;const o=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,n),e.queryXY(s,i),a.P.sqrDistance(n,i)>o){r=!1;break}return!!r}(t,e,s)||Xe(t,e,s,!1,!0,!1))}(t,e,s);case 32:return function(t,e,s){return Xe(t,e,s,!1,!1,!0)}(t,e,s)}return!1}(P,y,_,h);break;case n.G.enumPoint:p=le(P,y,_,h);break;case n.G.enumEnvelope:p=ue(P,y,_,h)}break;case n.G.enumEnvelope:switch(c){case n.G.enumPolygon:p=oe(y,P,_,h,m);break;case n.G.enumPolyline:p=me(y,P,_,h,m);break;case n.G.enumMultiPoint:p=ue(y,P,_,h)}}return p}function Jt(t,e,s,n,r){if(t.isEmpty()||e.isEmpty())return 4===n;const a=t.getXY(),h=i.Envelope2D.constructEmpty();e.queryEnvelope(h);const m=function(t,e,s){let n;if(t instanceof mo||null===t){const r=i.Envelope2D.constructEmpty();r.setCoords({pt:e}),r.mergeEnvelope2D(s),n=(0,o.a)(t,r,!1)}else n=t;return n}(s,a,h);switch(n){case 4:return se(a,h,m);case 2:case 128:return function(t,e,s){if(e.height()<=s||e.width()<=s)return!1;const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.containsExclusive(t)}(a,h,m);case 1:case 64:return!1;case 3:return function(t,e,s){const n=new i.Envelope2D;return n.setCoords({pt:t}),we(n,e,s)}(a,h,m);case 8:return function(t,e,s){if(e.height()<=s||e.width()<=s)return!1;const n=new i.Envelope2D,r=new i.Envelope2D;return n.setCoords({env2D:e}),n.inflateCoords(s,s),!!n.contains(t)&&(r.setCoords({env2D:e}),r.inflateCoords(-s,-s),!r.containsExclusive(t))}(a,h,m)}return!1}function te(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),!t.isIntersecting(n)}function ee(t,e,s,i=!1){const r=t.getGeometryType(),o=e.getGeometryType();if((0,n.i)(r)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();(0,n.g)(null===t)}}if((0,n.i)(o)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();(0,n.g)(null===e)}}return 0}function se(t,e,s,n){const r=i.Envelope2D.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(s,s),!r.contains(t)}function ne(t,e,s,n,h){switch(n){case 4:return function(t,e,s){return ee(t,e,0,!0),1===Ne(t,e,s,!0)}(t,e,s);case 1:return function(t,e,s,n){const a=i.Envelope2D.constructEmpty(),h=i.Envelope2D.constructEmpty();return t.queryEnvelope(a),e.queryEnvelope(h),!!Ge(a,h,s)&&(ee(t,e),function(t,e,s,n){const a=[!1],h=Ae(t,e,s,a);if(a[0])return h;const m=i.Envelope2D.constructEmpty();let u;if(e.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),t.getPointCount()>10){if(u=(0,l.c)(t,m,s,0,n),u.isEmpty())return!1}else u=t;return function(t,e,s,n){const a=new Ut;a.resetMatrix_(),a.setPredicates_("T*****F**"),a.setAreaLinePredicates_();const h=i.Envelope2D.constructEmpty(),m=i.Envelope2D.constructEmpty();t.queryEnvelope(h),e.queryEnvelope(m);let l=!1;if(te(h,m,s)&&(a.areaLineDisjointPredicates_(t,e),l=!0),l||ee(t,e),l)return Ht(a.m_matrix,a.m_scl);const u=new r.E,c=u.addGeometry(t),g=u.addGeometry(e);return a.setEditShapeCrackAndCluster_(u,new o.C(s,0),n),0!==u.getPointCount(c)&&(a.computeMatrixTopoGraphHalfEdges_(c,g),a.m_topoGraph.removeShape(),Ht(a.m_matrix,a.m_scl))}(u,e,s,n)}(t,e,s,n))}(t,e,s,h);case 64:return function(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!!Ge(n,r,s)&&(ee(t,e),2===Ne(t,e,s,!1))}(t,e,s);case 8:return _e(t,e,s,h);case 16:return function(t,e,s){return ee(t,e),function(t,e,s,n){const r=t.getImpl(),o=e.getImpl(),h=r.querySegmentIterator(),m=o.querySegmentIterator(),u=(0,a.d)(2,Number.NaN),c=(0,a.d)(2,Number.NaN),g=new Zt(r,o,s);let d=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();h.resetToVertex(t,-1),m.resetToVertex(e,-1);const n=h.nextSegment(),i=m.nextSegment();let r=0;if(Ze(n,i)?!d&&i.isIntersecting(n,s)&&(d=!0):r=i.intersect(n,null,c,u,s),2===r)d=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!0;d=!0}}if(!d)return!1;const _=i.Envelope2D.constructEmpty(),p=i.Envelope2D.constructEmpty(),f=i.Envelope2D.constructEmpty(),x=i.Envelope2D.constructEmpty(),P=i.Envelope2D.constructEmpty();if(t.queryEnvelope(_),e.queryEnvelope(p),Me(p,_,s)){let i,r;if(f.setCoords({env2D:_}),f.inflateCoords(1e3*s,1e3*s),x.setCoords({env2D:p}),x.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:f}),P.intersect(x),t.getPointCount()>10){if(i=(0,l.c)(t,P,s,0,n),i.isEmpty())return!1}else i=t;if(e.getPointCount()>10){if(r=(0,l.c)(e,P,s,0,n),r.isEmpty())return!1}else r=e;return Ft(i,r,s,"T********",n,!1)}return Ft(t,e,s,"T*****T**",n,!1)}(t,e,s,null)}(t,e,s)}return!1}function ie(t,e,s,n,i){switch(n){case 4:return function(t,e,s){return 0===$e(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return function(t,e,s){return 1===Je(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return function(t,e,s){return 2===Je(t,e,s)}(t,e.getXY(),s)}(t,e,s)}return!1}function re(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return ee(t,e),1===function(t,e,s){const n=i.Envelope2D.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new a.P,h=t.getImpl(),m=new r.a;let l=t,u=!1,c=!1,g=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,o),n.contains(o)){const t=Je(l,o,s);if(1===t)return c=!0,4;if(2===t)return 4;g=!0}else g=!0;u||(!wt(t,e.getPointCount()-1)||null!==h.getAccelerators()&&null!=h.getAccelerators().getQuadTree()?l=t:(t.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),u=!0)}return c?g?4:2:1}(t,e,s)}(t,e,s);case 1:return pe(t,e,s,!1);case 64:return pe(t,e,s,!0);case 8:return function(t,e,s){ee(t,e);const n=i.Envelope2D.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new a.P;let h=!1;const m=t.getImpl(),l=new r.a;let u=t,c=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,o),n.contains(o)){const t=Je(u,o,s);if(2===t)h=!0;else if(1===t)return!1}c||(!wt(t,e.getPointCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?u=t:(t.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),u=l),c=!0)}return!!h}(t,e,s);case 16:return function(t,e,s){ee(t,e);const n=new i.Envelope2D,o=new i.Envelope2D,h=new i.Envelope2D;t.queryEnvelope(n),e.queryEnvelope(h),o.setCoords({env2D:n}),o.inflateCoords(s,s);let m=!1,l=!1;const u=new a.P,c=t.getImpl(),g=new r.a;let d=t,_=!1;for(let n=0;n<e.getPointCount();n++){if(e.queryXY(n,u),o.contains(u)){const t=Je(d,u,s);0===t?l=!0:1===t&&(m=!0)}else l=!0;if(m&&l)return!0;_||(!wt(t,e.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?d=t:(t.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),d=g),_=!0)}return!1}(t,e,s)}return!1}function oe(t,e,s,n,o){if(function(t,e,s){ee(t,e);const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!Ge(r,n,s)&&0===Je(t,r.getLowerLeft(),0)&&!r.contains(t.getXY(0))&&!He(t,r,s)}(t,e,s))return 4===n;if(4===n)return!1;switch(n){case 2:return fe(t,e,s,!1);case 128:return fe(t,e,s,!0);case 1:return xe(t,e,s,!1,o);case 64:return xe(t,e,s,!0,o);case 3:return function(t,e,s,n){const o=new i.Envelope2D,a=new i.Envelope2D;if(t.queryEnvelope(o),e.queryEnvelope(a),!we(o,a,s))return!1;const h=new r.a;return h.addEnvelope(e,!1),ce(t,h,s,n)}(t,e,s,o);case 8:return function(t,e,s,n){ee(t,e);const o=new i.Envelope2D,a=new i.Envelope2D;if(t.queryEnvelope(o),e.queryEnvelope(a),Ge(a,o,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new r.a;return h.addEnvelope(e,!1),ze(t,h,s,n)}(t,e,s,o);case 32:return function(t,e,s,n){ee(t,e);const o=new i.Envelope2D,a=new i.Envelope2D;if(t.queryEnvelope(o),e.queryEnvelope(a),Ge(a,o,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new r.a;return h.addEnvelope(e,!1),Ue(t,h,s,n)}(t,e,s,o);case 16:return!1}return!1}function ae(t,e,s,n,i){switch(n){case 4:return function(t,e,s){return ee(t,e),!Be(t,e.getXY(),s)}(t,e,s);case 1:case 64:return function(t,e,s){return ee(t,e),function(t,e,s){return Be(t,e,s)&&!je(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return ee(t,e),je(t,e.getXY(),s)}(t,e,s)}return!1}function he(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return ee(t,e),!Le(t,e,s,!1)}(t,e,s);case 1:case 64:return function(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),!Ge(n,r,s))return!1;ee(t,e);const o=Le(t,e,s,!0);if(!o)return o;const a=t.getBoundary();return a.isEmpty()?o:!Ce(a,e,s)}(t,e,s);case 8:return function(t,e,s){ee(t,e);const n=t.getImpl(),i=e.getImpl(),o=new r.M,a=new Zt(n,i,s,!1),h=n.querySegmentIterator();let m=!1;for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();h.resetToVertex(t,-1);const n=h.nextSegment(),r=i.getXY(e);n.isIntersectingPoint(r,s)&&(m=!0,o.addPoint2D(r))}if(!m)return!1;const l=t.getBoundary();return!l.isEmpty()&&Ce(l,o,s)}(t,e,s);case 16:return function(t,e,s){ee(t,e);const n=t.getImpl(),i=e.getImpl(),o=i.getPointCount(),h=(0,a.d)(o,!1),m=new Zt(n,i,s,!1),l=n.querySegmentIterator();let u=!1;for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const n=l.nextSegment(),r=i.getXY(e);n.isIntersectingPoint(r,s)&&(u=!0,h[e]=!0)}if(!u)return!1;let c=!1;for(let t=0;t<o;t++)if(!h[t]){c=!0;break}if(!c)return!1;const g=t.getBoundary();if(g.isEmpty())return!0;const d=new r.M;for(let t=0;t<o;t++)h[t]&&d.addPoint2D(i.getXY(t));return!Ce(g,d,s)}(t,e,s)}return!1}function me(t,e,s,o,h){if(function(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();t.queryEnvelope(n),e.queryEnvelope(r);const o=function(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),n.containsEnvelope(e)?1073741824:n.isIntersecting(e)?t.isIntersecting(e)?t.xmin<e.xmin&&e.xmax<t.xmax?e.ymin<t.ymin&&e.ymax>t.ymax?0:1073741824:t.ymin<e.ymin&&e.ymax<t.ymax?e.xmin<t.xmin&&e.xmax>t.xmax?0:1073741824:0:0:4}(r,n,s);return 0===o?!He(t,r,s):4===o}(t,e,s))return 4===o;if(4===o)return!1;switch(o){case 2:return Ee(t,e,s,!1);case 128:return Ee(t,e,s,!0);case 1:case 64:case 32:return!1;case 3:return function(t,e,s){const n=new i.Envelope2D,r=new i.Envelope2D;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s&&r.width()>s)&&we(n,r,s)}(t,e,s);case 8:return function(t,e,s,o){const h=new i.Envelope2D,m=new i.Envelope2D;if(t.queryEnvelope(h),e.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;const l=new i.Envelope2D,u=new i.Envelope2D;if(l.setCoords({env2D:m}),u.setCoords({env2D:m}),l.inflateCoords(s,s),u.inflateCoords(-s,-s),u.containsEnvelope(h)||!h.isIntersecting(l))return!1;const c=t.getImpl().querySegmentIterator();c.stripAttributes();const g=t.getImpl().getAccelerators();let d=null,_=null;null!==g&&(d=g.getQuadTree(),null!==d&&(_=d.getIterator(m,s))),_||c.nextPath()||(0,n.d)("relational_operations");let p=!1,f=null;const x=new a.P,P=new a.P,y=t.hasNonLinearSegments();let E=!1;for(;;){if(null!==_){const t=_.next();if(-1===t)break;c.resetToVertex(d.getElement(t),-1),f=c.nextSegment()}else{for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;f=c.nextSegment()}if(y&&f.getGeometryType()!==n.G.enumLine){const t=new i.Envelope2D;if(f.queryEnvelope(t),u.containsEnvelope(t))return!1;if(l.isIntersecting(t)){E=!0;break}}else{x.assign(f.getStartXY()),P.assign(f.getEndXY());let t=u.clipLine(x,P);if(0!==t)return!1;p||(t=l.clipLine(x,P),0!==t&&(p=!0))}}if(!E)return p;const C=new r.a;return C.addEnvelope(m,!1),_e(C,t,s,o)}(t,e,s,h);case 16:return function(t,e,s){const o=new i.Envelope2D,h=new i.Envelope2D;if(t.queryEnvelope(o),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;const m=new i.Envelope2D;if(m.setCoords({env2D:h}),m.inflateCoords(s,s),m.containsEnvelope(o))return!1;const l=new i.Envelope2D;if(l.setCoords({env2D:h}),l.inflateCoords(-s,-s),!l.isIntersecting(o))return!1;const u=t.getImpl().querySegmentIterator();u.stripAttributes();const c=t.getImpl().getAccelerators();let g=null,d=null;if(null!==c&&(g=c.getQuadTree(),null!==g&&(d=g.getIterator(h,s))),!d){const t=u.nextPath();(0,n.g)(t)}let _=!1,p=null;const f=new a.P,x=new a.P;let P=null,y=null,E=null,C=null;for(t.hasNonLinearSegments()&&(P=new r.L,y=new r.L,E=new r.L,C=new r.L,l.querySide(0,P),l.querySide(1,y),l.querySide(2,E),l.querySide(3,C));;){if(null!==d){const t=d.next();if(-1===t)break;u.resetToVertex(g.getElement(t),-1),p=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;p=u.nextSegment()}if(p.getGeometryType()===n.G.enumLine){if(f.assign(p.getStartXY()),x.assign(p.getEndXY()),0!==l.clipLine(f,x)){_=!0;break}}else{if(P.isIntersecting(p,s)){_=!0;break}if(y.isIntersecting(p,s)){_=!0;break}if(E.isIntersecting(p,s)){_=!0;break}if(C.isIntersecting(p,s)){_=!0;break}}}return _&&!0}(t,e,s)}return!1}function le(t,e,s,n,i){switch(n){case 4:return Se(t,e,s);case 2:case 128:return function(t,e,s){return ve(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return!Se(t,e,s)}(t,e,s);case 3:return ve(t,e,s)}return!1}function ue(t,e,s,n,r){switch(n){case 4:return function(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),Ge(r,n,s))return!1;const o=i.Envelope2D.constructEmpty();o.setCoords({env2D:r}),o.inflateCoords(s,s);const h=new a.P;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,h),o.contains(h))return!1;return!0}(t,e,s);case 2:return be(t,e,s,!1);case 128:return be(t,e,s,!0);case 1:case 64:return!1;case 3:return function(t,e,s){const n=new i.Envelope2D,r=new i.Envelope2D;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s||r.width()>s)&&we(n,r,s)}(t,e,s);case 8:return function(t,e,s){const n=new i.Envelope2D,r=new i.Envelope2D,o=new i.Envelope2D;if(e.queryEnvelope(n),n.height()<=s||n.width()<=s)return!1;r.setCoords({env2D:n}),o.setCoords({env2D:n}),r.inflateCoords(s,s),o.inflateCoords(-s,-s);const h=new a.P;let m=!1;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,h),r.contains(h)){if(o.containsExclusive(h))return!1;m=!0}return m}(t,e,s);case 16:return function(t,e,s){const n=new i.Envelope2D,r=new i.Envelope2D;if(t.queryEnvelope(n),e.queryEnvelope(r),Ge(r,n,s))return!1;if(r.height()<=s||r.width()<=s)return!1;const o=new i.Envelope2D,h=new i.Envelope2D;o.setCoords({env2D:r}),o.inflateCoords(-s,-s),h.setCoords({env2D:r}),h.inflateCoords(s,s);const m=new a.P;let l=!1,u=!1;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,m),!l&&o.containsExclusive(m)&&(l=!0),u||h.contains(m)||(u=!0),l&&u)return!0;return!1}(t,e,s)}return!1}function ce(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();if(t.queryEnvelope(r),e.queryEnvelope(o),!we(r,o,s))return!1;if(ee(t,e),Fe(t,e,s))return!0;const a=t.calculateLength2D(),h=e.calculateLength2D(),m=Math.max(t.getPointCount(),e.getPointCount());return!(Math.abs(a-h)>4*m*s)&&(t.hasNonLinearSegments()||e.hasNonLinearSegments()?Ft(t,e,s,"**F**FFF*",n,!1):Ve(t,e,s,!0))}function ge(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ge(r,o,s)&&(ee(t,e),Oe(t,e,s,n))}function de(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ge(r,o,s)&&(ee(t,e),2===Ne(t,e,s,!1))}function _e(t,e,s,n){return ee(t,e),function(t,e,s,n){const r=t.getImpl(),o=e.getImpl(),h=r.querySegmentIterator(),m=o.querySegmentIterator(),u=(0,a.d)(2,Number.NaN),c=(0,a.d)(2,Number.NaN),g=new Zt(r,o,s);let d=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();h.resetToVertex(t,-1),m.resetToVertex(e,-1);const n=h.nextSegment(),i=m.nextSegment();let r=0;if(Ze(n,i)?!d&&i.isIntersecting(n,s)&&(d=!0):r=i.intersect(n,null,c,u,s),2===r)d=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!1;d=!0}}if(!d)return!1;const _=i.Envelope2D.constructEmpty(),p=i.Envelope2D.constructEmpty(),f=i.Envelope2D.constructEmpty();let x,P;if(t.queryEnvelope(_),e.queryEnvelope(p),_.inflateCoords(1e3*s,1e3*s),p.inflateCoords(1e3*s,1e3*s),f.setCoords({env2D:_}),f.intersect(p),t.getPointCount()>10){if(x=(0,l.c)(t,f,s,0,n),x.isEmpty())return!1}else x=t;if(e.getPointCount()>10){if(P=(0,l.c)(e,f,s,0,n),P.isEmpty())return!1}else P=e;return Ft(x,P,s,"F********",n,!1)}(t,e,s,n)}function pe(t,e,s,n,o){const h=i.Envelope2D.constructEmpty(),m=i.Envelope2D.constructEmpty();if(t.queryEnvelope(h),e.queryEnvelope(m),!Ge(h,m,s))return!1;ee(t,e);let l=!1;const u=new a.P,c=t.getImpl(),g=new r.a;let d=t,_=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,u),!h.contains(u))return!1;const r=Je(d,u,s);if(1===r)l=!0;else if(0===r)return!1;if(n&&2===r)return!1;_||(!wt(t,e.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?d=t:(t.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),d=g),_=!0)}return l}function fe(t,e,s,n,r){const o=i.Envelope2D.constructEmpty(),a=i.Envelope2D.constructEmpty();return t.queryEnvelope(o),e.queryEnvelope(a),n?qe(a,o,s):Ge(a,o,s)}function xe(t,e,s,n,o){const a=i.Envelope2D.constructEmpty(),h=i.Envelope2D.constructEmpty();if(t.queryEnvelope(a),e.queryEnvelope(h),!Ge(a,h,s))return!1;ee(t,e);const m=new r.a;return m.addEnvelope(e,!1),n?2===Ne(t,m,s,!1):Oe(t,m,s,o)}function Pe(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ge(r,o,s)&&(ee(t,e),t.hasNonLinearSegments()||e.hasNonLinearSegments()?Ft(t,e,s,"******FF*",n,!1):Ye(e,t,s,!1))}function ye(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ge(r,o,s)&&(ee(t,e),Ft(t,e,s,"T**FF*FF*",n,!1))}function Ee(t,e,s,o,a){const h=i.Envelope2D.constructEmpty(),m=i.Envelope2D.constructEmpty();if(t.queryEnvelope(h),e.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;if(o)return qe(m,h,s);if(!Ge(m,h,s))return!1;const l=i.Envelope2D.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-s,-s);const u=i.Envelope2D.constructEmpty();if(u.setCoords({env2D:m}),u.inflateCoords(s,s),l.containsEnvelope(h))return!0;const c=t.getImpl().querySegmentIterator();c.stripAttributes(),c.nextPath()||(0,n.d)("relational_operations");let g,d,_,p,f,x,P=!1;const y=t.hasNonLinearSegments();for(y&&(_=new r.L,p=new r.L,f=new r.L,x=new r.L,l.querySide(0,_),l.querySide(1,p),l.querySide(2,f),l.querySide(3,x));;){for(;!c.hasNextSegment()&&c.nextPath(););if(!c.hasNextSegment())break;const t=c.nextSegment();if(y&&t.getGeometryType()!==n.G.enumLine){if(t.isIntersecting(_,s)){P=!0;break}if(t.isIntersecting(p,s)){P=!0;break}if(t.isIntersecting(f,s)){P=!0;break}if(t.isIntersecting(x,s)){P=!0;break}}else if(g=t.getStartXY(),d=t.getEndXY(),0!==l.clipLine(g,d)){P=!0;break}}return P}function Ce(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ge(r,o,s)&&Xe(e,t,s,!0,!1,!1)}function ve(t,e,s,n){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),we(r,o,s)}function Se(t,e,s,n){return We(t,e.getXY(),s)}function be(t,e,s,n,r){const o=i.Envelope2D.constructEmpty(),h=i.Envelope2D.constructEmpty();if(t.queryEnvelope(o),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;if(n)return qe(h,o,s);if(!Ge(h,o,s))return!1;let m=!1;const l=i.Envelope2D.constructEmpty(),u=i.Envelope2D.constructEmpty();l.setCoords({env2D:h}),u.setCoords({env2D:h}),l.inflateCoords(-s,-s),u.inflateCoords(s,s);const c=new a.P;for(let e=0;e<t.getPointCount();e++){if(t.queryXY(e,c),!u.contains(c))return!1;l.containsExclusive(c)&&(m=!0)}return m}function Ie(t,e,s,n){return a.P.sqrDistance(t,e)<=s*s}function De(t,e,s,n){return Ie(t,e,s)}function we(t,e,s,n){return Ge(t,e,s)&&Ge(e,t,s)}function Te(t,e,s,n,r){if(t.height()<=s||t.width()<=s)return!1;if(n)return qe(t,e,s);if(!Ge(t,e,s))return!1;const o=i.Envelope2D.constructEmpty();return o.setCoords({env2D:t}),o.inflateCoords(-s,-s),o.intersect(e),!o.isEmpty()}function Ne(t,e,s,o,h){const m=new a.P,l=new a.P,u=i.Envelope2D.constructEmpty(),c=i.Envelope2D.constructEmpty(),g=t.getImpl(),d=e.getImpl(),_=d.getGeometryType(),p=new Zt(g,d,s,!0);if(!p.next())return 1;if(Re(t,e,s))return o?4:0;const f=new r.a;let x=t;const P=new r.a;let y=null;_===n.G.enumPolygon&&(y=e);const E=_===n.G.enumPolygon?(0,a.d)(g.getPathCount(),!1):[],C=(0,a.d)(d.getPathCount(),!1);let v=!1,S=!1,b=!1,I=!1,D=!1,w=!1;do{if(b&&D||I&&w)break;if(b&&I)break;const i=p.getRedElement(),r=p.getBlueElement();if(!C[r]&&(l.assign(e.getXY(e.getPathStart(r))),u.setCoords({env2D:p.getRedEnvelope()}),u.inflateCoords(s,s),u.contains(l))){if(0!==Je(x,l,0)){if(I=!0,o)return 4}else w=!0;C[r]=!0}if(_===n.G.enumPolygon&&!E[i]&&(m.assign(t.getXY(t.getPathStart(i))),c.setCoords({env2D:p.getBlueEnvelope()}),c.inflateCoords(s,s),c.contains(m))){if(0!==Je(y,m,0)){if(b=!0,o)return 4}else D=!0;E[i]=!0}if(v||(!wt(t,e.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?x=t:(t.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),v=!0),_===n.G.enumPolygon&&!S){const s=e;!wt(s,t.getPathCount()-1)||null!==d.getAccelerators()&&null!==d.getAccelerators().getQuadTree()?y=e:(s.copyTo(P),P.getImpl().buildQuadTreeAccelerator(1),y=P),S=!0}}while(p.next());if(!b&&!I)return 1;if(!D||!w){if(_===n.G.enumPolygon)for(let t=0,e=g.getPathCount();t<e;t++)if(!E[t]){D=!0;break}for(let t=0,e=d.getPathCount();t<e;t++)if(!C[t]){w=!0;break}}return b&&D||I&&w||b&&I?4:I?2:3}function Ae(t,e,s,o,a){o[0]=!1;const h=t.getImpl(),m=e.getImpl(),l=h.querySegmentIterator(),u=m.querySegmentIterator(),c=[0,0],g=[0,0],d=new Zt(h,m,s);let _=!1;for(;d.next();){const t=d.getRedElement(),e=d.getBlueElement();l.resetToVertex(t,-1),u.resetToVertex(e,-1);const n=l.nextSegment(),i=u.nextSegment();let r=0;if(Ze(n,i)?!_&&i.isIntersecting(n,s)&&(_=!0):r=i.intersect(n,null,g,c,s),0!==r&&(_=!0,1===r)){const t=c[0],e=g[0];if(t>0&&t<1&&e>0&&e<1)return o[0]=!0,!1}}if(!_){o[0]=!0;const a=i.Envelope2D.constructEmpty();t.queryEnvelope(a),a.inflateCoords(s,s);const l=new r.a;let u=t,c=!1;for(let s=0,r=e.getPathCount();s<r;s++)if(e.getPathSize(s)>0){const r=i.Envelope2D.constructEmpty();if(e.queryPathEnvelope(s,r),!a.isIntersecting(r))return!1;{const t=Dt(u,e.getXY(e.getPathStart(s)),0);if((0,n.g)(-1!==t),0===t)return!1}c||(!wt(t,e.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?u=t:(t.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),u=l),c=!0)}if(1===t.getPathCount()||e.getGeometryType()===n.G.enumPolyline)return!0;const g=e,d=i.Envelope2D.constructEmpty();g.queryEnvelope(d),d.inflateCoords(s,s);const _=new r.a;let p=g,f=!1;for(let e=0,s=t.getPathCount();e<s;e++)if(t.getPathSize(e)>0){const s=i.Envelope2D.constructEmpty();if(t.queryPathEnvelope(e,s),d.isIntersecting(s)){const s=Dt(p,t.getXY(t.getPathStart(e)),0);if((0,n.g)(-1!==s),1===s)return!1}f||(!wt(g,t.getPathCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?p=g:(g.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),p=_),f=!0)}return!0}return!1}function Ge(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),n.containsEnvelope(e)}function qe(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),t.containsExclusiveEnvelope(n)}function Me(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),!(n.contains(t.getLowerLeft())&&n.contains(t.getLowerRight())&&n.contains(t.getUpperLeft())&&n.contains(t.getUpperRight()))}function Fe(t,e,s,n){if(t.getPathCount()!==e.getPathCount()||t.getPointCount()!==e.getPointCount())return!1;if(t.hasNonLinearSegments()||e.hasNonLinearSegments())return t.equals(e);const i=new a.P,r=new a.P;let o=!0;const h=s*s;for(let s=0;s<t.getPathCount();s++){if(t.getPathEnd(s)!==e.getPathEnd(s)){o=!1;break}for(let n=t.getPathStart(s);n<e.getPathEnd(s);n++)if(t.queryXY(n,i),e.queryXY(n,r),a.P.sqrDistance(i,r)>h){o=!1;break}if(!o)break}return!!o}function Xe(t,e,s,n,i,r,o){const h=t.getImpl(),m=e.getImpl(),l=h.getPointCount(),u=m.getPointCount(),c=(0,a.d)(l,!1),g=i||r?(0,a.d)(u,!1):[],d=s*s,_=new Zt(h,m,s);for(;_.next();){const t=_.getRedElement(),e=_.getBlueElement(),s=h.getXY(t),n=m.getXY(e);a.P.sqrDistance(s,n)<=d&&(c[t]=!0,(i||r)&&(g[e]=!0))}let p=!1,f=!1;for(let t=0;t<l;t++){const e=c[t];if(p||=!e,f||=e,(i||n)&&p)return!1}if(n)return!0;let x=!1,P=!1;for(let t=0;t<u;t++){const e=g[t];if(x||=!e,P||=e,i&&x)return!1}return!!i||p&&f&&x&&P}function Ve(t,e,s,n){return Ye(t,e,s,n)&&Ye(e,t,s,n)}function Ye(t,e,s,r){if((0,n.o)(t),(0,n.o)(e),e.isEmpty())return!1;let h=!0;const m=(0,a.d)(2,Number.NaN),l=(0,a.d)(2,Number.NaN),u=[],c=new Ke;let g;const d=i.Envelope2D.constructEmpty(),_=i.Envelope2D.constructEmpty(),p=i.Envelope2D.constructEmpty();t.queryEnvelope(d),e.queryEnvelope(_),d.inflateCoords(s,s),_.inflateCoords(s,s),p.setCoords({env2D:d}),p.intersect(_);const f=t.getImpl().querySegmentIterator(),x=e.getImpl().querySegmentIterator(),P=e.getImpl().getAccelerators();let y=null,E=null,C=null,v=null;if(null!==P&&(y=P.getQuadTree(),E=P.getQuadTreeForPaths(),null!==E&&(v=E.getIteratorForQT())),null===y){const s=t.getPointCount(),n=e.getPointCount();s>10&&n>10&&(y=(0,o.t)(e.getImpl(),p))}for(null!==y&&(C=y.getIteratorForQT());f.nextPath();)for(;f.hasNextSegment();){let t=f.nextSegment();if(t.queryEnvelope(d),!d.isIntersecting(p))return h=!1,!1;if(null!==v&&(v.resetIterator(d,s),-1===v.next()))continue;let e=0,i=null;if(null!=C)C.resetIterator(t,s);else if(x.resetToFirstPath(),!x.nextPath())return h=!1,!1;do{if(e=0,null!==C){const n=C.next();if(-1===n)return h=!1,!1;x.resetToVertex(y.getElement(n),-1),i=x.nextSegment(),e=t.intersect(i,null,m,l,s)}else{for(;!x.hasNextSegment();)if(!x.nextPath())return h=!1,!1;i=x.nextSegment(),i.queryEnvelope(_),_.inflateCoords(s,s),d.isIntersecting(_)&&(e=t.intersect(i,null,m,l,s))}}while(2!==e||0!==m[0]||r&&!(l[0]<=l[1]));let a=Number.NaN,P=!1;do{let n=!1;if(1===m[1]){if(!f.hasNextSegment()){P=!0;break}t=f.nextSegment(),n=!0}if(1===l[1]&&l[0]<=l[1]){if(-1===a)break;if(a=1,!x.hasNextSegment())break;i=x.nextSegment(),n=!0}if(0===l[1]&&l[0]>l[1]){if(1===a)break;if(Number.isNaN(a)){if(!x.hasPreviousSegment())break;x.previousSegment(),a=-1}if(!x.hasPreviousSegment())break;i=x.previousSegment(),n=!0}if(!n)break;e=t.intersect(i,null,m,l,s)}while(2===e&&(!r||l[0]<=l[1]));if(P)continue;const E=t.calculateLength2D();t.queryEnvelope(d),u.length=0,c.m_overlapEvents.length=0;let S=!1,b=!1,I=0;const D=(0,o.a)(null,d,!0);for(null!==C?C.resetIterator(t,s):(x.resetToFirstPath(),x.nextPath()||(0,n.d)("relational_operations"));;){if(e=0,null!==C){const n=C.next();if(-1===n)break;x.resetToVertex(y.getElement(n),-1),i=x.nextSegment(),e=t.intersect(i,null,m,l,s)}else{for(;!x.hasNextSegment()&&x.nextPath(););if(!x.hasNextSegment())break;i=x.nextSegment(),i.queryEnvelope(_),_.inflateCoords(s,s),d.isIntersecting(_)&&(e=t.intersect(i,null,m,l,s))}if(2===e&&(!r||l[0]<=l[1])){const t=f.getStartPointIndex(),e=f.getPathIndex(),n=x.getStartPointIndex(),i=x.getPathIndex();if(g=Qe(t,e,m[0],m[1],n,i,l[0],l[1]),c.m_overlapEvents.push(g),u.push(u.length),!(S||g.m_scalarA0<I&&g.m_scalarA1<I))if(0===I&&E*(g.m_scalarA0-I)>s)S=!0;else if(0!==I&&E*(g.m_scalarA0-I)>D)S=!0;else if(I=g.m_scalarA1,E*(1-I)<=s||1===I){b=!0;break}}}if(!b){if(!S)return h=!1,!1;u.length>1&&u.sort((t,e)=>c.compareOverlapEvents(t,e)),I=0;for(let t=0;t<c.m_overlapEvents.length;t++)if(g=c.m_overlapEvents[u[t]],!(g.m_scalarA0<I&&g.m_scalarA1<I)){if(0===I&&E*(g.m_scalarA0-I)>s)return h=!1,!1;if(0!==I&&E*(g.m_scalarA0-I)>D)return h=!1,!1;if(I=g.m_scalarA1,E*(1-I)<=s||1===I)break}if(E*(1-I)>s)return h=!1,!1;u.length=0,c.m_overlapEvents.length=0}}return h}function Re(t,e,s){const n=t.getImpl(),i=e.getImpl(),r=n.querySegmentIterator(),o=i.querySegmentIterator(),a=new Zt(n,i,s);for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();r.resetToVertex(t,-1),o.resetToVertex(e,-1);const n=r.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function ke(t,e,s,n){const i=t.getImpl(),r=e.getImpl(),o=i.querySegmentIterator(),h=r.querySegmentIterator(),m=(0,a.d)(2,Number.NaN),l=new Zt(i,r,s);let u=!1,c=-1;for(;l.next();){const t=l.getRedElement(),e=l.getBlueElement();o.resetToVertex(t,-1),h.resetToVertex(e,-1);const i=o.nextSegment(),r=h.nextSegment();let g=0;if(Ze(i,r)){if(r.isIntersecting(i,s))return-2}else g=i.intersect(r,null,m,null,s);if(g)if(2===g){const t=i.calculateLength2D(),e=m[0];if(t*(m[1]-e)>s)return c=1,c;u=!0}else if(c=0,n){const t=m[0],e=new a.P;i.queryCoord2D(t,e),n.push(e.x),n.push(e.y)}}return u?-2:c}function Le(t,e,s,n){const i=t.getImpl(),r=e,o=r.getPointCount(),h=n?(0,a.d)(o,!1):[],m=new Zt(i,r,s,!1),l=i.querySegmentIterator();for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const i=l.nextSegment(),o=r.getXY(e);if(i.isIntersectingPoint(o,s)){if(!n)return!0;h[e]=!0}}if(!n)return!1;for(let t=0;t<o;t++)if(!h[t])return!1;return!0}function Be(t,e,s){const n=new a.P,r=s*s,o=t.querySegmentIterator(),h=t.getImpl().getAccelerators();if(null!==h){const t=h.getQuadTree();if(null!==t){const h=i.Envelope2D.constructEmpty();h.setCoords({pt:e});const m=t.getIterator(h,s);for(let s=m.next();-1!==s;s=m.next())if(o.resetToVertex(t.getElement(s),-1),o.hasNextSegment()){const t=o.nextSegment(),s=t.getClosestCoordinate(e,!1);if(t.queryCoord2D(s,n),a.P.sqrDistance(e,n)<=r)return!0}return!1}}const m=i.Envelope2D.constructEmpty();for(;o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment();if(t.queryEnvelope(m),m.inflateCoords(s,s),!m.contains(e))continue;const i=t.getClosestCoordinate(e,!1);if(t.queryCoord2D(i,n),a.P.sqrDistance(e,n)<=r)return!0}return!1}function He(t,e,s,o){const h=t.querySegmentIterator(),m=t.getImpl().getAccelerators(),l=t.hasNonLinearSegments();let u=null,c=null,g=null,d=null;if(null!==m){const t=m.getQuadTree();if(null!==t){const o=t.getIterator(e,s);l&&(u=new r.L,c=new r.L,g=new r.L,d=new r.L,e.querySide(0,u),e.querySide(1,c),e.querySide(2,g),e.querySide(3,d));const a=i.Envelope2D.constructEmpty();a.setCoords({env2D:e}),a.inflateCoords(s,s);for(let i=o.next();-1!==i;i=o.next())if(h.resetToVertex(t.getElement(i),-1),h.hasNextSegment()){const t=h.nextSegment();if(t.getGeometryType()===n.G.enumLine){const e=t.getStartXY(),s=t.getEndXY();if(a.clipLine(e,s))return!0;continue}if(e.contains(t.getStartXY())||e.contains(t.getEndXY()))return!0;if(t.isIntersecting(u,s))return!0;if(t.isIntersecting(c,s))return!0;if(t.isIntersecting(g,s))return!0;if(t.isIntersecting(d,s))return!0}return!1}}if(l){u=new r.L,c=new r.L,g=new r.L,d=new r.L,e.querySide(0,u),e.querySide(1,c),e.querySide(2,g),e.querySide(3,d);const n=t.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const t=n.nextSegment();if(e.contains(t.getStartXY())||e.contains(t.getEndXY()))return!0;if(t.isIntersecting(u,s))return!0;if(t.isIntersecting(c,s))return!0;if(t.isIntersecting(g,s))return!0;if(t.isIntersecting(d,s))return!0}}else{const n=i.Envelope2D.constructEmpty();n.setCoords({env2D:e}),n.inflateCoords(s,s);const r=t.getImpl(),o=r.getAttributeStreamRef(0),h=new a.P;for(let t=0,e=r.getPathCount();t<e;t++){let e=!0;const s=new a.P,i=new a.P,m=new a.P,l=r.getPathStart(t),u=new a.P;for(let a=l,c=r.getPathEnd(t);a<c;a++)if(e)o.queryPoint2D(2*a,s),u.assign(s),e=!1;else{if(o.queryPoint2D(2*a,h),i.setCoordsPoint2D(s),m.setCoordsPoint2D(h),n.clipLine(i,m))return!0;s.assign(h)}if(r.isClosedPath(t)&&!e&&(i.setCoordsPoint2D(s),m.setCoordsPoint2D(u),n.clipLine(i,m)))return!0}}return!1}function ze(t,e,s,n){const r=t.getImpl(),h=e.getImpl(),m=[0],u=(0,o.p)(r.getIsSimple(0,m))&&(0,o.p)(h.getIsSimple(0,m)),c=r.querySegmentIterator(),g=h.querySegmentIterator(),d=(0,a.d)(2,0),_=(0,a.d)(2,0),p=new Zt(r,h,s);let f=!1;for(;p.next();){const t=p.getRedElement(),e=p.getBlueElement();c.resetToVertex(t,-1),g.resetToVertex(e,-1);const n=c.nextSegment(),i=g.nextSegment();let r=0;if(Ze(n,i)){if(i.isIntersecting(n,s)){f=!0;break}}else r=i.intersect(n,null,_,d,s);if(2===r){const t=d[0],e=d[1],i=n.calculateLength2D();if(u&&(e-t)*i>s)return!1;f=!0}else if(r){const t=d[0],e=_[0];if(t>0&&t<1&&e>0&&e<1)return!1;f=!0}}if(!f)return!1;const x=i.Envelope2D.constructEmpty(),P=i.Envelope2D.constructEmpty(),y=i.Envelope2D.constructEmpty();let E,C;if(t.queryEnvelope(x),e.queryEnvelope(P),x.inflateCoords(1e3*s,1e3*s),P.inflateCoords(1e3*s,1e3*s),y.setCoords({env2D:x}),y.intersect(P),t.getPointCount()>10){if(E=(0,l.c)(t,y,s,0,n),E.isEmpty())return!1}else E=t;if(e.getPointCount()>10){if(C=(0,l.c)(e,y,s,0,n),C.isEmpty())return!1}else C=e;return Ft(E,C,s,"F********",n,!1)}function Ue(t,e,s,n){const r=t.getImpl(),h=e.getImpl(),m=[0],u=(0,o.p)(r.getIsSimple(0,m))&&(0,o.p)(h.getIsSimple(0,m)),c=i.Envelope2D.constructEmpty(),g=i.Envelope2D.constructEmpty(),d=i.Envelope2D.constructEmpty();t.queryEnvelope(c),e.queryEnvelope(g);let _=!1;const p=Me(c,g,s),f=Me(g,c,s),x=r.querySegmentIterator(),P=h.querySegmentIterator(),y=(0,a.d)(2,Number.NaN),E=(0,a.d)(2,Number.NaN),C=new Zt(r,h,s);for(;C.next();){const t=C.getRedElement(),e=C.getBlueElement();x.resetToVertex(t,-1),P.resetToVertex(e,-1);const n=x.nextSegment(),i=P.nextSegment();let r=0;if(Ze(n,i)){if(i.isIntersecting(n,s))break}else r=i.intersect(n,null,E,y,s);if(2===r){const t=y[0],e=y[1],i=n.calculateLength2D();if(u&&(e-t)*i>s&&(_=!0,p&&f))return!0}else if(r){const t=y[0],e=E[0];if(t>0&&t<1&&e>0&&e<1)return!0}}const v=i.Envelope2D.constructEmpty(),S=i.Envelope2D.constructEmpty();let b,I;v.setCoords({env2D:c}),v.inflateCoords(1e3*s,1e3*s),S.setCoords({env2D:g}),S.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:v}),d.intersect(S);let D="";if(D+=_?"**":"T*",p){if(e.getPointCount()>10){if(I=(0,l.c)(e,d,s,0,n),I.isEmpty())return!1}else I=e;D+="****"}else I=e,D+="T***";if(f){if(t.getPointCount()>10){if(b=(0,l.c)(t,d,s,0,n),b.isEmpty())return!1}else b=t;D+="***"}else b=t,D+="T**";return Ft(b,I,s,D,n,!1)}function Oe(t,e,s,n){const a=[!1],h=Ae(t,e,s,a);if(a[0])return h;const m=i.Envelope2D.constructEmpty();let u;if(e.queryEnvelope(m),m.inflateCoords(1e3*s,1e3*s),t.getPointCount()>10){if(u=(0,l.c)(t,m,s,0,n),u.isEmpty())return!1}else u=t;return function(t,e,s,n){const a=new Ut;a.resetMatrix_(),a.setPredicates_("T*****F**"),a.setAreaAreaPredicates_();const h=i.Envelope2D.constructEmpty(),m=i.Envelope2D.constructEmpty();t.queryEnvelope(h),e.queryEnvelope(m);let l=!1;if(te(h,m,s)&&(a.areaAreaDisjointPredicates_(t,e),l=!0),l||ee(t,e),l)return Ht(a.m_matrix,a.m_scl);let u=new r.E,c=u.addGeometry(t),g=u.addGeometry(e),d=null,_=0;if(t.hasNonLinearSegments()||e.hasNonLinearSegments()){d=new us;const t=hs(s,u.getEnvelope2D(n));_=ls(t,0),rs(u,t,s,0,d,null,n)}gs(u,new o.C(s,0).add(_),n,!1,!1);const p=u.getGeometry(g).getBoundary();if(u.filterClosePoints(0,!0,!0,!1,r.n),qt(u,c,-1,!1,r.n,n),0===u.getPointCount(c))return!1;qt(u,g,-1,!1,r.n,n),a.setEditShape_(u,n);const f=0===u.getPointCount(g);if(!f){a.computeMatrixTopoGraphHalfEdges_(c,g),a.m_topoGraph.removeShape();const t=Ht(a.m_matrix,a.m_scl);if(!t)return t}const x=u.getGeometry(c);return u=new r.E,c=u.addGeometry(x),g=u.addGeometry(p),a.setEditShape_(u,n),a.m_predicateCount=0,a.resetMatrix_(),a.setPredicates_(f?"T*****F**":"******F**"),a.setAreaLinePredicates_(),a.computeMatrixTopoGraphHalfEdges_(c,g),a.m_topoGraph.removeShape(),Ht(a.m_matrix,a.m_scl)}(u,e,s,n)}function We(t,e,s,n){const i=new a.P,r=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,i),a.P.sqrDistance(i,e)<=r)return!1;return!0}function je(t,e,s){const n=t.getBoundary();return!n.isEmpty()&&!We(n,e,s)}function Ze(t,e){return t.getGeometryType()!==n.G.enumLine||e.getGeometryType()!==n.G.enumLine}function Qe(t,e,s,n,i,r,o,a){return{m_ivertexA:t,m_ipathA:e,m_scalarA0:s,m_scalarA1:n,m_ivertexB:i,m_ipathB:r,m_scalarB0:o,m_scalarB1:a}}class Ke{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(t,e){const s=this.m_overlapEvents[t],n=this.m_overlapEvents[e];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 $e(t,e,s){const n=function(t,e,s){return e.isEmpty()?0:Dt(t,e.getXY(),s)}(t,e,s);return n?1===n?1:2:0}function Je(t,e,s){const n=Dt(t,e,s);return n?1===n?1:2:0}function ts(t,e,s,r,o){if(t.getGeometryType()===n.G.enumPolygon)!function(t,e,s,n,i){for(let r=0;r<s;r++)i[r]=Je(t,e[r],n)}(t,e,s,r,o);else if(t.getGeometryType()===n.G.enumEnvelope){const n=i.Envelope2D.constructEmpty();t.queryEnvelope(n),function(t,e,s,n,i){if(t.isEmpty()){for(let t=0;t<s;t++)i[t]=0;return}const r=t.clone();r.inflateCoords(.5*-n,.5*-n);const o=t.clone();o.inflateCoords(.5*n,.5*n);for(let t=0;t<s;t++)r.contains(e[t])?i[t]=1:o.contains(e[t])?i[t]=2:i[t]=0}(n,e,s,r,o)}else(0,n.p)("")}function es(t,e,s,r,a){const h=t.getGeometryType();h===n.G.enumPolyline?function(t,e,s,r,a){const h=t.getImpl(),m=h.getAccelerators();let l=null;m&&(l=m.getRasterizedGeometry());let u=s;for(let t=0;t<s;t++)a[t]=1,l&&(0,n.g)(0);if(u){if(m){let t=null;null!==m&&null!==m.getQuadTree()&&(t=m.getQuadTree());const n=h.getPointCount();if(null===t&&n>20&&n*s>4*n+Math.log(n)*s&&(t=(0,o.t)(h)),t){let n=null;const o=h.querySegmentIterator(),m=new i.Envelope2D;for(let i=0;i<s&&u;i++)if(1===a[i]){m.setCoords(e[i]),null===n?n=t.getIterator(m,r):n.resetIterator(m,r);let s=-1;for(let h=n.next();-1!==h;h=n.next()){if(o.resetToVertex(t.getElement(h),s),s=o.getPathIndex(),o.nextSegment().isIntersectingPoint(e[i],r)){a[i]=2,u--;break}a[i]=0}}return}}const t=h.querySegmentIterator();for(;t.nextPath()&&u;)for(;t.hasNextSegment()&&u;){const n=t.nextSegment();for(let t=0;t<s&&u;t++)1===a[t]&&n.isIntersectingPoint(e[t],r)&&(a[t]=2,u--)}}for(let t=0;t<s;t++)1===a[t]&&(a[t]=0)}(t,e,s,r,a):(0,n.f)(h)?(0,n.g)(0):(0,n.p)("")}function ss(){return Number.isNaN(this.radius.value())}function ns(t,e,s,n){return{pt:t.clone(),t:e,err:s,checkCount:n}}class is{constructor(t,e,s,n,i){this.m_left=t,this.m_tracker=i,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 a.P,ptEnd:new a.P,center:new r.X,radius:new a.X,fcenter:new r.$,fradius2:new a.M,maxError:Number.NaN,isLine:ss}}closeToCircularArc(t,e,s,n,i,o){if(this.m_circleCheckCounter++,o.maxError=0,!is.checkSweepAngle(t,e))return!1;if(o.ptStart.setCoordsPoint2D(s),o.ptEnd.setCoordsPoint2D(i),t.isCircular()){const e=t;return o.fradius2=a.M.constructDouble(e.getSemiMajorAxis()).mulDouble(e.getSemiMajorAxis()),o.radius.set(e.getSemiMajorAxis()),o.fcenter.assignPoint2D(e.getCenter()),o.center.set(e.getCenter()),!0}const h=o.ptEnd.sub(o.ptStart).clone();if(h.leftPerpendicularThis(),h.normalize(),Math.abs(h.dotProduct(n.sub(o.ptStart)))<=this.m_eps)return!!this.confirmIsLine(o,h)&&(o.radius.set(Number.NaN),o.center.setCoords(0,0),!0);{const s=o.ptEnd.sub(o.ptStart),i=n.sub(o.ptStart),r=s.crossProduct(i);if(0===r)return!1;const a=.5*s.sqrLength(),h=.5*i.sqrLength();let m=a*i.y-h*s.y;m/=r;let l=s.x*h-i.x*a;l/=r;const u=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*u>this.m_eps)return!1;const c=m+o.ptStart.x,g=l+o.ptStart.y;o.radius.set(u),o.center.setCoords(c,g);const d=this.maxCircleApproximationError(t,e,o);if(d>this.m_eps)return o.maxError=d,!1}const m=(new r.$).assignPoint2D(o.ptStart),l=(new r.$).assignPoint2D(o.ptEnd).sub(m),u=(new r.$).assignPoint2D(n).sub(m),c=l.crossProduct(u);if(c.isZero())return!1;const g=l.sqrLength().mulDouble(.5),d=u.sqrLength().mulDouble(.5),_=g.mul(u.y).sub(d.mul(l.y)),p=l.x.mul(d).sub(u.x.mul(g)),f=_.mul(_).add(p.mul(p)),x=c.clone();x.invertThis(),o.fradius2=f.mul(x).mul(x),o.fcenter.setCoords(_.mul(x).add(m.x),p.mul(x).add(m.y)),o.center.setWithEps(o.fcenter.asPoint2D()),o.radius.setWithEps(Math.sqrt(o.fradius2.toDouble()));const P=r.X.constructPoint2D(o.ptStart).subE(o.center),y=r.X.constructPoint2D(o.ptEnd).subE(o.center);if(!P.dotProduct(y).gt(a.U))return!1;const E=this.maxCircleApproximationError(t,e,o);return o.maxError=E,E<=this.m_eps}static checkSweepAngle(t,e){if(t.getGeometryType()===n.G.enumEllipticArc){const s=t,n=(0,r.a0)(s,e.vmin),i=(0,r.a0)(s,e.vmax);return!(Math.abs(i-n)>.5*a.o)}return!0}confirmIsLine(t,e){const s=t.ptEnd.sub(t.ptStart);return!(Math.abs(e.dotProduct(s.mul(.25)))>this.m_eps||Math.abs(e.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(t,e,s){const i=[.25,.75],r=[.1,.25,.75,.9];let o,h;t.getGeometryType()===n.G.enumEllipticArc?(o=i,h=i.length):(o=r,h=r.length);let m=0;for(let n=0;n<h;++n){const i=new a.P;t.queryCoord2D((0,a.q)(e.vmin,e.vmax,o[n]),i);const r=i.sub(s.center.value()).length(),h=Math.abs(r-s.radius.value());h>m&&(m=h)}return m}approximateWithCirclesImpl(t,e){let s=1;e&&e.push(0);const n=(0,a.d)(9,Number.NaN);let i;t?i=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,i=2);const r=[],o=[],h=new a.P(0,0);for(let t=1;t<i;t++){const i=new a.E(n[t-1],n[t]);for(this.m_bReversedLeft=!is.goodOrientation(this.m_left,i),this.m_bReversedLeft?(r.push(ns(h,i.vmin,0,0)),r.push(ns(h,i.vmax,0,0))):(r.push(ns(h,i.vmax,0,0)),r.push(ns(h,i.vmin,0,0))),r[0].pt=this.m_left.getCoord2D(r[0].t),r[1].pt=this.m_left.getCoord2D(r[1].t);r.length>1;){this.progress_();const t=r.at(-1);let n=t.checkCount,i=t.err;const h=t.pt.clone(),m=t.t,l=r[r.length-2].t,u=.5*(m+l),c=this.m_left.getCoord2D(u);if(i<=this.m_eps||n>=5){const t=new a.E;if(t.setCoords(m,l),this.closeToCircularArc(this.m_left,t,h,c,r[r.length-2].pt,this.m_leftArc)){e&&(this.m_bReversedLeft?o.push(m):e.push(l)),s++,r.pop();continue}n=0,i=this.m_leftArc.maxError}t.t=u,t.pt.setCoordsPoint2D(c),i*=.125,n++,t.err=i,t.checkCount=n,r.push(ns(h,m,i,n))}this.m_bReversedLeft&&e&&(e.length=e.length+o.length,(0,a.b)(e,o.reverse(),e.length-o.length,0,o.length),o.length=0),r.length=0}return s}approximateWithCirclesImplPolyline(t){const e=new r.P,s=[];if(!this.approximateWithCirclesImpl(!0,s))return e;let n=0;const i=this.m_left.getStartXY();e.startPath(i);for(let o=1;o<s.length;++o)if(t)e.lineTo(this.m_left.getCoord2D(s[o]));else{const t=new a.P;this.m_left.queryCoord2D(s[o],t);const h=new a.P;this.m_left.queryCoord2D(.5*(s[o]+n),h);const m=new r.l;m.constructCircularArcThreePoint(i,t,h),e.addSegment(m,!1),i.assign(t),n=s[o]}return e}static goodOrientation(t,e){const s=t.getCoord2D(e.vmin),n=t.getCoord2D(e.vmax);return s.compare(n)<0}progress_(t=!1){}}function rs(t,e,s,n,i,r,o){(function(t,e,s,n,i,r){t.hasCurves()?(t.setCurveStitcherPointer(n),n.m_impl=new cs(r,!1,null),n.m_impl.buildMonotonicCurveParentage(t,e,s,i)):n.m_impl=null})(t,e,s,i,r,o),_s(t,s,o)}function os(t,e,s,i){if(!(0,n.h)(t.getGeometryType()))return t;const a=t.getImpl();if(!a.hasNonLinearSegments())return t;const h=t.createInstance();h.getGeometryType()===n.G.enumPolygon&&h.setFillRule(t.getFillRule()),new r.E;const m=new o.P,l=new r.S,u=[],c=[],g=[],d=t.getDescription().getAttributeCount()>1,_=a.querySegmentIterator();for(;_.nextPath();){let t=!0;for(;_.hasNextSegment();){const i=_.isClosingSegment(),o=_.nextSegment();if(!o.isCurve()){h.addSegment(o,t,i),t=!1;continue}let a,p=!1;const f=!0,x=!0;switch(o.getGeometryType()){case n.G.enumEllipticArc:case n.G.enumRationalBezier2:a=(0,r.F)(o,e,s,f,x,c,g,u),p=!0;break;default:a=(0,r.B)(o,e,s,!0,f,c,u)}const P=p?2:3;c[1].isNAN()?(l.createLine(),l.get().construct(c[0],c[P])):p?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c,g)):(l.createCubicBezier(),l.get().constructPoints(c)),d&&t&&(o.queryCoord(u[0],m),l.get().setStart(m)),d&&(o.queryCoord(u[1],m),l.get().setEnd(m)),h.addSegment(l.get(),t,i&&1===a),t=!1;for(let t=1,e=a,s=P;t<e;++t,s+=P)c[s+1].isNAN()?(l.createLine(),l.get().construct(c[s],c[s+P])):p?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(c.slice(s),g.slice(s))):(l.createCubicBezier(),l.get().constructPoints(c.slice(s))),d&&(o.queryCoord(u[t+1],m),l.get().setEnd(m)),h.addSegment(l.get(),!1,i&&t+1===e)}}return h}function as(t){if(!t.hasSegmentParentage())return;const e=t.queryVertexIteratorOnSelection();for(let s=e.next();s!==r.n;s=e.next())if(!t.getSegmentParentageBreakVertex(s)){t.getPathFromVertex(s);const e=t.getPrevVertex(s),n=e!==r.n?t.getSegmentParentage(e):-1,i=t.getSegmentParentage(s);-1!==i&&-1!==n&&i!==n&&t.setSegmentParentageBreakVertex(s,!0)}}function hs(t,e){return e||(e=i.Envelope2D.constructEmpty()),function(t,e){let s=e.isEmpty()?t:(0,o.c)(null,e,!0).total();return s>t&&(s=t),.125*s}(t,e)}function ms(t,e){return.125*t}function ls(t,e){return 3*t+3*e}class us{constructor(){this.m_impl=null}stitchCurves(t,e,s,n){this.m_impl&&(this.m_impl.stitchCurves(t,e,s),n&&this.clearStitcher(t))}clearStitcher(t){this.m_impl&&(this.m_impl.clearStitcher(t),this.m_impl=null)}getOriginalVertexIndex(t,e){return this.m_impl.getOriginalVertexIndex(t,e)}getOriginalSegmentTypeInfo(t){return this.m_impl.getOriginalSegmentTypeInfo(t)}}class cs{constructor(t,e,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=t,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=e,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(t,e,s,i){const a=!1;if(!t.hasCurves())return;(0,n.g)(!t.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=t.createUserIndex()),this.m_tolerance=s;const h=new o.P,m=new r.S,l=[],u=[],c=[];for(let i=t.getFirstGeometry();i!==r.n;i=t.getNextGeometry(i))for(let o=t.getFirstPath(i);o!==r.n;o=t.getNextPath(o)){let i=t.getPathSize(o),d=t.getFirstVertex(o),_=0,p=-1;for(let f=0;f<i;f++){let x=t.getNextVertex(d);if(!t.querySegment(d,m,!0,!1)){d=x;continue}if(0===_){p=t.getVertexIndex(d);const e=cs.regularizeCurve(t,m.get(),d,s);if(e>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new g.NonSimpleResult(13,p,-1)),_=e,i=t.getPathSize(o),x=t.getNextVertex(d);const s=t.querySegment(d,m,!0,!1);(0,n.g)(s)}}else _--;const P=t.getVertexIndex(d);let y;-1!==this.m_originalVertexIndex&&t.setUserIndex(d,this.m_originalVertexIndex,p),t.setSegmentToIndex(P,null);let E=!1;switch(m.get().getGeometryType()){case n.G.enumEllipticArc:case n.G.enumRationalBezier2:y=(0,r.F)(m.get(),e,s,a,!0,u,c,l),E=!0;break;default:{const t=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();y=(0,r.B)(m.get(),e,s,t,a,u,l)}}const C=this.m_originalPlanarSegments.length;if(t.setSegmentParentageAndBreak(d,C,!0),!u[1].isNAN()){let e=null;e=E?new r.Q({points:u,weights:c}):new r.J({cp:u}),e.snapControlPoints(s*s),t.setSegmentToIndex(P,e)}const v=E?2:3;for(let e=1,n=y,i=v;e<n;++e,i+=v){m.get().queryCoord(l[e],h);const n=t.insertVertex(o,x,h);if(-1!==this.m_originalVertexIndex&&t.setUserIndex(n,this.m_originalVertexIndex,p),!u[i+1].isNAN())if(E){const e=new r.Q({points:u.slice(i),weights:c.slice(i)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(n),e)}else{const e=new r.J({cp:u.slice(i)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(n),e)}t.setSegmentParentageAndBreak(n,C,!1)}y>1&&(f+=y-1,i=t.getPathSize(o)),this.m_originalPlanarSegments.push(m.releaseSegment()),d=x}}}buildLinearSegmentParentage(t,e,s,i,a){if(this.m_type=0,this.m_densificationDeviation=e,this.m_maxSegmentsPerCurve=i,!t.hasCurves())return;(0,n.g)(!t.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=t.createUserIndex());const h=new o.P,m=new r.S,l=new r.D(0,e,0,this.m_progressTracker,!1,i),u=[];for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e))for(let i=t.getFirstPath(e);i!==r.n;i=t.getNextPath(i)){let e=t.getPathSize(i),r=t.getFirstVertex(i);for(let o=0;o<e;o++){let o=t.getNextVertex(r);if(!t.querySegment(r,m,!0,!1)){r=o;continue}if(cs.regularizeCurve(t,m.get(),r,s)>=0){e=t.getPathSize(i),o=t.getNextVertex(r);const s=t.querySegment(r,m,!0,!1);(0,n.g)(s)}const a=t.getVertexIndex(r);-1!==this.m_originalVertexIndex&&t.setUserIndex(r,this.m_originalVertexIndex,a),t.setSegmentToIndex(a,null),u.length=0,l.densifySegment(m.get(),u),this.progress_();const c=this.m_originalPlanarSegments.length;t.setSegmentParentageAndBreak(r,c,!0);for(let e=1,s=u.length-1;e<s;++e){m.get().queryCoord(u[e],h);const s=t.insertVertex(i,o,h);t.setSegmentParentageAndBreak(s,c,!1),-1!==this.m_originalVertexIndex&&t.setUserIndex(s,this.m_originalVertexIndex,a)}this.m_originalPlanarSegments.push(m.releaseSegment()),r=o}}t.clearSegments()}stitchCurves(t,e,s){cs.st_stitchCurvesImpl(this,t,e,s,!1)}clearStitcher(t){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(t.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),t.deleteSegmentParentage()}static st_verifyParentage(t){cs.st_stitchCurvesImpl(null,t,r.n,0,!0)}getOriginalVertexIndex(t,e){return-1!==this.m_originalVertexIndex&&e!==r.n?t.getUserIndex(e,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(t){if(-1!==t){const e=this.m_originalPlanarSegments[t];switch(e.getGeometryType()){case n.G.enumEllipticArc:return 0===e.projectionBehavior()?0:1;case n.G.enumBezier:return 2;case n.G.enumBezier2:return 3;case n.G.enumLine:return-1;case n.G.enumRationalBezier2:return 4;default:(0,n.t)("")}}return-1}progress_(t=!1){this.m_progressCounter++}processSpanSmartTe_(t,e,s,i,o,h,m){if(e===s&&0===i)return(0,n.g)(t.getNextVertex(e)===r.n),t.setSegmentToIndex(t.getVertexIndex(e),null),void t.setSegmentParentageAndBreak(e,-1);const l=t.getNextVertex(e),u=t.getXY(e),c=t.getXY(s);let g,d=0;{let e=2,r=u;for(let n=l;n!==s;n=t.getNextVertex(n)){const s=t.getXY(n);d+=a.P.distance(s,r),r=s,e++}d+=a.P.distance(c,r),(0,n.g)(e===i)}if(null===o)return t.setSegmentToIndex(t.getVertexIndex(e),null),void t.removeVertices(l,s);const _=m;let p=o.getClosestCoordinate(u,!1),f=o.getClosestCoordinate(c,!1);const x=o.calculateLength2D();let P=o.tToLength(p),y=o.tToLength(f);const E=Math.abs(P)>10*_&&Math.abs(P-x)>10*_,C=Math.abs(y)>10*_&&Math.abs(y-x)>10*_,v=t=>{const e=t.calculateLength2D();return Math.abs(e-d)>Math.max(.2*d,4*_)?null:t};let S=o.isClosed();if(!S){const t=a.P.distance(o.getStartXY(),o.getEndXY());t<=_&&x>5*t&&(S=!0)}if(S){let r,h,m=new a.P;if(2===i)m=a.P.lerp(u,c,.5),r=o.getClosestCoordinate(m,!1),h=o.tToLength(r);else{let s=t.getNextNthVertex(e,(i-1)/2);m=t.getXY(s),r=o.getClosestCoordinate(m,!1),h=o.tToLength(r);let n=Math.abs(h)>10*_&&Math.abs(h-x)>10*_;if(!n&&(i-1>=4&&(s=t.getNextNthVertex(e,(i-1)/4),r=o.getClosestCoordinate(m,!1),h=o.tToLength(r),n=Math.abs(h)>10*_&&Math.abs(h-x)>10*_),!n))return}let l=!1;const d=P===y;if(d){const s=0;let n=2,r=4;i-1<=4&&(n=s+1,r=s+2);const h=u,m=t.getXY(t.getNextNthVertex(e,n)),c=t.getXY(t.getNextNthVertex(e,r));l=-a.P.orientationNonRobust(h,m,c)*(0,a.e)(o.calculateArea2DHelper())>0}else C?E?l=h>P:h<y?(P=0,p=0):(P=x,p=1):h>P?(y=x,f=1):(y=0,f=0);if(d)g=o.clone(),g.dropAllAttributes(),l||g.reverse(),(0,n.g)(u.equals(c));else{let t=!1;p>f&&(t=!0,[p,f]=[f,p]),g=o.cut(p,f,!0),g.getDescription().getAttributeCount(),t&&g.reverse()}g.setCoordsForIntersector(u,c,!1),g=v(g),g&&(this.removeSpanBetween(t,e,s),t.setSegmentToIndex(t.getVertexIndex(e),g))}else if(E||C){if((!E||!C)&&a.P.distance(o.getStartXY(),o.getEndXY())<10*_){const n=[(0,a.l)(p,f),(0,a.l)(p,f),(0,a.l)(p,f)];E?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],r=[0,0,0];let h=Number.MAX_VALUE,m=0;for(let t=0;t<3;t++){let e=!1;if(n[t].first>n[t].second){e=!0;const s=n[t].first;n[t].first=n[t].second,n[t].second=s}i[t]=o.cut(n[t].first,n[t].second,!0),i[t].dropAllAttributes(),e&&i[t].reverse(),i[t].setCoordsForIntersector(u,c,!1),r[t]=i[t].calculateLength2D();const s=Math.abs(d-r[t]);s<h&&(h=s,m=t)}return g=i[m],g=v(g),void(g&&(this.removeSpanBetween(t,e,s),t.setSegmentToIndex(t.getVertexIndex(e),g)))}let n=!1;p>f&&(n=!0,[p,f]=[f,p]),g=o.cut(p,f,!0),g.dropAllAttributes(),n&&g.reverse(),g.setCoordsForIntersector(u,c,!1),g=v(g),g&&(this.removeSpanBetween(t,e,s),t.setSegmentToIndex(t.getVertexIndex(e),g))}else{if(g=o.clone(),g.dropAllAttributes(),P>y&&g.reverse(),d<Math.max(.75*x,x-this.m_densificationDeviation*(i-1))){const t=p>f?f:p,e=g.tToLength(t)+d;let s=g.lengthToT(e);s=(0,a.s)(s,t,1),g=g.cut(t,s,!0)}g.setCoordsForIntersector(u,c,!1),g=v(g),g&&(this.removeSpanBetween(t,e,s),t.setSegmentToIndex(t.getVertexIndex(e),g))}}processSpanCurves_(t,e,s,i,o,a,h){if(e===s&&0===i)return(0,n.g)(t.getNextVertex(e)===r.n),t.setSegmentToIndex(t.getVertexIndex(e),null),void t.setSegmentParentageAndBreak(e,-1);const m=t.getNextVertex(e);{let e=2;for(let n=m;n!==s;n=t.getNextVertex(n))e++;(0,n.g)(e===i)}if(null===o)return t.setSegmentToIndex(t.getVertexIndex(e),null),void t.removeVertices(m,s);const l=t.getXY(e),u=t.getXY(s);if(o.isClosed()){if(l.isEqualPoint2D(u)&&l.isEqualPoint2D(o.getStartXY())){let n;if(n=this.verifySegmentFitnessCurves(t,e,s,i,o,a,h)){const i=o.clone();return i.dropAllAttributes(),n<0&&i.reverse(),this.removeSpanBetween(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),i)}}}else if(l.isEqualPoint2D(o.getStartXY())){if(u.isEqualPoint2D(o.getEndXY())){const r=o.clone();r.dropAllAttributes();const m=this.verifySegmentFitnessCurves(t,e,s,i,r,a,h);if(m)return(0,n.g)(m>0),this.removeSpanBetween(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),r)}}else if(u.isEqualPoint2D(o.getStartXY())&&l.isEqualPoint2D(o.getEndXY())){const r=o.getReversed();r.dropAllAttributes();const m=this.verifySegmentFitnessCurves(t,e,s,i,r,a,h);if(m)return(0,n.g)(m>0),this.removeSpanBetween(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),r)}this.processSpanSplitSegmentCurves(t,e,s,i,o,a,h)}processSpan_(t,e,s,n,i,r,o){return 0===this.m_type?void this.processSpanSmartTe_(t,e,s,n,i,r,o):void this.processSpanCurves_(t,e,s,n,i,r,o)}processSpanSplitSegmentCurves(t,e,s,n,i,r,o){if(i.isLine())return;if(this.fitSegmentToSpanCurves(t,e,s,n,i,r,o))return;const h=o*o;let m=n,l=e;const u=t.getXY(e);let c=i.getClosestCoordinate(u,!1);const g=i.getCoord2D(c);let d=!1;const _=a.P.sqrDistance(u,g);if(_>h){const n=t.getNextVertex(e);if(this.approximateSpanSectionCurves(t,e,i,r,o),n===s)return;l=n,d=!0,m-=1}let p=s;const f=t.getXY(s);c=i.getClosestCoordinate(f,!1);const x=i.getCoord2D(c);let P=!1;const y=a.P.sqrDistance(f,x);if(y>h){const e=t.getPrevVertex(s);if(this.approximateSpanSectionCurves(t,e,i,r,o),e===l)return;p=e,P=!0,m-=1}if((d||P)&&this.fitSegmentToSpanCurves(t,l,p,m,i,r,o))return;let E=!1;if(!d&&_>0){const s=t.getNextVertex(e);if(this.approximateSpanSectionCurves(t,e,i,r,o),s===p)return;l=s,d=!0,E=!0,m-=1}if(!P&&y>0){const e=t.getPrevVertex(s);if(this.approximateSpanSectionCurves(t,e,i,r,o),e===l)return;p=e,P=!0,E=!0,m-=1}if(E&&this.fitSegmentToSpanCurves(t,l,p,m,i,r,o))return;let C=l;for(;;){const e=t.getNextVertex(C);if(this.approximateSpanSectionCurves(t,C,i,r,o),C=e,C===p)return}}fitSegmentToSpanCurves(t,e,s,n,i,o,h){const m=[];m.push(t.getXY(e));let l=e;const u=new r.S;for(;;){t.querySegment(l,u,!1,!0);const e=[.1,.25,.4,.5,.6,.75,.9,1];let i=0;for(const t of e)(2===n||1&i)&&m.push(u.get().getCoord2D(t)),i++;if(l=t.getNextVertex(l),l===s)break}const c=(()=>{let t=m[0].compare(m.at(-1));if(0===t){const e=new a.K(0);(function(t,e,s){if(s.reset(),e<3)return;const n=t[0].clone(),i=n.x,r=n.y,o=t[1].clone(),h=new a.P;for(let i=2;i<e;i++)h.assign(t[i]),s.pe((h.x-n.x)*(o.y-r)),n.assign(o),o.assign(h);s.pe((i-n.x)*(o.y-r))})(m,m.length,e),t=e.getResult()>=0?-1:1}return t>0})();c&&m.reverse();const g=i.clone();if(g.dropAllAttributes(),c&&g.reverse(),g.setSegmentFromCoordsForStitcher(m,m.length),c&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(t,e,s,n,g,o,h)){this.removeSpanBetween(t,e,s);const n=t.getVertexIndex(e);return t.setSegmentToIndex(n,g),!0}return!1}approximateSpanSectionCurves(t,e,s,i,h){const m=new r.S;if(!t.querySegment(e,m,!0,!1))return;const l=s.getGeometryType();if(l!==m.get().getGeometryType()){if(l===n.G.enumEllipticArc){if(m.get().getGeometryType()!==n.G.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];!function(t,e,s,n,i){const o=(0,r.U)(e),a=Math.max(4*o,s);new is(e,null,a,Number.NaN,i).approximateWithCirclesImpl(!1,n)}(0,m.get(),h,s,this.m_progressTracker);const n=t.getNextVertex(e),i=t.getPathFromVertex(e),l=new o.P;let u=e;for(let e=1,o=s.length;e<o;e++){const o=s[e],h=m.get().getCoord2D(s[e-1]),c=m.get().getCoord2D((0,a.q)(s[e-1],o,.5));m.get().queryCoord(o,l);const g=l.getXY(),d=new r.l;d.constructCircularArcThreePoint(h,g,c);let _=r.n;o<1&&(_=t.insertVertex(i,n,l)),t.setSegmentToIndex(t.getVertexIndex(u),d),u=_}return}{const s=(0,a.m)(a.P,3);m.get().queryControlPoints(s);const n=[0,0,0];m.get().queryWeights(n);const i=(0,r.K)(n),o=new r.l;return(0,r.N)(s,i*i,null,!1,o),void t.setSegmentToIndex(t.getVertexIndex(e),o)}}(0,n.d)("approximate_span_section_")}}verifySegmentFitnessCurves(t,e,s,n,i,o,h){const m=t.getXY(e),l=t.getXY(s);if(!m.isEqualPoint2D(i.getStartXY())||!l.isEqualPoint2D(i.getEndXY()))return 0;let u=0;if(i.isClosed()){const t=i.getCoord2D(.1).sub(m);u=i.getCoord2D(.7).sub(m).crossProduct(t)>=0?1:-1}const c=(0,a.d)(r.O.s_maxMonotonicPartParams,Number.NaN);let g=i.getMonotonicPartParams(c.length,c);g--;const d=new r.L,_=[1,.5,.75,.25];let p=0,f=e;const x=m.clone();for(;;){const e=t.getNextVertex(f);let n=t.getSegment(f);null===n&&(t.queryLineConnector(f,d,!0),n=d);for(let t=e===s?1:0;t<_.length;t++){const e=n.getCoord2D(_[t]);if(!i.isCloserThanDistance(e,a.E.unit(),h))return 0}if(g>1)for(let t=1;t<g;){const e=i.getCoord2D(c[t]);n.isCloserThanDistance(e,a.E.unit(),h)?(c[g-1]=(0,a.c)(c[t],c[t]=c[g-1]),g--):t++}if(u){const t=n.getCoord2D(.25);p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t),t.assign(n.getCoord2D(.75)),p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t)}if(f=e,f===s)return g>1?0:u?p<0?-u:u:1}}removeSpanBetween(t,e,s){t.setSegmentToIndex(t.getVertexIndex(e),null);const n=t.getNextVertex(e);n!==s&&t.removeVertices(n,s)}static st_stitchCurvesImpl(t,e,s,i,o){if(!e.hasSegmentParentage())return;as(e);let a=s===r.n?e.getFirstGeometry():s;for(;a!==r.n;)if((0,n.l)(e.getGeometryType(a))){for(let s=e.getFirstPath(a);s!==r.n;s=e.getNextPath(s)){let a=e.getPathSize(s);const h=e.isClosedPath(s);h&&(a+=1);let m=e.getFirstVertex(s);const l=e.getSegmentParentage(m);if(h){if(-1!==l&&!e.getSegmentParentageBreakVertex(m)){let t=e.getPrevVertex(m);const s=m;for(let i=0;;i++){const r=e.getSegmentParentage(t);if(l!==r){(0,n.g)(-1===r);break}if(m=t,e.getSegmentParentageBreakVertex(t))break;if(t===s){m=s,e.setSegmentParentageBreakVertex(m,!0);break}t=e.getPrevVertex(t),(0,n.g)(i<a)}}}else(0,n.g)(-1===l||e.getSegmentParentageBreakVertex(m));let u=m;for(let s=0;s<a&&u!==r.n;){const h=e.getSegmentParentage(u);if(-1===h){if(s++,u=e.getNextVertex(u),u===m)break;continue}let l=0,c=r.n;const g=u;l=1;let d=e.getNextVertex(g);for(;s<a&&d!==r.n;){s++,c=d,l++;const t=e.getSegmentParentage(d);if(-1===t||e.getSegmentParentageBreakVertex(d))break;(0,n.g)(t===h),d=e.getNextVertex(d)}if(c===r.n){(0,n.g)(0);break}if(!o){const s=t.m_originalPlanarSegments[h];t.processSpan_(e,g,c,l,s,h,i)}if(u=c,u===m)break}}if(s!==r.n)break;a=e.getNextGeometry(a)}else a=s===r.n?e.getNextGeometry(a):r.n}static st_stitchCurvesFromLinesImpl(t,e,s,i,o){let a=s===r.n?e.getFirstGeometry():s;for(;a!==r.n;){for(let s=e.getFirstPath(a);s!==r.n;s=e.getNextPath(s)){let a=e.getPathSize(s);e.isClosedPath(s)&&(a+=1);let h=!0,m=!1;const l=e.getFirstVertex(s);let u=l;for(let s=0;s<a&&u!==r.n;){let c=e.getSegmentParentage(u);if(-1===c||h){h=!1,s++,u=e.getNextVertex(u),m=!0;continue}let g,d,_=0;if(m?(g=e.getPrevVertex(u),d=u,(0,n.g)(g!==r.n),(0,n.g)(d!==g),(0,n.g)(-1===e.getSegmentParentage(g)||l===g)):(g=u,d=e.getNextVertex(g),s++,(0,n.g)(d!==r.n),(0,n.g)(d!==g),c=e.getSegmentParentage(d)),_=2,m=!1,-1===c||e.getSegmentParentageBreakVertex(d)){u=d;continue}let p=e.getNextVertex(d);for(s++;s<a&&p!==r.n;){d=p,_++;const t=e.getSegmentParentage(p);if(-1===t||e.getSegmentParentageBreakVertex(p))break;(0,n.g)(t===c),s++,p=e.getNextVertex(p)}if(!o){const s=t.m_originalPlanarSegments[c];t.processSpan_(e,g,d,_,s,c,i)}u=d}}if(s!==r.n)break;a=e.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(t,e,s,i,o){let a=s===r.n?e.getFirstGeometry():s;for(;a!==r.n;)if((0,n.l)(e.getGeometryType(a))){for(let s=e.getFirstPath(a);s!==r.n;s=e.getNextPath(s)){let a=e.getPathSize(s);const h=e.isClosedPath(s);h&&(a+=1);let m=e.getFirstVertex(s);if(h){if(-1!==e.getSegmentParentage(m)){let t=m;for(let n=0;!e.getSegmentParentageBreakVertex(t);n++){if(n===a){m=e.getFirstVertex(s),e.setSegmentParentageBreakVertex(t,!0);break}t=e.getPrevVertex(t)}}}else(0,n.g)(-1===e.getSegmentParentage(m)||e.getSegmentParentageBreakVertex(m));let l=m;for(let s=0;s<a&&l!==r.n;){const h=e.getSegmentParentage(l);if(-1===h){s++,l=e.getNextVertex(l);continue}let m=0,u=r.n;const c=l;m=1;let g=e.getNextVertex(c);for(;s<a&&g!==r.n;){s++,u=g,m++;const t=e.getSegmentParentage(g);if(-1===t||e.getSegmentParentageBreakVertex(g))break;(0,n.g)(t===h),g=e.getNextVertex(g)}if(u===r.n)break;if(!o){const s=t.m_originalPlanarSegments[h];t.processSpan_(e,c,u,m,s,h,i)}l=u}}if(s!==r.n)break;a=e.getNextGeometry(a)}else a=s===r.n?e.getNextGeometry(a):r.n}static regularizeCurve(t,e,s,n){let i=e.snapControlPoints(n*n);if(i){const n=t.getVertexIndex(s),i=e.clone();t.setSegmentToIndex(n,i)}if(e.getGeometryType()===r.J.type){const r=[],o=e.calculateSpecialPointsForCracking(n,r);if(o>0){const h=[];if(o>1)for(let t=0;t<o;t++)if(h.push(e.getCoord2D(r[t])),t>0){const e=(Math.abs(h[t].x)+Math.abs(h[t].y))*(0,a.g)(),s=a.P.distance(h[t-1],h[t]);if(s<e&&s>0){const e=new a.P;(0,a.Q)(h[t-1],h[t],.5,e),h[t-1]=e,h[t]=e}}t.splitSegment(s,r,o),i=t.snapControlPoints(s,o+1,n*n)||i;for(let e=0;e<o;e++)s=t.getNextVertex(s),t.setSegmentParentageBreakVertex(s,!0);return o}}return i?0:-1}}function gs(t,e,s,n,i){return new fs(t,s,e,n,i).do_()}function ds(t,e,s=1,n=1,i=1,r=1){if(n>r)return t;if(r>n)return e;const a=new o.P;return function(t,e,s,n,i,r,o,a,h){const m=t.equals(e);if(n>r)return o.assignCopy(t),h[0]=n,a[0]=s,m;if(r>n)return o=e,h[0]=r,a[0]=i,m;o.assignCopy(t);const l=nt(t.getXY(),e.getXY(),s,n,i,r);o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank}(t,e,s,n,i,r,a,[0],[0]),a}function _s(t,e,s){return fs.fixCurveTwoPointLoops(t,e,s)}function ps(t){return(0,o.e)(t)}class fs{constructor(t,e,s,n,i){this.m_shape=t,this.m_progressTracker=e,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=i,this.m_progressCounter=0}do_(){const t=new o.C(this.m_tolerance.tolerance,this.m_tolerance.resolution),e=ps(t);let s=(0,o.l)(t);const i=1.00001*s;s*=1.000001;let h=!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 t=0;;t++){this.m_shape.dbgCheckSelection(),t>m&&(0,n.d)("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let o=-1;0===t&&(o=this.firstCrack_(),h||=o>0);const a=this.cluster_(e);if(this.m_shape.dbgVerifyMonotone(),h||=a,this.m_bFilterDegenerateSegments){const t=0!==this.m_shape.filterClosePoints(e,!0,!1,this.m_bTrackChanges,r.n);h||=t,this.m_shape.dbgVerifyMonotone()}const u=this.m_shape.snapControlPointsOnSelection(i*i);h||=u,this.m_shape.dbgCheckSelection();let c=!1;if((0===t&&-1===o||l||vt(!0,this.m_shape,s,null,this.m_progressTracker))&&(c=this.crack_(i),h||=c,this.m_shape.dbgVerifyMonotone()),!c&&!fs.fixCurveTwoPointLoops(this.m_shape,e,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return h&&function(t){if(!t.hasSegmentParentage())return;as(t);const e=new o.A(0),s=t.queryVertexIteratorOnSelection();for(let t=s.next();t!==r.n;t=s.next())e.add(t);if(0===e.size())return;t.sortVerticesSimpleByY(e,0,e.size()),e.add(r.n);const n=a.P.getNAN();t.queryXY(e.read(0),n);let i=0;const h=a.P.getNAN();for(let s=1,o=e.size();s<o;s++){{const n=e.read(s);n!==r.n?t.queryXY(n,h):h.setNAN()}if(!h.isEqualPoint2D(n)){if(s-i>1){let n=!1;for(let r=i;r<s;++r){const s=e.read(r);if(t.getSegmentParentageBreakVertex(s)){n=!0;break}}if(!n){const o=(e,s,n)=>{const i=t.getPrevVertex(e),o=t.getNextVertex(e);i!==r.n?s.assign(t.getXY(i)):s.setNAN(),o!==r.n?n.assign(t.getXY(o)):n.setNAN()},h=new a.P,m=new a.P;o(e.read(i),h,m);for(let t=i+1;t<s;++t){const s=e.read(t);if(s===r.n)continue;const i=new a.P,l=new a.P;o(s,i,l);const u=(t,e)=>!!(t.equals(e)||t.isNAN()&&e.isNAN());if(!(u(i,h)&&u(l,m)||u(l,h)&&u(i,m))){n=!0;break}}}if(n)for(let n=i;n<s;++n)t.setSegmentParentageBreakVertex(e.read(n),!0)}n.setCoordsPoint2D(h),i=s}}}(this.m_shape),h}cluster_(t){return et(this.m_shape,t,r.n,this.m_bTrackChanges,this.m_progressTracker)}crack_(t){return function(t,e,s,n){if(!Ct(t))return!1;const i=new bt(n);i.m_shape=t,i.m_tolerance=e,i.m_bTrackChanges=s;let r=!1;const o=t.hasCurves()?5:15;return r=t.getTotalPointCount()<o?i.crackBruteForce_():i.crackerPlaneSweep_(),r}(this.m_shape,t,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(t,e,s){if(!t.hasCurves())return!1;t.dbgVerifyCurves();const i=t.createUserIndexUninitialized(),h=new o.A(0),m=t.queryVertexIteratorOnSelection();for(let e=m.next();e!==r.n;e=m.next())h.add(e),t.setUserIndex(e,i,-1);if(0===h.size())return!1;h.add(r.n),t.sortVerticesSimpleByY(h,0,h.size()-1);let l=0;const u=t.getXY(h.read(l)),c=new a.P(Number.NaN,Number.NaN),g=[];for(let e=1,s=h.size();e<s;++e){const s=h.read(e),n=s!==r.n?t.getXY(s):c;if(n.equals(u))continue;const o=[];for(let s=l;s<e;s++){const e=h.read(s),n=t.getPrevVertex(e);if(n!==r.n&&-1===t.getUserIndex(n,i)){const e=xs(t.getXY(n),t.getSegment(n));0!==a.P.sqrDistance(u,e.otherPt)&&(e.vert=n,e.dir=-1,o.push(e)),t.setUserIndex(n,i,1)}const m=t.getNextVertex(e);if(m!==r.n&&-1===t.getUserIndex(e,i)){const s=xs(t.getXY(m),t.getSegment(e));0!==a.P.sqrDistance(u,s.otherPt)&&(s.vert=e,s.dir=1,o.push(s)),t.setUserIndex(e,i,1)}}if(o.length>1){o.sort((t,e)=>ys(t,e));const t=xs(c.clone(),null);o.push(t);let e=0;for(let t=1,s=o.length;t<s;t++)if(!o[t].otherPt.equals(o[t-1].otherPt)){if(t-e>1&&null!==o[e].seg){let s=!1;const n=e;for(let i=e+1;i<t;i++)if(!Ps(o[n],o[i])){s=!0;break}if(s)for(let s=e;s<t&&null!==o[s].seg;s++)g.push(o[s].vert)}e=t}}l=e,u.setCoordsPoint2D(n)}for(const s of g){const i=t.getSegment(s);(0,n.g)(null!==i);const r=t.getXY(s),o=t.getXY(t.getNextVertex(s));if(a.P.distance(r,o)<3*e)t.setSegmentToIndex(t.getVertexIndex(s),null);else{const e=i.lengthToT(.5*i.calculateLength2D());t.splitSegment(s,[e],1)}}return t.removeUserIndex(i),g.length>0}firstCrack_(){const t=this.m_shape.getEnvelope2D(this.m_progressTracker),e=(0,o.c)(null,t,!0).total();if(4*e<this.m_tolerance.total()){let t=!1;const s=1.1*e,n=e,i=this.cluster_(s);t||=i;let o=0;this.m_bFilterDegenerateSegments&&(o=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,r.n));const a=this.crack_(n);return t||=a,t?1:o?2:0}return-1}progress_(t=!1){this.m_progressCounter++,!t&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function xs(t,e){return{otherPt:t,seg:e,vert:-1,dir:0}}function Ps(t,e){if((0,n.g)(t.otherPt.equals(e.otherPt)),null===t.seg)return null===e.seg;if(null===e.seg)return!1;const s=t.seg.getGeometryType();if(s!==e.seg.getGeometryType())return!1;if(s===n.G.enumBezier){const s=t.seg,n=e.seg;let i=s.getControlPoint1(),r=s.getControlPoint2();-1===t.dir&&(r=(0,a.c)(i,i=r));let o=n.getControlPoint1(),h=n.getControlPoint2();return-1===e.dir&&(h=(0,a.c)(o,o=h)),i.equals(o)&&r.equals(h)}if(s===n.G.enumRationalBezier2){const s=t.seg,n=e.seg,i=s.getControlPoint1(),r=n.getControlPoint1();if(!i.equals(r))return!1;const o=[0,0,0];s.queryWeights(o),-1===t.dir&&(o[2]=(0,a.c)(o[0],o[0]=o[2]));const h=[0,0,0];return n.queryWeights(h),-1===e.dir&&(h[2]=(0,a.c)(h[0],h[0]=h[2])),o[0]===h[0]&&o[1]===h[1]&&o[2]===h[2]}(0,n.d)("")}function ys(t,e){const s=t.otherPt.compare(e.otherPt);return 0!==s?s:function(t,e){if(null===t.seg||null===e.seg)return null!==t.seg?-1:null!==e.seg?1:0;const s=t.seg.getGeometryType(),n=e.seg.getGeometryType();return s<n?-1:s>n?1:0}(t,e)}var Es=n.h,Cs=n.f,vs=n.u;function Ss(t){switch(t){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:(0,n.g)(0,"unrecognized cut side")}return 3}function bs(t,e,s,i,r,a,h){const m=new Gs(r);m.m_bOGCOutput=!0;const l=t.getGeometryType()===n.G.enumPolygon&&1===t.getFillRule()&&!(0,o.p)(i);return m.planarSimplifyImpl_(t,e,l,s,i,r,a,h)}function Is(t,e,s,n,i,r,o,a){return new Gs(r).planarSimplifyImpl_(t,e,s,n,i,r,o,a)}function Ds(t,e,s){return function(t,e,s){const i=t.createInstance(),r=(0,a.m)(a.P,100),o=new Array(100),h=t.getPointCount();let m=!0;const l=2===e.getDimension();1!==e.getDimension()&&2!==e.getDimension()&&(0,n.d)("");for(let n=0;n<h;){const a=t.queryCoordinates(r,r.length,n,-1)-n;l?ts(e,r,a,s.total(),o):es(e,r,a,s.total(),o);let h=0;for(let e=0;e<a;e++)0===o[e]&&(m&&(m=!1,i.addPoints(t,0,n)),h!==e&&i.addPoints(t,n+h,n+e),h=e+1);m||h===a||i.addPoints(t,n+h,n+a),n+=a}return m?t:i}(t,e,s)}function ws(t,e,s,a){if(t.getDimension()>e.getDimension())return qs(Ms(t),t,0,"^");if(t.getDimension()<e.getDimension())return qs(Ms(e),t,0,"^");if(t.isEmpty())return qs(Ms(e),t,0,"^");if(e.isEmpty())return qs(Ms(t),t,0,"^");const h=new i.Envelope2D;t.queryEnvelope(h);const m=new i.Envelope2D;e.queryEnvelope(m);const l=new i.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const u=(0,o.c)(s,l,!0),c=new Gs(a),g=new r.E,d=g.addGeometry(Ms(t)),_=g.addGeometry(Ms(e));let p=0,f=null;if(g.hasCurves()){f=new us;const t=g.getEnvelope2D(a);p=ms(u.total()),rs(g,hs(u.total(),t),u.total(),0,f,null,a)}c.setEditShapeCrackAndCluster(g,u);const x=c.symmetricDifference(d,_);null!==f&&f.stitchCurves(g,x,p,!0);const P=qs(g.getGeometry(x),t,0,"^");return Es(P.getGeometryType())&&(P.getImpl().setIsSimple(4,u.total()),P.getGeometryType()===n.G.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Ts(t,e,s){return function(t,e,s){if(t.isEmpty())return t.createInstance();if(e.isEmpty())return t.createInstance();const i=[new a.P],r=[0],o=2===e.getDimension();return 1!==e.getDimension()&&2!==e.getDimension()&&(0,n.d)(""),i[0]=t.getXY(),o?ts(e,i,1,s.total(),r):es(e,i,1,s.total(),r),0===r[0]?t.createInstance():t}(t,e,s)}function Ns(t,e,s,i,a,h=!1){0===e&&(0,n.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=e;s<n;s++)m=Math.max(t[s].getDimension(),m);if(2===m||1===m)return new Gs(i).dissolveMultiPaths_(m,!1,t,e,s,a,h);let l=0,u=-1;for(let s=0,n=e;s<n;s++)t[s].getDimension()===m&&(-1===u&&(u=s),t[s].isEmpty()||(u=s,l++));if(l<2)return Ms(t[u]);const c=o.q.constructEmpty(),g=new r.E;let d=r.n;for(let s=0,n=e;s<n;s++)if(t[s].getDimension()===m&&!t[s].isEmpty()){d===r.n?d=g.addGeometry(Ms(t[s])):g.appendGeometry(d,Ms(t[s]));const e=o.q.constructEmpty();t[s].queryLooseEnvelope(e),c.mergeEnv3D(e)}const _=(0,o.c)(s,c.getEnvelope2D(),!0),p=new Gs(i);if(h){const t=(0,o.r)(s,c.getEnvelopeZs(),!0);return p.planarSimplify3DImpl_(g,_,t,0,!0)}return p.m_bOGCOutput=!0,p.planarSimplifyMultiPoints(g,_,!1,-1)}function As(t,e,s,i,a,h=!1){e<2&&(0,n.a)("not enough geometries to dissolve");let m=0;for(let s=0,n=e;s<n;s++)m=Math.max(t[s].getDimension(),m);if(2===m||1===m)return new Gs(i).dissolveMultiPaths_(m,!0,t,e,s,a,h);const l=o.q.constructEmpty(),u=new r.E;let c=r.n,g=0,d=-1;for(let s=0,n=e;s<n;s++)if(t[s].getDimension()===m&&(-1===d&&(d=s),!t[s].isEmpty())){d=s,c===r.n?c=u.addGeometry(Ms(t[s])):u.appendGeometry(c,Ms(t[s]));const e=o.q.constructEmpty();t[s].queryLooseEnvelope(e),l.mergeEnv3D(e),g++}if(g<2)return Ms(t[d]);const _=0===m?s:null,p=(0,o.c)(_,l.getEnvelope2D(),!0),f=new Gs(i);if(h){const t=(0,o.r)(_,l.getEnvelopeZs(),!0);return f.m_bOGCOutput=!0,f.planarSimplify3DImpl_(u,p,t,0,!0)}return f.planarSimplifyMultiPoints(u,p,!0,-1)}class Gs{constructor(t){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=a.P.getNAN(),this.m_dummyPt2=a.P.getNAN(),this.m_fromEdgeForPolylines=r.n,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=t}linesToPolygonsImpl(t,e){let s=0,n=0,i=null;if(t.hasCurves()){i=new us;const r=t.getEnvelope2D(this.m_progressTracker);n=ms(e.total());const o=hs(e.total(),r);s=ls(o,n),rs(t,o,e.total(),0,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,e.add(s));const o=this.m_topoGraph.createUserIndexForChains(),a=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(a,o,1);for(let t=this.m_topoGraph.getChainFirstIsland(a);t!==r.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,o,1);const h=[];for(let e=this.m_topoGraph.getFirstChain();e!==r.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,o))continue;this.m_topoGraph.setChainUserIndex(e,o,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==r.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,o,1);if(0===this.m_topoGraph.getChainArea(e))continue;const s=this.m_topoGraph.extractPolygonFromChainAndIslands(t,r.n,e,r.n);null!=i&&i.stitchCurves(t,s,n,!1);const a=t.getGeometry(s);h.push(a)}return new c.S(h)}autoCompleteImpl(t,e,s){let n=0,i=0,o=null;if(t.hasCurves()){o=new us;const e=t.getEnvelope2D(this.m_progressTracker);i=ms(s.total());const r=hs(s.total(),e);n=ls(r,i),rs(t,r,s.total(),0,o,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,s.add(n));const a=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.createUserIndexForChains(),m=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(m,h,1);for(let t=this.m_topoGraph.getChainFirstIsland(m);t!==r.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,h,1);const l=[];for(let e=this.m_topoGraph.getFirstChain();e!==r.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,h))continue;this.m_topoGraph.setChainUserIndex(e,h,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==r.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,h,1);if(0!==this.m_topoGraph.getChainParentage(e))continue;const s=this.m_topoGraph.getChainHalfEdge(e);let n=s,m=!1;do{const t=this.m_topoGraph.getHalfEdgeTwin(n);if(this.m_topoGraph.getHalfEdgeChain(t)!==e&&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(e))continue;const u=this.m_topoGraph.extractPolygonFromChainAndIslands(t,r.n,e,r.n);null!==o&&o.stitchCurves(t,u,i,!1);const c=t.getGeometry(u);l.push(c)}return new c.S(l)}setEditShape(t,e=!1){null===this.m_topoGraph&&(this.m_topoGraph=new Z),this.m_topoGraph.setEditShape(t,this.m_progressTracker,!0,e)}setEditShapeCrackAndCluster(t,e){gs(t,e,this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e))t.getGeometryType(e)===n.G.enumPolygon&&qt(t,e,-1,this.m_bOGCOutput,r.n,this.m_progressTracker);this.setEditShape(t)}setHalfEdgeOrientations_(t,e){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==r.n;n=s.getNextGeometry(n))if(n===e)for(let e=s.getFirstPath(n);e!==r.n;e=s.getNextPath(e)){let n=s.getFirstVertex(e);if(n===r.n)continue;let i=s.getNextVertex(n);for(;i!==r.n;){const e=this.m_topoGraph.getClusterFromVertex(n),o=this.m_topoGraph.getClusterFromVertex(i),a=this.m_topoGraph.getHalfEdgeConnector(e,o);if(a!==r.n){const e=this.m_topoGraph.getHalfEdgeTwin(a);this.m_topoGraph.setHalfEdgeUserIndex(a,t,1),this.m_topoGraph.setHalfEdgeUserIndex(e,t,2)}n=i,i=s.getNextVertex(n)}}}flushVertices_(t,e){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),i=new r.S,o=s.insertPath(t,r.n);e.push(e[0]);const a=e.length;let h=r.n;for(let t=0;t<a;t++){const r=e[t];if(h=s.addVertex(o,r),!n)continue;const m=this.m_topoGraph.getClusterFromVertex(r);if(t>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(h,!0),t<a-1){const n=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(e[t+1])),r=this.m_topoGraph.getSegmentParentage(n);s.setSegmentParentageAndBreak(h,r,t>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,i),s.setSegmentToIndex(s.getVertexIndex(h),i.get().clone()))}}if(n){const t=this.m_topoGraph.getClusterFromVertex(e[a-1]);this.m_topoGraph.isBreakNode(t)&&s.setSegmentParentageBreakVertex(h,!0)}s.setClosedPath(o,!0)}processPolygonCuts_(t,e,s,i){const o=this.m_topoGraph.getGeometryID(s),a=this.m_topoGraph.getGeometryID(i),h=[],m=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let s=this.m_topoGraph.getFirstCluster();s!==r.n;s=this.m_topoGraph.getNextCluster(s)){const i=this.m_topoGraph.getClusterHalfEdge(s);if(i===r.n)continue;let u=i;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(u,l)){let s=u,i=u,r=!1,c=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,l,1),r||0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&o)&&(i=s,r=!0),r){const e=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(e),i=this.m_topoGraph.getVertexFromVertexIterator(n);h.push(i),-1!==t&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&a)&&(c|=this.m_topoGraph.getHalfEdgeUserIndex(s,t))}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==i);if(r&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(i))>0){const t=m.createGeometry(n.G.enumPolygon);this.flushVertices_(t,h),-1!==e&&m.setGeometryUserIndex(t,e,c)}h.length=0}u=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(u))}while(u!==i)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(t,e,s,n){this.m_topoGraph.removeSpikes_();let i=-1;-1!==t&&(i=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(i,s)),this.processPolygonCuts_(i,t,e,s),-1!==i&&(this.m_topoGraph.deleteUserIndexForHalfEdges(i),i=-1);const o=this.m_topoGraph.getShape();for(let t=o.getFirstGeometry();t!==r.n;t=o.getNextGeometry(t))t!==e&&t!==s&&n.push(t);n.sort((t,e)=>{const s=o.getFirstPath(t),n=o.getRingArea(s),i=o.getFirstPath(e),r=o.getRingArea(i);return n<r?-1:n>r?1:0})}cut(t,e,s,i,r){const o=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(i),h=(0,n.u)(o),m=(0,n.u)(a);if(2!==h||1!==m){if(1===h&&1===m)return void new Xs(this,t,e,s,i,r).Do();(0,n.d)("")}else this.cutPolygonPolyline_(e,s,i,r)}progress_(t=!1){}isGoodParentage(t){return t>=0&&t<this.m_maskLookup.length&&this.m_maskLookup[t]}normalizeInputGeometry(t){const e=t.getGeometryType();if(e===n.G.enumEnvelope){const e=new r.a({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===n.G.enumPoint){const e=new r.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if((0,n.f)(e)){const e=new r.P({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==n.G.enumMultiPoint&&e!==n.G.enumPolyline&&e!==n.G.enumPolygon&&(0,n.a)("Unexpected geometry type"),t}dissolveNonSimplePolygons(t,e,s,i){(0,n.g)(e>0);const o=new r.E;let a=0,h=-1;for(let s=0,n=e;s<n;s++)2===t[s].getDimension()&&(-1===h&&(h=s),t[s].isEmpty()||(a++,o.addGeometry(t[s])));return 0===a?((0,n.g)(h>=0),this.normalizeInputGeometry(t[h])):this.planarSimplifyPolygons(o,s,!0,!1,-1,!0)}dissolveMultiPaths_(t,e,s,h,m,l,u){(0,n.g)(t>=1&&t<=2),(0,n.g)(h>0);const c=8&l?1:2,g=o.q.constructEmpty();let d=0,_=-1,p=!0;for(let e=0,i=h;e<i;e++)if(s[e].getDimension()===t&&(-1===_&&(_=e),!s[e].isEmpty())){_=e,d++;const i=o.q.constructEmpty();if(s[e].queryLooseEnvelope(i),g.mergeEnv3D(i),2===t&&p&&s[e].getGeometryType()===n.G.enumPolygon)if(16&l){const t=[0],n=s[e].getImpl().getIsSimple(0,t),i=this.m_bOGCOutput?5===n:(0,o.i)(n);p&&=i}else{const t=(0,o.h)(s[e],0);p&&=t}}if(d<2&&((0,n.g)(_>=0),0===d||!(16&l)))return this.normalizeInputGeometry(s[_]);if(!p){const t=(0,o.c)(e?null:m,g.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,h,t,l)}const f=s.slice(0,h),x=(0,o.c)(m,g.getEnvelope2D(),!0),P=10*(0,o.e)(x);let y=new o.C(0,0);if(u&&(y=(0,o.r)(m,g.getEnvelopeZs(),!0)),1===d&&1===t&&2===c&&!e)return u?((0,n.g)(0),{}):this.m_bOGCOutput?bs(f[_],x,!1,-1,this.m_progressTracker,c,!1):Is(f[_],x,!1,!1,-1,this.m_progressTracker,c,!1);const E=new o.z;E.startConstruction();let C=2===t?3:4,v=0;for(let s=0,r=h;s<r;s++){if(f[s].getDimension()!==t||f[s].isEmpty())continue;let r=f[s].getGeometryType();if(r!==n.G.enumEnvelope){if((0,n.f)(r)?(f[s]=this.normalizeInputGeometry(f[s]),r=n.G.enumPolyline):(0,n.g)((0,n.h)(r)),1===t){(0,n.g)(r===n.G.enumPolyline);let t=-1;if(u)(0,n.g)(0,"3d not implemented yet");else{const e=[0];t=f[s].getImpl().getIsSimple(x.total(),e)}if(this.m_bOGCOutput?5!==t:!(0,o.i)(t))if(e)C=-1;else{u?(0,n.g)(0,"3d not implemented yet"):this.m_bOGCOutput?f[s]=bs(f[s],x,!1,-1,this.m_progressTracker,c,!1):f[s]=Is(f[s],x,!1,!1,-1,this.m_progressTracker,c,!1);const t=[0];(0,n.g)((0,o.i)(f[s].getImpl().getIsSimple(x.total(),t)))}}else{(0,n.g)(r===n.G.enumPolygon);const t=[0],e=f[s].getImpl().getIsSimple(0,t);(0,n.g)((0,o.p)(e))}const a=f[s].getImpl();for(let t=0,e=a.getPathCount();t<e;t++){const e=i.Envelope2D.constructEmpty();a.queryLoosePathEnvelope(t,e),e.inflateCoords(P,P),E.addEnvelope(v,e),v++}}else{(0,n.g)(r===n.G.enumEnvelope);const t=i.Envelope2D.constructEmpty();f[s].queryLooseEnvelope(t),t.inflateCoords(P,P),E.addEnvelope(v,t),v++,C=-1}}E.endConstruction();const S=v,b=(0,a.d)(S,-2147483647),I=(0,a.d)(S,-1);let D=0;_=-1,v=0;for(let e=0,s=h;e<s;e++){if(f[e].getDimension()!==t)continue;if(-1===_&&(_=e),f[e].isEmpty())continue;_=e,D++;const s=f[e].getGeometryType();if((0,n.h)(s))for(let t=0,s=f[e].getPathCount();t<s;t++)I[v]=e,b[v]=-t-1,v++;else(0,n.g)(s===n.G.enumEnvelope),I[v]=e,b[v]=-1,v++}if(D<2&&2===t)return(0,n.g)(_>=0),this.normalizeInputGeometry(f[_]);let w=S;for(;E.next()&&w>0;){this.progress_();const t=E.getHandleA(),e=E.getHandleB(),s=E.getElement(t),n=E.getElement(e);I[s]!==I[n]&&(b[s]<0&&(w--,b[s]=-(b[s]+1)),b[n]<0&&(w--,b[n]=-(b[n]+1)))}const T=new r.E;let N,A=!1,G=0;for(let e=0,s=h;e<s;e++){if(f[e].getDimension()!==t||f[e].isEmpty())continue;const s=f[e].getGeometryType(),i=G;let o=0,a=0;const h=(0,n.h)(s)?f[e]:null;for(let t=i,s=b.length;t<s&&I[t]===e;t++)b[t]>=0&&(o++,a+=h?h.getPathSize(b[t]):(0,n.v)(f[e])),G++;if(a>.95*(0,n.v)(f[e])){T.addGeometry(this.normalizeInputGeometry(f[e]));for(let t=i;t<G;t++)b[t]<0&&(b[t]=-(b[t]+1))}else{if(0===o){A=!0;continue}{A=!0,(0,n.g)((0,n.h)(s)),(0,n.g)(null!=h);const t=new r.a({vd:f[e].getDescription()}),o=new r.P({vd:f[e].getDescription()}),a=s===n.G.enumPolygon?t:o;for(let t=i;t<G;t++)b[t]>=0&&a.addPath(h,b[t],!0);T.addGeometry(a)}}}if(T.getFirstGeometry()!==r.n){const s=2===t,n=e?(0,o.c)(null,g.getEnvelope2D(),!0):x;let i=new o.C(0,0);if(u&&(i=e?(0,o.r)(null,g.getEnvelopeZs(),!0):y),2===t&&!(2&l)){T.collapseAllGeometriesToFirst();let t=0,e=null;if(T.hasCurves()&&!T.hasSegmentParentage()){e=new us;const s=T.getEnvelope2D(this.m_progressTracker);t=ms(n.total()),rs(T,hs(n.total(),s),n.total(),0,e,null,this.m_progressTracker)}(function(t,e,s,n){s>0&&et(t,s,e,!1,n),new Et(n).executeImpl_(t,e)})(T,T.getFirstGeometry(),n.total(),this.m_progressTracker),null!==e&&e.stitchCurves(T,r.n,t,!0)}if(u)N=this.planarSimplify3DImpl_(T,n,i,c,!0);else if(2===t)N=this.planarSimplifyPolygons(T,n,s,e,-1,!1);else{const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=c,N=this.planarSimplifyPolylines(T,n,e,t,-1)}if(!A){const t=[0];C=N.getImpl().getIsSimple(n.total(),t)}}else(0,n.g)(A),(0,n.g)(_>=0),N=2===t?new r.a({vd:f[_].getDescription()}):new r.P({vd:f[_].getDescription()});if(A){let t=0;for(let e=0,s=b.length;e<s;e++){const s=I[e];if(!(s<0)&&b[e]<0){const i=f[s].getGeometryType(),r=(0,n.h)(i)?f[s]:null;if(r){const s=-(b[e]+1);t+=r.getPathSize(s)}else t+=4}}N.reserve(N.getPointCount()+t);for(let t=0,e=b.length;t<e;t++){const e=I[t];if(!(e<0)&&b[t]<0){const s=f[e].getGeometryType(),i=(0,n.h)(s)?f[e]:null;if(i){const e=-(b[t]+1);N.addPath(i,e,!0)}else s===n.G.enumEnvelope?N.addEnvelope(f[e],!1):((0,n.g)((0,n.f)(s)),N.addSegment(f[e],!0))}}}let q=0;if(2===t?-1!==C&&(C=3,q=e?0:x.total()):((0,n.g)(1===t),e||-1===C||(q=x.total())),u||N.getImpl().setIsSimple(C,q),!e&&A)if(2===t){if(!u)return(new Ks).execute(N,m,!1,this.m_progressTracker);(0,n.g)(0,"3d not yet implemented")}else 1===t&&1!==c&&(N=u?((0,n.g)(0),{}):function(t,e,s,i){const o=new Gs(i),a=new r.E,h=a.addGeometry(e),m=o.planarSimplifyNoCrackingAndCluster(t,a,h,s);return(0,n.g)(m,"planar_simplify_no_cracking_and_cluster"),a.getGeometry(h)}(this.m_bOGCOutput,N,c,this.m_progressTracker),N.getImpl().setIsSimple(C,q));return N}dissolveTopoGraphCommonEdges_(){const t=this.m_topoGraph.createUserIndexForHalfEdges(),e=[];for(let s=this.m_topoGraph.getFirstCluster();s!==r.n;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let i=n;if(n!==r.n)do{if(this.progress_(),1!==this.m_topoGraph.getHalfEdgeUserIndex(i,t)){const s=this.m_topoGraph.getHalfEdgeTwin(i);this.m_topoGraph.setHalfEdgeUserIndex(s,t,1),this.m_topoGraph.setHalfEdgeUserIndex(i,t,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(i);if(this.isGoodParentage(n)){const t=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(t)&&e.push(i)}}i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(i))}while(i!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(t),this.m_topoGraph.deleteEdgesBreakFaces_(e)}chooseVertexByOrder(t,e,s,i){let o=(0,a.j)(),h=r.n;for(let n=this.m_topoGraph.getClusterVertexIterator(t);n!==r.n;n=this.m_topoGraph.incrementVertexIterator(n)){const t=this.m_topoGraph.getVertexFromVertexIterator(n),i=e.getUserIndex(t,s);i>=0&&i<o&&(o=i,h=t)}(0,n.g)(h!==r.n);let m=e.getUserIndex(h,i);return m>0&&(e.setUserIndex(h,i,--m),0===m&&e.setUserIndex(h,s,-1)),h}chooseVertexFromCluster_(t,e){return this.m_topoGraph.getVertexDominantFromCluster(t,e)}chooseVertexFromVertexCluster_(t,e){return this.m_topoGraph.getVertexDominant(t,e)}collectPolygonPathsPreservingFrom_(t,e,s,i,o){const a=this.m_topoGraph.getShape();if(a.getGeometryType(t)!==n.G.enumPolygon)return;const h=a.hasSegmentParentage(),m=new r.S;for(let n=a.getFirstPath(t);n!==r.n;n=a.getNextPath(n)){const t=a.getFirstVertex(n);this.m_topoGraph.getClusterFromVertex(t);const l=this.m_topoGraph.getHalfEdgeFromVertex(t);if(l===r.n)continue;const u=this.m_topoGraph.getHalfEdgeUserIndex(l,s);if(1===u||2===u)continue;const c=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(!this.isGoodParentage(c)){this.m_topoGraph.setHalfEdgeUserIndex(l,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(l,s,1);const g=a.insertPath(e,r.n);a.setClosedPath(g,!0);let d=l,_=t,p=this.m_topoGraph.getClusterFromVertex(_),f=1;do{this.progress_();const t=this.chooseVertexFromVertexCluster_(_,o),e=a.addVertex(g,t);if(this.m_topoGraph.isHalfEdgeCurve(d)&&(this.m_topoGraph.querySegmentXY(d,m),a.setSegmentToIndex(a.getVertexIndex(e),m.get().clone())),h){const t=this.m_topoGraph.getSegmentParentage(d);a.setSegmentParentageAndBreak(e,t,this.m_topoGraph.isBreakNode(p))}let n,l;-1!==i&&this.m_topoGraph.setClusterUserIndex(p,i,1),this.m_topoGraph.setHalfEdgeUserIndex(d,s,1),d=this.m_topoGraph.getHalfEdgeNext(d);do{n=1===f?a.getNextVertex(_):a.getPrevVertex(_),l=n!==r.n?this.m_topoGraph.getClusterFromVertex(n):r.n}while(l===p);const u=this.m_topoGraph.getHalfEdgeOrigin(d);if(u!==l){do{n=1===f?a.getPrevVertex(_):a.getNextVertex(_),l=n!==r.n?this.m_topoGraph.getClusterFromVertex(n):r.n}while(l===p);if(u!==l){l=u;const t=this.m_topoGraph.getClusterVertexIterator(l);n=this.m_topoGraph.getVertexFromVertexIterator(t)}else f=-f}p=l,_=n}while(d!==l)}}topoOperationPolygonPolygonHelper_(t,e,s,n,i,o){this.progress_(!0),t!==r.n&&this.collectPolygonPathsPreservingFrom_(t,s,i,o,n),e!==r.n&&this.collectPolygonPathsPreservingFrom_(e,s,i,o,n);const a=new r.S,h=this.m_topoGraph.getShape();h.dbgVerifyCurves();const m=h.hasSegmentParentage();for(let t=this.m_topoGraph.getFirstCluster();t!==r.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===r.n)continue;let l=e;do{this.progress_();const t=this.m_topoGraph.getHalfEdgeUserIndex(l,i);if(1!==t&&2!==t){const t=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(t)){const t=h.insertPath(s,r.n);h.setClosedPath(t,!0);let e=l;do{const s=this.m_topoGraph.getHalfEdgeVertexIterator(e);let l=r.n;if(s!==r.n)l=this.m_topoGraph.getVertexFromVertexIterator(s);else{const t=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(e));l=this.m_topoGraph.getVertexFromVertexIterator(t),l=h.getNextVertex(l)}const u=this.chooseVertexFromVertexCluster_(l,n),c=h.addVertex(t,u);if(m){const t=this.m_topoGraph.getSegmentParentage(e),s=this.m_topoGraph.getHalfEdgeOrigin(e);h.setSegmentParentageAndBreak(c,t,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,a),h.setSegmentToIndex(h.getVertexIndex(c),a.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(e,i,1),-1!==o){const t=this.m_topoGraph.getClusterFromVertex(u);this.m_topoGraph.setClusterUserIndex(t,o,1)}e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,i,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==e)}}topoOperationPolygonPolygon_(t,e,s,i=!1){this.dissolveTopoGraphCommonEdges_();const o=this.m_topoGraph.getShape(),a=o.createGeometry(n.G.enumPolygon),h=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(t,e,a,s,h,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(h),i||qt(o,a,3,this.m_bOGCOutput,r.n,this.m_progressTracker),a}topoOperationPolyline_(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(r.n,t,!1,s).first}topoOperationMultiPoint_(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(n.G.enumMultiPoint),s=t.insertPath(e,r.n);for(let e=this.m_topoGraph.getFirstCluster();e!==r.n;e=this.m_topoGraph.getNextCluster(e)){const n=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(n)){let n=r.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==r.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);n===r.n&&(n=e);const i=t.getGeometryFromPath(t.getPathFromVertex(e)),o=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(o)){n=e;break}}t.addVertex(s,n)}}return e}intersection(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),o=(0,n.u)(s),a=(0,n.u)(i),h=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,n.g)(h>=0),(0,n.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=r.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===o&&2===a?this.topoOperationPolygonPolygon_(t,e,l):1===o&&a>0||1===a&&o>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===o||0===a?this.topoOperationMultiPoint_():void(0,n.d)("")}topoOperationPolygonPolygonEx(t,e,s){const i=this.m_topoGraph.getShape(),o=i.createGeometry(n.G.enumPolygon),a=i.createGeometry(n.G.enumPolyline),h=i.createGeometry(n.G.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=r.n;const l=this.m_topoGraph.createUserIndexForHalfEdges(),u=this.m_topoGraph.createUserIndexForClusters();i.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(t,e,o,s,l,u),i.dbgVerifyCurves();const c=i.hasSegmentParentage(),g=new r.S;for(let t=this.m_topoGraph.getFirstCluster();t!==r.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===r.n)continue;let n=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(n,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l),h=e|o;if(2===h){let m=this.m_topoGraph.getHalfEdgeParentage(n);if(this.isGoodParentage(m)){const d=i.insertPath(a,r.n);let _=n;const p=this.chooseVertexFromCluster_(t,s);let f=i.addVertex(d,p);if(c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone())),this.m_topoGraph.setClusterUserIndex(t,u,1);do{this.progress_();const t=this.m_topoGraph.getHalfEdgeTo(_),r=this.chooseVertexFromCluster_(t,s);if(f=i.addVertex(d,r),c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}if(this.m_topoGraph.setHalfEdgeUserIndex(_,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),l,1),this.m_topoGraph.setClusterUserIndex(t,u,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),l),h=e|o,2!==h)break;if(m=this.m_topoGraph.getHalfEdgeParentage(_),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(_,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),l,1);break}this.m_topoGraph.isHalfEdgeCurve(n)&&_!==n&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone()))}while(_!==n)}else this.m_topoGraph.setHalfEdgeUserIndex(n,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l,1)}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==e)}for(let t=this.m_topoGraph.getFirstCluster();t!==r.n;t=this.m_topoGraph.getNextCluster(t)){if(this.progress_(),1===this.m_topoGraph.getClusterUserIndex(t,u))continue;const e=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(e)){m===r.n&&(m=i.insertPath(h,r.n));const e=this.m_topoGraph.getClusterVertexIterator(t);let n=r.n;if(e!==r.n){n=this.m_topoGraph.getVertexFromVertexIterator(e);const t=this.chooseVertexFromVertexCluster_(n,s);i.addVertex(m,t)}}}this.m_topoGraph.deleteUserIndexForClusters(u),this.m_topoGraph.deleteUserIndexForHalfEdges(l),i.dbgVerifyCurves(),qt(i,o,3,this.m_bOGCOutput,r.n,this.m_progressTracker);const d=[r.n,r.n,r.n];return d[0]=h,d[1]=a,d[2]=o,d}topoOperationPolylinePolylineOrPolygonEx(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(r.n,t,!0,s)}topoOperationMultiPoint(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(n.G.enumMultiPoint),s=t.insertPath(e,r.n);for(let e=this.m_topoGraph.getFirstCluster();e!==r.n;e=this.m_topoGraph.getNextCluster(e)){const n=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(n)){let n=r.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==r.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);n===r.n&&(n=e);const i=t.getGeometryFromPath(t.getPathFromVertex(e)),o=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(o)){n=e;break}}t.addVertex(s,n)}}return e}intersectionEx(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),o=vs(s),a=vs(i),h=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,n.g)(h>=0),(0,n.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=r.n;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===o&&2===a)return this.topoOperationPolygonPolygonEx(t,e,l);if(1===o&&a>0||1===a&&o>0){const{first:t,second:e}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[e,t]}if(0===o||0===a){const t=[];return t.push(this.topoOperationMultiPoint()),t}(0,n.d)("")}getCombinedHalfEdgeParentage(t){return this.m_topoGraph.getHalfEdgeParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t))}prevailingDirection(t,e){const s=this.getCombinedHalfEdgeParentage(e),n=this.m_topoGraph.getHalfEdgeOrigin(e),i=this.m_topoGraph.getHalfEdgeTo(e);let o=0,h=0;for(let a=this.m_topoGraph.getClusterVertexIterator(n);a!==r.n;a=this.m_topoGraph.incrementVertexIterator(a)){const n=this.m_topoGraph.getVertexFromVertexIterator(a),m=t.getPathFromVertex(n),l=t.getGeometryFromPath(m),u=this.m_topoGraph.getGeometryID(l),c=t.getFirstVertex(m),g=0!==(u&s);g&&c===n&&(this.m_fromEdgeForPolylines=e);const d=t.getNextVertex(n);if(d!==r.n&&this.m_topoGraph.getClusterFromVertex(d)===i){if(o++,g){if(this.m_fromEdgeForPolylines===r.n&&c===d){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}h++}}else{const s=t.getPrevVertex(n);if(s!==r.n&&this.m_topoGraph.getClusterFromVertex(s)===i&&(o--,g)){if(this.m_fromEdgeForPolylines===r.n&&c===s){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}h--}}}return this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(i,this.m_dummyPt2),(0!==h?h:o)*a.P.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(t,e){const s=this.m_topoGraph.getHalfEdgePrev(t),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return r.n;const e=this.m_topoGraph.getHalfEdgeTwin(t);if(n===this.m_topoGraph.getHalfEdgeNext(e))return s}let i=n,o=r.n;for(;i!==t;){const t=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(t)){if(o!==r.n)return r.n;o=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(i))}return o}tryMoveThroughCrossroadForward(t,e){const s=this.m_topoGraph.getHalfEdgeNext(t),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){const e=this.m_topoGraph.getHalfEdgeTwin(t);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return r.n;if(n===this.m_topoGraph.getHalfEdgePrev(e))return s}let i=n,o=r.n;for(;i!==t;){const t=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(t)){if(o!==r.n)return r.n;o=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(i))}return o}isOnALoop(t,e){let s=t;const i=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let n=0;n<i;n++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,e))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===t)return!0}(0,n.d)("is_on_a_loop_")}restorePolylineParts(t,e,s,i,o,h,m,l,u,c){(0,n.g)(o===r.n&&h>=0&&m>=0||-1===h&&-1===m),(0,n.g)(-1===l&&1!==c.unsplitBehavior||-1!==l&&1===c.unsplitBehavior);const g=c.ogcRule,d=c.allCrossRoadsImpassable,_=1===c.unsplitBehavior,p=0===c.unsplitBehavior,f=this.m_topoGraph.getShape(),x=f.hasSegmentParentage();let P=t,y=this.m_topoGraph.getHalfEdgeTwin(P);const E=new r.S;this.m_fromEdgeForPolylines=r.n;let C=this.prevailingDirection(f,P),v=P,S=r.n,b=!1,I=!1,D=!1;if(!_)for(;;){const e=this.m_topoGraph.getHalfEdgePrev(P);if(e===y){D=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(y);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){b=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(d){b=!0;break}if(P=this.tryMoveThroughCrossroadBackwards(P,!0),P===r.n){b=!0;break}y=this.m_topoGraph.getHalfEdgeTwin(P)}else P=e,y=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){D=!0;break}if(P===t){S=t,I=!0;break}const i=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(i))break;v=P,C+=this.prevailingDirection(f,P)}if(S===r.n){for(P=t,y=this.m_topoGraph.getHalfEdgeTwin(P),S=P;;){const t=this.m_topoGraph.getHalfEdgeNext(P),e=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t));if(e){b=!0;break}if(t===y){D=!0;break}if(-1!==l){const t=this.m_topoGraph.getHalfEdgeOrigin(y);if(1===this.m_topoGraph.getClusterUserIndex(t,l)){b=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(y);if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(e||d){b=!0;break}if(P=this.tryMoveThroughCrossroadForward(P,!0),P===r.n){b=!0;break}y=this.m_topoGraph.getHalfEdgeTwin(P)}else P=t,y=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){D=!0;break}const i=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(i))break;S=P,C+=this.prevailingDirection(f,P)}const e=this.m_topoGraph.getHalfEdgeOrigin(v);I=this.m_topoGraph.getHalfEdgeTo(S)===e}else if(this.m_fromEdgeForPolylines!==r.n){v=t,S=this.tryMoveThroughCrossroadBackwards(v,!1),(0,n.g)(S!==r.n);const e=this.m_topoGraph.getHalfEdgeTwin(v);this.m_topoGraph.getHalfEdgeNext(e)}let w=I;I||D||u&&(w=this.isOnALoop(t,s),w||(w=this.isOnALoop(y,s)));const T=C>=0;let N=!1;w&&b&&(I?(N=g,T&&(N||_||p)&&v!==t&&((0,n.g)(!_),v=t,N=!1)):(_||T&&p)&&(v=t));let A=0;for(P=v;y=this.m_topoGraph.getHalfEdgeTwin(P),this.m_topoGraph.setHalfEdgeUserIndex(P,s,1),this.m_topoGraph.setHalfEdgeUserIndex(y,s,1),A++,P!==S;)P=d?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1);T||(S=(0,a.c)(v,v=S),S=this.m_topoGraph.getHalfEdgeTwin(S),v=this.m_topoGraph.getHalfEdgeTwin(v));let G=f.insertPath(e,r.n);P=v;const q=this.m_topoGraph.getHalfEdgeOrigin(v);let M;M=-1!==h?this.chooseVertexByOrder(q,f,h,m):this.chooseVertexFromCluster_(q,o),this.m_topoGraph.isStrongPathNode(q)&&f.setStrongPathStart(G,!0);let F=f.addVertex(G,M),X=F;-1!==i&&this.m_topoGraph.setClusterUserIndex(q,i,1);let V=0;const Y=N?Math.trunc((A+1)/2):-1;let R=r.n,k=!0,L=r.n;for(;;){if(x){const t=this.m_topoGraph.getSegmentParentage(P),e=this.m_topoGraph.getHalfEdgeOrigin(P);f.setSegmentParentageAndBreak(X,t,k||this.m_topoGraph.isBreakNode(e))}k=!1,this.m_topoGraph.isHalfEdgeCurve(P)&&(this.m_topoGraph.querySegmentXY(P,E),f.setSegmentToIndex(f.getVertexIndex(X),E.get().clone())),R!==r.n&&-1!==m&&f.addToUserIndex(R,m,-1);const t=d?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1),s=this.m_topoGraph.getHalfEdgeTo(P);let n;if(n=-1!==h?this.chooseVertexByOrder(s,f,h,m):this.chooseVertexFromCluster_(s,o),F=f.addVertex(G,n),L=s,-1!==i&&this.m_topoGraph.setClusterUserIndex(s,i,1),x&&this.m_topoGraph.isBreakNode(s)&&f.setSegmentParentageBreakVertex(F,!0),R=n,V++,N&&V===Y&&(G=f.insertPath(e,r.n),F=f.addVertex(G,n),k=!0,-1!==m&&f.addToUserIndex(n,m,-1),R=r.n),P===S)break;P=t,X=F}L!==r.n&&this.m_topoGraph.isStrongPathNode(L)&&f.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(t,e){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,r.n,!1,e).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,e,s,i){(0,n.g)(e===r.n||t===r.n);const o=this.m_topoGraph.getShape(),h=e=>t===r.n?e===r.n?o.getFirstGeometry():o.getNextGeometry(e):e===r.n?t:r.n,m=o.createGeometry(n.G.enumPolyline);let l=-1;s&&(l=this.m_topoGraph.createUserIndexForClusters());const u=this.m_topoGraph.createUserIndexForHalfEdges(),c=e===r.n?o.createUserIndex():-1,g=e===r.n?o.createUserIndex():-1;let d=-1;if(1===i.unsplitBehavior){d=this.m_topoGraph.createUserIndexForClusters();for(let t=h(r.n);t!==r.n;t=h(t))for(let e=o.getFirstPath(t);e!==r.n;e=o.getNextPath(e)){{const t=o.getFirstVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,d,1)}if(!o.isClosedPath(e)){const t=o.getLastVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,d,1)}}}if(e===r.n){let t=0;for(let e=h(r.n);e!==r.n;e=h(e))for(let s=o.getFirstPath(e);s!==r.n;s=o.getNextPath(s))if(o.isClosedPath(s)){let e=o.getFirstVertex(s);for(let n=0,i=o.getPathSize(s);n<i;n++,e=o.getNextVertex(e))o.setUserIndex(e,c,t++),o.setUserIndex(e,g,2)}else{const e=o.getFirstVertex(s);o.setUserIndex(e,c,t++),o.setUserIndex(e,g,1);let n=o.getNextVertex(e);for(let e=1,i=o.getPathSize(s)-1;e<i;++e)o.setUserIndex(n,c,t++),o.setUserIndex(n,g,2),n=o.getNextVertex(n);o.setUserIndex(n,c,t++),o.setUserIndex(n,g,1)}}for(let t=h(r.n);t!==r.n;t=h(t))for(let s=o.getFirstPath(t);s!==r.n;s=o.getNextPath(s)){let t=o.getFirstVertex(s);for(let n=0,a=o.getPathSize(s);n<a;n++,t=o.getNextVertex(t)){const s=this.m_topoGraph.getHalfEdgeFromVertex(t);if(s===r.n)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,u))continue;const o=this.getCombinedHalfEdgeParentage(s);if(this.isGoodParentage(o)){const t=0===n;this.restorePolylineParts(s,m,u,l,e,c,g,d,t,i)}}}let _=r.n;if(s){_=o.createGeometry(n.G.enumMultiPoint);let t=r.n;for(let s=this.m_topoGraph.getFirstCluster();s!==r.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)){t===r.n&&(t=o.insertPath(_,r.n));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==r.n){let i;this.m_topoGraph.getVertexFromVertexIterator(n),i=-1!==c?this.chooseVertexByOrder(s,o,c,g):this.chooseVertexFromCluster_(s,e),o.addVertex(t,i)}}}}return-1!==g&&o.removeUserIndex(g),-1!==c&&o.removeUserIndex(c),-1!==l&&o.removeUserIndex(l),this.m_topoGraph.deleteUserIndexForHalfEdges(u),(0,a.l)(m,_)}difference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),o=(0,n.u)(s),a=(0,n.u)(i);if(o>a)return t;const h=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,2===o&&2===a){let s=r.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=t),this.topoOperationPolygonPolygon_(t,e,s)}if(1===o&&2===a){const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,r.n,!1,e).first}if(1===o&&1===a){const e={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,r.n,!1,e).first}if(0===o)return this.topoOperationMultiPoint_();(0,n.d)("")}symmetricDifference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),o=vs(s),a=vs(i),h=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);return(0,n.g)(h>=0),(0,n.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===o&&2===a?this.topoOperationPolygonPolygon_(t,e,r.n):1===o&&1===a?this.topoOperationPolyline_(r.n,this.m_bOGCOutput):0===o&&0===a?this.topoOperationMultiPoint():void(0,n.d)("")}planarSimplifyNoCrackingAndCluster(t,e,s,i){this.m_bOGCOutput=t,this.m_topoGraph=new Z;const o=e.getFillRule(s),a=e.getGeometryType(s);if(1!==o||a===n.G.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(e,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const h=this.m_topoGraph.getGeometryID(s);if((0,n.g)(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=h+1,this.m_maskLookup[h]=!0,e.getGeometryType(s)===n.G.enumPolygon||1===o&&e.getGeometryType(s)!==n.G.enumMultiPoint){e.setFillRule(s,0);const n=this.topoOperationPolygonPolygon_(s,r.n,r.n);if(e.swapGeometry(n,s),e.removeGeometry(n),1===o&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(t,e,s,i)}else if(e.getGeometryType(s)===n.G.enumPolyline){const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=i;const n=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),t);e.swapGeometry(n,s),e.removeGeometry(n)}else if(e.getGeometryType(s)===n.G.enumMultiPoint){const t=this.topoOperationMultiPoint_();e.swapGeometry(t,s),e.removeGeometry(t)}else(0,n.d)("");return!0}unsplitPolylineExact(t){return(0,n.g)(0),new r.P}planarSimplifyPolylines(t,e,s,i,o){for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,n.g)(s===n.G.enumPolyline)}let a=0,h=0,m=null;if(t.hasCurves()&&!t.hasSegmentParentage()){m=new us;const s=t.getEnvelope2D(this.m_progressTracker);h=ms(e.total());const n=hs(e.total(),s);a=ls(n,h),rs(t,n,e.total(),0,m,null,this.m_progressTracker)}{const s=ps(e.add(a));t.filterClosePoints(s,!1,!1,!1,r.n)}if(this.m_topoGraph=new Z,4!==o&&5!==o)if(null===m&&s){const n=new Pt(this.m_progressTracker,!1);n.sweepVertical(t,e.total()),n.hadComplications()?(gs(t,e,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else gs(t,e.add(a),this.m_progressTracker,!0,!1),s=!1;else s=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const l=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,n.g)(s&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(t,e,!1,i,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(l);(0,n.g)(u>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=u+1,this.m_maskLookup[u]=!0;const c=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),i);null!==m&&m.stitchCurves(t,c,h,!0);const g=t.getGeometry(c);return s||g.getImpl().setIsSimple(4,e.total()),g}planarSimplifyMultiPoints(t,e,s,i){for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,n.g)(s===n.G.enumMultiPoint)}this.m_topoGraph=new Z,4!==i&&5!==i?(gs(t,e,this.m_progressTracker,!0,!1),s=!1):s=!1,t.removeSelection(),t.collapseAllGeometriesToFirst();const o=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,o,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,n.g)(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(t,e,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const a=this.m_topoGraph.getGeometryID(o);(0,n.g)(a>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=a+1,this.m_maskLookup[a]=!0;const h=this.topoOperationMultiPoint(),m=t.getGeometry(h);return s||m.getImpl().setIsSimple(4,e.total()),m}planarSimplifyPolygons(t,e,s,i,o,a){for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e)){const i=t.getGeometryType(e);(0,n.g)(i===n.G.enumPolygon||i===n.G.enumPolyline&&s)}let h=0,m=0,l=null;if(t.hasCurves()&&!t.hasSegmentParentage()){l=new us;const s=t.getEnvelope2D(this.m_progressTracker);m=ms(e.total());const n=hs(e.total(),s);h=ls(n,m),rs(t,n,e.total(),0,l,null,this.m_progressTracker)}if(a){gs(t,e.add(h),this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==r.n;e=t.getNextGeometry(e))t.getGeometryType(e)===n.G.enumPolygon&&qt(t,e,-1,!1,r.n,this.m_progressTracker)}if(this.m_topoGraph=new Z,a||4===o||5===o)i=!1;else if(null===l&&i){const s=new Pt(this.m_progressTracker,!1);s.sweepVertical(t,e.total()),s.hadComplications()?(gs(t,e,this.m_progressTracker,!0,!1),i=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else gs(t,e.add(h),this.m_progressTracker,!0,!1),i=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const u=t.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(t,u,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,u,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,n.g)(i&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(t,e,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const c=this.m_topoGraph.getGeometryID(u);(0,n.g)(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0,t.setFillRule(u,0);const g=this.m_bOGCOutput&&s,d=g;let _=this.topoOperationPolygonPolygon_(u,r.n,r.n,d);g&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,t.removeGeometry(u),this.m_topoGraph=new Z,this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,_,this.m_progressTracker),_=this.topoOperationPolygonPolygon_(_,r.n,r.n,!1)),null!==l&&l.stitchCurves(t,_,m,!0);const p=t.getGeometry(_);return p.setFillRule(0),i?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,e.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(t,e,s,i,r){return(0,n.g)(0),{}}planarSimplifyImpl_(t,e,s,i,a,h,m,l){if(t.isEmpty())return t.clone();const u=t.getGeometryType(),c=new r.E,g=c.addGeometry(t);if((0,o.p)(a)&&u===n.G.enumPolygon&&(s=!1,c.setFillRule(g,0)),l&&(t.hasAttribute(1)&&c.replaceNaNs(1,0),c.removeNaNVertices()),u===n.G.enumPolygon||u===n.G.enumPolyline&&s)return this.planarSimplifyPolygons(c,e,s,i,a,!1);if(u===r.P.type){const t={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=m,this.planarSimplifyPolylines(c,e,i,t,a)}if(u===n.G.enumMultiPoint)return this.planarSimplifyMultiPoints(c,e,i,a);(0,n.d)("what else?")}}function qs(t,e,s,i){const a=t.getGeometryType();if(a===n.G.enumEnvelope){const e=new r.a({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(a===n.G.enumPoint&&("|"===i||"^"===i)){const e=new r.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(a===n.G.enumLine){const e=new r.P({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}if(a===n.G.enumMultiPoint&&"-"===i&&e.getGeometryType()===n.G.enumPoint){const e=new o.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}if(a===n.G.enumMultiPoint&&"&"===i&&e.getGeometryType()===n.G.enumPoint){const e=new o.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}return t}function Ms(t){const e=t.getGeometryType();if(e===n.G.enumEnvelope){const e=new r.a({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===n.G.enumPoint){const e=new r.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(Cs(e)){const e=new r.P({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==n.G.enumMultiPoint&&e!==n.G.enumPolyline&&e!==n.G.enumPolygon&&(0,n.a)("Unexpected geometry type"),t}function Fs(t,e,s,i){const o=s===r.n?t.getClusterHalfEdge(e):s;let a=o;(0,n.g)(t.getHalfEdgeOrigin(o)===e);do{i(a),a=t.getHalfEdgeNext(t.getHalfEdgeTwin(a))}while(a!==o)}class Xs{constructor(t,e,s,n,i,o){this.m_rParent=t,this.m_rTopoGraph=t.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(i),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=e,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=i,this.m_rCutHandles=o,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==r.n;t=this.m_rShape.getNextPath(t)){let e=0;const s=this.m_rShape.getPathSize(t);for(let n=this.m_rShape.getFirstVertex(t);e<s;e++,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(t){return 8|t}classifyStandardCut(t,e,s,n){const i=this.m_rShape.getPrevVertex(t),o=this.m_rShape.getNextVertex(t),a=i===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i)),h=o===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(o)),m=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n));let u=1,c=32,g=32;if(Fs(this.m_rTopoGraph,e,l,t=>{t===m&&(u=2),t===a&&(c=u),t===h&&(g=u)}),this.m_bConsiderTouch)32!==c&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|c),32!==g&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g);else{if(32===c||32===g)return 1;if(c===g&&a!==m&&a!==l&&h!==m&&h!==l)return 1;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|c),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g)}return 0}classifyTouchCut(t,e,s,n){const i=this.m_rShape.getPrevVertex(t),o=this.m_rShape.getNextVertex(t),a=i===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i)),h=o===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(o)),m=s===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=n===r.n?r.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let e;return(e=m===a||l===a)?this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))):(e=m===h||l===h)&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),e?0:1}if(a===r.n)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(h===r.n)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(l!==r.n){if(a===l)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(h===l)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let s=1;Fs(this.m_rTopoGraph,e,l,e=>{if(e===a){const t=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,t),s=2}else if(e===h){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=2}})}else{if(a===m)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(h===m)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let s=2;Fs(this.m_rTopoGraph,e,m,e=>{if(e===a){const t=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,t),s=1}else if(e===h){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=1}})}return 0}classifyCutVertex(t,e){let s=0,n=0;for(let i=this.m_rTopoGraph.getClusterVertexIterator(e);i!==r.n;i=this.m_rTopoGraph.incrementVertexIterator(i)){const o=this.m_rTopoGraph.getVertexFromVertexIterator(i);if(this.m_rShape.getGeometryFromVertex(o)===this.m_cutter){n++;const i=this.m_rShape.getPrevVertex(o),a=this.m_rShape.getNextVertex(o);s+=i===r.n||a===r.n?this.classifyTouchCut(t,e,i,a):this.classifyStandardCut(t,e,i,a)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(t,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==r.n;t=this.m_rShape.getNextPath(t)){const e=this.m_rShape.getPathSize(t);let s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,0);s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s)){const t=this.m_rTopoGraph.getClusterFromVertex(s);this.m_rTopoGraph.getClusterParentage(t)===this.m_IDBoth&&this.classifyCutVertex(s,t)}}const t=(t,e)=>{let s=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(t),this.m_rTopoGraph.getClusterFromVertex(e));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==r.n;e=this.m_rShape.getNextPath(e)){let s=this.m_rShape.getFirstVertex(e);const n=this.m_rShape.isClosedPath(e),i=this.m_rShape.getPathSize(e)+(n?1:0);let r=1,o=32;for(let e=this.m_rShape.getNextVertex(s);r<i;++r,s=e,e=this.m_rShape.getNextVertex(e)){const n=t(s,e);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(e);let a=32;r=1;for(let e=this.m_rShape.getPrevVertex(s);r<i;++r,s=e,e=this.m_rShape.getPrevVertex(e)){const n=t(e,s);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=n),32!==a&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,a|n)}}let e=r.n,s=r.n,i=32;const o=this.m_rShape.hasSegmentParentage(),a=new r.S;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==r.n;t=this.m_rShape.getNextPath(t)){const h=this.m_rShape.isClosedPath(t),m=this.m_rShape.getPathSize(t)+(h?1:0);let l=1,u=this.m_rShape.getFirstVertex(t),c=r.n,g=!0;for(let t=this.m_rShape.getNextVertex(u);l<m;++l,t=this.m_rShape.getNextVertex(t)){let h=this.m_rShape.getUserIndex(u,this.m_cutteeBreadcrumbsIndex);8===h?h=3:(h&=-9,4&h?h=4:3&~h||(h=3)),h!==i?(e!==r.n&&(c=this.m_rShape.addVertex(s,u),o&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i)),e=this.m_rShape.createGeometry(n.G.enumPolyline),s=this.m_rShape.insertPath(e,r.n),i=h,g=!0):this.m_rShape.getUserIndex(u,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==h&&(c=this.m_rShape.addVertex(s,u),o&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),s=this.m_rShape.insertPath(e,r.n),g=!0),c=this.m_rShape.addVertex(s,u);const m=this.m_rTopoGraph.getClusterFromVertex(u);!g&&o&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(c,!0);const l=this.m_rTopoGraph.getHalfEdgeFromVertex(u);if(o){const t=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(c,t,g||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,a),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(c),a.get().clone())),u=t,g=!1}c=this.m_rShape.addVertex(s,u),o&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i),e=r.n,s=r.n,i=32}}}function Vs(t,e,s,a,h){if(a&&(a.m_reason=0,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),t.isEmpty())return 5;const m=t.getGeometryType();if(m===n.G.enumPoint)return Ls(t,a);const l=(0,o.b)(e,t,!1).total();if(m===n.G.enumEnvelope){const e=t,s=new i.Envelope2D;return e.queryEnvelope(s),s.isDegenerate(l)?(a&&(a.m_reason=4,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),0):5}if((0,n.f)(m)){const n=t,i=new r.P({vd:n.getDescription()});return i.addSegment(n,!0),Vs(i,e,s,a,h)}(0,n.x)(m),(0,n.i)(m)||(0,n.t)("OGC simplify is not implemented for this geometry type");const u=t.getImpl().getIsSimple(l,[0]);let c=s?-1:u;if(5===c||0===c)return c;const g=new Qs(t,e,c,h,!0);return m===n.G.enumMultiPoint||m===n.G.enumPolyline||m===n.G.enumPolygon?(c=g.isSimplePlanarImpl(),(0,o.i)(c)&&(c=5)):(0,n.d)(""),t.getImpl().setIsSimple(c,l),a&&a.assign(g.m_nonSimpleResult),c}function Ys(t,e,s,a,h){if(a&&(a.m_reason=0,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),t.isEmpty())return 5;const m=t.getGeometryType();if(m===n.G.enumPoint)return Ls(t,a);const l=(0,o.b)(e,t,!1).total();if(m===n.G.enumEnvelope){const e=t,s=i.Envelope2D.constructEmpty();return e.queryEnvelope(s),s.isDegenerate(l)?(a&&(a.m_reason=4,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),0):5}if((0,n.f)(m)){const n=t,i=new r.P({vd:n.getDescription()});return i.addSegment(n,!0),Ys(i,e,s,a,h)}const u=t.getImpl().getIsSimple(l,[0]);let c=s?-1:u;if(-1!==c)return c;const g=new Qs(t,e,c,h,!1);return m===n.G.enumMultiPoint?c=g.multipointIsSimpleAsFeature():m===n.G.enumPolyline?c=g.polylineIsSimpleAsFeature():m===n.G.enumPolygon?c=g.polygonIsSimpleAsFeature():(0,n.d)(""),t.getImpl().setIsSimple(c,l),a&&a.assign(g.m_nonSimpleResult),c}function Rs(t,e,s,a){if(t.isEmpty())return t;const h=t.getGeometryType();if(h===n.G.enumPoint){const e=new g.NonSimpleResult;if(Ls(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(h===n.G.enumEnvelope){const s=(0,o.b)(e,t,!0).total(),n=t,r=i.Envelope2D.constructEmpty();return n.queryEnvelope(r),r.isDegenerate(s)?n.createInstance():t}if((0,n.f)(h)){const n=t,i=new r.P({vd:n.getDescription()});return i.addSegment(n,!0),Rs(i,e,s,a)}(0,n.x)(h);const m=(0,o.b)(e,t,!1).total(),l=t.getImpl().getIsSimple(m,[0]),u=s?-1:l;if((0,o.i)(u)){if(h===n.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}if((h===n.G.enumMultiPoint||h===n.G.enumPolyline)&&u>=1)return t;const c=new Qs(t,e,u,a,!1);let d;return h===n.G.enumMultiPoint?d=c.multipointSimplifyAsFeature():h===n.G.enumPolyline?d=c.polylineSimplifyAsFeature():h===n.G.enumPolygon?d=c.polygonSimplifyAsFeature():(0,n.d)(""),d}function ks(t,e,s,a){if(t.isEmpty())return t;const h=t.getGeometryType();if(h===n.G.enumPoint){const e=new g.NonSimpleResult;if(Ls(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(h===n.G.enumEnvelope){const s=t,n=new i.Envelope2D;s.queryEnvelope(n);const r=(0,o.b)(e,t,!0).total();return n.isDegenerate(r)?s.createInstance():t}if((0,n.f)(h)){const n=t,i=new r.P({vd:n.getDescription()});return i.addSegment(n,!0),ks(i,e,s,a)}(0,n.x)(h),(0,n.i)(h)||(0,n.t)("OGC simplify is not implemented for this geometry type");const m=(0,o.b)(e,t,!1).total(),l=t.getImpl().getIsSimple(m,[0]),u=s?-1:l;if(5===u){if(h===n.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}return bs(t,(0,o.b)(e,t,!0),!1,u,a,0,!0)}function Ls(t,e){const s=t.getX(),n=t.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return e&&(e.m_reason=2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0;if(t.hasAttribute(1)){const s=t.getZ();if(!Number.isFinite(s))return e&&(e.m_reason=Number.isNaN(s)?3:2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0}return 5}class Bs{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(t){this.m_flags&=-2,this.m_flags=this.m_flags|(t?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function Hs(t,e,s,n,i){return{x:t,y:e,ipath:s,ivertex:n,ipolygon:i}}function zs(t,e){return t.x===e.x&&t.y===e.y&&t.ipath===e.ipath&&t.ivertex===e.ivertex&&t.ipolygon===e.ipolygon}function Us(t,e){t.x=e.x,t.y=e.y,t.ipath=e.ipath,t.ivertex=e.ivertex,t.ipolygon=e.ipolygon}function Os(t,e,s,n,i,r){return{x:t,y:e,ipath:s,ivertex:n,bBoundary:i,bEndPoint:r}}function Ws(t,e){t.x=e.x,t.y=e.y,t.ipath=e.ipath,t.ivertex=e.ivertex,t.bBoundary=e.bBoundary,t.bEndPoint=e.bEndPoint}class js extends o.F{constructor(t){super(),this.m_helper=t}compare(t,e,s){const n=t.getElement(s),i=this.m_helper.m_xy.read(2*e)-this.m_helper.m_xy.read(2*n);return i<0?-1:i>0?1:0}}class Zs extends o.F{constructor(t){super(),this.m_helper=t}compare(t,e,s){const n=t.getElement(s),i=this.m_helper.m_edges[e],r=this.m_helper.m_edges[n],o=i.getReversed(),a=r.getReversed();let h=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const t=o?i.m_segment.getStartY():i.m_segment.getEndY(),e=a?r.m_segment.getStartY():r.m_segment.getEndY(),s=Math.min(t,e);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),h=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return h<m?-1:h>m?1:0}}class Qs{constructor(t,e,s,n,i){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new o.I,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new o.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 g.NonSimpleResult,this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=t,this.m_knownSimpleResult=s,this.m_sr=e;const r=(0,o.b)(e,t,!1);this.m_toleranceIsSimple=r,this.m_toleranceIsSimpleClustering=(0,o.e)(r),this.m_toleranceIsSimpleCracking=(0,o.l)(r),this.m_toleranceSimplify=(0,o.b)(e,t,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=i,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const t=this.m_geometry.getGeometryType();return(0,n.h)(t)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?(0,n.h)(t)?this._CheckCracking()?this.m_geometry.getGeometryType()===n.G.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return(0,n.g)(0),7}generateSortedPairs(t){let e=null;(0,n.h)(t.getGeometryType())&&(e=t);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==e,i=t.getPointCount();this.m_xy=t.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new o.A(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let t=0;t<i;t++)if(this.m_pairs.push(2*t),this.m_pairs.push(2*t+1),this.m_pairIndices.add(2*t),this.m_pairIndices.add(2*t+1),s){for(;t>=e.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const h=new o.B,m={parent:this,workPt:new a.P,userSort(t,e,n){n.sort(t,e,(t,e)=>this.parent.compareVerticesForPlanarClustering(t,e,s))},getValue(t){const e=this.parent.m_pairs[t],s=e>>1;return this.parent.m_xy.queryPoint2D(2*s,this.workPt),this.workPt.y+(1&e?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};h.sort(this.m_pairIndices,0,2*i,m)}_TestToleranceDistancePlanar(t,e){const s=this.m_xy.read(2*t),n=this.m_xy.read(2*t+1),i=this.m_xy.read(2*e),r=this.m_xy.read(2*e+1);return!st(s,n,i,r,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||0!==this.m_geometry.getDimension()&&s===i&&n===r}checkStructure(){const t=this.m_geometry.getGeometryType();if((0,n.h)(t)){const t=this.m_geometry.getImpl(),e=this.m_geometry.getGeometryType()===n.G.enumPolygon?3:2;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)<e){if(t.hasNonLinearSegments()&&t.hasNonLinearSegmentsPath(s)&&t.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new g.NonSimpleResult(1,s,0),!1}}if((0,n.i)(t)){const t=this.m_geometry.getImpl(),e=t.getAttributeStreamRef(0);for(let s=0,n=t.getPointCount();s<n;s++)if(!e.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new g.NonSimpleResult(2,s,0),!1;if(this.m_geometry.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,n=t.getPointCount();s<n;s++){const t=e.read(s);if(!Number.isFinite(t))return Number.isNaN(t)?this.m_nonSimpleResult=new g.NonSimpleResult(3,s,0):this.m_nonSimpleResult=new g.NonSimpleResult(2,s,0),!1}}}return!0}checkDegenerateSegments(t){const e=this.m_geometry.getImpl(),s=e.querySegmentIterator(),n=e.hasAttribute(1),i=n?(0,o.m)(this.m_sr,e,!1).total():0,r=e.hasNonLinearSegments(),a=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment();let o=e.calculateLowerLength2D();if(!(o>a||r&&e.isCurve()&&(o=e.calculateLength2D(),o>a))){if(t&&n){const t=e.getStartAttributeAsDbl(1,0),s=e.getEndAttributeAsDbl(1,0);if(Math.abs(s-t)>i)continue}return this.m_nonSimpleResult=new g.NonSimpleResult(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return(0,n.g)(0),!1}_CheckClustering(){const t=this.m_geometry.getImpl();this.generateSortedPairs(t);const e=t.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new js(this)),this.m_AET.setCapacity(e);for(let t=0,s=2*e;t<s;t++){this.progress_();const e=this.m_pairIndices.read(t),s=this.m_pairs[e],n=s>>1;if(1&s){const t=this.m_AET.search(n),e=this.m_AET.getPrev(t),s=this.m_AET.getNext(t);if(this.m_AET.deleteNode(t),e!==o.T.st_nullNode()&&s!==o.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new g.NonSimpleResult(5,this.m_AET.getElement(e),this.m_AET.getElement(s)),!1}else{const t=this.m_AET.addElement(n),e=this.m_AET.getPrev(t);if(e!==o.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),n))return this.m_nonSimpleResult=new g.NonSimpleResult(5,n,this.m_AET.getElement(e)),!1;const s=this.m_AET.getNext(t);if(s!==o.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new g.NonSimpleResult(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const t=this.m_geometry.getImpl(),e=t.getPointCount();return!t.hasNonLinearSegments()&&e<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new r.E,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new us;const t=i.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(t);const e=hs(this.m_toleranceSimplify.total(),t),s=new g.NonSimpleResult;if(function(t,e,s,n,i,r,o,a){t.hasCurves()?(t.setCurveStitcherPointer(r),r.m_impl=new cs(a,!0,i),r.m_impl.buildMonotonicCurveParentage(t,e,s,null),_s(t,s,a)):r.m_impl=null}(this.m_editShape,e,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 t=new g.NonSimpleResult;return vt(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,t,this.m_progressTracker)?(null!=this.m_curveStitcher?(t.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex1),t.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex2),this.m_curveStitcher=null):(t.m_vertexIndex1=this.m_editShape.getVertexIndex(t.m_vertexIndex1),t.m_vertexIndex2=this.m_editShape.getVertexIndex(t.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(t),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator();for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(!e.isLastSegmentInPath()||!e.isLastPath()){s.resetTo(e);do{for(;s.hasNextSegment();){const n=s.nextSegment(),i=(0,r.H)(!0,t,n,this.m_toleranceIsSimpleCracking,!0);if(i){const t=2===i?7:6;return this.m_nonSimpleResult=new g.NonSimpleResult(t,e.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let t=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),t=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(t)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=t.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const e=[],s=t.getPointCount();let n=Number.NaN,i=0;for(let t=0,r=2*s;t<r;t++){this.progress_();const s=this.m_pairIndices.read(t),r=this.m_pairs[s];if(1&r)continue;const o=r>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(e.length&&(a!==n||h!==i)){if(!this.processBunchForSelfIntersectionTest(e))return!1;e.length=0}e.push(o),n=a,i=h}return!!this.processBunchForSelfIntersectionTest(e)}checkSelfIntersectionsPolylinePlanar(){const t=this.m_geometry.getImpl(),e=[];for(let s=0,n=t.getPathCount();s<n;s++)e.push(t.isClosedPathInXYPlane(s));const s={x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1};let n,i,r;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,h=this.m_xy.readPoint2D(2*a),m=this.m_pathsForOGCTests[a];n=e[m],i=t.getPathStart(m),r=t.getPathEnd(m)-1,s.bEndPoint=a===i||a===r,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),u=this.m_pathsForOGCTests[m];let c;u!==s.ipath&&(n=e[u],i=t.getPathStart(u),r=t.getPathEnd(u)-1);const d=m===i||m===r;c=this.m_bOGCRestrictions?!n&&d:d;const _=Os(l.x,l.y,u,m,c,d);if(_.x===s.x&&_.y===s.y)if(this.m_bOGCRestrictions){if(!(_.bBoundary&&s.bBoundary||_.ipath===s.ipath&&_.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new g.NonSimpleResult(10,_.ivertex,s.ivertex),!1}else if(!_.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new g.NonSimpleResult(7,_.ivertex,s.ivertex),!1;Ws(s,_)}return!0}checkSelfIntersectionsPolylinePlanar3D(t){return(0,n.g)(0),!1}checkSelfIntersectionsPolygonsOGC(){const t=this.m_geometry.getImpl(),e=[];let s=-1,n=!1;for(let i=0,r=t.getPathCount();i<r;i++)t.isExteriorRingOGC(i)&&(n=!1,s++,i<r-1&&(t.isExteriorRingOGC(i+1)||(n=!0))),e.push(n?s:-1);const i={x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1};{const t=this.m_pairIndices.read(0),s=this.m_pairs[t]>>1,n=this.m_xy.readPoint2D(2*s),r=this.m_pathsForOGCTests[s];i.ipath=r,i.x=n.x,i.y=n.y,i.ivertex=s,i.ipolygon=e[r]}const r=[];for(let t=1,s=this.m_pairIndices.size();t<s;t++){const s=this.m_pairIndices.read(t),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=Hs(a.x,a.y,h,o,e[h]);if(m.x===i.x&&m.y===i.y){if(m.ipath===i.ipath)return this.m_nonSimpleResult=new g.NonSimpleResult(11,m.ivertex,i.ivertex),!1;e[m.ipath]>=0&&e[m.ipath]===e[i.ipath]&&(0!==r.length&&zs(r.at(-1),i)||r.push({...i}),r.push(m))}Us(i,m)}if(0===r.length)return!0;const h=new o.I(!0);e.fill(-1);let m=-1;const l=new a.P;for(let t=0,s=r.length;t<s;t++){const s=r[t];s.x===l.x&&s.y===l.y||(m=h.createList(0),l.x=s.x,l.y=s.y);let n=e[s.ipath];-1===n&&(n=h.createList(2),e[s.ipath]=n),h.addElement(n,m),h.addElement(m,n)}const u=[];for(let t=h.getFirstList();-1!==t;t=h.getNextList(t)){const s=h.getListData(t);if(1&s||!(2&s))continue;let n=-1;for(u.push(t),u.push(-1);u.length;){const t=u.at(-1);u.pop();const e=u.at(-1);u.pop();const s=h.getListData(e);if(1&s){n=2&s?e:t;break}h.setListData(e,1|s);for(let s=h.getFirst(e);-1!==s;s=h.getNext(s)){const n=h.getData(s);n!==t&&(u.push(n),u.push(e))}}if(-1!==n){const t=e.indexOf(n);return this.m_nonSimpleResult=new g.NonSimpleResult(12,t,-1),!1}}return!0}_CheckValidRingOrientation(){const t=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(t.calculateArea2D()<=0)return this.m_nonSimpleResult=new g.NonSimpleResult(8,1===t.getPathCount()?1:-1,-1),0;if(1===t.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new o.n(t.getPathCount(),0),this.m_pathParentage=new o.A(t.getPathCount(),-1);let e=-1,s=0;for(let n=0,i=t.getPathCount();n<i;n++){const i=t.calculateRingArea2D(n);if(this.m_pathOrientations.write(n,i<0?0:8),i>0)e=n,s=i;else{if(0===i)return this.m_nonSimpleResult=new g.NonSimpleResult(8,n,-1),0;if((e<0||s<Math.abs(i))&&(this.m_nonSimpleResult=new g.NonSimpleResult(9,n,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(n,e)}}this.m_unknownOrientationPathCount=t.getPathCount(),this.m_newEdges.length=0;const n=t.getPointCount();this.m_yScanline=Number.NaN;const i=[];this.m_xyToNode1=new o.A(n,o.T.st_nullNode()),this.m_xyToNode2=new o.A(n,o.T.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new Zs(this));for(let t=0,e=2*n;this.m_unknownOrientationPathCount>0&&t<e;t++){const e=this.m_pairIndices.read(t),s=this.m_pairs[e];if(1&s)continue;const n=s>>1,r=this.m_xy.read(2*n+1);if(r!==this.m_yScanline&&i.length){if(!this.processBunchForRingOrientationTest(i))return 0;i.length=0}i.push(n),this.m_yScanline=r}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(i)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(t){if(1===t.length)return!0;for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const i=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(i,s,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((t,e)=>this.edgeAngleCompare(t,e));let e=this.m_crossOverHelperList.getFirstList();-1===e&&(e=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let t=0,s=this.m_edges.length;t<s;t++)this.m_crossOverHelperList.addElement(e,t);let s=!0,n=-1,i=-1;for(;s;){s=!1;let t=this.m_crossOverHelperList.getFirst(e);if(-1===t)break;let r=this.m_crossOverHelperList.getNext(t);for(;-1!==r;){const o=this.m_crossOverHelperList.getData(t),a=this.m_crossOverHelperList.getData(r);if(n=this.m_edges[o].m_vertexIndex,i=this.m_edges[a].m_vertexIndex,n!==i)t=r,r=this.m_crossOverHelperList.getNext(t);else if(s=!0,this.m_crossOverHelperList.deleteElement(e,t),t=this.m_crossOverHelperList.getPrev(r),r=this.m_crossOverHelperList.deleteElement(e,r),-1===r||-1===t)break}}const r=this.m_crossOverHelperList.getListSize(e);if(this.m_crossOverHelperList.clear(e),r>0)return this.m_nonSimpleResult=new g.NonSimpleResult(7,n,i),!1;for(let e=0,s=t.length;e<s;e++)this.recycleEdge(this.m_edges[e]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(t){for(let e=0,s=t.length;e<s;e++){const s=t[e];let n=this.m_xyToNode1.read(s);if(n!==o.T.st_nullNode()){const t=this.m_AET.getElement(n);this.m_freeEdges.push(t),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode1.write(s,o.T.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==o.T.st_nullNode()){const t=this.m_AET.getElement(n);this.m_freeEdges.push(t),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode2.write(s,o.T.st_nullNode())}}for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const t=this.m_recycledSegIter.getStartPointIndex(),e=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let i;this.m_freeEdges.length>0?(i=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[i]=e):(i=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(i);this.m_xyToNode1.read(t)===o.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}this.m_recycledSegIter.nextSegment();const i=this.m_recycledSegIter.nextSegment();if(i.getStartY()<i.getEndY()){const t=this.m_recycledSegIter.getEndPointIndex(),e=this.createEdge(i,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]=e):(n=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(n);this.m_xyToNode1.read(t)===o.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}}for(let t=0,e=this.m_newEdges.length;t<e&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let t=-1,s=this.m_AET.getPrev(e),n=e,i=0;{let e=-1,r=null,a=-1,h=0;for(;s!==o.T.st_nullNode()&&(e=this.m_AET.getElement(s),r=this.m_edges[e],a=r.m_pathIndex,h=this.m_pathOrientations.read(a),!(3&h));)n=s,s=this.m_AET.getPrev(s);s===o.T.st_nullNode()?(i=1,s=n):(t=1==(3&h)?a:this.m_pathParentage.read(a),i=r.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),r=this.m_edges[e],o=r.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(i!==r.getRightSide())return this.m_nonSimpleResult=new g.NonSimpleResult(8,o,-1),!1;const e=i&&!r.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new g.NonSimpleResult(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),i=i?0:1}while(n!==e)}}return this.m_newEdges.length=0,!0}createEdge(t,e,s,i){let r;return t.getGeometryType()===n.G.enumLine?r=this.createEdgeLine(t):(r=new Bs,r.m_segment=t.clone()),r.m_vertexIndex=e,r.m_pathIndex=s,r.m_flags=0,r.setReversed(i),r}createEdgeLine(t){let e;return this.m_lineEdgesRecycle.length>0?(e=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),t.copyTo(e.m_segment)):(e=new Bs,e.m_segment=t.clone()),e}recycleEdge(t){t.m_segment.getGeometryType()===n.G.enumLine&&this.m_lineEdgesRecycle.push(t)}static isShortSegment(t,e,s,n){let i=t.calculateLowerLength2D();if(i<=s){let r=!0;if(t.isCurve()&&(i=t.calculateLength2D(),r=i<=s),r){if(e){let e=t.getEndAttributeAsDbl(1,0);Number.isNaN(e)&&(e=0);let s=t.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-e)<=n}return!0}return!1}return!1}static isShortSegmentPoints(t,e,s,n,i){if(s){const s=t.getXYZ(),r=e.getXYZ();return(0,o.o)(s,r,n,i)}{const s=t.getXY(),i=e.getXY();return a.P.sqrDistance(s,i)<=n*n}}removeDegenerateSegmentsFromCurvedPath(t,e,s,i){const r=t.hasAttribute(1),h=t.querySegmentIterator();h.resetToPath(e),(0,n.g)(h.nextPath());const m=this.m_toleranceSimplify.total();let l=!1,u=!0;const c=new o.P,g=new o.P,d=new a.P;for(;h.hasNextSegment();){this.progress_();const t=h.nextSegment();if(Qs.isShortSegment(t,r,m,s))if(l){if(t.queryEnd(g),Qs.isShortSegmentPoints(c,g,r,m,s))continue;u&&(i.startPathPoint(c),u=!1),t.queryEnd(c),i.lineToPoint(c),l=!1}else d.assign(t.getStartXY()),t.queryStart(c),l=!0;else if(l)if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(d,t.getEndXY(),!1),e.setStart(c),Qs.isShortSegment(e,r,m,s))continue;i.addSegment(e,u),u=!1,l=!1}else{if(t.queryEnd(g),Qs.isShortSegmentPoints(c,g,r,m,s))continue;u&&(i.startPathPoint(c),u=!1),i.lineToPoint(g),l=!1}else i.addSegment(t,u),u=!1}if(u)return;if(!l)return;t.isClosedPath(e)?t.getPointByVal(t.getPathStart(e),c):t.getPointByVal(t.getPathEnd(e)-1,c);const _=i.querySegmentIterator();_.resetToLastPath(),_.resetToLastSegment();const p=i.getDescription().getAttributeCount()>1;for((0,n.g)(_.previousPath());_.hasPreviousSegment();){const t=_.previousSegment();if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(t.getStartXY(),c.getXY(),!1),!Qs.isShortSegment(e,r,m,s)){p&&e.setEnd(c);const t=_.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.addSegment(e,!1)}}else if(t.queryStart(g),!Qs.isShortSegmentPoints(g,c,r,m,s)){const t=_.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.lineToPoint(c)}}i.removePath(i.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const t=this.m_geometry.getImpl();this.m_multiVertexGeom=t;const e=t.getPointCount(),s=(0,a.d)(e,0);for(let t=0;t<e;t++)s[t]=t;s.sort((t,e)=>this.compareVerticesMultiPoint(t,e));for(let t=1;t<e;t++)if(0===this.compareVerticesMultiPoint(s[t-1],s[t]))return this.m_nonSimpleResult=new g.NonSimpleResult(5,s[t-1],s[t]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let t=this.m_geometry.getImpl();const e=Qs.hasNanZs(t);let s,n=this.m_geometry;e&&(s=this.m_geometry.clone(),t=s.getImpl(),s.replaceNaNs(1,o.V.getDefaultValue(1)),n=s),this.m_multiVertexGeom=t;const i=t.getPointCount(),r=(0,a.d)(i,0);for(let t=0;t<i;t++)r[t]=t;r.sort((t,e)=>this.compareVerticesMultiPoint(t,e));const h=new Array(i);h.fill(!1);let m=-1;for(let e=0;e<i;e++){const s=r[e];t.getXY(s).isFinite()&&((m<0||0!==this.compareVerticesMultiPoint(m,s))&&(h[s]=!0),m=s)}const l=this.m_geometry.createInstance();let u=0,c=0;for(let t=0;t<i;t++)h[t]?c=t+1:(u<c&&l.addPoints(n,u,c),u=t+1);return u<c&&l.addPoints(n,u,c),l.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),l}polylineSimplifyAsFeature(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator(),n=this.m_geometry.createInstance(),i=this.m_geometry,r=t.hasAttribute(1),h=r?(0,o.m)(this.m_sr,t,!0).total():0,m=[],l=[];let u=null;r&&(u=t.getAttributeStreamRef(1));const c=new o.P,g=t.hasNonLinearSegments(),d=this.m_toleranceSimplify.total();for(;e.nextPath();){if(s.nextPath(),t.getPathSize(e.getPathIndex())<2)continue;if(g&&t.hasNonLinearSegmentsPath(e.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(t,e.getPathIndex(),h,n);continue}s.resetToLastSegment();let o=0,_=0,p=!0,f=!0;for(;e.hasNextSegment();){this.progress_();const n=e.nextSegment(),i=s.previousSegment();if(e.getStartPointIndex()>s.getStartPointIndex())break;if(p){const s=e.getStartPointIndex();t.getXY(s).isNAN()||(p=!1,m.push(s))}if(f){const e=s.getEndPointIndex();t.getXY(e).isNAN()||(l.push(e),f=!1)}if(!p){const s=m.at(-1),i=e.getEndPointIndex();if(i-s>1){const e=new a.P;e.setSub(t.getXY(s),t.getXY(i)),o=e.length()}else o=n.calculateLength2D();if(o>d)m.push(i),o=0;else if(r){let t=u.read(s);Number.isNaN(t)&&(t=0);let e=u.read(i);Number.isNaN(e)&&(e=0),Math.abs(e-t)>h&&(m.push(i),o=0)}}if(!f){const e=l.at(-1),n=s.getStartPointIndex();if(n-e>1){const s=new a.P;s.setSub(t.getXY(e),t.getXY(n)),_=s.length()}else _=i.calculateLength2D();if(_>d)l.push(n),_=0;else if(r){let t=u.read(e);Number.isNaN(t)&&(t=0);let s=u.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-t)>h&&(l.push(n),_=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 t=!1;for(let e=0,s=m.length;e<s;e++)i.getPointByVal(m[e],c),t?n.lineToPoint(c):(n.startPathPoint(c),t=!0);for(let e=l.length-1;e>0;e--)i.getPointByVal(l[e],c),t?n.lineToPoint(c):(n.startPathPoint(c),t=!0);i.isClosedPath(e.getPathIndex())?n.closePathWithLine():l.length>0&&(i.getPointByVal(l[0],c),n.lineToPoint(c))}m.length=0,l.length=0}return r&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,d),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!(0,o.p)(this.m_knownSimpleResult))return Is(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const t=new r.E;if(t.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&t.replaceNaNs(1,0),t.removeNaNVertices(),0!==t.getTotalPointCount()){let e=null,s=0,r=0;if(t.hasCurves()){e=new us;const n=i.Envelope2D.constructEmpty();this.m_geometry.queryEnvelope(n);const o=hs(this.m_toleranceSimplify.total(),n);s=ms(this.m_toleranceSimplify.total()),r=ls(o,s),rs(t,o,this.m_toleranceSimplify.total(),0,e,null,this.m_progressTracker)}(0,o.p)(this.m_knownSimpleResult)||gs(t,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1),this.m_geometry.getGeometryType()===n.G.enumPolygon&&qt(t,t.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==e&&e.stitchCurves(t,t.getFirstGeometry(),s,!0)}const e=t.getGeometry(t.getFirstGeometry());return e.getGeometryType()===n.G.enumPolygon&&(e.getImpl().updateOGCFlagsProtected(),e.setFillRule(0)),e.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),e}progress_(){}static hasNanZs(t){if(t.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,n=t.getPointCount();s<n;s++){const t=e.read(s);if(Number.isNaN(t))return!0}}return!1}compareVerticesForPlanarClustering(t,e,s){if(t===e)return 0;const n=this.m_pairs[t],i=this.m_pairs[e],r=n>>1,o=i>>1,h=this.m_xy.readPoint2D(2*r);h.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=this.m_xy.readPoint2D(2*o);m.y+=1&i?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const l=h.compare(m);if(0===l&&s){const t=this.m_pathsForOGCTests[r]-this.m_pathsForOGCTests[o];return(0,a.e)(t)}return l}compareVerticesMultiPoint(t,e){if(t===e)return 0;const s=this.m_multiVertexGeom.getXY(t),n=this.m_multiVertexGeom.getXY(e),i=!s.isFinite(),r=!n.isFinite();if(i||r)return i<r?-1:i>r?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),i=o.V.getComponentCount(n);for(let s=0;s<i;s++){const i=this.m_multiVertexGeom.getAttributeAsDbl(n,t,s),r=this.m_multiVertexGeom.getAttributeAsDbl(n,e,s),o=(0,a.r)(i,r);if(0!==o)return o}}return 0}edgeAngleCompare(t,e){if(t===e)return 0;const s=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&s.negateThis();const n=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&n.negateThis();const i=s.getQuarter(),r=n.getQuarter();if(r===i){const t=s.crossProduct(n);return t<0?1:t>0?-1:0}return i<r?-1:1}}class Ks{getOperatorType(){return 10103}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}isSimpleAsFeature(t,e,s,n,i){const r=Ys(t,e,s,n,i);return(0,o.k)(t.getGeometryType(),r)}isSimplePlanarDONOTUSE(t,e,s,a,h){const m=function(t,e,s,a,h){if(a&&(a.m_reason=0,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),t.isEmpty())return 5;const m=t.getGeometryType();if(m===n.G.enumPoint)return Ls(t,a);const l=(0,o.b)(e,t,!1).total();if(m===n.G.enumEnvelope){const e=t,s=new i.Envelope2D;return e.queryEnvelope(s),s.isDegenerate(l)?(a&&(a.m_reason=4,a.m_vertexIndex1=-1,a.m_vertexIndex2=-1),0):5}if((0,n.f)(m)){const n=t,i=new r.P({vd:n.getDescription()});return i.addSegment(n,!0),Ys(i,e,s,a,h)}const u=t.getImpl().getIsSimple(l,[0]);let c=s?-1:u;if((0,o.i)(c)||0===c)return c;const g=new Qs(t,e,c,h,!1);return m===n.G.enumMultiPoint||m===n.G.enumPolyline||m===n.G.enumPolygon?c=g.isSimplePlanarImpl():(0,n.d)(""),t.getImpl().setIsSimple(c,l),a&&a.assign(g.m_nonSimpleResult),c}(t,e,s,a,h);return(0,o.i)(m)}executeMany(t,e,s,n){return new $s(t,e,s,n)}execute(t,e,s,i){const r=new c.S([t]),o=this.executeMany(r,e,s,i).next();return o||(0,n.d)("null geometry"),o}}class $s extends c.G{constructor(t,e,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=t,this.m_spatialReference=e}next(){const t=this.m_inputGeometryCursor.next();return t?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(t)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(t){if(t||(0,n.a)(""),t.getGeometryType()===n.G.enumGeometryCollection){const e=(0,r.g)(t,-1),s=(new Ks).executeMany(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=t.createInstance();for(let t=s.next();null!=t;t=s.next())n.addGeometry(t);return n}return Rs(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}class Js{constructor(t,e,s,i){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=n.G.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=t,this.m_sr=e,this.m_dimensionMask=s,this.m_progressTracker=i,this.m_intersectorGeomType=t.getGeometryType()}intersect(t){const e=this.tryFastImplementation(t);if(null!==e)return e;const s=(0,o.g)(this.m_intersectorGeom,t),h=(0,o.c)(this.m_sr,s,!0).total(),m=i.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const u=i.Envelope2D.constructEmpty();t.queryEnvelope(u),m.inflateCoords(2*h,2*h),m.intersect(u),m.inflateCoords(100*h,100*h);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),g=(0,l.c)(t,m,0,0,this.m_progressTracker);return t.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,a.c)(g,g=c)),function(t,e,s,a){const h=i.Envelope2D.constructEmpty();t.queryEnvelope(h);const m=i.Envelope2D.constructEmpty();e.queryEnvelope(m);const l=i.Envelope2D.constructEmpty();l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const u=(0,o.c)(s,l,!0),c=new i.Envelope2D(m),g=(0,o.e)(u);if(c.inflateCoords(g,g),!h.isIntersecting(c)){if(t.getDimension()<=e.getDimension())return qs(Ms(t.createInstance()),t,0,"&");if(t.getDimension()>e.getDimension())return qs(Ms(e.createInstance()),t,0,"&")}const d=new Gs(a),_=new r.E,p=_.addGeometry(Ms(t)),f=_.addGeometry(Ms(e));let x=0,P=0,y=null;if(_.hasCurves()){y=new us;const t=_.getEnvelope2D(a);P=ms(u.total());const e=hs(u.total(),t);x=ls(e,P),rs(_,e,u.total(),0,y,null,a)}d.setEditShapeCrackAndCluster(_,u.add(x));const E=d.intersection(p,f);null!==y&&y.stitchCurves(_,E,P,!0);const C=qs(_.getGeometry(E),t,0,"&");return Es(C.getGeometryType())&&(C.getImpl().setIsSimple(4,u.total()),C.getGeometryType()===n.G.enumPolygon&&C.getImpl().updateOGCFlagsProtected()),C}(g,c,this.m_sr,this.m_progressTracker)}intersectEx(t){const e=this.tryFastImplementation(t);if(null!==e){const s=[];return s.length=3,s[e.getDimension()]=e,this.prepareVector(t.getDescription(),this.m_dimensionMask,s)}const s=(0,o.g)(this.m_intersectorGeom,t),h=(0,o.c)(this.m_sr,s,!0).total(),m=i.Envelope2D.constructEmpty();this.m_intersectorGeom.queryEnvelope(m);const u=i.Envelope2D.constructEmpty();t.queryEnvelope(u),m.inflateCoords(2*h,2*h),m.intersect(u),m.inflateCoords(100*h,100*h);let c=(0,l.c)(this.m_intersectorGeom,m,0,0,this.m_progressTracker),g=(0,l.c)(t,m,0,0,this.m_progressTracker);t.getDimension()>this.m_intersectorGeom.getDimension()&&(c=(0,a.c)(g,g=c));const d=function(t,e,s,a){const h=new Array(3),m=i.Envelope2D.constructEmpty();t.queryEnvelope(m);const l=i.Envelope2D.constructEmpty();e.queryEnvelope(l);const u=i.Envelope2D.constructEmpty();u.setCoords({env2D:m}),u.mergeEnvelope2D(l);const c=(0,o.c)(s,u,!0),g=new i.Envelope2D(l),d=(0,o.e)(c);if(g.inflateCoords(d,d),!m.isIntersecting(g)){if(t.getDimension()<=e.getDimension()){const e=qs(Ms(t.createInstance()),t,0,"&");return h[e.getDimension()]=e,h}if(t.getDimension()>e.getDimension()){const s=qs(Ms(e.createInstance()),t,0,"&");return h[s.getDimension()]=s,h}}const _=new Gs(a),p=new r.E,f=p.addGeometry(Ms(t)),x=p.addGeometry(Ms(e));let P=0,y=0,E=null;if(p.hasCurves()){E=new us;const t=p.getEnvelope2D(a);y=ms(c.total());const e=hs(c.total(),t);P=ls(e,y),rs(p,e,c.total(),0,E,null,a)}_.setEditShapeCrackAndCluster(p,c.add(P)),p.dbgVerifyCurves();const C=_.intersectionEx(f,x);for(const e of C){null!==E&&E.stitchCurves(p,e,y,!1);const s=qs(p.getGeometry(e),t,0,"&");Es(s.getGeometryType())&&(s.getImpl().setIsSimple(4,c.total()),s.getGeometryType()===n.G.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),h[s.getDimension()]=s}return null!==E&&E.clearStitcher(p),h}(g,c,this.m_sr,this.m_progressTracker);return this.prepareVector(t.getDescription(),this.m_dimensionMask,d)}init(t,e,s,i=null){(0,n.g)(0)}static intersectPoints(t,e,s){const n=(0,o.g)(t,e);return function(t,e,s){return t.isEmpty()||e.isEmpty()?t.createInstance():function(t,e,s){const n=(0,o.e)(t);return st(e.getX(),e.getY(),s.getX(),s.getY(),(0,a.a)(n))}(s,t,e)?new o.P({copy:ds(t,e)}):t.createInstance()}(t,e,(0,o.c)(s,n,!0))}tryFastImplementation(t){const e=t.getGeometryType();if(this.m_intersectorGeomType===n.G.enumPoint&&e===n.G.enumPoint){const e=Js.intersectPoints(t,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const t=new r.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}return e}if(e===n.G.enumEnvelope&&this.m_intersectorGeomType===n.G.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const e=t,s=this.m_intersectorGeom,n=new o.E({copy:e});return n.intersect(s),n}const s=(0,o.g)(t,this.m_intersectorGeom),a=(0,o.c)(this.m_sr,s,!0),h=t.isEmpty(),m=this.m_intersectorGeom.isEmpty();let u=h||m;if(!u){const e=function(t,e,s){const r=new i.Envelope2D;t.queryEnvelope(r);const o=new i.Envelope2D;e.queryEnvelope(o);const a=new i.Envelope2D(o);if(a.inflate(2*s),!a.isIntersecting(r))return 4;const h=t.getGeometryType(),m=e.getGeometryType();if(h===n.G.enumEnvelope&&r.containsEnvelope(a))return 1;if(m===n.G.enumEnvelope){const t=new i.Envelope2D(r);if(t.inflate(2*s),o.containsEnvelope(t))return 2}return 0}(this.m_intersectorGeom,t,a.total());if(4===e)u=!0;else{if(2&e)return this.m_intersectorGeom;if(1&e)return t}}if(u){const s=(0,n.u)(e),i=(0,n.u)(this.m_intersectorGeomType);return s<i?Js.ReturnEmpty(t,h):s>i||0===s&&e===n.G.enumMultiPoint&&this.m_intersectorGeomType===n.G.enumPoint?this.ReturnEmptyIntersector():Js.ReturnEmpty(t,h)}if(e===n.G.enumEnvelope&&0===(0,n.u)(this.m_intersectorGeomType)||this.m_intersectorGeomType===n.G.enumEnvelope&&0===(0,n.u)(e)){const s=e===n.G.enumEnvelope?t:this.m_intersectorGeom,r=e===n.G.enumEnvelope?this.m_intersectorGeom:t,o=i.Envelope2D.constructEmpty();return s.queryEnvelope(o),(0,l.c)(r,o,a.total(),0,this.m_progressTracker)}if(0===(0,n.u)(e)&&(0,n.u)(this.m_intersectorGeomType)>0||(0,n.u)(e)>0&&0===(0,n.u)(this.m_intersectorGeomType)){if(e===n.G.enumMultiPoint)return Ds(t,this.m_intersectorGeom,a);if(e===n.G.enumPoint)return Ts(t,this.m_intersectorGeom,a);if(this.m_intersectorGeomType===n.G.enumMultiPoint)return Ds(this.m_intersectorGeom,t,a);if(this.m_intersectorGeomType===n.G.enumPoint)return Ts(this.m_intersectorGeom,t,a);(0,n.d)("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(t,e){return e?t:t.createInstance()}prepareVector(t,e,s){let n=0;return 1&e?(s[0]||(s[0]=new r.M({vd:t})),n++):s.shift(),2&e?(s[n]||(s[n]=new r.P({vd:t})),n++):s.splice(n,1),4&e?s[n]||(s[n]=new r.a({vd:t})):s.splice(n,1),new c.S(s)}}class tn extends c.G{constructor(t,e,s,i,r){super(),this.m_smallCursor=null,this.m_progressTracker=i,this.m_geomIntersector=e.next(),this.m_intersector=new Js(this.m_geomIntersector,s,r,i),this.m_index=-1,this.m_inputGeoms=t,this.m_dimensionMask=r,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&(0,n.a)("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let t;if(null!==this.m_smallCursor){if(t=this.m_smallCursor.next(),t)return t;this.m_smallCursor=null}for(;t=this.m_inputGeoms.next();)return(0,n.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask?this.m_intersector.intersect(t):(this.m_smallCursor=this.m_intersector.intersectEx(t),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class en{getOperatorType(){return 1e4}accelerateGeometry(t,e,s){if(!this.canAccelerateGeometry(t))return!1;(0,o.b)(e,t,!0);let i=0;return t.getGeometryType()!==n.G.enumPolygon&&t.getGeometryType()!==n.G.enumPolyline||!(0,r.y)(t)||0===s||(i|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),!!i}canAccelerateGeometry(t){return(0,r.y)(t)}supportsCurves(){return!0}executeMany(t,e,s,n,i=-1){return new tn(t,e,s,n,i)}execute(t,e,s,i){if(t.getGeometryType()===n.G.enumPoint&&e.getGeometryType()===n.G.enumPoint)return Js.intersectPoints(t,e,s);const r=new c.S([t]),o=new c.S([e]),a=this.executeMany(r,o,s,i,-1).next();return a||(0,n.d)("null output"),a}}function sn(t,e,s){return e.m_projector.project(t,s)}function nn(t,e,s,n,i){return t.m_projector.transformInPlaceZ(e,null,s,n,null,i)}function rn(t,e,s,a){if(t&&e&&e.isPannable()||(0,n.a)("fold_into_360_range_geodetic"),t.isEmpty())return t;if(4===s)return on(t,e,a);let h=t;const m=h.getGeometryType();if((0,n.h)(m)){h=Ii(t,e);const n=new i.Envelope2D;h.queryEnvelope(n);const r=(0,o.c)(e,n,!1).total(),a=e.getPannableExtent();let m=Math.floor((n.xmin-a.xmin)/a.width())*a.width()+a.xmin,l=h;for(;m<n.xmax;)m>n.xmin+r&&m<n.xmax-r&&(l=Si(l,e,s,!0,m)),m+=a.width();h=l}else{if(m===n.G.enumEnvelope){const t=new r.a({vd:h.getDescription()});return t.addEnvelope(h,!1),rn(t,e,s,a)}if((0,n.f)(m)){const t=new r.P({vd:h.getDescription()});return t.addSegment(h,!0),rn(t,e,s,a)}}return on(h,e,a)}function on(t,e,s){if(t&&e&&e.isPannable()||(0,n.a)(""),t.isEmpty())return t;let i;const o=t.getGeometryType();if(o===n.G.enumEnvelope){const e=new r.a({vd:t.getDescription()});e.addEnvelope(t,!1),i=e}else if((0,n.f)(o)){const e=new r.P({vd:t.getDescription()});e.addSegment(t,!0),i=e}else i=t;const a=Ii(i,e);return a.isEmpty()?a:Pi(a,e,0,a!==t,0,s)}function an(t,e,s,n){const i=e.getXYGridRange(),r=t.hasAttribute(1),h=t.hasAttribute(2);let m=new a.E,u=new a.E;r&&(m=e.getZGridRange()),h&&(u=e.getMGridRange());let c=(new l.O).execute(t,i,s,n);if(r){const e=c.queryInterval(1,0);m.contains(e)||(t===c&&(c=c.clone()),(0,o.H)(c,m,1,0))}if(h){const e=c.queryInterval(2,0);u.contains(e)||(t===c&&(c=c.clone()),(0,o.H)(c,u,2,0))}return c}class hn{constructor(t){this.m_inputPCSHorizonClipOption=0,this.m_outputPCSHorizonClipOption=0,this.m_bDontGeonormalizePolygon=!1,this.m_bClipOutCurvedPoles=!1,this.m_bNormalizeOutputGeometry=!1,this.m_bDontHackPolesInGeogToGeog=!1,this.m_centralMeridianOfOutputGCS=0,this.m_densificationStepInput=0,t||(0,n.a)(""),this.m_projTransform=t,this.m_bClipOutCurvedPoles=!1;const e=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=e.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(e.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),e.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,e.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=e.centralMeridianOfOutputGCS,this.m_densificationStepInput=e.densificationStep;const s=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=s.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=s.hasFlag(1073741824),this.m_bClipOutCurvedPoles=s.hasFlag(536870912)}project(t,e){if(this.m_projTransform.isIdentity()||t.isEmpty())return t;const s=t.getGeometryType();if(s===n.G.enumPoint)return this.projectPoint(t,e);const i=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),a=this.m_projTransform.getOutputSR();if(0===i&&i===r){const e=ln(o,a),s=t.clone();return s.applyTransformation(e),s}switch(s){case n.G.enumPolyline:case n.G.enumPolygon:return this.projectMultiPath(t,e);case n.G.enumMultiPoint:return this.projectMultiPoint(t,e);case n.G.enumEnvelope:return this.projectEnvelope(t,e);case n.G.enumGeometryCollection:return this.projectGeometryCollection(t,e);default:(0,n.d)("")}}projectPoint(t,e){const s=[t.getXY()];let n,i=null;(n=t.hasAttribute(1))&&(i=[t.getZ()]),this.transformInPlaceZ(s,i,1,s,i,null);const r=t.clone();return r.setXY(s[0]),n&&r.setZ(i[0]),r}projectMultiPoint(t,e){let s=new r.M({copy:t});const i=this.m_projTransform.getInputSR(),o=this.m_projTransform.getOutputSR(),a=i.getCoordinateSystemType(),h=o.getCoordinateSystemType();if(3===a&&(0,n.g)(0),s=Gi(s,i,this.m_inputPCSHorizonClipOption,e),s.isEmpty())return s;2===a&&Ri(i,0,s),Ui(this.m_projTransform,s,!1);let m=0;3===h&&(0,n.g)(0);const l=2===h;return l?m=o.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(m=this.m_centralMeridianOfOutputGCS),l&&0!==this.m_outputPCSHorizonClipOption||(s=Pi(s,$r(o),m,!1,0,e)),l&&(s=_i(s,o,this.m_outputPCSHorizonClipOption,e),Xi(o,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(t,e){const s=t.getGeometryType();return s===n.G.enumPolygon?this.projectPolygon(t,e):s===n.G.enumPolyline?this.projectPolyline(t,e):void(0,n.d)("project_multi_path_")}projectEnvelope(t,e){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&t.hasAttribute(1);let n=a.E.constructEmpty();if(s&&(n=t.queryInterval(1,0)),n.width()>0){const s=t.clone();s.setInterval(1,0,n.vmin,n.vmin);const i=this.projectEnvelopeHelper(s,e);s.setInterval(1,0,n.vmax,n.vmax);const r=this.projectEnvelopeHelper(s,e);return i.merge(r),i}return this.projectEnvelopeHelper(t,e)}projectPolygon(t,e){(0,n.g)(t.getGeometryType()===n.G.enumPolygon),(0,n.g)(!this.m_projTransform.isIdentity()),(0,n.g)(!t.isEmpty());const s=this.m_projTransform.getInputSR(),o=this.m_projTransform.getOutputSR(),a=s.getCoordinateSystemType(),h=o.getCoordinateSystemType(),m=new r.a({copy:t});3===a&&(0,n.g)(0),3===h&&(0,n.g)(0);const c=2===a,g=2===h,d=c?s.getGCS():s,_=g?o.getGCS():o,p=!g&&!this.m_bDontHackPolesInGeogToGeog;let f=!1,x=Gi(m,s,this.m_inputPCSHorizonClipOption,e);if(x.isEmpty())return x;let P=this.m_densificationStepInput;const y=!Number.isNaN(P);let E;y&&(x=(new u.O).execute(x,P,0,0,e));let C=g?o.getPCSInfo():null,v=Number.NaN;c&&(v=s.getCentralMeridian());const S=null!==o.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const t=x;if(c&&(Bi(s,v,t),y)){const t=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/t}if(Wi(this.m_projTransform,t,p),y){const t=s.getGCS().getUnitsPerMillimeter();P*=o.getGCS().getUnitsPerMillimeter()/t}E=t}else{let t=new r.P({vd:x.getDescription()});if(t.addAndExplicitlyOpenAllPaths(x,!1),c){if(Bi(s,v,t),y){const t=s.getUnitsPerMillimeter();P*=s.getGCS().getUnitsPerMillimeter()/t}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),r=n.getSouthPoleGeometry()===To.PE_POLE_LINE_CURVED,o=n.getNorthPoleGeometry()===To.PE_POLE_LINE_CURVED;if(r||o){const s=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*d.getOneDegreeGCSUnit();r&&(s.ymin=-n),o&&(s.ymax=n),t=(0,l.a)(t,s,d,0,0,e)}}}if(Wi(this.m_projTransform,t,p),y){const t=$r(s).getUnitsPerMillimeter();P*=$r(o).getUnitsPerMillimeter()/t}let n=Number.NaN;g?(C=o.getPCSInfo(),n=o.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(n=this.m_centralMeridianOfOutputGCS);let a=mn(s)|mn(o),h=10*_.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(a=3,h=10*_.getTolerance(0)),E=function(t,e,s,n,i,r,o,a,h){return new Un(t,null,s,e,n,i,o,a,r).geoNormalizePolygonGeometry(h)}(x,s,t,_,n,e,a,h,this.m_bNormalizeOutputGeometry),a=0}if(S&&((0,n.g)(!o.isPannable()),E=ci(E,o,e)),g){if(!f){const t=_.getPannableExtent().width();if(E.queryInterval(0,0).width()>=t-10*_.getTolerance(0)){const t=C.getNorthPoleLocation(),e=C.getSouthPoleLocation(),s=C.getNorthPoleGeometry(),n=C.getSouthPoleGeometry();let i=0;s===To.PE_POLE_POINT&&t!==To.PE_POLE_OUTSIDE_BOUNDARY&&(i=1),n===To.PE_POLE_POINT&&e!==To.PE_POLE_OUTSIDE_BOUNDARY&&(i|=2),f||=0!==i}}E=_i(E,o,this.m_outputPCSHorizonClipOption,e),y&&(E=(new u.O).execute(E,P,0,0,e)),Yi(o,E,this.m_bNormalizeOutputGeometry)}return E.isEmpty()||f&&(E=(new Ks).execute(E,o,!1,e)),E}projectPolyline(t,e){(0,n.g)(t.getGeometryType()===n.G.enumPolyline),(0,n.g)(!this.m_projTransform.isIdentity()),(0,n.g)(!t.isEmpty());const s=this.m_projTransform.getInputSR(),i=this.m_projTransform.getOutputSR(),o=s.getCoordinateSystemType(),a=i.getCoordinateSystemType(),h=new r.P({copy:t});3===o&&(0,n.g)(0),3===a&&(0,n.g)(0);const m=2===o,l=2===a;m&&s.getGCS();const c=l?i.getGCS():i,g=!l&&!this.m_bDontHackPolesInGeogToGeog;let d=Gi(h,s,this.m_inputPCSHorizonClipOption,e);if(d.isEmpty())return d;let _=Number.NaN;m&&(_=s.getCentralMeridian());const p=null!==i.getGCSSplitLines();let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let P;if(x&&(d=(new u.O).execute(d,f,0,0,e)),this.m_bDontGeonormalizePolygon){if(m&&(Bi(s,_,d),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Wi(this.m_projTransform,d,g),x){const t=s.getGCS().getUnitsPerMillimeter();f*=i.getGCS().getUnitsPerMillimeter()/t}P=d}else{const t=new r.P({vd:d.getDescription()});if(t.addAndExplicitlyOpenAllPaths(d,!1),m&&(Bi(s,_,t),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Wi(this.m_projTransform,t,g),x){const t=s.getGCS().getUnitsPerMillimeter();f*=i.getGCS().getUnitsPerMillimeter()/t}let n=Number.NaN;l?n=i.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(n=this.m_centralMeridianOfOutputGCS);let o=mn(s)|mn(i),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,a=0),P=function(t,e,s,n,i,r,o,a,h){return new Un(t,null,s,e,n,i,o,a,r).geoNormalizePolylineGeometry(h)}(d,s,t,c,n,e,o,a,this.m_bNormalizeOutputGeometry),o=0}return p&&((0,n.g)(!i.isPannable()),P=ci(P,i,e)),l&&(P=_i(P,i,this.m_outputPCSHorizonClipOption,e),x&&(P=(new u.O).execute(P,f,0,0,e)),Yi(i,P,this.m_bNormalizeOutputGeometry)),P.isEmpty(),P}projectGeometryCollection(t,e){return(0,n.g)(0),{}}projectEnvelopeHelper(t,e){const s=(t.height()+t.width())/400;if(0!==s){const n=(new u.O).execute(t,s,0,0,e),a=this.projectMultiPath(n,e),h=new o.E({vd:t.getDescription()});if(a.isEmpty()){const s=Math.min(t.height(),t.width()),a=(0,o.b)(this.m_projTransform.getInputSR(),t,!0).total();if(s>100*a){const t=i.Envelope2D.constructEmpty(),e=(0,o.c)(this.m_projTransform.getOutputSR(),t,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(a,e*n))return h}const m=new r.P;m.addAndExplicitlyOpenAllPaths(n,!1),this.projectMultiPath(m,e).queryEnvelope(h);const l=new r.M({vd:t.getDescription()});l.reserve(4);const u=new o.P;for(let e=0;e<4;e++)t.queryCornerByVal(e,u),l.add(u);const c=this.projectMultiPoint(l,e),g=new o.E;return c.queryEnvelope(g),h.merge(g),h}return a.queryEnvelope(h),h}{const s=t.getCenterXY(),n=new o.P(s),i=this.projectPoint(n,e),r=new o.E({vd:t.getDescription()});if(i.isEmpty())r.setEmpty();else{t.copyTo(r);const e=i.getXY();r.setCoords(e.x,e.y,e.x,e.y)}return r}}transformInPlace(t,e,s,i){return(0,n.g)(0),0}transformInPlaceZ(t,e,s,i,r,o){if(this.m_projTransform.isIdentity())return t!==i&&(0,a.D)(i,t,s),e!==r&&(0,a.b)(r,e,0,0,s),s;const h=this.m_projTransform,m=h.getInputSR(),l=h.getOutputSR(),u=m.getCoordinateSystemType(),c=l.getCoordinateSystemType();if(0===u&&u===c)return ln(m,l).transformPoints2D(t,s,i),h.isVertical()&&(0,n.g)(0),s;3===u&&(0,n.t)("image: transform_in_place_"),3===c&&(0,n.t)("image: transform_in_place_"),function(t,e,s,i,r){const o=i.getCoordinateSystemType();if(2===o){if(0===r)s!==t&&(0,a.D)(s,t,e),function(t,e,s){const i=t.getPCSHorizon();if(i.getGeometryType()===n.G.enumPolygon){const n=t.getDefaultPrecisionSR().getTolerance(0),r=i;for(let t=0;t<s;t++)1!==Je(r,e[t],n)&&e[t].setNAN();return}if(i.getGeometryType()===n.G.enumEnvelope){const t=i;for(let n=0;n<s;n++)t.contains(e[n])||e[n].setNAN();return}(0,n.a)("")}(i,s,e);else if(s!==t&&(0,a.D)(s,t,e),i.isPannable()){const t=i.getTolerance(0);(function(t,e,s,n){for(let i=0;i<e;i++){if(t[i].y<s.ymin||t[i].y>s.ymax){t[i].setNAN();continue}const e=t[i].x;t[i].x=Ci(e,s,n)}})(s,e,i.getPannableExtent(),t),yi(s,e,i,0)}}else{(0,n.g)(1===o);const r=i.getTolerance(0),a=i.getPannableExtent();for(let n=0;n<e;n++)s[n].assign(Ai(t[n],a,r))}}(t,s,i,m,this.m_inputPCSHorizonClipOption),r!==e&&(0,a.b)(r,e,0,0,s),2===u&&Hi(m,0,i,s),Ki(this.m_projTransform,i,r,s,!1);let g=0;const d=2===c;d?g=l.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(g=this.m_centralMeridianOfOutputGCS),d&&0!==this.m_outputPCSHorizonClipOption||yi(i,s,l.getGCS(),g),d&&(xi(i,s,l,this.m_outputPCSHorizonClipOption),Mi(l,i,s,!1));let _=s;for(let t=0;t<s;++t)i[t].isNAN()&&(r&&(r[t]=Number.NaN),_--);return _}}function mn(t){if(2!==t.getCoordinateSystemType())return 0;let e=0;const s=t.getPCSInfo(),n=s.getNorthPoleLocation(),i=s.getSouthPoleLocation(),r=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return r===To.PE_POLE_POINT&&n!==To.PE_POLE_OUTSIDE_BOUNDARY&&(e=1),o===To.PE_POLE_POINT&&i!==To.PE_POLE_OUTSIDE_BOUNDARY&&(e|=2),e}function ln(t,e){const s=t.getHorzUnitFactor(),n=e.getHorzUnitFactor();let i=1,r=1;const o=20015077/180;1===t.getUnit().getUnitType()&&(i=o),1===e.getUnit().getUnitType()&&(r=o);const a=s/n*(i!==r?i/r:1),h=new m.T;return h.setScaleCoords(a,a),h}class un{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s){return!e||e.isIdentity()?t:new cn(t,e,s)}execute(t,e,s){return e.isIdentity()?t:sn(t,e,s)}transform(t,e,s,n,i=!0){return i?function(t,e,s,n){t.m_projector.transformInPlaceZ(e,null,s,n,null,null);const i=n.slice(0,s).filter(t=>!t.isNAN());for(let t=0,e=i.length;t<e;++t)n[t].assign(i[t]);return i.length}(t,e,s,n):nn(t,e,s,n,null)}transform3D(t,e,s,i,r=!0){return(0,n.g)(0),0}foldInto360Range(t,e){return on(t,e,null)}foldInto360RangeGeodetic(t,e,s){return rn(t,e,s,null)}normalizeGeometryEx(t,e,s,i,h=0){return function(t,e,s,i,h){if(!e.isPannable()||t.isEmpty())return t;const l=t.getGeometryType();l===n.G.enumGeometryCollection&&(0,n.t)("not yet impl for geometry collection");const u=e.getPannableExtent();Number.isNaN(s)&&(s=u.getCenterX());const c=u.width(),g=.5*c,d=h>0,_=t.queryInterval(0,0);if(!d&&_.width()<g||!(0,n.i)(t.getGeometryType())){const e=_.getCenter();if(Math.abs(e-s)<=g)return t;{const n=new m.T,i=(0,a.G)((s-e)/c)*c;n.setShiftCoords(i,0);const r=t.clone();return r.applyTransformation(n),r}}if(l===n.G.enumPolygon){let n=new r.P({vd:t.getDescription()});n.addAndExplicitlyOpenAllPaths(t,!1),d&&(n=gn(n,e,2,h,Number.NaN,null,!0));const m=[];if(!i){{let s=t;d&&(s=new r.a,s.add(n,!1));const i=function(t,e,s){const n=Rr();e.querySpheroidData(n);const i=e.getGCS()!==e?e.getSRToGCSTransform():null,r=(0,a.m)(a.P,100),h=new o.d(0,0,0),m=t.getPointCount(),l=e.getGCS().getUnit().getUnitToBaseFactor();for(let e=0,s=m;e<s;){const o=Math.min(100,s-e);t.queryCoordinates(r,o,e,e+o),i&&(new un).transform(i,r,o,r,!1);for(let t=0;t<o;t++){if(r[t].isNAN())continue;r[t].scale(l);const e=S(n.majorSemiAxis,n.e2,r[t]);h.addThis(e)}e+=o}const u=D(n.majorSemiAxis,n.e2,h);u.scale(1/l);const c=t;if(!new Rn(e.getGCS(),u).project(c))return 0;s.length=t.getPathCount();const g=c.calculateArea2D()<0;for(let e=0,n=t.getPathCount();e<n;e++){const t=c.calculateRingArea2D(e),n=g?t<0:t>0;s[e]=n}return g?-1:1}(t,e,m);if(i)i<0&&n.reverseAllPaths();else{const t=s.getPathCount();for(let e=0;e<t;e++)m.push(s.calculateRingArea2D(e)>0)}}i=m}return new Un(null,i,n,null,e,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(l===n.G.enumPolyline){let n=new r.P({vd:t.getDescription()});return n.addAndExplicitlyOpenAllPaths(t,!1),d&&(n=gn(n,e,2,h,Number.NaN,null,!0)),new Un(null,null,n,null,e,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(l===n.G.enumMultiPoint){const e=t,n=e.getAttributeStreamRef(0);let i,r=null,o=s,h=0;const m=.1*c;for(let s=0,l=e.getPointCount();s<l;s++){const e=n.read(2*s);let l=e-o;if(Math.abs(l)>g&&(l=(0,a.G)(l/c)*c,h-=l,Math.abs(h)<m&&(h=0)),0!==h){r||(i=t.clone(),r=i.getAttributeStreamRef(0));const n=e+h;r.write(2*s,n)}o=e}return r?(i.notifyModified(),i):t}(0,n.d)("")}(t,e,s,i,h)}normalizeGeometry(t,e,s){return function(t,e,s){if(!e.isPannable()||t.isEmpty())return t;const i=e.getPannableExtent().width(),r=.5*i,o=t.queryInterval(0,0);if(o.width()<r||!(0,n.i)(t.getGeometryType())){if(Number.isNaN(s))return t;const e=o.getCenter();if(Math.abs(e-s)<=r)return t;{const n=new m.T,r=(0,a.G)((s-e)/i)*i;n.setShiftCoords(r,0);const o=t.clone();return o.applyTransformation(n),o}}const h=t.getGeometryType(),l=t,u=l.getAttributeStreamRef(0),c=t.clone(),g=c.getAttributeStreamRef(0);let d=0,_=0,p=0,f=(0,n.h)(h)?0:-1;const x=a.E.constructEmpty();let P=!1;for(let t=0,e=l.getPointCount();t<e;t++){const e=u.read(2*t);t===_&&((0,n.h)(h)?(0===f&&Number.isNaN(s)&&(P=!0),f>0&&Number.isNaN(s)&&(s=x.getCenter(),P=!1),_=l.getPathEnd(f),f++):_=l.getPointCount(),Number.isNaN(s)?p=e:(p=s,d=0));let o=e-p;Math.abs(o)>r&&(o=(0,a.G)(o/i)*i,d-=o,Math.abs(d)<.1*i&&(d=0));const m=e+d;g.write(2*t,m),P&&x.mergeCoordinate(m),p=e}return c.notifyModified(),c}(t,e,s)}clipToSpatialReference(t,e,s,r=0){return function(t,e,s,r){const o=e.getCoordinateSystemType();if(0===o){const n=new lo;return e.queryPrecisionDescriptor(n),an(t,n,e,s)}let a=t;2!==r&&3!==r||!e.isPannable()||(a=on(a,e,s));const h=new lo;if(e.queryPrecisionDescriptor(h),a=an(a,h,e,s),0===r||a.isEmpty())return a;if(1===o){if(1===r){const t=new i.Envelope2D;a.queryLooseEnvelope(t);const n=e.getPannableExtent(),r=.01*n.width();return n.xmin=t.xmin-r,n.xmax=t.xmax+r,(new l.O).execute(a,n,e,s)}return a}if(2===o){const t=e.getPCSHorizon();if(1===r||2===r){const n=(new en).execute(a,t,e,s);return n===t?n.clone():n}return a}if(3===o)return a;(0,n.d)("missing implementation")}(t,e,s,r)}}class cn extends c.G{constructor(t,e,s){super(),this.m_projTrans=e,this.m_progressTracker=s,this.m_index=-1,t||(0,n.a)(""),this.m_inputGeoms=t}next(){const t=this.m_inputGeoms.next();return null!=t?((0,n.o)(t),(0,n.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),sn(t,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function gn(t,e,s,i,o,a,h=!1){t||(0,n.a)("Geometry.Geodetic_densify.densify");let m=t.getGeometryType();if((0,n.c)(t),t.isEmpty()||(0,n.e)(m))return t;const l=new Pn;l.m_sr=e,l.m_gcs=e.getGCS(),l.m_transform=l.m_gcs!==e?e.getSRToGCSTransform():null,l.m_progressTracker=a;const u=Rr();let c,g,d;if(l.m_gcs.querySpheroidData(u),l.m_a=u.majorSemiAxis,l.m_eSquared=u.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=i,l.m_maxDeviation=o,l.m_curveType=s,m===n.G.enumEnvelope){const e=new r.a({vd:t.getDescription()});e.addEnvelope(t,!1),c=e,m=n.G.enumPolygon}else if((0,n.f)(m)){const e=new r.P({vd:t.getDescription()});e.addSegment(t,!0),c=e,m=n.G.enumPolyline}else c=t;if(4!==l.m_curveType){if((0,n.g)((0,n.h)(m)),g=l.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(c),g.isEmpty())return g;g=dn(l.m_rpu,g);let t=l.geodeticDensify(g);h||(t=(new un).foldInto360RangeGeodetic(t,l.m_gcs,l.m_curveType)),d=l.m_transform&&!l.m_transform.isIdentity()?(new un).execute(t,l.m_transform.getInverse(),a):t}else{let t;if((0,n.g)((0,n.h)(m)),e.isPannable())t=Ii(c,e);else{const s=e.getPCSHorizon();t=(new en).execute(c,s,e,a),t===s&&(t=s.clone())}if(g=t,g.isEmpty())return g;d=l.shapePreservingDensify(g)}return d}function dn(t,e){const s=new i.Envelope2D;if(e.queryLooseEnvelope(s),s.width()*t<Math.PI)return e;let n=!1;const r=e.querySegmentIterator(),h=new a.P,m=new a.P;for(;r.nextPath();)for(;r.hasNextSegment();){const e=r.nextSegment();if(h.setCoordsPoint2D(e.getStartXY()),m.setCoordsPoint2D(e.getEndXY()),h.scale(t),m.scale(t),Math.abs(h.x-m.x)>Math.PI){if(!pn(h,m)){n=!0;break}if(Math.abs(h.x-m.x)>2*Math.PI){n=!0;break}}}if(!n)return e;const l=e.createInstance();l.reserve(e.getPointCount());const u=e.getDescription().getAttributeCount()>1,c=new a.P,g=new a.P,d=new a.P(0,0),_=new a.P(0,0),p=new o.P;for(r.resetToFirstPath();r.nextPath();){let e=Number.NaN,s=0;for(;r.hasNextSegment();){const n=r.nextSegment();if(h.setCoordsPoint2D(n.getStartXY()),m.setCoordsPoint2D(n.getEndXY()),h.scale(t),m.scale(t),Number.isNaN(e)?(s=An(h.x,Number.NaN,s),d.setCoordsPoint2D(h)):d.setCoordsPoint2D(_),e=d.x,pn(h,m)){if(m.x-h.x>2*Math.PI)for(;m.x-h.x>2*Math.PI;)m.x-=2*Math.PI;else if(m.x-h.x<2*-Math.PI)for(;m.x-h.x<2*-Math.PI;)m.x+=2*Math.PI;s=An(m.x,Number.NaN,s),_.setCoordsPoint2D(m)}else c.setCoordsPoint2D(m),Xn(c),s=An(c.x,e,s),_.setCoords(s+c.x,c.y);if(Math.abs(_.x-m.x)<.5&&_.setCoordsPoint2D(m),u)n.queryCoord(0,p),g.setCoordsPoint2D(d),g.scale(1/t),p.setXY(g),r.isFirstSegmentInPath()?l.startPathPoint(p):l.lineToPoint(p),r.isLastSegmentInPath()&&!r.isPathClosed()&&(n.queryCoord(1,p),g.setCoordsPoint2D(_),g.scale(1/t),p.setXY(g),l.lineToPoint(p));else{r.isFirstSegmentInPath()&&l.insertPath2D(-1,null,0,0,!0);const e=l.getPathCount()-1;g.setCoordsPoint2D(d),g.scale(1/t),l.insertPoint2D(e,-1,g),r.isLastSegmentInPath()&&!r.isPathClosed()&&(g.setCoordsPoint2D(_),g.scale(1/t),l.insertPoint2D(e,-1,g))}}}return l}function _n(t,e,s,n,i,r,o,h,m,l,u,c){const g=new a.P,d=new a.P,_=n.compare(i)>0;Tn(_,n,i,g,d);const p=Cn(t,e,s,g,d,r,o,h,m,l,null,u,c);return _&&wn(m,l,null,u),p}function pn(t,e){return!(!vo(t.y,a.o)||!vo(e.y,a.o))||!(!vo(t.y,-a.o)||!vo(e.y,-a.o))}function fn(t,e){return!(!vo(t.y,a.o)||vo(e.y,a.o))||!(!vo(t.y,-a.o)||vo(e.y,-a.o))}function xn(t,e){return!(!vo(e.y,a.o)||vo(t.y,a.o))||!(!vo(e.y,-a.o)||vo(t.y,-a.o))}class Pn{constructor(){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_progressTracker=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_gcsTolerance=0,this.m_radTolerance=0,this.m_maxLength=0,this.m_maxDeviation=0,this.m_curveType=0}geodeticDensify(t){const e=t.createInstance(),s=t.querySegmentIterator(),n=[],i=[],o=new r.S,h=t.getDescription().getAttributeCount()>1;for(;s.nextPath();){const t=[0];for(;s.hasNextSegment();){const r=s.nextSegment(),m=r.getStartXY(),l=r.getEndXY();m.scale(this.m_rpu),l.scale(this.m_rpu);const u=new a.P,c=new a.P,g=m.compare(l)>0;Tn(g,m,l,u,c),n.length=0,i.length=0,this.m_maxLength>0?Cn(this.m_a,this.m_eSquared,this.m_curveType,u,c,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,h?i:null,n,t):vn(),g&&wn(null,null,h?i:null,n),n[0].setCoordsPoint2D(r.getStartXY()),n.at(-1).setCoordsPoint2D(r.getEndXY());const d=1/this.m_rpu;for(let t=1,e=n.length-1;t<e;t++)n[t].scale(d);if(h){const t=Nn(g,r,o);En(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),r,t,i,n,e)}else yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,e)}}return e}shapePreservingDensify(t){const e=t.createInstance(),s=t.querySegmentIterator(),n=[],i=[],o=new r.S,a=t.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment(),r=t.getStartXY(),h=t.getEndXY(),m=r.compare(h)>0,l=Nn(m,t,o);n.length=0,i.length=0,Dn(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,a?i:null,n),m&&wn(null,null,a?i:null,n),a?En(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),t,l,i,n,e):yn(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,e)}return e}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(t){const e=t.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(t=Ii(t,this.m_gcs),!e))return t;const s=t.createInstance();s.reserveParts(t.getPointCount(),t.getPathCount());for(let e=0,n=t.getPathCount();e<n;++e){let n=new r.M;const i=t.getPathStart(e),a=t.getPathEnd(e);n.addPoints(t,i,a);const h=t.isClosedPath(e);let m=!1;if(h&&a-i===1&&t.hasNonLinearSegmentsPath(e)){const e=new o.P;t.getPointByVal(i,e),n.add(e),m=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(h&&!m){const e=new o.P;t.getPointByVal(i,e),n.add(e)}if(n=(new un).execute(n,this.m_transform,this.m_progressTracker),h&&n.getPointCount()>1){const t=n.getXY(0),e=n.getXY(n.getPointCount()-1);t.equals(e)&&n.removePoint(n.getPointCount()-1)}}n.getPointCount()>1&&(s.addPathMultiPoint(n,0,-1,!0),h&&s.closePathWithLine())}return s}}function yn(t,e,s,n){t&&n.insertPath2D(-1,null,0,0,!0);const i=n.getPathCount()-1;n.insertPointsFromPoints(i,-1,s,0,s.length-1,!0),e&&n.insertPoint2D(i,-1,s.at(-1))}function En(t,e,s,n,i,r,a){a.reserve(a.getPointCount()+r.length-1);const h=new o.P;if(s.queryStart(h),t?a.startPathPoint(h):a.lineToPoint(h),r.length>2){const t=n.calculateLength2D();for(let e=1;e<r.length-1;e++){const s=n.lengthToT(i[e]*t);n.queryCoord(s,h),h.setXY(r[e]),a.lineToPoint(h)}}e&&(s.queryEnd(h),a.lineToPoint(h))}function Cn(t,e,s,n,i,r,o,m,l,u,c,g,d){const _={stack:[],error:void 0,hasError:!1};try{const p=(0,h.mS)(_,new So,!1),f=(0,h.mS)(_,new So,!1),x=(0,h.mS)(_,new So,!1);Go.geodeticDistance(t,e,n.x,n.y,i.x,i.y,x,p,f,s);const P=x.val,y=p.val,E=f.val;let C=y,v=E;C<0&&(C+=2*Math.PI),v<0&&(v+=2*Math.PI),l&&(l[0]=C),u&&(u[0]=v);let S=Number.NaN,b=Number.NaN;if(null!==c){const s=qo.q90(t,e),i=qo.q(t,e,n.y);S=(s-i)/P,b=(s+i)/P}const I=fn(n,i),D=xn(n,i),w=I||D,T=function(t,e,s){return!(!Fn(t,e,s)||vo(t.y,a.o)||vo(t.y,-a.o)||vo(e.y,a.o)||vo(e.y,-a.o))}(n,i,m),N=(0,h.mS)(_,new a.S(new So,new So),!1),A=new a.P,G=new a.P,q=new a.P;d[0]=An(n.x,Number.NaN,d[0]);let M=d[0];if(P<=r)return g.push(n.clone()),d[0]=An(i.x,Number.NaN,d[0]),null!=c&&c.push(0),w?(I&&Gn(n,i,c,g),D&&qn(n,i,c,g)):T?Mn(n,i,y,S,b,c,g):o>0&&(G.setCoords(n.x-M,n.y),A.setCoords(i.x-d[0],i.y),M=Sn()),g.push(i.clone()),P;const F=1+Math.ceil(P/r),X=P/(F-1),V=new a.P;g.push(n.clone()),V.setCoordsPoint2D(n),G.setCoords(n.x-d[0],n.y),null!==c&&c.push(0);for(let r=1;r<F;r++){let a;if(r<F-1){const i=r*X;Go.geodeticCoordinate(t,e,n.x,n.y,i,y,N.at(0),N.at(1),s),A.setCoords(N.at(0).val,N.at(1).val),d[0]=An(A.x,V.x,d[0]),q.setCoords(d[0]+A.x,A.y),a=r/(F-1)}else d[0]=An(i.x,Number.NaN,d[0]),A.setCoords(i.x-d[0],i.y),q.setCoordsPoint2D(i),a=1;w?(1===r&&I&&Gn(n,q,c,g),r===F-1&&D&&qn(V,i,c,g)):T?Fn(V,q,m)&&(n.x<i.x?V.x>q.x&&(d[0]+=2*Math.PI,q.setCoords(d[0]+A.x,A.y)):V.x<q.x&&(d[0]-=2*Math.PI,q.setCoords(d[0]+A.x,A.y)),Mn(V,q,y,S,b,c,g)):o>0&&Sn(),g.push(q.clone()),null!=c&&c.push(a),V.setCoordsPoint2D(q),G.setCoordsPoint2D(A),M=d[0]}return P}catch(t){_.error=t,_.hasError=!0}finally{(0,h.hk)(_)}}function vn(t,e,s,i,r,o,a,h,m,l){(0,n.g)(0)}function Sn(t,e,s,i,r,o,a,h,m,l,u,c,g,d,_){return(0,n.g)(0),0}function bn(t,e,s,n){const i=S(t,e,s),r=S(t,e,n);return o.d.distance(i,r)}function In(t,e,s,i,r,h,m,l){const u=new Array,c=(0,a.m)(Array,8);let g=2,d=r.getCoord2D(h);c[0][0]=d.x,c[0][1]=d.y,d=r.getCoord2D(m),c[1][0]=d.x,c[1][1]=d.y;const _=t=>{if(null!==s){const e=Do.projToGeog(s,t,c);(0,n.g)(e===t)}for(const t of c)t[0]*=i,t[1]*=i};_(2),u.push(S(t,e,new a.P(c[0][0],c[0][1]))),u.push(S(t,e,new a.P(c[1][0],c[1][1])));let p=o.d.distance(u[0],u[1]);if(p>l)return p;let f=0;for(g=3;g<=17;){const s=1/(g-1);let i=0;for(let t=1;t<g;++t)if(1&t){const e=(0,a.q)(h,m,t*s);r.queryCoord2D(e,d),c[i][0]=d.x,c[i][1]=d.y,i++}_(i);let x=1;for(let s=0;s<i;++s)u.splice(x,0,S(t,e,new a.P(c[s][0],c[s][1]))),x++;x=0;let P=u[x];x++;let y=0;for(;x!==u.length;++x){const t=u[x];y+=o.d.distance(P,t),P=t}if(y>l)return y;if(f=y-p,(0,n.g)(f>=0||Math.abs(f)<1e-14*y),f<0&&(f=0),p=y,y+f<=l)return y+f;g=2*g-1}return p+f}function Dn(t,e,s,i,r,o,h,m,l){const u=i.isCurve(),c=function(t,e){return t*Math.sqrt(1-e)}(t,e)*Math.PI*179/180;let g=o;o>0&&!(o>c)||(g=c);const d=h,_=d>0;let p=Number.NaN;_&&(p=function(t,e,s){const n=s/(2*function(t,e){return(1-e)*t}(t,e)),i=n*n;return s*(1-i*(.16666666666666666-.008333333333333333*i))}(t,e,d));const f=1===r.getCoordinateSystemType();let x=null;f||(x=r.getPECoordSys());const P=r.getTolerance(0),y=i.getStartXY(),E=i.getEndXY(),C=new a.P,v=new a.P;if(f)C.setCoordsPoint2D(y),C.scale(s),v.setCoordsPoint2D(E),v.scale(s);else{const t=[y.x,y.y,E.x,E.y];Do.projToGeog(x,2,t),C.setCoords(t[0],t[1]),C.scale(s),v.setCoords(t[2],t[3]),v.scale(s)}let b=0,I=0;const D=[],w=[],A=[];D.push(E.clone()),w.push(v.clone()),A.push(1),l.push(y.clone()),null!==m&&m.push(I);const G=r.isPannable(),q=y.clone(),M=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let F=5;u||(_?(M[0]=.5,M[1]=.25,M[2]=.75,F=3):F=1),(0,n.g)(g>0);const X=t=>{if(t=t.clone(),null!==x){const e=[t.x,t.y];Do.projToGeog(x,1,e),t.setCoords(e[0],e[1])}return t.scale(s),t};for(;w.length>0;){const o=D.at(-1).clone();v.assign(w.at(-1));const h=A.at(-1);let c=!1,d=Number.NaN;const y=In(t,e,x,s,i,I,h,g);let E=g>=y&&Math.abs(C.y-v.y)<.9*Math.PI;f&&E&&(E=Math.abs(C.x-v.x)<.9*Math.PI);const V=new a.P,Y=new a.P;let R=!1;if(!_&&E&&E&&(R=!0),i.calculateSubLength(I,h)<=P&&(R=!0),!R)for(let m=0;m<F;m++){const l=(0,a.q)(I,h,M[m]),g=new a.P;i.queryCoord2D(l,g);const x=X(g);if(0===m&&(d=l,V.setCoordsPoint2D(g),Y.setCoordsPoint2D(x),!E)){c=!0;break}if((0,n.g)(_),f&&Math.abs(C.x-x.x)>=Math.PI){c=!0;break}let P=new a.P,y=new a.P;u?(P=a.P.lerp(q,o,M[m]),y=X(P)):(P=g.clone(),y=x.clone());const b=T(t,e,C,v,M[m]),D=b.clone();if(f?(D.x/=s,D.y/=s):(D.x/=s,D.y/=s,nn(r.getGCSToSRTransform(),[D],1,[D],null)),D.isNAN()){const s=S(t,e,x),n=S(t,e,C),i=S(t,e,v),{second:r}=N(t,e,s,n,i,2,null);if(r>p){c=!0;break}}else{if(G){const t=r.getPannableExtent().width(),e=(0,a.q)(i.getStartX(),i.getEndX(),.5);for(;D.x<e-.5*t;)D.x+=t;for(;D.x>=e+.5*t;)D.x-=t}const s=i.getClosestCoordinateOnInterval(D,new a.E(I,h),-1);let n=i.getCoord2D(s);n=X(n);let o=bn(t,e,n,b);if(o>p){if(o<4*p){const s=S(t,e,n),i=S(t,e,C),r=S(t,e,v),{second:a}=N(t,e,s,i,r,2,null);o=a}if(o>p){c=!0;break}}else if(u){let s=S(t,e,x);const n=S(t,e,C),i=S(t,e,v);let{second:r}=N(t,e,s,n,i,3,null);if(r<=p){s=S(t,e,y);const{second:o}=N(t,e,s,n,i,3,null);r=o}if(r>p){c=!0;break}}}}c?(D.push(V.clone()),w.push(Y.clone()),A.push(d)):(D.pop(),w.pop(),A.pop(),l.push(o.clone()),b+=y,null!==m&&m.push(b),q.setCoordsPoint2D(o),C.setCoordsPoint2D(v),I=h)}if(null!==m){const t=1/b;for(let e=0;e<m.length;e++)m[e]*=t}}function wn(t,e,s,n){if(n.reverse(),null!==s&&s.reverse(),t){const s=t[0],n=e[0];t[0]=n,e[0]=s}}function Tn(t,e,s,n,i){t?(n.setCoordsPoint2D(s),i.setCoordsPoint2D(e)):(n.setCoordsPoint2D(e),i.setCoordsPoint2D(s))}function Nn(t,e,s){return t?(s.create(e.getGeometryType()),e.copyTo(s.get()),s.get().reverse(),s.get()):e}function An(t,e,s){if(Number.isNaN(e)){for(;s-t>Math.PI;)s-=2*Math.PI;for(;t-s>Math.PI;)s+=2*Math.PI;return s}return s+t-e>Math.PI?s-=2*Math.PI:e-(s+t)>Math.PI&&(s+=2*Math.PI),s}function Gn(t,e,s,n){if(t.y>0){const i=new a.P;i.setCoords(e.x,a.o),vo(t.x,i.x)||vo(e.y,i.y)||(n.push(i),null!==s&&s.push(0))}else{const i=new a.P;i.setCoords(e.x,-a.o),vo(t.x,i.x)||vo(e.y,i.y)||(n.push(i),null!==s&&s.push(0))}}function qn(t,e,s,n){if(e.y>0){const i=new a.P;i.setCoords(t.x,a.o),vo(e.x,i.x)||vo(t.y,i.y)||(n.push(i),null!==s&&s.push(1))}else{const i=new a.P;i.setCoords(t.x,-a.o),vo(e.x,i.x)||vo(t.y,i.y)||(n.push(i),null!==s&&s.push(1))}}function Mn(t,e,s,n,i,r,o){if(function(t){return function(t,e){return 0===t||Math.abs(t)<=e}(t,Co)}(s)){if(a.o-t.y>0){const e=new a.P;e.setCoords(t.x,a.o),o.push(e),null!==r&&r.push(n)}if(a.o-e.y>0){const t=new a.P;t.setCoords(e.x,a.o),o.push(t),null!==r&&r.push(n)}}else{if(a.o+t.y>0){const e=new a.P;e.setCoords(t.x,-a.o),o.push(e),null!==r&&r.push(i)}if(a.o+e.y>0){const t=new a.P;t.setCoords(e.x,-a.o),o.push(t),null!==r&&r.push(i)}}}function Fn(t,e,s){return Math.abs(Math.abs(t.x-e.x)-Math.PI)<=s}function Xn(t){if(t.x<-Math.PI)for(;t.x<-Math.PI;)t.x+=2*Math.PI;else if(t.x>Math.PI)for(;t.x>Math.PI;)t.x-=2*Math.PI}function Vn(t,e,s,n){const i={stack:[],error:void 0,hasError:!1};try{const r=[s.x],o=[s.y-n],a=[s.x],m=[s.y+n];G(r,o),G(a,m);const l=(0,h.mS)(i,new So,!1),u=(0,h.mS)(i,new So,!1);return Go.greatEllipticDistance(t,e,s.x,s.y,r[0],o[0],l,null,null),Go.greatEllipticDistance(t,e,s.x,s.y,a[0],m[0],u,null,null),Math.min(l.val,u.val)}catch(t){i.error=t,i.hasError=!0}finally{(0,h.hk)(i)}}function Yn(t,e,s,n,r){const a=new i.Envelope2D;s.queryEnvelope(a);const h=(0,o.b)(null,s,!0).total();if(e.xmin-a.xmin<=h&&a.xmax-e.xmax<=h)return s;const u=e.width();let c=0;for(;e.xmin+c*u<a.xmin;)c++;for(;e.xmin+c*u>a.xmin;)c--;const g=c*u,d=new m.T;d.setShiftCoords(-g,0);const _=s;_.applyTransformation(d);const p=new i.Envelope2D;_.queryEnvelope(p);let f=null;if(p.xmax>e.xmax){let s=0;const n=new i.Envelope2D;n.setCoords({env2D:e}),n.ymin-=1,n.ymax+=1;let a=_;for(;n.xmin<p.xmax;){p.xmax>n.xmax&&(a=Si(a,t,2,!0,n.xmax));const i=(0,o.f)(a,n),h=(0,o.c)(null,i,!0).total(),m=(0,l.c)(a,n,h,Number.NaN,r);null===f?f=m===a?m.clone():m:(d.setShiftCoords(-s*u,0),m.applyTransformation(d),f.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=e.xmax+s*u}}else f=_;return f}class Rn{constructor(t,e){this.m_basisX=new o.d,this.m_basisY=new o.d,this.m_normal=new o.d,(0,n.g)(1===t.getCoordinateSystemType()),this.m_gcs=t;const s=Rr();t.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=t.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=e.mul(this.m_rpu);const i=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,h=Math.cos(i),m=Math.sin(i),l=Math.cos(r),u=Math.sin(r);this.m_cartCenter3D=function(t,e,s,n,i,r){return b(t,e,s,n,i,r,0)}(this.m_a,this.m_e2,h,m,l,u),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),o.d.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(a.P.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(a.P.construct(0,.5*-Math.PI/this.m_rpu))}project(t){const e=t.getGeometryType();if((0,n.i)(e)){(0,n.o)(t);const e=t;return this.projectMultiVertex(e)}(0,n.a)("Gnomonic.project")}unproject(t,e,s){const h=t.getGeometryType();if((0,n.i)(h)){(0,n.o)(t);let m=t;const l=[];if(h===n.G.enumPolygon){const t=m.getPathCount();for(let e=0;e<t;e++){const t=m.calculateRingArea2D(e);l.push(t)}}return this.unprojectMultiVertex(e,m),(0,n.h)(h)?(function(t,e,s){const n=t.getPannableExtent(),i=a.P.construct(0,0);n.centerAt(i);const r=n.width(),o=.5*r,h=new a.P;h.setNAN();let m=Number.NaN;for(let t=0;t<s.getPathCount();t++)for(let e=s.getPathStart(t);e<s.getPathEnd(t);e++){const i=s.getXY(e),a=vo(i.y,n.ymax)||vo(n.ymin,i.y);e===s.getPathStart(t)?(h.setNAN(),m=0):h.isNAN()||a||(m=Bn(i.x,h.x,o,r,m)),i.x+=m,s.setXYNoCurves(e,i),a||h.setCoordsPoint2D(i)}s.getImpl().notifyModifiedFlags(2001)}(this.m_gcs,0,m),function(t,e,s,h,m){const l=h.getGeometryType(),u=e.getPannableExtent();let c=h,g=!1,d=!1;if(l===n.G.enumPolygon){const s=new i.Envelope2D,n=a.P.construct(0,0);s.setCoords({env2D:u}),s.centerAt(n),g=function(t,e,s,n,o){const h=function(t,e){const s=new i.Envelope2D;e.queryEnvelope(s);const n=vo(t.ymax,s.ymax),o=vo(t.ymin,s.ymin),h=n||o;return!!h&&(function(t,e){const s=new r.a,n=new i.Envelope2D;for(let i=0;i<e.getPathCount();i++){e.queryPathEnvelope(i,n);let r=vo(t.ymax,n.ymax),o=vo(t.ymin,n.ymin);if(!r&&!o){s.addPath(e,i,!0);continue}s.insertPath2D(-1,null,0,0,!0);const h=e.getPathStart(i),m=e.getPathEnd(i),l=m-h;let u=-1;for(u=h;u<m;u++){const s=e.getXY(u);if(r=vo(t.ymax,s.y),o=vo(t.ymin,s.y),!r&&!o)break}let c=u,g=!1,d=Number.NaN;do{const n=e.getXY(c);r=vo(t.ymax,n.y),o=vo(t.ymin,n.y);const m=h+(c+1-h)%l;if(r||o){let r=a.P.construct(d,n.y);s.insertPoint2D(i,-1,r);const o=e.getXY(m),h=vo(t.ymax,o.y),l=vo(t.ymin,o.y);h||l||(r=a.P.construct(o.x,n.y),g?s.setXYNoCurves(s.getPointCount()-1,r):s.insertPoint2D(i,-1,r)),g=!0}else s.insertPoint2D(i,-1,n),d=n.x,g=!1;c=m}while(c!==u)}e.setEmpty(),e.add(s,!1)}(t,e),h)}(s,n),m=function(t,e,s,n,i){const o=[],a=[],h=.5*s.width();for(let r=0;r<n.getPathCount();r++){const m=n.getXY(n.getPathStart(r)),l=n.getXY(n.getPathEnd(r)-1),u=t[r]<0;if(Math.abs(m.x-l.x)>h){const t=kn(u,e,s,r,n,i);o.push(t),a.push(r)}else if(!u&&n.calculateRingArea2D(r)<0){const t=Ln(e,s,r,n,i);o.push(t),a.push(r)}}if(0===o.length)return!1;const m=new r.a({vd:n.getDescription()});let l=0,u=a[l];for(let t=0;t<n.getPathCount();t++)t===u?(m.add(o[l],!1),l++,l<a.length&&(u=a[l])):m.addPath(n,t,!0);return n.setEmpty(),n.add(m,!1),!0}(t,e,s,n,o);return h||m}(t,e,s,c,m);const h=function(t,e,s,n){const r=new i.Envelope2D;s.queryEnvelope(r);const a=(0,o.b)(null,s,!0).total();if(e.xmin-r.xmin<=a&&r.xmax-e.xmax<=a)return s;const h=s.createInstance();let m=s.createInstance();const l=new i.Envelope2D,u=s.getPathCount();for(let i=0;i<u;i++)s.queryPathEnvelope(i,l),e.xmin-l.xmin<=a&&l.xmax-e.xmax<=a?h.addPath(s,i,!0):(m.setEmpty(),m.addPath(s,i,!0),m=Yn(t,e,m,0,n),h.add(m,!0));return h}(e,s,c,m);h!==c&&(d=!0),c=h}else c=(new un).foldInto360RangeGeodetic(c,e,2);l===n.G.enumPolygon&&(g||d)&&(c=(new Ks).execute(c,e,!1,m)),c!==h&&(h.setEmpty(),h.add(c,!1))}(l,this.m_gcs,0,m,s)):m=Pi(m,this.m_gcs,0,!0,0,s),m}(0,n.a)("Gnomonic.unproject")}projectPoint(t){const e=t.mul(this.m_rpu),s=S(this.m_a,this.m_e2,e),n=this.m_normal.dotProduct(s);if(n<=0)return a.P.construct(Number.NaN,Number.NaN);const i=this.m_d/n,r=s.mul(i).sub(this.m_cartCenter3D),o=new a.P;return o.x=this.m_basisX.dotProduct(r),o.y=this.m_basisY.dotProduct(r),o}unprojectPoint(t){const e=this.m_cartCenter3D.add(this.m_basisX.mul(t.x).add(this.m_basisY.mul(t.y)));return D(this.m_a,this.m_e2,e).divide(this.m_rpu)}projectMultiVertex(t){const e=t.getImpl();let s=!0;const n=new a.P,i=new a.P;for(let t=0,r=e.getPointCount();t<r;t++)e.queryXY(t,n),n.y*this.m_rpu>.5*Math.PI?i.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?i.assign(this.m_southPolePcs):i.assign(this.projectPoint(n)),e.setXYNoCurves(t,i),i.isNAN()&&(s=!1);return e.notifyModifiedFlags(2001),s}unprojectMultiVertex(t,e){const s=e.getImpl(),n=t*t,i=!this.m_northPolePcs.isNAN(),r=!this.m_southPolePcs.isNAN();for(let t=0,e=s.getPointCount();t<e;t++){const e=s.getXY(t);let o=new a.P;i&&a.P.sqrDistance(e,this.m_northPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*Math.PI),o.scale(1/this.m_rpu)):r&&a.P.sqrDistance(e,this.m_southPolePcs)<=n?(o.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),o.scale(1/this.m_rpu)):o=this.unprojectPoint(e),s.setXYNoCurves(t,o)}s.notifyModifiedFlags(2001)}}function kn(t,e,s,n,h,u){const c=new r.a,g=new r.a,d=new m.T,_=h.getXY(h.getPathStart(n)),p=h.getXY(h.getPathEnd(n)-1),f=s.width(),x=.5*f,P=new i.Envelope2D;h.queryEnvelope(P);const y=Math.ceil(P.width()/f)+1;let E,C;_.x>p.x?(E=-f,C=t?s.ymin:s.ymax):(E=f,C=t?s.ymax:s.ymin),d.setShiftCoords(E,0),c.addPath(h,n,!0),g.add(c,!1);const v=new o.P;for(let t=0;t<y;t++)g.applyTransformation(d),g.getPointByVal(0,v),c.lineToPoint(v),c.addSegmentsFromPath(g,0,0,g.getSegmentCount()-1,!1);const S=c.getXY(0),b=c.getXY(c.getPointCount()-1);S.y=C,b.y=C,c.lineTo(b);const I=new a.P;for(I.setCoordsPoint2D(b),I.x-=.5*E;Math.abs(I.x-S.x)>x;)c.lineTo(I),I.x-=.5*E;c.lineTo(S);const D=s.getCenter().x,w=new i.Envelope2D;c.queryEnvelope(w);let T=0;const N=w.getCenter().x;N-D>x?T=-Math.ceil((N-D-x)/f):D-N>x&&(T=Math.ceil((D-N-x)/f)),0!==T&&(d.setShiftCoords(T*f,0),c.applyTransformation(d));const A=new r.E,G=A.addGeometry(c);bi(A,G,e,0,2,!0,s.xmin),bi(A,G,e,0,2,!0,s.xmax);const q=A.getGeometry(G),M=(0,o.f)(q,s);M.inflateCoords(0,1);const F=(0,o.c)(null,M,!0);return(0,l.c)(q,s,F.total(),Number.NaN,u)}function Ln(t,e,s,n,h){const u=e.width(),c=.5*u,g=e.getCenter().x,d=new i.Envelope2D;n.queryPathEnvelope(s,d);let _,p=0,f=d.getCenter().x;if(f-g>c?p=-Math.ceil((f-g-c)/u):g-f>c&&(p=Math.ceil((g-f-c)/u)),0!==p){const t=new m.T;t.setShiftCoords(p*u,0),n.getImpl().applyTransformationToPath(t,s),n.queryPathEnvelope(s,d),f=d.getCenter().x}const x=new i.Envelope2D;e.containsExclusiveEnvelope(d)?(_=!1,x.setCoords({env2D:e})):(_=!0,x.setCoords({env2D:e}),x.xmin-=u,x.xmax+=u);let P=n.createInstance();P.addPathPoint2D(null,0,!0);const y=new a.P;if(y.setCoords(x.xmin,x.ymin),P.insertPoint2D(0,-1,y),y.setCoords(x.xmin,x.ymax),P.insertPoint2D(0,-1,y),y.setCoords(.5*(x.xmin+x.xmax),x.ymax),P.insertPoint2D(0,-1,y),y.setCoords(x.xmax,x.ymax),P.insertPoint2D(0,-1,y),y.setCoords(x.xmax,x.ymin),P.insertPoint2D(0,-1,y),y.setCoords(.5*(x.xmin+x.xmax),x.ymin),P.insertPoint2D(0,-1,y),_){P.addPath(n,s,!0);const i=new m.T;f<g?i.setShiftCoords(u,0):i.setShiftCoords(-u,0),n.getImpl().applyTransformationToPath(i,s),P.addPath(n,s,!0);const a=new r.E,c=a.addGeometry(P);bi(a,c,t,0,2,!0,e.xmin),bi(a,c,t,0,2,!0,e.xmax),P=a.getGeometry(c);const d=(0,o.f)(P,e);d.inflateCoords(0,1);const _=(0,o.c)(null,d,!0).total();P=(0,l.c)(P,e,_,Number.NaN,h)}else P.addPath(n,s,!0);return P}function Bn(t,e,s,n,i){return i+t-e>s?i-=n:e-(i+t)>s&&(i+=n),i}function Hn(t,e,s,n,i,h){const m=e.getAttributeStreamRef(0),l=e.getPointCount();let u=!1;const c=new a.P;for(let t=0;t<l;++t){if(m.queryPoint2D(2*t,c),1&h&&c.y>=s){u=!0;break}if(2&h&&c.y<=-s){u=!0;break}}if(!u)return!1;let g=!1;t&&(g=e.getImpl().isClosedPathInXYPlane(0));const d=new r.E,_=d.addGeometry(e),p=d.getFirstPath(_);let f=-1,x=!0;const P=new a.P,y=new o.P;let E=r.n;const C=zn*i/360;for(let t=d.getFirstVertex(p);t!==r.n;t=d.getNextVertex(t)){d.queryXY(t,c);let e=1&h&&c.y>=s?1:0;if(e|=2&h&&c.y<=-s?2:0,f>0&&f!==e){if(P.x!==c.x){const e=d.getPrevVertex(t);d.queryPoint(e,y);const s=d.insertVertex(p,t,y);P.x=c.x,d.setXY(s,P)}if(g){let e=E!==r.n?d.getNextVertex(E):d.getFirstVertex(p);const s=d.getPrevVertex(t);for(;e!==s;)e=d.removeVertex(e,!1);if(E!==r.n){const t=d.getXY(E),e=d.getXY(s);if(Math.abs(t.x-e.x)>C){d.queryPoint(E,y);const n=d.insertVertex(p,s,y);t.x=(0,a.q)(t.x,e.x,.5),d.setXY(n,t)}}}E=r.n}if(e&&(c.y=(0,a.f)(n,c.y),d.setXY(t,c),!x&&f!==e))if(c.x!==P.x){d.queryPoint(t,y);const e=d.insertVertex(p,t,y);d.setXYCoords(e,P.x,c.y),E=e}else E=t;f=e,P.assign(c),x=!1}if(g){if(E!==r.n){let t=d.getNextVertex(E);for(;t!==r.n;)t=d.removeVertex(t,!1)}const t=d.getFirstVertex(p);let e=d.getLastVertex(p);const s=d.getXY(t),n=d.getXY(e);if(!s.equals(n)&&(d.queryPoint(t,y),e=d.insertVertex(p,r.n,y),Math.abs(s.x-n.x)>C)){const t=d.insertVertex(p,e,y);s.x=(0,a.q)(s.x,n.x,.5),d.setXY(t,s)}}return e.assignCopy(d.getGeometry(_)),!0}const zn=210;class Un{constructor(t,e,s,i,r,o,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=t,this.m_originalSR=i,this.m_polygonRingFlags=e,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=function(t,e){const s=t.getPannableExtent();return Number.isNaN(e)||s.centerAtCoords(e,0),s}(this.m_pannableSR,o),this.m_centralLongitude=Number.isNaN(o)?this.m_pannableExtent.getCenterX():o,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=zn*this.m_degree,(0,n.g)(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(t,e,s,i,h,m,l){let u=s;const c=new r.P({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,t,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Hn(!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&&(u=!1));let g=-1;u&&(g=this.m_originalGeometry.getPathStart(t));const d=c.getAttributeStreamRef(0),_=c.getPointCount();let p=0,f=d.read(0),x=0;const P=3*this.m_pannableSR.getTolerance(0);let y=!1;const E=new a.P,C=new a.P;let v=!1;const S=c.hasNonLinearSegments(),b=new a.P;for(let t=1;t<_;++t){d.queryPoint2D(2*t,b);const e=b.x;let s=e+p;const r=s-f;if(b.x=s,Math.abs(r)>this.m_GCSLargeDelta){if(u){const e=g+t-1,s=g+(t+1<_?t:0),n=m.read(2*e),o=(m.read(2*s)-n)*i;Math.abs(r-o)>1*this.m_degree&&(u=!1)}u||(p-=(0,a.f)(this.m_width360,s-f),s=e+p,++x,v=0!==p,b.x=s)}else y||(0,o.G)(E,C,b,P)&&(y=!0);v&&(S&&(0,n.d)("error in geonormalize_ring_ for curves"),d.write(2*t,s)),f=s,E.setCoordsPoint2D(C),C.setCoordsPoint2D(b)}x&&c.notifyModified();const I=c.getXY(0),D=c.getXY(_-1);if(a.P.distance(I,D)<P){const t=this.finalizeGeoNormalizeClosedRing(c,y,h);l.add(t,!1)}else{e<0&&(null!==this.m_originalGeometry?((0,n.g)(null!==this.m_originalGeometry),e=this.m_originalGeometry.calculateRingArea2D(t)>0?1:0):e=1);const s=this.finalizeGeoNormalizeOpenedRing(e>0,c);l.add(s,!1)}}geoNormalizePolygonGeometry(t){(0,n.g)(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),(0,n.g)(this.m_pannableSR.isPannable());let e=null,s=Number.NaN;const o=!!this.m_originalSR&&this.m_originalSR.isPannable();o&&(e=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const a=new r.a({vd:this.m_inputPoly.getDescription()});for(let n=0,i=this.m_inputPoly.getPathCount();n<i;++n){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[n]?1:0:-1;this.geonormalizeRing(n,i,o,s,t,e,a)}const h=this.m_pannableSR.getTolerance(0),m=this.m_pannableExtent.width()/180;Ni(a,this.m_pannableExtent,.1*h,!1);const c=i.Envelope2D.constructEmpty();if(c.setCoords({env2D:this.m_pannableExtent}),t){let t=!0;for(let e=0;e<2;e++){t=!0;const e=i.Envelope2D.constructEmpty();for(let s=0,n=a.getPathCount();s<n;s++)if(a.queryPathEnvelope(s,e),!(c.xmin<=e.xmin&&c.xmax>=e.xmax||e.xmin>=c.xmax||e.xmax<=c.xmin)){t=!1;break}if(t)break;c.move(.5*this.m_width360,0)}t||c.setCoords({env2D:this.m_pannableExtent})}let g=(0,l.c)(a,c,h,m,this.m_progressTracker),d=a!==g;const _=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,p=g.calculateArea2D();let f=0;if(p>0&&_<0)f=1;else if(p<=0&&_>0)if(0===p){if(this.m_originalSR){let t=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?t=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(t=this.m_originalSR.getPannableExtent().getArea()),_>.99*t&&(f=-1)}}else f=-1;if(0!==f){const t=function(t,e){let s=new r.a({vd:t});s.addEnvelope(e,!1);const n=e.width()/180;return s=(new u.O).execute(s,n,0,0,null),s}(g.getDescription(),c);t.add(g,!1),d=!0,g=t}return d&&(g=(new Ks).execute(g,this.m_pannableSR,!1,this.m_progressTracker)),g}geoNormalizePolylineGeometry(t){(0,n.g)(this.m_pannableSR.isPannable());let e=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let o=1;s&&((0,n.g)(this.m_originalGeometry),o=this.m_width360/this.m_originalSR.getPannableExtent().width(),e=this.m_originalGeometry.getAttributeStreamRef(0));const h=this.m_pannableExtent.width(),u=h*(0,a.H)()*4;let c=t,g=Number.NaN;const d=a.E.constructEmpty();this.m_bAdjustedAtPoles=0;let _=new r.P({vd:this.m_inputPoly.getDescription()});for(let t=0,l=this.m_inputPoly.getPathCount();t<l;++t){let l=s;const p=new r.P({vd:this.m_inputPoly.getDescription()});p.addPath(this.m_inputPoly,t,!0);const f=this.m_inputPoly.isClosedPath(t);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=Hn(f,p,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,h,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(l=!1));let x=-1;const P=p.getPointCount();let y=!1;l&&(x=this.m_originalGeometry.getPathStart(t),y=this.m_originalGeometry.isClosedPath(t));const E=p.getAttributeStreamRef(0);let C=0,v=E.read(0),S=0;const b=new a.P,I=new a.P;let D=!1;const w=p.hasNonLinearSegments(),T=new a.P;for(let t=1;t<P;++t){E.queryPoint2D(2*t,T);const s=T.x;let i=s+C;const r=i-v;if(T.x=i,Math.abs(r)>this.m_GCSLargeDelta){if(l){const s=x+t-1;let n=x;(!y||t+1<P)&&(n+=t);const i=e.read(2*s),a=(e.read(2*n)-i)*o;Math.abs(r-a)>1*this.m_degree&&(l=!1)}l||(C-=(0,a.f)(this.m_width360,i-v),i=s+C,++S,D=0!==C,T.x=i)}D&&(w&&(0,n.d)("error in geonormalize_ring_ for curves"),E.write(2*t,i)),v=i,b.setCoordsPoint2D(I),I.setCoordsPoint2D(T)}if(S&&p.notifyModified(),c){let t=!1;if(!p.isEmpty()){const e=i.Envelope2D.constructEmpty();if(p.queryEnvelope(e),e.width()>=h||e.ymin<=this.m_pannableExtent.ymin||e.ymax>=this.m_pannableExtent.ymax)t=!0;else{if(Number.isNaN(g)){const t=this.m_centralLongitude-.5*h;g=e.xmin,g+=Math.round((t-e.xmin)/h)*h,g>t&&(g-=h),(0,n.g)(g<=t),g<t&&(g+=h),(0,n.g)(g>=t)}let s=Math.round((g-e.xmin)/h)*h;if(e.xmin+s>g+u&&(s-=h),e.xmin+s<g-u&&(s+=h),d.mergeCoordinate(e.xmin+s),d.mergeCoordinate(e.xmax+s),t=d.width()>=h,!t){const t=new m.T;t.setShiftCoords(s,0),p.applyTransformation(t)}}}_.add(p,!1),t&&(_=(()=>{const t=new r.P({vd:_.getDescription()});for(let e=0,s=_.getPathCount();e<s;++e){const s=new r.P({vd:_.getDescription()});s.addPath(_,e,!0);const n=Pi(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);t.add(n,!1)}return t})(),c=!1)}else{const t=Pi(p,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);_.add(t,!1)}}if(c)return _;const p=this.m_pannableSR.getTolerance(0),f=this.m_pannableExtent.width()/180;return Ni(_,this.m_pannableExtent,.1*p,!1),(0,l.c)(_,this.m_pannableExtent,p,f,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(t,e){const s=e.getPointCount(),o=e.getXY(0),h=e.getXY(s-1);{const t=Math.abs(h.x-o.x),e=Math.round(t/this.m_width360)*this.m_width360;(0,n.g)(Math.abs(t-e)<this.m_pannableSR.getTolerance(0))}const l=(0,a.e)(h.x-o.x),u=i.Envelope2D.constructEmpty();e.queryLooseEnvelope(u);const c=this.m_pannableExtent.getCenterX();let g=0,d=c-this.m_width360,_=c+this.m_width360;if(l>=0){let t=Math.ceil((d-u.xmin)/this.m_width360);for(t*=this.m_width360;d>u.xmin+t;)t+=this.m_width360;for(;d<u.xmax+t;)t-=this.m_width360;for(g=t,u.width()>720&&(_=d+360*Math.ceil(u.width()/360));_<u.xmax;)_+=this.m_width360}else{let t=Math.ceil((_-u.xmax)/this.m_width360);for(t*=this.m_width360;_<u.xmax+t;)t-=this.m_width360;for(;_>u.xmin+t;)t+=this.m_width360;for(g=t,u.width()>720&&(d=_-360*Math.ceil(u.width()/360));d>u.xmin;)d-=this.m_width360}const p=Math.round(Math.abs(h.x-o.x)/this.m_width360)*this.m_width360,f=l*p,x=u.clone();x.move(g,0);const P=new a.P(0,0),y=new m.T;y.setShiftCoords(g,0),e.applyTransformation(y);const E=new r.P({vd:e.getDescription()});E.add(e,!1),P.assign(e.getXY(s-1));let C=0,v=E.getXY(0).x;for(;l>0?x.xmax<_:x.xmin>d;)x.move(f,0),y.xd=f,e.applyTransformation(y),v+=f,this.m_pannableExtent.xmin<=v&&this.m_pannableExtent.xmax>=v&&(C=E.getPointCount()-1),e.setXY(0,P),P.assign(e.getXY(s-1)),E.addSegmentsFromPath(e,0,0,s-1,!1);const S=new r.a({vd:E.getDescription()});S.add(E,!1);const b=E.getXY(0),I=E.getXY(E.getPointCount()-1),D=l<0?t:!t,w=S.getPointCount()-1;if(D){const t=new a.P(I.x,this.m_pannableExtent.ymax);S.lineTo(t);const e=new a.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);S.lineTo(e);const s=new a.P(b.x,this.m_pannableExtent.ymax);S.lineTo(s)}else{const t=new a.P(I.x,this.m_pannableExtent.ymin);S.lineTo(t);const e=new a.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);S.lineTo(e);const s=new a.P(b.x,this.m_pannableExtent.ymin);S.lineTo(s)}if(S.interpolateAttributesPath(0,w,0),S.getImpl().changeRingStartPoint(C),p>this.m_width360){const t=new r.a({copy:S});y.setShiftCoords(this.m_width360,0),t.applyTransformation(y),S.add(t,!1)}return S}finalizeGeoNormalizeClosedRing(t,e,s){const o=new r.a({vd:t.getDescription()});if(o.add(t,!1),o.hasNonLinearSegments()&&(()=>{const t=o.getPointCount()-2;return o.getSegmentType(t)!==n.G.enumLine})()){const t=new r.S,e=o.getPointCount()-2;o.getSegmentBuffer(e,t,!1),o.removePointFromPath(0,e+1),o.closeLastPathWithSegment(t.get())}else o.removePointFromPath(0,o.getPointCount()-1);const h=i.Envelope2D.constructEmpty();o.queryLooseEnvelope(h);let l=Math.ceil((this.m_pannableExtent.xmin-h.xmin)/this.m_width360);for(l*=this.m_width360;this.m_pannableExtent.xmin>h.xmin+l;)l+=this.m_width360;for(;this.m_pannableExtent.xmin<h.xmax+l;)l-=this.m_width360;if(l+=this.m_width360,0!==l){h.move(l,0);const t=new m.T;t.setShiftCoords(l,0),o.applyTransformation(t)}if(this.m_pannableExtent.xmin<=h.xmin&&this.m_pannableExtent.xmax>=h.xmax){if(e){const t=o.calculateArea2D(),e=(new Ks).execute(o,this.m_pannableSR,!0,this.m_progressTracker);if(e!==o){const s=e.calculateArea2D();(0,a.e)(t)!==(0,a.e)(s)&&e.reverseAllPaths(),o.assignMove(e)}}let t;if(t=new r.a(s?{copy:o}:{move:o}),s)for(;h.xmin<this.m_pannableExtent.xmax;){h.move(this.m_width360,0);const e=new m.T;e.setShiftCoords(this.m_width360,0),o.applyTransformation(e),t.add(o,!1)}return t}let u=new r.a({vd:t.getDescription()});u.add(o,!1);const c=e||h.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;h.xmin<this.m_pannableExtent.xmax;){h.move(this.m_width360,0);const t=new m.T;t.setShiftCoords(this.m_width360,0),o.applyTransformation(t),u.add(o,!1)}if(c){const t=u.calculateArea2D();u.setFillRule(1),u=(new Ks).execute(u,this.m_pannableSR,!0,this.m_progressTracker);const e=u.calculateArea2D();(0,a.e)(t)!==(0,a.e)(e)&&u.reverseAllPaths()}return u}geonormalize_ring_(t,e,s,i,r,o,a){(0,n.g)(0)}}function On(t){(0,n.g)(0);const e=function(t){const e=new or({},!0);return e.m_WKID=t,e}(t),s=new jn;return s.setVertProj_(e),s}function Wn(t){return!1}class jn{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new Ar,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return(0,n.g)(0),0}getID(){return(0,n.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,n.g)(0),""}getTextExtended(t){return(0,n.g)(0),""}getText2(t){return(0,n.g)(0),""}getUnit(){return(0,n.g)(0),{}}equals(t){return(0,n.g)(0),!1}equalForProjection(t){return(0,n.g)(0),!1}getPeVertcsCopy(){return(0,n.g)(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return(0,n.g)(0),0}isDepth(){return(0,n.g)(0),!1}getVerticalShift(){return(0,n.g)(0),0}isCustomWkid(){return!!this.m_peVertSysVal&&this.m_peVertSysVal.isCustomWkid()}getHashCode(){return this.m_hashCode}setVertProj_(t){this.m_peVertSysVal=t}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Zn(t,e,s,n,i){if(t.equals(e))return!1;if(n){let s=1,r=0,o=1,a=1,h=0,m=1;Number.isNaN(t.m_heightMetersPerUnit)||(s=t.m_heightMetersPerUnit,r=t.m_heightZ0,o=t.m_heightSign,a=e.m_heightMetersPerUnit,h=e.m_heightZ0,m=e.m_heightSign);const l=o*m*s/a;for(let t=0;t<i;t++)n[t]=(n[t]-r)*l+h}let o=1,a=0;if(Number.isNaN(t.m_XYToRadians)||(o=t.m_XYToRadians/e.m_XYToRadians,a=t.m_PrimeMeridianDegrees-e.m_PrimeMeridianDegrees,0!==a&&(a=(0,r.b)(a),a/=e.m_XYToRadians)),Array.isArray(s)){const t=s;for(let e=0;e<i;e++)t[e][0]=t[e][0]*o+a,t[e][1]=t[e][1]*o}else{const t=s;for(let e=0;e<i;e++){const s=e<<1;t[s]=t[s]*o+a,t[s+1]=t[s+1]*o}}return!0}function Qn(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(t){this.m_heightMetersPerUnit=t.m_heightMetersPerUnit,this.m_heightSign=t.m_heightSign,this.m_heightZ0=t.m_heightZ0,this.m_XYToRadians=t.m_XYToRadians,this.m_PrimeMeridianDegrees=t.m_PrimeMeridianDegrees},equals(t){return(0,a.F)(this.m_heightSign,t.m_heightSign)&&(0,a.F)(this.m_heightMetersPerUnit,t.m_heightMetersPerUnit)&&(0,a.F)(this.m_heightZ0,t.m_heightZ0)&&(0,a.F)(this.m_XYToRadians,t.m_XYToRadians)&&(0,a.F)(this.m_PrimeMeridianDegrees,t.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(t,e){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,e&&(0,n.g)(0),t&&(this.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=t.getPrimem().getLongitude())},initFromGcsAndVcs(t,e){const s=t?t.getPECoordSys():null,n=e?e.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(t){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=t.m_heightMetersPerUnit,this.m_heightSign=t.m_heightSign,this.m_heightZ0=t.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=t.m_XYToRadians,this.m_PrimeMeridianDegrees=t.m_PrimeMeridianDegrees)}}}class Kn{constructor(t){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 o.E,this.m_inputUnitParams=Qn(),this.m_outputUnitParams=Qn(),(0,n.g)(t),this.m_geogTran=t,this.m_vertTran=null,this.m_latestID=bo.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const e=this.m_geogTran.getGeogcs1();bo.getCode(e);const s=this.m_geogTran.getGeogcs2();bo.getCode(s),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():((0,n.g)(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(t){let e=this.m_constantsLoaded;if(-1===e){if(!t){this.m_geogTran||(0,n.d)("vcs not impl");const e=this.m_geogTran.getParameters();null!==e[Io.PE_PARM_ND]&&(t=0===e[Io.PE_PARM_ND].getValue())}e=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=e}return 0!==e}isUsable(){let t=this.m_isUsable;return-1===t&&(this.m_geogTran?this.m_isUsable=t=this.m_geogTran?1:0:this.m_isUsable=t=this.m_vertTran?1:0),1===t}getInputSr(t){return this.updateSrs(),t?this.m_inputSR:this.m_inputSRHorz}getOutputSr(t){return this.updateSrs(),t?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let t=this.m_hashCode;return 0===t&&(t=this.m_latestID>0?(0,a.B)(this.m_latestID):(0,a.I)(this.getText()),0===t&&(t=345),this.m_hashCode=t),t}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():((0,n.t)("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let t,e,s,i,r,o;if(this.m_geogTran){const n=this.m_geogTran.getGeogcs1(),a=Er(n),h=this.m_geogTran.getGeogcs2(),m=Er(h);let l=-1,u=-1;l=a.getVcsCode(),u=m.getVcsCode(),s=Wr(n,null,0,1),i=Wr(h,null,0,1),l>0&&u>0?(r=On(l),o=On(u),t={},e={}):(t=s,e=i)}else(0,n.g)(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=t,this.m_outputSR=e,this.m_inputSRHorz=s,this.m_outputSRHorz=i,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,n.g)(0);else if(this.m_geogTran){const t=this.m_geogTran;let e=t.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=e.getPrimem().getLongitude(),e=t.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=e.getPrimem().getLongitude()}}}function $n(t,e,s,n,i,r,o){let a=null;e&&(a=e.getPEVerticalCoordSys());let h=null;t&&(h=t.getPECoordSys());let m=null;n&&(m=n.getPEVerticalCoordSys());let l=null;if(s&&(l=s.getPECoordSys()),!(h||a||l||m))return!1;const u=Qn();u.initFromGcsAndVcsPe(h,a);const c=Qn();return c.initFromGcsAndVcsPe(l,m),Zn(u,c,i,r,o)}function Jn(t,e,s,n,i,r,o,a){const h=e,m=t,l=Qn();l.initFromGcsAndVcsPe(m,h),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Zn(l,a,i,r,o)}function ti(t,e,s,n,i,r,o,a,h){const m=Qn(),l=Qn();m.assign(s?e.m_inputUnitParams:e.m_outputUnitParams),l.assign(i?n.m_outputUnitParams:n.m_inputUnitParams),m.processUnitParams(t),l.processUnitParams(m),m.processUnitParams(l),a>0&&Zn(m,l,r,o,a),h.assign(l)}function ei(t,e,s,n,i,r,o){const a=e.getVerttran(),h=e.getGeogtran();if(o.assign(s?e.m_inputUnitParams:e.m_outputUnitParams),o.processUnitParams(t),r>0){e.prepareOrThrow();const t=s?Io.PE_TRANSFORM_2_TO_1:Io.PE_TRANSFORM_1_TO_2;a?Zi():Qi(h,r,n,i,t)}}class si{supportsCurves(){return!0}accelerateGeometry(t,e,s){return ni(t,e,s)}canAccelerateGeometry(t){return ii(t)}}function ni(t,e,s){if(!ii(t))return!1;(0,o.j)(e,t,!1);let i=0;const a=t.getGeometryType();return(0,n.h)(a)&&(0,r.y)(t)&&0!==s&&(i|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),(0,n.h)(a)&&(0,r.z)(t)&&0!==s&&(i|=t.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),i>0}function ii(t){return(0,r.y)(t)||(0,r.z)(t)}class ri extends si{getOperatorType(){return 8}execute(t,e,s,n){return $t(t,e,s,1,n)}}class oi{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,n){return new ai(t,e,s,n)}execute(t,e,s,n){return this.executeMany(new c.S([t]),new c.S([e]),s,n).next()}}class ai extends c.G{constructor(t,e,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=t,this.m_spatialReference=s;const i=e.next();this.m_geomSubtractor=i||new r.a}next(){const t=this.m_inputGeoms.next();return t?((0,n.c)(t),(0,n.s)(t),this.m_index=this.m_inputGeoms.getGeometryID(),function(t,e,s,h){if(t.isEmpty()||e.isEmpty())return t;const m=t.getDimension(),u=e.getDimension();if(m>u)return t;const c=t.getGeometryType(),g=e.getGeometryType(),d=new i.Envelope2D,_=new i.Envelope2D,p=new i.Envelope2D;t.queryEnvelope(d),e.queryEnvelope(_),p.setCoords({env2D:d}),p.mergeEnvelope2D(_);const f=(0,o.c)(s,p,!0),x=(0,o.e)(f),P=new i.Envelope2D;if(P.setCoords({env2D:d}),P.inflateCoords(x,x),!P.isIntersecting(_))return t;if(1===m&&2===u){const a=function(t,e,s,a,h){const m=new o.E;t.queryEnvelope(m);const l=new i.Envelope2D;e.queryEnvelope(l),m.merge(l);const u=.1*m.width(),c=.1*m.height();m.inflateCoords(u,c);const g=new r.a;g.addEnvelope(m,!1);const d=g.getImpl();if(s===n.G.enumPolygon){const t=e.getImpl();d.add(t,!0)}else d.addEnvelope(e,!0);return new Js(g,a,-1,h).tryFastImplementation(t)}(t,e,g,s,h);if(a)return a}if(c===n.G.enumPoint){let s;switch((0,n.f)(g)?(s=new r.P({vd:e.getDescription()}),s.addSegment(e,!0)):s=e,g){case n.G.enumPolygon:return function(t,e,s){return 0===$e(e,t,s.total())?t:t.createInstance()}(t,s,f);case n.G.enumPolyline:return function(t,e,s){const n=t.getXY(),r=e.querySegmentIterator(),h=(0,o.e)(s),m=h*h;for(;r.nextPath();)for(;r.hasNextSegment();){const e=r.nextSegment(),o=new i.Envelope2D;if(e.queryEnvelope(o),o.inflateCoords(h,h),!o.contains(n))continue;if(e.isIntersectingPoint(n,s.total()))return t.createInstance();let l=e.getStartXY();if(a.P.sqrDistance(n,l)<=m)return t.createInstance();if(l=e.getEndXY(),a.P.sqrDistance(n,l)<=m)return t.createInstance()}return t}(t,s,f);case n.G.enumMultiPoint:return function(t,e,s){const n=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),r=t.getXY(),h=(0,o.e)(s),m=h*h,l=new a.P;for(let e=0;e<i;e++)if(n.queryPoint2D(2*e,l),a.P.sqrDistance(l,r)<=m)return t.createInstance();return t}(t,s,f);case n.G.enumEnvelope:return function(t,e,s){const n=new i.Envelope2D;e.queryEnvelope(n),n.inflate(s.total());const r=t.getXY();return n.contains(r)?t.createInstance():t}(t,s,f);case n.G.enumPoint:return function(t,e,s){const n=(0,o.e)(s),i=n*n,r=t.getXY(),h=e.getXY();return a.P.sqrDistance(r,h)<=i?t.createInstance():t}(t,s,f);default:(0,n.a)("invalid shape type")}}else if(c===n.G.enumMultiPoint)switch(g){case n.G.enumPolygon:return function(t,e,s){const n=new i.Envelope2D;e.queryEnvelope(n),n.inflate(s.total());const r=t.getPointCount();let o=!1;const h=(0,a.d)(r,!1),m=new a.P;for(let i=0;i<r;i++)t.queryXY(i,m),n.contains(m)&&0!==Je(e,m,s.total())&&(o=!0,h[i]=!0);if(!o)return t;const l=t.createInstance();for(let e=0;e<r;e++)h[e]||l.addPoints(t,e,e+1);return l}(t,e,f);case n.G.enumEnvelope:return function(t,e,s){const n=new i.Envelope2D;e.queryEnvelope(n),n.inflate(s.total());const r=t.getPointCount();let o=!1;const h=(0,a.d)(r,!1),m=new a.P;for(let e=0;e<r;e++)t.queryXY(e,m),n.contains(m)&&(o=!0,h[e]=!0);if(!o)return t;const l=t.createInstance();for(let e=0;e<r;e++)h[e]||l.addPoints(t,e,e+1);return l}(t,e,f);case n.G.enumPoint:return function(t,e,s){const n=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),r=e.getXY();let h=!1;const m=(0,a.d)(i,!1),l=(0,o.e)(s),u=l*l,c=new a.P;for(let t=0;t<i;t++)n.queryPoint2D(2*t,c),a.P.sqrDistance(c,r)<=u&&(h=!0,m[t]=!0);if(!h)return t;const g=t.createInstance();for(let e=0;e<i;e++)m[e]||g.addPoints(t,e,e+1);return g}(t,e,f)}const y=new i.Envelope2D(d);return y.inflate(100*f.total()),function(t,e,s,a){if(t.isEmpty()||e.isEmpty()||t.getDimension()>e.getDimension())return qs(Ms(t),t,0,"-");const h=new i.Envelope2D;t.queryEnvelope(h);const m=new i.Envelope2D;e.queryEnvelope(m);const l=new i.Envelope2D;l.setCoords({env2D:h}),l.mergeEnvelope2D(m);const u=(0,o.c)(s,l,!0),c=m.clone(),g=(0,o.e)(u);if(c.inflateCoords(g,g),!h.isIntersecting(c))return qs(Ms(t),t,0,"-");const d=new Gs(a),_=new r.E,p=_.addGeometry(Ms(t)),f=_.addGeometry(Ms(e));let x=0,P=0,y=null;if(_.hasCurves()){y=new us;const t=_.getEnvelope2D(a);P=ms(u.total());const e=hs(u.total(),t);x=ls(e,P),rs(_,e,u.total(),0,y,null,a)}d.setEditShapeCrackAndCluster(_,u.add(x));const E=d.difference(p,f);null!==y&&y.stitchCurves(_,E,P,!0);const C=qs(_.getGeometry(E),t,0,"-");return Es(C.getGeometryType())&&(C.getImpl().setIsSimple(4,u.total()),C.getGeometryType()===n.G.enumPolygon&&C.getImpl().updateOGCFlagsProtected()),C}(t,(0,l.c)(e,y,0,0,h),s,h)}(t,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class hi{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,n=0){return new li(t,e,s,n)}execute(t,e,s,i){const r=new c.S([t,e]),o=new li(r,s,i,0).next();return o||(0,n.d)("null output"),o}}class mi{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(t){this.binVertexCount+=t.vertexCount,this.geometries.push(t)}sort(){this.geometries.sort((t,e)=>function(t,e){return a.P.compareZorder(t.location,e.location)?-1:t.location.equals(e.location)?0:1}(t,e))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class li extends c.G{constructor(t,e,s,n,i=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=(0,a.C)(4),this.m_dimGeomCounts=(0,a.d)(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=(0,a.d)(4,!1),this.m_complexUnionGeoms=(0,a.C)(4),this.m_totalNonEmptyGeomCounters=(0,a.d)(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=t,this.m_spatialReference=e,this.m_options=n,this.m_bIs3D=i}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let t=0;t<=this.m_maxDimension;t++)if(this.m_bHadGeometry[t]){this.m_complexUnionGeoms[t]=this.getResultGeometry(t);for(let e=t+1;e<=this.m_maxDimension;e++)this.m_complexUnionGeoms[e]=this.getResultGeometry(e),this.m_bHadGeometry[e]&&!this.m_complexUnionGeoms[e].isEmpty()&&(this.m_bIs3D?(0,n.g)(0):this.m_complexUnionGeoms[t]=(new oi).execute(this.m_complexUnionGeoms[t],this.m_complexUnionGeoms[e],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&(0,n.d)(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===n.G.enumPoint){const t=new r.M({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||t.add(this.m_complexUnionGeoms[this.m_currentDim]),t}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(t){return this.m_readyGeoms[t]}finishDim(t,e,s){let i=e;if(!s)return 16&this.m_options?(i=Ns([i],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),i):i;if(1&this.m_options)return i;if(1===t)if(8&this.m_options||!(16&this.m_options||this.m_totalNonEmptyGeomCounters[t]>1))1===this.m_totalNonEmptyGeomCounters[t]&&(this.m_bIs3D?(0,n.g)(0):i=(new Ks).execute(i,this.m_spatialReference,!1,this.m_progressTracker));else{i=Ns([i],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const t=[0],e=i.getImpl().getIsSimple(0,t);(0,n.g)(this.m_bIs3D||(0,o.i)(e))}else this.m_bIs3D?(0,n.g)(0):i=(new Ks).execute(i,this.m_spatialReference,!1,this.m_progressTracker);if(0===t&&i.getGeometryType()===n.G.enumPoint){const t=new r.M({vd:i.getDescription()});i.isEmpty()||t.add(i),i=t}return i}static getLevel(t){const e=(0,n.v)(t);let s=e>0?(Math.log(e)-Math.log(32))/Math.log(4):0;return s<0&&(s=0),Math.floor(s)}step_(){if(this.m_bDone)return!0;let t;if(this.m_inputGeoms?(t=this.m_inputGeoms.next(),null===t?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(t),t.isEmpty()||this.m_totalNonEmptyGeomCounters[t.getDimension()]++)):t=null,null!==t){const e=t.getDimension();this.m_bHadGeometry[e]=!0,(e>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(e,!1,t),e>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(e))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?Ns(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):As(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&((0,n.g)(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,n=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,n)}}return this.m_bDone}addGeom(t,e,s){const r={geom:null,vertexCount:-1,bUnioned:!1,location:new a.P};r.geom=s;const o=(0,n.v)(s);r.vertexCount=o;const h=i.Envelope2D.constructEmpty();s.queryEnvelope(h),r.location=o>0?h.getCenter():new a.P(0,0);const m=li.getLevel(s);if(t+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,t+1);)this.m_unionBins.push(new Map);let l=null;const u=this.m_unionBins[t].get(m);u&&(l=u),null===l&&(l=new mi,this.m_unionBins[t].set(m,l)),r.bUnioned=e,l.addPair(r),this.m_dimGeomCounts[t]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,t)}removeAllBinsWithLowerDimension(t){for(let e=0;e<t;e++)this.m_unionBins[e].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[e],this.m_dimGeomCounts[e]=0}collectGeometriesToUnion(t){if(1&this.m_options&&!this.m_bDone)return null;let e=null;const s=[];for(const e of this.m_unionBins[t].keys())s.push(e);(0,a.v)(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const i=this.m_unionBins[t].get(s[n]);{const r=5e3,o=4,a=i.getBinVertexCount()>r&&i.geomCount()>=o;if(this.m_bDone||a){for(let i=0;i<n;i++){if(-1===s[i])continue;const n=this.m_unionBins[t].get(s[i]);n.sort(),this.m_dimGeomCounts[t]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const t of n.geomPairs())e||(e=new Array),e.push(t.geom);n.clear(),this.m_unionBins[t].delete(s[i]),s[i]=-1}i.sort(),this.m_dimGeomCounts[t]-=i.geomCount(),this.m_addedGeoms-=i.geomCount();for(const t of i.geomPairs())e||(e=new Array),e.push(t.geom);if(i.clear(),this.m_unionBins[t].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return e}checkAndThrow(t){this.m_bIs3D&&(t.getDimension()>1&&(0,n.w)(),t.hasAttribute(1)||(0,n.a)("Geometry must have Zs")),(0,n.c)(t)}}class ui extends si{getOperatorType(){return 3}execute(t,e,s,n=null){return $t(t,e,s,4,n)}}function ci(t,e,s){const h=e.getGCSSplitLines();if(null===h)return t;const l=e.getGCS(),u=l.getPannableExtent().width(),c=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(c);const g=a.E.constructEmpty();c.queryIntervalX(g);const d=h.querySegmentIterator();let _=null;const p=new m.T;for(;d.nextPath();)for(;d.hasNextSegment();){const t=d.nextSegment(),e=t.queryInterval(0,0),s=a.E.constructEmpty();s.setCoordsFromEnvelope(e);let n=0;for(;s.vmax>g.vmin;)s.move(-u),n--;for(;s.vmin<=g.vmax;){if(s.isIntersecting(g)){null===_&&(_=new r.P);const e=new r.L({start:t.getStartXY(),end:t.getEndXY()});0!==n&&(p.setShiftCoords(n*u,0),e.applyTransformation(p)),_.addSegment(e,!0)}s.move(u),++n}}if(null!==_){const e=(0,o.b)(l,_,!0);return function(t,e,s,i){const r=e.getGeometryType();if((0,n.h)(r))return new bt(i).crackAWithBMultiPath_(t,e,s);(0,n.t)("crack_A_with_B")}(t,_,(0,o.e)(e),s)}return t}function gi(t,e,s){let n=t.getName();return ho(n)||(s||e>0?(n=t.toString(Io.PE_STR_NAME_CANON|Io.PE_STR_AUTH_NONE),n=function(t){return t.toLocaleUpperCase("en-US")}(n)):n=t.toString(Io.PE_STR_AUTH_TOP)),n}function di(t,e=-1){if((e>1||e<-1)&&(0,n.a)("verbosity"),-1===e)return t.toString();{const s=0===e?Io.PE_STR_AUTH_TOP:Io.PE_STR_AUTH_ALL;return t.toString(s)}}function _i(t,e,s,r){if(t.isEmpty()||1===s)return t;const a=t.getGeometryType();if(a===n.G.enumPoint){const n=t,i=n.getXY();return 0===xi([i],1,e,s)||i.isNAN()?n.setEmpty():n.setXY(i),t}if(a===n.G.enumMultiPoint){const n=t,i=t.createInstance(),r=n.getPointCount();i.reserve(r);const a=n.getAttributeStreamRef(0),h=n.getDescription().getAttributeCount()>1,m=new o.P,l=Float64Array.from(a.getArray());if(xi(l,r,e,s)>0)for(let t=0,e=2*r;t<e;t+=2)Number.isNaN(l[t])||(h?(n.getPointByVal(t>>1,m),m.setXYCoords(l[t],l[t+1]),i.add(m)):i.addXY(l[t],l[t+1]));return i}let h=t;const u=e.getOneDegreeGCSUnit(),c=90*u,g=180*u,d=360*u,_=e.getCentralMeridian(),p=.5*u,f=i.Envelope2D.constructEmpty();h.queryEnvelope(f);const x=e.getGCSHorizon(),P=e.getGCSHorisonIsInclusive(),y=x.getGeometryType()===n.G.enumEnvelope,E=i.Envelope2D.constructEmpty();x.queryEnvelope(E);const C=e.getGCS();if(2!==s&&4!==s||(E.xmin=_-g,E.xmax=E.xmin+d),4===s){if(!(f.width()>d-u)){const t=i.Envelope2D.constructEmpty();t.setCoords({xmin:f.xmin-u,ymin:E.ymin,xmax:f.xmax+u,ymax:E.ymax}),h=(new l.O).execute(h,t,C,r);let e=Math.floor((_-f.getCenterX())/d);for(f.move(e*d,0);f.xmin>E.xmax;)e-=1,f.move(-d,0);for(;f.xmin<E.xmin;)e+=1,f.move(d,0);if(0!==e){const t=new m.T;t.setShiftCoords(e*d,0),h.applyTransformation(t)}return h}s=2}if(2===s&&(E.xmin=_-g,E.xmax=E.xmin+d),f.ymin<-c||f.ymax>c){const t=i.Envelope2D.constructEmpty();if(t.setCoords({xmin:f.xmin-u,ymin:-c,xmax:f.xmax+u,ymax:c}),h=(new l.O).execute(h,t,C,r),h.isEmpty())return h;h.queryEnvelope(f)}if(P&&(E.ymax<f.ymin||E.ymin>f.ymax))return h.createInstance();f.width()>d&&(h=wi(h,_-g,d,C,!0,0,!0,r),h.queryEnvelope(f));let v=function(t,e,s,n,i){return t>=s&&e<=n?0:Di(.5*(e+t),s,n,i)}(f.xmin,f.xmax,E.xmin,E.xmax,d);if(0!==v&&f.move(v,0),f.xmax>E.xmax||f.xmin<E.xmin){if(f.xmax>E.xmax)for(;f.xmin>=E.xmax;)f.move(-d,0),v-=d;for(;f.xmin<E.xmax-d;)f.move(d,0),v+=d}const S=(0,o.j)(C,x,!1);if(0!==v){const t=new m.T;t.setShiftCoords(v,0),h.applyTransformation(t),v=0}if(P){if(y&&E.containsEnvelope(f))return h;const t=new Array(2);for(let e=0;e<2;e++){let s;if(y?s=(0,n.h)(a)?(0,l.c)(h,E,S,p,r):(0,l.c)(h,E,S,0,r):(s=(new en).execute(h,x,C,r),s===x&&(s=s.clone())),E.xmin<=f.xmin&&E.xmax>=f.xmax)return s;if(E.xmin>=f.xmin&&E.xmax<=f.xmax)return s;if(t[e]=s,0===e){f.move(-d,0);const t=new m.T;t.setShiftCoords(-d,0),h.applyTransformation(t)}}return(0,n.h)(a)?t[0].add(t[1],!1):(0,n.d)("intersect_with_GCS_horizon: unexpected geometry type"),t[0]}{if(E.ymax<f.ymin||E.ymin>f.ymax)return h;let t=0;for(;!h.isEmpty()&&f.xmax>E.xmin;){if(0!==t){const e=new m.T;e.setShiftCoords(t,0),h.applyTransformation(e)}if((new ui).execute(h,x,C,r)||(h=(new oi).execute(h,x,C,r),x===h&&(h=h.clone())),0!==t){const e=new m.T;e.setShiftCoords(-t,0),h.applyTransformation(e)}t-=d,f.move(-d,0)}return h}}function pi(t,e,s,n,i,m){const l={stack:[],error:void 0,hasError:!1};try{if(2===m)return function(t,e,s,n,i){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>a.o||Math.abs(n.y)>a.o)return Number.NaN;if((Math.abs(s.y)===a.o||Math.abs(n.y)===a.o)&&s.x!==n.x)return Number.NaN;const{first:h,second:m}=(0,a.W)(s.x,n.x);let l=i;if(l=v(l,h,m),!a.E.construct(s.x,n.x).containsCoordinate(l))return Number.NaN;const u=r.X.constructPoint2D(s),c=r.X.constructPoint2D(n),g=I(1,e,u),d=I(1,e,c),_=g.crossProductVector(d);if(_.z.isZero())return s.y;const p=_.x.divE(_.z.negate()),f=_.y.divE(_.z.negate()),x=p.mulE(p).addE(f.mulE(f)).sqrt();if(x.isZero()||p.isZero()&&f.isZero())return s.y;const P=Math.atan2(f.value(),p.value());let y=Math.atan2(x.value()*Math.cos(P-l),1-e);const E=S(1,e,a.P.construct(l,y)),C=o.d.construct(E.x,E.y,-E.z),b=_.value().dotProduct(E),D=_.value().dotProduct(C);return Math.abs(D)<Math.abs(b)&&(y=-y),y}(0,e,s,n,i);if(Math.abs(s.x-n.x)>=Math.PI||!er(s.x,n.x,i))return Number.NaN;s.x>n.x&&(n=(0,a.c)(s,s=n));const u=(0,h.mS)(l,new So,!1),c=(0,h.mS)(l,new So,!1),g=(0,h.mS)(l,new So,!1),d=s.clone();Go.geodeticDistance(t,e,s.x,s.y,n.x,n.y,c,u,null,m);const _=c.val;let p=0,f=1;for(;_*(f-p)>1e-12*t;){const r=.5*(p+f);if(Go.geodeticCoordinate(t,e,s.x,s.y,_*r,u.val,c,g,m),d.x=c.val,d.y=g.val,d.x===i)return d.y;if(er(s.x,d.x,i))f=r;else{if(!er(n.x,d.x,i))return Number.NaN;p=r}}return d.y}catch(t){l.error=t,l.hasError=!0}finally{(0,h.hk)(l)}}function fi(t,e,s,n){for(let i=0,r=0;i<n;i++,r+=2)e[s+i].x=t[r],e[s+i].y=t[r+1]}function xi(t,e,s,r){if(0===e||1===r)return e;const h=function(t,e){let s;if(Array.isArray(t)){const n=t;s=new Float64Array(2*e);for(let t=0,i=0;t<e;t++,i+=2)s[i]=n[t].x,s[i+1]=n[t].y}else s=t;return s}(t,e);if(2===r){const n=s.getPannableExtentInGCS();let i=e;for(let t=0,s=2*e;t<s;t+=2)(h[t+1]>n.ymax||h[t+1]<n.ymin)&&(h[t]=Number.NaN,i--);return i?(Ti(h,e,n.xmin,n.width(),!0),t!==h&&fi(h,t,0,e),i):(t!==h&&fi(h,t,0,e),0)}const m=s.getOneDegreeGCSUnit(),l=90*m,u=180*m,c=360*m;let g=e;for(let t=0,s=2*e;t<s;t+=2)(h[t+1]>l||h[t+1]<-l)&&(h[t]=Number.NaN,g--);if(!g)return t!==h&&fi(h,t,0,e),0;const d=i.Envelope2D.constructEmpty();d.setFromPoints(h,e);const _=s.getGCSHorizon(),p=s.getGCSHorisonIsInclusive(),f=_.getGeometryType()===n.G.enumEnvelope,x=i.Envelope2D.constructEmpty();if(_.queryEnvelope(x),p&&(x.ymax<d.ymin||x.ymin>d.ymax))return t!==h&&fi(h,t,0,e),0;if(p)if(Ti(h,e,x.getCenterX()-u,c,!0),g=e,f)for(let t=0,s=2*e;t<s;t+=2)x.containsCoords(h[t],h[t+1])||(h[t]=Number.NaN,g--);else{const t=(0,o.j)(s.getGCS(),_,!1),n=new a.P;for(let s=0,i=2*e;s<i;s+=2)n.setCoords(h[s],h[s+1]),0!==Je(_,n,t)||(h[s]=Number.NaN,g--)}else{Ti(h,e,-u,c,!0),g=e;const t=(0,o.j)(s.getGCS(),_,!1),n=new a.P;for(let s=0,i=2*e;s<i;s+=2){n.setCoords(h[s],h[s+1]),n.isNAN()&&g--;const e=Di(n.x,x.xmin,x.xmax,c);n.x+=e,0!==Je(_,n,t)&&(h[s]=Number.NaN,g--)}}return t!==h&&fi(h,t,0,e),g}function Pi(t,e,s,i,r,o){if(e.isPannable()||(0,n.a)("fold_into_360_degree_range"),t.isEmpty())return t;let a,h;if(2===e.getCoordinateSystemType()){const t=e.getPannableExtent();h=t.xmin,a=t.width()}else{const t=e.getOneDegreeGCSUnit();a=360*t,h=s-180*t}return wi(t,h,a,e,i,r,!0,o)}function yi(t,e,s,n){let i,r;if(2===s.getCoordinateSystemType()){const t=s.getPannableExtent();i=t.xmin,r=t.width()}else{const t=s.getOneDegreeGCSUnit();r=360*t,i=n-180*t}Ti(t,e,i,r)}function Ei(t,e){const s=e.width();let n=(0,a.n)(t-e.vmin,s);return n<0&&(n+=s),e.snapClip(n+e.vmin)}function Ci(t,e,s){return t>e.xmax&&t-e.xmax<s?e.xmax:t<e.xmin&&e.xmin-t<s?e.xmin:t}function vi(t,e,s){if(t[0]<e.vmin||t[0]>e.vmax||s&&t[0]===e.vmax){const s=e.width();return t[0]+=Math.ceil((e.vmin-t[0])/s)*s,t[0]=e.snapClip(t[0]),!0}return!1}function Si(t,e,s,n,i){const a=new r.E,h=a.addGeometry(t);return bi(a,h,e,(0,o.j)(e,t,!1),s,n,i),a.getGeometry(h)}function bi(t,e,s,i,o,m,l){const u={stack:[],error:void 0,hasError:!1};try{(0,n.g)(Br()),s.isPannable()||(0,n.p)("insert_geodetic_points");const c=s.getPannableExtent(),g=s.getGCS(),d=Rr();g.querySpheroidData(d);const _=g.getUnit().getUnitToBaseFactor(),p=d.majorSemiAxis,f=d.e2;let x=0;const P=new a.E;c.queryIntervalX(P);let y=null;const E=(0,a.d)(4,Number.NaN);2===s.getCoordinateSystemType()?(y=s.getPECoordSys(),m?(E[0]=Ei(l,P),E[1]=c.getCenterY(),Do.projToGeog(y,1,E),x=E[0]*_):(E[0]=c.getCenterX(),E[1]=l,Do.projToGeog(y,1,E),x=E[1]*_)):x=l*_,m||0===x||2===o||(0,n.p)("insert_geodetic_points: 1");const C=(0,h.mS)(u,new So,!1),v=new a.P,S=new a.P,b=new a.P,I=new a.P,D=new a.P,w=new a.P;for(let n=t.getFirstPath(e);n!==r.n;n=t.getNextPath(n)){const e=t.getFirstVertex(n);t.queryXY(e,b);let h=!1;const u=t.getNextVertex(e);for(let e=u;e!==r.n;e=t.getNextVertex(e)){if(e===u){if(h)break;h=!0}if(t.queryXY(e,I),m&&(i<l-b.x&&I.x-l>i||i<l-I.x&&b.x-l>i)||!m&&(0!==l||i<-b.y&&I.y>i||i<-I.y&&b.y>i))do{if(Math.abs(b.x-I.x)>=.5*P.width())break;2===s.getCoordinateSystemType()?(E[0]=Ei(b.x,P),E[1]=b.y,E[2]=Ei(I.x,P),E[3]=I.y,Li(y,2,E,0),D.x=E[0]*_,D.y=E[1]*_,w.y=E[3]*_):(D.x=b.x*_,D.y=b.y*_,w.y=I.y*_),w.x=(I.x-b.x)*Math.PI*2/P.width()+D.x;let n=0;const i=(0,a.m)(a.P,2);if(m){if(S.x=x,S.y=pi(p,f,D,w,x,o),Number.isNaN(S.y))break;i[0]=S,n=1}else if(2===o){const t=[0,0];if(n=A(0,f,D,w,x,t),!n)break;i[0].x=t[0],i[0].y=x,2===n&&(i[1].x=t[1],i[1].y=x)}else{if(S.x=sr(p,f,D,w,o),Number.isNaN(S.x))break;S.y=0,i[0]=S,n=1}let r=-1;for(let h=0;h<n;h++){Go.geodeticDistance(p,f,D.x,D.y,w.x,w.y,C,null,null,o);const n=C.val;Go.geodeticDistance(p,f,D.x,D.y,i[h].x,i[h].y,C,null,null,o);const u=C.val;2===s.getCoordinateSystemType()?(E[0]=i[h].x/_,E[1]=i[h].y/_,Do.geogToProj(y,1,E),m?(v.y=E[1],v.x=l):(v.x=nr(E[0],b.x,I.x,P),v.y=l)):m?(v.x=l,v.y=i[h].y/_):(v.x=nr(i[h].x/_,b.x,I.x,P),v.y=l);const c=n>0?(0,a.s)(u/n,0,1):.5;if(0===c||1===c)continue;if(r>c)continue;const g=t.getPrevVertex(e);t.splitSegment(g,[c],1);const d=t.getNextVertex(g);t.setXYCoords(d,v.x,v.y),r=c}}while(0);b.setCoordsPoint2D(I)}}}catch(t){u.error=t,u.hasError=!0}finally{(0,h.hk)(u)}}function Ii(t,e){(0,n.g)(e.isPannable());const s=e.getPannableExtent();if(t.getGeometryType()===n.G.enumPoint){const e=t.getY();return s.ymin<=e&&e<=s.ymax?t:t.createInstance()}const r=i.Envelope2D.constructEmpty();t.queryEnvelope(r);const a=i.Envelope2D.constructEmpty();a.setCoords({env2D:s}),a.xmin=r.xmin,a.xmax=r.xmax,a.inflateCoords(.01*a.height(),0);const h=(0,o.a)(e,r,!1);let m;return m=a.containsEnvelope(r)?t:(0,l.c)(t,a,h,0,null),m}function Di(t,e,s,n){return(0,a.G)((.5*(s+e)-t)/n)*n}function wi(t,e,s,o,h,u,c,g){const d=t.getGeometryType(),_=a.E.constructEmpty();_.setCoords(e,e+s);const p=[0];if(d===n.G.enumPoint){const e=t;if(p[0]=e.getX(),vi(p,_,c)){const e=h?t:t.clone();return e.setX(p[0]),e}return t}const f=i.Envelope2D.constructEmpty();if(t.queryEnvelope(f),f.isEmpty())return t;if(d===n.G.enumMultiPoint){const e=h?t:t.clone(),s=e.getImpl(),n=s.getAttributeStreamRef(0),i=2*s.getPointCount();let r=!1;for(let t=0;t<i;t+=2)p[0]=n.read(t),vi(p,_,c)&&(n.write(t,p[0]),r=!0);return r&&s.notifyModifiedFlags(2001),e}const x=a.E.constructEmpty();if(f.queryIntervalX(x),_.contains(x))return _.vmax,x.vmax,t;const P=i.Envelope2D.constructEmpty();if(P.setCoords({env2D:f}),0===x.width()){let e=x.vmin;e+=Math.ceil((_.vmin-e)/s)*s,e=_.snapClip(e);const n=h?t:t.clone();return n.setAttributeBasic(0,0,e),n}if(d===n.G.enumEnvelope){const e=h?t:t.clone();return f.intersect(P),e.setEnvelope(f),e}const y=.1*Math.max(f.height(),f.width())*1;P.inflateCoords(0,y);let E=t;const C=o.getTolerance(0),v=new m.T;for(;;){const t=Math.floor((x.vmin-e)/s),i=Math.ceil((x.vmax-e)/s);if(!(i-t>3))break;{const r=Math.floor(.5*(i+t));P.xmin=f.xmin-y,P.xmax=e+s*r;const a=(0,l.c)(E,P,C,u,g);P.xmin=P.xmax,P.xmax=f.xmax+y;const h=(0,l.c)(E,P,C,u,g);v.setShiftCoords((r-i)*s,0),h.applyTransformation(v),d===n.G.enumPolygon?E=(new hi).execute(a,h,o,g):(E=a,E.add(h,!1)),E.queryEnvelope(f),f.queryIntervalX(x)}}P.xmin=e,P.xmax=e+s;const S=i.Envelope2D.constructEmpty();S.setCoords({env2D:P}),S.inflateCoords(C,0);const b=Math.floor((f.xmin-P.xmin)/s)*s;let I;b?(P.move(b,0),v.setShiftCoords(-b,0)):v.setIdentity(),I=d===n.G.enumPolyline?new r.P({vd:E.getDescription()}):new r.a({vd:E.getDescription()});const D=i.Envelope2D.constructEmpty(),w=i.Envelope2D.constructEmpty();for(;f.xmax>P.xmin;){const t=(0,l.c)(E,P,C,0,g);t.queryEnvelope(w);let e=!1;e=d===n.G.enumPolyline?!t.isEmpty()&&(w.width()>C||w.height()>C):!t.isEmpty()&&(d!==n.G.enumPolygon||w.width()>C),e&&(t.applyTransformation(v),t.queryEnvelope(w),I.queryEnvelope(D),D.inflateCoords(C,C),D.isIntersecting(w)&&d===n.G.enumPolygon?I=(new hi).execute(I,t,o,g):I.add(t,!1)),P.move(s,0),v.shiftCoords(-s,0)}return I}function Ti(t,e,s,n,i=!0){const r=new a.E;r.setCoords(s,s+n);const o=[0];if(Array.isArray(t)){const s=t;for(let t=0;t<e;t++)r.containsRightExclusive(s[t].x)||(o[0]=s[t].x,vi(o,r,i),s[t].x=o[0])}else{const s=t;for(let t=0;t<e;t++){const e=t<<1;r.containsRightExclusive(s[e])||(o[0]=s[e],vi(o,r,i),s[e]=o[0])}}}function Ni(t,e,s,r=!0){if(t.isEmpty())return;const o=t.getGeometryType();if(!r||o!==n.G.enumPolygon)if((0,n.i)(o)){let i=!1;if((0,n.h)(o)&&t.hasNonLinearSegments()){const r=t.getImpl(),o=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();(0,n.g)(null!==a);for(let t=0,n=r.getPathCount();t<n;t++){let n=!0;const h=r.isClosedPath(t),m=r.getPathEnd(t);h&&r.getPathSize(t)>0&&(n=1==(31&a.read(m-1)));for(let h=r.getPathStart(t);h<m;h++)if(1==(31&a.read(h))){if(n){const t=o.read(2*h),n=Ci(t,e,s);n!==t&&(i=!0,o.write(2*h,n))}n=!0}else n=!1}}else{const n=t.getImpl(),r=n.getAttributeStreamRef(0);for(let t=0,o=n.getPointCount();t<o;t++){const n=r.read(2*t),o=Ci(n,e,s);o!==n&&(i=!0,r.write(2*t,o))}}i&&t.getImpl().notifyModifiedFlags(2001)}else if(o===n.G.enumEnvelope){const n=t,r=i.Envelope2D.constructEmpty();n.queryEnvelope(r),r.xmin=Ci(r.xmin,e,s),r.xmax=Ci(r.xmax,e,s),n.setEnvelope(r)}else if(o===n.G.enumPoint){const n=t;n.setX(Ci(n.getX(),e,s))}else(0,n.d)("")}function Ai(t,e,s){const n=new a.P;return n.x=Ci(t.x,e,s),n.y=t.y,n}function Gi(t,e,s,r){const h=t.getGeometryType();(0,n.g)(h===n.G.enumPolygon||h===n.G.enumPolyline||h===n.G.enumMultiPoint);const m=e.getCoordinateSystemType();if(2===m){let m=t;if(0===s){const s=function(t,e){if(e.isEmpty())return 0;const s=t.getPECoordSys();if(s.getProjection().getCode()===Io.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Rr();t.querySpheroidData(n);const r=s.getParameters();if(null===r[Io.PE_PARM_LAM0])return 0;if(null===r[Io.PE_PARM_PHI0])return 0;const o=[r[Io.PE_PARM_LAM0].getValue(),r[Io.PE_PARM_PHI0].getValue()];Do.geogToProj(s,1,o);const h=new a.P(o[0],o[1]),m=i.Envelope2D.constructEmpty();e.queryEnvelope(m);const l=(0,a.m)(a.P,4);m.queryCorners(l);let u=0;const c=t.getOneMeter();let g=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,d=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;d-=g/180,g*=c,d*=c;for(let t=0;t<4;t++){const e=a.P.distance(l[t],h);if(e>g)u++;else if(e>d)return-1}if(0===u)return 1;if(4===u){const t=i.Envelope2D.constructEmpty();return t.setCoords({center:h,width:g,height:g}),m.isIntersectingNe(t)?-1:0}return-1}return-1}(e,t);if(0===s)return t.createInstance();if(1===s)return t;const h=e.getPCSHorizon(),u=h.getGeometryType(),c=e.getDefaultPrecisionSR();if(u===n.G.enumEnvelope){const s=i.Envelope2D.constructEmpty();h.queryEnvelope(s);const n=(0,o.a)(c,s,!1);m=(0,l.c)(t,s,n,5e4*e.getOneMeterPCSUnit(),r)}else(new ri).execute(h,t,c,r)||(m=(new en).execute(m,h,c,r),m===h&&(m=m.clone()))}else if(e.isPannable()){const t=i.Envelope2D.constructEmpty();m.queryEnvelope(t);const o=e.getPannableExtent();o.containsEnvelope(t)||(Ni(m,o,e.getTolerance(0)),2!==s&&4!==s||(m=Ii(m,e)),4!==s?m=Pi(m,e,0,!0,1e5*e.getOneMeterPCSUnit(),r):h===n.G.enumPolygon&&t.width()>2*o.width()&&(m=wi(m,-2*o.width(),2*o.width(),e,!0,0,!0,r)))}return m}if((0,n.g)(1===m),h===n.G.enumMultiPoint)return Ni(t,e.getPannableExtent(),e.getTolerance(0)),t;{const s=i.Envelope2D.constructEmpty();t.queryEnvelope(s);let o=t;const a=e.getPannableExtent();if(s.ymin<a.ymin||s.ymax>a.ymax){const t=Math.max(1,s.calculateToleranceFromEnvelope()),n=new i.Envelope2D(s.xmin-t,a.ymin,s.xmax+t,a.ymax);if(o=(new l.O).execute(o,n,e,r),o.isEmpty())return o}return h===n.G.enumPolygon&&s.width()>2*a.width()&&(o=wi(o,-2*a.width(),2*a.width(),e,!0,0,!0,r)),o}}function qi(t,e){const s=e.getPointCount();if(!s)return;const n=e.getImpl(),i=n.getAttributeStreamRef(0),r=t;Do.geogToProj(r,s,i.getArray()),n.notifyModifiedFlags(2001)}function Mi(t,e,s,n){if(!s)return;const i=t.getPECoordSys();if(1===s){if(e[0].isNAN())return;const s=[e[0].x,e[0].y];if(Do.geogToProj(i,1,s),n){const{first:n,second:i}=t.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(e[0].x-t.getCentralMeridian())+i}return void e[0].setCoords(s[0],s[1])}const r=t.isPannable(),o=r?t.getPannableExtent().width():0,h=179*o/360;let m=0;r&&(m=t.getCentralMeridian());const l=new Float64Array(512);for(let u=0;u<s;){for(let t=u;t<s&&e[t].isNAN();++t)u++;let c=Math.min(256,s-u);if(c>0){for(let t=1,s=u+1;t<c;++t,++s)if(e[s].isNAN()){c=t;break}for(let t=0;t<c;++t){const s=t<<1;l[s]=e[u+t].x,l[s+1]=e[u+t].y}if(Do.geogToProj(i,c,l),n){const{first:s,second:n}=t.m_peCoordSysVal.getGeogToProjFactors();for(let t=0;t<c;++t)l[t<<1]=s*(e[u+t].x-m)+n}if(r)for(let t=0,s=u;t<c;t++,s++){const n=t<<1,i=l[n],r=(0,a.e)(i),u=e[s].x-m;r*(0,a.e)(u)<0&&Math.abs(i)>h&&(l[n]-=r*o)}fi(l,e,u,c),u+=c}}}function Fi(t,e,s,n){const o=new r.M({vd:e.getDescription()});let a;o.addPoints(e,0,-1),a=(new un).execute(o,t,n);const h=e.getPointCount();if(s.setEmpty(),t.getInputSR().isPannable()){if(h!==a.getPointCount())return!1;const n=new i.Envelope2D;e.queryEnvelope(n);const r=new i.Envelope2D;a.queryEnvelope(r);const o=n.width(),m=r.width();if(0!==o&&0!==m){const e=m/o,s=t.getOutputSR().getPannableExtent().width()/t.getInputSR().getPannableExtent().width();if(Math.abs(e/s-1)>1e-10)return!1}else if(0!==o||0!==m)return!1;s.add(e,!1);for(let t=0;t<h;t++){const e=a.getXY(t);s.setXY(t,e)}return!0}return!1}function Xi(t,e,s){(0,n.g)(!s||t.isPannable());const i=e.getPointCount();if(!i)return;const r=e.getImpl(),o=r.getAttributeStreamRef(0),h=t.getPECoordSys();let m=0;const l=o.readRange(0,2*i);let u=()=>{Do.geogToProj(h,i,l)};const c=t.isPannable()&&!s,g=c?t.getPannableExtent().width():0,d=179*g/360;if(t.isPannable()&&(m=t.getCentralMeridian(),s)){const e=t.m_peCoordSysVal.getGeogToProjFactors(),s=e.first,n=e.second;u=()=>{Do.geogToProj(h,i,l);for(let t=0;t<i;t++){const e=t<<1,i=o.read(e),r=s*(i-m)+n;l[e]=r}}}if(u(),c)for(let t=0;t<i;t++){const e=t<<1,s=l[e],n=(0,a.e)(s),i=o.read(e)-m;n*(0,a.e)(i)<0&&Math.abs(s)>d&&(l[e]+=-n*g)}o.writeRangeFromArray(0,2*i,l,!0,1),r.notifyModifiedFlags(2001)}function Vi(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const n=[e.getStartXY(),e.getEndXY()];Mi(t,n,2,s),e.setStartXY(n[0]),e.setEndXY(n[1]),e.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const n=(0,a.m)(a.P,4);e.queryControlPoints(n),$i(t,n,4,s),e.setControlPoints(n)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===e.projectionBehavior())!function(t,e,s){tr(!0,t,0,e,s)}(t,e,s);else{const n=e.isClosed()&&e.isMajor(),i=[e.getStartXY(),n?e.getCenter():e.getEndXY()],r=[i[0].clone(),i[1].clone()];$i(t,r,2,s);const o=new m.T;o.initializeFromTwoPointsArray(i,r),e.applyTransformation(o);const a=n?0:1;e.setCoordsForIntersector(r[0],r[a],!1)}}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return void(0,n.g)(0);default:(0,n.d)("")}}function Yi(t,e,s){if(!e.hasNonLinearSegments())return void Xi(t,e,s);if((0,n.g)(!s||t.isPannable()),e.isEmpty())return;const i=t.getPECoordSys(),h=t.isPannable(),m=h?t.getPannableExtent().width():0,l=179*m/360;let u=0;h&&(u=t.getCentralMeridian());const c=e.createInstance();c.reserveParts(e.getPointCount(),e.getPathCount());const g=e.getImpl(),d=new r.S;for(let n=0,r=e.getPathCount();n<r;++n)if(g.hasNonLinearSegmentsPath(n)){let e=!0,i=-1;const r=g.getPathStart(n),h=r+g.getSegmentCountPath(n);g.isClosedPath(n)&&(i=h-1);const m=new a.P;for(let n=r;n<h;++n){if(g.getSegmentBuffer(n,d,!1),Vi(t,d.get(),s),e||d.get().getStartXY().equals(m)||d.get().moveTo(m),n!==i)c.addSegment(d.get(),e);else{if(e){const t=new o.P;d.get().queryStart(t),c.startPathPoint(t)}c.closeLastPathWithSegment(d.get())}m.assign(d.get().getEndXY()),e=!1}}else{const t=1024;let s,r=g.getPathSize(n),o=Math.min(r,t);c.insertPath(-1,e,n,!0);const d=g.getAttributeStreamRef(0),_=c.getAttributeStreamRef(0);for(let e=g.getPathStart(n),c=g.getPathEnd(n);e<c;){if(s=d.readRange(e,o),Do.geogToProj(i,o,s),h)for(let t=0;t<o;t++){const e=t<<1,n=s[e],i=(0,a.e)(n),r=d.read(2*(0+t))-u;i*(0,a.e)(r)<0&&Math.abs(n)>l&&(s[e]+=-i*m)}_.writeRangeFromArray(e,o,s,!0,1),e+=o,r-=o,o=Math.min(r,t)}}e.assignMove(c)}function Ri(t,e,s){let n=s.getPointCount();if(!n)return;const i=s.getImpl(),r=i.getAttributeStreamRef(0);let o=Math.min(n,1e3),h=0;const m=t.getPECoordSys();Number.isNaN(e)&&(e=0);const l=t.isPannable(),u=t.getOneDegreeGCSUnit(),c=360*u,g=179*u;let d;for(;n;){if(d=r.readRange(2*h,2*o),Li(m,o,d,e),l)for(let t=0;t<o;t++){const s=t<<1,n=d[s]-e,i=(0,a.e)(n),o=r.read(2*(h+t));i*(0,a.e)(o)<0&&Math.abs(n)>g&&(d[s]+=-i*c)}r.writeRangeFromArray(2*h,2*o,d,!0,1),h+=o,n-=o,o=Math.min(n,1e3)}i.notifyModifiedFlags(2001)}function ki(t,e,s){switch(s.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const n=[s.getStartXY(),s.getEndXY()];Hi(t,e,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const n=(0,a.m)(a.P,4);s.queryControlPoints(n),Ji(t,e,n,4),s.setControlPoints(n)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===s.projectionBehavior())!function(t,e,s){tr(!1,t,e,s,!1)}(t,e,s);else{const n=s.isClosed()&&s.isMajor(),i=[s.getStartXY(),n?s.getCenter():s.getEndXY()],r=[i[0].clone(),i[1].clone()];Ji(t,e,r,2);const o=new m.T;o.initializeFromTwoPointsArray(i,r),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(r[0],r[a],!1)}}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return void(0,n.g)(0);default:(0,n.d)("")}}function Li(t,e,s,i){const r=Do.projToGeogCenter(t,e,s,i);for(let t=0;t<e;++t){const e=t<<1;(0,n.g)(Number.isFinite(s[e]+s[e+1]))}return r}function Bi(t,e,s){if(!s.hasNonLinearSegments())return void Ri(t,e,s);if(s.isEmpty())return;const n=t.getPECoordSys();Number.isNaN(e)&&(e=0);const i=t.isPannable(),h=t.getOneDegreeGCSUnit(),m=360*h,l=179*h,u=s.createInstance();u.reserveParts(s.getPointCount(),s.getPathCount());const c=s.getImpl(),g=new r.S;for(let r=0,h=s.getPathCount();r<h;++r)if(c.hasNonLinearSegmentsPath(r)){let s=!0,n=-1;const i=c.getPathStart(r),h=i+c.getSegmentCountPath(r);c.isClosedPath(r)&&(n=h-1);const m=new a.P;for(let r=i;r<h;++r){if(c.getSegmentBuffer(r,g,!1),ki(t,e,g.get()),s||g.get().getStartXY().equals(m)||g.get().moveTo(m),r!==n)u.addSegment(g.get(),s);else{if(s){const t=new o.P;g.get().queryStart(t),u.startPathPoint(t)}u.closeLastPathWithSegment(g.get())}m.assign(g.get().getEndXY()),s=!1}}else{const t=1e3;let o,h=c.getPathSize(r),g=Math.min(h,t);u.insertPath(-1,s,r,!0);const d=c.getAttributeStreamRef(0),_=u.getAttributeStreamRef(0);for(let s=c.getPathStart(r),u=c.getPathEnd(r);s<u;){if(o=d.readRange(2*s,2*g),Li(n,g,o,e),i)for(let t=0;t<g;t++){const n=t<<1,i=o[n]-e,r=(0,a.e)(i),h=d.read(2*s);r*(0,a.e)(h)<0&&Math.abs(i)>l&&(o[n]+=-r*m)}_.writeRangeFromArray(2*s,2*g,o,!0,1),s+=g,h-=g,g=Math.min(h,t)}}s.assignMove(u)}function Hi(t,e,s,n){const i=t.getPECoordSys();Number.isNaN(e)&&(e=0);const r=t.isPannable(),o=t.getOneDegreeGCSUnit(),h=360*o,m=179*o,l=new Float64Array(512);for(let t=0;t<n;){for(let e=t;e<n&&s[e].isNAN();++e)t++;let o=Math.min(256,n-t);if(o>0){for(let e=1,n=t+1;e<o;++e,++n)if(s[n].isNAN()){o=e;break}for(let e=0;e<o;e++){const n=e<<1;l[n]=s[t+e].x,l[n+1]=s[t+e].y}if(Li(i,o,l,e),r)for(let n=0,i=t;n<o;++n,++i){const t=n<<1,r=s[i].x,o=l[t]-e,u=(0,a.e)(o);u*(0,a.e)(r)<0&&Math.abs(o)>m&&(l[t]-=u*h)}for(let e=0;e<o;e++){const n=e<<1;s[t+e].x=l[n],s[t+e].y=l[n+1]}t+=o}}}function zi(t,e,s,i){(0,n.g)(0)}function Ui(t,e,s){let n=e.getPointCount();if(!n)return!1;const i=e.getImpl(),r=i.getAttributeStreamRef(0);let o=null;const h=t.getInputSR(),m=t.getOutputSR();h.getVCS(),m.getVCS();const l=h.getOneDegreeGCSUnit(),u=m.getOneDegreeGCSUnit(),c=t.isVertical();c&&e.hasAttribute(1)&&(o=i.getAttributeStreamRef(1));const g=t.getDatumTransformation(),d=!!g&&1===g.getType();if(d||null===o||(zi(o.getArray()),o=null),!g||0===g.count()){const t=h.getGcsUnitFactor()/m.getGcsUnitFactor(),e=(h.getPrimeMeridian()-m.getPrimeMeridian())*u,s=-90*l,o=90*l;let c=0;const g=r.getArray(),d=[0];for(let t=1,e=2*n;t<e;)d[0]=g[t],c|=(0,a.V)(d,s,o)?1:0,g[t]=d[0],t+=2;if(0!==e||1!==t){c=1;const s=r.getArray();for(let i=0,r=2*n;i<r;){let n=s[i];n*=t,n+=e,s[i]=n,s[i+1]*=t,i+=2}}return 0!==c&&i.notifyModifiedFlags(2001),!!c}let _=Math.min(n,1e3);const p=(0,a.d)(_,Number.NaN),f=(0,a.d)(_,Number.NaN);let x=null;null!==o&&(x=new Float64Array(_));let P=0,y=Number.NaN,E=Number.NaN;const C=360*u,v=u/l;s&&(E=90*u,y=89.9*l,f.fill(0));let S=!0,b=0;for(;n;){let t=!1;const e=r.readRange(2*P,2*_);for(let t=0;t<_;t++)p[t]=e[t<<1];if(s)for(let s=0;s<_;s++){const n=1+(s<<1),i=Math.abs(e[n])-y;if(i>0){const r=e[n];e[n]=(0,a.f)(y,r),f[s]=(0,a.f)(i,r),t=!0}}const i=e[0];if(d){const t=g;x&&o.queryRange(P,_,x,!0,1),t.transform(!1,e,x,_),x&&o.writeRangeFromArray(P,_,x,!0,1)}else g.transform(!1,e,_);S&&(b=e[0]-v*i,S=!1);for(let t=0;t<_;t++){const s=t<<1,n=e[s]-p[t]*v-b;Math.abs(n)>200&&(e[s]+=n>0?-C:C)}if(t){for(let t=0;t<_;t++)if(f[t]){const s=1+(t<<1);e[s]+=v*f[t],e[s]>E?e[s]=E:e[s]<-E&&(e[s]=-E)}f.fill(0)}r.writeRangeFromArray(2*P,2*_,e,!0,1),c&&o&&o.writeRangeFromArray(P,_,x,!0,1),P+=_,n-=_,_=Math.min(n,1e3)}return i.notifyModifiedFlags(2001),!0}function Oi(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return function(t,e,s){const n=[e.getStartXY(),e.getEndXY()];let i=null;e.hasAttribute(1)&&(i=[0,0],i[0]=e.getAttributeAsDbl(0,1,0),i[1]=e.getAttributeAsDbl(1,1,0));const r=Ki(t,n,i,2,s);return e.setStartXY(n[0]),e.setEndXY(n[1]),i&&(e.setStartAttribute(1,0,i[0]),e.setEndAttribute(1,0,i[1])),e.normalizeAfterEndpointChange(),r}(t,e,s);case n.G.enumBezier:return function(t,e,s){const n=(0,a.m)(a.P,4);e.queryControlPoints(n);let i=null;e.hasAttribute(1)&&(i=[0,0,0,0],i[0]=e.getAttributeAsDbl(0,1,0),i[3]=e.getAttributeAsDbl(1,1,0),i[1]=(0,a.q)(i[0],i[3],.5),i[2]=i[1]);const r=Ki(t,n,i||null,n.length,s);return e.setControlPoints(n),i&&(e.setStartAttribute(1,0,i[0]),e.setEndAttribute(1,0,i[3])),e.normalizeAfterEndpointChange(),r}(t,e,s);case n.G.enumEllipticArc:return function(t,e,s){if(0===e.projectionBehavior())return function(t,e,s){const n=[e.getStartXY(),e.getEndXY(),e.getInteriorPoint(),e.getCenter()];let i=4;e.isDegenerateToLine()&&(i=2);const r=[0,0,0,0];let o=null;if(e.hasAttribute(1)){o=r,o[0]=e.getAttributeAsDbl(0,1,0),o[1]=e.getAttributeAsDbl(1,1,0);const t=(0,a.q)(o[0],o[1],.5);o[2]=t,o[3]=t}const h=e.getStartXY().equals(e.getEndXY())&&!e.isDegenerateToLine(),m=Ki(t,n,o,i,s);return h?e.constructCircleCenterAndPoint(n[3],n[0],!e.isClockwise()):e.isDegenerateToLine()?e.constructLineCircularArc(n[0],n[1]):e.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(e.setStartAttribute(1,0,o[0]),e.setEndAttribute(1,0,o[1])),m}(t,e,s);const n=e.getStartXY().equals(e.getEndXY()),i=(0,a.m)(a.P,3),r=(0,a.m)(a.P,3);let o=null;i[0].assign(e.getStartXY()),i[1].assign(n?e.getCenter():e.getEndXY());let h=!1;e.hasAttribute(1)&&(o=[0,0,0],o[0]=e.getAttributeAsDbl(0,1,0),o[1]=e.getAttributeAsDbl(1,1,0),o[2]=(0,a.q)(o[0],o[1],.5),n&&(o[1]=o[2])),r[0].setCoordsPoint2D(i[0]),r[1].setCoordsPoint2D(i[1]);const l=new m.T;if(n||e.isDegenerateToLine())h=Ki(t,r,o,2,s),l.initializeFromTwoPoints(i[0],i[1],r[0],r[1]);else{const n=new a.P;e.queryCoord2D(.5,n),i[2].setCoordsPoint2D(n),r[2].setCoordsPoint2D(n),h=Ki(t,r,o,3,s),l.setFromTwoTriangles(i,r)}return l.isIdentity()||(e.applyTransformation(l),e.setStartXY(r[0]),e.setEndXY(n?r[0]:r[1]),e.normalizeAfterEndpointChange()),o&&(e.setStartAttribute(1,0,o[0]),e.setEndAttribute(1,0,n?o[0]:o[1])),h}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return(0,n.g)(0),!1;default:(0,n.d)("")}}function Wi(t,e,s){if(!e.hasNonLinearSegments())return Ui(t,e,s);if(e.isEmpty())return!1;const n=e.createInstance();n.reserveParts(e.getPointCount(),e.getPathCount());const i=e.getImpl(),h=new r.S;for(let r=0,m=e.getPathCount();r<m;++r){let e=!0,m=-1;const l=i.getPathStart(r),u=l+i.getSegmentCountPath(r);i.isClosedPath(r)&&(m=u-1);const c=new a.P;for(let r=l;r<u;++r){if(i.getSegmentBuffer(r,h,!1),Oi(t,h.get(),s),e||h.get().getStartXY().equals(c)||h.get().moveTo(c),r!==m)n.addSegment(h.get(),e);else{if(e){const t=new o.P;h.get().queryStart(t),n.startPathPoint(t)}n.closeLastPathWithSegment(h.get())}c.assign(h.get().getEndXY()),e=!1}}return e.assignMove(n),!0}function ji(t,e,s,n,i,r){if(t.isIdentityGeogToGeog()){const s=90*t.getInputSR().getOneDegreeGCSUnit();let i=0;const r=[0];for(let t=0;t<n;t++)r[0]=e[t].y,i|=(0,a.V)(r,-s,s)?1:0,e[t].y=r[0];return i}const o=t.getInputSR(),h=t.getOutputSR(),m=o.getVCS(),l=h.getVCS(),u=o.getOneDegreeGCSUnit(),c=90*u,g=h.getOneDegreeGCSUnit(),d=t.isVertical(),_=t.getDatumTransformation(),p=!!_&&1===_.getType();if(d||(s=null),!_||0===_.count()){let t=0;const i=[0];for(let s=0;s<n;s++)i[0]=e[s].y,t|=(0,a.V)(i,-c,c)?1:0,e[s].y=i[0];return t|=$n(o.getGCS(),m,h.getGCS(),l,e,s,n)?1:0,t}p||null===s||zi();let f=Math.min(n,1024);const x=(0,a.d)(f,Number.NaN),P=(0,a.d)(f,Number.NaN);let y=0,E=Number.NaN,C=Number.NaN;const v=360*g,S=g/u;i&&(C=90*g,E=89.9*u);let b=!0,I=0,D=n;for(;D;){let t=!1;for(let t=0;t<f;t++)x[t]=e[t+y].x;if(i)for(let s=0;s<f;s++){const n=Math.abs(e[s+y].y)-E;if(n>0){const i=e[s+y].y;e[s+y].y=(0,a.f)(E,i),P[s]=(0,a.f)(n,i),t=!0}}const n=e[0].x;p?_.transform(!1,e,s,f):_.transform(!1,e,f),b&&(I=e[0].x-S*n,b=!1);for(let t=0;t<f;t++){const s=e[y+t].x-x[t]*S-I;Math.abs(s)>200&&(s>0?e[y+t].x-=v:e[y+t].x+=v)}if(t){for(let t=0;t<f;t++)P[t]&&(e[y+t].y+=S*P[t],e[y+t].y>C?e[y+t].y=C:e[y+t].y<-C&&(e[y+t].y=-C));P.fill(0,0,f)}y+=f,D-=f,f=Math.min(D,1024)}return 1}function Zi(t,e,s,i,r){return(0,n.g)(0),0}function Qi(t,e,s,i,r){(0,n.g)(null===i),(0,n.g)(e<2147483647);const o=Array.isArray(s);let h;h=o?(0,a._)(s):s;const m=wo.geogToGeog(t,e,h,null,r);return o&&(0,a.$)(h,s),m}function Ki(t,e,s,n,i,r){let o=0,a=!0,h=0;for(let r=0;r<n;++r)e[r].isNAN()?a||(o|=ji(t,e.slice(h,r-h),s?s.slice(h,r-h):null,r-h,i),h=r,a=!0):a&&(h=r,a=!1);return a||(o|=ji(t,0===h?e:e.slice(h),s?0===h?s:s.slice(h):null,n-h,i)),0!==o}function $i(t,e,s,n){Mi(t,e,s,n)}function Ji(t,e,s,n){Hi(t,e,s,n);const r=new i.Envelope2D;r.setFromPoints(s,n);const o=t.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(r.width()>h){for(let t=0;t<n;t++)for(;s[t].x<e;)s[t].x+=a;if(r.setFromPoints(s,n),r.xmax>h+e)for(let t=0;t<n;t++)s[t].x-=a}}function tr(t,e,s,n,i){const r=(0,a.m)(a.P,3);let o=0,h=!1,m=!1;const l=n.isDegenerateToLine();l?(r[0].assign(n.getStartXY()),r[1].assign(n.getEndXY()),r[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(h=!0,m=!n.isClockwise(),r[0].assign(n.getStartXY()),r[1].assign(n.getCenter()),r[2].setCoords(0,0),o=2):(r[0].assign(n.getStartXY()),r[1].assign(n.getEndXY()),r[2].assign(n.getInteriorPoint()),o=3),t?$i(e,r,o,i):Ji(e,s,r,o),l?n.constructLineCircularArc(r[0],r[1]):h?n.constructCircleCenterAndPoint(r[1],r[0],m):n.constructCircularArcThreePoint(r[0],r[1],r[2])}function er(t,e,s){const n=(0,r.a3)(t),i=(0,r.a3)(e),o=(0,r.a2)(n,i),a=(0,r.a2)(n,(0,r.a3)(s));return 0===a||o>0&&a>0&&a<=o||o<0&&a<0&&a>=o}function sr(t,e,s,i,r){const o={stack:[],error:void 0,hasError:!1};try{const m=s.clone(),l=i.clone();if(2===r){const t=[0,0];return A(0,e,m,l,0,t),t[0]}if(m.y>l.y){const t=new a.P;t.assign(m),m.assign(l),l.assign(t)}const u=(0,h.mS)(o,new So,!1),c=(0,h.mS)(o,new So,!1),g=(0,h.mS)(o,new So,!1),d=new a.E;if(d.setCoords(m.y,l.y),!d.containsCoordinate(0)||Math.abs(m.x-l.x)>=Math.PI)return Number.NaN;if(m.x===l.x)return m.x;Go.geodeticDistance(t,e,m.x,m.y,l.x,l.y,c,u,null,r);const _=c.val;let p=0,f=1;const x=m.clone();for(;_*(f-p)>1e-12*t;){const s=.5*(p+f);if(Go.geodeticCoordinate(t,e,m.x,m.y,_*s,u.val,c,g,r),x.x=c.val,x.y=g.val,d.setCoords(m.y,x.y),0===x.y)return x.x;if(d.containsCoordinate(0))f=s;else{if(d.setCoords(l.y,x.y),!d.containsCoordinate(0))return(0,n.g)(!1),Number.NaN;p=s}}return x.x}catch(t){o.error=t,o.hasError=!0}finally{(0,h.hk)(o)}}function nr(t,e,s,n){const i=new a.E;i.setCoords(e,s);const r=n.width();let o=Math.floor((t-e)/r)*r+t;const h=i.getCenter();for(;Math.abs(o-h)>Math.abs(o+r-h);)o+=r;return o}class ir extends c.G{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const t=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),t}return null}getGeometryID(){return this.m_index}tick(t){this.m_geometryDeque.push(t)}tock(){return!0}getRank(){return 1}}class rr{constructor(t,e=!0){this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_bGCSHorisonIsInclusive=!1,this.m_oneMeterPCS=0,this.m_oneDegreeGCS=0,this.m_gcsUnitFactor=0,this.m_northPole=a.P.getNAN(),this.m_southPole=a.P.getNAN(),this.m_polesUpdated=0,this.m_domain=i.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=i.Envelope2D.constructEmpty(),this.m_pannableExtentGCS=i.Envelope2D.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=t,this.m_WKID=bo.getCode(t),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=gi(t,0,!0),this.m_hashCode=(0,a.I)(this.m_canonicalWkt)):this.m_hashCode=(0,a.J)(this.m_WKID);const s=this.m_peCoordSys.getType();this.m_csType=s===Io.PE_TYPE_PROJCS?2:1,(0,n.g)(s===Io.PE_TYPE_PROJCS||s===Io.PE_TYPE_GEOGCS),s===Io.PE_TYPE_PROJCS&&(t.loadConstants()||(0,n.a)("PeProjcs.loadConstants failed"));const r=s===Io.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();s!==Io.PE_TYPE_GEOGCS&&bo.getCode(r),this.m_unit=function(t){const e=Fo(null);return t.getType()===Io.PE_TYPE_PROJCS||t.getType()===Io.PE_TYPE_GEOGCS?e.reset(t.getUnit()):(0,n.a)("PE_coord_sys"),e.get()||(0,n.d)("cannot create units from coord sys"),function(t){return t.getType()===Io.PE_TYPE_LINUNIT?new Ar(t):t.getType()===Io.PE_TYPE_ANGUNIT?new f(t):void(0,n.a)("peUnit")}(e.get())}(t),this.m_primeMeridian=r.getPrimem().getLongitude();{const t=r.getUnit().getUnitFactor();this.m_gcsUnitFactor=t;let e=Math.PI/(180*t);Math.abs(e-1)<1e-10&&(e=1),this.m_oneDegreeGCS=e}if(s===Io.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=t.getUnit().getUnitFactor();this.m_oneMeterPCS=1/e,this.m_oneMillimeter=.001/e,this.m_pPCSInfoNoDomain=To.generate(t,To.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||(0,n.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 t=1/r.getUnit().getUnitFactor(),e=r.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/e*t,this.m_centralMeridian=0}this.m_bIsPannable&&(this.updateGCSHorizon(),this.updatePCSHorizon(),this.updatePoles(),this.updateDomain(),this.updatePannableExtent(),this.updatePannableExtentGCS())}[Symbol.dispose](){}getHashCode(){return this.m_hashCode}getPCSHorizonPannable(){return this.m_PCSHorizon}getGCSHorizonPannable(){return this.m_GCSHorizon}getPCSInfo(){return(0,n.g)(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==Io.PE_TYPE_PROJCS)return;let t=!0;const e=this.m_peCoordSys,s=e.getGeogcs(),h=e.horizonGcsGenerate();if(!h)return;(0,n.g)(h.length>0);const u=h[0].getNump(),c=h[0].getKind();let g,d;t=h[0].getInclusive()>0;const _=this.getOneDegreeGCSUnit(),p=90*_,f=360*_,x=370*_,P=180*_*Io.PE_HORIZON_DELTA/Math.PI,y=i.Envelope2D.constructEmpty();let E=null;if(u>1)for(let t=1;t<u;t++)if(h[t].getKind()===Io.PE_HORIZON_LINE){E||(E=new r.P);const e=h[t].getCoord();E.startPathCoords(e[0][0],e[0][1]),E.lineToCoords(e[1][0],e[1][1])}if(c===Io.PE_HORIZON_RECT){const e=h[0].getCoord();if(y.setFromPoints([new a.P(e[0][0],e[0][1]),new a.P(e[1][0],e[1][1])],2),Math.abs(y.ymax-p)<1e-7*P&&(y.ymax=p),Math.abs(y.ymin+p)<1e-7*P&&(y.ymin=-p),y.width()>x){const t=-400*_,e=t+5*f;y.setCoords({xmin:t,ymin:y.ymin,xmax:e,ymax:y.ymax})}const s=new o.E({env2D:y});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=t)}else{let e=this.getPCSInfo().isGcsHorizonMultiOverlap();const o=Wr(s,null,0,1),c=[],x=new a.E;for(let t=0;t<u;t++){if(h[t].getKind()!==Io.PE_HORIZON_POLY)continue;g=h[t].getSize();const e=h[t].getCoord(),s=i.Envelope2D.constructEmpty();s.setFromPoints((0,a.L)(e),g),c.push(new a.E(s.xmin,s.xmax)),s.width(),x.merge(c.at(-1))}let P=!1;const y=new a.E;x.width()>f&&c.length>1?(y.vmin=this.getCentralMeridian()-f,y.vmax=y.vmin+2*f,P=!0,e=!0):(y.vmin=x.vmin,y.vmax=y.vmin+f);const C=t=>{let e=0;for(;c[t].vmin+e<y.vmin;)e+=f;for(;c[t].vmax+e-f>y.vmin;)e-=f;return e};let v=new r.a;if(e){const t=new ir,e=(new hi).executeMany(t,o,null);for(let s=0;s<u;s++){if(h[s].getKind()!==Io.PE_HORIZON_POLY)continue;g=h[s].getSize();const n=h[s].getCoord();d=h[s].getInclusive()>0;const i=new r.a;if(i.addPathPoint2D((0,a.L)(n),g-1,!0),P){const e=C(s),n=c[s].clone();n.move(e);let r=e;const o=new m.T;do{o.setShiftCoords(r,0);const e=i.clone();e.applyTransformation(o),t.tick(e),t.tock(),r+=f,n.move(f)}while(n.vmin<y.vmax)}else t.tick(i),e.tock()}v=e.next()}else{v=new r.a;for(let e=0;e<u;e++){if(h[e].getKind()!==Io.PE_HORIZON_POLY)continue;g=h[e].getSize();const s=h[e].getCoord();if(d=h[e].getInclusive()>0,(0,n.g)(d===t),P){const t=new r.a;t.addPathPoint2D((0,a.L)(s),g-1,!0);const n=C(e),i=c[e].clone();i.move(n);let o=n;const h=new m.T;do{if(0!==o){h.setShiftCoords(o,0);const e=new r.a({copy:t});e.applyTransformation(h),v.addPath(e,0,!0)}else v.addPath(t,0,!0);o+=f,i.move(f)}while(i.vmin<y.vmax)}else v.addPathPoint2D((0,a.L)(s),g-1,!0)}}P&&(v=(new l.O).execute(v,new i.Envelope2D(y.vmin,-p-_,y.vmax,p+_),o,null)),t?(new en).accelerateGeometry(v,o,1):(new oi).accelerateGeometry(v,o,1),(new ui).accelerateGeometry(v,o,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=v,this.m_bGCSHorisonIsInclusive=t,this.m_GCSSplitLines=E)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==Io.PE_TYPE_PROJCS)return;const t=this.m_peCoordSys.horizonPcsGenerate();if(!t)return;let e;this.getPCSInfo();const s=t[0].getKind();t[0].getInclusive();const h=i.Envelope2D.constructEmpty(),m=t[0].getNump();let l=!1;if(s===Io.PE_HORIZON_RECT){const s=t[0].getCoord();h.setFromPoints((0,a.L)(s),2),e=new o.E({env2D:h})}else{let s=-1;for(let e=0;e<m;e++)t[e].getKind()===Io.PE_HORIZON_POLY&&(s=e);(0,n.g)(s>=0);const i=t[s].getSize()-1,o=t[s].getCoord(),h=new r.a;e=h,h.addPathPoint2D((0,a.L)(o),i,!0),l=!0}if(this.getPCSInfo().isDensificationNeeded()){(0,n.g)(s!==Io.PE_HORIZON_RECT);const t=1e5*this.getOneMeterPCSUnit();e=(new u.O).execute(e,t,0,0,null)}if(l){{const t=new o.E;e.queryEnvelope(t),e.calculateArea2D(),e.calculateLength2D(),e.getExteriorRingCount()}(new en).accelerateGeometry(e,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=e)}updatePannableExtent(){const t=this.m_peCoordSys.getType();if(t===Io.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.getPCSInfo().getCentralMeridian(),s=t.getGeogcs();s||(0,n.d)("");const r=[e+1/s.getUnit().getUnitFactor()*Math.PI,0];Do.geogToProj(t,1,r);const o=r[0],a=t.getParameters()[Io.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=i.Envelope2D.constructEmpty();h.queryEnvelope(m);const l=Math.abs(o-a),u=l+a,c=-1*l+a,g=m.ymax,d=m.ymin;this.m_pannableExtent.setCoords({xmin:c,ymin:d,xmax:u,ymax:g})}else if(t===Io.PE_TYPE_GEOGCS){const t=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-t,ymin:-t/2,xmax:t,ymax:t/2})}else(0,n.d)("")}updatePannableExtentGCS(){const t=this.m_peCoordSys.getType();if(t===Io.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.m_centralMeridian,s=t.getGeogcs();s||(0,n.d)("");const r=1/s.getUnit().getUnitFactor()*Math.PI,o=this.getGCSHorizon(),a=i.Envelope2D.constructEmpty();o.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:e-r,ymin:a.ymin,xmax:e+r,ymax:a.ymax})}else if(t===Io.PE_TYPE_GEOGCS){const t=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-t,ymin:-t/2,xmax:t,ymax:t/2})}else(0,n.d)("")}updateDomain(){if(1===this.m_csType){const t=400*this.getOneDegreeGCSUnit();this.m_domain=i.Envelope2D.construct(-t,-t,t,t)}else{(0,n.g)(2===this.m_csType);const t=To.generate(this.m_peCoordSys,To.PE_PCSINFO_OPTION_DOMAIN);t||(0,n.d)("generate pcs info failed");const e=new i.Envelope2D(t.getDomainMinx(),t.getDomainMiny(),t.getDomainMaxx(),t.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:e})}}updatePoles(){if(this.m_peCoordSys.getType()===Io.PE_TYPE_PROJCS){const t=90*this.getOneDegreeGCSUnit(),e=[[0,t],[0,-t]];Do.geogToProj(this.m_peCoordSys,2,e);const s=this.getPCSInfo().getNorthPoleLocation()!==To.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==To.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(e[0][0],e[0][1]),n&&this.m_southPole.setCoords(e[1][0],e[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===Io.PE_TYPE_PROJCS){const t=this.getOneDegreeGCSUnit(),e=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=e,s[1]=0,s[2]=e+t,s[3]=0;const i=Do.geogToProj(this.m_peCoordSys,2,s);(0,n.g)(2===i);const r=(s[2]-s[0])/t,o=s[0];0===this.m_geogToProjFactorsUpdated&&(this.m_geogToProjFactor=r,this.m_geogToProjOffset=o,this.m_geogToProjFactorsUpdated=1)}else this.m_geogToProjFactorsUpdated=1}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return this.m_gcsUnitFactor}getUnitsPerMillimeter(){return this.m_oneMillimeter}getGCSSplitLines(){return this.m_bIsPannable?null:(this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSSplitLines)}getGCSHorizon(){return this.m_bIsPannable?this.getGCSHorizonPannable():(null!==this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(null!==this.m_PCSHorizon||this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(t){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),t?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),(0,a.l)(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let t=!1;return t=this.m_domain.isEmpty(),t&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;if(t<0){if(t=0,this.m_WKID>0){const e=[0],s=[0];(function(t,e,s,n){return e<=0?(s[0]=0,n[0]=0,!1):(s[0]=e,n[0]=e,!0)})(this.m_peCoordSys.getType(),this.m_WKID,e,s)||(0,n.d)("query_code_change"),t=e[0]}this.m_oldWKID=t}return t}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return null!==this.m_areaOfUse?this.m_areaOfUse:this.updateAreaOfUse()}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}class or{constructor(t,e=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new Ar,this.m_cached=!1}setCached(t=!0){this.m_cached=t}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;return t<0&&(t=0,this.m_WKID>0&&(t=this.m_WKID),this.m_oldWKID=t),t}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}function ar(t,e,s){return hr(t,e,i.Envelope2D.constructEmpty())}function hr(t,e,s,r){return function(t,e,s,r){return Br()||(0,n.r)("cannot create projection transformation"),e.hasVCS()&&s.hasVCS()?((0,n.g)(0),{}):function(t,e,s){t&&e||(0,n.a)("!inputSR || !outputSR");const r=t.getLatestID(),o=e.getLatestID();if(3857===r&&4326===o){if(t.m_bDefaultDescriptor&&e.m_bDefaultDescriptor)return Dr()}else if(4326===r&&3857===o&&t.m_bDefaultDescriptor&&e.m_bDefaultDescriptor)return br||(br=Dr().getInverse()),br;const a=i.Envelope2D.constructEmpty();a.setCoords({env2D:s});const h=t.getCoordinateSystemType(),m=e.getCoordinateSystemType();if(0===h||0===m)return gr(t,e);const l=t.getGCS().getLatestID(),u=e.getGCS().getLatestID();if(l>0&&l===u)return gr(t,e);const c=new Cr(t,e,s);{const t=function(t){if(vr.has(t.getHashCode()))return vr.get(t.getHashCode())}(c);if(t)return t}const g=ur(0,t,e,a,1,!0);return function(t,e){return vr.set(t.getHashCode(),e),e}(c,gr(t,e,g.length?g[0]:void 0))}(e,s,r)}(0,t,e,s)}function mr(t,e,s,n){return lr(!0,t,e,s,n)}function lr(t,e,s,i,r,o){return Br()||(0,n.r)("cannot create projection transformation"),new fr(t?2:1,e,s,i,r,o)}function ur(t,e,s,i,r,h=!1){if(e&&s||(0,n.a)(""),Br()||(0,n.r)("cannot obtain geotransformation list"),1===t&&e.hasVCS()&&s.hasVCS())return(0,n.t)("hv xform not impl"),[];{const t=function(t,e,s,i,r){const h=t.getGCS(),m=e.getGCS(),l=h.getPECoordSys(),u=m.getPECoordSys();let c=null;if(!s.isEmpty()){const e=s.clone();if(!e.isEmpty()&&2===t.getCoordinateSystemType()){let s=new o.E({env2D:e});const n=mr(t,h,null);s=(new un).execute(s,n,null),s.queryEnvelope(e)}if(!e.isEmpty()){const t=l.getPrimem().getLongitude(),s=l.getUnit().getUnitFactor();c=new Mo(e.xmin,e.ymin,e.xmax,e.ymax,t,s)}}let g=i;g>=(0,a.i)()&&(g=0);const d=[];let _=No.PE_GTLIST_OPTS_COMMON;r||(_&=~No.PE_GTLIST_OPTS_USABLE);for(let t=0;t<2;t++){d.length=0;const t=g,e=No.getGTlist(l,u,2,_,c,t);let s=!1;if(e&&e.length>0)for(let t=0,o=e.length;t<o;t++){const o=Wo([e[t]]);if((0,n.g)(o),r&&o.referencesMissingData())s=!0;else if(d.push(o),i>0&&d.length===i)break}if(!s)break;0===g||(g=0)}return c&&c.destroy(),d}(e,s,i,r,h),m=[];for(const e of t)m.push(e);return m}}function cr(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(t){return(0,a.F)(this.centralMeridianOfOutputGCS,t.centralMeridianOfOutputGCS)&&(0,a.F)(this.densificationStep,t.densificationStep)&&this.clipWithInputHorizon===t.clipWithInputHorizon&&this.clipWithOutputHorizon===t.clipWithOutputHorizon&&this.legacyHorizonClipping===t.legacyHorizonClipping&&this.normalizeResultGeometry===t.normalizeResultGeometry}}}function gr(t,e,s,n,i){return new fr(1,t,e,s,n,i)}function dr(){return{flagsMask:0,setFlag(t,e){e?this.flagsMask|=t:this.flagsMask&=~t},hasFlag(t){return 0!==(this.flagsMask&t)}}}function _r(){return{m_extendedParams:cr(),m_extendedParamsInternal:dr()}}function pr(){return _r()}class fr{constructor(t,e,s,i,r,o){let a,h;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,e&&s||(0,n.a)("!inputSR || !outputSR"),i&&0===i.getType()&&(i.m_bReadOnly=!0),this.m_bNormalize=!1,1!==t&&(a=e.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=e,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,(0,n.g)(!this.m_params),r&&(this.m_params=_r(),this.m_params.m_extendedParams=r),o&&(this.m_params||(this.m_params=_r()),this.m_params.m_extendedParamsInternal=o);let m=!1;const l=null!=i,u=e.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==u&&r){const t=r.centralMeridianOfOutputGCS;if(!Number.isNaN(t)&&s.isPannable()){const e=s.getPannableExtent(),n=e.getCenterX();if(n!==t){const s=Math.ceil(e.width());t+s!==n+s&&(m=!0)}}}const g=r&&r.normalizeResultGeometry;if(e.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!l&&e.equalForProjection(s,this.m_bVertical);this.m_bIdentity=d&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(g&&this.m_outputSR.isPannable()&&(this.m_bNormalize=g),this.m_datumTran=i||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const t=new fr(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return t.m_bIdentity=this.m_bIdentity,t.m_bVertical=this.m_bVertical,t.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,t.updateProjector(),t}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:pr().m_extendedParams}equals(t){return(0,n.g)(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(t,e){return(0,n.g)(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:pr().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:pr().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new hn(this)}}const xr=new Map,Pr=new Map,yr=new Map;function Er(t){let e=t.getCode();if(e>0)return Nr(e)||Tr(bo.coordsys(e));const s=t.getName();if(Pr.has(s)){const e=Pr.get(s);if(e&&e.deref()){const s=e.deref();if(s.m_peCoordSys.isEqual(t))return s}}return e=bo.getCode(t),Tr(e>0?bo.coordsys(e):t)}class Cr{constructor(t,e,s){this.m_hashCode=-1,t&&(this.m_inputSR=t,this.m_outputSR=e,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=(0,a.A)(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=(0,a.A)(this.m_hashCode,(0,a.a0)(this.m_env.xmin)),this.m_hashCode=(0,a.A)(this.m_hashCode,(0,a.a0)(this.m_env.xmax)),this.m_hashCode=(0,a.A)(this.m_hashCode,(0,a.a0)(this.m_env.ymin)),this.m_hashCode=(0,a.A)(this.m_hashCode,(0,a.a0)(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(t){return!(this.m_inputSR&&!t.m_inputSR||!this.m_inputSR&&t.m_inputSR)&&this.m_env.equals(t.m_env)&&this.m_inputSR.equals(t.m_inputSR)&&this.m_outputSR.equals(t.m_outputSR)}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const vr=new Map;let Sr,br,Ir;function Dr(){return Sr||(Sr=mr(uo(),go())),Sr}const wr=new Map;function Tr(t){const e=Fo(t),s=t.getCode();if(s>0){const t=Nr(s);if(t)return t}const n=t.getName();let i=Pr.get(n);if(i){const e=i.deref();if(e&&e.m_peCoordSys.isEqual(t))return e}const r=new rr(e.release());if(s>0)return r.setCached(),xr.set(s,new WeakRef(r)),Pr.set(n,new WeakRef(r)),r;const o=gi(t,0,!1);if(i=yr.get(o),i){const t=i.deref();if(t)return t}return r.setCached(),yr.set(o,new WeakRef(r)),r}function Nr(t){const e=xr.get(t);if(e)return e.deref()}class Ar extends _{constructor(t){return void 0===t?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof t?(super(),this.m_factor=t,void(this.m_wkid=0)):(super(t),void(t||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=(Ir||(Ir=bo.unit(9001)),Ir))))}getUnitType(){return 0}convertFromMeters(t){return t/this.getUnitToBaseFactor()}convertToMeters(t){return t*this.getUnitToBaseFactor()}}const Gr=["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 qr(t,e,s,i,r){(0,n.g)(i>>5<r.length);let o=e,a=s;for(let e=i;e>=0;e-=2){const s=31&e,n=.5*(a+o);t>=n?(r[e>>5]|=1<<s,o=n):a=n}}let Mr=new Set;const Fr=2147483645n,Xr=9007199254740990n,Vr="operation is not supported for unknown coordinate systems";var Yr;function Rr(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function kr(t){if(bo)return;!function(t){const e=t;bo=e.PeFactory,(0,n.g)(bo),Mo=e.PeGCSExtent,(0,n.g)(Mo),Go=e.PeLineType,(0,n.g)(Go),qo=e.PeMath,(0,n.g)(qo),So=e.PeDouble,(0,n.g)(So),Io=e.PeDefs,(0,n.g)(Io),Do=e.PeCSTransformations,(0,n.g)(Do),wo=e.PeGTTransformations,(0,n.g)(wo),To=e.PePCSInfo,(0,n.g)(To),No=e.PeGTlistExtended,(0,n.g)(No),bo.initialize(),Ao=e.PeGTlistExtendedEntry,(0,n.g)(Ao),Io.PE_TYPE_ANGUNIT=512,Io.PE_STR_AUTH_ALL=2,To.PE_POLE_LINE_STRAIGHT=2,To.PE_POLE_LINE_CURVED=3,Io.PE_PARM_LAM0=2,Io.PE_PARM_PHI0=6,Io.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,Io.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,Io.PE_PRJ_ALBERS=43007,Io.PE_PRJ_CYLINDRICAL_EQAREA=43034,Io.PE_TYPE_VERTCS=8,Io.PE_LINETYPE_GEODESIC=0,Io.PE_LINETYPE_LOXODROME=1,Io.PE_LINETYPE_GREAT_ELLIPTIC=2,Io.PE_LINETYPE_NORMAL_SECTION=3,No.PE_GTLIST_OPTS_USABLE=1,Xo=null}(t);const e=Mr;Mr=null,e.forEach(t=>{const e=t.deref();e&&e.attachToPe()})}function Lr(t){!function(t){Xo=t,(0,n.g)(Xo)}(t)}function Br(){return!!bo}function Hr(){return!!Xo}function zr(){return!!bo||!!Xo}function Ur(t,e,s){return(0,n.g)(zr()),Po(t,void 0===e?0:e,0,!1)}function Or(t,e){(0,n.g)(zr());const s=new mo;let i;return Br()?(i=function(t){const e=Fo(bo.fromString(Io.PE_TYPE_COORDSYS,t));return e.get()||(0,n.A)(t),Er(e.release())}(t),s.setHorzProj_(i),s.m_vertcs=null,s.m_userWKID=i.getLatestID()):(i=Vo(t),s.m_unit=i.isPCS?new Ar(i.metersOrRadiansPerUnit):new f(i.metersOrRadiansPerUnit)),po(s.m_precisionDescriptor,i,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=t,s.calculateHashCode(),s.initDbgName(),s}function Wr(t,e,s,i,r=!0){let o=null;return e&&((0,n.g)(0),o={}),function(t,e,s,i,r){t||(0,n.a)("!PE_coord_sys");const o=new mo;let a;return a=r?Er(t):new rr(t,!1),po(o.m_precisionDescriptor,a,e,i),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=e,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}(t,o,0,i,r)}function jr(t,e,s=!1){3===t.getCoordinateSystemType()&&(0,n.a)("image spatial reference cannot be altered");const i=new mo,r=t;return i.m_peCoordSysVal=r.m_peCoordSysVal,i.m_vertcs=r.m_vertcs,i.m_unit=r.m_unit,i.m_precisionDescriptor.assign(e),i.m_localZToXYFactor=r.m_localZToXYFactor,(Number.isNaN(i.m_precisionDescriptor.m_falseX)||Number.isNaN(i.m_precisionDescriptor.m_falseY))&&(i.m_precisionDescriptor.m_falseX=r.m_precisionDescriptor.m_falseX,i.m_precisionDescriptor.m_falseY=r.m_precisionDescriptor.m_falseY),i.m_precisionDescriptor.snapPrecision(),i.m_precisionDescriptor.fixTolerance(),i.m_userWKID=r.m_userWKID,i.m_precisionDescriptor.equals(r.m_precisionDescriptor)?i.m_bDefaultDescriptor=r.m_bDefaultDescriptor:i.m_bDefaultDescriptor=!1,s&&(i.m_bDefaultDescriptor=!0),i.calculateHashCode(),i.initDbgName(),i}function Zr(t,e,s){return{}}function Qr(t,e,s){void 0===e&&(e=1),(e<=0||!Number.isFinite(e))&&(0,n.a)(""),t||1===e||(0,n.a)("null Unit has to have z_to_xy_factor equal to 1");const i=new mo;i.m_unit=t;const r=t||new Ar(9001);return xo(i.m_precisionDescriptor,r,null,1),i.m_bDefaultDescriptor=!0,Number.isNaN(i.m_precisionDescriptor.m_falseX)&&(0,n.a)("NAN false X/Y are not allowed here"),i.m_localZToXYFactor=e,i.calculateHashCode(),i.initDbgName(),i}function Kr(t,e){return t.snapGeometry(e)}function $r(t){const e=t.getCoordinateSystemType();return 1===e?t:(3===e&&(0,n.g)(0),t.getGCS())}function Jr(t){return(0,n.g)(zr()),Hr()?function(t){return(0,n.g)(Hr()),!!Xo(t).isPCS||function(t){return bo&&(0,n.p)("pe has been loaded. no-pe methods should not be used at this point."),Eo||Ro(),Eo.has(t)}(t)}(t):function(t){if(wr.has(t))return wr.get(t);{const e=function(t){return null!==Fo(bo.coordsys(t)).get()}(t);return wr.set(t,e),e}}(t)}function to(t){if(Br())return null!==Fo(bo.fromString(Io.PE_TYPE_COORDSYS,t)).get();try{return Vo(t),!0}catch(t){}return!1}let eo;function so(){return eo||(eo=(()=>{const t=Math.trunc(Math.random()*(0,a.i)()),e=Date.now();return`|abba_000|${t.toString(16)}|${e.toString(16)}|`})()),eo}!function(t){t[t.utmDefault=0]="utmDefault",t[t.utmNorthSouth=1]="utmNorthSouth"}(Yr||(Yr={}));let no,io,ro,oo=0;function ao(t=""){let e=`${so()}${oo++}`;return""!==t&&(e+=`|${t}`),e}function ho(t){return t.startsWith(so())}class mo{destroy(){(function(t){Pr.delete(t.m_peCoordSys.getName()),yr.delete(gi(t.m_peCoordSys,0,!1))})(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():(0,n.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 lo,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,_o(this.m_precisionDescriptor),Mr&&Mr.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ur(this.m_userWKID):Or(this.m_userWKT)).copyTo(this,!1)}copyTo(t,e=!0){(e||t.m_bDefaultDescriptor)&&(t.m_bDefaultDescriptor=this.m_bDefaultDescriptor,t.m_precisionDescriptor.assign(this.m_precisionDescriptor)),t.m_defaultPrecisionSR=null,t.m_gcsToSr=this.m_gcsToSr,t.m_geogSpatialReference=this.m_geogSpatialReference,t.m_hashCode=this.m_hashCode,t.m_localZToXYFactor=this.m_localZToXYFactor,t.m_peCoordSysVal=this.m_peCoordSysVal,t.m_srToGcs=this.m_srToGcs,t.m_userWKID=this.m_userWKID,t.m_userWKT=this.m_userWKT,t.m_vertcs=this.m_vertcs,t.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let t=0;return t=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,t}updateTransform(t){if(1===this.getCoordinateSystemType())return mr(this,this,null);let e=t?this.m_srToGcs:this.m_gcsToSr;if(e)return e;const s=this.getGCS();e=t?mr(this,s,null):mr(s,this,null);const n=e;return(t?this.m_srToGcs:this.m_gcsToSr)||(t?this.m_srToGcs=n:this.m_gcsToSr=n,e)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let t=this.getHashCodeHorizontal();const e=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();t=(0,a.A)(t,e),this.m_hashCode=(0,a.A)(t,s)}initDbgName(){}setHorzProj_(t){this.m_peCoordSysVal=t,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(t=0){return this.m_precisionDescriptor.getTolerance(t)}getResolution(t=0){return this.m_precisionDescriptor.getResolution(t)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType()?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const t=this.getPECoordSys();if(t)switch(t.getType()){case Io.PE_TYPE_GEOGCS:return 1;case Io.PE_TYPE_PROJCS:return 2;default:return 0}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Ar)return 2;if(this.m_unit instanceof f)return 1}return 0}getID(){return this.m_userWKID}getLatestID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getLatestID():this.m_userWKID}getOldID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getOldID():this.m_userWKID}getVerticalID(){return(0,n.t)("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return(0,n.t)("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(t){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(t)}getText(){const t=this.getPECoordSys();return t?di(t):this.m_userWKT??""}getTextExtended(t){const e=this.getPECoordSys();return e?this.getPEVerticalCoordSys()?(this.getPEVerticalCoordSys(),(0,n.g)(0),""):di(e,t):this.m_userWKT??""}getText2(t=-1){const e=this.getPECoordSys();return e?function(t,e){(e>1||e<-1)&&(0,n.a)("verbosity");let s=Io.PE_STR_FMT_WKT2;return-1!==e&&(s|=0===e?Io.PE_STR_AUTH_TOP:Io.PE_STR_AUTH_ALL),t.toString(s)}(e,t):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof Ar?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof f?.001/(Vo(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):((0,n.p)("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?((0,n.g)(0),""):""}getVerticalUnit(){return(0,n.t)("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const t=this.getCoordinateSystemType();if(0===t)(0,n.p)(Vr);else{if(1===t)return this;3===t&&(0,n.p)("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let e;if(this===uo()||this===co())e=go();else{(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();t||(0,n.d)(""),e=Wr(t,this.m_vertcs,0,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?e=this.m_geogSpatialReference:this.m_geogSpatialReference=e,e}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(t,e){if(0===t.length)return 0;t.length>e.length&&(0,n.a)("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&(0,n.p)(Vr),1===s)return(0,a.D)(e,t,t.length),t.length;(0,n.g)(this.m_peCoordSysVal);const i=this.getSRToGCSTransform();return(new un).transform(i,t,t.length,e)}toGeohash(t,e=8){const s=t.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=(0,a.n)(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=(0,a.n)(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*e,i=new Uint32Array(4);return qr(s.x,-180,180,n-1,i),qr(s.y,-90,90,n-2,i),function(t,e,s){const n=(0,a.d)(e,"R");let i=0,r=0;for(let s=0;s<e;s++){let o=t[i]>>r&31;if(r+=5,r>31){const e=37-r;o&=(1<<e)-1,r-=32,i++,o|=(t[i]&(1<<r)-1)<<e}const a=Gr[o];n[e-1-s]=a}return s>e?n.push(..."0".repeat(s-e)):s<e&&(n.length=s),n.join("")}(i,e,e)}isPannable(){const t=this.getCoordinateSystemType();return 0!==t&&3!==t&&((0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||(0,n.a)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||(0,n.a)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const t=this.getCoordinateSystemType();1!==t&&2!==t&&(0,n.a)("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(t){if(t.assign(this.m_precisionDescriptor),Number.isNaN(t.m_falseX))if(Br()||(0,n.r)("cannot query precision descriptor"),(0,n.g)(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const e=this.m_peCoordSysVal.getDomainXY();t.m_falseX=e.xmin,t.m_falseY=e.ymin}else t.m_falseX=-Number.MAX_VALUE,t.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(t){t.assign(this.m_precisionDescriptor),t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(t){if(this.m_bDefaultDescriptor)t.assign(this.m_precisionDescriptor);else{const e=this.getCoordinateSystemType();0===e?xo(t,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===e?(0,n.t)("image cs"):po(t,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}horizontalEqual(t){return function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?t.m_hashCode===e.m_hashCode&&t.m_canonicalWkt===e.m_canonicalWkt:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)}verticalEqual(t){return null!==this.m_vertcs==(null!==t.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(t.m_vertcs))}equals(t){const e=t;if(this===e)return!0;if(!this.horizontalEqual(e)||!this.verticalEqual(e))return!1;if(!e.m_peCoordSysVal){if((0,n.g)(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==e.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(e.m_unit))return!1;if(this.m_localZToXYFactor!==e.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!e.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(e.m_precisionDescriptor))return!1;(0,n.g)(e.m_peCoordSysVal);let t=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(t)){const e=this.m_peCoordSysVal.getDomainXY();t=e.xmin,s=e.ymin}let i=e.m_precisionDescriptor.m_falseX,r=e.m_precisionDescriptor.m_falseY;if(Number.isNaN(i)){const t=e.m_peCoordSysVal.getDomainXY();i=t.xmin,r=t.ymin}return t===i&&s===r}return this.m_precisionDescriptor.equals(e.m_precisionDescriptor)}return!0}equalForProjection(t,e){if(this===t)return!0;const s=this.getCoordinateSystemType(),n=t.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!e||this.getZToXYFactor()===t.getZToXYFactor())&&(!this.getUnit()||!t.getUnit()||this.getUnit().equals(t.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===t.getUnit()||(!e||this.getZToXYFactor()===t.getZToXYFactor())&&this.getUnit().equals(t.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(t);if(function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?1===t.m_csType?t.m_peCoordSys.isEqual(e.m_peCoordSys):t.m_peCoordSys===e.m_peCoordSys:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)){if(!e)return!0;if(null!==this.m_vertcs==(null!==t.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(t.m_vertcs)}return!1}equalHorizontal(t){return this.horizontalEqual(t)}equalVertical(t){return(0,n.g)(0),!1}equalVerticalVCS(t){return(0,n.g)(0),!1}convergenceAngle(t){return(0,n.g)(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const t=this.m_peCoordSysVal.m_peCoordSys;return t||(0,n.d)("cannot clone coord sys"),t}return null}getPeVertcsCopy(){return(0,n.g)(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&(0,n.a)(Vr)}getPrimeMeridian(){return this.throwIfLocal(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return 1e3*this.getUnitsPerMillimeter()}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const t=new lo;this.queryDefaultPrecisionDescriptorWithoutFalseXY(t),this.m_defaultPrecisionSR=jr(this,t,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(t){this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal);const e=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=e.getFlattening();!function(t,e,s){t.majorSemiAxis=e,t.minorSemiAxis=e*(1-s),t.e2=s*(2-s),t.flattening=s}(t,e.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&(0,n.p)(""),(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.getAreaOfUse();return null===t?new d:new d({geom:t.clone(),sr:Ur(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(t){if(t.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const e=t.getGeometryType();if((0,n.i)(e))return this.snapMultiVertex_(t);if(e===n.G.enumPoint)return this.snapPoint_(t);if(e===n.G.enumEnvelope)return this.snapEnvelope_(t);if((0,n.f)(e))return this.snapSegment_(t);if(e===n.G.enumGeometryCollection){const e=t;let s=!1;for(let t=0,n=e.getGeometryCount();t<n;++t)s=this.snapGeometry(e.getGeometry(t))||s;return s}(0,n.d)("what else?")}snapMultiVertex_(t){if((0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision()),(0,n.h)(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments())return this.snapGeometryWithCurves_(e)}const e=t.getImpl(),s=e.getDescription();let i=!1;for(let t=0,n=s.getAttributeCount();t<n;t++){const n=s.getSemantics(t),r=e.getAttributeStreamRef(n);i=this.snapAttributes(n,r,0,e.getPointCount())||i}return i&&e.notifyModifiedFlags(2001),i}snapPoint_(t){return!1}snapEnvelope_(t){return!1}snapSegment_(t){(0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision());const e=new lo;this.queryPrecisionDescriptor(e);const s=t.getStartXY(),i=new a.P;i.x=yo(s.x,e.getFalseX(),e.getGridUnitsXY()),i.y=yo(s.y,e.getFalseY(),e.getGridUnitsXY());let r=!i.equals(s);const o=t.getEndXY(),h=new a.P;h.x=yo(o.x,e.getFalseX(),e.getGridUnitsXY()),h.y=yo(o.y,e.getFalseY(),e.getGridUnitsXY()),r||=!h.equals(o),r&&t.changeEndPoints2D(i,h);const m=(e,s,n)=>{let i=!1;{const r=t.getStartAttributeAsDbl(e,0),o=yo(r,s,n),h=!(0,a.F)(o,r);i||=h,h&&t.setStartAttribute(e,0,o)}{const r=t.getEndAttributeAsDbl(e,0),o=yo(r,s,n),h=!(0,a.F)(o,r);i||=h,h&&t.setEndAttribute(e,0,o)}return i};let l=r?1:0;return t.hasAttribute(1)&&(l|=m(1,e.getFalseZ(),e.getGridUnitsZ())?1:0),t.hasAttribute(2)&&(l|=m(2,e.getFalseM(),e.getGridUnitsM())?1:0),!!l}snapGeometryWithCurves_(t){(0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision());const e=t.createInstance(),s=new r.S;let i=0;for(let n=0,r=t.getPathCount();n<r;++n){const r=t.getSegmentCountPath(n);if(0===r){if(e.addPath(t,n,!0),1===e.getPathSize(n)){const t=new o.P;e.getPointByVal(e.getPointCount()-1,t),i|=this.snapGeometry(t)?1:0,e.setPointByVal(e.getPointCount()-1,t)}continue}const a=t.isClosedPath(n);for(let o=0,h=a?r-1:r;o<h;++o)t.getSegmentFromPath(n,o,s,!1),i|=this.snapGeometry(s.get())?1:0,e.addSegment(s.get(),0===o);a&&(t.getSegmentFromPath(n,r-1,s,!1),i|=this.snapGeometry(s.get())?1:0,1===r?e.addPathFromClosedSegment(s.get(),!1):e.closeLastPathWithSegment(s.get()))}return i&&e.copyTo(t),!!i}snapAttributes(t,e,s,n){let i=!1;const r=new lo;if(this.queryPrecisionDescriptor(r),0===t){const t=e;for(let e=s;e<n;e++){const s=t.read(2*e),n=mo.s_SnapValue(s,r.getFalseX(),r.getGridUnitsXY()),o=t.read(2*e+1),a=mo.s_SnapValue(o,r.getFalseY(),r.getGridUnitsXY());i=i||n!==s||a!==o,i&&(t.write(2*e,n),t.write(2*e+1,a))}}else if(1===t){const t=e;for(let e=s;e<n;e++){const s=t.read(e),n=mo.s_SnapValue(s,r.getFalseZ(),r.getGridUnitsZ());i=i||!(0,a.F)(n,s),i&&t.write(e,n)}}else if(2===t){const t=e;for(let e=s;e<n;e++){const s=t.read(e),n=mo.s_SnapValue(s,r.getFalseM(),r.getGridUnitsM());i=i||!(0,a.F)(n,s),i&&t.write(e,n)}}return i}static s_SnapValue(t,e,s){return(0,a.G)((t-e)*s)/s+e}}class lo{constructor(){const t=Xr,e=1e-4,s=.001,n=e*Number(t)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(t)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/e,this.m_falseZ=-1e5,this.m_unitsZ=1/e,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let t=7777,e=7777;return e=(0,a.A)(e,this.m_falseM),e=(0,a.A)(e,this.m_unitsM),t=(0,a.A)(t,this.m_unitsXY),e=(0,a.A)(e,this.m_toleranceXY),t=(0,a.A)(t,this.m_falseZ),e=(0,a.A)(e,this.m_toleranceZ),t=(0,a.A)(t,this.m_unitsZ),e=(0,a.A)(e,this.m_toleranceM),t=(0,a.A)(t,this.m_precision),(0,a.A)(t,e)}clone(){const t=new lo;return t.m_falseX=this.m_falseX,t.m_falseY=this.m_falseY,t.m_unitsXY=this.m_unitsXY,t.m_falseZ=this.m_falseZ,t.m_unitsZ=this.m_unitsZ,t.m_falseM=this.m_falseM,t.m_unitsM=this.m_unitsM,t.m_toleranceXY=this.m_toleranceXY,t.m_toleranceZ=this.m_toleranceZ,t.m_toleranceM=this.m_toleranceM,t.m_precision=this.m_precision,t}assign(t){return this.m_falseX=t.m_falseX,this.m_falseY=t.m_falseY,this.m_unitsXY=t.m_unitsXY,this.m_falseZ=t.m_falseZ,this.m_unitsZ=t.m_unitsZ,this.m_falseM=t.m_falseM,this.m_unitsM=t.m_unitsM,this.m_toleranceXY=t.m_toleranceXY,this.m_toleranceZ=t.m_toleranceZ,this.m_toleranceM=t.m_toleranceM,this.m_precision=t.m_precision,this}initialize2D(t,e){}getTolerance(t){switch(t){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(t){if(2===this.m_precision)return 0;switch(t){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){const t=new i.Envelope2D;switch(this.m_precision){case 0:{const e=lo.getLimit32()/this.getGridUnitsXY();t.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+e,ymax:this.getFalseY()+e})}break;case 1:{const e=Number(lo.getLimit64())/this.getGridUnitsXY();t.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+e,ymax:this.getFalseY()+e})}break;case 2:t.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:t.setEmpty(),(0,n.d)("")}return t}getZGridRange(){const t=new a.E;switch(this.m_precision){case 0:{const e=lo.getLimit32()/this.getGridUnitsZ();t.setCoords(this.getFalseZ(),this.getFalseZ()+e)}break;case 1:{const e=Number(lo.getLimit64())/this.getGridUnitsZ();t.setCoords(this.getFalseZ(),this.getFalseZ()+e)}break;case 2:t.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:t.setEmpty(),(0,n.d)("")}return t}getMGridRange(){const t=new a.E;switch(this.m_precision){case 0:{const e=lo.getLimit32()/this.getGridUnitsM();t.setCoords(this.getFalseM(),this.getFalseM()+e)}break;case 1:{const e=Number(lo.getLimit64())/this.getGridUnitsM();t.setCoords(this.getFalseM(),this.getFalseM()+e)}break;case 2:t.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:t.setEmpty(),(0,n.d)("")}return t}setTolerance(t,e){switch(e<0&&(0,n.a)("tol < 0"),Number.isFinite(e)||(0,n.a)("tol is not finite"),t){case 0:this.m_toleranceXY=e;break;case 1:this.m_toleranceZ=e;break;case 2:this.m_toleranceM=e;break;default:(0,n.a)("cannot set tolerance for this attribute")}}setGridParams(t,e,s){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(s)||(0,n.a)("grid params are not finite"),s<1&&(0,n.a)("grid units cannot be smaller than 1.0"),this.m_falseX=t,this.m_falseY=e,this.m_unitsXY=s}setZParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.a)("grid params are not finite"),e<1&&(0,n.a)("grid units cannot be smaller than 1.0"),this.m_falseZ=t,this.m_unitsZ=e}setMParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.a)("grid params are not finite"),e<1&&(0,n.a)("grid units cannot be smaller than 1.0"),this.m_falseM=t,this.m_unitsM=e}setPrecision(t){}equals(t){return this===t||(0,a.F)(this.m_falseX,t.m_falseX)&&(0,a.F)(this.m_falseY,t.m_falseY)&&this.equalsWithoutFalseXY(t)}snapPrecision(){if(2===this.m_precision)return;const t=(t,e,s,n)=>{if(!Number.isFinite(e)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const i=Number(t)/s;return Math.trunc((e+i-e)*s)>t&&(s=t/(e+i-e)),Math.max(1,s)},e=Number(0===this.m_precision?Fr:Xr);this.m_unitsXY=t(e,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=t(e,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=t(e,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=t(e,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const t=(t,e,s,n)=>{if(s<1)return!1;if(!Number.isFinite(e)||!Number.isFinite(s))return!1;if(!n)return!0;const i=Number(t)/s;return!(BigInt((e+i-e)*s)>t)},e=0===this.m_precision?Fr:Xr;return!!(t(e,this.m_falseX,this.m_unitsXY,!0)&&t(e,this.m_falseY,this.m_unitsXY,!0)&&t(e,this.m_falseZ,this.m_unitsZ,!1)&&t(e,this.m_falseM,this.m_unitsM,!1))}fixTolerance(){2!==this.m_precision&&(this.m_toleranceXY=Math.max(2/this.m_unitsXY,this.m_toleranceXY),this.m_toleranceZ=Math.max(2/this.m_unitsZ,this.m_toleranceZ),this.m_toleranceM=Math.max(2/this.m_unitsM,this.m_toleranceM),(Number.isNaN(this.m_falseX)||Number.isNaN(this.m_falseY))&&(this.m_falseX=this.m_falseY=Number.NaN))}equalsWithoutFalseXY(t){return this===t||this.m_unitsXY===t.m_unitsXY&&this.m_falseZ===t.m_falseZ&&this.m_unitsZ===t.m_unitsZ&&this.m_falseM===t.m_falseM&&this.m_unitsM===t.m_unitsM&&this.m_toleranceXY===t.m_toleranceXY&&this.m_toleranceZ===t.m_toleranceZ&&this.m_toleranceM===t.m_toleranceM&&this.m_precision===t.m_precision}setBestXyDomainFromEnvelope(t,e){}setBestZDomainFromZRange(t,e,s){}setBestMDomainFromMRange(t,e,s){}}function uo(){return(!no||Br()&&null===no.getPECoordSys())&&(no=Po(3857,0,0,!0)),no}function co(){return(!io||Br()&&null===io.getPECoordSys())&&(io=Po(102100,0,0,!0)),io}function go(){return(!ro||Br()&&null===ro.getPECoordSys())&&(ro=Po(4326,0,0,!0)),ro}function _o(t){t.m_falseX=0,t.m_falseY=0,t.m_unitsXY=1,t.m_falseZ=0,t.m_unitsZ=1,t.m_falseM=0,t.m_unitsM=1,t.m_toleranceXY=100*(0,a.H)(),t.m_toleranceZ=100*(0,a.H)(),t.m_toleranceM=100*(0,a.H)(),t.m_precision=2}function po(t,e,s,i){const r=e instanceof rr;_o(t),t.m_precision=i,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const o=1e-4,a=.001,h=r?e.m_csType:e.isPCS?2:1;if(1===h){const s=(0===i?1/18e5:1e-9)*(r?e.getOneDegreeGCSUnit():Math.PI/e.metersOrRadiansPerUnit/180);t.m_unitsXY=1/s}else if(2===h){const s=(0===i?a:o)*(r?e.getOneMeterPCSUnit():1/e.metersOrRadiansPerUnit);t.m_unitsXY=1/s}else(0,n.a)("unrecognized cs type");t.m_falseM=-1e5,t.m_unitsM=1/(0===i?a:o),t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let m=0,l=0;0!==i&&1!==i||(m=2/t.m_unitsXY,l=2/t.m_unitsM),t.m_toleranceXY=Math.max(m,r?e.getUnitsPerMillimeter():2===h?.001/e.metersOrRadiansPerUnit:.001/(e.semiMajor*e.metersOrRadiansPerUnit)),t.m_toleranceM=Math.max(a,l),fo(t,s)}function fo(t,e){const s=1e-4,n=.001;if(t.m_falseZ=-1e5,e){const i=(0===t.m_precision?n:s)*e.getOneMeter();t.m_unitsZ=1/i}else t.m_unitsZ=1/(0===t.m_precision?n:s);t.m_unitsZ=Math.max(1,t.m_unitsZ);let i=0;0!==t.m_precision&&1!==t.m_precision||(i=2/t.m_unitsZ),t.m_toleranceZ=Math.max(e?e.getOneMeter()*n:n,i)}function xo(t,e,s,n){_o(t),t.m_precision=n;const i=0===n?Fr:Xr,r=1e-4,o=.001;let a=1,h=1,m=.001;e&&(h=e.getUnitToBaseFactor()),e&&1===e.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===n?o:r)*Number(i)*.5,m=o/h),a/=h,t.m_falseX=-a,t.m_falseY=-a,t.m_unitsXY=Number(i)/(2*a),t.m_falseM=-1e5,t.m_unitsM=1/(0===n?o:r),t.m_unitsM=Math.max(1,t.m_unitsM),t.snapPrecision();let l=0,u=0;0!==t.m_precision&&1!==t.m_precision||(u=2/t.m_unitsM,l=2/t.m_unitsXY),t.m_toleranceXY=Math.max(l,m),t.m_toleranceM=Math.max(o,u),fo(t,s)}function Po(t,e,s,i){if(!i&&e<=0){if(3857===t)return uo();if(102100===t)return co();if(4326===t)return go()}const r=new mo;let o,a=null;return Br()?(o=function(t){t<=0&&(0,n.y)(t);{const e=Nr(t);if(e)return e}const e=Fo(bo.coordsys(t));e.get()||(0,n.y)(t);const s=Tr(e.release());return s.getLatestID()!==t&&xr.set(t,new WeakRef(s)),s}(t),e>0?a=null:e=0,r.setHorzProj_(o),r.m_vertcs=a):(o=Vo(t),r.m_unit=o.isPCS?new Ar(o.metersOrRadiansPerUnit):new f(o.metersOrRadiansPerUnit)),po(r.m_precisionDescriptor,o,a,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=t,r.calculateHashCode(),r.initDbgName(),r}function yo(t,e,s){return(0,a.G)((t-e)*s)/s+e}let Eo=null;const Co=3552713678800501e-30;function vo(t,e){return function(t,e,s){return t===e||Math.abs(t-e)<=s*(1+(Math.abs(t)+Math.abs(e))/2)}(t,e,Co)}let So,bo,Io,Do,wo,To,No,Ao,Go,qo,Mo;function Fo(t){return{_this:t,get(){return this._this},reset(t){this._this=t},release(){const t=this._this;return this._this=null,t}}}let Xo=null;function Vo(t){(0,n.g)(Xo);const e=Xo(t);return e.semiMajor=e.isPCS?Number.NaN:function(t){if(bo&&(0,n.p)("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof t){const e=t.match(Yo);e&&2===e.length||(0,n.a)("bad gcs wkt");const s=Number.parseFloat(e[1]);return Number.isFinite(s)||(0,n.a)("bad gcs wkt"),s}return Eo||Ro(),Eo.has(t)||(0,n.p)("gcs wkid not found"),Eo.get(t)}(t),e}const Yo=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Ro(){Eo=new Map;for(const t in p){const e=Number.parseFloat(t),s=p[t];if(Array.isArray(s))for(const t of s)Eo.set(t,e);else Eo.set(s,e)}!function(){for(const t in p)delete p[t]}()}function ko(t,e){const s=bo.geogtran(t);return s||(0,n.y)(t),new Uo(s,e)}function Lo(t,e){const s=bo.fromString(Io.PE_TYPE_GEOGTRAN,t);return s||(0,n.A)(t),new Uo(s,e)}function Bo(t,e){return new Uo(t,e)}const Ho=(0,a.B)(0),zo=(0,a.B)(1);class Uo{constructor(t,e){if(t instanceof Uo)return this.m_geogTranWrapper=t.m_geogTranWrapper,this.m_bInverted=e?!t.m_bInverted:t.m_bInverted,void(this.m_hashCode=(0,a.A)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?zo:Ho));this.m_geogTranWrapper=new Kn(t),this.m_bInverted=e,this.m_hashCode=(0,a.A)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?zo:Ho)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(t){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===t)return this.m_geogTranWrapper.getGeogtran().toString();{const e=0===t?Io.PE_STR_AUTH_TOP:Io.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(e)}}getText2(t=-1){let e=Io.PE_STR_FMT_WKT2;return-1!==t&&(e|=0===t?Io.PE_STR_AUTH_TOP:Io.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(e)}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 Uo(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(t){const e=t;return e===this||this.m_bInverted===e.m_bInverted&&(this.GetPeGeogtran()===e.GetPeGeogtran()||this.getID()===e.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(e.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Oo(){return new jo([],null,null,null)}function Wo(t){(0,n.g)(null!==t);const e=new Zo,s=t[0].getSteps();if(s){const n=t[0].getEntries();for(let t=0;t<s;t++){const s=0!==n[t].getDirection(),i=Bo(n[t].getGeogtran(),s);e.add(i)}return e.create()}return null}class jo{constructor(t,e,s,n){this.m_bReadOnly=!0,this.m_name="",this.m_fastTrack=-1,this.m_bNameIsSet=!1,this.m_transforms=t,e&&(this.m_name=e,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 t="";for(const e of this.m_transforms)t.length>0&&(t+=" + "),e.isInverted()&&(t+="~"),t+=e.getName();return t}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let t=1973;for(let e=0;e<this.m_transforms.length;e++)t=(0,a.A)(t,this.m_transforms[e].getHashCode());return t}equals(t){return(0,n.g)(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const t of this.m_transforms)if(t.referencesMissingData())return!0;return!1}isMatchingTransformation(t,e){return(0,n.g)(0),!1}validateTransformation(t,e){return(0,n.g)(0),!1}nameIsSet(){return(0,n.g)(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(t){return(t<0||t>this.count())&&(0,n.q)(""),this.m_transforms[t]}getInverse(){const t=new Zo;return t.addSteps(this,!0),t.setInputSpatialReference(this.m_outputSr),t.setOutputSpatialReference(this.m_inputSr),t.create()}transform(t,e,s){if(0===this.count())return;let n=this.m_inputSr,i=this.m_outputSr;if(t&&(i=(0,a.c)(n,n=i)),0===this.m_transforms.length)return void $n(n,null,i,null,e,null,s);let o=this.m_fastTrack;if(1===o)return void(0,r.a4)(t,this.m_transforms,n=>{!function(t,e,s,n,i){const r=t.getVerttran(),o=t.getGeogtran();if(i>0){t.prepareOrThrow();const n=e?Io.PE_TRANSFORM_2_TO_1:Io.PE_TRANSFORM_1_TO_2;r?Zi():Qi(o,i,s,null,n)}}(n.getWrapper(),t!==n.isInverted(),e,0,s)});const h=Qn();-1===o&&h.initFromGcsAndVcs(n,null);const m=Qn();let l=t?this.m_transforms.length-1:0;const u=t?-1:1;for(let i=0,r=this.m_transforms.length;i<r;i++,l+=u){if(0===i){const i=this.m_transforms[l];Jn(n.getPECoordSys(),null,i.getWrapper(),t!==i.isInverted(),e,null,s,m),-1===o&&(h.equals(m)||(o=0)),h.assign(m)}else{const n=this.m_transforms[l-u],i=this.m_transforms[l];ti(h,n.getWrapper(),t!==n.isInverted(),i.getWrapper(),t!==i.isInverted(),e,null,s,m),-1===o&&(h.equals(m)||(o=0)),h.assign(m)}const r=this.m_transforms[l];ei(h,r.getWrapper(),t!==r.isInverted(),e,null,s,m),h.assign(m)}const c=this.m_transforms[l-u];(function(t,e,s,n,i,r,o,a){const h=Qn();h.assign(s?e.m_inputUnitParams:e.m_outputUnitParams),h.processUnitParams(t);let m=null;n&&(m=n.getPECoordSys());const l=Qn();l.initFromGcsAndVcsPe(m,null),l.processUnitParams(h),h.processUnitParams(l),a>0&&Zn(h,l,r,null,a)})(h,c.getWrapper(),t!==c.isInverted(),i,0,e,0,s),-1===o&&(m.initFromGcsAndVcs(i,null),h.equals(m)||(o=0)),this.m_fastTrack=0===o?0:1}}class Zo{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(t){this.m_inputGCS=t?t.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(t){this.m_outputGCS=t?t.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let t="";for(const e of this.m_transforms)t.length>0&&(t+=" + "),e.isInverted()&&(t+="~"),t+=e.getName();return t}count(){return this.m_transforms.length}getStep(t){return(t<0||t>this.count())&&(0,n.q)(""),this.m_transforms[t]}setStep(t,e){(0,n.g)(0)}add(t){this.m_transforms.push(t)}addSteps(t,e){if(e)for(let e=t.count()-1;e>=0;--e)this.add(t.getStep(e).getInverse());else for(let e=0;e<t.count();++e)this.add(t.getStep(e))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(t){(0,n.g)(0)}create(){const t=this.getInputSpatialReference(),e=this.getOutputSpatialReference(),s=new jo(this.m_transforms,this.m_bNameIsSet?this.m_name:null,t,e);return s.m_bReadOnly=!0,this.clear(),s}}},79187:(t,e,s)=>{s.r(e),s.d(e,{Envelope2D:()=>r});var n=s(55537),i=s(83661);class r{static construct(t,e,s,n){return new r(t,e,s,n)}constructor(t,e,s,n){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=n):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new r(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new r(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return i.P.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let n=s;n<e;n++)this.mergeNe(t[n]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let n=2*e,i=n+2*s;n<i;n+=2)this.mergeCoords(t.read(n),t.read(n+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(t){void 0!==t.xmin?(this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax):void 0!==t.x?(this.xmin=t.x,this.xmax=t.x,this.ymin=t.y,this.ymax=t.y):void 0!==t.pt1?(this.xmin=t.pt1.x,this.ymin=t.pt1.y,this.xmax=t.pt2.x,this.ymax=t.pt2.y,this.normalize()):void 0!==t.env2D?(this.xmin=t.env2D.xmin,this.xmax=t.env2D.xmax,this.ymin=t.env2D.ymin,this.ymax=t.env2D.ymax,this.normalize()):void 0!==t.pt?(this.xmin=t.pt.x,this.xmax=t.pt.x,this.ymin=t.pt.y,this.ymax=t.pt.y):void 0!==t.center?(this.xmin=t.center.x-.5*t.width,this.xmax=this.xmin+t.width,this.ymin=t.center.y-.5*t.height,this.ymax=this.ymin+t.height,this.normalize()):(0,n.t)("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let n=t;n<e;n++)this.mergeNe(s[n]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let t=1,n=2*e;t<n;t+=2){if(!this.isEmpty()){for(let n=t,i=2*e;n<i;n+=2)this.mergeNeCoords(s[n],s[n+1]);return}this.setCoords({x:s[t],y:s[t+1]}),t+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new i.P(this.xmin,this.ymin)}getLowerRight(){return new i.P(this.xmax,this.ymin)}getUpperLeft(){return new i.P(this.xmin,this.ymax)}getUpperRight(){return new i.P(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new i.P(this.xmin,this.ymin);case 1:return new i.P(this.xmin,this.ymax);case 2:return new i.P(this.xmax,this.ymax);default:return new i.P(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,n=.5*this.width(),i=.5*this.height()*s;if(n<=i){const t=this.getCenterX();this.xmin=t-i,this.xmax=t+i}else{const t=n/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),n=this.clipCode(e);if(s&n)return 0;if(!(s|n))return 4;const i=(s?1:0)|(n?2:0);do{const i=e.x-t.x,o=e.y-t.y;if(Math.abs(i)>Math.abs(o)?s&r.XMASK?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/i,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/i,t.x=this.xmax),s=this.clipCode(t)):n&r.XMASK?(n&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/i,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/i,e.x=this.xmax),n=this.clipCode(e)):s?(s&r.YLESSYMIN?(t.x+=i*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=i*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):(n&r.YLESSYMIN?(e.x+=i*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=i*(this.ymax-e.y)/o,e.y=this.ymax),n=this.clipCode(e)):s&r.YMASK?(s&r.YLESSYMIN?(t.x+=i*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=i*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):n&r.YMASK?(n&r.YLESSYMIN?(e.x+=i*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=i*(this.ymax-e.y)/o,e.y=this.ymax),n=this.clipCode(e)):s?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/i,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/i,t.x=this.xmax),s=this.clipCode(t)):(n&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/i,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/i,e.x=this.xmax),n=this.clipCode(e)),s&n)return 0}while(s|n);return i}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,n=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>n&&(n=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>n&&(n=e),s*s+n*n}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let n,i=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),n=this.xmin-t.xmax,n>i&&(i=n,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),n=this.ymin-t.ymax,n>r&&(r=n,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),n=t.xmin-this.xmax,n>i&&(i=n,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),n=t.ymin-this.ymax,n>r&&(r=n,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),i*i+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,n=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>n&&(n=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>n&&(n=e),s*s+n*n}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,n=0,i=0;return s=this.xmin-t.x,s>n&&(n=s,e.x=this.xmin),s=this.ymin-t.y,s>i&&(i=s,e.y=this.ymin),s=t.x-this.xmax,s>n&&(n=s,e.x=this.xmax),s=t.y-this.ymax,s>i&&(i=s,e.y=this.ymax),n*n+i*i}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=i.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),n=i.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=i.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),o=i.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),a=Math.max(s,n),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=i.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),n=i.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=i.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),o=i.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),a=Math.max(s,n),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=i.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),n=i.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=i.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=i.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),a=Math.max(s,n),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=i.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),n=i.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=i.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=i.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),a=Math.max(s,n),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=(0,i.m)(i.P,4);this.queryCorners(s);const n=(0,i.m)(i.P,4);t.queryCorners(n);for(let t=0;t<4;t++)for(let r=0;r<4;r++){const o=i.P.sqrDistance(s[t],n[r]);o>e&&(e=o)}return e}sqrMaxMinDistance(t){const e=i.P.sqrDistance(t,this.getLowerLeft()),s=i.P.sqrDistance(t,this.getUpperLeft()),n=i.P.sqrDistance(t,this.getLowerRight()),r=i.P.sqrDistance(t,this.getUpperRight());let o,a=Math.max(e,s);return o=Math.max(e,n),a>o&&(a=o),o=Math.max(s,r),a>o&&(a=o),o=Math.max(n,r),a>o&&(a=o),a}sqrMinDistance(t){return this.contains(t)?0:this.sqrDistance(t)}sqrMaxDistance(t){let e=i.P.sqrDistance(t,this.getLowerLeft());return e=Math.max(i.P.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(i.P.sqrDistance(t,this.getUpperRight()),e),e=Math.max(i.P.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,n=t.x-this.xmin,i=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,n)>Math.max(i,r)?t.y=r<i?this.ymin:this.ymax:t.x=n<s?this.xmin:this.xmax,!0}snapClip(t){const e=(0,i.s)(t.x,this.xmin,this.xmax),s=(0,i.s)(t.y,this.ymin,this.ymax);return i.P.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const n=new i.P;return n.setCoordsPoint2D(t),this.snapToBoundary(n),this.boundaryDistance(n)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,n=this.xmax-this.xmin;return e<s?0:(e-=s)<n?1:e-n<s?2:3}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:(0,n.a)("query_side")}return e}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){return this.isEmpty()?(0,i.g)():(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*(0,i.g)()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}r.XLESSXMIN=1,r.YLESSYMIN=4,r.XMASK=3,r.YMASK=12},88885:(t,e,s)=>{s.d(e,{$:()=>x,A:()=>Dt,B:()=>Gi,C:()=>fs,D:()=>Mi,E:()=>us,F:()=>qi,H:()=>Ir,I:()=>v,J:()=>vn,K:()=>di,L:()=>Xr,M:()=>Z,N:()=>_r,O:()=>B,P:()=>bt,Q:()=>jt,R:()=>Dr,S:()=>Vr,T:()=>Nr,U:()=>V,V:()=>ms,W:()=>it,X:()=>p,Y:()=>wr,Z:()=>Tr,_:()=>qr,a:()=>rs,a0:()=>Oi,a1:()=>ls,a2:()=>wi,a3:()=>bi,a4:()=>z,a5:()=>lr,a6:()=>ur,a7:()=>nr,a8:()=>ki,a9:()=>xt,b:()=>Si,c:()=>wt,d:()=>Ai,e:()=>_s,f:()=>cs,g:()=>u,i:()=>ds,l:()=>Ni,n:()=>as,s:()=>U,x:()=>fe,y:()=>dt,z:()=>_t});var n=s(55537),i=s(95213),r=s(83661),o=s(79187),a=s(11878),h=s(76061);class m extends h.G{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class l{constructor(t){this.m_geoms=[],this.m_description=(0,i.K)(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,n.a)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===n.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&(0,n.a)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return n.G.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,i.L)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,i.M)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,i.K)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new r.E;const n=new r.E;n.setEmpty();for(const i of this.m_geoms)s=i.queryInterval(t,e),n.merge(s);return n}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new i.E;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,n.t)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,n.t)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);(0,n.t)("3d xform not impl")}transformAttribute(t,e,s,n,i){for(const r of this.m_geoms)r.transformAttribute(t,e,s,n,i)}createInstance(){return new l({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==n.G.enumGeometryCollection&&(0,n.a)("");const e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(const t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,n.g)(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const t of this.m_geoms){const s=t.getBoundary();s&&e.m_geoms.push(s)}return t}clone(){return new l({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==n.G.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(s.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==n.G.enumGeometryCollection&&(0,n.a)("");const e=t;e!==this&&(this.m_geoms=(0,r.c)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const n of this.m_geoms)n.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,i.N)(e,t);this.assignVertexDescription(s)}}function u(t,e=-1){return new m(t,e)}l.type=n.G.enumGeometryCollection;class c{constructor(){this.m_EnvelopeType=5,this.envAabb=o.Envelope2D.constructEmpty(),this.envRot=o.Envelope2D.constructEmpty()}static constructEmpty(){return new c}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:g(t),y:d(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(g(t),d(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let n=s;n<e;n++){const e=g(t[n]),s=d(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=g(t[s]),n=d(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(g(t),d(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*(0,r.a3)();this.envRot.inflateCoords(e,e),e<0&&c.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(_(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(_(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(_(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=function(t,e){return t-e}(t.x,t.y),n=function(t,e){return t+e}(t.x,t.y);e.setCoords(s,n)}}function g(t){return t.x-t.y}function d(t){return t.x+t.y}function _(t){return new r.P(g(t),d(t))}class p{constructor(){this.x=r.X.getNAN(),this.y=r.X.getNAN()}static getNAN(){return new p}static constructPoint2D(t){const e=new p;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new p;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new p;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new p).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new p;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new p;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=r.a6.clone(),this.y=r.U.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),n=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),n=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return r.P.construct(this.x.value(),this.y.value())}}class f{constructor(){this.a11=new r.X(1),this.a12=new r.X(0),this.a21=new r.X(0),this.a22=new r.X(1)}clone(){const t=new f;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),n=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),i=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=n,this.a22=i,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),n=this.a21.negate().divThisE(t),i=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=n,this.a22=i}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,r.c)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let n=new r.X(1),i=new r.X(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new r.X(1);if(this.a11.ne(this.a22)){const o=this.a11.subE(this.a22).divE(s);o.mulThisByPower2(.5);const a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(r.U)&&e.negateThis();const h=e.sqr().addThis(1).sqrtThis().invThis();i=e.mulE(h),n.setE(h);const m=e.mulE(s);t[0]=this.a11.addE(m),t[1]=this.a22.subE(m)}else n=new r.X(1/Math.sqrt(2)),i=n.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=n.toDouble(),e[0].y=i.toDouble(),e[1].x=i.negate().toDouble(),e[1].y=n.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,r.c)(t[0],t[0]=t[1]),e[1]=(0,r.c)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class x{static constructPoint2D(t){return new x(r.M.constructDouble(t.x),r.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new r.M).setNAN(),void(this.y=(new r.M).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new r.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new x(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new x(this.x.add(t.x),this.y.add(t.y))}sub(t){return new x(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var P=i.V;function y(t){let e=!1;for(let s=0;s<2;s++){const n=(0,r.a4)(t[0][s],t[3][s]);n>0?((0,r.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),(0,r.a4)(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),(0,r.a4)(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),(0,r.a4)(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?((0,r.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),(0,r.a4)(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),(0,r.a4)(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),(0,r.a4)(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function E(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const n=t.getEndXY();return!!n.equals(e.getStartXY())||!!n.equals(e.getEndXY())}function C(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function v(t,e,s){const i=(0,r.m)(r.P,4);let o=t.queryControlPointsHelper(i);const a=(0,r.m)(r.P,4);let h=e.queryControlPointsHelper(a);i[0].equals(a[0])||(0,n.z)("");const m=t.getGeometryType();if(m===e.getGeometryType()&&i.map((t,e)=>a[e].equals(t)).reduce((t,e)=>t&&e)){if(m!==n.G.enumRationalBezier2)return 0;{const s=e,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),s.queryWeights(i),n.map((t,e)=>i[e]===t).reduce((t,e)=>t&&e))return 0}}for(;o>2&&i[1].equals(i[0]);)i.splice(1,1),o--;for(;h>2&&a[1].equals(a[0]);)a.splice(1,1),h--;(i[1].equals(i[0])||a[1].equals(i[0]))&&(0,n.z)("");const l=r.P.compareVectorsOrigin(i[0],i[1],a[1]);if(0===l){const s=x.constructPoint2D(i[0]),n=new x;t.queryCoord2DMP(1e-16,n),n.sub(s);const r=new x;return e.queryCoord2DMP(1e-16,r),r.sub(s),r.crossProduct(n).sign()}return l}function S(t,e,s,i,o,a,h,m){let l=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),c=t,g=e,d=!1;l>u&&(g=(0,r.c)(c,c=g),i=(0,r.c)(s,s=i),u=(0,r.c)(l,l=u),d=!0);const _=0===s;{h[0]=_?1:0;const t=c.getCoord2D(h[0]);m[0]=g.getClosestCoordinate(t,!1);const e=g.getCoord2D(m[0]);if(r.P.distance(t,e)<=o){const e=[.5,.75,.25,.1,.9];let s=!0;for(let n=0;n<e.length;n++)if(t.assign(c.getCoord2D(e[n])),!g.isCloserThanDistance(t,new r.E(0,1),o)){s=!1;break}if(s)return d&&(m[0]=(0,r.c)(h[0],h[0]=m[0])),1}}if(l<=3*o)return 0;let p=(0,r.s)(Math.max(o/l,.1),0,.5),f=.01*o,x=0,P=0,y=p,E=-1,C=0,v=1/32;for(let t=0;;t++){(0,n.g)(t<4095);const e=_?p:1-p,s=c.getCoord2D(e),l=g.getClosestCoordinate(s,!1);if(l===i)return C;const u=g.getCoord2D(l),S=r.P.distance(s,u);if(0===t&&(E=S),S<=f?(v=.5,P=S,x=p):(y=p,E=S),Math.abs(P-E)>.1*f&&y-x>1e-16)p=(0,r.q)(x,y,v);else{if(h[C]=e,m[C]=l,d&&(m[C]=(0,r.c)(h[C],h[C]=m[C])),1===a||1===C)return 1===C&&h[0]>h[1]&&(h[1]=(0,r.c)(h[0],h[0]=h[1]),m[1]=(0,r.c)(m[0],m[0]=m[1])),C+1;C++,x=y,P=E,y=.8,E=-1,p=.8,v=1/32,f=10*o,t=0}}}function b(t,e,s,n,i,o,a,h,m){if((0,r.a8)(s,0,1)&&(0,r.a8)(n,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(n))){const m=1e-12,l=new p,u=(0,r.H)();if(t.queryDerivative(new r.X(s,u),l),l.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new r.X(s,u).add(e),l)}1===s&&l.negateThis();const c=new p;if(e.queryDerivative(new r.X(n,u),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new r.X(n,u).add(t),c)}1===n&&c.negateThis(),l.isZero()||l.normalize(),c.isZero()||c.normalize();const g=l.dotProduct(c),d=l.crossProduct(c);d.scaleError(3);const _=()=>{{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(g.ge(r.U)&&(d.isZero()||Math.abs(d.value())<_()))return S(t,e,s,n,i,o,a,h)}return 0}function I(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function D(t,e,s){t.m_XStart=e,t.m_YStart=s}function w(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function T(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function N(t,e){const s=new i.d;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:P.getDefaultValue(1)}(t,e),s}function A(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function G(t,e,s){s.assignVertexDescription(t.m_description);const n=0===e?t.m_XStart:t.m_XEnd,i=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(n,i);for(let n=1;n<t.m_description.getAttributeCount();n++){const i=t.m_description.getSemantics(n);for(let n=0,r=P.getComponentCount(i);n<r;n++){const r=M(t,e,i,n);s.setAttributeBasic(i,n,r)}}}function q(t,e,s){s.isEmpty()&&(0,n.B)(""),function(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}(t,e,s.getXY());const i=s.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let n=1,r=i.getAttributeCount();n<r;n++){const r=i.getSemantics(n),o=P.getComponentCount(r);for(let n=0;n<o;n++)F(t,e,r,n,s.getAttributeAsDbl(r,n))}}function M(t,e,s,i){if((e<0||e>1)&&(0,n.q)(""),0===s)return(i<0||i>=2)&&(0,n.q)(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const r=P.getComponentCount(s);(i<0||i>=r)&&(0,n.q)("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+i]:P.getDefaultValue(s)}function F(t,e,s,i,r){if((e<0||e>1)&&(0,n.q)(""),0===s)return 0===e?0===i?t.m_XStart=r:1===i?t.m_YStart=r:(0,n.q)(""):1===e?0===i?t.m_XEnd=r:1===i?t.m_YEnd=r:(0,n.q)(""):(0,n.q)(""),void t.endPointModified();const o=P.getComponentCount(s);(i<0||i>=o)&&(0,n.q)("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+i]=r}function X(t,e){if(t===e)return;e.isEmpty()&&(0,n.B)("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let n=1,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=P.getComponentCount(i);for(let s=0;s<r;s++){let n=M(e,0,i,s);F(t,0,i,s,n),n=M(e,1,i,s),F(t,1,i,s,n)}}}function V(t){return t.absNorm()*(0,r.g)()}function Y(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,r.g)()}function R(t,e,s){const n=new c;t.queryEnvelopeW(r.E.unit(),n);const i=new c;return e.queryEnvelopeW(r.E.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function k(t,e,s){const n=(0,r.a7)(t,s),i=(0,r.a7)(e,s);n.sort((t,e)=>t.compare(e)),i.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(n[t].compare(i[t])<0)return-1;if(0!==n[t].compare(i[t]))return 1}return 0}var L=i.V;class B{constructor(t){if(t.copy)this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice());else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:(0,i.K)(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:(0,i.O)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=(0,i.K)());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:(0,i.O)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);(0,n.d)("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,r.d)(2*t,Number.NaN)),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,n.t)("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return(0,n.t)("not implemented"),!1}setCoordsForIntersector3D(t,e,s){(0,n.t)("not implemented")}transformAttribute(t,e,s,i,r){(0,n.t)("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,i.N)(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),n=e.getXY();this.changeEndPoints2D(s,n);let i=t.getDescription();i!==this.getDescription()&&this.mergeVertexDescription(i),i=e.getDescription(),i!==this.getDescription()&&this.mergeVertexDescription(i);for(let s=1,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=L.getComponentCount(n);for(let s=0;s<r;s++)F(this,0,n,s,t.getAttributeAsDbl(n,s)),F(this,1,n,s,e.getAttributeAsDbl(n,s))}}getStartXY(){return new r.P(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return N(this,0)}setStartXYZ(t){A(this,0,t)}setStartXYZCoords(t,e,s){A(this,0,i.d.construct(t,e,s))}queryStart(t){G(this,0,t)}setStart(t){q(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return M(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,n.g)(0),0}setStartAttribute(t,e,s){F(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=L.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,n)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=L.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,n)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,n.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,n.g)(0),0}getEndXY(){return new r.P(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return N(this,1)}setEndXYZ(t){A(this,1,t)}setEndXYZCoords(t,e,s){A(this,1,i.d.construct(t,e,s))}queryEnd(t){G(this,1,t)}setEnd(t){q(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return M(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,n.g)(0),Math.trunc(0)}setEndAttribute(t,e,s){F(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,n.a)("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,r.b)(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=r.E.constructEmpty();return s.vmin=M(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(M(this,1,t,e)),s}calculateLength3D(t){return(0,n.g)(0),0}getCoord3D(t){return(0,n.g)(0),{}}getCoord2D(t){const e=r.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,n.g)(0)}getCoordZ(t){return(0,n.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),i=L.getComponentCount(n);for(let s=0;s<i;s++){const i=this.getAttributeAsDbl(t,n,s);e.setAttributeBasic(n,s,i)}}}isCloserThanDistance(t,e,s){const n=o.Envelope2D.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,n),n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&r.P.distance(t,this.getCoord2D(i))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=L.getComponentCount(e);t<s;t++){const s=M(this,0,e,t);F(this,0,e,t,M(this,1,e,t)),F(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==i){const e=(0,r.d)(9,Number.NaN),o=(0,r.d)(9,Number.NaN),a=this.intersect(t,null,e,o,0);(0,n.g)(a<=9),0===a&&(0,n.d)(""),null!==s&&(s[0]=e[0]),null!==i&&(i[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,h=-1,m=a;return o=this.getStartXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==i&&(i[0]=h),null!==s&&(s[0]=0)),o=this.getEndXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==i&&(i[0]=h),null!==s&&(s[0]=1)),o=t.getStartXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==i&&(i[0]=0)),o=t.getEndXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==i&&(i[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return(0,r.q)(t,e,s)}moveTo(t){const e=this.isClosed(),s=new a.T;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,n.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){const s=(0,i.Q)();(0,i.R)(e,t.m_description,s);let n=null;const o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(n=(0,r.d)(2*o,Number.NaN),(0,r.b)(n,e.getDefaultPointAttributes(),0,2,o),(0,r.b)(n,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let i=1;i<e.getAttributeCount();i++){const r=s[i];if(-1!==r){const s=t.m_description.getPointAttributeOffset(r)-2,h=e.getPointAttributeOffset(i)-2,m=P.getComponentCount(e.getSemantics(i));for(let e=0;e<m;++e)n[h]=t.m_attributes[s],n[o+h]=t.m_attributes[a+s]}}t.m_attributes=n,t.m_description=e}(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,i.L)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,i.M)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,i.K)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,n.a)("wrong geometry type");const e=t;e.m_description=(0,r.c)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,r.c)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,r.c)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,r.c)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,r.c)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,r.c)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const n=t;if(this===n)return!0;if(this.m_description!==n.m_description)return!1;if(Math.abs(this.m_XStart-n.m_XStart)>e||Math.abs(this.m_XEnd-n.m_XEnd)>e||Math.abs(this.m_YStart-n.m_YStart)>e||Math.abs(this.m_YEnd-n.m_YEnd)>e)return!1;for(let t=0,s=2*(this.m_description.getTotalComponentCount()-2);t<s;t++)if(!(0,r.a5)(this.m_attributes[t],n.m_attributes[t],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(t,e,s){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,n.a)("");const t=new a.T,i=0===e?s:0,r=1===e?s:0;t.setShiftCoords(i,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,s),this.setEndAttribute(t,e,s)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=L.getComponentCount(t);for(let n=0;n<s;n++){const s=this.getStartAttributeAsDbl(t,n);Number.isNaN(s)&&this.setStartAttribute(t,n,e);const i=this.getEndAttributeAsDbl(t,n);Number.isNaN(i)&&this.setEndAttribute(t,n,e)}}}B.s_maxMonotonicPartParams=8;class H{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function z(t,e,s){if(t)for(let t=e.length-1;t>=0;--t)s(e[t]);else e.forEach(s)}function U(t,e){let s=(0,r.J)(t);const n=e.length/(0,r.i)();for(let t=0;t<e.length;++t){const t=Math.trunc(s*n);s=(0,r.J)(s);const i=Math.trunc(s*n),o=e[t];e[t]=e[i],e[i]=o}}var O=i.V;const W="can not assign an empty point to a vertex";class j{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,i.K)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new H,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new i.U,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:(0,i.K)();this.m_description=e,this.m_vertexAttributes=new H,this.m_envelopeData=new i.U,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,n.i)(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==s.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const n=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(n),o=s.getAttributeStreamRef(n),a=O.getComponentCount(n);if(!r.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,r,o){if(this.addAttribute(t),!this.isEmpty()&&(0!==s||1!==r)){if(0===t){const t=new a.T;return 0===o?0===e?(t.setShiftCoords(s,0),t.scale(r,1)):1===e?(t.setShiftCoords(0,s),t.scale(1,r)):(0,n.a)(""):0===e?(t.setScaleCoords(1/r,1),t.shiftCoords(-s,0)):1===e?(t.setScaleCoords(1,1/r),t.shiftCoords(0,-s)):(0,n.a)(""),void this.applyTransformation(t)}(function(t,e,s,i,r){(e<0||s<0||i<1||e+i*(s-1)+1>t.size())&&(0,n.a)("Index out of bound");for(let n=e,o=e+i*(s-1)+1;n<o;n+=i)t.writeAsDbl(n,r(t.readAsDbl(n)))})(this.getAttributeStreamRef(t),e,this.getPointCount(),O.getComponentCount(t),(0,i._)(s,r,o)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,i.N)(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,i.L)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,i.M)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,i.K)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,n.a)("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,n.a)("stream"),e&&O.getPersistence(t)!==e.getPersistence()&&(0,n.a)(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){const n=this.m_description.getSemantics(e);for(let i=0,r=O.getComponentCount(n);i<r;i++){const o=this.m_vertexAttributes.get(e).readAsDbl(r*t+i);s.setAttributeBasic(n,i,o)}}}setPointByValNoCurves(t,e){const s=e;s.isEmpty()&&(0,n.a)(W);const i=s.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*t,s.getX()),r.write(2*t+1,s.getY());for(let e=1,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),i=O.getComponentCount(n);for(let r=0;r<i;r++){const o=s.getAttributeAsDbl(n,r);this.m_vertexAttributes.get(e).writeAsDbl(t*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,s,i){(0,n.g)(0)}getPointByValAsArray(t,e,s,i){(0,n.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=O.getComponentCount(t);s>=i&&(0,n.q)("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*i+s):O.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const r=O.getComponentCount(t);i<r&&(0,n.q)("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,n=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=n.readAsDbl(t+e)}else{const e=O.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,i){(0,n.g)(0)}setAttributeNoCurves(t,e,s,i){const r=O.getComponentCount(t);s>=r&&(0,n.q)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,i)}setAttributeFromArrayNoCurves(t,e,s,i){(e<0||e>=this.m_pointCount)&&(0,n.q)("");const r=O.getComponentCount(t);i<r&&(0,n.q)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let t=0;t<r;++t)a.writeAsDbl(e*r+t,s[t])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const n=this.m_vertexAttributes.get(0);n.write(2*t,e),n.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=i.d.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=O.getDefaultValue(1),s}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.Envelope2D||t instanceof i.q?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=r.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let n=!1;const i=O.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*i;r<a;r+=i){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),n=!0)}}else for(let t=e,o=this.m_pointCount*i;t<o;t+=i)r.readAsDbl(t)!==s&&(r.writeAsDbl(t,s),n=!0);n&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const n=O.getComponentCount(t),i=this.getAttributeStreamRef(t);for(let t=0;t<n;t++)if(1===i.getPersistence()){const t=i;for(let i=0,r=this.m_pointCount*n;i<r;i++){const n=t.read(i);Number.isNaN(n)&&(t.write(i,e),s=!0)}}else for(let t=0,r=this.m_pointCount*n;t<r;t++){const n=i.readAsDbl(t);Number.isNaN(n)&&(i.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,n.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,n.a)(""),this.m_envelopeData=new i.U({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,n.a)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,n.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*s,n=2*r,i=0;e<n;e+=2,i++)o.queryPoint2D(e,t[i]);return r}queryCoordinates3D(t,e,s,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,n.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=O.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<r;e++,l++)t[l].x=o.read(2*e),t[l].y=o.read(2*e+1),t[l].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const n=t&~e,i=e|n;s=this.m_flags,(s&i)!==e&&(this.m_flags=s&~n|e)}getIsSimple(t,e){e[0]=0;let s=-1;const n=this.m_flags,i=this.m_simpleTolerance;return 1&n||(s=(14&n)>>1,e[0]=i,i<t&&(s=-1)),s}setIsSimple(t,e,s=!1){if(2===t?(0,n.g)(this.getGeometryType()===n.G.enumPolyline):1===t?(0,n.g)(this.getGeometryType()===n.G.enumMultiPoint||this.getGeometryType()===n.G.enumPolyline):3===t&&(0,n.g)(this.getGeometryType()===n.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let n=t<<1;s||(n|=16);const i=31;this.clearAndSetDirtyFlagProtected(i,n),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&(0,n.C)("Cannot do shallow clone on unprepared geometry");const s=t,i=this.getGeometryType(),r=s.getGeometryType();(0,n.g)(i===r||i===n.G.enumPolygon&&r===n.G.enumPolyline,"failure in copyToUnchcked"),s.clearAccelerators(),s.m_description=this.m_description,s.m_vertexAttributes.destroyAndSetSize(0),s.m_envelopeData.releaseAttributes();const o=this.m_description.getAttributeCount(),a=new H;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{const e=O.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,s.m_envelopeData),s.m_flags=this.m_flags,s.m_simpleTolerance=this.m_simpleTolerance,i!==r){const t=[Number.NaN];s.getIsSimple(0,t)>=3?s.setIsSimple(1,t[0]):s.setIsSimple(-1,0)}s.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),s.m_pointCount=this.m_pointCount,s.hasDirtyFlag(32)||s.m_vertexAttributes.empty()?((0,n.g)(!e||0===s.m_pointCount),s.m_reservedPointCount=-1):s.m_reservedPointCount=s.m_pointCount;try{this.copyToImpl(s,e)}catch(t){throw s.setEmpty(),t}s.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,o){(t<0||t>=this.m_pointCount)&&(0,n.q)(""),(e<0||e>=this.m_pointCount)&&(0,n.q)(""),o.assignVertexDescription(this.m_description);const a=(0,r.d)(O.maxComponentCount(),Number.NaN),h=(0,r.d)(O.maxComponentCount(),Number.NaN),m=(0,i.W)();let l=0;for(let o=0;o<this.m_description.getAttributeCount();o++){const u=this.m_description.getSemantics(o),c=O.getInterpolation(u),g=O.getComponentCount(u),d=O.getDefaultValue(u);this.queryAttributeAsDbl(u,t,a,g),this.queryAttributeAsDbl(u,e,h,g),(0,n.g)(l+g<=i.X),(0,r.a9)(c,a,h,m,l,g,s,d),l+=g}!function(t,e){const s=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,r.b)(t.getAttributeArray(),e,0,2,s-2)}(o,m)}getShortestDistance(t,e){return r.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return r.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,n.a)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=(0,i.Q)();(0,i.R)(t,this.m_description,e);const s=new H;s.destroyAndSetSize(t.getAttributeCount());for(let n=0;n<t.getAttributeCount();n++){const t=e[n];-1!==t?s.set(n,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return 0!==(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const n=this.m_description.getSemantics(s);let r=0;if(null!==this.m_vertexAttributes.get(s)){const t=O.getComponentCount(n);r=this.m_vertexAttributes.get(s).size()/t,r<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,O.getDefaultValue(n)),r=e)}else this.m_vertexAttributes.set(s,(0,i.Y)(n,e)),r=e;r<t&&(t=r)}this.m_reservedPointCount=t}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new i.E({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),n=O.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const o=new r.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=i.readAsDbl(e*n+t);o.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new i.U({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=o.Envelope2D.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){(0,n.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.Envelope2D?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&(0,n.a)(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,i.Z)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*s),s=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,i.Z)(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),n=O.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*n):this.m_vertexAttributes.set(t,(0,i.Z)(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&(0,n.a)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,n.B)("")}}class Z extends j{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,e){t>this.getPointCount()&&(0,n.a)("invalid point index"),t<0&&(t=this.getPointCount());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let n=0,r=this.m_description.getAttributeCount();n<r;n++){const r=this.m_description.getSemantics(n),o=i.V.getComponentCount(r);if(0===r)this.m_vertexAttributes.get(n).insert(o*t,e,o*s);else{const e=i.V.getDefaultValue(r);this.m_vertexAttributes.get(n).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,n.a)(W),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let n=0,r=this.m_description.getAttributeCount();n<r;n++){const r=this.m_description.getSemantics(n),o=i.V.getComponentCount(r);if(e.hasAttribute(r))this.m_vertexAttributes.get(n).insertAttributes(o*t,e,r,o*s);else{const e=i.V.getDefaultValue(r);this.m_vertexAttributes.get(n).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&(0,n.q)(""),t<0&&(t=this.getPointCount()),0===s)return;const r=e[0].getDescription();this.mergeVertexDescription(r);const o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let n=0,a=this.m_description.getAttributeCount();n<a;n++){const a=this.m_description.getSemantics(n),h=i.V.getComponentCount(a);if(this.m_vertexAttributes.get(n))if(r.hasAttribute(a))this.m_vertexAttributes.get(n).insertAttributesFromPoints(t*h,e,s,a,o*h);else{const e=i.V.getDefaultValue(a);this.m_vertexAttributes.get(n).insertRange(h*t,e,h*s,h*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,s){if((t>this.getPointCount()||s<0)&&(0,n.a)("invalid point index"),t<0&&(t=this.getPointCount()),0===s)return;const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let n=0,o=this.m_description.getAttributeCount();n<o;n++){const o=this.m_description.getSemantics(n),a=i.V.getComponentCount(o);if(this.m_vertexAttributes.get(n))if(0===o)this.m_vertexAttributes.get(n).insertRangeFromPoints(a*t,e,0,s,!0,a*r);else{const e=i.V.getDefaultValue(o);this.m_vertexAttributes.get(n).insertRange(a*t,e,a,a*r)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,n.q)("remove_points"),0!==e){for(let s=0,n=this.m_description.getAttributeCount();s<n;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),r=i.V.getComponentCount(n);this.m_vertexAttributes.get(s).eraseRange(r*t,r*e,r*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),n=i.V.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(n*t,n,n*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),n=i.V.getDefaultValue(s),r=i.V.getComponentCount(s);this.m_vertexAttributes.get(t).insertRange(r*e,n,r*(this.m_pointCount-e),r*e)}}queryCoordinates3D(t,e,s,r){let o=r<0?this.m_pointCount:r;if(o=Math.min(o,s+e),(s<0||o<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,n.a)(""),0===this.m_pointCount)return o;const a=this.getAttributeStreamRef(0);let h=null;const m=i.V.getDefaultValue(1),l=this.m_description.hasAttribute(1);l&&(h=this.getAttributeStreamRef(1));let u=0;for(let e=s;e<o;e++,u++)t[u].x=a.read(2*e),t[u].y=a.read(2*e+1),t[u].z=l?h.read(e):m;return o}queryAttributeAsInt(t,e,s,i){(0,n.g)(0)}add(t){t.isEmpty()&&(0,n.a)(W),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new r.P(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const n=new i.d;n.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,n)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,s){this===t&&(0,n.a)("Multi_point_impl.add");const r=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||r<e)&&(0,n.a)(""),e===r)return;const o=t.getDescription();this.mergeVertexDescription(o);const a=r-e,h=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),r=i.V.getComponentCount(n),m=this.getAttributeStreamRef(n);if(o.hasAttribute(n)){const s=t.getAttributeStreamRef(n);m.insertRangeFromStream(h*r,s,e*r,a*r,!0,1,h*r)}else{const t=i.V.getDefaultValue(n);m.insertRange(h*r,t,a*r,h*r)}}}addPoints2D(t,e,s,i){let r=e;const o=i<0?r:i;if((r<0||s<0||s>r||o<s)&&(0,n.a)(""),s===o)return;r=o-s;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[s+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,s,i){let o=e;const a=i<0?o:i;if((o<0||s<0||s>o||a<s)&&(0,n.a)(""),this.addAttribute(1),s===a)return;o=a-s;const h=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);const m=this.getAttributeStreamRef(0),l=new r.P;for(let e=0;e<o;e++)l.x=t[s+e].x,l.y=t[s+e].y,m.writePoint2D(2*(h+e),l);const u=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)u.write(h+e,t[s+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeNoCurves(t,e,s,n)}getGeometryType(){return n.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new Z({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,n.t)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===n.G.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):(0,n.t)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){(0,n.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,n.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}Z.type=n.G.enumMultiPoint;class Q extends B{constructor(t){super(t)}}class K extends Q{isTrue3D(){return!0}constructor(t){super(t)}}function $(t,e,s){J(e,t.getStartXY(),t.getEndXY(),s)}function J(t,e,s,n){(0,r.Q)(e,s,t,n)}function tt(t,e){return(0,r.q)(t.m_XStart,t.m_XEnd,e)}function et(t,e){return(0,r.q)(t.m_YStart,t.m_YEnd,e)}function st(t,e,s){e.value()<=.5?(0,r.ao)(2,p.constructPoint2D(t.getStartXY()),p.constructPoint2D(t.getEndXY()),e,s):(0,r.ap)(2,p.constructPoint2D(t.getStartXY()),p.constructPoint2D(t.getEndXY()),e,s)}function nt(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function it(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,r.c)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,r.c)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=(0,r.c)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function rt(t,e,s,n){let i=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(i++,!n))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(i++,2===i)return 2;if(!n)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:n&&i?0:function(t,e){const s=ht(t,e.m_XStart,e.m_YStart),n=ht(t,e.m_XEnd,e.m_YEnd);if(s<0&&n<0||s>0&&n>0)return!1;const i=ht(e,t.m_XStart,t.m_YStart),r=ht(e,t.m_XEnd,t.m_YEnd);return!(i<0&&r<0||i>0&&r>0)&&(ut(t)>ut(e)?lt(t,e):lt(e,t))}(t,e)?4:0}function ot(t,e,s,n,i,o,a,h){null!==n&&(0,r.w)(n,2,Number.NaN),null!==i&&(0,r.w)(i,2,Number.NaN),null!==s&&(0,r.av)(s,r.P,2);const m=function(t,e,s,n,i,o,a,h,m){const l=at(t,e.getStartXY(),a,!1),u=at(t,e.getEndXY(),a,!1),c=at(e,t.getStartXY(),a,!1),g=at(e,t.getEndXY(),a,!1);let d=0,_=0;if(!Number.isNaN(l)){let s=!1;h&&(0,r.a8)(l,0,1)&&t.getCoord2D(l).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(i&&(i[_]=l),o&&(o[_]=0),n&&n[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(u)){let s=!1;h&&(0,r.a8)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,s=!0),s||(2>_&&(i&&(i[_]=u),o&&(o[_]=1),n&&n[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(2!==_&&!Number.isNaN(c)&&!(0===l&&0===c||0===u&&1===c)){let s=!1;h&&(0,r.a8)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getStartXY())&&(d++,s=!0),s||(2>_&&(i&&(i[_]=0),o&&(o[_]=c),n&&n[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(2!==_&&!Number.isNaN(g)&&!(1===l&&0===g||1===u&&1===g)){let s=!1;h&&(0,r.a8)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(d++,s=!0),s||(2>_&&(i&&(i[_]=1),o&&(o[_]=g),n&&n[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return m&&(o=(0,r.c)(i,i=o)),2===_&&i&&i[0]>i[1]&&(i[1]=(0,r.c)(i[0],i[0]=i[1]),o&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),n&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),_;if(d>0)return 0;const p=function(t,e,s){const n=t.m_XEnd-t.m_XStart,i=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,h=o*i-n*a;if(0===h)return r.P.getNAN();const m=4*(0,r.H)()*(Math.abs(o*i)+Math.abs(n*a)),l=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,c=o*u-l*a,g=4*(0,r.H)()*(Math.abs(o*u)+Math.abs(l*a)),d=c/h,_=Math.abs(h),p=(g*_+m*Math.abs(c))/(h*h)+(0,r.H)()*Math.abs(d);if(d<-p||d>1+p)return r.P.getNAN();const f=n*u-l*i,x=f/h,P=(4*(0,r.H)()*(Math.abs(n*u)+Math.abs(l*i))*_+m*Math.abs(f))/(h*h)+(0,r.H)()*Math.abs(x);if(x<-P||x>1+P)return r.P.getNAN();let y=(0,r.s)(d,0,1),E=(0,r.s)(x,0,1);const C=r.P.getNAN();$(t,y,C);const v=r.P.getNAN();if($(e,E,v),!s||r.P.distance(C,v)>s){const n=r.P.getNAN();(0,r.Q)(C,v,.5,n),y=t.getClosestCoordinate(n,!1),E=e.getClosestCoordinate(n,!1);const i=r.P.getNAN();$(t,y,i);const o=r.P.getNAN();$(e,E,o),i.subThis(o);const a=i.length(),h=(t.absNorm()+e.absNorm())*(0,r.g)();if(a>Math.max(s,h))return r.P.getNAN()}return new r.P(y,E)}(t,e,a);return Number.isNaN(p.x)?0:(n&&(n[0]=t.getCoord2D(p.x)),i&&(i[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,s,n,i,o,a,h);return n&&(n.length=m),i&&(i.length=m),s&&(s.length=m),m}function at(t,e,s,n){const i=r.P.getNAN(),o=r.P.getNAN();let a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(i.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(i.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));const h=a?1:0,m=a?0:1,l=r.P.getNAN();l.setSub(e,i);let u=l.length(),c=3*u*(0,r.H)();if(u<=Math.max(s,c))return n&&0===u?Number.NaN:h;if(l.setSub(e,o),u=l.length(),c=3*u*(0,r.H)(),u<=Math.max(s,c))return n&&0===u?Number.NaN:m;l.setCoords(o.x-i.x,o.y-i.y);const g=l.length();if(g>0){const t=1/g;l.scale(t);const n=r.P.getNAN();n.setSub(e,i);const u=n.dotProduct(l),c=8*n.dotProductAbs(l)*(0,r.H)();l.leftPerpendicularThis();const d=n.dotProduct(l),_=8*n.dotProductAbs(l)*(0,r.H)(),p=Math.max(s,c);if(u<-p||u>g+p)return Number.NaN;const f=Math.max(s,_);if(Math.abs(d)<=f){let n=u*t;n=(0,r.s)(n,0,1);const l=r.P.getNAN();if(J(n,i,o,l),r.P.distance(l,e)<=s){if(n<.5){if(r.P.distance(l,i)<=s&&r.P.distance(e,i)<=s)return h}else if(r.P.distance(l,o)<=s&&r.P.distance(e,o)<=s)return m;return a?1-n:n}}}return Number.NaN}function ht(t,e,s){const n=r.P.getNAN();n.setCoords(e,s),n.subThis(t.getStartXY());const i=r.P.getNAN();i.setSub(t.getEndXY(),t.getStartXY());const o=i.crossProduct(n),a=4*(0,r.H)()*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return o>a?-1:o<-a?1:0}function mt(t,e,s,n){const i=n?t.m_XStart:t.m_XEnd,o=n?t.m_YStart:t.m_YEnd,a=r.P.getNAN();return a.x=e.getEndX()-i,a.y=e.getEndY()-o,!(s.dotProduct(a)>3*(0,r.H)()*s.dotProductAbs(a))||(a.x=e.getStartX()-i,a.y=e.getStartY()-o,s.dotProduct(a)<=3*(0,r.H)()*s.dotProductAbs(a))}function lt(t,e){const s=r.P.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!mt(t,e,s,!1)&&(s.negateThis(),!!mt(t,e,s,!0))}function ut(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}class ct{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&(0,n.q)("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&(0,n.q)("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,n.q)(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount()||(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,0))}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&(0,n.q)(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,n.p)(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,n.q)("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&(0,n.q)(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!=(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,n.q)(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&(0,n.q)(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class gt{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,n.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new gt;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0===--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,n.g)(this.uniqueUse())}setQuadTree(t){(0,n.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,n.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function dt(t){return!(t.isEmpty()||t.getGeometryType()!==n.G.enumPolyline&&t.getGeometryType()!==n.G.enumPolygon||t.getPointCount()<20)}function _t(t){return!(t.isEmpty()||t.getGeometryType()!==n.G.enumPolyline&&t.getGeometryType()!==n.G.enumPolygon||t.getPointCount()<20)}function pt(t,e){return t.readPoint2D(e+4)}function ft(t){const e=t.getGeometryType();return e===n.G.enumEllipticArc?10:e===n.G.enumBezier?4:e===n.G.enumRationalBezier2?5:e===n.G.enumBezier2?2:void(0,n.d)("")}function xt(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Pt(t,e,s,n){const i=t.getPathStart(e),o=t.getPathEnd(e);if(o-i<3)return;const a=2*i,h=r.P.getNAN();s.queryPoint2D(a,h);const m=h.x,l=h.y,u=r.P.getNAN();s.queryPoint2D(a+2,u);const c=r.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)s.queryPoint2D(t,c),n.pe((c.x-h.x)*(u.y-l)),h.setCoordsPoint2D(u),u.setCoordsPoint2D(c);n.pe((m-h.x)*(u.y-l))}function yt(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var Et=i.V;class Ct{static toSegType(t){let e=0;switch(t){case n.G.enumLine:e=1;break;case n.G.enumBezier:e=2;break;case n.G.enumEllipticArc:e=4;break;case n.G.enumRationalBezier2:e=8;break;case n.G.enumBezier2:e=16;break;default:(0,n.d)("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class vt extends j{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?n.G.enumPolygon:n.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,n.g)(this.m_bPolygon);const e=this.getPathIndexFromPointIndex(t),s=this.getPathStart(e);if(s===t)return;const i=this.getPathEnd(e);(t>=i||t<s)&&(0,n.a)("change_ring_start_point");for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),r=Et.getComponentCount(n);this.m_vertexAttributes.get(e).rotate(s*r,t*r,i*r)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(s,t,i),this.m_curveData.m_segmentParamIndex.rotate(s,t,i))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new i.D(t),s=new r.K(0),n=new r.K(0);if(0!==this.m_pointCount){const i=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new ct({parent:this});for(t.stripAttributes();t.nextPath();){n.reset();const r=t.getPathIndex();Pt(this,r,i,n),yt(0,t,n);const o=.5*n.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){n.reset(),Pt(this,r,i,n);const t=.5*n.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return(0,n.g)(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==e.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!vt.isNonLinearSegmentFlag(s))continue;const n=this.m_curveData.m_segmentParamIndex.read(t),i=e.m_curveData.m_segmentParamIndex.read(t),o=xt(s);for(let t=0;t<o;t++){const s=this.m_curveData.m_segmentParams.read(n+t),o=e.m_curveData.m_segmentParams.read(i+t);if(!(0,r.F)(s,o))return!1}}}return!0}equalsImplTol(t,e){const s=t,n=this.getPathCount();if(n!==s.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==s.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,n+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,n))return!1;if(!i)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=(0,i.$)(1,0),this.m_pathFlags=(0,i.a0)(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Ct),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new r.K(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new r.K(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return(0,n.g)(0),0}calculatePathLength3D(t,e){return(0,n.g)(0),0}copyTo(t){(0,n.h)(t.getGeometryType())||(0,n.a)(""),this!==t&&super.copyTo(t)}swap(t){(0,n.g)(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){const s=e.getXY();if(this.setXYCoordsWithCurves(t,s.x,s.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,s){if(this.hasNonLinearSegments()){const n=vt.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=n;const i=this.getPrevSegmentTypeFromPath(n,t),o=this.getNextSegmentType(t);if(1!==i||1!==o){let a=t-1;const h=new Vr;1!==i&&(this.isClosedPath(n)&&t===this.getPathStart(n)&&(a=this.getPathEnd(n)-1),this.getSegmentBuffer(a,h,!0));const m=new Vr;1!==o&&this.getSegmentBuffer(t,m,!0);const l=t+1;this.setXYCoordsNoCurves(t,e,s);const u=new r.P(e,s);return 1!==i&&(h.get().changeEndPoints2D(h.get().getStartXY(),u),this.replaceSegmentImpl(a,t,h.get(),!0)),void(1!==o&&(m.get().changeEndPoints2D(u,m.get().getEndXY()),this.replaceSegmentImpl(t,l,m.get(),!0)))}}this.setXYCoordsNoCurves(t,e,s)}setXYZWithCurves(t,e){this.hasNonLinearSegments()?(this.setXYCoordsWithCurves(t,e.x,e.y),this.setAttributeNoCurves(1,t,0,e.z)):this.setXYZNoCurves(t,e)}setAttributeWithCurves(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){const t=this.getXY(e);0===s?t.x=n:t.y=n,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,s,n)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,s){this.setXYCoordsWithCurves(t,e,s)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeWithCurves(t,e,s,n)}setAttributeWithCurvesFromArray(t,e,s,i){if(0===t&&this.hasNonLinearSegments()){i<2&&(0,n.q)("");const t=this.getXY(e);t.x=s[0],t.y=s[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,s,i)}setAttributeFromArray(t,e,s,n){this.setAttributeWithCurvesFromArray(t,e,s,n)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,n.a)("Multi_path_impl::add");for(let s=0,n=t.getPathCount();s<n;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addPathMultiPoint(t,e,s,n){s<0&&(s=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,s,n)}addSegmentsFromPath(t,e,s,i,r){if(this===t&&(0,n.a)("Multi_path_impl.add_segments_from_path"),r||0!==this.getPathCount()||(r=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||i<0||s+i>t.getSegmentCountPath(e))&&(0,n.q)("add_segments_from_path"),0===i)return;const o=t.getPathStart(e),a=t.isClosedPath(e)&&s+i===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let h=i;const m=o+s;let l=m+1;r&&(h++,l--),!r&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||(0,n.a)("add_segments_from_path: start point mismatch"));const u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange(),r){if(0===h)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const c=a?h-1:h;for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),n=Et.getComponentCount(s),i=t.m_description.getAttributeIndex(s);if(c>0){if(i<0||!t.m_vertexAttributes.get(i)){const t=Et.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(n*u,t,c*n,n*u),a&&this.m_vertexAttributes.get(e).insertRange(n*u+c*n,t,n,n*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(n*u,t.m_vertexAttributes.get(i),n*l,c*n,!0,n,n*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(n*(u+c),t.m_vertexAttributes.get(i),n*o,n,!0,n,n*(u+c))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,n=m;s<i;s++)e+=xt(t.m_curveData.m_segmentFlags.read(n)),n++;if(e>0){this.initSegmentData(e);let s=m,n=u-(r?0:1),o=0;for(let e=0;e<i;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(n,e),vt.isNonLinearSegmentFlag(e)){o++;let i=t.m_curveData.m_segmentParamIndex.read(s);const r=xt(e);this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentParams.read(i);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,i++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(n,-1);n++,s++}this.modifyCurveCounter(o)}}if(a){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,n=this.getXY(e),i=this.getXY(s);n.isEqualPoint2D(i)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&(0,n.a)("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),i=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const n=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!vt.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,n,!0),n.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,s)}if(r){const t=i?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const r=i?1:0;for(let t=0,n=this.m_description.getAttributeCount();t<n;t++)if(this.m_vertexAttributes.get(t)){const n=this.m_description.getSemantics(t),i=Et.getComponentCount(n);this.m_vertexAttributes.get(t).reverseRange(i*(s+r),i*(e-r),i)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,n.a)("");const s=this.getPathStart(t),i=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),n=Et.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(n*s,n*i,n*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=s,n=s+i;e<n;e++){const s=this.m_curveData.m_segmentFlags.read(e);vt.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(s,i,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(s,i,this.m_pointCount)}for(let s=t+1;s<=e;s++){const t=this.m_paths.read(s);this.m_paths.write(s-1,t-i)}if(this.m_pathFlags)for(let s=t+1;s<=e;s++){const t=this.m_pathFlags.read(s);this.m_pathFlags.write(s-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=i,this.m_reservedPointCount-=i,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,s,r){this===e&&(0,n.a)("Multi_path_impl::insert_path");const o=this.getPathCount();if(!r&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&(0,n.a)(""),t>o&&(0,n.a)(""),t<0&&(t=o),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const a=e.getPathStart(s),h=e.getPathSize(s);if(0===h)return this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,l=e.isClosedPath(s)&&!r?1:0;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const u=t<o?this.getPathStart(t):m;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),n=e.getDescription().getAttributeIndex(s),i=Et.getComponentCount(s);if(n>=0&&e.m_vertexAttributes.get(n))0!==l&&this.m_vertexAttributes.get(t).insertRangeFromStream(u*i,e.m_vertexAttributes.get(n),i*a,i,!0,i,i*m),this.m_vertexAttributes.get(t).insertRangeFromStream((u+l)*i,e.m_vertexAttributes.get(n),i*(a+l),i*(h-l),r,i,i*(m+l));else{const e=Et.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(u*i,e,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=e.getPathFlagsStreamRef().read(s);if(g&=-9,this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,s=0;for(let n=0;n<h;n++)s+=xt(e.m_curveData.m_segmentFlags.read(t)),t++;if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,i.a0)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,i.$)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,h,m),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,h,m)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=(0,i.a1)(s),t=a;let n=u,r=0;for(let s=0;s<h;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(vt.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(n,s),this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);const i=xt(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<i;t++){const t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}r++,this.incCurveType(s,1)}t++,n++}this.modifyCurveCounter(r)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,i,r){const o=this.getPathCount();(t>o||s<0)&&(0,n.a)(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+i),0===i&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,e,s,i,r,2*a);else{const t=Et.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*i,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Et.getComponentCount(e),n=Et.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,n,s*i,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+i)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,i,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,i,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,s,i,r){const o=e.getImpl(),a=this.getPathCount();(t>a||s<0)&&(0,n.a)("");const h=i<0?o.getPointCount()-s:i;if(h>o.getPointCount()&&(0,n.a)(""),s>=o.getPointCount()&&(0,n.a)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,l=s;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const u=t<a?this.getPathStart(t):m;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),n=Et.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(u*n,s,n*l,n*h,r,n,n*m)}else{const s=Et.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(u*n,s,n*h,n*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,e,s,i,r,o,a){if(this===s&&(0,n.a)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),i<0&&(i=s.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||i>=s.getPathCount()||o>s.getPathSize(i))&&(0,n.q)(""),!o)return;if(this.mergeVertexDescription(s.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=s.m_pathFlags.read(i);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+e;o<0&&(o=s.getPathSize(i));const u=s.getPathStart(i),c=u+o;for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const n=this.m_description.getSemantics(t),i=Et.getComponentCount(n),g=s.m_description.getAttributeIndex(n);if(g<0||!s.m_vertexAttributes.get(g)){const e=Et.getDefaultValue(n);this.m_vertexAttributes.get(t).insertRange(i*l,e,c*i,i*h);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(i*(m+e),s.m_vertexAttributes.get(g),i*(u+r),o*i,a,i,i*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,o,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,o,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,i,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||i<0)&&(0,n.q)(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,i,r,o,2*a);for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),n=Et.getComponentCount(s),i=Et.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange((h+e)*n,i,n*r,n*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,i,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const m=a.getPointCount();if((i<0||i>m)&&(0,n.q)(""),(r<0||i+r>m)&&(r=m-i),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&(0,n.q)(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===h){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const l=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const u=this.getPathStart(t),c=u+e,g=0+r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),n=Et.getComponentCount(s);if(a.getDescription().getAttributeIndex(s)<0){const e=Et.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(n*c,e,g*n,n*l);continue}const h=a.getAttributeStreamRef(s);this.m_vertexAttributes.get(t).insertRangeFromStream(n*(u+e),h,n*(0+i),r*n,o,n,n*l)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+e,1,r,l),this.m_curveData.m_segmentParamIndex.insertRange(u+e,-1,r,l),e>0&&this.isNonLinearSegment(u+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+e-1),-1),this.m_curveData.m_segmentFlags.write(u+e-1,1),this.m_curveData.m_segmentParamIndex.write(u+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&(0,n.q)(""),t===i&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Et.getComponentCount(e),n=Et.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,n,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=i;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&(0,n.q)(""),t===i&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByValNoCurves(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const n=this.m_description.getSemantics(t),i=Et.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(t).insertAttributes(i*a,s,n,i*r);else{const e=Et.getDefaultValue(n);this.m_vertexAttributes.get(t).insertRange(i*a,e,i,i*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=i;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&(0,n.q)("Multi_path.remove_point");const i=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,n.q)("Multi_path.remove_point");const o=i+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Et.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*o,s,s*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>i&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&i+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=s;e>=t+1;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNextSegmentType(t){return this.hasNonLinearSegments()?this.m_curveData.m_segmentFlags.read(t):1}getPrevSegmentTypeFromPath(t,e){if(!this.hasNonLinearSegments())return 1;const s=this.getPathStart(t);if(e>s)return this.m_curveData.m_segmentFlags.read(e-1);if(e===s){if(this.isClosedPath(t)){const e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}(0,n.d)("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),n=this.getPathEnd(t);s<n;s++)vt.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),n=vt.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=n,n}startPathCoords(t,e){this.startPathPoint(new i.P({x:t,y:e}))}startPath(t){this.startPathPoint(new i.P({pt:t}))}startPath3D(t){this.startPathPoint(new i.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new i.P({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&(0,n.a)("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const n=new i.P({vd:this.m_description});t.copyCommonAttributesTo(n),s=n}else s=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,i.$)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,i.a0)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,n=e+t;this.m_paths.write(s,n),this.resizeImpl(n),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoordsNoCurves(this.m_pointCount-1,t,e);else{const s=(0,i.W)(),n=new i.P({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});n.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,n)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=(0,i.N)(this.m_description,(0,i.O)()),s=(0,i.W)(),n=new i.P({vd:e,attribBuffer:s,initDefaultValues:!0});n.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,n),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new i.d(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=(0,i.W)(),s=new i.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,n.d)("");const e=this.getPathCount();if(t>e&&(0,n.a)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,n.d)("");const s=this.m_pointCount,i=this.getPathStart(t),r=this.getPathEnd(t);if(r-i!==0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),n=Et.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(n*r,this.m_vertexAttributes.get(t),n*i,n,!0,1,n*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,n.d)(""),t>this.getPathCount()&&(0,n.a)(""),this.m_pathFlags||(0,n.d)(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&(0,n.d)(""),this.isEmpty())return;this.m_pathFlags||(0,n.d)("");let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)this.isClosedPath(s)&&(this.getPathSize(s)>0?t++:this.m_pathFlags.clearBits(s,1));if(0===t)return;const s=this.hasNonLinearSegments();let r=0;const o=this.getPathCount(),a=this.m_description.getAttributeCount(),h=new Array(a);let m=null,l=null;for(let e=0;e<o;++e){const n=this.getPathStart(e),o=this.getPathSize(e),u=this.isClosedPath(e);if(o>0){const e=n+r;for(let s=0;s<a;s++)if(this.m_vertexAttributes.get(s)){const r=this.m_description.getSemantics(s),a=Et.getComponentCount(r);if(!h[s]){const e=a*(this.m_pointCount+t),n=(0,i.Z)(r,e);h[s]=n}h[s].writeRange(e*a,o*a,this.m_vertexAttributes.get(s),n*a,!0,1),u&&h[s].writeRange((e+o)*a,a,this.m_vertexAttributes.get(s),n*a,!0,1)}if(s){if(null===m){const e=this.m_pointCount+t;m=(0,i.a0)(e),l=(0,i.$)(e)}m.writeRange(e,o,this.m_curveData.m_segmentFlags,n,!0,1),l.writeRange(e,o,this.m_curveData.m_segmentParamIndex,n,!0,1),u&&(m.write(e+o,1),l.write(e+o,-1))}}this.m_paths.write(e,n+r),u&&(this.m_pathFlags.clearBits(e,1),++r)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,h[t]);s&&(this.m_curveData.m_segmentFlags=m,this.m_curveData.m_segmentParamIndex=l),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,n.a)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);1!==s&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,n.a)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,n.a)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),i=this.getPathEnd(t)-1;s.equals(this.getXY(i))||(0,n.a)("close_path_with_segment: start point mismatch");const r=e.getGeometryType();if(r===n.G.enumLine)return void this.closePathWithLine(t);{const t=ft(e);this.initSegmentData(t);const s=Ct.toSegType(r),n=this.m_curveData.m_segmentFlags.read(i);if(n!==s)this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==n?this.incCurveType(n,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(i);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(i,s)}}const s=this.m_pathFlags.read(t);1&s||this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const n=this.getXY(e),i=this.getXY(s);return n.isEqualPoint2D(i)}isClosedPathIn3D(t){return(0,n.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(vt.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof o.Envelope2D)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),n=(0,i.W)(),r=new i.P({vd:s,attribBuffer:n,initDefaultValues:!1});for(let s=0,n=4;s<n;s++){const i=e?n-s-1:s;t.queryCornerByVal(i,r),0===s?this.startPathPoint(r):this.lineToPoint(r)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,n.a)("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new i.P;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new i.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const r=(0,i.W)(),o=new i.P({vd:s,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===n.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),s||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,n.a)("add_segment: start point mismatch"),s&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=(0,i.W)(),e=new i.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const r=ft(t);this.initSegmentData(r),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=r;const h=Ct.toSegType(a);this.incCurveType(h,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,h)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,s,i){for(let e=t;e<s-1;e++)this.isClosedPath(e)&&(0,n.a)("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,e,s,i);if(0!==o)for(let n=1;n<r;n++){const r=this.m_description.getSemantics(n);this.interpolateAttributesSemanticsImpl(r,t,e,s,i,o)}}interpolateAttributesSemantics(t,e,s,i,r){if(0===t)return;this.hasAttribute(t)||(0,n.a)("does not have the given attribute"),2===Et.getInterpolation(t)&&(0,n.a)("angular interpolation");for(let t=e;t<i-1;t++)this.isClosedPath(t)&&(0,n.a)("cannot interpolate across closed paths");const o=this.calculateSubLength2D(e,s,i,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,s,i,r,o)}interpolateAttributesPath(t,e,s){const n=this.m_description.getAttributeCount();if(1===n)return;if(e===s)return;const i=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<n;r++){const n=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(n,t,e,s,i)}}interpolateAttributesSemanticsPath(t,e,s,i){if(0===t)return;this.hasAttribute(t)||(0,n.a)("does not have the given attribute"),2===Et.getInterpolation(t)&&(0,n.a)("angular interpolation");const r=this.calculatePathSubLength2D(e,s,i);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,e,s,i,r)}interpolateAttributesSemanticsImpl(t,e,s,n,i,o){const a=this.querySegmentIterator(),h=this.getPathStart(e)+s,m=this.getPathStart(n)+i,l=Et.getComponentCount(t),u=(0,r.d)(Et.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,u,l);const c=(0,r.d)(Et.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,l);const g=(0,r.d)(Et.maxComponentCount(),Number.NaN);(0,r.b)(g,u,0,0,l);let d=0;const _=Et.getDefaultValue(t),p=Et.getInterpolation(t);a.resetToVertex(h,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===m)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,l),a.previousSegment();do{const e=a.nextSegment();if(a.getEndPointIndex()===m)return;d+=e.calculateLength2D(),(0,r.a9)(p,u,c,g,0,l,d/o,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,l)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,o){(0,n.g)(0!==t);const a=this.querySegmentIterator(),h=Et.getInterpolation(t),m=this.getPathStart(e)+s,l=this.getPathStart(e)+i;if(l===m)return;const u=Et.getComponentCount(t),c=(0,r.d)(Et.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,u);const g=(0,r.d)(Et.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,l,g,u);const d=new r.K(0);a.resetToVertex(m,e),a.setCirculator(this.isClosedPath(e));const _=Et.getDefaultValue(t),p=(0,r.d)(Et.maxComponentCount(),Number.NaN);(0,r.b)(p,c,0,0,u);const f=0===o;let x=.5;do{const e=a.nextSegment();if(this.setAttributeFromArrayNoCurves(t,a.getStartPointIndex(),p,u),!f){const t=e.calculateLength2D();d.pe(t),x=d.getResult()/o}(0,r.a9)(h,c,g,p,0,u,x,_)}while(a.getEndPointIndex()!==l)}querySegment(t,e,s){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&(0,n.a)("get_segment"),this.getSegmentFromPath(i,r,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const e=this.getPathIndexFromPointIndex(t),s=t-this.getPathStart(e);return s>=this.getSegmentCountPath(e)&&(0,n.a)("get_segment"),this.getSegmentTypeFromPath(e,s)}getSegmentFromPath(t,e,s,r){const o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef();let h=1;switch(a&&(h=31&a.read(o)),h){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:(0,n.d)("")}const m=s.get();let l,u=null;if(r?(u=(0,i.K)(),m.assignVertexDescription(u)):m.assignVertexDescription(this.m_description),l=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,I(m,this.getXY(o)),w(m,this.getXY(l)),!r)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Et.getComponentCount(e);for(let t=0;t<s;t++){const s=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,s);const n=this.getAttributeAsDbl(e,l,t);m.setEndAttribute(e,t,n)}}if(vt.isNonLinearSegmentFlag(h)){const t=this.m_curveData.m_segmentParamIndex.read(o);m.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);pt(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,e,s,i=!1){const o={iSegment:-1},a=i?o:{tSegment:0};if(s.setEmpty(),this.isEmpty())return o;if((t<0||t>=this.getPathCount())&&(0,n.a)("query_point_along_path"),e<0)return o;const h=this.getPathSize(t);if(0===h)return o;if(1===h)return this.getPointByVal(this.getPathStart(t),s),a.tSegment=0,o.iSegment=this.getPathStart(t),o;const m=this.querySegmentIteratorAtVertex(this.getPathStart(t)),l=new r.K(0);for(;m.hasNextSegment();){const t=m.nextSegment(),n=t.calculateLength2D(),i=l.getResult();if(l.add(n),l.getResult()>=e){let r=e-i;r>n&&(r=n);const h=t.lengthToT(r);return t.queryCoord(h,s),a.tSegment=h,o.iSegment=m.getStartPointIndex(),o}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,s,i,o,a){{let t=0;for(let r=0;r<e;++r)i&&i[r].setEmpty(),o&&(o[r]=-1),a&&(a[r]=0),t>s[r]&&(0,n.a)("query_points_along"),t=s[r]}const h=this.getPathSize(t);if(0===e||0===h)return 0;if(1===h){const e=this.getPathStart(t);return i&&this.getPointByVal(e,i[0]),a&&(a[0]=0),o&&(o[0]=e),1}const m=this.getPathStart(t),l=new r.K(0),u=this.querySegmentIteratorAtVertex(m);let c=0,g=0,d=s[c];for(;u.hasNextSegment();){const t=u.nextSegment(),n=t.calculateLength2D(),r=l.getResult();for(l.add(n);l.getResult()>=d;){let h=d-r;h>n&&(h=n);const m=t.lengthToT(h);if(i&&t.queryCoord(m,i[g]),a&&(a[g]=m),o&&(o[g]=u.getStartPointIndex()),g++,c++,d=s[c],c===e)return g}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;i&&this.getPointByVal(e,i[g]),a&&(a[g]=s),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;i&&this.getPointByVal(e+1,i[g]),a&&(a[g]=s),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,s,i,o){{let r=0;for(let a=0;a<t;++a)s&&s[a].setEmpty(),i&&(i[a]=-1),o&&(o[a]=0),r>e[a]&&(0,n.a)("query_points_along"),r=e[a]}if(0===t)return 0;const a=new r.K(0),h=this.querySegmentIterator();let m=-1,l=0,u=0,c=e[l];for(;h.nextPath();)for(;h.hasNextSegment();){m=h.getPathIndex();const n=h.nextSegment(),r=n.calculateLength2D(),g=a.getResult();for(a.add(r);a.getResult()>=c;){let a=c-g;a>r&&(a=r);const m=n.lengthToT(a);if(s&&n.queryCoord(m,s[u]),o&&(o[u]=m),i&&(i[u]=h.getStartPointIndex()),u++,l++,c=e[l],l===t)return u}}if(m<0)return 0;if(this.isClosedPath(m)){const t=this.getPathStart(m),e=0;s&&this.getPointByVal(t,s[u]),o&&(o[u]=e),i&&(i[u]=t),u++}else if(this.getPathSize(m)>1){const t=this.getPathEnd(m)-2,e=1;s&&this.getPointByVal(t+1,s[u]),o&&(o[u]=e),i&&(i[u]=t),u++}return u}querySegmentIterator(){return new ct({parent:this})}querySegmentIteratorAtVertex(t){return new ct({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,s){if(e instanceof i.E&&(0,n.g)(0,"not implemented for Envelope"),e instanceof i.q&&(0,n.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,n.a)(""),this.isEmpty())return void e.setEmpty();const r=this.getAttributeStreamRef(0),a=o.Envelope2D.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),s=2*this.getPathEnd(t);e<s;){const t=s-e;(0,n.g)(!(1&t)),a.mergePointsInterleaved(r,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){const i=this.querySegmentIterator();if(i.resetToPath(t),i.nextPath())for(;i.hasNextSegment();){const t=i.nextCurve();if(!t)break;{const n=o.Envelope2D.constructEmpty();s?t.queryEnvelope(n):t.queryLooseEnvelope(n),e.mergeEnvelope2D(n)}}else(0,n.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=xt(4)*this.m_curveData.m_arcCount+xt(2)*this.m_curveData.m_bezierCount+xt(8)*this.m_curveData.m_rbezier2Count+xt(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,s=this.getPointCount();e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);vt.isNonLinearSegmentFlag(s)&&(t+=xt(s))}const e=(0,i.a1)(t);let s=0;for(let t=0,n=this.getPointCount();t<n;t++){const n=this.m_curveData.m_segmentFlags.read(t);if(vt.isNonLinearSegmentFlag(n)){let i=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,s);const r=xt(n);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(i)),s++,i++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,n.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,i.$)(0),this.m_pathFlags=(0,i.a0)(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=(0,i.$)(0),this.m_pathFlags=(0,i.a0)(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new St(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,n){this.m_curveData||(this.m_curveData=new Ct),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=n}static getPathIndexFromPointIndexImpl(t,e,s,i){if(i>=0&&i<e){if(s>=t.read(i)){if(s<t.read(i+1))return i;i++}else i--;if(i>=0&&i<e&&s>=t.read(i)&&s<t.read(i+1))return i}if(e<5){for(let n=0;n<e;n++)if(s<t.read(n+1))return n;(0,n.n)("")}let r=0,o=e-1;for(;o>r;){const e=r+(o-r>>1);if(s<t.read(e))o=e-1;else{if(!(s>=t.read(e+1)))return e;r=e+1}}return r}getHighestPointIndex(t){(0,n.g)(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),i=this.getPathStart(t);let o=-1;const a=new r.P;a.y=Number.NEGATIVE_INFINITY,a.x=Number.NEGATIVE_INFINITY;for(let t=i+0;t<s;t++){const s=e.readPoint2D(2*t);-1===a.compare(s)&&(o=t,a.setCoordsPoint2D(s))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,n.a)("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let n,i;return e<0?(n=0,i=this.m_pointCount):(n=this.getPathStart(e),i=this.getPathEnd(e)),s.applyTransformation(t,2*n,i-n),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,o=this.getPathCount();let a=e<0?0:e;do{const n=this.getPathStart(a),o=this.getPathEnd(a),h=this.isClosedPath(a),m=s.readPoint2D(2*n);if(!this.hasNonLinearSegmentsPath(a)){s.applyTransformation(t,2*n,o-n);continue}const l=r.P.getNAN();for(let e=n;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){const r=h&&e+1===o;r&&s.writePoint2D(2*n,m),this.getSegmentBuffer(e,i,!0),i.get().applyTransformation(t);const a=this.m_curveData.m_segmentParamIndex.read(e);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),s.writePoint2D(2*e,i.get().getStartXY()),r&&s.writePoint2D(2*n,i.get().getEndXY());continue}const r=2*e;s.queryPoint2D(r,l),t.transformInPlace(l),s.writePoint2D(r,l)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,i){const r=this.getPathStart(t)+e,o=this.getPathStart(s)+i;(o<r||r<0||o>this.getPointCount()-1)&&(0,n.p)("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(r,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===o)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return h}calculatePathSubLength2D(t,e,s){const i=this.getPathStart(t)+e,r=this.getPathStart(t)+s;(i<0||r>this.getPointCount()-1)&&(0,n.p)("");const o=this.querySegmentIterator();if(i>r&&(this.isClosedPath(t)||(0,n.a)("cannot iterate across an open path"),o.setCirculator(!0)),i===r)return 0;let a=0,h=0;o.resetToVertex(i,t);do{h+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=o.Envelope2D.constructEmpty(),n=this.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const i=n.nextCurve();if(!i)break;t?i.queryEnvelope(s):i.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&(0,n.a)("Multi_path_impl::add");let s=this.getPathCount();for(let n=0,i=t.getPathCount();n<i;n++)this.addPath(t,n,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&(0,n.a)("getSegmentBuffer"),this.getSegmentFromPath(i,r,e,s)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,i=this.getSegmentFlagsStreamRef();let r=1;switch(i&&(r=31&i.read(s)),r){case 1:return n.G.enumLine;case 2:return n.G.enumBezier;case 4:return n.G.enumEllipticArc;case 8:return n.G.enumRationalBezier2;case 16:return n.G.enumBezier2;default:(0,n.d)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),i=this.getPathEnd(e),o=i-s;for(let e=s;e<i;e++){const i=31&this.m_curveData.m_segmentFlags.read(e);if(1===i)continue;2!==i&&(0,n.t)("ensure_xy_monotone_segments");const a=(e-s+1)%o+s,h=this.m_curveData.m_segmentParamIndex.read(e),m=(0,r.m)(r.P,4);m[0]=this.getXY(e),m[3]=this.getXY(a),m[1].x=this.m_curveData.m_segmentParams.read(h),m[1].y=this.m_curveData.m_segmentParams.read(h+1),m[2].x=this.m_curveData.m_segmentParams.read(h+2),m[2].y=this.m_curveData.m_segmentParams.read(h+3),y(m)&&(t=!0,this.m_curveData.m_segmentParams.write(h,m[1].x),this.m_curveData.m_segmentParams.write(h+1,m[1].y),this.m_curveData.m_segmentParams.write(h+2,m[2].x),this.m_curveData.m_segmentParams.write(h+3,m[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=(0,i.t)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=(0,i.a2)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(vt.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Ct),vt.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Ct),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Ct);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,i.a0)(e,1),this.m_curveData.m_segmentParamIndex=(0,i.$)(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,i.a1)(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Ct),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let n=0;n<t;n++){const t=this.m_cachedRingAreas2D.read(n);0===s&&(s=(0,r.e)(t)),t*s>0||0===s?e.setBits(n,8):e.clearBits(n,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,s){(t<0||t>=this.getPointCount())&&(0,n.a)("Multi_path_impl.replace_segment"),(0,n.g)(e.isCurve());const i=this.getPathIndexFromPointIndex(t),r=this.getPathStart(i),o=(t-r+1)%this.getPathSize(i)+r;{const s=this.getXY(t),i=this.getXY(o),r=!s.isEqualPoint2D(e.getStartXY())||!i.isEqualPoint2D(e.getEndXY());(0,n.g)(!r)}this.replaceSegmentImpl(t,o,e,s)}replaceSegmentImpl(t,e,s,o){const a=s.getDescription();this.mergeVertexDescription(a);const h=(0,r.d)(32,Number.NaN),m=new i.P({vd:a,attribBuffer:h,initDefaultValues:!1}),l=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=xt(l),c=ft(s);let g,d=!1;u>=c?((0,n.g)(null!==this.m_curveData),d=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(c),d=!1,g=this.m_curveData.m_curveParamWritePoint);const _=s.getGeometryType(),p=Ct.toSegType(_);o||(s.queryStart(m),this.setPointByValNoCurves(t,m),s.queryEnd(m),this.setPointByValNoCurves(e,m)),this.m_curveData.m_segmentParamIndex.write(t,1!==p?g:-1),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&s.writeInBufferStream(this.m_curveData.m_segmentParams,g),d||(this.m_curveData.m_curveParamWritePoint+=c),l!==p&&(this.incCurveType(l,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===l?1:-1))}setAttributeImpl(t,e,s){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,n.a)("");const t=new a.T,i=0===e?s:0,r=0===e?0:1;t.setShiftCoords(i,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,s)}}vt.st_totalCurveCount=0;class St{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o.Envelope2D(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=o.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class bt extends vt{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Vr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Vr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Vr):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Vr,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Vr,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,n.d)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Vr)}getBoundary(){return wt(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return bt.type}getDimension(){return 1}createInstance(){return new bt({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}bt.type=n.G.enumPolyline;var It=n.G;function Dt(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===It.enumPolygon)return 0!==t.calculateArea2D();if(s===It.enumPolyline)return Tt(t.getImpl(),0,!0).bNotEmpty;if(s===It.enumEnvelope)return!0;if((0,n.f)(s))return!!t.isClosed();if((0,n.e)(s))return!1;if(s===It.enumGeometryCollection){const s=t;for(let t=0,n=s.getGeometryCount();t<n;t++)if(Dt(s.getGeometry(t),e))return!0;return!1}(0,n.t)("")}function wt(t,e){const s=t.getGeometryType();if(s===It.enumPolygon){const e=new bt({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===It.enumPolyline)return Tt(t.getImpl(),0,!1).boundary;if(s===It.enumEnvelope){const e=new bt({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,n.f)(s)){const e=new Z({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new i.P;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===It.enumGeometryCollection){const s=t;let n=null;for(let i=0,r=s.getGeometryCount();i<r;i++){const r=wt(s.getGeometry(i),e);if(null!==r){null===n&&(n=t.createInstance());const e=r;n.addGeometry(e)}}return n}if((0,n.e)(s))return new i.P({vd:t.getDescription()});(0,n.t)("")}function Tt(t,e,s){const n=!1,o=t;let a=null;if(s||(a=new Z({vd:o.getDescription()})),!o.isEmpty()){const t=new i.A(0);for(let e=0,s=o.getPathCount();e<s;e++)if(o.getPathSize(e)>0&&!o.isClosedPathInXYPlane(e)){const s=o.getPathStart(e);t.add(s);const n=o.getPathEnd(e)-1;t.add(n)}if(t.size()>0){const e=new i.B,n=o.getAttributeStreamRef(0),h={userSort(t,e,s){const i=r.P.getNAN(),o=r.P.getNAN();s.sort(t,e,(t,e)=>(n.queryPoint2D(2*t,i),n.queryPoint2D(2*e,o),i.compare(o)))},getValue:t=>n.read(2*t+1)};e.sort(t,0,t.size(),h);let m=n.readPoint2D(2*t.read(0)),l=0,u=1;const c=new i.P;for(let e=1,i=t.size();e<i;e++){const i=n.readPoint2D(2*t.read(e));if(i.isEqualPoint2D(m))t.read(l)>t.read(e)?(t.write(l,(0,r.j)()),l=e):t.write(e,(0,r.j)()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new Z({})}}else t.write(l,(0,r.j)());m=i,l=e,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new Z({})}}else t.write(l,(0,r.j)());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==(0,r.j)();e++)o.getPointByVal(t.read(e),c),a.add(c)}}}return s?{bNotEmpty:n,boundary:new Z({})}:{bNotEmpty:n,boundary:a}}function Nt(t,e,s,i){const o=4*(0,r.H)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,r.H)();if(1===t.getMaxDerivative()){(0,n.g)(s>0);const a=Mt(t,0,e,(0,r.H)(),o);return i[0]=a.root,a.cRoots}let h,m=[];const l=new r.E(e.vmin-o,e.vmax+o);m.push(new r.P(l.vmin,l.vmax));let u=0;for(let n=t.getMaxDerivative()-1;n>=0;n--){h=m,m=[];for(let l=0,c=h.length;l<c;l++){if(h[l][0]<h[l][1]){let c,g,d;if(n===t.getMaxDerivative()-1?({root:c,funcAtRoot:g,cRoots:d}=Mt(t,n,r.E.construct(h[l][0],h[l][1]),a,.5*o)):({root:c,funcAtRoot:g,cRoots:d}=Ft(t,n,r.E.construct(h[l][0],h[l][1]),0,.5*o)),1===d){if(0===n)u<s&&(h[l][0]<=e.vmin&&h[l][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),h[l][0]<=e.vmax&&h[l][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),i[u]=e.snapClip(c),u>0?i[u]-i[u-1]>o&&u++:u++);else{const t=r.P.getNAN();t[0]=h[l][0],t[1]=c,m.push(t);const e=r.P.getNAN();e[0]=c,e[1]=h[l][1],m.push(e)}continue}}m.push(h[l])}}return u}function At(t,e,s,n,i,o){const a=(0,r.m)(r.X,2),h=Yt(new r.X(t),new r.X(e),new r.X(s),n,i,a);return o[0]=a[0].value(),o[1]=a[1].value(),h}function Gt(t,e,s,n,i,o,a){const h=(0,r.m)(r.X,3),m=Rt(new r.X(t),new r.X(e),new r.X(s),new r.X(n),i,o,h);return a[0]=h[0].value(),a[1]=h[1].value(),a[2]=h[2].value(),m}function qt(t,e,s,n,i,o,a,h){return function(t,e,s,n,i,o,a,h){const m=(0,r.d)(s*s,Number.NaN);m.fill(0),(0,r.b)(h,n,0,0,s);const l=(0,r.d)(s,Number.NaN),u=(0,r.d)(s,Number.NaN),c=(0,r.d)(s,Number.NaN);let g=t(h,s,e);let d=0;for(d=0;d<100;d++){const n=g;for(let t=0;t<s;++t)u[t]=h[t];if(d%s===0){m.fill(0);for(let t=0;t<s;t++)m[t*s+t]=1}let a=0,_=0;for(let n=0;n<s;++n){for(let t=0;t<s;++t)l[t]=m[n*s+t];const r=g;g=Xt(t,e,h,l,i,o,s);const u=r-g;u>a&&(_=n,a=u)}for(let t=0;t<s;t++)l[t]=h[t]-u[t],c[t]=h[t]+(h[t]-u[t]);const p=t(c,s,e);if(p<n&&2*(n-2*g+p)*(0,r.a)(n-g-a)<(0,r.a)(n-p)*a){g=Xt(t,e,h,l,i,o,s);for(let t=0;t<s;++t)m[_*s+t]=m[(s-1)*s+t],m[(s-1)*s+t]=l[t]}if(n<=g)return t(h,s,e)}return g}(t,e,s,n,i,o,0,h)}function Mt(t,e,s,i,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=s.vmax,l=0,u=Number.MAX_VALUE,c=t.getValue(e,h),g=t.getValue(e,m),d=0,_=0,p=0;if(c>=0&&g>=0||c<=0&&g<=0)return Math.abs(c)<Math.abs(g)?(a.funcAtRoot=c,a.root=h,a.cRoots=0===c?1:0,a):(a.funcAtRoot=g,a.root=m,a.cRoots=0===g?1:0,a);Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),l=h,d=c;let f=!0,x=0;for(;0!==g&&Math.abs(h-m)>i*Math.abs(m)+o;x++){let s=x>64;if(!s){_=c!==d&&g!==d?h*g*d/((c-g)*(c-d))+m*c*d/((g-c)*(g-d))+l*c*g/((d-c)*(d-g)):m-g*(m-h)/(g-c);const t=(3*h+m)/4;if(s=!(_>t&&_<m||_>m&&_<t),!s){const t=i*Math.abs(m)+o;if(f){const e=Math.abs(m-l);s=Math.abs(_-m)>=.5*e||e<t}else{const e=Math.abs(l-u);s=Math.abs(_-m)>=.5*e||e<t}}}if(s?(_=(h+m)/2,f=!0):f=!1,p=t.getValue(e,_),0===p)return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!s){const s=h-_,n=_-m;if(Math.abs(s)>10*Math.abs(n)){let s=m+3*n;for(let n=0;n<2;n++){const n=t.getValue(e,s);(0,r.e)(c)*(0,r.e)(n)>0?(h=s,c=n):s=(0,r.q)(h,m,.75)}}else if(Math.abs(n)>10*Math.abs(s)){let n=h-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,n);(0,r.e)(g)*(0,r.e)(s)>0?(m=n,g=s):n=(0,r.q)(h,m,.25)}}}u=l,l=m,d=g,(0,r.e)(c)*(0,r.e)(p)<0?(m=_,g=p):(h=_,c=p),Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),128===x&&(0,n.d)("Root_finder iterations exceeded")}return a.root=m,a.funcAtRoot=g,a.cRoots=1,a}function Ft(t,e,s,i,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=t.getValue(e,h),l=s.vmax,u=t.getValue(e,l);if(m>=0&&u>=0||m<=0&&u<=0)return Math.abs(m)<Math.abs(u)?(a.funcAtRoot=m,a.root=h,a.cRoots=0===m?1:0,a):(a.funcAtRoot=u,a.root=l,a.cRoots=0===u?1:0,a);u<0&&(u=(0,r.c)(m,m=u),l=(0,r.c)(h,h=l));let c=.5*(h+l),g=Math.abs(l-h),d=g,_=t.getValue(e,c),p=t.getValue(e+1,c),f=4,x=1,P=0,y=0,E=1,C=0;for(;++C<100;){let s;C>32||0===p||2===E&&P>1||1===E&&f<4?(E=1,x>1&&x--):(E=2,y>1&&Math.abs(2*_)>Math.abs(g*p)&&x++),g=d;let n=!1;if(1===E)do{if(y>2){const t=16*Math.abs(g);if(.5*Math.abs(h-l)>t){const e=Math.min(h,l),n=Math.max(h,l);if(c===e){s=c,c=e+t,d=c-s;break}if(c===n){s=c,c=n-t,d=c-s;break}}}d=.5*(l-h),s=c,c=h+d,n=h===c||l===c}while(0);else for(;;){d=x*_/p,s=c,c-=d,n=c===s;const t=Math.min(h,l),e=Math.max(h,l);if(c<t){if(x>1){c=s,x--;continue}d=s-t,c=t}else if(c>e){if(x>1){c=s,x--;continue}d=s-e,c=e}break}if(n||Math.abs(d)<o){s!==c&&(_=t.getValue(e,c));break}_=t.getValue(e,c),p=t.getValue(e+1,c);const i=h,r=l;_<0?(m=_,h=c):(u=_,l=c),2===E&&(h===i&&l===r||y>1&&Math.abs(d)>=.5001*Math.abs(g))?P++:P=0,1===E?(f++,y=0):(f=0,y++)}return 100===C&&(0,n.d)("Root_finder iterations exceeded"),a.root=c,a.funcAtRoot=_,a.cRoots=1,a}function Xt(t,e,s,n,i,o,a){const h=n.slice(0,a);let m=0;for(let t=0;t<a;t++)m+=n[t]*n[t];if(m=Math.sqrt(m),m>0)for(let t=0;t<a;t++)h[t]/=m;let l=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=(0,r.d)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{const s=Math.abs(h[t]),n=Math.abs(h[e]);return s<n?-1:s>n?1:0});for(let e=0;e<a;e++){const n=t[e];if(0===h[n])continue;let a=(i[n]-s[n])/h[n],m=(o[n]-s[n])/h[n];m<a&&(m=(0,r.c)(a,a=m)),a>l&&(l=a),m<u&&(u=m)}}let c=0;const g=(Math.abs(l)+Math.abs(u))*(0,r.H)()*100,d=(0,r.d)(a,Number.NaN),_=h.slice();function p(n,i){for(let t=0,e=a;t<e;t++)d[t]=s[t]+n*_[t];return t(d,a,e)}g>0&&(c=function(t,e,s,n,i,o){return function(t,e,s,n,i,o){const a=(0,r.a1)();let h=n,m=t(h,e),l=s,u=i,c=t(l,e),g=t(u,e);m>c&&(m=c,h=l),m>g&&(m=g,h=u);let d=l,_=u,p=c,f=g;p>f&&(p=(0,r.c)(f,f=p),_=(0,r.c)(d,d=_));let x=h-d,P=d-_;const y=.5*Math.min(o,u-l),E=2*y;let C,v=0;for(C=0;C<100&&!(u-l<=E);++C){const s=l+.5*(u-l);let n=v>0;if(!n&&Math.abs(P)<=y&&(n=!0,v=3),!n){const t=h-d,e=h-_,s=t*(m-f);let i=e*(m-p),r=e*i-t*s;i=2*(i-s),i>0&&(r=-r),i=Math.abs(i),0===i||Math.abs(r)>=Math.abs(i*P/2)||r<=i*(l-h)||r>=i*(u-h)?(n=!0,v=3):(P=x,x=r/i)}n&&(P=h>=s?l-h:u-h,x=a*P,v--);let i=h+x;i<l+y?i=l+y:i>u-y&&(i=u-y);const r=t(i,e);r<m?(i>=h?(l=h,c=m):(u=h,g=m),_=d,d=h,h=i,f=p,p=m,m=r):(i<h?(l=i,c=r):(u=i,g=r),r<=p||d===h?(_=d,d=i,f=p,p=r):(r<=f||_===h||_===d)&&(_=i,f=r))}return h}(t,e,s,n,i,o)}(p,null,l,0,u,g));const f=p(c);for(let t=0,e=a;t<e;t++)s[t]=(0,r.s)(d[t],i[t],o[t]);return f}function Vt(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(n.value())?1:0)}function Yt(t,e,s,n,i,o){if(0===t.value())return i?(o[0].set(1),n.containsCoordinate(o[0].value())?1:0):Vt(e,s,n,o[0]);if(i){let e=2;return o[0].set(1),o[1].setE(s).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),n.containsCoordinate(o[1].value())||(e=1),n.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),e}const a=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(r.aq));if(a.lt(r.U))return 0;const h=new r.X(e.value()>=0?1:-1),m=a.clone().sqrtThis(),l=new r.X(-.5).mulThisE(e.clone().addThisE(h.clone().mulThisE(m)));let u=0;o[0].setE(l.divE(t));const c=new r.X(o[0].value()),g=new r.X(t.value()).mulE(c).addE(new r.X(e.value()).mulE(c).addE(new r.X(s.value())));return g.isZero()||Ot(o[0],t,e,s,o[0]),n.containsCoordinate(o[0].value())&&u++,0!==m.value()&&0!==l.value()?(o[u].assign(s.divE(l)),c.set(o[u].value()),g.assign(new r.X(t.value()).mulE(c).addE(new r.X(e.value()).mulE(c).addE(new r.X(s.value())))),g.isZero()||Ot(o[u],t,e,s,o[u]),n.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),u):u}function Rt(t,e,s,i,o,a,h){if(0===t.value())return Yt(e,s,i,o,a,h);if(a){let s=1;h[0].set(1);const n=h.slice(s),a=Yt(t,e.addE(t),i.negate(),o,!1,n);if(a>0){s+=a;for(let t=1;t<s;t++)h[t].eq(r.a6)&&(h[s-1]=(0,r.c)(h[t],h[t]=h[s-1]),s--)}const m=h.slice(0,s);m.sort((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);for(let t=0;t<s;++t)h[t]=m[t];return s}return function(t,e,s,i,o,a){const h=(0,r.m)(r.X,3);let m=0;const l=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(l.value())&&(h[0].setE(l),m=1);const u=(0,r.m)(r.X,2),c=Yt(t.mul(3),e.mul(2),s,o,!1,u);if(c<0)return i.isZero()?-1:0;for(let t=0;t<c;t++)o.containsCoordinate(u[t].value())&&h[m++].setE(u[t]);(0,r.aa)(h,0,m,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const g=(0,r.m)(r.X,5);g[0].set(o.vmin);for(let t=0;t<m;t++)g[1+t].setE(h[t]);g[1+m].set(o.vmax);const d=m+2;let _=1,p=0;{const n=g[0].clone();if(t.clone().mulThisE(n).addThisE(e).mulThisE(n).addThisE(s).mulThisE(n).addThisE(i).isZero()){const r=Lt(t,e,s,i);n.setError(r.estimateError(n.value())),a[p]=n,p++,_++}}for(let r=_;r<d;r++){const h=g[r].clone(),m=t.clone().mulThisE(h).addThisE(e).mulThisE(h).addThisE(s).mulThisE(h).addThisE(i).isZero();if(m||!g[r].eq(g[r-1])){if(m||zt(g[r-1].value(),g[r].value(),g[r-1].clone().addThisE(g[r]).divThisByPower2(2),t,e,s,i,h)){if(p>0&&h.eq(a[p-1]))continue;if(p>=3&&(0,n.d)("cubic_polynomial_solver_too_many_roots"),m){const n=Lt(t,e,s,i);h.setError(n.estimateError(h.value()))}a[p]=h,p++}if(g[r].value()===o.vmax)break;m&&r++}}return p}(t,e,s,i,o,h)}function kt(t,e,s,i,o,a){return(a<e||e<0)&&(0,n.a)("nth_degree_real_roots"),function(t,e,s,n,i){const o=new Bt(t,e,s,(0,r.H)());let a=0;if(2===o.truePower)a=Yt(t[2],t[1],t[0],s,n,i);else if(1===o.truePower)a=Vt(t[1],t[0],s,i[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=Nt(o,s,e,t);for(let e=0;e<a;e++)i[e].set(t[e])}}for(let t=0;t<a;t++)i[t].setError(o.getError(i[t].value()));return a}(t,e,s,i,o)}function Lt(t,e,s,n){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:n.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),n=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(n.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(n.value())}}}class Bt{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let s=0,n=this.truePower-t;s<=n;++s){e.push(this.coefs[s+t].clone());let n=s+t,i=n--;for(let e=1;e<t;e++)i*=n--;e[s].mulThis(i)}this.curCoefs=e}constructor(t,e,s,n){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const n=new r.K(0);let i=1;for(let r=0,o=this.truePower-t;r<=o;++r)n.pe(i*s[r].value()),i*=e;return n.getResult()}getError(t){const e=Math.abs(t),s=new r.K(0),n=new r.X(1),i=new r.X(0);for(let t=0,r=this.power;t<=r;++t)i.addThisE(this.coefs[t].mulE(n)),s.pe(n.value()*this.coefs[t].eps()),n.mulThis(e);s.pe(i.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);const n=new r.X(1),i=new r.X(0);for(let s=0,r=this.truePower-e;s<=r;++s)i.addThisE(this.curCoefs[s].mulE(n)),n.mulThis(t);if(!i.isZero())return Math.pow(o*s.getResult()/Math.abs(i.value()),1/e)}return 0}}function Ht(t,e,s,n,i,o){let a=t,h=e,m=h-a;if(!o){let s=n.calcF(t).value(),i=n.calcF(e).value();if((s>0||s>i)&&(h=(0,r.c)(a,a=h),i=(0,r.c)(s,s=i)),s>=0||i<=0)return!1}let l,u=!1,c=s,g=0;for(;g<100;g++){const t=n.calcF(c);if(l=n.calcDF(c),l.isZero())return!1;if(!t.value()||g>3&&t.isZero()){u=!0;break}o||(t.value()<0?a=c:h=c);const e=t.value()/l.value(),s=c-e;o||(s>=a&&s<=h||s>=h&&s<=a)&&Math.abs(e)<=.5*m?(c=s,m=Math.abs(e)):(m=Math.abs(.5*(h-a)),c=.5*(a+h))}return!!u&&(i.set(c,n.estimateError(c)),!0)}function zt(t,e,s,n,i,r,o,a){return Ht(t,e,s.value(),Lt(n,i,r,o),a,!1)}class Ut{constructor(t,e,s){this.coefs=(0,r.m)(r.X,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new r.X(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new r.X(t);return r.X.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),n=new r.X(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(n.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(n.value())}}function Ot(t,e,s,n,i){return Ht(0,0,t.value(),new Ut(e,s,n),i,!0)}var Wt=i.V;class jt extends Q{constructor(t){return void 0===t||(0,r.ae)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&(0,n.a)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,n.t)("unexpected constructor param"))}getBoundary(){return wt(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,n,1),Nn(this)}constructWeights(t,e,s,n,i,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,n,i,r),Nn(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Nn(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return n.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.Envelope2D){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Hn(this);if(null!==e){const s=new r.P;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[],s=(0,r.m)(r.P,3);this.queryControlPoints(s),Gn(s,this.m_weights,e);const n=new r.P;for(const s of e)this.queryCoord2D(s,n),t.mergeNe(n)}}}applyTransformation(t){if(t instanceof a.T){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new jt({vd:this.m_description})}calculateLength2D(){return qn(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp):r.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),function(t,e,s,n){if(0===s.value())return void n.setE(t[0]);if(1===s.value())return void n.setE(t[2]);const i=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],h=new r.X,m=new r.X,l=new r.X;if(s.value()<=.5){const t=(0,r.aw)(i[0],i[1],s),e=(0,r.aw)(i[1],i[2],s);h.setE((0,r.aw)(t,e,s));const n=(0,r.aw)(o[0],o[1],s),u=(0,r.aw)(o[1],o[2],s);m.setE((0,r.aw)(n,u,s));const c=(0,r.aw)(a[0],a[1],s),g=(0,r.aw)(a[1],a[2],s);l.setE((0,r.aw)(c,g,s))}else{const t=(0,r.ax)(i[0],i[1],s),e=(0,r.ax)(i[1],i[2],s);h.setE((0,r.ax)(t,e,s));const n=(0,r.ax)(o[0],o[1],s),u=(0,r.ax)(o[1],o[2],s);m.setE((0,r.ax)(n,u,s));const c=(0,r.ax)(a[0],a[1],s),g=(0,r.ax)(a[1],a[2],s);l.setE((0,r.ax)(c,g,s))}h.divThisE(l),m.divThisE(l);const u=new r.P(h.value(),m.value());Pi([t[0].value(),t[1].value(),t[2].value()],u),n.x.set(u.x,h.eps()),n.y.set(u.y,m.eps())}([p.constructPoint2D(n[0]),p.constructPoint2D(n[1]),p.constructPoint2D(n[2])],[new r.X(i[0]),new r.X(i[1]),new r.X(i[2])],e,s)}(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0)return void $(new Xr({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void $(new Xr({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}const n=(0,r.m)(r.P,3);this.queryControlPoints(n),ci(n,this.m_weights,t,e)}getCoordX(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const n=new Vr;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=Wt.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=Wt.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const o=(0,r.d)(3,Number.NaN);t.queryWeights(o),function(t,e,s,i){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const o=(0,r.m)(p,4);(function(t,e,s,i,o){const a=[p.constructPoint2D(t[0]),p.constructPoint2D(t[1]),p.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,s,i,o){(0,n.g)(!0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=p.constructCoords(0,0)}const h=Vn(a,e,0,i),m=function(t,e,s){if(s.toDouble()<=.5){const e=(0,r.aw)(t[0],t[1],s),n=(0,r.aw)(t[1],t[2],s);return(0,r.aw)(e,n,s)}{const e=(0,r.ax)(t[0],t[1],s),n=(0,r.ax)(t[1],t[2],s);return(0,r.ax)(e,n,s)}}(e,0,i),l=h.divE(m);o[0].setE(l);const u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],c=Vn([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,i).mul(2),g=m.sqr(),d=c.divE(g);o[1].setE(d)}(a,[new r.X(e[0]),new r.X(e[1]),new r.X(e[2])],0,i,o)})(t,e,0,s,o),i.setE(o[1])}(i,o,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,n.a)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=(0,r.m)(r.P,3);this.queryControlPoints(i);const o=[0,0,0];Jn(i,this.m_weights,t,e,i,o),s.setControlPointsAndWeights(i,o)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,o=Wt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.ad)(o,a,h,i,Wt.getDefaultValue(e))}getClosestCoordinate(t,e){return Un(this,t,r.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Un(this,t,0,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,n.a)("");const s=An(this);let i=0;if(2===s.specialPointsCount())return 0;(0,n.g)(t.length>=s.specialPointsCount()-1);for(let n=1,r=s.specialPointsCount();n<r;++n)this.queryCut(s.specialPoints[n-1],s.specialPoints[n],t[i],e),i++;for(let e=0;e<i;++e)Qn(t[e].get());return i}intersectionWithAxis2D(t,e,s,n){s&&(s.length=9),n&&(n.length=9);const i=new Array(3),o=(0,r.m)(r.X,2),a=new r.E(0,1);let h=0;const m=(0,r.m)(r.P,3);if(this.queryControlPoints(m),t){if(i[0]=new r.X(m[0].y).sub(e).mul(this.m_weights[0]),i[1]=new r.X(m[1].y).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new r.X(m[2].y).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),h=Yt(i[2],i[1],i[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(i[0]=new r.X(m[0].x).sub(e).mul(this.m_weights[0]),i[1]=new r.X(m[1].x).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new r.X(m[2].x).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),h=Yt(i[2],i[1],i[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(n)for(let t=0;t<h;t++)n[t]=o[t].value();else s&&(0,r.aa)(s,0,h,r.R);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],i=this.intersectionWithAxis2D(!0,t,s,null);return(0,n.g)(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return C(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.Envelope2D)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Jn(s,this.m_weights,t.vmin,t.vmax,s,[0,0,0]),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return qn(this,t,!0)}lengthToT(t){return function(t,e){const s=qn(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const i=[0];return 1!==Nt(new kn(t,e),r.E.unit(),1,i)&&(0,n.d)(""),i[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=function(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=di(e);if(1===s){const e=(0,r.m)(r.P,3);Ze(t,e);const s=e[2].clone(),n=e[1].clone(),i=new r.P,o=s.y*n.x-s.x*n.y;return i.x=-(4*s.x+5*n.x)*o/60,i.y=-(4*s.y+5*n.y)*o/60,i}if(0===s)return new r.P(0,0);(0,n.g)(s>0);const i=t[1].sub(t[0]),o=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),n=(i.y*o.x-i.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atan2(t,e),a=s*t*e,h=s*s,m=i.mul(2*(2+h)),l=o.mul(2*h-5),u=m.add(l).mul(a),c=o.sub(i.mul(2*h)).mul(6*r);return u.add(c).mul(n)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),n=(i.y*o.x-i.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atanh(t/e),a=s*t*e,h=s*s,m=i.mul(4).sub(o.mul(5)),l=i.add(o).mul(2*h),u=m.add(l).mul(a),c=o.sub(i.mul(2*h)).mul(6*r);return u.add(c).mul(n)}}(e,s)}(this),s=Ln(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const i=new r.P;if(e<0||s>1)return i.setNAN(),i;if(e>s&&(0,n.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return i.setCoords(0,0),i;const o=An(t),a=Bn(t),h=a/t.calculateUpperLength2D();let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}i.setCoords(0,0);for(let e=l+1,n=o.specialPointsCount();e<n;e++){const n=Math.min(o.specialPoints[e],s),r=Tn(t,m,n,h,a);if(i.addThis(r),m=n,s<=o.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}queryCoord2DMP(t,e){const s=(0,r.m)(r.P,3);return this.queryControlPoints(s),function(t,e,s,n){const i=s.lte(r.ar)?r.M.lerpLo:r.M.lerpHi,[o,a,h]=[e.map((e,s)=>t[s].x.mul(e)),e.map((e,s)=>t[s].y.mul(e)),e].map(([t,e,n])=>i(i(t,e,s),i(e,n,s),s)),m=new r.P(o.divThis(h).value(),a.divThis(h).value());Pi(t.map(t=>t.asPoint2D()),m),n.x=r.M.constructDouble(m.x),n.y=r.M.constructDouble(m.y)}(s.map(t=>x.constructPoint2D(t)),this.m_weights.map(t=>r.M.constructDouble(t)),r.M.constructDouble(t),e)}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),Rn(e,this.m_weights,t)}getDerivative(t){const e=(0,r.s)(t,0,1),s=(0,r.m)(r.P,4);return Mn(this,1,e,s),s[1]}getCurvature(t){const e=(0,r.m)(r.P,4);Mn(this,2,t,e);const s=e[1].sqrLength();return 0===s?Number.NaN:(e[1].divThis(Math.sqrt(s)),e[1].crossProduct(e[2])/s)}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,n,i=1){return!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,3);return this.queryControlPoints(t),Zn(t)}getMonotonicPartParams(t,e){const s=An(this),i=s.specialPointsCount();if(!e)return s.specialPointsCount();t<i&&(0,n.a)("");for(let t=0;t<i;t++)e[t]=s.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-n>t)return!1;const i=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ln(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,n.g)(0),0}queryEnvelopeW(t,e){Wn(this,t,e)}setSegmentFromCoordsForStitcher(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),n=r.P.sqrDistance(e[1],e[2]);let i=e[0].clone(),o=s;s>n&&(i=e[2].clone(),o=n);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(i)),a}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),n=r.P.sqrDistance(e[1],e[2]);e[0].clone();let i=s;return s>n&&(e[2].clone(),i=n),i<=t&&0!==i}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Qn(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const l=(0,r.m)(r.P,3);l[0].setCoordsPoint2D(e),l[2].setCoordsPoint2D(s),m.setSub(l[2],l[0]),m.leftPerpendicularThis(),l[1].setAdd(l[0],m),o.setFromTwoTriangles(h,l)?o.transformInPlace(t.m_cp):(0,r.Q)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Qn(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],zn(e,Hn(this))}reverseImpl(){this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const n=(0,r.m)(r.P,3);this.queryControlPoints(n);const o=(0,r.m)(r.P,3);s.queryControlPoints(o);const a=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let t=0;t<3;t++){const s=new i.d;s.setCoordsPoint2DZ(n[t].mul(this.m_weights[t]),this.m_weights[t]);const r=new i.d;if(r.setCoordsPoint2DZ(o[t].mul(a[t]),a[t]),!s.isEqual(r,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,r.c)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Nn(this)}intersect(t,e,s,n,i){return Nr(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return function(t,e,s,i){const o=new c;if(Wn(t,r.E.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=An(t);let h=0;const m=[];let l=a.specialPoints[0];for(let s=1,i=a.specialPoints.length;s<i;++s){const i=a.specialPoints[s],r=wn(t,e,l,i);if(0===m.length)m.push(r);else if(r.t===r.tmin)(0,n.g)(m.at(-1).d<=r.d),m.at(-1).tmax=r.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,n.g)(m.at(-1).d>=r.d);const t=m.at(-1).tmin;m[m.length-1]=r,m.at(-1).tmin=t}else m.push(r);l=i}for(const t of m)if(t.d<=i){const e=t.t;s?(s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Nn(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,i,r,o){(i<=0||o<=0||r<0)&&(0,n.a)("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&(0,n.a)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=i,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}jt.type=n.G.enumRationalBezier2;var Zt=i.V;class Qt extends Q{constructor(t){void 0===t||(0,r.ae)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):(0,n.d)("unexpected constructor args")}getBoundary(){return wt(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),ve(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),ve(this)}getGeometryType(){return n.G.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Me(this);if(null!==e){const s=new r.P;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[];be(this,e);const s=new r.P;for(const n of e)this.queryCoord2D(n,s),t.mergeNe(s)}return}(0,n.t)("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}(0,n.g)(0)}createInstance(){return new Qt({vd:this.m_description})}calculateLength2D(){return Ie(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const n=(0,r.m)(r.P,3);this.queryControlPoints(n),Ke(n,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n),function(t,e,s){if(e.value()<=.5){const n=p.constructPoint2D(t[1]),i=new p;(0,r.ao)(2,p.constructPoint2D(t[0]),n,e,i);const o=new p;(0,r.ao)(2,n,p.constructPoint2D(t[2]),e,o);const a=new p;(0,r.ao)(2,i,o,e,a),s.setE(a)}else{const n=p.constructPoint2D(t[1]),i=new p;(0,r.ap)(2,p.constructPoint2D(t[0]),n,e,i);const o=new p;(0,r.ap)(2,n,p.constructPoint2D(t[2]),e,o);const a=new p;(0,r.ap)(2,i,o,e,a),s.setE(a)}}(n,e,s)}(this,t,e)}queryCoord2DMP(t,e){(0,n.g)(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=(0,r.af)(this.getStartX(),this.m_cp.x,t),s=(0,r.af)(this.m_cp.x,this.getEndX(),t);return(0,r.af)(e,s,t)}{const e=(0,r.ag)(this.getStartX(),this.m_cp.x,t),s=(0,r.ag)(this.m_cp.x,this.getEndX(),t);return(0,r.ag)(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=(0,r.af)(this.getStartX(),this.m_cp.x,t),s=(0,r.af)(this.m_cp.x,this.getEndX(),t);return(0,r.af)(e,s,t)}{const e=(0,r.ag)(this.getStartY(),this.m_cp.y,t),s=(0,r.ag)(this.m_cp.y,this.getEndY(),t);return(0,r.ag)(e,s,t)}}cut(t,e,s){const n=new Vr;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=Zt.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=Zt.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){!function(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){{const e=p.constructPoint2D(t[1]).subE(p.constructPoint2D(t[0])),n=new r.X(1).subE(s),i=p.constructPoint2D(t[2]).subE(p.constructPoint2D(t[1])),o=e.mulE(n).addE(i.mulE(s));return o.mulThisE(new r.X(2)),o}}(t,0,e))}(n,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&(0,n.a)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const i=(0,r.m)(r.P,3);this.queryControlPoints(i),He(i,t,e,i),s.constructPoints(i)}splitBezierIgnoreAttributes(t,e,s){(0,n.g)(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,o=Zt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.ad)(o,a,h,i,Zt.getDefaultValue(e))}getClosestCoordinate(t,e){return Xe(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Xe(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,n.a)("");const s=Se(this);let i=0;if(2===s.specialPointsCount())return 0;(0,n.g)(t.length>=s.specialPointsCount()-1);for(let n=1,r=s.specialPointsCount();n<r;++n)this.queryCut(s.specialPoints[n-1],s.specialPoints[n],t[i],e),i++;for(let e=0;e<i;++e)ke(t[e].get());return i}intersectionWithAxis2D(t,e,s,n){const i=(0,r.m)(r.X,3),o=(0,r.m)(r.X,2),a=new r.E(0,1);let h=0;if(t){if(i[0]=new r.X(this.getStartY()).sub(e),i[1]=new r.X(this.m_cp.y).subE(new r.X(this.getStartY())).mulThisByPower2(2),i[2]=new r.X(this.getStartY()).add(this.getEndY()).subE(new r.X(this.m_cp.y).mulThisByPower2(2)),h=Yt(i[2],i[1],i[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(i[0]=new r.X(this.getStartX()).sub(e),i[1]=new r.X(this.m_cp.x).subE(new r.X(this.getStartX())).mulThisByPower2(2),i[2]=new r.X(this.getStartX()).add(this.getEndX()).subE(new r.X(this.m_cp.x).mulThisByPower2(2)),h=Yt(i[2],i[1],i[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(n)for(let t=0;t<h;t++)n[t]=o[t].value();else s&&(0,r.ah)(s,h);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return(0,n.g)(2!==i),-1===i?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return C(this,t)}isDegenerate3D(t,e){return(0,n.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,n.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new o.Envelope2D;this.queryEnvelope(t);const s=new r.E;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),He(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Ie(this,t,!0)}lengthToT(t){return function(t,e){const s=Ie(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const i=[0];return 1!==Nt(new Ee(t,e),r.E.unit(),1,i)&&(0,n.d)(""),i[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,3);!function(t,e,s=!1){const n=(0,r.m)(r.P,3);t.queryControlPoints(n),Ze(n,e,s)}(this,e);const s=e[2],n=e[1],i=new r.P,o=s.y*n.x-s.x*n.y;i.x=-(4*s.x+5*n.x)*o/60,i.y=-(4*s.y+5*n.y)*o/60;const a=Ge(this);return i.x+=(e[0].x-t.x)*a,i.y+=(e[0].y-t.y)*a,i}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const i=new r.P;if(e<0||s>1)return i.setNAN(),i;if(e>s&&(0,n.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return i.setCoords(0,0),i;const o=Se(t),a=V(t),h=Math.min(a/t.calculateUpperLength2D(),1e-7);let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}i.setCoords(0,0);for(let e=l+1,n=o.specialPointsCount();e<n;e++){const n=Math.min(o.specialPoints[e],s),r=Ce(t,m,n,h,a);if(i.addThis(r),m=n,s<=o.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPoints(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,n.a)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.s)(t,0,1);let s=Ne(this,1,e);return s.isZero()&&(s=Ne(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Ne(this,1,(0,r.s)(t,0,1))}getCurvature(t){const e=Ne(this,1,t),s=Ne(this,2,t),n=e.sqrLength();return 0===n?Number.NaN:(e.divThis(Math.sqrt(n)),e.crossProduct(s)/n)}isIntersecting(t,e,s){return 0!==Ir(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const n=new o.Envelope2D;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(i,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return(0,n.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){const s=Se(this),i=s.specialPointsCount();if(!e)return s.specialPointsCount();t<i&&(0,n.a)("");for(let t=0;t<i;t++)e[t]=s.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-n>t)return!1;const i=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Ge(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ye(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const n=r.P.sqrDistance(s[1],s[0]),i=r.P.sqrDistance(s[1],s[2]);let o=s[0].clone(),a=n;n>i&&(o=s[2].clone(),a=i);let h=!1;return a<=e&&0!==a&&(h=!0,t.setControlPoint1(o)),h}(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const n=r.P.sqrDistance(s[1],s[0]),i=r.P.sqrDistance(s[1],s[2]);s[0].clone();let o=n;return n>i&&(s[2].clone(),o=i),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return ke(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const l=(0,r.m)(r.P,3);l[0].setCoordsPoint2D(e),l[2].setCoordsPoint2D(s),m.setSub(l[2],l[0]),m.leftPerpendicularThis(),l[1].setAdd(l[0],m),o.setFromTwoTriangles(h,l)?o.transformInPlace(t.m_cp):(0,r.Q)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&ke(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Fe(e,Me(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){ve(this)}intersect(t,e,s,n,i){return Nr(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return function(t,e,s,n,i){const o=new c;if(function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n),Ye(n,e,s)}(t,r.E.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=new r.P,h=Xe(t,e,r.E.unit(),!1);return t.queryCoord2D(h,a),r.P.distance(a,e)<=i?(n&&(n[0]=h),1):0}(this,t,e.length,e,s)}endPointModified(){ve(this)}clearEndPointModified(){}}Qt.type=n.G.enumBezier2;class Kt{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,n.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}scaleRangeToUnitInterval(t,e){const s=e;s.subThis(t);const n=this.power();for(let e=0;e<=n;e++){const i=new this.m_zeroCtor;for(let s=e;s<=n;s++){const n=this.m_elements[s];n.mulDoubleThis((0,r.aH)(s,e));const o=t.pow(s-e);n.mulThis(o),i.addThis(n)}const o=s.pow(e);i.mulThis(o),this.m_elements[e]=i}}fmSubThis(t,e){return(0,n.g)(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].addThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,n.g)(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0(t){return(0,n.g)(0),this}subNumber0(t){return(0,n.g)(0),this}subShifted(t,e){const s=this.power(),n=t.power()+e,i=Math.min(this.power(),n);let r=0;for(let s=e;s<=i;++s)this.m_elements[s].subThis(t.m_elements[r]),r++;if(n<=s)return this.updatePower(),this;this.m_elements.length=n+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=i+1;e<=n;++e)this.m_elements[e].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const n=this.power(),i=t.power()+s,r=Math.min(this.power(),i);let o=0;for(let n=s;n<=r;++n)this.m_elements[n].fmSubThis(t.m_elements[o],e),o++;if(i<=n)return this.updatePower(),this;this.m_elements.length=i+1;for(let t=n+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let s=r+1;s<=i;++s)this.m_elements[s].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,n=this.power();t<=n;t++)for(let n=0,i=e.power();n<=i;n++){const i=this.m_elements[t].clone();i.mulThis(e.m_elements[n]),t+n<s.length?s[t+n].addThis(i):s.push(i)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return(0,n.g)(0),this}mulBigint0(t){return(0,n.g)(0),this}mulBigIntThis(t){return(0,n.g)(0),this}mulInt320(t){return(0,n.g)(0),this}div0(t){return(0,n.g)(0),this}absThis(){return(0,n.g)(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const n=t.getElement(t.power()),i=this.clone();let o=i.power();const a=i.power()-t.power();let h=a;for(e.m_elements=(0,r.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){s.assignMove(i);break}if(o===i.power()){const s=i.getElement(i.power());s.divThis(n),i.subShiftedWithCoef(t,s,i.power()-t.power()),e.m_elements[h]=s.clone()}h--,o--}s.updatePower(),e.updatePower()}divThis(t){return(0,n.g)(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,n.g)(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let n=e-1;n>=0;--n)s.mulThis(t),s.addThis(this.m_elements[n]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,n=this.power();s<=n;s++){let n=BigInt(s);for(let e=s-1,i=s-t;e>i;--e)n*=BigInt(e);e.m_elements[s-t].mulBigIntThis(n)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(r.M.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{const s=e.hiBitIndex();return t<s?s:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){const e=this.power(),s=this.m_elements[e];s.mulDoubleThis(e);for(let n=e-1;n>=1;--n){s.mulThis(t);const e=this.m_elements[n];e.mulDoubleThis(n),s.addThis(e)}return s}static evaluateCoefs(t,e,s){const n=t.power();s.construct0(t.getElement(0).evaluate(e));for(let i=1;i<=n;++i)s.addElement(t.getElement(i).evaluate(e));s.updatePower()}}class $t extends Kt{constructor(t){super(void 0===t?{zeroCtor:r.M}:{...t,zeroCtor:r.M})}clone(){return new $t({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const n=t.clone();n.absThis();for(let t=e-1;t>=0;--t)s.mulThis(n),s.addThis(this.m_elements[t].abs());return s}}class Jt extends Kt{constructor(t){super(void 0===t?{zeroCtor:$t}:{...t,zeroCtor:$t})}clone(){return new Jt({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new $t({coef0:t[s]}));return this.updatePower(),this}}function te(t,e,s,i,o,a,h,m,l,u,c,g,d,_,p,f,x,P,y,E=!1){const C={polypoly1:new Jt,polypoly2:new Jt,polyX2:new $t,polyY2:new $t,polyX2Deriv:new $t,polyY2Deriv:new $t,polypolyX1:new Jt,polypolyY1:new Jt,polypolyX1Deriv:new Jt,polypolyY1Deriv:new Jt,lazyPolypolyD1:new Jt,lazyPolypolyD1Deriv:new Jt,lazyPolyD2:new $t,lazyPolyD2Deriv:null,polypoly11:new Jt,polypoly12:new Jt,tempPp:new Jt,tempPp1:new Jt,tempPp2:new Jt,tempP:new $t,tempP1:new $t,tempP2:new $t};C.polyX2.construct(h,m),C.polyY2.construct(l,u),C.polypolyX1.constructFromMPValues(t,e),C.polypolyY1.constructFromMPValues(s,i),C.polypoly11.assignCopy(C.polypolyX1),C.polypoly12.assignCopy(C.polypolyY1),c&&(C.lazyPolyD2.construct(c,g),C.polypoly11.mulElementThis(C.lazyPolyD2),C.polypoly12.mulElementThis(C.lazyPolyD2)),o?(C.lazyPolypolyD1.constructFromMPValues(o,a),C.lazyPolypolyD1Deriv=new Jt({copy:C.lazyPolypolyD1}),C.lazyPolypolyD1Deriv.derivative1This(),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyX2),C.polypoly11.subThis(C.tempPp),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyY2),C.polypoly12.subThis(C.tempPp)):(C.polypoly11.sub0This(C.polyX2),C.polypoly12.sub0This(C.polyY2)),C.polypolyX1Deriv.assignCopy(C.polypolyX1),C.polypolyX1Deriv.derivative1This(),C.polypolyY1Deriv.assignCopy(C.polypolyY1),C.polypolyY1Deriv.derivative1This(),o&&(C.polypolyX1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyX1),C.polypolyX1Deriv.subThis(C.tempPp2),C.polypolyY1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyY1),C.polypolyY1Deriv.subThis(C.tempPp2)),C.polyX2Deriv.assignCopy(C.polyX2),C.polyX2Deriv.derivative1This(),C.polyY2Deriv.assignCopy(C.polyY2),C.polyY2Deriv.derivative1This(),c&&((0,n.g)(null===C.lazyPolyD2Deriv),C.lazyPolyD2Deriv=new $t({copy:C.lazyPolyD2}),C.lazyPolyD2Deriv.derivative1This(),C.polyX2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyX2),C.polyX2Deriv.subThis(C.tempP1),C.polyY2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyY2),C.polyY2Deriv.subThis(C.tempP1)),C.polypoly1.assignCopy(C.polypoly11),C.polypoly1.mulElementThis(C.polyX2Deriv),C.tempPp.assignCopy(C.polypoly12),C.tempPp.mulElementThis(C.polyY2Deriv),C.polypoly1.addThis(C.tempPp),C.polypoly2.assignCopy(C.polypolyX1Deriv),C.polypoly2.mulElementThis(C.polyY2Deriv),C.tempPp.assignCopy(C.polypolyY1Deriv),C.tempPp.mulElementThis(C.polyX2Deriv),C.polypoly2.subThis(C.tempPp);let v=[];const S=[];x||(x=[]),f||(f=[]),he(C.polypoly11,C.polypoly12,C.tempP);const b=r.aB.ldexp(-59).toDouble(),I=[];let D=me(C.tempP,0,p,b,64,I,P,P);if(D<0)return-1;for(let t=0;t<D;t++){const e=C.tempP1,s=C.tempP2;$t.evaluateCoefs(C.polypoly11,I[t],e);const i=(0,r.aC)(e.m_elements,e.power()+1);i.sort((t,e)=>t.compare(e)),$t.evaluateCoefs(C.polypoly12,I[t],s);const o=(0,r.aC)(s.m_elements,s.power()+1);o.sort((t,e)=>t.compare(e));const a=i[0],h=i.at(-1),m=o[0],l=o.at(-1);h.subThis(a),l.subThis(m);const u=h.subThis(l).GEZ(),c=58,g=[];let d;if(d=me(u?e:s,0,_,r.aB.ldexp(-59).toDouble(),c,g,P,P),d<0&&(0,n.d)("mp_curve_proximity"),d>0){const i=u?s:e;for(let e=0;e<d;e++){let s;if(u){const n=C.tempP;$t.evaluateCoefs(C.polypoly12,I[t].addDouble(Number.EPSILON),n),s=n.evaluate(g[e])}else{const n=C.tempP;$t.evaluateCoefs(C.polypoly11,I[t].addDouble(Number.EPSILON),n),s=n.evaluate(g[e])}const o=i.evaluateDerivative(g[e]).abs().mulDoubleThis(Number.EPSILON),a=i.evaluate(g[e]);o.addThis(s.sub(a).absThis()),o.ldexpThis(3),a.absThis(),a.lt(o)?S.push((0,r.l)(g[e].toDouble(),I[t].toDouble())):(0,n.g)(a.gte(o))}}}D=S.length,he(C.polypoly1,C.polypoly2,C.tempP);const w=[];let T=me(C.tempP,0,p,b,64,w);T<0&&(T=0);for(let t=0;t<T;t++){$t.evaluateCoefs(C.polypoly1,w[t],C.tempP1);const e=[];let s=me(C.tempP1,0,_,b,64,e);if(0!==s)if($t.evaluateCoefs(C.polypoly2,w[t],C.tempP2),s<0){if(s=me(C.tempP2,0,_,b,64,e),s<0)continue;for(let n=0;n<s;n++)v.push((0,r.l)(e[n].toDouble(),w[t].toDouble()))}else{const n=C.tempP2.absEvaluate(r.aB);n.mulThis(r.M.constructDouble(1e-12));for(let i=0;i<s;i++){const s=C.tempP2.evaluate(e[i]);s.absThis(),s.lt(n)&&v.push((0,r.l)(e[i].toDouble(),w[t].toDouble()))}}}if(T=v.length,0===D&&0===T)return 0;v=v.concat(S),v.sort((t,e)=>E?(0,r.R)(t.second,e.second):(0,r.R)(t.first,e.first));const N=(0,r.u)(v,(t,e)=>t.first===e.first&&t.second===e.second);v=v.slice(0,N),f.length=0,x.length=0;for(const t of v)f.push(t.first),x.push(t.second);return(0,n.g)(f.length===x.length),x.length}function ee(t,e,s,n,i,o,a,h,m,l,u,c,g){const d={polyIntersect:new $t,polyX1:new $t,polyY1:new $t,polyX1Deriv:new $t,polyY1Deriv:new $t,lazyPolyD1:new $t,lazyPolyD1Deriv:new $t,tempP:new $t,tempP1:new $t,tempP2:new $t,polypoly1Proximity:new Jt,polypoly2Proximity:new Jt};d.polyX1.construct(t,e),d.polyY1.construct(s,n),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.polyIntersect.assignCopy(d.polyX1),d.polyIntersect.mulThis(d.polyX1),d.polyIntersect.mulElementThis(a[0]),d.tempP.assignCopy(d.polyY1),d.tempP.mulThis(d.polyY1),d.tempP.mulElementThis(a[1]),d.polyIntersect.addThis(d.tempP),i?(d.lazyPolyD1.construct(i,o),d.tempP.assignCopy(d.lazyPolyD1),d.tempP.mulThis(d.lazyPolyD1),d.tempP.mulElementThis(a[2]),d.polyIntersect.addThis(d.tempP)):d.polyIntersect.add0(a[2]);{const i=a[0].clone(),o=i.clone();o.sqrThis();const h=a[1].clone(),m=h.clone();m.sqrThis();const l=a[2].clone(),u=i.clone();u.subThis(h),d.polyX1.construct(t,e),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1.construct(s,n),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(m),d.tempP.mulElementThis(l),d.polypoly1Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(h.mul(u).mul(l).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(i.mul(m)),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1),d.tempP1.mulElementThis(o.mul(h)),d.tempP.addThis(d.tempP1),d.tempP.add0(u.mul(u).mul(l)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulElementThis(u.mul(i).mul(h).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.construct0(i.mul(u).mul(u)),d.polypoly1Proximity.addElement(d.tempP),d.polypoly1Proximity.updatePower(),d.tempP.construct0(r.aA),d.polypoly2Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1Deriv),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1Deriv),d.tempP.addThis(d.tempP1),d.tempP.mulElementThis(i.mul(h)),d.polypoly2Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1Deriv),d.tempP.mulElementThis(u.mul(i)),d.polypoly2Proximity.addElement(d.tempP),d.polypoly2Proximity.updatePower()}const _=[],p=[];null===u&&(u=[]);let f=2*d.polyIntersect.power()+58;const x=.5*Number.EPSILON,P=[],y=me(d.polyIntersect,0,m,x,f,P,c,c);if(y<0)return-1;for(const t of P)p.push(t.toDouble());he(d.polypoly1Proximity,d.polypoly2Proximity,d.tempP),f=2*d.tempP.power()+58,P.length=0;let E=me(d.tempP,0,m,x,f,P);if(E<0&&(E=0),0===y&&0===E)return 0;for(const t of P)_.push(t.toDouble());const C=_.concat(p);u.length=C.length,(0,r.b)(u,C,0,0,C.length),(0,r.v)(u);const v=(0,r.u)(u,(t,e)=>0===(0,r.R)(t,e));return u.length=v,u.length}function se(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setThis(e),n.negateThis(),n.divThis(t),s.isEmpty()||s.containsCoordinate(n.value())?1:0)}function ne(t,e,s,n,i,o,a){if(t.isZero())return o?(a[0].setInt32(1),i.containsCoordinate(1)?1:0):se(e,s,i,a[0]);if(o){let e=2;return a[0].setInt32(1),s.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(s.div(t)),i.containsCoordinate(a[1].value())||(e=1),i.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,r.c)(a[0],a[0]=a[1])),e}const h=e.clone();h.sqrThis();const m=t.clone();if(m.mulThis(s).ldexpThis(2).negateThis().addThis(h),m.LZ())return 0;const l=n+2,u=r.M.sqrt(m,l),c=u.clone();e.LZ()&&c.negateThis(),c.addThis(e).limitPrecisionThis(l).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(c).divThis(r.M.constructAssign(t,l)).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(a[0].value()))&&g++,u.isZero()||c.isZero()||(a[g].setThis(s).divThis(c).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,r.c)(a[0],a[0]=a[1]))),g}function ie(t,e,s,i,o,a,h,m){if(t.isZero())return ne(e,s,i,o,a,h,m);const l=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.aa)(m,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let n=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),n=1),l(ne(t,e,s,o,a,h,m.slice(1)),n)}if(h){let s=0;a.containsCoordinate(1)&&(m[0].setInt32(1),s=1);const n=e.add(t),r=i.negate(),h=t.add(n).add(r).isZero();return l(ne(t,n,r,o,a,h,m.slice(s)),s)}const u=new r.M,c=new r.M,g=new r.M,d=e.clone();if(d.isZero())c.setThis(s),c.divThis(t),g.setThis(i),g.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();const n=e.clone();n.sqrThis();const r=t.clone();r.sqrThis(),c.setThis(t),c.mulThis(s).mulDoubleThis(3).subThis(n).divThis(r).divDoubleThis(3),g.setThis(n),g.mulThis(e),g.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(s).mulDoubleThis(9),g.subThis(u),u.setThis(r),u.mulThis(i).mulDoubleThis(27),g.addThis(u),g.divThis(r).divThis(t).divDoubleThis(27)}if(c.isZero()){const t=g.clone();return t.negateThis(),t.isZero()?(m[0].setThis(d),pe(a,o,m,1)):(m[0].setThis(r.M.cubicRoot(t,o).add(d)),pe(a,o,m,1))}const _=g.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(c.clone()),u.sqrThis().mulThis(c).divDoubleThis(27),_.addThis(u),_.isZero())return m[0].setThis(g),m[0].mulDoubleThis(3).divThis(c),m[1].setThis(m[0]),m[1].negateThis(),m[1].ldexpThis(-1),m[0].addThis(d),m[1].addThis(d),pe(a,o,m,2);if(_.GZ())return _.setThis(r.M.sqrt(_,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.addThis(_),m[0].setThis(r.M.cubicRoot(u,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.subThis(_),m[0].addThis(r.M.cubicRoot(u,o+8)),m[0].addThis(d),pe(a,o,m,1);u.setThis(c),u.divDoubleThis(3).negateThis(),(0,n.g)(u.GEZ());const p=r.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(d),p.addThis(d);const x=r.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),P=r.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),y=new $t({zeroCtor:r.M});y.construct0(i),y.addElement(s),y.addElement(e),y.addElement(t);const E=new $t({copy:y});E.derivative1This();let C=0;const v=(0,r.m)(r.M,4);v[C++].setThis(x),f.gt(x)&&f.lt(P)&&v[C++].setThis(f),p.gt(x)&&p.lt(P)&&v[C++].setThis(p),v[C++].setThis(P);const S=3*o;let b=52,I=Number.EPSILON;for(;b<S;)2*b<=S?(I*=I,b*=2):(I*=Number.EPSILON,b+=52);b+=2;let D=0,w=!1;for(let t=1;t<C;t++)if(ce(y,E,v[t-1],v[t],I,b,m[0])){D=1,w=t+1<C;break}if(!D)return 0;if(w){const t=new $t({zeroCtor:r.M,coef0:m[0]});t.negateThis(),t.addElement(r.aB);const e=new $t({zeroCtor:r.M}),s=new $t({zeroCtor:r.M});y.div(t,e,s),(0,n.g)(2===e.power()),(0,n.g)(0===s.power());const i=ne(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,m.slice(1));(0,n.g)(i>=0&&i<=2),D+=i}return pe(a,o,m,D)}function re(t,e,s,n,i,o,a,h,m){if(t.isZero())return ie(e,s,n,i,o,a,h,m);const l=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.aa)(m,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let i=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),i=1),l(ie(t,e,s,n,o,a,h,m.slice(i)),i)}const u=new $t({zeroCtor:r.M,coef0:i});if(u.addElement(n),u.addElement(s),u.addElement(e),u.addElement(t),h){let t=0;a.containsCoordinate(1)&&(m[0].setInt32(1),t=1);const e=new $t({zeroCtor:r.M,coef0:r.M.constructInt32(-1)});e.addElement(r.M.constructInt32(1));const s=new $t({zeroCtor:r.M}),n=new $t({zeroCtor:r.M});return u.div(e,s,n),l(ie(3===s.power()?s.getElement(3):r.aA.clone(),s.power()>=2?s.getElement(2):r.aA.clone(),s.power()>=1?s.getElement(1):r.aA.clone(),s.getElement(0),o,a,s.evaluate(r.aB).isZero(),m.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,m[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=ie(3===u.power()?u.getElement(3):r.aA.clone(),u.power()>=2?u.getElement(2):r.aA.clone(),u.power()>=1?u.getElement(1):r.aA.clone(),u.getElement(0),o,a,!1,m.slice(t));return e>0&&(t+=e),(0,r.aa)(m,0,t,(t,e)=>t.compare(e)),t}let c=52,g=Number.EPSILON;for(;c<o;)2*c<=o?(g*=g,c*=2):(g*=Number.EPSILON,c+=52);c+=2;const d=_e(u),_=r.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(d.lt(_)?d:_).mul(r.M.constructDouble(g)).toDouble(),de(u,a,g,c,h,0,m,4)}function oe(t,e){let s=t,n=e;n.power()>s.power()&&(n=(0,r.c)(s,s=n));const i=s.power()-n.power(),o=new $t({copy:s.getElement(s.power())});s.mulThis(n.getElement(n.power()));for(let t=0,e=s.power();t<e;t++)if(t>=i){const e=new $t({copy:n.getElement(t-i)});e.mulThis(o);const r=s.getElement(t).sub(e);s.setElement(t,r)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),ae(s)}function ae(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function he(t,e,s){const n=t.clone(),i=e.clone();for(ae(n),ae(i);0!==n.power()||0!==i.power();)oe(n,i);s.assignMove(n.getElement(0))}function me(t,e,s,n,i,o,a=!1,h=!1){o.length=0;const m=t.power(),l=(0,r.m)(r.M,2*m+4),u=function(t,e,s,n,i,o,a){if(0===t.power())return t.isZero()?-1:0;const h=t.evaluate(r.M.constructInt32(1)).isZero();if(1===t.power()){const s=se(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(n),1!==s?0:(o[0].limitPrecisionThis(n),1)}return 2===t.power()?ne(t.getElement(2),t.getElement(1),t.getElement(0),n,e,h,o):3===t.power()?ie(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,h,o):4===t.power()?re(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,h,o):de(t,e,s,n,h,0,o,a)}(t,s||r.E.unit(),n,i,0,l,l.length);if(u>0){o.length=0;for(let t=0;t<u;t++){const e=l[t];t>0&&e.lte(o.at(-1))||o.push(e.clone())}return o.length}return u}function le(t,e,s){if((0,n.g)(s>=1),0===t.power())return t.isZero()?-1:0;const i=t.getElement(0);return i.negateThis(),i.divThis(t.getElement(1)),e[0].setThis(i),1}function ue(t,e,s,i){if(t.power()<2)return le(t,s,i);(0,n.g)(i>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));const a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){const n=t.getElement(1);return n.negateThis(),n.divThis(t.getElement(2)),n.ldexpThis(-1),n.limitPrecisionThis(e),s[0].setThis(n),1}(0,n.g)(i>=2),o=r.M.sqrt(o,e+8);const h=t.getElement(1);h.negateThis();const m=h.clone();m.subThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e);const l=h.clone();return l.addThis(o),l.divThis(t.getElement(2)),l.ldexpThis(-1),l.limitPrecisionThis(e),m.lt(l)?(s[0].setThis(m),s[1].setThis(l)):(s[1].setThis(m),s[0].setThis(l)),2}function ce(t,e,s,i,o,a,h){let m=s.clone(),l=i.clone();m.limitPrecisionThis(a),l.limitPrecisionThis(a);let u=t.evaluate(m);u.limitPrecisionThis(a+2);let c=t.evaluate(l);if(c.limitPrecisionThis(a+2),u.GEZ()&&c.GEZ()||u.LEZ()&&c.LEZ())return u.absLessAbs(c)?(h=m,u.isZero()):(h=l,c.isZero());const g=c.LZ();g&&(c=(0,r.c)(u,u=c),l=(0,r.c)(m,m=l));const d=g?l:m,_=g?m:l,p=m.add(l).ldexpThis(-1);p.limitPrecisionThis(a);const f=l.sub(m);f.limitPrecisionThis(a),f.absThis();const x=f.clone();let P=t.evaluate(p),y=e.evaluate(p);const E=new $t({copy:t}),C=new $t({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),n=r.aB.clone();n.ldexpThis(-(a+2));for(let i=64;i<s;){E.limitPrecisionThis(i),C.limitPrecisionThis(i);const r=E.evaluate(p),o=C.evaluate(p),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(n)&&(y.isZero()||h.divThis(y).absThis().lt(n)))break;E.assignCopy(t),C.assignCopy(e),i=Math.min(i+64,s)}P.limitPrecisionThis(a+2),y.limitPrecisionThis(a+2)}let v=4,S=1,b=0,I=0,D=1;const w=r.M.constructDouble(.25*o),T=r.M.constructDouble(.5001);let N=0;for(;++N<300;){if(N>32&&b>0||y.isZero()||2===D&&b>1||1===D&&v<4)D=1,S>1&&S--;else if(D=2,I>1){const t=f.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&S++}f.setThis(x);const t=new r.M;let e=!1;if(1===D)do{if(I>2){const e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(d).ldexpThis(-1).gt(e)){if(p.equals(d)){t.setThis(p),p.setThis(d.add(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}}}x.setThis(l.sub(m)),x.ldexpThis(-1),x.limitPrecisionThis(a),t.setThis(p),p.setThis(m.add(x)),p.limitPrecisionThis(a),p.lt(d)?p.setThis(d):p.gt(_)&&p.setThis(_),e=m.equals(p)||l.equals(p)}while(0);else for(;;){if(x.setThis(P.div(y)),x.limitPrecisionThis(a),1!==S&&x.mulDoubleThis(S),t.setThis(p),p.subThis(x),p.limitPrecisionThis(a),e=p.equals(t),p.lt(d)){if(S>1){p.setThis(t),S--;continue}x.setThis(t.sub(d)),p.setThis(d)}else if(p.gt(_)){if(S>1){p.setThis(t),S--;continue}x.setThis(t.sub(_)),p.setThis(_)}break}if(e||x.absLessAbs(w)){t.equals(p)||(P=E.evaluate(p),P.limitPrecisionThis(a+2));break}P=E.evaluate(p),P.limitPrecisionThis(a+2),y=C.evaluate(p),y.limitPrecisionThis(a+2);const s=m.clone(),n=l.clone();P.LZ()?(u.setThis(P),m.setThis(p)):(c.setThis(P),l.setThis(p)),2===D&&(m.equals(s)&&l.equals(n)||I>1&&!x.absLessAbs(T.mul(f)))?b++:b=0,1===D?(v++,I=0):(v=0,I++)}return N>=300&&(0,n.d)("Root_finder iterations exceeded"),h.setThis(p),!0}function ge(t,e,s,n,i){const o=t.evaluate(s);if(o.isZero())return!0;const a=r.M.constructDouble(.5*n),h=s.clone();h.subThis(a);const m=t.evaluate(h),l=s.clone();l.addThis(a);const u=t.evaluate(l);if(m.LZ()&&u.GZ()||m.GZ()&&u.LZ())return!0;if(o.GZ()?m.LEZ()||u.LEZ():m.GEZ()||u.GEZ())return!0;const c=m.LEZ()&&u.LEZ(),g=m.GEZ()&&u.GEZ();let d=!1;return c?o.gt(m)&&o.gt(u)&&(d=!0):g&&o.lt(m)&&o.lt(u)&&(d=!0),!!d&&o.absThis().lt(r.M.constructDouble(1e-17))}function de(t,e,s,i,o,a,h,m){(0,n.g)(s>0),(0,n.g)(m>=t.power());const l=h,u=[];let c=[];const g=new $t({zeroCtor:t.m_zeroCtor}),d=new $t({zeroCtor:t.m_zeroCtor}),_=new $t({zeroCtor:t.m_zeroCtor}),p=r.M.constructDouble(s),f=r.M.constructDouble(e.vmin),x=r.M.constructDouble(e.vmax),P=f.sub(p),y=x.add(p),E=_e(t),C=E.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(p));else if(P.gt(E))return 0;if(y.gt(E))y.setThis(E.add(p));else if(y.lt(C))return 0;let v=t,S=null;if(o){const e=new $t({coef0:r.M.constructInt32(-1)});e.addElement(r.aB),S=new $t,v=S;const s=new $t,n=new $t;for(t.div(e,s,n),S.assignCopy(s);v.evaluate(r.aB).isZero();)v.div(e,s,n),S.assignCopy(s)}let b=!1;if(v.power()>0&&v.getElement(0).isZero())for(b=!0,S||(S=new $t({copy:v}),v=S);v.getElement(0).isZero();)S.shiftRight(1);let I=i+2*v.power()+2,D=s/Math.pow(2,v.power()+2),w=I;if(r.aA.gt(P)&&r.aA.lt(y))for(let t=0,e=v.power();t<e;t++)if(v.getElement(t).isZero()){u.push(r.aA.clone());break}for(let t=v.power()-1;t>0;t--)if(D*=2,I-=2,w-=2,v.power()-t!==1){if(v.power()-t===2){d.assignMove(v.derivative(t));const e=ue(d,I,l,m);(0,n.g)(e>=0&&e<=2);for(let t=0;t<e;t++)l[t].gt(P)&&l[t].lt(y)&&!l[t].isZero()&&u.push(l[t].clone());if(u.length>1&&u.sort((t,e)=>t.compare(e)),u.length>0){let t=u[0].sub(p);t.limitPrecisionThis(w),c.push((0,r.l)(P.clone(),t));let e=1===u.length?y.clone():u[1].sub(p);t=u[0].add(p),t.limitPrecisionThis(w),e.limitPrecisionThis(w),c.push((0,r.l)(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(p),e.limitPrecisionThis(w),t=u[1].add(p),t.limitPrecisionThis(w),c.push((0,r.l)(t,e)),u.length>2&&(t=u[2].add(p),t.limitPrecisionThis(w),c.push((0,r.l)(t,y.clone()))))}else c.push((0,r.l)(P.clone(),y.clone()));g.assignCopy(d),_.assignMove(v.derivative(t-1));continue}{d.assignMove(_),_.assignMove(v.derivative(t-1));let e=[];for(let t=0,s=c.length;t<s;++t)if(c[t].first.lte(c[t].second)){const s=new r.M;if(ce(d,g,c[t].first,c[t].second,D,I,s)){u.push(s);let n=s.sub(p);n.limitPrecisionThis(w),e.push((0,r.l)(c[t].first,n)),n=s.add(p),n.limitPrecisionThis(w),e.push((0,r.l)(n,c[t].second))}else e.push(c[t])}c=e,e=[],g.assignMove(d)}}else d.assignMove(v.derivative(t)),1===le(d,l,m)&&(l[0].gt(P)&&l[0].lt(y)&&!l[0].isZero()&&u.push(l[0].clone()),g.assignMove(d),_.assignMove(v.derivative(t-1)));u.sort((t,e)=>t.compare(e)),0===c.length&&(g.assignMove(v.derivative(v.power())),g.isZero()||c.push((0,r.l)(P.clone(),y.clone())));let T=0,N=0,A=0;const G=new r.M;for(;;){if(N<c.length){if(c[N].first.gt(c[N].second)){N++;continue}let t=!1;if(A<u.length&&u[A].lt(c[N].first)&&(t=!0),!t){ce(v,g,c[N].first,c[N].second,s,i,G)&&(G.lt(f)?l[T++].setThis(f):G.gt(x)?l[T++].setThis(x):l[T++].setThis(G)),N++;continue}}if(!(A<u.length))break;0!==A&&u[A-1].equals(u[A])||ge(v,0,u[A],s)&&(G.setThis(u[A]),G.lt(f)?G.setThis(f):G.gt(x)&&G.setThis(x),0!==T&&l[T].equals(G)||l[T++].setThis(G)),A++}return b&&r.aA.gt(P)&&r.aA.lt(y)&&(l[T++].setThis(r.aA),(0,r.aa)(l,0,T,(t,e)=>t.compare(e))),o&&r.aB.gt(P)&&r.aB.lt(y)&&(l[T++].setThis(r.aB),(0,r.aa)(l,0,T,(t,e)=>t.compare(e))),T}function _e(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=r.aA.clone();for(let e=0,n=t.power();e<n;e++){const n=t.getElement(e);n.limitPrecisionThis(53),n.gt(s)&&s.setThis(n)}return s.divThis(e),s.addThis(r.aB),s.mulThis(r.M.constructDouble(1+100*Number.EPSILON)),s}function pe(t,e,s,n){let i=n;if(!t.isEmpty()){i=0;for(let e=0;e<n;++e)t.containsCoordinate(s[e].value())&&(i!==e&&s[i].setThis(s[e]),i++)}i>1&&(s[0].gt(s[1])&&(s[1]=(0,r.c)(s[0],s[0]=s[1])),i>2&&(s[0].gt(s[2])&&(s[2]=(0,r.c)(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=(0,r.c)(s[1],s[1]=s[2]))));for(let t=0;t<i;++t)s[t].limitPrecisionThis(e);return i}function fe(t,e,s,i,o,a){return function(t,e,s,i,o,a){if(s<e&&(0,n.a)("xTo < xFrom"),s===e)return 0;const h=[0];let m=Number.MAX_VALUE;const l=[Number.MAX_VALUE];let u=0;const c=(0,r.d)(33,Number.NaN),g=(0,r.d)(33,Number.NaN),d=[0];c[0]=1;let _=0,p=0;for(let r=0;r<32;r++){if(u=xe(e,s,i,0===r,u,d),g[r]=u,r+1>=t){Pe(r+1-t,t,c,g,0,h,l)||(0,n.d)("polynomial_interpolation");const e=o*Math.abs(h[0])+a,s=Math.abs(m-h[0]);if(s<=e&&Math.abs(l[0])<=e){if(_++,_>1&&(s<=.1*p||0===p||_>2))return h[0]}else _=0;p=s,m=h[0]}g[r+1]=g[r],c[r+1]=.25*c[r]}return h[0]}(t,e,s,a,i,o)}function xe(t,e,s,n,i,o){let a=i;if(n)return o[0]=1,a=.5*(e-t)*(s(t)+s(e)),a;const h=o[0],m=(e-t)/h,l=t,u=new r.K(0);for(let t=1;t<=o[0];++t){const e=(t-.5)*m;u.add(s(l+e))}return a=.5*(a+(e-t)*u.getResult()/h),o[0]*=2,a}function Pe(t,e,s,n,i,o,a){let h=0,m=Math.abs(i-s[t]);const l=(0,r.d)(e,Number.NaN),u=(0,r.d)(e,Number.NaN);for(let r=0;r<e;++r){const e=Math.abs(i-s[t+r]);e<m&&(h=r,m=e),l[r]=n[t+r],u[r]=n[t+r]}let c=0,g=0,d=0;o[0]=n[t+h],h--;for(let n=1;n<e;n++){for(let r=0;r<e-n;r++){if(g=s[t+r]-i,d=s[t+r+n]-i,c=g-d,0===c)return!1;const e=(l[r+1]-u[r])/c;l[r]=g*e,u[r]=d*e}if(2*(h+1)<e-n){const t=h+1;a[0]=l[t]}else{const t=h;a[0]=u[t],h--}o[0]+=a[0]}return!0}class ye{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let Ee=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ie(this.b,e,!1):0}getError(t){return(0,n.g)(0),0}};function Ce(t,e,s,n,i){let o=!0;const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=o?0:1,m=a[1][h]-a[0][h],l=a[2][h]-a[0][h];const u=fe(5,e,s,n,i,t=>{let e;if(t<=.5){const s=(0,r.af)(0,m,t),n=(0,r.af)(m,l,t);e=(0,r.af)(s,n,t)}else{const s=(0,r.ag)(0,m,t),n=(0,r.ag)(m,l,t);e=(0,r.ag)(s,n,t)}return e*Ae(a,1,t).length()});o=!1,h=o?0:1,m=a[1][h]-a[0][h],l=a[2][h]-a[0][h];const c=fe(5,e,s,n,i,t=>{let e;if(t<=.5){const s=(0,r.af)(0,m,t),n=(0,r.af)(m,l,t);e=(0,r.af)(s,n,t)}else{const s=(0,r.ag)(0,m,t),n=(0,r.ag)(m,l,t);e=(0,r.ag)(s,n,t)}return e*Ae(a,1,t).length()});return new r.P(u,c)}function ve(t){t.m_cachedValues=null}function Se(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ye;return be(t,e.specialPoints),Fe(t,e),e}function be(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const n=(0,r.m)(r.X,8);n[0].set(0);let i=1;{const t=(0,r.m)(r.X,3);!function(t,e,s=!1){const n=new r.X(t[1][0]).subE(new r.X(t[0][0]));e[1]=n.mul(2),e[2]=new r.X(t[2][0]).subE(new r.X(t[1][0])).subE(n),s?e[0].set(0):e[0].set(t[0][0])}(s,t,!1);const e=(0,r.m)(r.X,2),o=new r.E(0,1);let a=Vt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.a8)(e[t].value(),0,1)||(n[i]=e[t],i++)}{const t=(0,r.m)(r.X,3);!function(t,e,s=!1){const n=new r.X(t[1][1]).subE(new r.X(t[0][1]));e[1]=n.mul(2),e[2]=new r.X(t[2][1]).subE(new r.X(t[1][1])).subE(n),s?e[0].set(0):e[0].set(t[0][1])}(s,t,!1);const e=(0,r.m)(r.X,2),o=new r.E(0,1);let a=Vt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.a8)(e[t].value(),0,1)||(n[i]=e[t],i++)}if(n[i].set(1),i++,i>2){(0,r.aa)(n,0,i,(t,e)=>t.value()-e.value());let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),e.length=i;for(let t=0;t<i;t++)e[t]=n[t].value()}function Ie(t,e,s){const n=(0,r.m)(r.P,3);return t.queryControlPoints(n),De(n,e,s)}function De(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+De(t,1,!1)}if(1===e)return we(t);const n=(0,r.m)(r.P,3);return Be(t,e,n,null),we(n)}function we(t){if(t[0].equals(t[1]))return r.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return r.P.distance(t[0],t[2]);const e=r.P.distance(t[0],t[1])+r.P.distance(t[2],t[1]),s=r.P.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const n=(0,r.m)(r.P,3);Ze(t,n,!0);const i=4*((0,r.a)(n[2].x)+(0,r.a)(n[2].y)),o=2*(n[2].x*n[1].x+n[2].y*n[1].y),a=(0,r.a)(n[1].x)+(0,r.a)(n[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(i))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*(Math.pow(1*o+a,1.5)-Math.pow(a,1.5));const h=o/i,m=a/i,l=m-h*h,u=1+h;if(0===l)return h>=0&&u>=0||h<=0&&u<=0?Math.abs(.5*Math.sqrt(i)*(u*u-h*h)):.5*Math.sqrt(i)*(u*u+h*h);const c=Math.sqrt(l+u*u),g=Math.sqrt(m);return.5*Math.sqrt(i)*(u*c-h*g+l*Math.log(Math.abs((u+c)/(h+g))))}function Te(t,e){const s=(0,r.s)(e,0,1);let n=Ae(t,1,s);return n.isZero()&&(n=Ae(t,2,s)),n}function Ne(t,e,s){const n=(0,r.m)(r.P,3);return t.queryControlPoints(n),Ae(n,e,s)}function Ae(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):r.P.construct(0,0)}function Ge(t){const e=(0,r.m)(r.P,3);return t.queryControlPoints(e),qe(e)}function qe(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Me(t){return t.m_cachedValues}function Fe(t,e){t.m_cachedValues=e}function Xe(t,e,s,i,o){(0,n.D)(r.E.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=Number.MAX_VALUE;const m=[0],l=Ve(a,e,m);if(s.containsCoordinate(m[0]))h=r.P.distance(e,l);else{m[0]=s.vmin,Ke(a,m[0],l),h=r.P.distance(l,e);const t=new r.P;Ke(a,s.vmax,t);const n=r.P.distance(t,e);h>n&&(l.setCoordsPoint2D(t),m[0]=s.vmax,h=n)}if(!i)return m[0];if(s.vmin<=0){const n=new r.P;t.queryCoord2DExtended(-1,n,!0);const i=new r.P;t.queryCoord2D(s.vmin,i);const o=new Xr({start:n,end:i}),a=o.getClosestCoordinate(e,!0);if(a<1){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=a-1,l.assign(t))}}if(s.vmin>=1){const n=new r.P;t.queryCoord2DExtended(2,n,!0);const i=new r.P;t.queryCoord2D(s.vmax,i);const o=new Xr({start:i,end:n}),a=o.getClosestCoordinate(e,!0);if(a>0){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=1+a,l.assign(t))}}return m[0]}function Ve(t,e,s){const n=t[2].sub(t[1]).sub(t[1].sub(t[0])),i=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(i),h=o.dotProduct(n)+2*i.dotProduct(i),m=3*i.dotProduct(n),l=n.dotProduct(n),u=(0,r.d)(3,Number.NaN),c=Gt(l,m,h,a,r.E.unit(),!1,u),g=t[0].clone();let d=0,_=r.P.sqrDistance(t[0],e),p=r.P.sqrDistance(t[2],e);p<_&&(d=1,g.assign(t[2]),_=p);for(let s=0;s<c;s++){const n=new r.P;Ke(t,u[s],n),p=r.P.sqrDistance(n,e),p<_&&(_=p,g.assign(n),d=u[s])}return s&&(s[0]=d),g}function Ye(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const n=(0,r.m)(r.P,3);He(t,e.vmin,e.vmax,n),s.setFromPoints(n,3)}function Re(t,e,s){s.setEmpty();const n=[];n.push(new r.E(0,1));const i=.5*Math.max(e.width(),e.height());for(;n.length;){const o=n.at(-1);n.pop();const a=new c;if(Ye(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=i||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();n.push(r.E.construct(o.vmin,t)),n.push(r.E.construct(t,o.vmax))}}}}function ke(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Le(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Le(t){let e=!1;for(let s=0;s<2;s++){const n=(0,r.a4)(t[0][s],t[2][s]);n>0?((0,r.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?((0,r.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Be(t,e,s,n){(new r.P).setCoordsPoint2D(t[0]),(new r.P).setCoordsPoint2D(t[1]),(new r.P).setCoordsPoint2D(t[2]);const i=new r.P,o=new r.P,a=new r.P;if((0,r.Q)(t[0],t[1],e,i),(0,r.Q)(t[1],t[2],e,o),(0,r.Q)(i,o,e,a),s&&(s[0].assign(t[0]),s[1].assign(i),s[2].assign(a)),n){const e=t[2];n[0].assign(a),n[1].assign(o),n[2].assign(e)}}function He(t,e,s,n){if(e===s){const s=new r.P;return Ke(t,e,s),n[0]=s,n[1]=s,void(n[2]=s)}const i=(0,r.m)(r.P,3);Be(t,s,i,null),Be(i,e/s,null,i),Ke(t,e,i[0]),Ke(t,s,i[2]),n[0].setCoordsPoint2D(i[0]),n[1].setCoordsPoint2D(i[1]),n[2].setCoordsPoint2D(i[2])}function ze(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==Oe(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Ue(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==We(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Oe(t,e,s,i,o,a,h,m,l,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,h);if(n>0){if(null!==o)for(let e=0;e<n;e++)o.push(t[e]);if(null!==a)for(let t=0;t<n;t++)a.push(0);if(null!==i)for(let s=0;s<n;s++){const n=new r.P;e.queryCoord2D(t[s],n),i.push(n)}}return n}const c=Y(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Xr({start:e.getStartXY(),end:e.getEndXY()}),n=ot(t,s,i,o,a,h,m,u);if(o)for(let s=0;s<n;++s){const n=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(n,!1)}return n}if(R(e,s,h))return 0;const g=x.constructPoint2D(s.getStartXY()),d=x.constructPoint2D(s.getEndXY()).sub(g),_=d.clone();_.leftPerpendicularThis();const p=x.constructPoint2D(e.m_cp).sub(x.constructPoint2D(e.getStartXY())),f=x.constructPoint2D(e.getEndXY()).sub(x.constructPoint2D(e.m_cp));let P=p.dotProduct(_).toDouble(),y=f.sub(p).dotProduct(_).toDouble();const E=(0,r.d)(12,Number.NaN),C=(0,r.d)(12,Number.NaN);let v=function(t,e,s,n){const i=new r.X,o=Vt(new r.X(t),new r.X(e),s,i);return n[0]=i.value(),o}(y,P,r.E.unit(),E);v<0&&(E[0]=0,E[1]=1,v=2);let S,b=0;for(let t=0,n=b;t<v;++t){const i=e.getCoord2D(E[t+n]);C[b]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(C[b]))<=h&&(E[b]=E[t+n],b++)}const I=(0,r.m)(r.P,3);e.queryControlPoints(I);{const t=(0,r.m)(x,3);if(Qe(I,t,!1),t[0]=t[0].sub(g),d.x.abs().gte(d.y.abs())){const e=d.y.div(d.x);y=t[2].y.sub(t[2].x.mul(e)).toDouble(),P=t[1].y.sub(t[1].x.mul(e)).toDouble(),S=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=d.x.div(d.y);y=t[2].x.sub(t[2].y.mul(e)).toDouble(),P=t[1].x.sub(t[1].y.mul(e)).toDouble(),S=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const D=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),w=[0,0];v=At(y,P,S,r.E.unit(),D,w);for(let t=0,n=b;t<v;++t){E[t+n]=w[t];const i=e.getCoord2D(E[t+n]);C[b]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(C[b]))<=h&&(E[b]=E[t+n],b++)}(0,n.g)(b<E.length+4),v=e.intersectPoint(s.getStartXY(),w,h);for(let t=0;t<v;t++)E[b]=w[t],C[b++]=0;v=e.intersectPoint(s.getEndXY(),w,h);for(let t=0;t<v;t++)E[b]=w[t],C[b++]=1;v=s.intersectPoint(e.getStartXY(),w,h);for(let t=0;t<v;t++)C[b]=w[t],E[b++]=0;v=s.intersectPoint(e.getEndXY(),w,h);for(let t=0;t<v;t++)C[b]=w[t],E[b++]=0;return 0===b?0:Gr(t,e,s,E,C,b,i,o,a,h,m,0,u)}function We(t,e,s,n,i,o,h,m,l,u){if(Ji(s))return Oe(t,e,new Xr({start:s.getStartXY(),end:s.getEndXY()}),n,i,o,h,m,0,u);const c=Y(e,s);if(R(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,3);{e.queryControlPoints(_);const t=(0,r.m)(r.P,3),n=new a.T;s.canonicToWorldTransformation(n);const i=new a.T;i.setInvert(n),i.transformPoints2D(_,3,t);const o=(0,r.m)(x,3);Qe(t,o);const l=[o[0].x,o[1].x,o[2].x],u=[o[0].y,o[1].y,o[2].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2]=c[0],c[2].mul(c[1]),c[2].negate();const p=ee(l,2,u,2,null,0,c,0,r.E.unit(),r.E.unit(),g,m);if(p>0){let t=0;for(let n=0;n<p;n++){const i=new r.P;e.queryCoord2D(g[n],i);const o=s.getClosestCoordinate(i,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(i,a)<=h&&(g[t]=g[n],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),n=[0];Ve(_,e,n);const i=new r.P;Ke(_,n[0],i),r.P.distance(e,i)<=h&&(g.push(n[0]),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,2];{const n=s.getClosestCoordinate(_[e[t]],!1),i=new r.P;s.queryCoord2D(n,i),r.P.distance(_[e[t]],i)<=h&&(g.push(p[t]),d.push(n))}}return Gr(t,e,s,g,d,g.length,n,i,o,h,m,0,u)}function je(t,e,s,n,i,o,a,h,m,l){const u=(0,r.m)(r.P,3);e.queryControlPoints(u);const g=(0,r.m)(r.P,3);if(s.queryControlPoints(g),k(u,g,3)<0)return je(t,s,e,n,o,i,a,h,m,!l);const d=Y(e,s);if(R(e,s,a=Math.max(a,d)))return 0;if(function(t,e,s,n,i,o,a,h,m){const l=(0,r.m)(r.P,3);t.queryControlPoints(l);const u=(0,r.m)(r.P,3);if(e.queryControlPoints(u),l[0].equals(u[0])){if(l[1].equals(u[1])&&l[2].equals(u[2]))return s&&(s.length=0,s.push(l[0]),s.push(l[2])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!l[0].equals(u[2]))return!1}return!!(l[0].equals(u[2])&&l[1].equals(u[1])&&l[2].equals(u[0]))&&(n&&(n.length=0,n.push(0),n.push(1),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[2]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,n,i,o,0,0,0,l))return 2;const _=new r.E(0,1),p=new r.E(0,1);{const t=new c;Ye(u,r.E.unit(),t);const e=new c;Ye(g,r.E.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Re(u,t,_),Re(g,t,p),_.isEmpty()||p.isEmpty())return 0;He(u,_.vmin,_.vmax,u),He(g,p.vmin,p.vmax,g)}}const f=Mr(u,2,g,2,a);if(0===f)return 0;const P=[],y=[];if(-1===f){const t=(0,r.m)(x,3);Qe(u,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],n=(0,r.m)(x,3);Qe(g,n);const i=te(e,2,s,2,null,0,[n[0].x,n[1].x,n[2].x],2,[n[0].y,n[1].y,n[2].y],2,null,0,0,r.E.unit(),r.E.unit(),P,y,l,0,l);if(i>0){let t=0;for(let e=0;e<i;e++){const s=new r.P,n=new r.P;Ke(g,y[e],n),Ke(u,P[e],s),r.P.distance(s,n)<=a&&(P[t]=P[e],y[t]=y[e],t++)}P.length=t,y.length=t}}for(let t=0;t<2;t++){const e=0===t?u:g,s=0===t?g:u;for(let n=0;n<2;n++){const i=0===n?0:2,o=[0];Ve(s,e[i],o);const h=new r.P;Ke(s,o[0],h),r.P.distance(e[i],h)<=a&&(0===t?(P.push(0===i?0:1),y.push(o[0])):(y.push(0===i?0:1),P.push(o[0])))}}if(0===P.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=Qt.recalculateParentT(_.vmin,_.vmax,P[t]);if(!p.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=Qt.recalculateParentT(p.vmin,p.vmax,y[t]);return Gr(t,e,s,P,y,P.length,n,i,o,a,h,0,l)}function Ze(t,e,s=!1){const n=t[1].sub(t[0]);e[1].assign(n.mul(2)),e[2].assign(t[2].sub(t[1]).sub(n)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Qe(t,e,s=!1){const n=x.constructPoint2D(t[1]),i=n.sub(x.constructPoint2D(t[0]));e[1]=i.mul(r.M.constructInt32(2)),e[2]=x.constructPoint2D(t[2]).sub(n).sub(i),e[0]=s?new x(r.aA,r.aA):x.constructPoint2D(t[0])}function Ke(t,e,s,n){if(n){if(e<0)return void $(new Xr({start:t[0],end:t[0].add(Te(t,0).getUnitVector())}),e,s);if(e>1)return void $(new Xr({start:t[2],end:t[2].add(Te(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const n=t[1].clone(),i=new r.P;(0,r.am)(2,t[0],n,e,i);const o=new r.P;(0,r.am)(2,n,t[2],e,o);const a=new r.P;(0,r.am)(2,i,o,e,a),s.assign(a)}else{const n=t[1].clone(),i=new r.P;(0,r.an)(2,t[0],n,e,i);const o=new r.P;(0,r.an)(2,n,t[2],e,o);const a=new r.P;(0,r.an)(2,i,o,e,a),s.assign(a)}}const $e=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Je=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ts=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],es=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],ss=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],ns=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function is(t,e,s,n){const i=.5*(n-s),o=s+i,a=new r.K(0);for(let s=0,n=Math.trunc(t/2);s<n;++s){let n,h;switch(t){case 4:n=$e[s][0],h=$e[s][1];break;case 8:n=Je[s][0],h=Je[s][1];break;case 16:n=ts[s][0],h=ts[s][1];break;case 32:n=es[s][0],h=es[s][1];break;case 64:n=ss[s][0],h=ss[s][1];break;case 128:n=ns[s][0],h=ns[s][1];break;default:throw new Error("Quadrature_integral: invalid n")}const m=(0,r.aF)(-i,n,o),l=(0,r.aF)(i,n,o);a.pe(e(m)*h),a.pe(e(l)*h)}return a.getResult()*i}class rs extends vt{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Vr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Vr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Vr):t.envelope?(0,n.t)("envelope constructor not impl"):(0,n.d)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Vr)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return wt(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return rs.type}getDimension(){return 2}createInstance(){return new rs({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}rs.type=n.G.enumPolygon;var os=i.V;const as=-1;class hs{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}class ms{constructor(t){!function(t){return void 0!==t.parent}(t)?(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom):(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==as;){for(;this.m_path!==as;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==as)return this.m_vertex;if(this.m_bOneGeom)return as;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===as)break;this.m_bSkipMultiPoints&&!(0,n.h)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return as}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==as&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return as}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==as?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==as&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):as}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,n,i,r,o,a,h){return new ms({parent:t,geometry:e,path:s,vertex:n,firstVertex:i,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class ls{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class us{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,s=this.m_indices.length;t<s;t++){if(t===this.m_selectionIndex)continue;const s=this.m_indices[t];null!==s&&s.size()>e&&s.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,1),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,n){this.m_hasForceSetEnvelope=0;const i=e!==as?this.getPrevVertex(e):this.getLastVertex(t),r=i!==as?this.getNextVertex(i):as,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByValNoCurves(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,i),r!==as&&this.setPrevVertex(r,o),i!==as&&this.setNextVertex(i,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===as&&this.setLastVertex(t,o),e===m&&(h&&n&&m!==as||this.setFirstVertex(t,o)),h&&r===as&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const l=this.getGeometryFromPath(t);return this.setGeometryVertexCount(l,this.getPointCount(l)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new i.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(n.G.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const n=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let e=0,i=s.getPathCount();e<i;e++){if(0===s.getPathSize(e))continue;const i=this.insertPath(t,as);this.setClosedPath(i,s.isClosedPath(e));for(let t=s.getPathStart(e),r=s.getPathEnd(e);t<r;t++){const e=this.insertVertex_(i,as,null,!1);if(n){const n=this.getVertexIndex(e);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(n,null);else{const e=new Vr;s.querySegment(t,e,!0),this.setSegmentToIndex(n,e.releaseSegment())}}}s.isStrongPathStart(e)&&this.setStrongPathStart(i,!0),s.isStrongPathEnd(e)&&this.setStrongPathEnd(i,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===n.G.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const n=e.getImpl(),i=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),r=new o.Envelope2D;e.queryEnvelope(r);{const r=s.clone();let o=n.getPointCount();const a=n.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(r,0,n.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;const s=n.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,l=0,u=-1,c=as,g=!1,d=s.nextSegment();if(null!==d)for(;;d=s.nextSegment()){let r=null===d;const o=null!==d?s.getPathIndex():a,_=null!==d?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?l++:r=!0),r){if(-1!==u){let t=-1,s=-1;if(l===m){this.setClosedPath(c,g);const i=n.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i-u),this.m_verticesMp.addPoints(e,u,i),s=n.getPathSize(a),t=i-1}else if(!g||h+1<n.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp.addPoints(e,u,h+2),s=h-u+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp?.addPoints(e,u,h+1),t=h,s=h-u+1;const i=n.getPathStart(a);this.m_verticesMp.addPoints(e,i,i+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=u;e<s;e++,r++){const e=this.insertVertex_(c,as,null,!1);if(i){const s=this.getVertexIndex(e);if(1&n.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Vr;n.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;l=1,u=_,a!==o?(c=this.insertPath(t,as),this.setClosedPath(c,!1),m=n.getSegmentCountPath(o),g=n.isClosedPath(o),a=o):c=this.insertPath(t,as)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const i=e.getImpl(),a=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),h=o.Envelope2D.constructEmpty();e.queryEnvelope(h),(0,n.g)(s.isIntersecting(h)&&!s.containsEnvelope(h));let m=o.Envelope2D.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),l=o.Envelope2D.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const u=i.getAccelerators();if(u&&u.getQuadTree()){const t=u.getQuadTree(),e=t.getIntersectionCount(m,0,0);e>t.getIntersectionCount(l,0,e+1)&&(l=(0,r.c)(m,m=l))}else m.height()>l.width()&&(l=(0,r.c)(m,m=l));const c=[],g=i.queryLimitedSegmentIterator(m);let d=-1,_=-100,p=-1,f=0,x=-1,P=-1,y=as,E=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let s=null===C;const h=null!==C?g.getPathIndex():d,m=null!==C?g.getStartPointIndex():_;if(s||(h===d?_+1===m?f++:s=!0:(s=d>=0,d<0&&(d=h,p=i.getSegmentCountPath(d),x=m,y=as,f=1))),s){if(0!==c.length||p!==f){0!==c.length&&c[0].first===x||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,x,x+1),-1===P&&(P=x),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(y,as,null,!1));for(const{first:s,second:r}of c){-1===P&&(P=s);let o=-1,h=-1;const m=s+r-1;if(r===p){const t=m+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m,(0,n.g)(1===c.length)}else if(m+1<i.getPathEnd(d)){const t=m+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m}else{const t=i.getPathStart(d),n=t!==P?1:0,r=m+1;h=r-s+n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+n),this.m_verticesMp.addPoints(e,s,r),o=m,n>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(y,as,null,!1);if(a){const s=this.getVertexIndex(t);if(1&i.getSegmentFlags(e)||e>o)this.setSegmentToIndex(s,null);else{const t=new Vr;i.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===c.length||c.at(-1).first+c.at(-1).second!==x+f){let t=x+f;t===e.getPathEnd(d)&&(t=e.getPathStart(d)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(y,as,null,!1))}}c.length=0,E=!0,h!==d&&(d=h,p=i.getSegmentCountPath(d),y=as,P=-1),x=m,f=1}if(!C)break;{const t=o.Envelope2D.constructEmpty();C.queryLooseEnvelope(t),l.isIntersecting(t)?(E?c.push((0,r.l)(m,1)):c.at(-1).second++,E=!1):E=!0}_=m}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const i=e.getGeometryType()===n.G.enumPolygon,r=o.Envelope2D.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?i?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const n=this.insertPath(t,as);this.insertVertex_(n,as,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,as);for(let t=0,n=e.getPointCount();t<n;t++)this.insertVertex_(s,as,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const n=e.getAttributeStreamRef(0);let i=0;for(let t=0,r=e.getPointCount();t<r;t++){const e=n.readPoint2D(2*t);s.contains(e)&&i++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i);let r=-1,o=-1,a=0;for(let t=0,i=e.getPointCount();t<i;t++){const i=n.readPoint2D(2*t);s.contains(i)?(-1===r&&(r=t,o=t),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i);const h=this.insertPath(t,as);for(let t=0,i=e.getPointCount();t<i;t++){const e=n.readPoint2D(2*t);s.contains(e)&&this.insertVertex_(h,as,null,!1)}}splitSegmentForward(t,e,s,i,r){const o=this.getNextVertex(t);o===as&&(0,n.a)("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,i=e.getResultSegmentCount(s);t<i;t++){const u=this.getVertexIndex(m),c=this.getNextVertex(m),g=e.getResultSegment(s,t);let d=null;if(g.getGeometryType()!==n.G.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),r)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),l){const n=e.getResultSegmentSegmentParentage(s,t),i=e.getResultSegmentStartPointIsBreak(s,t);this.setSegmentParentageAndBreak(m,n,i)}if(g.queryEnd(a),t<i-1){this.setSegmentToIndex(u,d);const n=this.insertVertex(h,c,a);this.setWeight(n,e.getResultSegmentEndPointWeight(s,t)),this.setRank(n,e.getResultSegmentEndPointRank(s,t)),this.select(n),m=n}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),r);const n=e.getResultSegmentEndPointIsBreak(s,t);this.setSegmentParentageBreakVertex(o,n),this.setSegmentToIndex(u,d)}}}splitSegmentBackward(t,e,s,i,r){const o=this.getNextVertex(t);o===as&&(0,n.a)("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,i=e.getResultSegmentCount(s);t<i;t++){const u=i-t-1,c=this.getVertexIndex(m),g=this.getNextVertex(m),d=e.getResultSegment(s,u);let _=null;if(d.getGeometryType()!==n.G.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(a),this.setSegmentToIndex(c,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,u),e.getResultSegmentEndPointWeight(s,u),r),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))),d.getGeometryType()===n.G.enumLine?this.setSegmentToIndex(c,null):this.setSegmentToIndex(c,_),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,u)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,u)),d.queryStart(a),t<i-1){const t=this.insertVertex(h,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(s,u)),this.setRank(t,e.getResultSegmentStartPointRank(s,u)),this.select(t),m=t,l&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,u),e.getResultSegmentStartPointWeight(s,u),r)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,i.$)(0,-1):(0,i.$)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,i.$)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const n=this.getNextVertex(t),i=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,i),this.setPrevVertex(i,t),this.setNextVertex(e,n),this.setPrevVertex(n,e),this.m_segments){const t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),n=this.getSegmentParentage(t);-1===s&&-1===n||(n=(0,r.c)(s,s=n),this.setSegmentParentageAndBreak(t,n),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,as,n,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,i);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return as}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,(t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const n=this.getPathInternalIndexFromVertex(t),i=this.getPathInternalIndexFromVertex(e);s=n<i?-1:n>i?1:0}return s})}sortVerticesSimpleByYHelper3D(t,e,s){(0,n.g)(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=i.q.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=r.P.getNAN(),this.m_workPoint2_2D=r.P.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=as,this.m_lastGeometry=as,this.m_vertexIndexList=new i.S(5),this.m_pathIndexList=new i.S(8),this.m_geometryIndexList=new i.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new i.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.Envelope2D(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=o.Envelope2D.constructEmpty(),n=this.queryVertexIterator();let i=!0;for(let t=n.next();t!==as;t=n.next()){if(i?s.merge(this.getXY(t)):s.mergeNe(this.getXY(t)),e){const e=this.getSegment(t);if(null!==e){const t=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}i=!1}return s}getEnvelope3D(t){return(0,n.g)(0),i.q.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,n.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if((0,n.h)(s))return this.addMultiPath(t,e);if(s===n.G.enumMultiPoint)return this.addMultiPoint(t,e);if(s===n.G.enumPoint)return this.addPoint_(t,e);if(s===n.G.enumEnvelope){const s=new rs;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}(0,n.a)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());const s=e.getGeometryType();(0,n.h)(s)?this.appendMultiPath(t,e):s!==n.G.enumMultiPoint?(0,n.a)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);const s=this.queryVertexIterator();for(let t=s.next();t!==as;t=s.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(n.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=as,s=-1,i=-1;for(let r=this.getFirstGeometry();r!==as;){if(t===n.G.enumUnknown||this.getGeometryType(r)===t){if(e===as){e=r,s=this.getPathCount(e),i=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let t=this.getFirstPath(r);t!==as;t=this.getNextPath(t))this.setPathGeometry(t,e);s+=this.getPathCount(r),i+=this.getPointCount(r);const t=this.getLastPath(e),n=this.getFirstPath(r);t!==as?this.setNextPath(t,n):this.setFirstPath(e,n),n!==as&&(this.setPrevPath(n,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,as),this.setLastPath(r,as);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return e!==as&&(this.setGeometryVertexCount(e,i),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),n=this.getGeometryFromPath(s);this.setGeometryModified(n,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),n=this.getFirstPath(e),i=this.getLastPath(t),r=this.getLastPath(e);for(let s=this.getFirstPath(t);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,e);for(let s=this.getFirstPath(e);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,t);this.setFirstPath(t,n),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,i);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const l=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,l)}addPathFromMultiPath(t,e,s){const i=this.createGeometry(s?n.G.enumPolygon:n.G.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return i;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(i,as);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let t=r.getPathStart(e),s=r.getPathEnd(e);t<s;t++){const e=this.insertVertex_(o,as,null,!1);if(a){const s=this.getVertexIndex(e);if(1&r.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{const e=new Vr;r.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),i}getGeometry(t){const e=this.getGeometryType(t),s=function(t,e){let s,r=e,o=null;switch(r||(o=(0,n.j)(t)?(0,i.O)():(0,i.K)(),r=o),t){case n.G.enumPoint:s=new i.P({vd:r});break;case n.G.enumLine:s=new Xr({vd:r});break;case n.G.enumBezier:s=new vn({vd:r});break;case n.G.enumEllipticArc:s=new Ni({vd:r});break;case n.G.enumRationalBezier2:s=new jt({vd:r});break;case n.G.enumBezier2:s=new Qt({vd:r});break;case n.G.enumEnvelope:s=new i.E({vd:r});break;case n.G.enumMultiPoint:s=new Z({vd:r});break;case n.G.enumPolyline:s=new bt({vd:r});break;case n.G.enumPolygon:s=new rs({vd:r});break;case n.G.enumMultipatch:(0,n.t)("multipatch not impl");break;case n.G.enumGeometryCollection:s=new l({vd:r});break;default:(0,n.a)("Geometry.create")}return s}(e,this.m_verticesMp.getDescription()),r=this.getPointCount(t);if(0===r)return s;if((0,n.h)(e)){const e=s.getImpl(),n=this.getPathCount(t),o=(0,i.$)(n+1),a=(0,i.a0)(n+1,0),h=s.getDescription(),m=this.hasCurves();for(let s=0,m=h.getAttributeCount();s<m;s++){const m=h.getSemantics(s),l=os.getComponentCount(m),u=(0,i.Y)(m,r),c=this.m_vertices.getAttributeStreamRef(m);let g=0,d=0,_=0;for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&a.setBits(d,t);const s=this.getPathSize(e);if(o.write(d++,_),_+=s,0===m){const t=c,s=u;let n;for(let i=this.getFirstVertex(e);g<_;i=this.getNextVertex(i),g++){const e=this.getVertexIndex(i);n=t.readPoint2D(2*e),s.writePoint2D(2*g,n)}}else for(let t=this.getFirstVertex(e);g<_;t=this.getNextVertex(t),g++){const e=this.getVertexIndex(t);for(let t=0;t<l;t++){const s=c.readAsDbl(e*l+t);u.writeAsDbl(g*l+t,s)}}}e.setAttributeStreamRef(m,u),o.write(n,r)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),m){let s=0,n=0;for(let i=this.getFirstPath(t);i!==as;i=this.getNextPath(i)){s+=this.getPathSize(i);for(let t=this.getFirstVertex(i);n<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(n,s,!0),n++}}}}else if(e===n.G.enumMultiPoint){const e=s.getImpl(),n=s.getDescription();e.reserve(r),e.resizeNoInit(r);for(let s=0,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=os.getComponentCount(i),o=e.getAttributeStreamRef(i),a=this.m_vertices.getAttributeStreamRef(i);let h=0;const m=this.getFirstPath(t),l=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<l;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(i,o)}e.notifyModifiedFlags(65535)}else(0,n.d)("getGeometry");return s}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==n.G.enumMultiPoint&&(0,n.a)("get_point_geometry_only");const s=this.getPointCount(t);if(s>1&&(0,n.a)("get_point_geometry_only"),0===s)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();const i=this.getFirstPath(t),r=this.getFirstVertex(i);this.queryPoint(r,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==as;e=this.removePath(e));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==as?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==as?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=(0,i.K)());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new Z({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===as?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const n=this.m_geometryIndices[e],i=this.getGeometryIndex(t);i>=n.size()&&n.resize(Math.max(1.25*i,16),-1),n.write(i,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),n=this.m_geometryIndices[e];return s<n.size()?n.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,i.$)(0),t;this.m_geometryIndices.push((0,i.$)(0));const t=this.m_geometryIndices.length-1;return(0,n.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))if(!(0,n.h)(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,s,i,o){const a=t*t;let h=0;const m=this.hasCurves(),l=this.hasSegmentParentage(),u=!0;for(let t=o===as?this.getFirstGeometry():o;t!==as;t=o===as?this.getNextGeometry(t):as){const o=this.getGeometryType(t);if(!(0,n.h)(o))continue;if(s&&o!==n.G.enumPolygon)continue;const c=this.getGeometryType(t)===n.G.enumPolygon;let g=this.getGeometryModified(t);for(let s=this.getFirstPath(t);s!==as;){let o=0;for(let e=this.getFirstVertex(s);o<Math.trunc(this.getPathSize(s)/2);){const c=this.getNextVertex(e);if(c===as)break;const d=this.getXY(e),_=this.getXY(c);let p=r.P.sqrDistance(d,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,c!==this.getLastVertex(s)){const s=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(c));if(this.transferAllDataToTheVertex(c,e,u),this.removeVertex(c,!1),i&&!g&&(this.setGeometryModified(t,!0),g=!0),l&&e!==c){this.setSegmentParentageBreakVertex(e,s);const t=this.getNextVertex(e);(0,n.g)(t!==as),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}f=!1}}while(0);f&&(e=this.getNextVertex(e)),o++}let d=this.getFirstVertex(s);for(let e=this.isClosedPath(s)?d:this.getLastVertex(s);this.getPathSize(s)>0;){const o=this.getPrevVertex(e);if(o===as)break;{const c=this.getXY(o),_=this.getXY(e);let p=r.P.sqrDistance(c,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(o);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,l){(0,n.g)(this.m_segmentParentageIndex>=0);const t=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(o,e,u),this.setUserIndex(e,this.m_segmentParentageIndex,t)}else this.transferAllDataToTheVertex(o,e,u);const r=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(o));this.removeVertex(o,!0),i&&!g&&(this.setGeometryModified(t,!0),g=!0),l&&o!==e&&(r||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),d===o&&(d=this.getFirstVertex(s)),f=!1}}while(0);if(f&&(e=this.getPrevVertex(e),e===d))break}}const _=this.getPathSize(s);let p=e&&_<(c?3:2);p&&c&&2===_&&m&&(p=!this.pathHasCurves(s)),p?(s=this.removePath(s),0===h&&(h=-1),i&&!g&&(this.setGeometryModified(t,!0),g=!0)):s=this.getNextPath(s)}}return h}filterClosePoints3D(t,e,s,i,r,o){return(0,n.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==as;e=this.getNextGeometry(e))if((0,n.h)(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==as;){const e=this.getPathSize(s);if(0===e)return!0;let n=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(n);if(e===as)break;const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);let r=0;if(null!==i){if(r=i.calculateLowerLength2D(),r<=t){if(r=i.calculateUpperLength2D(),r<=t)return!0;if(r=i.calculateLength2D(),r<=t)return!0}}else{const n=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,n),r<=t)return!0}n=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return(0,n.g)(0),!1}transferAllDataToTheVertex(t,e,s=!1){const n=this.getVertexIndex(t),i=this.getVertexIndex(e);if(s){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(n),e=this.getRankWithIndex(i)),t>e&&this.setRankWithIndex(i,t),t>=e&&this.m_weights){const s=this.getWeightWithIndex(n),r=this.getWeightWithIndex(i);(t>e||s>r)&&this.setWeightWithIndex(i,s)}}else{if(this.m_weights){const t=this.getWeightWithIndex(n);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(n);this.setRankWithIndex(i,t)}}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(n);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(n);this.setSegmentRankWithIndex(i,t)}for(let s=0,n=this.m_indices.length;s<n;s++)if(s!==this.m_selectionIndex&&null!==this.m_indices[s]){const n=this.getUserIndex(t,s);this.setUserIndex(e,s,n)}const r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,i,r){let o=0;const a=this.getNextVertex(t);a===as&&(0,n.a)("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),l=this.getSegmentFromIndex(h);let u=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&l&&(u=l.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(l){let t=0,n=0,r=as;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=l.cut(t,s);if(null!==i&&(p>0&&e.setStartXY(i[p-1]),e.setEndXY(i[p]),e.normalizeAfterEndpointChange(),n=p),g){const t=u>0?l.calculateSubLengthFromStart(s)/u:0;this.m_vertices.interpolateTwoVertices(h,m,t,_)}_.setXY(e.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==d&&this.setSegmentParentageAndBreak(r,d,!1),t=s}}if(r!==as){const e=l.cut(t,1);null!==i&&(e.setStartXY(i[n]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(r);this.setSegmentToIndex(s,e)}}else{let t=0;for(let n=0;n<s;n++){const s=e[n];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(h,m,s,_);const t=this.insertVertex(c,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=s}}return o}splitSegment(t,e,s,n=null){return this.splitSegmentAxisAware(t,e,s,n,-1)}snapControlPoints(t,e,s){this.getNextVertex(t)===as&&(0,n.a)("");let i=t,r=!1;for(let t=0;t<e;++t){const t=this.getVertexIndex(i),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(s);r||=t}i=this.getNextVertex(i)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let n=s.next();n!==as;n=s.next()){const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);i&&(e|=i.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return(0,n.g)(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const n=this.getVertexIndex(t),i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!==n&&(n.setEndXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone())}}}setPointEx(t,e,s,n,i){this.setPoint(t,e,i);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,n),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(s,e)}setPointOnlyEx(t,e,s,i){(0,n.g)(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXYCoords(e,s),i.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!=n&&(n.setEndXYCoords(e,s),n.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);if(null!==i){const t=i.getEndXY();i.setCoordsForIntersector(new r.P(e,s),t,!1),i.ensureXYMonotone()}const o=this.getPrevVertex(t);if(o!==as){const t=this.getVertexIndex(o),n=this.getSegmentFromIndex(t);if(null!==n){const t=n.getStartXY();n.setCoordsForIntersector(t,new r.P(e,s),!1),n.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){(0,n.g)(0)}setXYZ(t,e,s){(0,n.g)(0)}setXYZCoords(t,e,s,i){(0,n.g)(0)}queryXYZ(t,e){(0,n.g)(0)}getXYZ(t){return(0,n.g)(0),i.d.getNAN()}getXYZWithIndex(t){return(0,n.g)(0),i.d.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,n.g)(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,i){(0,n.g)(0)}setAttribute(t,e,s,i){(0,n.g)(0)}setAttributeInt(t,e,s,i){(0,n.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,n.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return(0,n.g)(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=(0,i.a1)(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_weights.size()){if(s)return;this.m_weights.resize(n+1,1)}this.m_weights.write(n,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=(0,i.a1)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return 1;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,i.$)(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(n+1,1)}this.m_ranks.write(n,e)}setRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,i.$)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,i.a1)(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(n+1,1)}this.m_segmentWeights.write(n,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,i.a1)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return us.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?us.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,i.$)(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(n+1,1)}this.m_segmentRanks.write(n,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,i.$)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);if(n.size()<=i){if(-1===s)return;n.resize(this.m_vertices.getPointCount(),-1)}n.write(i,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),n=this.m_indices[e];return s<n.size()?n.read(s):-1}addToUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);n.size()<=i&&n.resize(this.m_vertices.getPointCount(),-1);const r=n.read(i);n.write(i,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return(0,n.g)(t>=0&&t<=(0,r.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return(0,n.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const n=this.m_indices[e],i=n.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let r=0,o=this.getPathSize(e);r<o;r++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<i&&n.write(e,s)}}}fillUserIndexForSelection(t,e){(0,n.g)(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const n=this.getNextVertex(t);if(n===as)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const i=this.getXY(n);e.setEndXY(i)}else{const s=new i.P({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(n,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return(0,n.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,n.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===as)return!1;const s=this.getPathSize(t);let i=e;for(let t=0;t<s;t++,i=this.getNextVertex(i)){const t=this.getSegment(i);if(null!==t&&t.getGeometryType()!==n.G.enumLine)return!0}return!1}insertPath(t,e){let s=as;e!==as?(t!==this.getGeometryFromPath(e)&&(0,n.a)(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const i=this.newPath(t);return e!==as&&this.setPrevPath(e,i),this.setNextPath(i,e),this.setPrevPath(i,s),s!==as?this.setNextPath(s,i):this.setFirstPath(t,i),e===as&&this.setLastPath(t,i),this.setGeometryPathCount(t,this.getPathCount(t)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);return e!==as?this.setNextPath(e,s):this.setFirstPath(n,s),s!==as?this.setPrevPath(s,e):this.setLastPath(n,e),this.clearPath(t),this.setGeometryPathCount(n,this.getPathCount(n)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==as){let s=e;for(let e=0,n=this.getPathSize(t);e<n;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const n=this.getGeometryFromPath(t);this.setGeometryVertexCount(n,this.getPointCount(n)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),n=this.getLastVertex(t);if(e){this.setNextVertex(n,s),this.setPrevVertex(s,n);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}else{this.setNextVertex(n,as),this.setPrevVertex(s,as);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){(0,n.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===as)return 0;const s=this.getXY(e),i=new r.K(0),o=this.getPathSize(t);if(o>2){const t=s.clone(),n=t.x,a=t.y;let h=this.getNextVertex(e);const m=this.getXY(h);h=this.getNextVertex(h);const l=r.P.getNAN();for(let e=2;e<o;e++,h=this.getNextVertex(h))this.queryXY(h,l),i.pe((l.x-t.x)*(m.y-a)),t.setCoordsPoint2D(m),m.setCoordsPoint2D(l);i.pe((n-t.x)*(m.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===n.G.enumLine)continue;const s=2*e.calculateArea2DHelper();i.pe(s)}}this.setRingAreaValid(t,!0);const a=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const n=this.m_pathindices[e],i=this.getPathIndex(t);n.size()<this.m_pathAreas.length&&n.resize(this.m_pathAreas.length,-1),n.write(i,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),n=this.m_pathindices[e];return s<n.size()?n.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return(0,n.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const n=this.m_pathindices[e],i=n.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){const t=this.getPathIndex(e);t<i&&n.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===as&&(0,n.a)(""),e===s)return;const i=this.getNextPath(s);let r=this.getPrevPath(s);const o=this.getGeometryFromPath(s);r===as?this.setFirstPath(o,i):this.setNextPath(r,i),i===as?this.setLastPath(o,r):this.setPrevPath(i,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(s)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=e===as?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,r),this.setNextPath(s,e),e===as?this.setLastPath(t,s):this.setPrevPath(e,s),r===as?this.setFirstPath(t,s):this.setNextPath(r,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,as,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),i=this.getNextVertex(t);n!==as&&this.setNextVertex(n,i);const r=this.getPathSize(s);if(t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?i:as),i!==as&&this.setPrevVertex(i,n),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?n:as),this.hasCurves()&&n!==as&&i!==as){const s=this.getVertexIndex(t),r=this.getVertexIndex(n),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),i}removeVertices(t,e){(0,n.g)(t!==e);const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),r=this.getPrevVertex(e);i!==as&&this.setNextVertex(i,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,i),this.setPrevVertex(t,as),this.setNextVertex(r,as);let h=0,m=t;const l=this.getFirstVertex(s);let u=!1;for(;;){const t=this.getNextVertex(m);if(u||=l===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,u&&this.setFirstVertex(s,o>0?e:as),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,as,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,n.d)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,n=this.getPathSize(e);s<n;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=as){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=as){let s=as,i=as,r=as,o=as,a=0,h=!1;for(s=e!==as?e:this.getFirstGeometry();s!==as;s=this.getNextGeometry(s))if(!t||(0,n.h)(this.getGeometryType(s))){for(i=this.getFirstPath(s);i!==as;i=this.getNextPath(i))if(r=this.getFirstVertex(i),o=r,a=0,r!==as){h=!0;break}if(h||e!==as)break}return h||(s=as),ms.create_(this,s,i,r,o,a,t,!1,e!==as)}queryVertexIteratorOnSelection(t=as){return this.m_selection?ms.create_(this,t,as,as,as,-1,!1,!0,t!==as):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,n.g)(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=as,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return(0,n.g)(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,n,i){n?this.splitSegmentForward(t,e,s,!0,i):this.splitSegmentBackward(t,e,s,!0,i)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;const e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,s=!0,n=!1){const i=this.getNextVertex(t);if(i===as)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),n),!0);if(e.copyFrom(r,!0),n)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(i,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return(0,n.g)(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let n=null,i=-1,r=t;if(e){const t=this.getVertexIndex(r);n=this.getAndClearSegmentFromIndex(t)}s&&(i=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);n&&n.reverse(),this.setSegmentToIndex(t,n),n=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,i),i=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);e!==as?this.setNextPath(e,s):this.setFirstPath(n,s),s!==as?this.setPrevPath(s,e):this.setLastPath(n,e),this.setFirstVertex(t,as),this.setLastVertex(t,as),this.freePath(t)}insertClosedPath(t,e,s,n,i){const r=this.insertPath(t,as);let o=0,a=s;for(i[0]=!1;;){a===n&&(i[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),i[0]&&(s=n),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return(0,n.g)(0),0}findVertex3D(t,e,s){return(0,n.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let s=t;for(let t=0;t<e;++t)if(s=e>0?this.getNextVertex(s):this.getPrevVertex(s),s===as)return as;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),n=this.getNextVertex(t);if(s!==as&&this.setNextVertex(s,n),n!==as&&this.setPrevVertex(n,s),this.hasCurves()&&s!==as&&n!==as){const i=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{const t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),n}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,n.g)(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new hs(this))}sortVerticesSimpleByX(t,e,s){(0,n.g)(0)}sortVerticesSimpleByY3D(t,e,s){(0,n.g)(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==as&&this.replaceCurveWithLine(s),this.getNextVertex(t)!==as&&this.replaceCurveWithLine(t);const n=new r.P;this.queryXY(t,n),n.y=e,this.setXY(t,n)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,n.g)(e<=(0,r.j)()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,n.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,n.g)(e<=(0,r.j)()>>1),e<<=1,e|=this.getSegmentParentageBreakVertex(t)?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new ls(e)}return new ls(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=(0,r.j)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);return e!==as&&this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function cs(t){if(t.isEmpty())return new rs({vd:t.getDescription()});if((0,n.h)(t.getGeometryType())&&t.hasNonLinearSegments())return function(t){(0,n.g)(t.hasNonLinearSegments()&&!t.isEmpty());const e=new fs;return e.addGeometry(t),e.getBoundingGeometry()}(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new i.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new i.P,s=new bt({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const o=e.getAttributeStreamRef(0),a=new fs({stream:o,n:s});let h=1;const m=o.readPoint2D(0),l=new r.P;for(;h<s&&o.queryPoint2D(h<<1,l).equals(m);)h++;if(a.m_treeHull.addElement(0),h<s){a.m_treeHull.addBiggestElement(h);const t=new r.P;for(let s=h+1;s<e.getPointCount();s++){o.queryPoint2D(s<<1,t);const e=a.treeHull(t);-1!==e&&a.m_treeHull.setElement(e,s)}}const u=e.getDescription(),c=u.getAttributeCount()>1,g=a.m_treeHull.size();let d=null;if(g>=2){d=g>=3?new rs({vd:u}):new bt({vd:u});const t=d.getImpl();t.reserve(a.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new r.P;for(let n=a.m_treeHull.getFirst();-1!==n;n=a.m_treeHull.getNext(n))if(c){const s=new i.P;e.getPointByVal(a.m_treeHull.getElement(n),s),t.insertPoint(0,-1,s)}else o.queryPoint2D(a.m_treeHull.getElement(n)<<1,s),t.insertPoint2D(0,-1,s)}else if(c){const t=new i.P({vd:u});e.getPointByVal(a.m_treeHull.getElement(a.m_treeHull.getFirst()),t),d=t}else{const t=o.readPoint2D(a.m_treeHull.getElement(a.m_treeHull.getFirst())<<1);d=new i.P(t)}return d}function gs(t,e,s,n=!1){if(e<=262144)return function(t,e,s,n){const r=new i.A(0);for(let t=0;t<e;t++)r.add(t);const o={userSort(e,s,n){n.sort(e,s,(e,s)=>t[e].compareX(t[s]))},getValue:e=>t[e].x};n||i.B.sortEx(r,0,e,o);let a=0;t:for(let n=0;n<e;++n){const e=r.read(n);for(;a>=2;){const i=s[a-2],o=s[a-1];if(t[o].equals(t[e])){r.write(n,-1);continue t}if(!(xs(t[i],t[o],t[e])>=0)){o===r.read(n-1)&&r.write(n-1,-1);break}a--}s[a++]=e,2===a&&t[e].equals(t[s[0]])&&(r.write(1,-1),a--)}const h=a+1;t:for(let n=e-2;n>=0;--n){const e=r.read(n);if(!(e<0)){for(;a>=h;){const n=s[a-2],i=s[a-1];if(t[i].equals(t[e]))continue t;if(!(Ps(t[n],t[i],t[e])>=0))break;a--}if(0!==n){const n=s[a-1];s[a++]=e,t[e].equals(t[n])&&a--}}}return a>1&&t[s[0]].equals(t[s[a-1]])&&a--,a}(t,e,s,n);const r=new fs({points:t,n:e});let o=1;const a=t[0];for(;o<e&&t[o].equals(a);)o++;if(r.m_treeHull.addElement(0),o<e){r.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],n=r.treeHull(e);-1!==n&&r.m_treeHull.setElement(n,s)}}let h=0;for(let t=r.m_treeHull.getFirst();-1!==t;t=r.m_treeHull.getNext(t))s[h++]=r.m_treeHull.getElement(t);return h}function ds(t,e,s){if((e<0||e>=t.getPathCount())&&(0,n.a)("path index"),t.hasNonLinearSegmentsPath(e))return!1;const i=t.getImpl(),o=i.getPathStart(e),a=i.getPathEnd(e),h=!i.isClosedPath(e)&&i.isClosedPathInXYPlane(e),m=i.getAttributeStreamRef(0),l=2*o;let u=2*a;if(h&&(u-=2),u-l<6)return!0;const c=m.readPoint2D(l),g=m.readPoint2D(l+2),d=m.readPoint2D(l+4);if(!ys(r.P.orientationRobust(g,d,c)))return!1;const _=g.clone(),p=new r.P;for(let t=l+6;t<u;t+=2){if(p.assign(g),g.assign(d),m.queryPoint2D(t,d),!ys(r.P.orientationRobust(g,d,c)))return!1;if(!ys(r.P.orientationRobust(_,d,c)))return!1;if(!ys(r.P.orientationRobust(g,d,p)))return!1}return!0}function _s(t,e,s,i,o){if(function(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}(s,i,o),t.isEmpty())return;if(t.getGeometryType()===n.G.enumPoint)return void s.assign(t.getXY());const a=t,h=a.getPointCount();0!==h&&(1!==h?function(t,e,s,n,i,o){if(2===e){const e=t.getXY(0),s=t.getXY(1);n.assign(e.add(s).mul(.5));const r=s.sub(e);i=vs(r),o.setCoords(.5*r.length(),0)}else{let a=Number.MAX_VALUE;const h=[0,1,0,0],m=new r.ab(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);h[0]<e;++h[0],Ss(m,0,e)){h[1]===h[0]&&(++h[1],Ss(m,1,e));for(let s=1;;++s){for(;;){const n=bs(t.getXY(m.get(0,0)),t.getXY(m.get(0,1)),t.getXY(m.get(s,0)),t.getXY(m.get(s,1)),2^s);if(n>0)break;if(++h[s],Ss(m,s,e),0===n)break}if(3===s)break;h[s+1]<h[s]&&(h[s+1]=h[s],m.set(s+1,0,m.get(s,0)),m.set(s+1,1,m.get(s,1)))}const l=t.getXY(m.get(0,0)).add(t.getXY(m.get(2,0))).mul(.5),u=vs(t.getXY(m.get(0,1)).sub(t.getXY(m.get(0,0)))),c=new r.P;let g,d;if(c.x=Math.max(0,u.dotProduct(t.getXY(m.get(1,0)).sub(t.getXY(m.get(3,0))))),c.y=Math.max(0,u.crossProduct(t.getXY(m.get(0,0)).sub(t.getXY(m.get(2,0))))),s?(g=c.x*c.y,d=g<a):(g=c.y,d=g<a),d){a=g;const e=t.getXY(m.get(1,0)),s=t.getXY(m.get(3,0)),r=e.add(s).mul(.5).sub(l);n.assign(l.add(u.mul(u.dotProduct(r)))),i.assign(u),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,r.c)(o.x,o.x=o.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}(a,h,e,s,i,o):s.assign(a.getXY(0)))}us.st_defaultRank=1;class ps{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,n.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,n.g)(0),!1}get_vertex_handle_p(){return(0,n.g)(0),0}get_vertex_handle_q(){return(0,n.g)(0),0}get_current_support(){return(0,n.g)(0),0}getNext(t){return(0,n.g)(0),0}getPrev(t){return(0,n.g)(0),0}intialize_(){return(0,n.g)(0),!1}increment_(){return(0,n.g)(0),!1}increment_q_(){return(0,n.g)(0),!1}increment_p_(){return(0,n.g)(0),!1}parallel_edge_with_q_support_(){return(0,n.g)(0),!1}parallel_edge_with_p_support_(){return(0,n.g)(0),!1}done_(){return(0,n.g)(0),!1}}class fs{nullGetXY(t){return(0,n.d)("m_getXY is null"),{}}nullDeleteNode(t){(0,n.d)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new i.T,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):void(0,n.p)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new us,this.m_geometryHandle=this.m_shape.createGeometry(n.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,as),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,n.g)(0),new r.P}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){(0,n.g)(0)}addGeometry(t){if(t.isEmpty())return;const e=t.getGeometryType();if(e===n.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else(0,n.i)(e)?this.addMultiVertexGeometry(t):(0,n.f)(e)?this.addSegment(t,!1):e===n.G.enumEnvelope?this.addEnvelope(t):e===n.G.enumPoint?this.addPoint(t):(0,n.a)("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new i.P,e=this.m_treeHull.getFirst(),s=new rs({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let n=this.m_treeHull.getNext(e);-1!==n;n=this.m_treeHull.getNext(n))this.m_shape.queryPoint(this.m_treeHull.getElement(n),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return(0,n.g)(0),new ps(this)}getXY(t){return(0,n.g)(0),new r.P}getXYWithIndex(t){return(0,n.g)(0),new r.P}getFirst(){return(0,n.g)(0),0}getLast(){return(0,n.g)(0),0}getNext(t){return(0,n.g)(0),0}getPrev(t){return(0,n.g)(0),0}getVertexIndex(t){return(0,n.g)(0),0}getPointCount(){return(0,n.g)(0),0}addMultiVertexGeometry(t){const e=new i.P,s=t.getImpl(),o=new r.P;for(let n=0;n<t.getPointCount();n++){s.queryXY(n,o);const i=this.addPoint2D(o);if(-1!==i){t.getPointByVal(n,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}}if((0,n.h)(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments()){const t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){const e=new i.P;for(let s=0;s<4;s++){const n=new r.P;t.queryCorner(s,n);const i=this.addPoint2D(n);if(-1!==i){t.queryCornerByVal(s,e);const n=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,n)}}}static querySegmentControlPoints(t,e,s){const o=t.getGeometryType();if((0,n.g)(o!==n.G.enumLine),o===n.G.enumEllipticArc){const s=t,n=60*Math.PI/180,o=Math.abs(s.getSweepAngle());if(o>n){const t=Math.min(6,Math.ceil(o/n)),a=1/t,h=new Vr;s.queryStart(e[0]);let m=1;for(let n=0;n<t;n++){s.queryCut(n*a,(n+1)*a,h);const o=(0,r.m)(r.P,3);gr(h.get(),o);const l=r.P.calculateLength(o,3),u=r.P.calculateLength(o,2),c=l>0?u/l:.5;n<t-1?h.get().queryEnd(e[m+1]):s.queryEnd(e[m+1]),i.P.lerp(e[m-1],e[m+1],c,e[m]),e[m].setXY(o[1]),m+=2}return m}{const s=(0,r.m)(r.P,3);gr(t,s);const n=r.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);const o=r.P.calculateLength(s,2),a=n>0?o/n:.5;return i.P.lerp(e[0],e[2],a,e[1]),e[1].setXY(s[1]),3}}if(o===n.G.enumBezier){const s=t,n=(0,r.m)(r.P,4);s.queryControlPoints(n);const o=r.P.calculateLength(n,4),a=r.P.calculateLength(n,2),h=r.P.calculateLength(n,3);t.queryStart(e[0]),t.queryEnd(e[3]);const m=o>0?a/o:.5;i.P.lerp(e[0],e[3],m,e[1]),e[1].setXY(n[1]);const l=o>0?h/o:.5;return i.P.lerp(e[0],e[3],l,e[2]),e[2].setXY(n[2]),4}if(o===n.G.enumBezier2){const s=t,n=(0,r.m)(r.P,3);s.queryControlPoints(n);const o=r.P.calculateLength(n,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(n,2),h=o>0?a/o:.5;return i.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(n[1]),3}if(o===n.G.enumRationalBezier2){const s=t,n=(0,r.m)(r.P,3);s.queryControlPoints(n);const o=r.P.calculateLength(n,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(n,2),h=o>0?a/o:.5;return i.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(n[1]),3}(0,n.a)("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new i.P,s=t.getStartXY(),n=this.addPoint2D(s);if(-1!==n){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,s)}const r=t.getEndXY(),o=this.addPoint2D(r);if(-1!==o){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,s)}}if(t.isCurve()){const e=(0,r.m)(i.P,13);for(let s=1,n=fs.querySegmentControlPoints(t,e,e.length)-1;s<n;++s){const t=e[s].getXY(),n=this.addPoint2D(t);if(-1!==n){const t=this.m_shape.addPoint(this.m_pathHandle,e[s]);this.m_treeHull.setElement(n,t)}}}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),n=this.m_shape.getXY(s);return t.equals(n)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),n=this.m_treeHull.getLast(),i=this.m_treeHull.getElement(s),o=this.m_treeHull.getElement(n),a=this.m_getXY(i),h=this.m_getXY(o),m=r.P.orientationRobust(h,t,a);if(ys(m)){e=this.m_treeHull.addBiggestElement(-1);const i=this.treeHullWalkBackward(t,n,s);i!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(i));break}if(Es(m)){let i=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),h=this.m_treeHull.getLast(),m=-1,l=-1,u=-1;for(;o!==this.m_treeHull.getPrev(h);){l=this.m_treeHull.getElement(i);const e=this.m_getXY(l);Es(r.P.orientationRobust(e,t,a))?(h=i,i=this.m_treeHull.getLeft(i)):(o=i,i=this.m_treeHull.getRight(i))}i=h,m=o,l=this.m_treeHull.getElement(i),u=this.m_treeHull.getElement(m);const c=this.m_getXY(l),g=this.m_getXY(u);if(m!==s&&!ys(r.P.orientationRobust(g,t,c)))break;e=this.m_treeHull.addElementAtPosition(m,i,-2,!0,!1),this.treeHullWalkForward(t,i,n),this.treeHullWalkBackward(t,m,s);break}{const i=Cs(t,h,a);if(-1===i){const i=this.m_treeHull.getPrev(n);this.m_treeHull.deleteNode(n),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,i,s)}else if(1===i){const i=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,i,-3,!0,!1),this.treeHullWalkForward(t,i,n)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),o=this.m_treeHull.getNext(n);const a=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(s,t,a)))break;const h=n;n=o,i=e,a.assign(s),o=this.m_treeHull.getNext(n),this.m_deleteNode(h)}return n}treeHullWalkBackward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),o=this.m_treeHull.getPrev(n);const a=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(a,t,s)))break;const h=n;n=o,i=e,a.assign(s),o=this.m_treeHull.getPrev(n),this.m_deleteNode(h)}return n}}function xs(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x>0?-1:0;if(0===n.y)return i.y>0?1:i.y<0?-1:0;const o=n.crossProduct(i),a=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function Ps(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x<0?-1:0;if(0===n.y)return i.y>0?-1:i.y<0?1:0;const o=n.crossProduct(i),a=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function ys(t){return t<0}function Es(t){return t>0}function Cs(t,e,s){let n=-1;n=e.y===s.y?0:e.x===s.x?1:Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1;let i=-1;return i=e[n]<s[n]?t[n]<e[n]?-1:s[n]<t[n]?1:0:e[n]<t[n]?-1:t[n]<s[n]?1:0,i}function vs(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function Ss(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function bs(t,e,s,i,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,n.a)("")}return r.P.orientationRobustEx(t,e,s,i)}class Is{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Ds(t){return function(t){return 256*(0,r.H)()*t}(t.calculateUpperLength2D())}function ws(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Ts(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),As(n,e,s)}function Ns(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),Gs(n,e,s)}function As(t,e,s){let n=t[1].x;n-=t[0].x,n*=3;let i=t[2].x;i-=t[1].x,i*=3;let r=t[3].x;r-=t[0].x,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].x)}function Gs(t,e,s){let n=t[1].y;n-=t[0].y,n*=3;let i=t[2].y;i-=t[1].y,i*=3;let r=t[3].y;r-=t[0].y,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].y)}function qs(t,e,s=!1){const n=(0,r.m)(x,4);n[0].assignPoint2D(t[0]),n[1].assignPoint2D(t[1]),n[2].assignPoint2D(t[2]),n[3].assignPoint2D(t[3]),e[1].setCoords(n[1].x.sub(n[0].x),n[1].y.sub(n[0].y)),e[1].mulThis(r.M.constructInt32(3)),e[2].setCoords(n[2].x.sub(n[1].x),n[2].y.sub(n[1].y)),e[2].mulThis(r.M.constructInt32(3)),e[3]=n[3].sub(n[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(r.aA,r.aA):e[0]=n[0].clone()}function Ms(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ms(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=Fs(t);if(n&&!Number.isNaN(i.length)&&!Number.isNaN(i.length))return i.length;const r=Ds(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,n=i.specialPointsCount();s<n;s++){const n=i.specialPoints[s];if(a+=Pn(t,h,Math.min(e,n),o,r),e<=n)break;h=n}return n&&(i.length=a),a}function Fs(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Is,s=(0,r.m)(r.X,8),n=(0,r.m)(r.P,4);t.queryControlPoints(n);const i=dn(n,s);e.specialPoints=[];for(let t=0;t<i;t++)e.specialPoints.push(s[t].value());return Vs(t,e),e}function Xs(t){let e=null;return e=t.m_cachedValues,e}function Vs(t,e){t.m_cachedValues=e}function Ys(t){t.m_cachedValues=null}function Rs(t,e,s,n){const i=(0,r.m)(r.P,4);t.queryControlPoints(i);const o=(0,r.d)(18,NaN),a=Nt(new ln(i,e,NaN),r.E.construct(s,n),18,o),h=new r.P;t.queryCoord2D(s,h);let m=s,l=r.P.distance(h,e);const u=new r.P;t.queryCoord2D(n,u);const c=r.P.distance(u,e);c<l&&(l=c,m=n,h.assign(u));for(let s=0;s<a;s++){t.queryCoord2D(o[s],u);const n=r.P.distance(u,e);n<l&&(l=n,m=o[s],h.assign(u))}return function(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}(s,n,m,l,h)}function ks(t,e){const s=(0,r.m)(r.X,4);Ts(t,s,!0);const i=(0,r.m)(r.X,4);Ns(t,i,!0);const o=s[3].clone(),a=s[2].clone(),h=s[1].clone(),m=i[3].clone(),l=i[2].clone(),u=i[1].clone(),c=a.mulE(h).addE(l.mulE(u)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(h).mul(12)).addE(l.mulE(l).mul(8).addE(m.mulE(u).mul(12))),d=o.mulE(a).addE(m.mulE(l)).mul(36),_=o.mulE(o).addE(m.mulE(m)).mul(36),p=(0,r.m)(r.X,3),f=Rt(_,d,g,c,new r.E(0,1),!1,p);if((0,n.g)(f<=3),f>0){const s=Bs(t,1,0).sqrLength(),n=Bs(t,1,1).sqrLength();let i=s;e.set(0),i<n&&(i=n,e.set(1));for(let s=0;s<f;s++){const n=Bs(t,1,p[s].value()).sqrLength();n<i&&(i=n,e=p[s])}}}function Ls(t,e,s){const n=new r.P;return function(t,e,s,n){if(1===e){const e=1-s,i=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(i).add(a.mul(2*e*s)).add(h.mul(r));n.assign(m.mul(3))}else if(2===e){const e=1-s,i=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=i.mul(e).add(r.mul(s));n.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);n.assign(s.mul(6))}else n.setCoords(0,0)}(t,e,s,n),n}function Bs(t,e,s){const n=(0,r.m)(r.P,4);return t.queryControlPoints(n),Ls(n,e,s)}function Hs(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),n=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),s.mulThis(3),n.subThis(s),s.subThis(e),(3*n.x*(2*s.y+5*e.y)-3*n.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function zs(t){const e=(0,r.m)(r.P,4);t.queryControlPoints(e);const s=Us(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Us(t){return y(t)}function Os(t,e,s){const n=new r.P,i=new r.P,o=new r.P,a=new r.P,h=new r.P;e<=.5?((0,r.am)(2,t[0],t[1],e,n),(0,r.am)(2,t[1],t[2],e,i),(0,r.am)(2,t[2],t[3],e,o),(0,r.am)(2,n,i,e,a),(0,r.am)(2,i,o,e,h),(0,r.am)(2,a,h,e,s)):((0,r.an)(2,t[0],t[1],e,n),(0,r.an)(2,t[1],t[2],e,i),(0,r.an)(2,t[2],t[3],e,o),(0,r.an)(2,n,i,e,a),(0,r.an)(2,i,o,e,h),(0,r.an)(2,a,h,e,s))}function Ws(t,e,s,i){(0,n.g)(e>=0&&e<=1);const o=new r.P,a=new r.P,h=new r.P,m=new r.P,l=new r.P,u=new r.P;e<=.5?((0,r.am)(2,t[0],t[1],e,o),(0,r.am)(2,t[1],t[2],e,a),(0,r.am)(2,t[2],t[3],e,h),(0,r.am)(2,o,a,e,m),(0,r.am)(2,a,h,e,l),(0,r.am)(2,m,l,e,u)):((0,r.an)(2,t[0],t[1],e,o),(0,r.an)(2,t[1],t[2],e,a),(0,r.an)(2,t[2],t[3],e,h),(0,r.an)(2,o,a,e,m),(0,r.an)(2,a,h,e,l),(0,r.an)(2,m,l,e,u));const c=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(o),s[2].assign(m),s[3].assign(u)),i&&(i[0].assign(u),i[1].assign(l),i[2].assign(h),i[3].assign(c))}function js(t,e,s,i){if((0,n.g)(e>=0&&s<=1&&e<=s),e===s){const s=new r.P;return Zs(t,e,s),i[0].assign(s),i[1].assign(s),i[2].assign(s),void i[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)i[e].assign(t[e]);return}const o=(0,r.m)(r.P,4);Ws(t,s,o,null),Ws(o,s>0?e/s:0,null,o),Zs(t,e,o[0]),Zs(t,s,o[3]),i[0].setCoordsPoint2D(o[0]),i[1].setCoordsPoint2D(o[1]),i[2].setCoordsPoint2D(o[2]),i[3].setCoordsPoint2D(o[3])}function Zs(t,e,s,n){if(n){if(e<0)return void $(new Xr({start:t[0],end:t[0].add(Qs(t,0).getUnitVector())}),e,s);if(e>1)return void $(new Xr({start:t[3],end:t[3].add(Qs(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const n=new r.P;(0,r.am)(2,t[0],t[1],e,n);const i=new r.P;(0,r.am)(2,t[1],t[2],e,i);const o=new r.P;(0,r.am)(2,t[2],t[3],e,o);const a=new r.P;(0,r.am)(2,n,i,e,a);const h=new r.P;(0,r.am)(2,i,o,e,h),(0,r.am)(2,a,h,e,s)}else{const n=new r.P;(0,r.an)(2,t[0],t[1],e,n);const i=new r.P;(0,r.an)(2,t[1],t[2],e,i);const o=new r.P;(0,r.an)(2,t[2],t[3],e,o);const a=new r.P;(0,r.an)(2,n,i,e,a);const h=new r.P;(0,r.an)(2,i,o,e,h),(0,r.an)(2,a,h,e,s)}}function Qs(t,e){const s=(0,r.s)(e,0,1);let n=Ls(t,1,s);return n.isZero()&&(n=Ls(t,2,s),n.isZero()?n=Ls(t,3,s):1===s&&n.negateThis()),n}function Ks(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){const n=[p.constructPoint2D(t[0]),p.constructPoint2D(t[1]),p.constructPoint2D(t[2]),p.constructPoint2D(t[3])],i=new p;return function(t,e,s,n){{const e=r.a6.subE(s),i=e.sqr(),o=s.sqr(),a=t[1].subE(t[0]).mulE(i).addE(t[2].subE(t[1]).mulE(new r.X(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(o));n.setE(a.mulE(new r.X(3)))}}(n,0,s,i),i}(t,0,e))}(n,e,s)}function $s(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==sn(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Js(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==nn(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function tn(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==on(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function en(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==an(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function sn(t,e,s,n,i,o,a,h,m,l){if(null!==i&&(i.length=0),null!=o&&(o.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0,0],h=e.intersectPoint(s.getStartXY(),t,a);if(h>0){if(null!==i)for(let e=0;e<h;e++)i.push(t[e]);if(null!==o)for(let t=0;t<h;t++)o.push(0);if(null!=n)for(let s=0;s<h;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return h}const u=Y(e,s);if(R(e,s,a=Math.max(a,u)))return 0;const c=(0,r.m)(r.P,4);ws(e,c);const g=s.getEndXY();g.subThis(s.getStartXY());const d=g.clone();d.leftPerpendicularThis();let _=3*c[3].dotProduct(d),p=2*c[2].dotProduct(d),f=c[1].dotProduct(d);const x=(0,r.d)(15,Number.NaN),P=(0,r.d)(15,Number.NaN);let y=At(_,p,f,r.E.unit(),!1,x);y<0&&(x[0]=0,x[1]=1,y=2);let E,C=0;for(let t=0,n=C;t<y;++t){const i=e.getCoord2D(x[t+n]);P[C]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+n],C++)}if(c[0].subThis(s.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;_=c[3].y-c[3].x*t,p=c[2].y-c[2].x*t,f=c[1].y-c[1].x*t,E=c[0].y-c[0].x*t}else{const t=g.x/g.y;_=c[3].x-c[3].y*t,p=c[2].x-c[2].y*t,f=c[1].x-c[1].y*t,E=c[0].x-c[0].y*t}const v=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),S=[0,0,0];y=Gt(_,p,f,E,r.E.unit(),v,S);for(let t=0,n=C;t<y;++t){x[t+n]=S[t];const i=e.getCoord2D(x[t+n]);P[C]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+n],C++)}y=e.intersectPoint(s.getStartXY(),S,a);for(let t=0;t<y;t++)x[C]=S[t],P[C++]=0;y=e.intersectPoint(s.getEndXY(),S,a);for(let t=0;t<y;t++)x[C]=S[t],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),S,a)&&(P[C]=S[0],x[C++]=0),0!==s.intersectPoint(e.getEndXY(),S,a)&&(P[C]=S[0],x[C++]=1),0===C?0:Gr(t,e,s,x,P,C,n,i,o,a,h,0,l)}function nn(t,e,s,n,i,o,h,m,l,u){if(Ji(s))return sn(t,e,new Xr({start:s.getStartXY(),end:s.getEndXY()}),n,i,o,h,m,0,u);const c=Y(e,s);if(R(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=[],p=(0,r.m)(r.P,4);{e.queryControlPoints(p);const t=(0,r.m)(r.P,4),n=new a.T;s.canonicToWorldTransformation(n);const i=new a.T;i.setInvert(n),i.transformPoints2D(p,4,t);const o=(0,r.m)(x,4);qs(t,o);const l=[o[0].x,o[1].x,o[2].x,o[3].x],u=[o[0].y,o[1].y,o[2].y,o[3].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2].setThis(c[0]),c[2].mulThis(c[1]),c[2].negateThis();const f=ee(l,3,u,3,null,0,c,0,r.E.unit(),r.E.unit(),d,m);if(f>0){let t=0;for(let n=0;n<f;n++){const i=new r.P;e.queryCoord2D(d[n],i);const o=s.getClosestCoordinate(i,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(i,a)<=h&&(g.push(i.clone()),d[t]=d[n],_.push(o),t++)}d.length=t,g.length=t}}const f=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),n=[0];un(p,e,r.E.unit(),!1,-1,1,n);const i=new r.P;Zs(p,n[0],i),r.P.distance(e,i)<=h&&(d.push(n[0]),_.push(f[t]),g.push(i.clone()))}for(let t=0;t<2;t++){const e=[0,3];{const n=s.getClosestCoordinate(p[e[t]],!1),i=new r.P;s.queryCoord2D(n,i),r.P.distance(p[e[t]],i)<=h&&(d.push(f[t]),_.push(n),g.push(i.clone()))}}return Gr(t,e,s,d,_,d.length,n,i,o,h,m,0,u)}function rn(t,e,s,i,o,a,h,m,l,u){const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,4);if(s.queryControlPoints(d),k(g,d,4)<0)return rn(t,s,e,i,a,o,h,m,l,!u);const _=Y(e,s);if(R(e,s,h=Math.max(h,_)))return 0;if(function(t,e,s,n,i,o,a,h,m){const l=(0,r.m)(r.P,4);t.queryControlPoints(l);const u=(0,r.m)(r.P,4);if(e.queryControlPoints(u),l[0].equals(u[0])){if(l[1].equals(u[1])&&l[2].equals(u[2])&&l[3].equals(u[3]))return s&&(s.length=0,s.push(l[0]),s.push(l[3])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!l[0].equals(u[3]))return!1}return!!(l[0].equals(u[3])&&l[1].equals(u[2])&&l[2].equals(u[1])&&l[3].equals(u[0]))&&(n&&(n.length=0,n.push(0),n.push(1),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[3]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,i,o,a,0,0,0,u))return 2;const p=new r.E(0,1),f=new r.E(0,1);{const t=new c;mn(g,new r.E(0,1),t);const e=new c;mn(d,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(pn(g,t,p),p.isEmpty())return 0;if(pn(d,t,f),f.isEmpty())return 0;js(g,p.vmin,p.vmax,g),js(d,f.vmin,f.vmax,d)}}const P=Mr(g,3,d,3,h);if(0===P)return 0;const y=[],E=[],C=[];let v=!1;if(-1===P){const t=(0,r.m)(x,4);qs(g,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=(0,r.m)(x,4);qs(d,n);const i=[],o=[],a=te(e,3,s,3,null,0,[n[0].x,n[1].x,n[2].x,n[3].x],3,[n[0].y,n[1].y,n[2].y,n[3].y],3,null,0,0,r.E.unit(),r.E.unit(),i,o,l);if(a>0)for(let t=0;t<a;t++){const e=new r.P;Zs(d,o[t],e);const s=new r.P;Zs(g,i[t],s),r.P.distance(s,e)<=h&&(y.push(s.clone()),C.push(o[t]),E.push(i[t]))}else-1===a&&(v=!0)}for(let t=0;t<2;t++){const e=0===t?g:d,s=0===t?d:g;for(let n=0;n<2;n++){const i=0===n?0:3,o=[0];un(s,e[i],r.E.unit(),!1,-1,1,o);const a=new r.P;Zs(s,o[0],a),r.P.distance(e[i],a)<=h&&(0===t?(E.push(0===i?0:1),C.push(o[0])):(C.push(0===i?0:1),E.push(o[0])),y.push(a.clone()))}}if(0===E.length&&v){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const i=[0,0];if(2===gn(t?e:s,i,!0)&&((0,n.g)(r.E.unit().containsCoordinate(i[0])),!r.E.unit().containsCoordinate(i[1]))){const e=new r.P;Zs(t?g:d,i[0],e);const s=[0,0];1===un(t?d:g,e,r.E.unit(),!1,-1,2,s)&&(y.push(e.clone()),E.push(t?i[0]:s[0]),C.push(t?s[0]:i[0]))}}}if(0===E.length)return 0;if(!p.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=vn.recalculateParentT(p.vmin,p.vmax,E[t]);if(!f.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=vn.recalculateParentT(f.vmin,f.vmax,C[t]);return Gr(t,e,s,E,C,E.length,i,o,a,h,m,0,u)}function on(t,e,s,i,o,a,h,m,l,u){const g=Y(e,s);if(s.isDegenerateToLineHelper(g)){const n=new Xr({start:s.getStartXY(),end:s.getEndXY()}),r=sn(t,e,n,i,o,a,h,m,0,u);if(a)for(let t=0;t<r;++t){const e=n.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(R(e,s,h=Math.max(h,g)))return 0;const d=(0,r.m)(r.P,4);e.queryControlPoints(d);const _=(0,r.m)(r.P,3);s.queryControlPoints(_);const p=new r.E(0,1),f=new r.E(0,1),P=[0,0,0];s.queryWeights(P);const y=[1,di(P),1];{const t=new c;mn(d,new r.E(0,1),t);const e=new c;jn(_,y,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(pn(d,t,p),p.isEmpty())return 0;if(gi(_,y,t,f),f.isEmpty())return 0;js(d,p.vmin,p.vmax,d),Jn(_,y,f.vmin,f.vmax,_,y)}}const E=Mr(d,3,_,2,h);if(0===E)return 0;const C=[],v=[],S=[];if(-1===E){const t=(0,r.m)(x,4);qs(d,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hi(_,y,n,i,o);const a=[],m=[],u=te(n,2,i,2,o,2,e,3,s,3,null,0,0,r.E.unit(),r.E.unit(),m,a,l);if(u>0)for(let t=0;t<u;t++){const e=new r.P;Zs(d,a[t],e);const s=new r.P;ci(_,y,m[t],s),r.P.distance(e,s)<=h&&(C.push(e.clone()),v.push(a[t]),S.push(m[t]))}}for(let t=0;t<2;t++){let e,s;0===t?(e=d,s=_):(s=d,e=_);for(let i=0;i<2;i++){const o=0===i?0:e.length-1,a=[0],m=new r.P;if(0===t){const t=On(s,y,e[o],r.E.unit(),!1,-1,1,a);(0,n.g)(1===t),ci(s,y,a[0],m)}else{const t=un(s,e[o],r.E.unit(),!1,-1,1,a);(0,n.g)(1===t),Zs(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(v.push(0===o?0:1),S.push(a[0])):(S.push(0===o?0:1),v.push(a[0])),C.push(m.clone()))}}if(0===v.length)return 0;if(!p.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=vn.recalculateParentT(p.vmin,p.vmax,v[t]);if(!f.equalsRange(0,1))for(let t=0;t<S.length;++t)S[t]=jt.recalculateParentT(f.vmin,f.vmax,S[t]);for(let t=0;t<S.length;++t)S[t]=_i(P,S[t]);return Gr(t,e,s,v,S,v.length,i,o,a,h,m,0,u)}function an(t,e,s,i,o,a,h,m,l,u){const c=Y(e,s);if(R(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);s.queryControlPoints(d);const _=Mr(g,3,d,2,h);if(0===_)return 0;const p=[],f=[],P=[];if(-1===_){const t=(0,r.m)(x,4);qs(g,t);const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,r.m)(x,3);Qe(d,o);const a=te([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,n,3,i,3,null,0,0,r.E.unit(),r.E.unit(),P,f,m);if(a>0){let t=0;for(let n=0;n<a;n++){const i=new r.P;e.queryCoord2D(f[n],i);const o=new r.P;s.queryCoord2D(P[n],o),r.P.distance(i,o)<=h&&(p.push(i.clone()),f[t]=f[n],P[t]=P[n],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=d):(s=g,e=d);for(let i=0;i<2;i++){const o=0===i?0:e.length-1,a=[0],m=new r.P;if(0===t)Ve(s,e[o],a),Ke(s,a[0],m);else{const t=un(s,e[o],r.E.unit(),!1,-1,1,a);(0,n.g)(1===t),Zs(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(f.push(0===o?0:1),P.push(a[0])):(P.push(0===o?0:1),f.push(a[0])),p.push(m.clone()))}}return Gr(t,e,s,f,P,f.length,i,o,a,h,m,0,u)}function hn(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),mn(n,e,s)}function mn(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const n=(0,r.m)(r.P,4);js(t,e.vmin,e.vmax,n),s.setFromPoints(n,4)}let ln=class{constructor(t,e,s){this.dbgCounter=0,this.controlPoints=t,this.point=e.clone(),this.maxDistance=s}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new r.P;Zs(this.controlPoints,e,t);const s=Ls(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new r.P;Zs(this.controlPoints,e,t);const s=Ls(this.controlPoints,1,e),n=Ls(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(n)+s.dotProduct(s))}case 2:{const t=new r.P;Zs(this.controlPoints,e,t);const s=Ls(this.controlPoints,1,e),n=Ls(this.controlPoints,2,e),i=Ls(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(i)+3*s.dotProduct(n))}case 3:{const t=Ls(this.controlPoints,1,e),s=Ls(this.controlPoints,2,e),n=Ls(this.controlPoints,3,e);return 2*(4*t.dotProduct(n)+3*s.sqrLength())}case 4:{const t=Ls(this.controlPoints,2,e),s=Ls(this.controlPoints,3,e);return 10*t.dotProduct(s)*2}case 5:{const t=Ls(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){const s=(0,r.m)(r.P,4);js(this.controlPoints,t,e,s);const n=new c;if(n.setFromPoints(s,4),Math.sqrt(n.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function un(t,e,s,o,a,h,m){(0,n.D)(r.E.unit().contains(s)&&h>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);const l=[],u=new r.P;Zs(t,s.vmin,u);let c=r.P.distance(u,e);if(c<=a&&l.push(new r.P(s.vmin,c)),s.vmin!==s.vmax&&(Zs(t,s.vmax,u),c=r.P.distance(u,e),c<=a&&l.push(new r.P(s.vmax,c))),s.width()>0){const n=(0,r.d)(18,Number.NaN),i=Nt(new ln(t,e,a),s,18,n);for(let s=0;s<i;s++)Zs(t,n[s],u),c=r.P.distance(u,e),c>a||l.push(new r.P(n[s],c))}if(o){(0,n.g)(s.equals(r.E.unit()));{Zs(t,-1,u,!0);const s=new r.P;Zs(t,0,s);const n=new Xr({start:u,end:s}),i=n.getClosestCoordinate(e,!0);i<1&&(u.assign(n.getCoord2D(i)),c=r.P.distance(u,e),c<=a&&l.push(new r.P(i-1,c)))}{Zs(t,2,u,!0);const n=new r.P;Zs(t,s.vmax,n);const i=new Xr({start:n,end:u}),o=i.getClosestCoordinate(e,!0);o>0&&(u.assign(i.getCoord2D(o)),c=r.P.distance(u,e),c<=a&&l.push(new r.P(1+o,c)))}}if(!l.length)return 0;l.sort((t,e)=>t.compare(e));let g=0;const d=l[0].x;if(m[g++]=d,g<h){const e=(0,i.a3)(t,4,!1).total(),s=l[0].y;for(let t=1,n=l.length;t<n;t++)if(l[t].y>s+e){l.length=t;break}l.sort((t,e)=>(0,r.R)(t.x,e.x)),g=0,m[g++]=l[0].x;for(let t=1,e=l.length;t<e;t++)l[t].x!==m[g-1]&&g<h&&(m[g++]=l[t].x)}return g}function cn(t,e,s,n,i,o,a){const h=(0,r.m)(r.P,4);return t.queryControlPoints(h),un(h,e,s,n,i,o,a)}function gn(t,e,s=!1){const n=(0,r.m)(r.P,4);t.queryControlPoints(n);const i=(0,r.m)(x,4);let o,a,h;qs(n,i,!0);const m=i[3].x.isZero(),l=i[3].y.isZero();if(m||l)if(m&&!l){if(i[2].x.isZero())return 0;o=i[1].x.div(i[2].x).negate(),a=i[2].y.div(i[3].y),h=i[1].y.div(i[3].y)}else{if(m||!l)return 0;if(i[2].y.isZero())return 0;o=i[1].y.div(i[2].y).negate(),a=i[2].x.div(i[3].x),h=i[1].x.div(i[3].x)}else{i[2].x.divThis(i[3].x),i[1].x.divThis(i[3].x),i[2].y.divThis(i[3].y),i[1].y.divThis(i[3].y);const t=i[2].x.sub(i[2].y);if(t.isZero())return 0;o=i[1].x.sub(i[1].y).div(t).negate(),a=i[2].x.clone(),h=i[1].x.clone()}if(!s&&o.abs().value()>2)return 0;const u=[0,0],c=t.getStartXY().equals(t.getEndXY()),g=At(1,-o.toDouble(),o.add(a).mul(o).add(h).toDouble(),r.E.unit(),c,u);if(0===g)return 0;if(u[0]>=0&&u[0]<=1){const t=o.toDouble()-u[0];if(s||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}if(2===g&&u[1]>=0&&u[1]<=1){const t=o.toDouble()-u[1];if(s||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}return 0}function dn(t,e){e[0].set(0);let s=1;const i=(0,r.m)(r.X,4);As(t,i,!0);const o=(0,r.m)(r.X,4);Gs(t,o,!0);{const t=i[3].mul(3),n=i[2].mul(2),o=i[1].clone(),a=(0,r.m)(r.X,2);let h=Yt(t,n,o,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.a8)(a[t].value(),0,1)||(e[s]=a[t],s++)}{const t=o[3].mul(3),n=o[2].mul(2),i=o[1].clone(),a=(0,r.m)(r.X,2);let h=Yt(t,n,i,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.a8)(a[t].value(),0,1)||(e[s]=a[t],s++)}if(s+=function(t,e,s){const n=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),i=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,r.m)(r.X,2);let h=Yt(o,i,n,new r.E(0,1),!1,a);h<0&&(h=0);let m=0;for(let t=0;t<h;t++)(0,r.a8)(a[t].value(),0,1)||(s[m].setE(a[t]),m++);return m}(i,o,e.slice(s)),e[s].set(1),s++,s>2){(0,r.aa)(e,0,s,(t,e)=>{const s=t.value(),n=e.value();return s<n?-1:s>n?1:0});let n=0;const i=e[0].clone();let o=0;const a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,r.H)(),h=new r.P;Os(t,e[0].value(),h);for(let m=1;m<s;m++){const s=new r.P;if(Os(t,e[m].value(),s),e[m].eq(i)||s.isEqualPoint2D(h,a)){if(0!==n){if(0===e[m].eps())i.setE(e[m]),o=0;else if(0!==o){const t=(0,r.a)(1/e[m].eps()),s=1/o,n=t+s;i.set((e[m].value()*t+i.value()*s)/n),o=1/n,i.setError(Math.sqrt(o))}e[n].setE(i),Os(t,i.value(),h)}}else n++,e[n].setE(e[m]),i.setE(e[m]),Os(t,i.value(),h),o=(0,r.a)(e[m].eps())}n++,s=n}return 1===s&&(s=2,e[1].set(1)),(0,n.g)(0===e[0].value()),(0,n.g)(1===e[s-1].value()),s}function _n(t,e,s,n){const i=(0,r.m)(r.P,s);for(let t=0;t<s;++t)i[t]=new r.P(t/(s-1),0);const o=(t,e,s,n)=>{const i=new r.X(e.x).subE(new r.X(t.x)).divE(new r.X(e.y).subE(new r.X(t.y))).mulE(new r.X(s).subE(new r.X(t.y))).addE(new r.X(t.x));if(i.eps()>.1){const n=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;i.set(n,(0,r.H)())}if(i.lt(new r.X(0))||i.gt(new r.X(1)))return!1;let o=i.value()-i.eps();o=(0,r.s)(o,0,1);let a=i.value()+i.eps();return a=(0,r.s)(a,0,1),n.mergeCoordinate(o),n.mergeCoordinate(a),!0},a=[];{const e=(t,e)=>{a.length=s;const n=gs(i,s,a,!0),h=new r.E;h.setEmpty();const m=s=>s.y<t?-1:s.y>e?1:0;let l=i[a[0]],u=m(l);0===u&&h.mergeCoordinate(l.x);for(let s=1;s<=n;++s){const r=i[a[s%n]],c=m(r);0===c&&h.mergeCoordinate(r.x);let g=0;c!==u&&(g=c*u===0?1===c||1===u?2:1:3,1&g&&o(l,r,t,h),2&g&&o(l,r,e,h)),l=r,u=c}return h};for(let e=0;e<s;++e)i[e].y=t[e].x;const h=e(n.xmin,n.xmax);if(h.isEmpty())return new r.E(h);for(let e=0;e<s;++e)i[e].y=t[e].y;const m=e(n.ymin,n.ymax);return h.intersect(new r.E(m)),new r.E(h)}}function pn(t,e,s){s.setEmpty(),s.merge(function(t,e,s,n){const i=_n(t,0,4,n.getEnvelope2D());if(i.isEmpty())return new r.E(i);const o=(0,r.m)(r.P,4);for(let e=0;e<4;++e)n.xyRot(t[e],o[e]);const a=_n(o,0,4,n.getRotatedEnvelope2D());return i.intersect(new r.E(a)),new r.E(i)}(t,0,0,e))}class fn{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ms(this.b,e,!1):0}getError(t){return 0}}function xn(t,e,s,i,o,a,h){for(;;){const m=r.P.distance(e[0],e[3]),l=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2])+r.P.distance(e[2],e[3]);if(l-m<=i+s*l)return t+(0,r.q)(m,l,.5);const u=t=>Ls(e,1,t).length();{(0,n.g)(h<12);let m=u(0),c=u(1);o[0]+=2,m>c&&(c=(0,r.c)(m,m=c),e[3]=(0,r.c)(e[0],e[0]=e[3]),e[2]=(0,r.c)(e[1],e[1]=e[2]));let g=m/(m+c),d=1,_=l;for(;g<1/32&&_>=32*(i+s*_);){d/=4;const t=u(d);o[0]++,g=m/(t+m);const s=new r.P;if(Zs(e,.5*d,s),_=r.P.distance(s,e[0]),_<=i){const t=new r.P;Zs(e,d,t),_+=r.P.distance(t,s)}}if(1!==d){const n=(0,r.m)(r.P,4);Ws(e,d,e,n),t=xn(t,n,s,i,o,0,h+1),a++,h++;continue}}const c=8;o[0]+=c;const g=is(c,u,0,1),d=16;o[0]+=d;const _=is(d,u,0,1);let p=Math.abs(g-_)>i+s*l;if(!p)return t+_;if(a<3){const n=(0,r.m)(r.P,4);Ws(e,.5,e,n),t=xn(t,n,s,i,o,a+1,h+1),a++,h++;continue}const f=32;o[0]+=f;const x=is(f,u,0,1);if(p=Math.abs(_-x)>i+s*l,!p)return t+x;const P=64;o[0]+=P;const y=is(P,u,0,1);if(p=Math.abs(x-y)>i+s*l,!p)return t+y;const E=128;o[0]+=E;const C=is(E,u,0,1);return p=Math.abs(y-C)>i+s*l,t+C}}function Pn(t,e,s,n,i){if(s===e)return 0;const o=(0,r.m)(r.P,4);t.queryControlPoints(o);const a=(0,r.m)(r.P,4);return js(o,e,s,a),xn(0,a,n,i,[0],0,0)}function yn(t,e,s,n,i){let o=!0;const a=fe(5,e,s,n,i,e=>{const s=Bs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});o=!1;const h=fe(5,e,s,n,i,e=>{const s=Bs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new r.P(a,h)}function En(t,e,s,i,o,a,h,m,l,u,c,g){(0,n.g)(u+2===g);let d=0,_=0,p=0,f=0,x=0,P=0,y=0;const E=(t,e)=>{const n=1-e,h=s.mul((0,r.aG)(n)),m=i.mul(3*e*n*n),l=o.mul(3*e*e*n),u=a.mul((0,r.aG)(e));return h.add(m).add(l).add(u).sub(c[t]).sqrLength()};for(let e=1,n=g-1;e<n;e++){let n=l[e-1];if(t){e>2?(n=(0,r.s)(2*l[e-2]-l[e-3],0,1),l[e-1]=n):2===e&&(n=(0,r.s)(2*l[e-2],0,1),l[e-1]=n);const t=(t,e,n)=>{let h=-1;for(let m=0;!(Math.abs(e-h)<1e-12)&&10!==m;m++){const m=e*e,l=1-e,u=l*l,g=u*l,d=s.x-2*i.x+o.x,_=s.x-3*i.x+3*o.x-a.x,p=s.y-2*i.y+o.y,f=s.y-3*i.y+3*o.y-a.y,x=s.x-i.x-2*d*e+_*m,P=-c[t].x+s.x*g+e*(3*i.x*u+e*(3*o.x*l+a.x*e)),y=s.y-i.y-2*p*e+f*m,E=-c[t].y+s.y*g+e*(3*i.y*u+e*(3*o.y*l+a.y*e)),C=-6*(x*P+y*E),v=6*(3*(0,r.a)(x)-(-2*d+2*_*e)*P)+6*(3*(0,r.a)(y)-(-2*p+2*f*e)*E);if(h=e,0===v)break;e=(0,r.s)(e-C/v,n,1)}return h};{const s=E(e,l[e-1]);let n=t(e,l[e-1],0),i=E(e,n);if(1.01*s<i){const s=e>1?l[e-2]:0,r=t(e,.3*(l[e-1]-s)+s,0),o=E(e,r);o<i&&(i=o,n=r)}s>i&&(l[e-1]=n)}}const h=l[e-1],m=h*h,u=m*h,g=1-h,C=g*g,v=C*g;d+=3*m*C*C,_+=3*u*v,p+=3*m*m*C;const S=-(v*s.x+u*a.x-c[e].x);f+=S*h*C,x+=S*m*g;const b=-(v*s.y+u*a.y-c[e].y);P+=b*h*C,y+=b*m*g}if(e){const t=d*p-_*_;Math.abs(t)>=1e-12*(Math.abs(d*p)+Math.abs(_*_))+1e-10?(h||(i.x=(f*p-x*_)/t,i.y=(P*p-y*_)/t),m||(o.x=(d*x-_*f)/t,o.y=(d*y-_*P)/t)):((0,r.Q)(s,a,.3,i),(0,r.Q)(s,a,.6,o))}let C=0;for(let t=1,e=g-1;t<e;t++)C+=E(t,l[t-1]);return C}var Cn=i.V;class vn extends Q{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,r.ae)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),(0,n.d)("unrecognized constructor params"),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return wt(this)}construct(t,e,s,n){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=n.x,this.m_YEnd=n.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=(0,r.m)(r.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,r.Q)(t[0],t[1],2/3,e[1]),(0,r.Q)(t[1],t[2],1/3,e[2])})(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),(0,r.ai)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,r.ai)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),X(this,t)}getGeometryType(){return n.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,n.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Xs(this);if(null!==e){const s=new r.P;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s);return}const s=(0,r.m)(r.X,8),i=(0,r.m)(r.P,4);this.queryControlPoints(i);const o=dn(i,s),a=new r.P;for(let e=1;e<o-1;e++)this.queryCoord2D(s[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Ys(this)}(0,n.g)(0)}createInstance(){return new vn({vd:this.m_description})}calculateLength2D(){return Ms(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return r.P.distance(this.getStartXY(),this.m_cp[0])+r.P.distance(this.m_cp[0],this.m_cp[1])+r.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){(0,n.g)(0)}queryCoord2DExtends(t,e,s){const n=(0,r.m)(r.P,4);this.queryControlPoints(n),Zs(n,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const n=(0,r.m)(r.P,4);t.queryControlPoints(n),function(t,e,s){if(e.value()<=.5){const n=new p;(0,r.ao)(2,p.constructPoint2D(t[0]),p.constructPoint2D(t[1]),e,n);const i=new p;(0,r.ao)(2,p.constructPoint2D(t[1]),p.constructPoint2D(t[2]),e,i);const o=new p;(0,r.ao)(2,p.constructPoint2D(t[2]),p.constructPoint2D(t[3]),e,o);const a=new p;(0,r.ao)(2,n,i,e,a);const h=new p;(0,r.ao)(2,i,o,e,h),(0,r.ao)(2,a,h,e,s)}else{const n=new p;(0,r.ap)(2,p.constructPoint2D(t[0]),p.constructPoint2D(t[1]),e,n);const i=new p;(0,r.ap)(2,p.constructPoint2D(t[1]),p.constructPoint2D(t[2]),e,i);const o=new p;(0,r.ap)(2,p.constructPoint2D(t[2]),p.constructPoint2D(t[3]),e,o);const a=new p;(0,r.ap)(2,n,i,e,a);const h=new p;(0,r.ap)(2,i,o,e,h),(0,r.ap)(2,a,h,e,s)}}(n,e,s)}(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.x}const e=(0,r.q)(this.getStartX(),this.m_cp[0].x,t),s=(0,r.q)(this.m_cp[0].x,this.m_cp[1].x,t),n=(0,r.q)(this.m_cp[1].x,this.getEndX(),t),i=(0,r.q)(e,s,t),o=(0,r.q)(s,n,t);return(0,r.q)(i,o,t)}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.y}const e=(0,r.q)(this.getStartY(),this.m_cp[0].y,t),s=(0,r.q)(this.m_cp[0].y,this.m_cp[1].y,t),n=(0,r.q)(this.m_cp[1].y,this.getEndY(),t),i=(0,r.q)(e,s,t),o=(0,r.q)(s,n,t);return(0,r.q)(i,o,t)}cut(t,e,s){const n=new Vr;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=Cn.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=Cn.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Ks(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,n.a)("Cubic_bezier.cut_bezier_ignore_attributes");const i=(0,r.m)(r.P,4);this.queryControlPoints(i);const o=(0,r.m)(r.P,4);js(i,t,e,o),s.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&(0,n.a)("Cubic_bezier.split_bezier_ignore_attributes");const i=(0,r.m)(r.P,4);this.queryControlPoints(i);const o=(0,r.m)(r.P,4),a=(0,r.m)(r.P,4);Ws(i,t,o,a),e&&e.setControlPoints(o),s&&s.setControlPoints(a)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.getStartAttributeAsDbl(e,s),i=this.getEndAttributeAsDbl(e,s),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,h=Cn.getInterpolation(e);return(0,r.ad)(h,n,i,a,Cn.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return cn(this,t,r.E.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const n=[Number.NaN];return 0===cn(this,t,e,!1,s,1,n)?Number.NaN:n[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,n.a)("");const s=Fs(this);if(2===s.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let i=0;(0,n.g)(t.length>=s.specialPointsCount()-1);for(let n=1,r=s.specialPointsCount();n<r;++n)this.queryCut(s.specialPoints[n-1],s.specialPoints[n],t[i],e),i++;for(let e=0;e<i;++e)zs(t[e].get());return i}intersectionWithAxis2D(t,e,s,n){const i=(0,r.m)(r.P,4);return this.queryControlPoints(i),function(t,e,s,n,i){const o=(0,r.m)(r.X,4),a=(0,r.m)(r.X,3),h=new r.E(0,1);let m=0;if(e){if(Gs(t,o,!1),m=Rt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),n)for(let e=0;e<m;e++){const s=new r.P;Zs(t,a[e].value(),s),n[e]=s.x}}else if(As(t,o,!1),m=Rt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),n)for(let e=0;e<m;e++){const s=new r.P;Zs(t,a[e].value(),s),n[e]=s.y}if(i)for(let t=0;t<m;t++)i[t]=a[t].value();else n&&(0,r.aa)(n,0,m,r.R);return m}(i,t,e,s,n)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return(0,n.g)(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return C(this,t)}isDegenerate3D(t,e){return(0,n.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,n.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),js(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),i=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):n&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):i&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ms(this,t,!0)}lengthToT(t){return function(t,e){const s=Ms(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const i=[0];return 1!==Nt(new fn(t,e),r.E.unit(),1,i)&&(0,n.d)(""),i[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,4);ws(this,e);const s=e[3],n=e[2],i=e[1],o=new r.P;o.x=(5*s.x*s.x*(7*n.y+16*i.y)+s.x*(-35*s.y*n.x+40*n.x*n.y-80*s.y*i.x+140*n.x*i.y+112*i.x*i.y)-2*(s.y*(20*n.x*n.x+70*n.x*i.x+56*i.x*i.x)-7*(4*n.x+5*i.x)*(-n.y*i.x+n.x*i.y)))/840,o.y=(-5*s.y*s.y*(7*n.x+16*i.x)+s.y*(5*s.x*(7*n.y+16*i.y)-4*(10*n.x*n.y+35*n.y*i.x+28*i.x*i.y))+2*(-7*(4*n.y+5*i.y)*(n.y*i.x-n.x*i.y)+s.x*(20*n.y*n.y+70*n.y*i.y+56*i.y*i.y)))/840;const a=Hs(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const i=new r.P;if(e<0||s>1)return i.setNAN(),i;if(e>s&&(0,n.a)("calculate_sub_weightedCentroid"),e===s||t.isDegenerate(0))return i.setCoords(0,0),i;const o=Fs(t),a=Ds(t),h=a/t.calculateUpperLength2D();let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}i.setCoords(0,0);for(let e=l+1,n=o.specialPointsCount();e<n;e++){const n=Math.min(o.specialPoints[e],s),r=yn(t,m,n,h,a);if(i.addThis(r),m=n,s<=o.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),4}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&(0,n.a)("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Qs(e,t)}getDerivative(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Ls(e,1,t)}getCurvature(t){const e=Bs(this,1,t),s=Bs(this,2,t),n=e.sqrLength();return 0===n?Number.NaN:(e.divThis(Math.sqrt(n)),e.crossProduct(s)/n)}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const n=new o.Envelope2D;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(i,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return(0,n.g)(0),!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,4);return this.queryControlPoints(t),function(t){return function(t){const e=(0,r.a4)(t[0].y,t[1].y),s=(0,r.a4)(t[1].y,t[2].y),n=(0,r.a4)(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=(0,r.a4)(t[0].x,t[1].x),s=(0,r.a4)(t[1].x,t[2].x),n=(0,r.a4)(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}(t)}(t)}getMonotonicPartParams(t,e){const s=Fs(this),i=s.specialPointsCount();if((0,n.g)(B.s_maxMonotonicPartParams>=i),!e)return s.specialPointsCount();t<i&&(0,n.a)("");for(let t=0;t<i;t++)e[t]=s.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new r.X;return ks(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),n=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])+r.P.distance(e[2],e[3])-n>t)return!1;const i=t;let o=e[1].clone();o.subThis(e[0]);let a=Math.abs(o.crossProduct(s))/n;return!(a>i||(o=e[2].clone(),o.subThis(e[1]),a=Math.abs(o.crossProduct(s))/n,a>i))}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Hs(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){hn(this,t,e)}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){if((0,n.g)(s>=2),2===s){const n=new r.P;(0,r.Q)(e[0],e[s-1],1/3,n);const i=new r.P;return(0,r.Q)(e[0],e[s-1],2/3,i),void t.construct(e[0],n,i,e[s-1])}const i=e[0],o=e[s-1],a=[0,0],h=cn(t,i,r.E.unit(),!1,Number.NaN,2,a),m=[0,0],l=cn(t,o,r.E.unit(),!1,Number.NaN,2,m),u=[];for(let n=0;n<h;n++)for(let h=0;h<l;h++){const l=a[n],c=m[h],g=l>c,d=(n,a)=>{const h=(0,r.d)(s-2,Number.NaN),m=()=>{let t=0;for(let n=1,i=s-1;n<i;n++){t+=r.P.distance(e[n-1],e[n]);const s=t;h[n-1]=s}t+=r.P.distance(e[s-2],e[s-1]),g&&h.reverse();for(let e=1,n=s-1;e<n;e++)h[e-1]/=t,g&&(h[e-1]=1-h[e-1])};let u=!1,d=!1;{const e=new Vr;g?(t.queryCut(c,l,e,!0),n.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())):(t.queryCut(l,c,e,!0),n.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())),i.equals(n)&&(u=!0),o.equals(a)&&(d=!0)}m();let _=Number.MAX_VALUE;const p=n.clone(),f=a.clone();for(let t=0;t<5;t++)_=En(!0,!1,i,p,f,o,u,d,h,s-2,e,s);for(let t=0;t<30;t++){const t=p.clone();f.clone();const n=En(!0,!0,i,p,f,o,u,d,h,s-2,e,s);if(_<=n&&t.equals(p)&&t.equals(f))break;_=n}m();let x=!1,P=Number.MAX_VALUE;const y=n.clone(),E=a.clone();for(let t=0;t<30;t++){const t=y.clone();E.clone();const n=En(x,!0,i,y,E,o,u,d,h,s-2,e,s);if(P<=n&&t.equals(y)&&t.equals(E))break;x=!0,P=n}return P<_?(n.assign(y),a.assign(E)):(n.assign(p),a.assign(f),P=_),P},_=new r.P,p=new r.P,f=[d(_,p),r.P.distance(i,_)+r.P.distance(_,p)+r.P.distance(p,o),_.x,_.y,p.x,p.y];u.splice(u.length,0,...f)}let c=u[0],g=u[1],d=0;for(let t=6;t<u.length;t+=6)u[t]<c&&(c=u[t],g=u[t+1],d=t);let _=d;for(let t=0;t<u.length;t+=6)t!==d&&u[t+1]<g&&Math.abs(c-u[t])<10*c&&(g=u[t+1],_=t);t.construct(i,new r.P(u[_+2],u[_+3]),new r.P(u[_+4],u[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;return r.P.sqrDistance(e,n)<=t&&(i=!e.equals(n),e.setCoordsPoint2D(n),r.P.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))),i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return(n||i)&&this.setControlPoints(e),n||i}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;return r.P.sqrDistance(e,n)<=t&&(i=!e.equals(n),e.setCoordsPoint2D(n),r.P.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))),i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return n||i}calculateSpecialPointsForCracking(t,e){return function(t,e,s){s.length=0;{const e=new r.X;ks(t,e);const n=new p;if(Ks(t,e,n),n.isZero())return e.isZero()||e.eq(new r.X(1))?0:(s.push(e.value()),1)}const n=(0,r.m)(r.X,4);Ts(t,n,!0);const i=(0,r.m)(r.X,4);Ns(t,i,!0);const o=(0,r.m)(r.X,6),a=n[3].negate().mulE(i[1]).addE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),h=n[3].negate().mulE(i[1]).subE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),m=n[2].mulE(n[2]).subE(i[2].mulE(i[2]));o[0]=i[1].mulE(i[1]).mulE(a).addE(n[1].mulE(n[1]).mulE(h)).addE(n[1].mulE(i[1]).mulE(m).mul(2)).mul(6),o[1]=n[2].mulE(i[1]).subE(n[1].mulE(i[2])).mulE(n[2].mulE(n[2]).addE(n[1].mulE(n[3]).mul(2)).addE(i[2].mulE(i[2])).addE(i[1].mulE(i[3]).mul(2))).mul(24);const l=n[1].mulE(i[2]).mulE(i[2]).mulE(i[3]),u=n[2].mulE(n[2]).mulE(n[3]).mulE(i[1]).subE(l).mul(156),c=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),g=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),d=n[1].mulE(n[3]).mulE(g).addE(i[1].mulE(i[3]).mulE(c)).mul(72),_=i[1].mulE(i[3]).subE(n[1].mulE(n[3])),f=n[2].mulE(i[2]).mulE(_).mul(120),x=n[1].mulE(n[2]).mulE(n[2]).mulE(i[3]),P=n[3].mulE(i[1]).mulE(i[2]).mulE(i[2]).subE(x).mul(36);o[2]=u.addE(d).addE(f).addE(P);const y=n[2].mulE(n[3]).mulE(n[3]).mulE(i[1]).subE(n[1].mulE(i[2]).mulE(i[3]).mulE(i[3])).mul(360),E=n[2].mulE(i[2]).mulE(n[2].mulE(n[3]).subE(i[2].mulE(i[3]))).addE(n[3].mulE(i[2]).mulE(i[2]).mulE(i[2])).subE(n[2].mulE(n[2]).mulE(n[2]).mulE(i[3])).mul(24),C=n[2].mulE(i[1]).mulE(i[3]).mulE(i[3]).subE(n[1].mulE(n[3]).mulE(n[3]).mulE(i[2])).mul(72),v=n[3].mulE(i[3]).mulE(i[1].mulE(i[2]).subE(n[1].mulE(n[2]))).mul(288);o[3]=y.addE(E).addE(C).addE(v),o[4]=i[3].mulE(i[3]).addE(n[3].mulE(n[3])).mulE(n[3].mulE(i[1]).subE(n[1].mulE(i[3]))).mul(270).addE(n[3].mulE(i[2]).subE(n[2].mulE(i[3]))).mulE(n[2].mulE(n[3]).addE(i[2].mulE(i[3]))).mul(180),o[5]=n[3].mulE(i[2]).subE(n[2].mulE(i[3])).mulE(n[3].mulE(n[3]).addE(i[3].mulE(i[3]))).mul(216);const S=(0,r.m)(r.X,5),b=kt(o,5,new r.E(0,1),!1,S,5);if(b>0){let n=Math.abs(t.getCurvature(0)),i=0;const o=Math.abs(t.getCurvature(1));(o>n||!Number.isFinite(o))&&(i=1);for(let e=0;e<b;e++){const s=Math.abs(t.getCurvature(S[e].value()));t.getCoord2D(S[e].value()),(s>n||!Number.isFinite(s))&&(n=s,i=S[e].value())}if((!Number.isFinite(n)||1/n<e)&&!(0,r.a8)(i,0,1)){const e=t.getCoord2D(i);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(i),1}}if(!t.isClosed()){const e=[0,0],n=gn(t,e,!1);for(let t=0;t<n;t++)e[t]>0&&e[t]<1&&s.push(e[t]);return s.length}return 0}(this,t,e)}ensureXYMonotone(){return zs(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const l=(0,r.m)(r.P,3);l[0].setCoordsPoint2D(e),l[2].setCoordsPoint2D(s),m.setSub(l[2],l[0]),m.leftPerpendicularThis(),l[1].setAdd(l[0],m),o.setFromTwoTriangles(h,l)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,r.Q)(e,s,1/3,t.m_cp[0]),(0,r.Q)(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),i&&zs(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Vs(e,Xs(this))}reverseImpl(){this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t;return!!this.m_cp[0].equals(e.m_cp[0])&&!!this.m_cp[1].equals(e.m_cp[1])}equalsImplTol(t,e){const s=t;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[1],e)}swapImpl(t){const e=t;e.m_cp[0]=(0,r.c)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,r.c)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ys(this)}isIntersecting(t,e,s){return 0!==Ir(!1,this,t,e,s)}intersect(t,e,s,n,i){return Nr(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return function(t,e,s,i){const o=new c;if(hn(t,r.E.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=Fs(t);let h=0,m=a.specialPoints[0];const l=[];for(let s=1,i=a.specialPoints.length;s<i;++s){const i=a.specialPoints[s],r=Rs(t,e,m,i);if(0===l.length)l.push(r);else if(r.t===r.tmin)(0,n.g)(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){(0,n.g)(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);m=i}for(const t of l)if(t.d<=i){const e=t.t;s?(h>=s.length&&(0,n.q)(""),s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Ys(this)}clearEndPointModified(){}}vn.type=n.G.enumBezier;class Sn{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function bn(t,e,s,i,o,a,h,m){for(;;){const l=r.P.distance(e[0],e[2]),u=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2]);if(u-l<=o+i*u)return t+(0,r.q)(l,u,.5);const c=(0,r.m)(r.P,4),g=t=>(Fn(e,s,1,t,c),c[1].length());if(0===h&&m<8){(0,n.g)(m<8);let l=g(0),c=g(1);a[0]+=2,l>c&&(c=(0,r.c)(l,l=c),e[2]=(0,r.c)(e[0],e[0]=e[2]),s[2]=(0,r.c)(s[0],s[0]=s[2]));let d=l/(l+c),_=1,p=u;for(;d<1/32&&p>=o+i*p;){_/=4;const t=g(_);a[0]++,d=l/(t+l);const n=new r.P;if(ci(e,s,.5*_,n),p=r.P.distance(n,e[0]),p<=o){const t=new r.P;ci(e,s,_,t),p+=r.P.distance(t,n)}}if(1!==_){const n=(0,r.m)(r.P,3),l=[0,0,0];$n(e,s,_,e,s,n,l),t=bn(t,n,l,i,o,a,0,m+1),h++,m++;continue}}let d=!1;const _=8;a[0]+=_;const p=is(_,g,0,1),f=16;a[0]+=f;const x=is(f,g,0,1);if(d=Math.abs(p-x)>o+i*u,!d)return t+x;if(h<8&&m<9){const n=(0,r.m)(r.P,3),l=[0,0,0];$n(e,s,.5,e,s,n,l),t=bn(t,n,l,i,o,a,h+1,m+1),h++,m++;continue}const P=32;a[0]+=P;const y=is(P,g,0,1);if(d=Math.abs(x-y)>o+i*u,!d)return t+y;const E=64;a[0]+=E;const C=is(E,g,0,1);if(d=Math.abs(y-C)>o+i*u,!d)return t+C;const v=128;a[0]+=v;const S=is(v,g,0,1);return d=Math.abs(C-S)>o+i*u,t+S}}function In(t,e,s,n,i){if(s===e)return 0;const o=(0,r.m)(r.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);const h=[0,0,0],m=(0,r.m)(r.P,3);return Jn(o,a,e,s,m,h),bn(0,m,h,n,i,[0],0,0)}class Dn{constructor(t,e,s){this.controlPoints=(0,r.a7)(t,3),this.weights=[0,0,0],(0,r.b)(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new r.P;ci(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Fn(this.controlPoints,this.weights,1,e,s),2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new r.P;ci(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Fn(this.controlPoints,this.weights,2,e,s),2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new r.P;ci(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Fn(this.controlPoints,this.weights,3,e,s),2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return(0,n.g)(0),0}}function wn(t,e,s,n){const i=function(t,e,s,n,i){return{tmin:0,tmax:0,t:0,d:0,pt:i.clone()}}(0,0,0,0,r.P.getNAN()),o=(0,r.d)(18,Number.NaN),a=(0,r.m)(r.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);const h=[0,0,0];t.queryWeights(h);const m=[1,di(h),1],l=pi(h,s),u=pi(h,n),c=Nt(new Dn(a,m,new r.P(0,0)),r.E.construct(l,u),18,o);ci(a,m,l,i.pt),i.t=l,i.d=r.P.distance(i.pt,new r.P(0,0));const g=new r.P;ci(a,m,u,g);const d=r.P.distance(g,new r.P(0,0));d<i.d&&(i.d=d,i.t=u,i.pt.assign(g));for(let t=0;t<c;t++){ci(a,m,o[t],g);const e=r.P.distance(g,new r.P(0,0));e<i.d&&(i.d=e,i.t=_i(h,o[t]),i.pt.assign(g))}return i}function Tn(t,e,s,n,i){let o=!0;const a=(0,r.m)(r.P,4),h=fe(5,e,s,n,i,e=>(Mn(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));o=!1;const m=fe(5,e,s,n,i,e=>(Mn(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));return new r.P(h,m)}function Nn(t){t.m_cachedValues=null}function An(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Sn,s=(0,r.m)(r.P,3);t.queryControlPoints(s);const n=[0,0,0];return t.queryWeights(n),Gn(s,n,e.specialPoints),zn(t,e),e}function Gn(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const n=(0,r.m)(r.X,8);n[0].set(0);let i=1;{const s=new r.X(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new r.X(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.X(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.X,2);let m=Yt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.a8)(h[t].value(),0,1)||(n[i]=h[t],i++)}{const s=new r.X(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new r.X(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.X(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.X,2);let m=Yt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.a8)(h[t].value(),0,1)||(n[i]=h[t],i++)}if(n[i].set(1),i++,i>2){(0,r.aa)(n,0,i,(t,e)=>(0,r.R)(t.value(),e.value()));let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),s.length=i;for(let t=0;t<i;t++)s[t]=n[t].value()}function qn(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+qn(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=An(t);if(n&&!Number.isNaN(i.length))return i.length;const r=Bn(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,n=i.specialPointsCount();s<n;s++){const n=i.specialPoints[s];if(a+=In(t,h,Math.min(e,n),o,r),e<=n)break;h=n}return n&&(i.length=a),a}function Mn(t,e,s,n){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const o=[0,0,0];t.queryWeights(o),Fn(i,o,e,s,n)}function Fn(t,e,s,i,o){const a=[t[0],t[1],t[2]],h=[e[0],e[1],e[2]],m=(0,r.m)(r.P,4);!function(t,e,s,i,r){(0,n.g)(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Xn(o,e,0,i),h=Yn(e,0,i),m=a.divide(h);if(r[0].assign(m),0===s)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],c=h*h,g=Xn(u,l,0,i).mul(2).divide(c);if(r[1].assign(g),1===s)return;const d=Yn(e,1,i),_=2*h*d,p=Xn(u,l,1,i).mul(2).sub(g.mul(_)).divide(c);if(r[2].assign(p),2===s)return;const f=Xn(u,l,2,i).mul(2),x=2*(d*d+h*Yn(e,2,i)),P=f.sub(p.mul(_).mul(2)).sub(g.mul(x)).divide(c);r[3].assign(P),3!==s&&(0,n.d)("")}(a,h,s,i,m);for(let t=0;t<=s;t++)o[t].setCoords(m[t].x,m[t].y)}function Xn(t,e,s,i){if(0===s){if(i<=.5){const s=new r.P;(0,r.am)(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new r.P;(0,r.am)(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const o=new r.P;return(0,r.am)(2,s,n,i,o),o}{const s=new r.P;(0,r.an)(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new r.P;(0,r.an)(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const o=new r.P;return(0,r.an)(2,s,n,i,o),o}}if(1===s){const s=t[1].mul(e[1]),n=s.sub(t[0].mul(e[0])).mul(1-i).add(t[2].mul(e[2]).sub(s).mul(i));return n.mulThis(2),n}if(2===s){const s=t[1].mul(e[1]),n=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return n.mulThis(2),n}(0,n.d)("")}function Vn(t,e,s,n){if(n.toDouble()<=.5){const s=new p;(0,r.ao)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new p;(0,r.ao)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const o=new p;return(0,r.ao)(2,s,i,n,o),o}{const s=new p;(0,r.ap)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new p;(0,r.ap)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const o=new p;return(0,r.ap)(2,s,i,n,o),o}}function Yn(t,e,s){if(0===e){const e=(0,r.q)(t[0],t[1],s),n=(0,r.q)(t[1],t[2],s);return(0,r.q)(e,n,s)}return 1===e?2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,n.d)("")}function Rn(t,e,s){const n=(0,r.s)(s,0,1),i=(0,r.m)(r.P,4);if(Fn(t,e,3,n,i),i[1].isZero()){if(i[2].isZero())return i[3];{const t=i[2].clone();return 1===n&&t.negateThis(),t}}return i[1]}class kn{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-qn(this.b,e,!1):0}getError(t){return(0,n.g)(0),0}}function Ln(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=di(e);if(1===s)return qe(t);if(0===s)return 0;const i=[new r.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=i[1].crossProduct(i[2]);if(s<1){(0,n.g)(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const n=t*(1+s),i=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-(0,r.aI)(n)*i)/n}return o*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*o-4*i[1].y*i[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-i[1].x*i[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}(e,s)}function Bn(t){return function(t){return 256*(0,r.H)()*t}(t.calculateUpperLength2D())}function Hn(t){return t.m_cachedValues}function zn(t,e){t.m_cachedValues=e}function Un(t,e,s,n,i){const o=(0,r.m)(r.P,3);t.queryControlPoints(o);const a=[0,0,0];t.queryWeights(a);const h=[0];return 1===On(o,a,e,r.E.unit(),n,i,1,h)?h[0]:Number.NaN}function On(t,e,s,o,a,h,m,l){(0,n.D)(r.E.unit().contains(o)&&m>0,""),(h<0||Number.isNaN(h))&&(h=Number.MAX_VALUE);const u=new Array(3);for(let e=0;e<3;++e)u[e]=t[e].sub(s);const c=di(e),g=x.constructPoint2D(u[0]),d=x.constructPoint2D(u[1]),_=x.constructPoint2D(u[2]),p=r.M.constructDouble(c),f=p.clone();f.ldexpThis(1);const P=g.dotProduct(d.sub(g)).mul(p),y=p.mul(p.addDouble(2)),E=_.sub(d.mul(y.ldexp(1))),C=d.sqrLength().mul(p.mul(p).ldexp(1)).add(g.sqrLength().mul(p.ldexp(2).subDouble(1))).add(g.dotProduct(E)),v=_.sub(d.mul(f)).add(g.mul(f.subDouble(1))),S=d.mul(p).sub(g).dotProduct(v).mulDouble(3),b=d.dotProduct(_).mul(p.subDouble(3).mul(p)).ldexp(1),I=d.sqrLength().mul(p.mul(p).ldexp(2)),D=g.sqrLength().mul(p.ldexp(2).subDouble(3)),w=g.dotProduct(_.sub(d.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),T=_.sqrLength().addThis(b).addThis(I).addThis(D).addThis(w),N=g.add(_).sub(d.mul(f)),A=p.subDouble(1),G=_.sub(g).dotProduct(N).mul(A),q=new r.P(0,0),M=[];let F=new r.P;ci(u,e,o.vmin,F);let X=r.P.distance(F,q);if(X<=h&&M.push(new r.P(o.vmin,X)),o.vmin!==o.vmax&&(ci(u,e,o.vmax,F),X=r.P.distance(F,q),X<=h&&M.push(new r.P(o.vmax,X))),o.width()>0){const t=u[2].isZero(),s=(0,r.m)(r.M,4),n=re(G,T,S,C,P,58,o,t,s);for(let t=0;t<n;t++){if(!o.containsExclusiveCoordinate(s[t].toDouble()))continue;let n=s[t].toDouble();n=_i(e,n);const i=new r.P;ci(u,e,n,i),X=r.P.distance(i,q),X<=h&&M.push(new r.P(n,X))}}if(a){(0,n.g)(o.equals(r.E.unit()));{ci(u,e,-1,F,!0);const t=new r.P;ci(u,e,0,t);const s=new Xr({start:F,end:t}),n=s.getClosestCoordinate(q,!0);n<1&&(F=s.getCoord2D(n),X=r.P.distance(F,q),X<=h&&M.push(new r.P(n-1,X)))}{ci(u,e,2,F,!0);const t=new r.P;ci(u,e,o.vmax,t);const s=new Xr({start:t,end:F}),n=s.getClosestCoordinate(q,!0);n>0&&(F=s.getCoord2D(n),X=r.P.distance(F,q),X<=h&&M.push(new r.P(1+n,X)))}}if(!M.length)return 0;M.sort((t,e)=>t.compare(e));let V=0;const Y=M[0].x;if(l[V++]=Y,V<m){const t=(0,i.a3)(u,4,!1).total(),e=M[0].y;for(let s=1,n=M.length;s<n;s++)if(M[s].y>e+t){M.length=s;break}M.sort((t,e)=>(0,r.R)(t.x,e.x)),V=0,l[V++]=M[0].x;for(let t=1,e=M.length;t<e;t++)M[t].x!==l[V-1]&&V<m&&(l[V++]=M[t].x)}return V}function Wn(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),jn(n,i,e,s)}function jn(t,e,s,n){if(s.equalsRange(0,1))return void n.setFromPoints(t,3);const i=(0,r.m)(r.P,3);Jn(t,e,s.vmin,s.vmax,i,[0,0,0]),n.setFromPoints(i,3)}function Zn(t){const e=(0,r.a4)(t[0].y,t[1].y),s=(0,r.a4)(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=(0,r.a4)(t[0].x,t[1].x),s=(0,r.a4)(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Qn(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Kn(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Kn(t){let e=!1;for(let s=0;s<2;s++){const n=(0,r.a4)(t[0][s],t[2][s]);n>0?((0,r.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?((0,r.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.a4)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function $n(t,e,s,o,a,h,m){(0,n.g)(s>=0&&s<=1&&o!==h&&a!==m),(0,n.g)(e[0]>0&&e[2]>0&&e[1]>=0);const l=[1,di(e),1],u=pi(e,s),c=(0,r.a7)(t,3),g=(0,r.m)(i.d,3);mi(c,l,g);const d=(0,r.m)(i.d,3),_=(0,r.m)(i.d,3);fi(g,u,o?d:null,h?_:null),xi(e,s,a,m);const p=Zn(c);if(o){for(let t=0;t<3;++t)ui(d[t],o[t]);yi(c,o),p&&Kn(o)}if(h){for(let t=0;t<3;++t)ui(_[t],h[t]);yi(c,h),p&&Kn(h)}}function Jn(t,e,s,o,a,h){if((0,n.g)(s>=0&&o<=1&&s<=o),s===o){const n=new r.P,i=li(t,e,s,n);return Pi(t,n),a[0].assign(n),a[1].assign(n),a[2].assign(n),h[0]=i,h[1]=i,void(h[2]=i)}if(0===s&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),h[0]=e[0],h[1]=e[1],void(h[2]=e[2]);const m=(0,r.m)(i.d,3);{const n=[1,di(e),1],i=pi(e,s),r=pi(e,o);mi(t,n,m),fi(m,r,m,null),fi(m,i>=r?1:i/r,null,m)}const l=[0,0,0];xi(e,o,l,null),xi(l,s/o,null,l);const u=Zn(t),c=(0,r.m)(r.P,3);ui(m[1],c[1]),ci(t,e,s,c[0]),ci(t,e,o,c[2]),yi(t,c);for(let t=0;t<3;++t)a[t].assign(c[t]),h[t]=l[t];u&&Kn(a)}function ti(t,e,s){const n=di(e),i=[1,n,1],o=4*n/(3*(1+n));s[0].assign(t[0]),s[3].assign(t[2]),(0,r.Q)(t[0],t[1],o,s[1]),(0,r.Q)(t[2],t[1],o,s[2]),new vn({cp:s}),new jt({points:t,weight:n});let a=0,h=.1,m=0;for(let e=0;e<9;e++,h+=.1){const e=new r.P;ci(t,i,h,e);const n=new r.P;Zs(s,h,n);const o=r.P.sqrDistance(e,n);o>a&&(a=o,m=h)}{const e=new r.P;ci(t,i,m,e);const n=[0];un(s,e,r.E.unit(),!1,-1,1,n);const o=new r.P;return Zs(s,n[0],o),a=r.P.sqrDistance(e,o),Math.sqrt(a)}}function ei(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==ii(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function si(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==ri(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function ni(t,e,s,n,i){if(i){if(0!==wr(e,s))return t?4:2}else if(E(e,s))return 1;return 0!==ai(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function ii(t,e,s,i,o,a,h,m,l,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,h);if(n>0){if(null!==o)for(let e=0;e<n;e++)o.push(t[e]);if(null!=a)for(let t=0;t<n;t++)a.push(0);if(null!=i)for(let s=0;s<n;s++){const n=new r.P;e.queryCoord2D(t[s],n),i.push(n)}}return n}const c=Y(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Xr({start:e.getStartXY(),end:e.getEndXY()}),n=ot(t,s,i,o,a,h,m,u);if(o)for(let s=0;s<n;++s){const n=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(n,!1)}return n}if(R(e,s,h))return 0;const g=(0,r.m)(r.P,3);e.queryControlPoints(g);const d=[0,0,0];e.queryWeights(d);const _=[1,di(d),1],p=s.getEndXY().sub(s.getStartXY()),f=p.clone();f.leftPerpendicularThis();const x=g[0].clone(),P=g[1].clone(),y=g[2].clone(),E=P.sub(x),C=y.sub(x),v=y.sub(P),S=_[0],b=_[1],I=_[2],D=S*b,w=S*I,T=b*I,N=E.dotProduct(f)*D,A=C.dotProduct(f)*w;let G=N,q=A-2*N,M=v.dotProduct(f)*T+A-A;const F=(0,r.d)(13,Number.NaN),X=(0,r.d)(13,Number.NaN);let V=At(M,q,G,r.E.unit(),!1,F);V<0&&(F[0]=0,F[1]=1,V=2);let k=0;for(let t=0,e=k;t<V;++t){const n=new r.P;ci(g,_,F[t+e],n),X[k]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(X[k]))<=h&&(F[k]=F[t+e],k++)}const L=(0,r.m)(r.P,3),B=(0,r.m)(r.P,3);if(e.queryControlPoints(B),B[0].subThis(s.getStartXY()),B[1].subThis(s.getStartXY()),B[2].subThis(s.getStartXY()),function(t,e,s,n=!1){const i=(0,r.m)(r.P,3);n?(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[1].subThis(i[0]),i[2].setCoordsPoint2D(t[2]),i[2].subThis(i[0]),i[0].setCoords(0,0)):(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[2].setCoordsPoint2D(t[2])),i[0].mulThis(e[0]),i[1].mulThis(e[1]),i[2].mulThis(e[2]),s[1].setCoords(i[1].x-i[0].x,i[1].y-i[0].y),s[2].setCoordsPoint2D(i[2].sub(i[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(i[0])}(B,_,L,!1),Math.abs(p.x)>=Math.abs(p.y)){const t=p.y/p.x;M=L[2].y-L[2].x*t,q=L[1].y-L[1].x*t,G=L[0].y-L[0].x*t}else{const t=p.x/p.y;M=L[2].x-L[2].y*t,q=L[1].x-L[1].y*t,G=L[0].x-L[0].y*t}const H=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),z=[0,0];V=At(M,q,G,r.E.unit(),H,z);for(let t=0,e=k;t<V;++t){F[t+e]=z[t];const n=new r.P;ci(g,_,F[t+e],n),X[k]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(X[k]))<=h&&(F[k]=F[t+e],k++)}(0,n.g)(k<F.length+4);for(let t=0;t<k;t++)F[t]=_i(d,F[t]);V=e.intersectPoint(s.getStartXY(),z,h);for(let t=0;t<V;t++)F[k]=z[t],X[k++]=0;V=e.intersectPoint(s.getEndXY(),z,h);for(let t=0;t<V;t++)F[k]=z[t],X[k++]=1;V=s.intersectPoint(e.getStartXY(),z,h);for(let t=0;t<V;t++)X[k]=z[t],F[k++]=0;V=s.intersectPoint(e.getEndXY(),z,h);for(let t=0;t<V;t++)X[k]=z[t],F[k++]=1;return 0===k?0:Gr(t,e,s,F,X,k,i,o,a,h,m,0,u)}function ri(t,e,s,n,i,o,h,m,l,u){if(Ji(s))return ii(t,e,new Xr({start:s.getStartXY(),end:s.getEndXY()}),n,i,o,h,m,0,u);const c=Y(e,s);if(R(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,4);{e.queryControlPoints(_);const t=(0,r.m)(r.P,4),n=new a.T;s.canonicToWorldTransformation(n);const i=new a.T;i.setInvert(n),i.transformPoints2D(_,4,t);const o=(0,r.m)(r.M,3),l=(0,r.m)(r.M,3),u=(0,r.m)(r.M,3),c=[0,0,0];e.queryWeights(c),hi(t,c,o,l,u);const p=(0,r.m)(r.M,3);p[0].setDouble(s.getSemiMinorAxis()),p[0].sqrThis(),p[1].setDouble(s.getSemiMajorAxis()),p[1].sqrThis(),p[2].setThis(p[0]),p[2].mulThis(p[1]),p[2].negateThis();const f=ee(o,2,l,2,u,2,p,0,r.E.unit(),r.E.unit(),g,m);if(f>0){let t=0;for(let n=0;n<f;n++){const i=new r.P;e.queryCoord2D(g[n],i);const o=s.getClosestCoordinate(i,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(i,a)<=h&&(g[t]=g[n],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const n=0===t?s.getStartXY():s.getEndXY(),i=Un(e,n,r.E.unit(),!1,-1),o=new r.P;e.queryCoord2D(i,o),r.P.distance(n,o)<=h&&(g.push(i),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,3];{const n=s.getClosestCoordinate(_[e[t]],!1),i=new r.P;s.queryCoord2D(n,i),r.P.distance(_[e[t]],i)<=h&&(g.push(p[t]),d.push(n))}}return Gr(t,e,s,g,d,g.length,n,i,o,h,m,0,u)}function oi(t,e,s,i,o,a,h,m,l,u){const g=(0,r.m)(r.P,3);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);if(s.queryControlPoints(d),k(g,d,3)<0)return oi(t,s,e,i,a,o,h,m,l,!u);const _=Y(e,s);if(e.isDegenerateToLineHelper(_)){const n=new Xr({start:e.getStartXY(),end:e.getEndXY()}),r=ii(t,s,n,i,a,o,h,m,0,!u);if(o)for(let t=0;t<r;++t){const s=n.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(s,!1)}return r}if(s.isDegenerateToLineHelper(_)){const n=new Xr({start:s.getStartXY(),end:s.getEndXY()}),r=ii(t,e,n,i,o,a,h,m,0,u);if(a)for(let t=0;t<r;++t){const e=n.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(R(e,s,h=Math.max(h,_)))return 0;const p=(0,r.d)(3,Number.NaN);e.queryWeights(p);const f=(0,r.d)(3,Number.NaN);s.queryWeights(f);const x=[1,di(p),1],P=[1,di(f),1],y=new r.E(0,1),E=new r.E(0,1);{const t=c.constructEmpty();jn(g,x,new r.E(0,1),t);const e=c.constructEmpty();jn(d,P,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(gi(g,x,t,y),gi(d,P,t,E),y.isEmpty()||E.isEmpty())return 0;Jn(g,x,y.vmin,y.vmax,g,x),Jn(d,P,E.vmin,E.vmax,d,P)}}const C=Mr(g,2,d,2,h);if(0===C)return 0;const v=[],S=[];if(-1===C){const t=(0,r.m)(r.M,3),e=(0,r.m)(r.M,3),s=(0,r.m)(r.M,3);hi(g,x,t,e,s);const n=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hi(d,P,n,i,o);const a=[],l=[],c=te(t,2,e,2,s,2,n,2,i,2,o,2,0,r.E.unit(),r.E.unit(),a,l,m,0,u);if(c>0)for(let t=0;t<c;t++){const e=new r.P;ci(d,P,l[t],e);const s=new r.P;ci(g,x,a[t],s),r.P.distance(s,e)<=h&&(v.push(a[t]),S.push(l[t]))}}for(let t=0;t<2;t++){let e,s,i;0===t?(e=g,s=d,i=P):(e=d,s=g,i=x);for(let o=0;o<2;o++){const a=0===o?0:e.length-1,m=new r.P,l=[0],u=On(s,i,e[a],r.E.unit(),!1,-1,1,l);(0,n.g)(1===u),ci(s,i,l[0],m),r.P.distance(e[a],m)<=h&&(0===t?(v.push(0===a?0:1),S.push(l[0])):(S.push(0===a?0:1),v.push(l[0])))}}if(0===v.length)return 0;if(!y.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=jt.recalculateParentT(y.vmin,y.vmax,v[t]);if(!E.equalsRange(0,1))for(let t=0;t<S.length;++t)S[t]=jt.recalculateParentT(E.vmin,E.vmax,S[t]);for(let t=0;t<v.length;++t)v[t]=_i(p,v[t]);for(let t=0;t<S.length;++t)S[t]=_i(f,S[t]);return Gr(t,e,s,v,S,v.length,i,o,a,h,m,0,u)}function ai(t,e,s,n,i,o,a,h,m,l){if(e.isLine())return Oe(t,s,new Xr({start:e.getStartXY(),end:e.getEndXY()}),n,o,i,a,h,0,!l);if(s.isLine())return ii(t,e,new Xr({start:s.getStartXY(),end:s.getEndXY()}),n,i,o,a,h,0,l);const u=Y(e,s);if(R(e,s,a=Math.max(a,u)))return 0;const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);s.queryControlPoints(g);const d=Mr(c,2,g,2,a);if(0===d)return 0;const _=[],p=[];if(-1===d){const t=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),o=[0,0,0];e.queryWeights(o),hi(c,o,t,n,i);const m=(0,r.m)(x,3);Qe(g,m);const u=te(t,2,n,2,i,2,[m[0].x,m[1].x,m[2].x],2,[m[0].y,m[1].y,m[2].y],2,null,0,0,r.E.unit(),r.E.unit(),_,p,h,0,l);if(u>0){let t=0;for(let n=0;n<u;n++){const i=new r.P;s.queryCoord2D(p[n],i);const o=new r.P;e.queryCoord2D(_[n],o),r.P.distance(o,i)<=a&&(_[t]=_[n],p[t]=p[n],t++)}_.length=t,p.length=t}}for(let t=0;t<2;t++){let n;n=0===t?c:g;for(let i=0;i<2;i++){const o=0===i?0:n.length-1;let h;const m=new r.P;0===t?(h=Xe(s,n[o],r.E.unit(),!1),s.queryCoord2D(h,m)):(h=Un(e,n[o],r.E.unit(),!1,-1),e.queryCoord2D(h,m)),r.P.distance(n[o],m)<=a&&(0===t?(_.push(0===o?0:1),p.push(h)):(p.push(0===o?0:1),_.push(h)))}}return Gr(t,e,s,_,p,_.length,n,i,o,a,h,0,l)}function hi(t,e,s,n,i){const o=r.M.constructDouble(e[0]),a=r.M.constructDouble(e[1]),h=r.M.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(o),s[1].setDouble(t[1].x),s[1].mulThis(a),s[2].setDouble(t[2].x),s[2].mulThis(h),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),n[0].setDouble(t[0].y),n[0].mulThis(o),n[1].setDouble(t[1].y),n[1].mulThis(a),n[2].setDouble(t[2].y),n[2].mulThis(h),n[2].subThis(n[1]),n[1].subThis(n[0]),n[2].subThis(n[1]),n[1].ldexpThis(1),i[0].setDouble(e[0]),i[1].setDouble(e[1]),i[2].setThis(i[1]),i[2].ldexpThis(1),i[2].negateThis(),i[2].addThis(i[0]),i[2].addDoubleThis(e[2]),i[1].subThis(i[0]),i[1].ldexpThis(1)}function mi(t,e,s){for(let n=0;n<3;++n)s[n].setCoordsPoint2DZ(t[n].mul(e[n]),e[n])}function li(t,e,s,n){if(0===s)return n.assign(t[0]),e[0];if(1===s)return n.assign(t[2]),e[2];const i=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],o=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],a=[e[0],e[1],e[2]],h=s;let m,l,u;if(s<=.5){const t=(0,r.af)(i[0],i[1],h),e=(0,r.af)(i[1],i[2],h);m=(0,r.q)(t,e,h);const s=(0,r.af)(o[0],o[1],h),n=(0,r.af)(o[1],o[2],h);l=(0,r.q)(s,n,h);const c=(0,r.af)(a[0],a[1],h),g=(0,r.af)(a[1],a[2],h);u=(0,r.af)(c,g,h)}else{const t=(0,r.ag)(i[0],i[1],h),e=(0,r.ag)(i[1],i[2],h);m=(0,r.ag)(t,e,h);const s=(0,r.ag)(o[0],o[1],h),n=(0,r.ag)(o[1],o[2],h);l=(0,r.ag)(s,n,h);const c=(0,r.ag)(a[0],a[1],h),g=(0,r.ag)(a[1],a[2],h);u=(0,r.ag)(c,g,h)}return m/=u,l/=u,n.setCoords(m,l),Pi(t,n),u}function ui(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function ci(t,e,s,n,i){if(i){if(s<0)return void $(new Xr({start:t[0],end:t[0].add(Rn(t,e,0).getUnitVector())}),s,n);if(s>1)return void $(new Xr({start:t[2],end:t[2].add(Rn(t,e,1).getUnitVector())}),s-1,n)}li(t,e,s,n)}function gi(t,e,s,n){n.setEmpty();const i=[];i.push(new r.E(0,1));const o=.5*Math.max(s.width(),s.height());for(;i.length;){const a=i.at(-1);i.pop();const h=new c;if(jn(t,e,a,h),h.isIntersectingW(s)){const t=Math.max(h.width(),h.height());if(s.containsW(h)||t<=o||a.width()<1e-12)n.merge(a);else{const t=a.getCenter();i.push(r.E.construct(a.vmin,t)),i.push(r.E.construct(t,a.vmax))}}}}function di(t){return t[1]/Math.sqrt(t[0]*t[2])}function _i(t,e){const s=Math.sqrt(t[2]/t[0]);return e/(0,r.q)(s,1,e)}function pi(t,e){const s=Math.sqrt(t[0]/t[2]);return e/(0,r.q)(s,1,e)}function fi(t,e,s,o){(0,n.g)(e>=0&&e<=1),(new i.d).setCoordsPoint3D(t[0]),(new i.d).setCoordsPoint3D(t[1]),(new i.d).setCoordsPoint3D(t[2]);const a=new i.d,h=new i.d,m=new i.d;(0,r.ai)(3,t[0],t[1],e,a),(0,r.ai)(3,t[1],t[2],e,h),(0,r.ai)(3,a,h,e,m);const l=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(a),s[2].assign(m)),o&&(o[0].assign(m),o[1].assign(h),o[2].assign(l))}function xi(t,e,s,i){const o=[t[0],t[1],t[2]];(0,n.g)(e>=0&&e<=1&&s!==i);const a=(0,r.q)(o[0],o[1],e),h=(0,r.q)(o[1],o[2],e),m=(0,r.q)(a,h,e);s&&(s[0]=o[0],s[1]=a,s[2]=m),i&&(i[0]=m,i[1]=h,i[2]=o[2])}function Pi(t,e){const s=r.E.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=(0,r.s)(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=(0,r.s)(e.y,s.vmin,s.vmax)}function yi(t,e){const s=new r.E;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=(0,r.s)(e[0].x,s.vmin,s.vmax),e[1].x=(0,r.s)(e[1].x,s.vmin,s.vmax),e[2].x=(0,r.s)(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=(0,r.s)(e[0].y,s.vmin,s.vmax),e[1].y=(0,r.s)(e[1].y,s.vmin,s.vmax),e[2].y=(0,r.s)(e[2].y,s.vmin,s.vmax)}const Ei=r.az/180,Ci=180/r.az;function vi(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,r.n)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function Si(t){return t*Ei}function bi(t){return t*Ci}function Ii(t){const e=(0,r.as)();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=(0,r.n)(s,e),s<0&&(s+=e),s)}function Di(t){const e=(0,r.aj)();let s=t;return s>-e&&s<=e||(s=Ii(s),s>e&&(s-=(0,r.as)())),s}function wi(t,e){return vi(e-t)}var Ti=i.V;class Ni extends Q{constructor(t){if(void 0===t||(0,r.ae)(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new r.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new r.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return wt(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const n=r.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,n,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const n=r.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(n,t,s),this}constructLineEllipticArc(t,e){return $i(this,t,e,1),this}constructLineCircularArc(t,e){return $i(this,t,e,0),this}constructEllipse(t,e,s,n,i=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=new r.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(n),h=Math.sin(n);return o.rotateDirect(a,h),o.addThis(s),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,n,!0,i,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new a.T;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new a.T;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return function(t,e,s,i){0===s&&(0,n.a)("construct_enclosing_circle");const o=[0,0,0],a=function(t,e,s){const n=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&U(t,e)}(e,n),function(t,e,s,n){let i=0;const o=[0,0,0];let a=0,h=0;for(let m=0;m<3;++m){let l=!1;for(;h<s;){const s=t.at(e[h]);let u=1;if(3===i?u=r.P.inCircleRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]),s):2===i?u=r.P.inCircleRobust3Point(t.at(n[0]),t.at(n[1]),s):1===i&&s.equals(t.at(n[0]))&&(u=0),u<=0){if(u<0&&m+1<3){e[a]=(0,r.c)(e[h],e[h]=e[a]);for(let t=0;t<i;t++)if(n[t]===e[h]){o[t]=h;break}a++}h++;continue}l=!0;let c=0;for(let t=0;t<i;t++)o[t]>h&&(n[c]=n[t],o[c]=o[t],c++);i=c,n[i]=e[h],o[i]=h,i++,i<3?h=a:(1===r.P.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=(0,r.c)(n[0],n[0]=n[2]),o[2]=(0,r.c)(o[0],o[0]=o[2])),h++)}if(!l)break;if(m+1<3){a=0;let s=!1;for(let t=0;t<i;t++)for(let e=t+1;e<i;e++)o[t]>o[e]&&(o[e]=(0,r.c)(o[t],o[t]=o[e]),n[e]=(0,r.c)(n[t],n[t]=n[e]),s=!0);for(let t=0;t<i;t++)e[o[t]]=(0,r.c)(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===i&&1===r.P.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=(0,r.c)(n[0],n[0]=n[2]),o[2]=(0,r.c)(o[0],o[0]=o[2]))}h=i}return i}(t,n,e,s)}(e,s,o);if(1===a)t.constructCircleRadius(0,e[o[0]],i);else if(2===a){const s=r.P.lerp(e[o[0]],e[o[1]],.5),n=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s);t.constructCircleRadius(Math.max(n,a),s,i)}else if(3===a){const s=r.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),n=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s),h=r.P.distance(e[o[2]],s);t.constructCircleRadius(Math.max(n,a,h),s,i)}else(0,n.d)("unexpected")}(this,t,e,s),this}constructThreePointCircle(t,e,s,n=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const i=t.clone(),r=e.clone(),o=s.clone();return i.equals(r)&&r.assign(o),this.constructTwoPointCircle(i,r,n)}{const i=r.P.calculateCircleCenterFromThreePoints(t,e,s);if(!i.isFinite()||!Number.isFinite(r.P.distance(t,i))){const n=r.P.distance(t,e),i=r.P.distance(t,s);this.constructLineCircularArc(t,n>=i?e:s)}return this.constructCircleCenterAndPoint(i,t,n)}}constructCircularArcThreePoint(t,e,s){const n=new r.X(t.x),i=new r.X(e.x),o=new r.X(s.x),a=new r.X(t.y),h=new r.X(e.y),m=new r.X(s.y),l=new r.X(.5),u=i.subE(n),c=h.subE(a),g=o.subE(n),d=m.subE(a),_=u.mulE(d).subThisE(c.mulE(g));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!c.isZero())return $i(this,t,e,0),this;{const n=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),i=s.sub(n).length();this.constructEllipticArcEndPointsCenter(t,e,i,1,0,!0,!1,n),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const p=u.sqr().addThisE(c.sqr()).mulThisE(l),f=g.sqr().addThisE(d.sqr()).mulThisE(l),x=p.mulE(d).subThisE(f.mulE(c)),P=u.mulE(f).subThisE(g.mulE(p));x.divThisE(_),P.divThisE(_);const y=x.sqr().addThisE(P.sqr());y.sqrtThis();const E=x.addE(n),C=P.addE(a);let v=t.x-E.value(),S=t.y-C.value();const b=Math.atan2(S,v);v=e.x-E.value(),S=e.y-C.value();const I=Math.atan2(S,v);v=s.x-E.value(),S=s.y-C.value();const D=Math.atan2(S,v);let w=D-2*(0,r.aj)();for(;w<b;)w+=2*(0,r.aj)();let T=I-2*(0,r.aj)();for(;T<w;)T+=2*(0,r.aj)();let N=D+2*(0,r.aj)();for(;N>b;)N-=2*(0,r.aj)();let A,G=I+2*(0,r.aj)();for(;G>N;)G-=2*(0,r.aj)();A=T-b<b-G?T-b:G-b;const q=new r.P(E.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(A)>(0,r.aj)(),A>0,q),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,n){return this.constructEllipticArcGeneral(t,1,e,s,n,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,n,i,r,o){return Ki(this,t,e,s,n,i,r,o)}constructEllipticArcEndPointsCenter(t,e,s,n,i,r,o,a){return Ki(this,t,e,s,n,i,r,o,a)}constructEllipticArcGeneral(t,e,s,n,i,o){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const a=Di(o),h=Math.cos(a),m=Math.sin(a),l=new r.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=r.P.getNAN(),c=Di(n);u.x=l.x*Math.cos(c),u.y=l.y*Math.sin(c),u.rotateDirect(h,m),u.addThis(s);const g=(0,r.ak)(i,(0,r.as)());let d=g;Math.abs(d)===(0,r.as)()&&(d=0);const _=r.P.getNAN();return _.x=l.x*Math.cos(c+d),_.y=l.y*Math.sin(c+d),_.rotateDirect(h,m),_.addThis(s),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,r.aj)(),g>0,s)}constructEllipticArcAsNURB(t,e,s,i){return(i>=1||i<0)&&(0,n.a)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,n.a)("construct_elliptic_arc_as_NURB: control_point"),dr([t,e,s],i*i,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,xr(this),this.afterCompletedModification(),t!==this&&X(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){if(this.isLine())return!0;if(this.isMajor())return!1;const e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Ji(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return r.P.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!ar(this)}isMajor(){return mr(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return n.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let n=0,i=Ti.getComponentCount(s);e<i;e++){const e=this.queryInterval(s,n);t.setIntervalEnvelope(s,n,e)}}}else 2===t.m_EnvelopeType?Cr(this,r.E.unit(),t):(0,n.t)("3d not impl")}applyTransformation(t){sr(this,t,!1,null,null)}createInstance(){return new Ni}calculateLength2D(){return function(t){if(Ji(t))return 1*r.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;const e=tr(t,0);return tr(t,1)-e}(this)}queryControlPointsHelper(t){(0,n.d)("")}queryCoord2D(t,e){if(Ji(this))J(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(r.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(r.P.construct(this.m_XEnd,this.m_YEnd));else{const s=Oi(this,t),n=new r.P(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));n.rotateDirect(this.m_cosr,this.m_sinr),n.addThis(this.m_center),e.assign(n)}}queryCoord2DE(t,e){!function(t,e,s){if(Ji(t))st(new Xr({start:t.getStartXY(),end:t.getEndXY()}),e,s);else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const n=new r.X;Wi(t,e,n);const i=new r.X,o=new r.X;r.X.st_cosAndSin(n,i,o);const a=p.constructCoordsE(new r.X(t.m_semiMajorAxis).mulThisE(i),new r.X(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),h=new r.X(t.m_rotation);r.X.st_cosAndSin(h,i,o),a.rotateDirect(i,o),a.addThisE(p.constructPoint2D(t.m_center)),s.setE(a)}}(this,t,e)}queryCoord2DMP(t,e){(0,n.t)("")}getCoordX(t){const e=new r.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const n=new Vr;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createEllipticArc();n&&i.dropAllAttributes();let o=0===t&&1===e;if(o&&!n)return void this.copyTo(i);const a=r.P.getNAN();this.queryCoord2D(t,a);const h=r.P.getNAN();if(this.queryCoord2D(e,h),!o)if(a.equals(h))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&h.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!n)return void this.copyTo(i);if(i.m_center.assign(this.m_center),i.m_semiMajorAxis=this.m_semiMajorAxis,i.m_minorMajorRatio=this.m_minorMajorRatio,i.m_interior.assign(this.m_interior),i.m_rotation=this.m_rotation,i.m_cosr=this.m_cosr,i.m_sinr=this.m_sinr,i.m_sweepAngle=this.m_sweepAngle,i.m_startAngle=this.m_startAngle,i.m_bits=this.m_bits,D(i,a.x,a.y),T(i,h.x,h.y),o)return void ir(i,ji(this));i.m_startAngle=Oi(this,t),i.m_sweepAngle=Oi(this,e)-i.m_startAngle,i.m_startAngle=Li(i.m_startAngle),hr(i,Math.abs(i.m_sweepAngle)>(0,r.aj)()),n&&i.assignVertexDescription(this.m_description),xr(i),zi(i);const m=this.m_description.getAttributeCount();if(m>1&&!n){for(let e=1;e<m;e++){const s=this.m_description.getSemantics(e),n=Ti.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<m;t++){const s=this.m_description.getSemantics(t),n=Ti.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}i.afterCompletedModification()}queryDerivative(t,e){!function(t,e,s){if(Ji(t))s.setE(p.constructPoint2D(t.getEndXY()).subE(p.constructPoint2D(t.getStartXY())));else{const n=new r.X;Wi(t,e,n);const i=new p;if(i.setCoordsE(new r.X(t.m_semiMajorAxis).negate().mulE((new r.X).setSin(n)),new r.X(t.getSemiMinorAxis()).mulE((new r.X).setCos(n))),t.m_rotation){const e=new r.X(t.m_rotation);i.rotateDirect((new r.X).setCos(e),(new r.X).setSin(e))}i.scaleThis(new r.X(t.getSweepAngle())),s.setE(i)}}(this,t,e)}cutArcIgnoreAttributes(t,e,s){let n=0===t&&1===e;const i=new r.P;this.queryCoord2D(t,i);const o=new r.P;this.queryCoord2D(e,o),n||(i.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(n=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&i.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),n=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,D(s,i.x,i.y),T(s,o.x,o.y),n?ir(s,ji(this)):(s.m_startAngle=Oi(this,t),s.m_sweepAngle=Oi(this,e)-s.m_startAngle,s.m_startAngle=Li(s.m_startAngle),hr(s,Math.abs(s.m_sweepAngle)>Math.PI),xr(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Qi(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,o=Ti.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.ad)(o,a,h,i,Ti.getDefaultValue(e))}getClosestCoordinate(t,e){return vr(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return vr(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,n.a)("");const s=this.getSemiAxes(),i=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),o=i+(0,r.aj)(),a=(0,r.d)(3,Number.NaN);let h=0;if(a[0]=Ui(this,i),a[0]>0&&a[0]<1&&h++,a[1]=Ui(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,(0,n.g)(t.length>=h);let m=0;for(let s=0;s<h;s++){const n=a[s];this.queryCut(m,n,t[s],e),m=n}return h}getMonotonicParts(t,e){if(t.length<4&&(0,n.a)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;const s=this.getSemiAxes(),i=(0,r.d)(4,Number.NaN);i[0]=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),i[1]=i[0]+(0,r.aj)(),i[2]=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),i[3]=i[2]+(0,r.aj)();const o=(0,r.d)(5,Number.NaN);let a=0;for(let t=0;t<4;t++)o[a]=Ui(this,i[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,r.ah)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,n.g)(t.length>=a);let h=0;for(let s=0;s<a;s++){const n=o[s];this.queryCut(h,n,t[s],e),h=n}return a}intersectionWithAxis2D(t,e,s,n){if(Ji(this))return new Xr({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,n);let i,o;const a=new r.X(e),h=this.getSemiAxes();if(t){if(e>this.m_center.y+h.x||e<this.m_center.y-h.x)return 0;i=new r.X(h.x).mulThis(this.m_sinr),o=new r.X(h.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+h.x||e<this.m_center.x-h.x)return 0;i=new r.X(h.x).mulThis(this.m_cosr),o=new r.X(h.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}const m=i.sqr(),l=o.sqr(),u=m.addE(l),c=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(m),d=c.sqr().subThisE(u.mulE(g).mulThis(4)),_=i.mulE(a).mulThis(-2),p=a.sqr().subThisE(l),f=_.sqr().subThisE(u.mulE(p).mulThis(4));let x=d.eps()*Math.abs(f.value())<=f.eps()*Math.abs(d.value());x?i.isZero()&&(x=!1):o.isZero()&&(x=!0),x||(c.setE(_),g.setE(p));const P=(0,r.m)(r.X,2);let y=Yt(u,c,g,r.E.construct(-1,1),!1,P);if(0===y)return 0;const E=[0,0];let C=0;for(let t=0;t<y;t++){const e=new r.X,s=new r.X;x?(e.setE(P[t]),s.setE(a.subE(o.mulE(P[t])).divThisE(i))):(s.setE(P[t]),e.setE(a.subE(i.mulE(P[t])).divThisE(o)));const n=Ui(this,Math.atan2(e.value(),s.value()));n>=0&&n<=1&&(E[C]=n,C++)}return y=C,0===y?0:(2===y&&E[0]>E[1]&&(E[1]=(0,r.c)(E[0],E[0]=E[1])),n&&(0,r.b)(n,E,0,0,y),s&&(s[0]=t?this.getCoordX(E[0]):this.getCoordY(E[0]),y>1&&(s[1]=t?this.getCoordX(E[1]):this.getCoordY(E[1]),!n&&s[0]>s[1]&&(s[1]=(0,r.c)(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return C(this,t)}isDegenerate3D(t,e){return(0,n.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new r.E(0,1),t):(0,n.t)("3d not impl")}clone(t){const e=new Ni;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Ji(this))return 0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const n=t+Math.PI,i=[0,0];i[0]=Ui(this,t),i[1]=Ui(this,n);const o=0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY()),a=new r.P;for(let t=0;t<2;t++){const s=i[t];s>0&&s<1&&(this.queryCoord2D(s,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new r.E(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Ji(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const n=this.getCoord2D(s.vmin),i=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=r.o){let t=r.P.lerp(n,i,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*r.P.distance(n,i))),e.setCoords(n),e.mergeNe(i),void e.mergeNe(t)}Cr(this,s,e)}tToLength(t){return Ji(this)?t*r.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:tr(this,t)}parametricAngleToT(t){return Ui(this,t)}tToParametricAngle(t){return Oi(this,t)}lengthToT(t){if(Ji(this)){const e=r.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(Ji(t)){const s=r.P.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const n=Zi(t),i=(0,r.ac)(),o=er(t);s<0&&(e=-e);const a=e/t.m_semiMajorAxis+o;let h=(0,r.au)(a,n.e2,n.completeE);return h-=i,h-=t.getStartAngle(),h/s}(this,t)}calculateWeightedAreaCentroid2D(t){if(Ji(this)){const t=new r.P;return t.setCoords(0,0),t}const e=fr(this),s=this.getStartXY().sub(this.m_center),n=this.getEndXY().sub(this.m_center),i=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,h=new r.P;h.x=i*o*(i*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,h.y=i*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+i*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const m=n.add(s).mul(n.crossProduct(s)/6);return h.x-=m.x,h.y-=m.y,h.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new r.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Ji(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const n=Math.sin(e),i=Math.sin(s),o=Math.cos(e),a=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,r=s*(i-n),h=s*(o-a);t.setCoords(r,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),r=e*e,h=s*s,m=e*s,l=r-h,u=l/h,c=l/r,g=Math.sqrt(u),d=Math.sqrt(c),_=.5*m*(Math.asinh(g*i)/g+i*Math.sqrt(1+u*i*i))-.5*m*(Math.asinh(g*n)/g+n*Math.sqrt(1+u*n*n)),p=-.5*m*(Math.asin(d*a)/d+a*Math.sqrt(1-c*a*a))- -.5*m*(Math.asin(d*o)/d+o*Math.sqrt(1-c*o*o));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Ji(this)){const s=r.P.distance(t,this.m_center),n=this.getSemiAxes();if(s<n.x-e||s>n.y+e)return!1}const n=this.getClosestCoordinate(t,!1),i=new r.P;return this.queryCoord2D(n,i),r.P.distance(i,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return(0,n.g)(0),!1}getTangent(t){if(Ji(this))return this.getEndXY().sub(this.getStartXY());{const e=Oi(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Ji(this))return this.getEndXY().sub(this.getStartXY());{const e=Oi(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!lr(this)&&(Ji(this)?(ur(this),!1):cr(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new r.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new r.P(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=Oi(this,t),s=new r.P,n=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),n*Math.cos(e));const i=new r.P;i.setCoords(-this.m_semiMajorAxis*Math.cos(e),-n*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),i.rotateDirect(this.m_cosr,this.m_sinr));const o=s.sqrLength();if(0===o)return Number.NaN;const a=Math.sqrt(o);return s.divThis(a),s.crossProduct(i)/o}getMonotonicPartParams(t,e){const s=(0,r.d)(6,Number.NaN);s[0]=0;let i=1;if(this.isDegenerateToLine())s[1]=1,i=2;else{const t=this.getSemiAxes(),e=(0,r.d)(4,Number.NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=(0,r.al)());for(let t=0;t<4;t++){const n=Ui(this,e[t]);n>0&&n<1&&(s[i]=n,i++)}i>2&&(0,r.ah)(s,i),s[i]=1,i++}if(e){t<i&&(0,n.a)("");for(let t=0;t<i;t++)e[t]=s[t]}return i}calculateLowerLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Ji(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,rr(t)}calculateArea2DHelper(){return fr(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Ji(this))return;const s=this.getSemiAxes(),n=(0,r.d)(8,Number.NaN);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,i=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=i+Math.PI;n[0]=Ui(this,t),n[1]=Ui(this,e),n[2]=Ui(this,i),n[3]=Ui(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,i=Math.atan2(-s.y*t,s.x*e),r=i+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;n[4]=Ui(this,i),n[5]=Ui(this,r),n[6]=Ui(this,o),n[7]=Ui(this,a)}const i=r.P.getNAN();for(let s=0;s<8;s++){const r=n[s];t.containsExclusiveCoordinate(r)&&(this.queryCoord2D(r,i),e.mergeNe(i))}}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){const n=0===t.projectionBehavior();if(s<=2)return void $i(t,e[0],e[s-1],n?0:1);if(n){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const n=new r.P;return t.queryCoord2D(.5,n),void t.m_interior.setCoordsPoint2D(n)}const i=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),h=t.getCenter(),m=new Array(4);m[0]=t.isMajor(),m[1]=!m[0],m[2]=m[0],m[3]=!m[0];const l=new Array(4);l[0]=t.isClockwise(),l[1]=l[0],l[2]=!l[0],l[3]=!l[0];const u=Math.trunc(s<5?1:(s+4)/5),c=(0,r.m)(Ni,4),g=(0,r.d)(4,Number.NaN);let d=0;for(let t=0;t<4;t++){c[t].constructEllipticArcEndPointsCenter(e[0],e[s-1],i,o,a,m[t],l[t],h),g[t]=0;let n=0;for(let i=u;i<s-1;i+=u){const s=c[t].getClosestCoordinate(e[i],!1);g[t]+=r.P.sqrDistance(c[t].getCoord2D(s),e[i]),n++}g[t]/=n,g[t]<g[d]&&(d=t)}t.assignCopy(c[d])}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,n.d)("should not1; be called"),0}ensureXYMonotone(){if(Ji(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return $i(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=(0,r.m)(r.P,3);let e=gr(this,t);if(Kn(t)){let s=!1;if(0===this.projectionBehavior()){const n=new o.Envelope2D;n.setCoords({pt:t[0]}),n.mergeNe(t[2]);const i=new r.P;i.setSub(t[2],t[0]),i.leftPerpendicularThis(),i.normalize(),i.scale(r.P.distance(t[2],t[0]));const a=r.P.lerp(t[2],t[0],.5),h=a.sub(i),m=a.add(i);n.clipLine(h,m);const l=r.P.getClosestCoordinate(h,m,t[1],!1);t[1]=r.P.lerp(h,m,l);const u=t[2].sub(t[1]),c=t[0].sub(t[1]),g=u.crossProduct(c),d=u.dotProduct(c);e=(0,r.ac)()-Math.abs(.5*Math.atan2(g,d)),s=!0}return dr(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Qi(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,ir(e,ji(this))}reverseImpl(){or(this,!ar(this)),zi(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&xr(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const n=e.m_startAngle;return this.m_startAngle===n}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const n=Math.abs(Si(vi(bi(this.m_rotation-s.m_rotation)))),i=Math.abs((0,r.aj)()-n),o=Math.min(n,i);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;const a=this.getCoord2D(.5),h=s.getCoord2D(.5);return!!a.isEqualPoint2D(h,e)}swapImpl(t){const e=t;this.m_center=(0,r.c)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,r.c)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,r.c)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,r.c)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,r.c)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,r.c)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,r.c)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,r.c)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,r.c)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,r.c)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){ur(this),rr(this)}intersect(t,e,s,n,i){return Nr(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){if(e.length<2&&(0,n.q)(""),Ji(this))return new Xr({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s);{const e=r.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const i=this.getClosestCoordinate(t,!1),o=r.P.getNAN();return this.queryCoord2D(i,o),r.P.distance(o,t)<=s?(0,r.a8)(i,0,1)&&(this.queryCoord2D(0===i?1:0,o),r.P.distance(o,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==Ir(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,rr(this)}clearEndPointModified(){ur(this)}}function Ai(t,e,s,n,i,o){return new Mi(0,0,0,null,!1,(0,r.i)()).densifyEx(t,e,s,n,!1,o)}function Gi(t,e,s,i,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const l=t.getGeometryType();if(l===n.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(l===n.G.enumBezier){if(!i)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;const e=(0,r.d)(9,Number.NaN);let n=t.getMonotonicPartParams(e.length,e);if(e.length=n,n=Fi(t,s,e),2===n&&o&&(e[1]=.5,e.push(1),n=3),h&&h.splice(0,0,...e.slice(0,n)),a){const s=new Vr;for(let i=1;i<n;i++){const n=e[i-1],r=e[i];t.queryCut(n,r,s,!0);const o=s.get();zs(o),1===i&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return n-1}if(l===n.G.enumEllipticArc){const m=t;if(m.isDegenerateToLine()||m.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(i&&(o||!m.isMonotoneQuickAndDirty())){const l=(0,r.d)(6,Number.NaN);let u=m.getMonotonicPartParams(l.length,l);l.length=u,u=Fi(t,s,l),2===u&&o&&(l[1]=.5,l.push(1),u=3);let c=0;if(u>2){const t=new Vr,r=h||[];let o=0;for(let g=1;g<u;g++){const d=l[o],_=l[g];if(m.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=r.length,f=Xi(1===g,t.get(),e,s,i,a,h);(0,n.g)(f>0),c+=f;const x=g===u-1,P=l[o],y=t.get().getSweepAngle()/m.getSweepAngle();for(let t=p,e=r.length;t<e;t++)if(r[t]=!x||t+1<e?P+r[t]*y:1,a){const e=3*t,s=m.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Us(a.slice(e-3))}o=g}return c}}return Xi(!0,m,e,s,i,a,h)}if(l===n.G.enumRationalBezier2){const n=t;if(i&&(o||!n.isMonotoneQuickAndDirty())){const i=(0,r.d)(6,Number.NaN);let m=n.getMonotonicPartParams(i.length,i);i.length=m,m=Fi(t,s,i),2===m&&o&&(i[1]=.5,i.push(1),m=3);let l=0;if(m>2){const t=new Vr,r=h||[];for(let o=1;o<m;o++){const u=i[o-1],c=i[o];n.queryCut(u,c,t,!0);const g=r.length;l+=Vi(1===o,t.get(),e,s,!1,a,h);const d=o===m-1,_=i[o-1];for(let t=g,e=r.length;t<e;t++)if(r[t]=!d||t+1<e?_+r[t]:1,a){const e=3*t,s=n.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Le(a.slice(e-3))}}return l}}return Vi(!0,n,e,s,i,a,h)}if(l===n.G.enumBezier2){const n=t,m=(0,r.m)(r.P,3);n.queryControlPoints(m);const l=new vn;l.constructFromQuadratic(m);const u=Gi(l,e,s,i,o,a,h);if(null!=a&&null!=h){const t=3;for(let e=1,s=0;e<u;++e,s+=t){const o=new r.P;n.queryCoord2D(h[e],o);const m=a[s+t];!o.equals(m)&&(a[s+t].setCoordsPoint2D(o),i)&&Us(a.slice(s,s+4))}}return u}(0,n.t)("")}function qi(t,e,s,i,o,a,h,m,l){const u=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),u===n.G.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=(0,r.d)(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Fi(t,s,c);else{if(g=2,c[0]=0,c[1]=1,u===Ni.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else(0,n.g)(u===jt.type);c.length=g}if(2===g&&i&&(c[1]=.5,c.push(1),g=3),a){const e=new Vr;let s=1;for(;s<g;){const i=c[s-1],m=c[s];t.queryCut(i,m,e,!0);const l=(0,r.m)(r.P,3),d=[1,1,1];if(u===n.G.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(m-i)/3;c.splice(s,0,i+t),c.splice(s+1,0,i+2*t),g+=2;continue}d[1]=gr(t,l)}else{const t=e.get();t.queryControlPoints(l),t.queryWeights(d)}o&&Kn(l),1===s&&(a.push(l[0].clone()),h.push(d[0])),a.push(l[1].clone()),a.push(l[2].clone()),h.push(d[1]),h.push(d[2]),s++}}return m&&(m.length=g,(0,r.b)(m,c,0,0,g)),g-1}Ni.type=n.G.enumEllipticArc;class Mi{static constructDefault(t){return new Mi(0,0,0,t,!1,(0,r.i)())}constructor(t,e,s,o,a,h){this.m_segmentBuffer=null,this.m_dummyPoint=new i.P,this.m_progressCounter=0,this.m_progressTracker=o,this.m_bSetDensifyFlag=a,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>(0,r.ac)()?(0,r.ac)():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=h,(0,n.D)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,i,o,a){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=i>(0,r.ac)()?(0,r.ac)():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,n.D)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return(0,n.j)(e)?t:(0,n.h)(e)?this.densifyMultiPath(t):(0,n.f)(e)?this.densifySegmentImpl(t):e===n.G.enumEnvelope?this.densifyEnvelope(t):void(0,n.d)("")}densifySegmentEx(t,e,s,i,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==n.G.enumLine)&&(!i||s))return void(e?o===n.G.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===n.G.enumBezier)return void this.densifyCubicBezier(t,e,s,i,r);if(o===n.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,i,r);if(o===n.G.enumBezier2)return void this.densifyBezier2(t,e,s,i,r);if(o===n.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,i,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,i,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();e.getGeometryType()===n.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const n=s.nextSegment(),i=s.isClosingSegment();this.densifySegmentEx(n,e,t,i,null),i&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new bt({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){const e=new rs({vd:t.getDescription()});e.addEnvelope(t,!1);const s=o.Envelope2D.constructEmpty();t.queryEnvelope(s);const n=s.width(),i=s.height();return!(this.m_maxLength>0)||n<=this.m_maxLength&&i<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();e.getGeometryType()===n.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=e.getImpl(),i=t.getImpl(),o=i.getAttributeStreamRef(0),a=new Xr;for(let t=0,n=i.getPathCount();t<n;t++){const n=i.isClosedPath(t);if(0===i.getPathSize(t))continue;const h=i.getPathStart(t),m=o.readPoint2D(2*h),l=m.clone();s.startPath(m);for(let n=h+1,m=i.getPathEnd(t);n<m;n++){const t=o.readPoint2D(2*n),i=r.P.distance(l,t);if(i>this.m_maxLength){let e=Math.ceil(i/this.m_maxLength);e>(0,r.i)()&&(e=(0,r.i)());const n=1/e;let o,h,m;l.compare(t)<0?(a.setStartXY(l),a.setEndXY(t),o=0,h=1):(a.setStartXY(t),a.setEndXY(l),o=e-2,h=-1);for(let t=0,i=e-1;t<i;t++,o+=h){this.progress_(),m=n*(o+1);const t=new r.P;a.queryCoord2D(m,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),l.assign(t)}if(n){const t=r.P.distance(l,m);if(t>this.m_maxLength){const e=m;let n=Math.ceil(t/this.m_maxLength);n>(0,r.i)()&&(n=(0,r.i)());const i=1/n;let o,h;l.compare(e)<0?(a.setStartXY(l),a.setEndXY(e),o=0,h=1):(a.setStartXY(e),a.setEndXY(l),o=n-2,h=-1);const u=new r.P(0,0);let c;for(let t=0,e=n-1;t<e;t++,o+=h)this.progress_(),c=i*(o+1),a.queryCoord2D(c,u),s.lineTo(u),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,s,i,o,a){(0,n.g)(t.getGeometryType()!==n.G.enumBezier);let h=t.getStartXY().compare(t.getEndXY());0===h&&e<1&&(t.getGeometryType()===n.G.enumEllipticArc?h=t.getSweepAngle()<0?1:-1:(0,n.t)("densify segment by length"));let m=0;if(i&&(s?(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)):a.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new Vr);let n=Math.ceil(1/e);n>(0,r.i)()&&(n=(0,r.i)()),e=1/n,this.m_segmentBuffer.create(t.getGeometryType());let i,o,l,u=t;h<0?(i=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),i=n-2,o=-1,u=this.m_segmentBuffer.get());const c=n-1;for(let t=0;t<c;t++,i+=o)l=e*(i+1),s?(u.queryCoord(l,this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==l&&0!==l&&s.setAttribute(10,s.getPointCount()-1,0,1)):a.push(h>0?1-l:l),this.progress_();l=1,m+=c}(!o||o&&i&&m<2)&&(s?(t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,s,n,i){const o=new vn;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());if(0===m&&h>0){const e=(0,r.m)(r.P,4);t.queryControlPoints(e),m=e[1].compare(e[2]),0===m&&(m=e[1].compare(e[0]))}m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++l);const u=[],c=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let d=!0,_=0;if(m>0)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);u.length;){this.progress_();const t=u.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=n.mul(1-s).add(i.mul(s)),p=i.mul(1-s).add(l.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[3];t[1]=n,t[2]=g,t[3]=f,t[4].setCoords(h,e);const P=[f,p,l,x,new r.P(e,m)];u.push(P),c[c.length-1]=o+1,c.push(o+1);continue}u.pop(),c.pop(),(u.length>0||!n||n&&s&&l<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(1-h),++l)}else for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);u.length;){this.progress_();const t=u.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=n.mul(1-s).add(i.mul(s)),p=i.mul(1-s).add(l.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[0];t[0]=f,t[1]=p,t[2]=l,t[4].setCoords(e,m);const P=[x,n,g,f,new r.P(h,e)];u.push(P),c[c.length-1]=o+1,c.push(o+1);continue}u.pop(),c.pop(),(u.length>0||!n||n&&s&&l<2)&&(e?(a.queryCoord(m,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(m),++l)}}densifyRationalBezier2(t,e,s,n,i){const o=new jt;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new jt,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!n||n&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(m>0?1-s:s),++l}}}densifyBezier2(t,e,s,n,i){const o=new Qt;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++l);const u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),c=new Qt,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<u&&this.bezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!n||n&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(m>0?1-s:s),++l}}}densifyEllipticArc(t,e,s,n,i){const o=new Ni;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=t.isClockwise()?0:1),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new Ni,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!n||n&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(m>0?1-s:s),++l}}}calculateLengthSubdivisionStep(t,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===n.G.enumEllipticArc){const n=t;if(n.isCircular()||n.isDegenerate(0)||n.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*n.getSemiAxes().y/n.getSemiAxes().x}t.getGeometryType()===n.G.enumBezier&&(0,n.t)(""),(0,n.t)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===n.G.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const n=s.getSemiMajorAxis(),i=1-e/n;let r=Math.PI/2;if(i>0){const t=4*Math.sqrt(e/n*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*n;return this.calculateLengthSubdivisionStep(t,o)}}(0,n.t)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===n.G.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}(0,n.t)("")}rationalBezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0;const o=(0,r.m)(r.P,3);e.queryControlPoints(o);const a=[0,0,0];return e.queryWeights(a),!i&&this.m_maxDeviation>0&&(i=!Mi.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Mi.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),i}bezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0;const o=(0,r.m)(r.P,3);return e.queryControlPoints(o),!i&&this.m_maxDeviation>0&&(i=!Mi.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Mi.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),i}ellipticArcNeedsSplit(t,e,s,n){t.cutArcIgnoreAttributes(s,n,e);let i=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(i=!0,!0):(!i&&this.m_maxDeviation>0&&(i=!Mi.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Mi.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),i)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&r.P.distance(t[0],t[1])+r.P.distance(t[1],t[2])+r.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!Mi.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Mi.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1])),o=n.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(i),Math.abs(o))<=e){const e=new r.P;Zs(t,.5,e,!1);const n=e.sub(t[0]).dotProduct(s);return n>=0&&n<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[1]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const n=t[2].sub(t[0]);if(n.sqrLength()>0){const e=n.clone();e.leftPerpendicularThis(),e.normalize();const i=e.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=s){const e=t[1].sub(t[0]).dotProduct(n);return e>=0&&e<=n.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const n=t[2].sub(t[0]);n.normalize();{const e=t[1].sub(t[0]),i=e.dotProduct(n);if(i<0)return!1;if(e.length()*s>i)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),i=[0,0];if(1===function(t,e,s){(0,n.g)(!Ji(t));const i=new a.T;i.setRotateAngle(-t.getAxisXRotation());const o=new r.P;i.queryTransform(e,o);const h=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),m=h+(0,r.aj)();let l=Ui(t,h),u=Ui(t,m);u<l&&(u=(0,r.c)(l,l=u));let c=0;return l>=0&&l<=1&&(s[c++]=l),u>=0&&u<=1&&(s[c++]=u),c}(t,s,i)){const s=t.getCoord2D(i[0]),n=r.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),o=new r.P;return(0,r.Q)(t.getStartXY(),t.getEndXY(),n,o),r.P.distance(s,o)<=e}}const s=t.getCoord2D(.5),i=new r.P;return(0,r.Q)(t.getEndXY(),t.getStartXY(),.5,i),r.P.distance(s,i)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),n=t.getTangent(1),i=s.dotProduct(n);return!(i<0||s.length()*n.length()*e>i)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==n.G.enumEllipticArc||t.isCircular())}}function Fi(t,e,s){const n=s.length;if(e<=0||n<=2)return n;let i=0;const o=(0,r.d)(n-1,Number.NaN);for(let e=1,r=n;e<r;e++){const n=t.tToLength(s[e]);o[e-1]=n-i,i=n}for(;o.length>1;){const t=o.findIndex(t=>t<=2*e);if(-1===t)break;let n=t+1,i=t+1;if(t>0){const e=t-1;(i===o.length||o[e]>o[i])&&(i=e,n--)}o[i]+=o[t],o.splice(t,1),s.splice(n,1)}return s.length}function Xi(t,e,s,n,i,h,m,l){const u=e.clone();u.dropAllAttributes();const c=(t,e,s,n)=>(e&&(t&&e.push(n.getStartXY()),e.push(r.P.getNAN()),e.push(r.P.getNAN()),e.push(n.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(u.isDegenerateToLine()||u.isDegenerate(0))return c(t,h,m,e);const g=u.getStartXY(),d=u.getEndXY(),_=u.getSemiAxes(),p=new a.T;if(u.isCircular())p.setIdentity();else{const t=u.getAxisXRotation();p.setScaleCoords(1,u.getMinorMajorRatio()),p.rotateAngle(t)}const f=u.getCenter();p.shift(f);const x=p.clone();x.invertThis(),u.applyTransformation(x);const P=u.getSweepAngle();if(0===P)return c(t,h,m,e);const y=o.Envelope2D.constructEmpty();y.setCoords({center:f,width:2*_.x,height:2*_.x});const E=.05*y.calculateToleranceFromEnvelope(),C=Math.max(s/_.x,E/_.x);let v=4*Math.pow(C/.0741,1/6);v=Math.min(v,Math.PI/2);const S=Ii(u.getStartAngle());let b=P>0?Math.floor(S/v):Math.ceil(S/v);b*=v;const I=P>0?v:-v;b+I===S&&(b+=I);let D=4/3*Math.tan(Math.abs(v)/4);P>0&&(D=-D),m&&t&&m.push(0);const w=v/Math.abs(P);let T=(b-S)/P;const N=g.clone(),A=new r.P;u.queryCoord2D(0,A);const G=A.clone(),q=1-.01*w;let M=0,F=0;for(;T<1;){let s;if(T+=w,F>0&&T<q)s=D;else{T>=q&&(T=1);const t=(T-F)*P;s=4/3*Math.tan(Math.abs(t)/4),P>0&&(s=-s)}u.queryCoord2D(T,A);const o=new r.P;p.queryTransform(A,o);const a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==T&&(r.P.distance(N,o)<=2*n||r.P.distance(o,d)<=2*n))continue;N.setCoordsPoint2D(o);const l=(0,r.m)(r.P,4);l[0].assign(G),l[3].assign(A),l[1].rightPerpendicularOther(G),l[1].scaleAddThis(s,G),l[2].leftPerpendicularOther(A),l[2].scaleAddThis(s,A),p.transformPoints2D(l,3,l),l[3].assign(o),0===F&&l[0].setCoordsPoint2D(g),1===T&&l[3].setCoordsPoint2D(d),i&&Us(l);let c=!0;for(let t=1;t<4;t++)if(!l[t].isEqualPoint2D(l[0])){c=!1;break}c||(m&&m.push(a),h&&(0===F&&t&&h.push(l[0].clone()),h.push(l[1].clone()),h.push(l[2].clone()),h.push(l[3].clone())),M++),F=T,G.setCoordsPoint2D(A)}return M}function Vi(t,e,s,n,i,a,h,m){e.clone().dropAllAttributes();const l=new o.Envelope2D;e.queryLooseEnvelope(l);const u=.05*l.calculateToleranceFromEnvelope(),c=Math.max(s,u);h&&t&&h.push(0);let g=0;const d=(0,r.m)(r.P,3);e.queryControlPoints(d);const _=[0,0,0];e.queryWeights(_);const p=[],f=(0,r.d)(9,Number.NaN);let x=0;i?(x=e.getMonotonicPartParams(f.length,f),f.length=x,x=Fi(e,n,f)):(f.length=2,x=2,f[0]=0,f[1]=1);let P=0,y=t;for(let t=1;t<x;t++){const e=f[t];for(p.length=0,p.push(e),p.push(P);p.length>1;){const t=p.at(-1);p.pop();const e=p.at(-1),s=(0,r.m)(r.P,3),n=[0,0,0];Jn(d,_,t,e,s,n);const i=(0,r.m)(r.P,4),o=ti(s,n,i),m=16,l=p.length>m;c>=o||l?(h.push(e),a&&(y&&(a.push(i[0]),y=!1),a.push(i[1]),a.push(i[2]),a.push(i[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class Yi{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?r.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function Ri(t,e){return t.convertToCanonic(e)}function ki(t,e,s,n){let i=t.m_startAngle,o=t.m_sweepAngle;const a=1e-12;for(;i>(0,r.aj)();)i-=2*(0,r.aj)();for(;i<=-(0,r.aj)();)i+=2*(0,r.aj)();if(!Number.isNaN(e)){for(;e>(0,r.aj)();)e-=2*(0,r.aj)();for(;e<=-(0,r.aj)();)e+=2*(0,r.aj)();!s&&e>i&&(e-=2*(0,r.aj)()),s&&e<i&&(e+=2*(0,r.aj)()),o=e-i,Math.abs(o)<a&&!n&&(o=s?2*(0,r.aj)():-2*(0,r.aj)()),Math.abs(o)>2*(0,r.aj)()-a&&n&&(o=0)}Math.abs(o)>2*(0,r.aj)()-a&&(o=o>=0?2*(0,r.aj)():-2*(0,r.aj)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),n=Math.abs(o)<=(0,r.aj)(),o&&(s=o>0),t.m_startAngle=Li(i),t.m_sweepAngle=o,hr(t,!n),or(t,s)}function Li(t){let e=t,s=!1;return e<=-(0,r.aj)()?(e+=(0,r.as)(),s=!0):e>(0,r.aj)()&&(e-=(0,r.as)(),s=!0),e<=-(0,r.aj)()?(e=(0,r.n)(e,(0,r.as)()),e<=-(0,r.aj)()&&(e+=(0,r.as)()),s=!0):e>(0,r.aj)()&&(e=(0,r.n)(e,(0,r.as)()),e>(0,r.aj)()&&(e-=(0,r.as)()),s=!0),s&&(e>(0,r.aj)()||e<=-(0,r.aj)())&&(e=(0,r.aj)()),e}function Bi(t,e,s){const n=s,i=n.getSemiAxes();let o=new r.P(i.x*Math.cos(t[0]),i.y*Math.sin(t[0]));return o=n.convertFromCanonic(o),r.P.sqrDistance(o,n.getStartXY())}function Hi(t,e,s){const n=s,i=n.getSemiAxes(),o=t[0]+n.getStartAngle();let a=new r.P(i.x*Math.cos(o),i.y*Math.sin(o));return a=n.convertFromCanonic(a),r.P.sqrDistance(a,n.getEndXY())}function zi(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),n=e.equals(s),i=mr(t),o=ar(t),a=t.projectionBehavior();if(n){const s=t.convertToCanonic(e),n=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=n.x,s.y/=n.y,t.m_startAngle=Li(Math.atan2(s.y,s.x)),t.m_sweepAngle=i?o?(0,r.as)():-(0,r.as)():0}else{const n=t.convertToCanonic(e),h=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);n.x/=h.x,n.y/=h.y;const m=t.convertToCanonic(s);m.x/=h.x,m.y/=h.y,t.m_startAngle=Math.atan2(n.y,n.x),t.m_sweepAngle=r.P.calculateAngle(n,m),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,r.as)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,r.as)()),t.m_startAngle=Li(t.m_startAngle);let l=Bi([t.m_startAngle],0,t);if(l=Math.sqrt(l),l>.25*V(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,n=[0];qt(Bi,t,1,[t.m_startAngle],[e],[s],0,n),t.m_startAngle=Li(n[0])}if(l=Hi([t.m_sweepAngle],0,t),l=Math.sqrt(l),l>.25*V(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,n=[0];qt(Hi,t,1,[t.m_sweepAngle],[e],[s],0,n),t.m_sweepAngle=n[0]}const u=Math.abs(t.m_sweepAngle)>(0,r.aj)();if(hr(t,u),i!==u&&!i&&Math.abs(t.m_sweepAngle)>1.5*(0,r.aj)())return void $i(t,e,s,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void $i(t,e,s,a)}}function Ui(t,e){return(function(t,e){const s=new r.E(t.getStartAngle(),t.getEndAngle());s.normalize();const n=(0,r.as)(),i=(0,r.n)(e,n);if(i<s.vmin){let t=i+n;for(;t<s.vmin;)t+=n;return s.containsCoordinate(t)?t:s.vmin-i<t-s.vmax?i:t}if(i>s.vmax){let t=i-n;for(;t>s.vmax;)t-=n;return s.containsCoordinate(t)||s.vmin-t<i-s.vmax?t:i}return i}(t,e)-t.getStartAngle())/t.getSweepAngle()}function Oi(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Wi(t,e,s){s.assign(new r.X(t.m_startAngle).addE(e.mulE(new r.X(t.m_sweepAngle))))}function ji(t){return t.m_cachedValues}function Zi(t){if(t.m_cachedValues)return t.m_cachedValues;const e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,r.a)(t.m_minorMajorRatio)}(t),e.completeE=(0,r.ay)(e.e2),t.m_cachedValues=e,e}function Qi(t,e,s,n){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Ji(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,xr(t),void t.afterCompletedModification();if(n&&Math.abs(t.getSweepAngle())<=1.01*(0,r.ac)()){const n=(0,r.m)(r.P,3),i=gr(t,n);if(Zn(n)){if(n[0].assign(e),n[2].assign(s),Kn(n),0===t.projectionBehavior()){let e=0,s=2;r.P.sqrDistance(n[1],n[0])<r.P.sqrDistance(n[1],n[2])&&(s=(0,r.c)(e,e=s));const i=n[s].sub(n[e]),o=i.length();i.divThis(o);const a=n[1].sub(n[e]),h=a.length(),m=a.dotProduct(i)/h,l=a.crossProduct(i)/h,u=new r.P;(0,r.Q)(n[e],n[s],.5,u);const c=.5*o/l*(0,r.s)(1-m,0,1),g=n[1].side(n[e],n[s]),d=i.clone();g?d.leftPerpendicularThis():d.rightPerpendicularThis();const _=u.sub(d.mul(c));t.constructCircularArcThreePoint(n[0],n[2],_)}else dr(n,i*i,null,!1,t);return}}0===t.projectionBehavior()?function(t,e,s){const n=t.getStartXY(),i=t.getEndXY(),o=n.equals(i),h=e.equals(s);if(!o&&!h){const o=new a.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);const h=r.P.distance(e,s),m=r.P.distance(n,i),l=h/m;o.scale(l,l);const u=i.sub(n);u.divThis(m);const c=s.sub(e);c.divThis(h);const g=u.crossProduct(c),d=c.dotProduct(u);return o.rotate(d,g),o.shiftCoords(e.x,e.y),void sr(t,o,!0,e,s)}const m=new r.P;if(t.queryCoord2D(.5,m),h){if(o){const i=t.m_center.add(e.sub(n));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),i),t.setProjectionBehavior(0)}else if(t.isMajor()){const n=m.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,n)}else t.constructCircularArcThreePoint(e,s,e);return}const l=e.add(s).mul(.5),u=s.sub(e);u.rightPerpendicularThis();const c=l.add(u),g=r.P.getClosestCoordinate(l,c,t.getCenter(),!0),d=new r.P;(0,r.Q)(l,c,g,d);const _=r.P.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}(t,e,s):br(t,e,s)}}function Ki(t,e,s,n,i,r,o,a,h){return t.m_bits=0,t.m_rotation=r,I(t,e),w(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),hr(t,o),or(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=n,t.m_minorMajorRatio=i,cr(t,void 0===h)}function $i(t,e,s,n){t.m_bits=0,t.m_rotation=0,I(t,e),w(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,hr(t,!1),or(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(n),t.afterCompletedModification()}function Ji(t){return t.m_center.isNAN()}function tr(t,e){if(0===e)return 0;const s=Zi(t),n=Oi(t,e),i=(0,r.ac)(),o=er(t),a=(0,r.at)(n+i,s.e2,s.completeE),h=t.m_semiMajorAxis*(a-o);return Math.abs(h)}function er(t){const e=Zi(t);return(0,r.at)(t.getStartAngle()+(0,r.ac)(),e.e2,e.completeE)}function sr(t,e,s,i,o){if(2===e.m_TransformationType)return void(0,n.g)(0);if((0,n.g)(!lr(t)),e.isIdentity()&&(!i||i.equals(t.getStartXY())&&o.equals(t.getEndXY())))return;rr(t);let a=r.P.getNAN(),h=r.P.getNAN();if(null===i?(a.x=t.m_XStart,a.y=t.m_YStart,e.transformInPlace(a),h.x=t.m_XEnd,h.y=t.m_YEnd,e.transformInPlace(h)):(a=i,h=o),Ji(t))return t.m_XStart=a.x,t.m_YStart=a.y,t.m_XEnd=h.x,void(t.m_YEnd=h.y);const m=t.m_center.clone();if(e.transformInPlace(m),s||e.isUniformNoRotation()){let s=ar(t);if(e.isReflective()&&(s=!s),0===t.projectionBehavior()){if(!a.equals(h)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(a,h,s)}return void nr(t,a,h,m,s,!1)}const n=new r.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(n);const i=Math.atan2(n.y,n.x),o=t.getSemiAxes();e.transformWithoutTranslateInPlace(o);const l=t.m_center.clone();return e.transformInPlace(l),void t.constructEllipticArcEndPointsCenter(a,h,o.x,o.y/o.x,i,t.isMajor(),s,l)}{{const s=new Array(4);!function(t,e){const s=new r.X(t.m_cosr).sqrThis(),n=new r.X(t.m_sinr).sqrThis(),i=new r.X(t.m_minorMajorRatio),o=new r.X(1/t.m_minorMajorRatio),a=i.mulE(s).addThisE(o.mulE(n)),h=i.subE(o).mulThis(2*t.m_cosr*t.m_sinr),m=i.mulE(n).addThisE(o.mulE(s));e[0]=a,e[1]=h,e[2]=m,e[3]=new r.X(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,s);const n=new f;if(n.a11.setE(s[0]),n.a12.setE(s[1]),n.a12.mulThisByPower2(.5),n.a21.setE(n.a12),n.a22.setE(s[2]),!n.det().isZero()){const i=new f;if(i.a11.set(e.xx),i.a12.set(e.xy),i.a21.set(e.yx),i.a22.set(e.yy),i.invertThis()){const o=i.clone();o.transposeThis();const l=n.clone();if(l.mulThis(i),l.mulLeftThis(o),!l.det().isZero()){const n=(0,r.m)(r.X,4);n[0].setE(l.a11),n[1].setE(l.a12),n[1].mulThisByPower2(2),n[2].setE(l.a22),n[3].setE(s[3]);const i=r.P.getNAN(),o=function(t,e){const s=new f;s.a11.setE(t[0]),s.a12=r.X.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const n=[r.P.getNAN(),r.P.getNAN()],i=[new r.X,new r.X];s.eigenSymmetric(i,n);const o=t[3].clone();return o.negateThis(),o.invThis(),i[0].mulThisE(o),i[1].mulThisE(o),i[0].sqrtThis().invThis(),i[1].sqrtThis().invThis(),e.x=i[0].toDouble(),e.y=i[1].toDouble(),Math.atan2(n[0].y,n[0].x)}(n,i);let u=ar(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(a,h,i.x,i.y/i.x,o,t.isMajor(),u,m)}}}}const s=[r.P.getNAN(),r.P.getNAN(),r.P.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let n=t.isClockwise();n&&(s[2]=(0,r.c)(s[0],s[0]=s[2]));const i=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(n=!n);const o=new r.P(0,0),l=t.createInstance();dr(s,i,o,!1,l),t.constructEllipticArcEndPointsCenter(a,h,l.getSemiMajorAxis(),l.getMinorMajorRatio(),l.getAxisXRotation(),t.isMajor(),!n,m)}}function nr(t,e,s,n,i,r){const o=.5*(n.sub(e).length()+n.sub(s).length());t.m_center.assign(n),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),ki(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),i,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,n);return t.setProjectionBehavior(0),a}function ir(t,e){t.m_cachedValues=e}function rr(t){t.m_cachedValues=null}function or(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function ar(t){return!!(1&t.m_bits)}function hr(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function mr(t){return!!(2&t.m_bits)}function lr(t){return!!(8&t.m_bits)}function ur(t){t.m_bits&=-9}function cr(t,e){ur(t);const s=t.getStartXY(),i=t.getEndXY();let o=!1;const a=mr(t),h=ar(t),m=t.projectionBehavior(),l=s.equals(i);let u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,n.n)("NAN minor major ratio and non-zero major axis")),u||=e?l:t.m_center.isNAN(),u)return $i(t,s,i,m),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const c=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if((0,n.g)(c.y>0&&c.x>=c.y),l){const e=t.convertToCanonic(s);(0,n.g)(!c.isZero()),e.x/=c.x,e.y/=c.y;const i=Math.sqrt((0,r.a)(e.x)+(0,r.a)(e.y));if(o=1!==i,t.m_semiMajorAxis*=i,c.mulThis(i),t.m_startAngle=Li(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=h?(0,r.as)():-(0,r.as)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;const e=new p;e.setWithEps(t.getStartXY(),8),e.subThisE((new p).setWithEps(t.m_center,8));const s=new r.X;s.setWithEps(t.m_rotation,8);const n=new r.X,i=new r.X;r.X.st_cosAndSin(s,n,i),e.rotateReverse(n,i);const o=new p;o.setWithEps(t.getEndXY()),o.subThisE(p.constructPoint2D(t.m_center)),o.rotateReverse(n,i);const a=new r.X;a.setWithEps(t.m_semiMajorAxis,8);const h=a.clone(),m=new r.X;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),e.x.divThisE(a),e.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const l=e.x.sqr().addThisE(e.y.sqr()).subThisE(r.a6),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(r.a6);return!l.isZero()||!u.isZero()}(t);if(!e){const n=t.convertToCanonic(s);n.x/=c.x,n.y/=c.y;const o=new r.P(1,0);t.m_startAngle=r.P.calculateAngle(o,n);const a=t.convertToCanonic(i);a.x/=c.x,a.y/=c.y,t.m_sweepAngle=r.P.calculateAngle(n,a),e=!pr(t)}if(e){o=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let n=(0,r.a)(e.x/c.x)+(0,r.a)(e.y/c.y);n>1&&(n=Math.sqrt(n),t.m_semiMajorAxis*=n,c.mulThis(n));const m=new r.P(0,0);{const t=c.x*c.x,s=c.y*c.y,n=t*e.y*e.y+s*e.x*e.x,i=t*s-n;if(i>0){const t=Math.sqrt(i/n);m.setCoords(c.x*e.y/c.y,-c.y*e.x/c.x),m.mulThis(t),a===h&&m.negateThis()}}{const e=new r.P(m.x,m.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(zi(t),!pr(t))return $i(t,s,i,m),!0}return xr(t),t.afterCompletedModification(),o}function gr(t,e){(0,n.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),i=t.getSemiMinorAxis();let o;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),o=1,o;if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=r.P.lerp(e[0],e[2],.5),o=1,o;const a=t.getSweepAngle(),h=t.getStartAngle(),m=h+a,l=new r.P(-s*Math.sin(h),i*Math.cos(h)),u=new r.P(-s*Math.sin(m),i*Math.cos(m));l.normalize(),u.normalize(),l.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const c=l.crossProduct(u);return e[1].assign(l.mul(e[1].crossProduct(u)/c)),e[1].addThis(e[0]),o=Math.cos(.5*a),o}function dr(t,e,s,i,o){if(i){const s=.5,n=Math.sqrt(e),i=(0,r.a)(1-s)+2*n*s*(1-s)+(0,r.a)(s),a=t[0].mul((0,r.a)(1-s)).add(t[1].mul(2*n*s*(1-s))).add(t[2].mul((0,r.a)(s))).divThis(i);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}const a=t[0].sub(t[1]),h=t[2].sub(t[1]),m=a.crossProduct(h),l=a.dotProduct(h),u=e;(0,n.g)(u<=1),(0,n.g)(u>0);const c=.5/(1-u),g=a.sqrLength(),d=l,_=h.sqrLength(),p=(0,r.a)(m),f=a.sub(h).sqrLength();if(0===p)return $i(o,t[0],t[2],1),!1;if(l<=-Math.sqrt(g)*Math.sqrt(_))return $i(o,t[0],t[2],1),!1;const x=[0,0],P=new r.E;P.setInfinite();const y=At(2*p,-(f/u+4*d),2*(1-u)/u,P,!1,x);if(0===y)return $i(o,t[0],t[2],1),!1;1===y&&(x[1]=x[0]);const E=Math.sqrt(c/x[0]),C=Math.sqrt(c/x[1]),v=.5/u;let S=v-_*x[0],b=v-g*x[0];Math.abs(S)>Math.abs(b)?b=d*x[0]-v+1:S=d*x[0]-v+1;const I=a.mul(S).add(h.mul(b)),D=I.norm(1)<1e-15*E?0:Math.atan2(I.y,I.x)+Math.PI,w=a.add(h),T=s?s.clone():t[1].add(w.mul(c)),N=t[0].sub(T),A=t[2].sub(T),G=N.crossProduct(A)<0;return new Ni,o.constructEllipticArcEndPointsCenter(t[0],t[2],E,C/E,D,!1,!G,T)}function _r(t,e,s,n,i){return dr(t,e,s,n,i)}function pr(t){const e=V(t);let s=!1;{const n=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));n.rotateDirect(t.m_cosr,t.m_sinr),n.addThis(t.m_center),s=r.P.distance(t.getStartXY(),n)>e}let n=!1;if(!s){const s=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),n=r.P.distance(t.getEndXY(),s)>e}return!s&&!n}function fr(t){if(Ji(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),n=e*e+s*s,i=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,l=0;t.m_rotation&&(m=(a-h)*(a+h),l=2*a*h);const u=((-.5*(r-i)+.25*m*(2*Math.cos(r+i)*Math.sin(r-i)))*s+-2*Math.sin(.5*(r+i))*Math.sin(.5*(r-i))*a*o)*e/n;let c=0;return t.m_rotation&&(c=-2*Math.sin(r+i)*Math.sin(r-i)*.125*l-s*o/n*(2*Math.cos(.5*(r+i))*Math.sin(.5*(r-i)))*h),n*(u+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function xr(t){t.queryCoord2D(.5,t.m_interior)}function Pr(t,e,s,n,i){if(i){if(0!==wr(e,s))return 2}else if(E(e,s))return 1;return 0!==yr(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function yr(t,e,s,i,o,a,h,m,l,u){if(Ji(e))return ot(new Xr({start:e.getStartXY(),end:e.getEndXY()}),s,i,o,a,h,m,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==i&&(i.length=0);const c=Y(e,s);if(R(e,s,h=Math.max(c,h)))return 0;const g=s.getStartXY();g.subThis(e.m_center);const d=s.getEndXY();d.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);const _=d.clone();_.subThis(g);const p=e.m_semiMajorAxis,f=1/p,x=e.getSemiMinorAxis(),P=1/x,y=_.clone();y.leftPerpendicularThis();const E=Math.atan2(x*y.y,p*y.x),C=(0,r.d)(16,Number.NaN),v=(0,r.d)(16,Number.NaN);let S=0;const b=[E,E+Math.PI];for(let t=0;t<2;++t){const n=Ui(e,b[t]);if(n>=0&&n<=1){C[S]=n;const t=e.getCoord2D(C[S]);v[S]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(v[S]))<=h&&S++}}const I=g.x*f,D=g.y*P,w=_.x*f,T=_.y*P;let N=At(w*w+T*T,2*(I*w+D*T),I*I+D*D-1,r.E.unit(),!1,v);(0,n.g)(N>=0);for(let t=0;t<N;t++){const n=_.mul(v[t]).add(g);n.x*=f,n.y*=P;const i=Ui(e,Math.atan2(n.y,n.x));if(i>=0&&i<=1){C[S]=i;const t=e.getCoord2D(i);v[S]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(v[S]))<=h&&S++}}(0,n.g)(S<C.length+4);const A=(0,r.d)(16,Number.NaN);N=e.intersectPoint(s.getStartXY(),A,h);for(let t=0;t<N;t++,S++)C[S]=A[t],v[S]=0;N=e.intersectPoint(s.getEndXY(),A,h);for(let t=0;t<N;t++,S++)C[S]=A[t],v[S]=1;N=s.intersectPoint(e.getStartXY(),A,h);for(let t=0;t<N;t++,S++)C[S]=0,v[S]=A[t];N=s.intersectPoint(e.getEndXY(),A,h);for(let t=0;t<N;t++,S++)C[S]=1,v[S]=A[t];return 0===S?0:Gr(t,e,s,C,v,S,i,o,a,h,m,0,u)}function Er(t,e,s,i,o,a,h,m,l,u){if(Ji(e)){const n=new Xr({start:e.getStartXY(),end:e.getEndXY()});return yr(t,s,n,i,a,o,h,m,0,!u)}if(Ji(s)){const n=new Xr({start:s.getStartXY(),end:s.getEndXY()});return yr(t,e,n,i,o,a,h,m,0,u)}const c=Y(e,s);h=Math.max(h,c);let g=!1;{const t=e.getSemiAxes(),i=e.getCenter(),u=s.getSemiAxes(),c=s.getCenter(),d=r.P.distance(c,i),_=t.x+u.x;if(d>_+h)return 0;if(t.y>u.x){if(d+u.x+h<t.y)return 0}else if(u.y>t.x&&d+t.x+h<u.y)return 0;if(l&&!m){const i=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),r=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(i&&r&&(g=!0,d<=_)&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+d)return(0,n.g)(!o&&!a),1}}if(!g&&R(e,s,h))return 0;const d=[],_=[],p=!1,f=!1,x=qi(e,0,0,p,f,d,_,null),P=[],y=[],E=qi(s,0,0,p,f,P,y,null);if(1===x&&1===E){const t=new jt({points:d,weights:_}),n=new jt({points:P,weights:y}),c=[],g=[],p=oi(!1,t,n,i,null===o?null:c,null===a?null:g,h,m,l,u);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let i=0;i<p;++i){if(o)if((0,r.a8)(c[i],0,1))o.push(c[i]);else{const s=t.tToLength(c[i]),n=e.lengthToT(s);o.push(n)}if(a)if((0,r.a8)(g[i],0,1))a.push(g[i]);else{const t=n.tToLength(g[i]),e=s.lengthToT(t);a.push(e)}}}return p}let C=[];const v=[];let S=0;const b=l&&!m;for(let t=0;t<x;t++){const n=new jt({points:d.slice(2*t,2*t+3),weights:_.slice(2*t,2*t+3)});let i=0;for(let o=0;o<E;o++){v.length<=o&&v.push(new jt({points:P.slice(2*o,2*o+3),weights:y.slice(2*o,2*o+3)}));const a=[],m=[],l=b?null:a,u=b?null:m,c=oi(!1,n,v[o],null,l,u,h,!1,b,!1);if(c>0&&b)return 1;for(let h=0;h<c;++h){if(0===a[h]&&0===t)a[h]=0;else if(1===a[h]&&t===x-1)a[h]=1;else{const t=n.tToLength(a[h])+S,s=e.lengthToT(t);a[h]=s}if(0===m[h]&&0===o)m[h]=0;else if(1===m[h]&&o===E-1)m[h]=1;else{const t=v[o].tToLength(m[h])+i,e=s.lengthToT(t);m[h]=e}C.push((0,r.l)(a[h],m[h]))}i+=v[o].calculateLength2D()}S+=n.calculateLength2D()}if(0===C.length)return 0;if(m&&(C=C.filter(t=>!(0,r.a8)(t.first,0,1)||!(0,r.a8)(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second)))),l)return C.length;const I=[],D=[];for(const t of C)I.push(t.first),D.push(t.second);return Gr(t,e,s,I,D,I.length,i,o,a,h,m,0,u)}function Cr(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Ji(t))return;const n=t.getSemiAxes(),i=[0,0,0,0];{const e=Math.atan2(-n.y*t.m_sinr,n.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(n.y*t.m_cosr,n.x*t.m_sinr),o=r+Math.PI;i[0]=Ui(t,e),i[1]=Ui(t,s),i[2]=Ui(t,r),i[3]=Ui(t,o)}const o=new r.P;for(let n=0;n<4;n++){const r=i[n];e.containsExclusiveCoordinate(r)&&(t.queryCoord2D(r,o),s.mergeNe(o))}}function vr(t,e,s,i,o){if(0===t.m_semiMajorAxis)return s.vmin;let a=r.P.getNAN();t.queryCoord2D(s.vmin,a);let h=r.P.getNAN();if(t.queryCoord2D(s.vmax,h),Ji(t))return new Xr({start:a,end:h}).getClosestCoordinate(e,i);const m=Ri(t,e);if(a=Ri(t,a),h=Ri(t,h),1===t.m_minorMajorRatio){if(m.isEqual(0,0))return s.vmin;const e=Ui(t,Math.atan2(m.y,m.x));return i||s.containsCoordinate(e)?e:r.P.distance(m,a)<=r.P.distance(m,h)?s.vmin:s.vmax}const l=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),c=(l-u)*(l+u),g=(0,r.a)(c),d=m.x,_=m.y,p=(0,r.a)(u*_),f=u*c*_*2,x=[new r.X(p),new r.X(f),new r.X(g-(0,r.a)(l*d)-p),new r.X(-f),new r.X(-g)],P=(0,r.m)(r.X,4),y=kt(x,4,new r.E(-1,1),!1,P,4);let E=s.vmin,C=r.P.sqrDistance(m,a);{const t=r.P.sqrDistance(m,h);t<C&&(E=s.vmax,C=t)}(0,n.g)(!i);let v=(0,r.d)(8,Number.NaN);for(let e=0;e<y;++e){const s=P[e].value(),n=Math.sqrt(1-s*s),i=Math.atan2(s,n),r=Math.atan2(s,-n);v[2*e]=Ui(t,i),v[2*e+1]=Ui(t,r)}v=v.slice(0,2*y),(0,r.v)(v);for(let n=0,i=2*y;n<i;++n)if(v[n]>s.vmin&&v[n]<s.vmax){const s=r.P.sqrDistance(e,t.getCoord2D(v[n]));C>s&&(C=s,E=v[n])}return E}function Sr(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&t.isMajor()!==e.isMajor()&&!!t.m_center.equals(e.m_center)&&t.m_sinr===e.m_sinr&&t.m_cosr===e.m_cosr&&t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function br(t,e,s,i){const o=t.getStartXY(),h=t.getEndXY(),m=o.equals(h),l=e.equals(s);if(!m&&!l){const n=new a.T;return n.initializeFromTwoPoints(o,h,e,s),sr(t,n,!0,e,s),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void $i(t,e,s,1);if(m&&l){const n=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),n)}if(!m){const n=.5*((0,r.as)()-Math.abs(t.getSweepAngle())),i=(t.getSweepAngle()+n*(0,r.e)(t.getSweepAngle()))/t.getSweepAngle(),o=new r.P;t.queryCoord2D(i,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}const u=r.P.sqrDistance(e,s);let c=.25,g=.75;if(u<r.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=Nt(new Yi(t,u),r.E.construct(0,.25),1,e);s>0&&((0,n.g)(1===s),c=e[0],g=1-e[0])}const d=t.getCoord2D(c),_=t.getCoord2D(g);(0,n.g)(!d.equals(_)),t.constructEllipticArcEndPointsCenter(d,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),br(t,e,s)}function Ir(t,e,s,n,i){return Dr(t,!1,e,s,n,i)}function Dr(t,e,s,i,r,o){const a=s.getGeometryType(),h=i.getGeometryType(),m=Math.max(r,Y(s,i));if(a===n.G.enumLine&&h===n.G.enumLine)return rt(s,i,m,o);let l=s,u=i,c=s.getStartXY(),g=s.getEndXY();if(c.compare(g)>0&&(l=s.clone().reverse()),c=i.getStartXY(),g=i.getEndXY(),c.compare(g)>0&&(u=i.clone().reverse()),e){if(s.equals(i))return 2;if(function(t,e,s){return(0,n.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&b(t,e,0,0,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&b(t,e,1,1,s,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&b(t,e,0,1,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&b(t,e,1,0,s,2,[0,0],[0,0]))}(s,i,m))return 4}switch(a){case n.G.enumLine:switch(h){case n.G.enumEllipticArc:return Pr(t,u,l,m,o);case n.G.enumBezier:return $s(t,u,l,m,o);case n.G.enumRationalBezier2:return ei(t,u,l,m,o);case n.G.enumBezier2:return ze(t,u,l,m,o);default:(0,n.d)("")}break;case n.G.enumEllipticArc:switch(h){case n.G.enumLine:return Pr(t,l,u,m,o);case n.G.enumEllipticArc:return function(t,e,s,n,i){if(i){if(0!==wr(e,s))return 2}else if(E(e,s))return 1;return 0!==Er(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}(t,l,u,m,o);case n.G.enumBezier:return Js(t,u,l,m,o);case n.G.enumRationalBezier2:return si(t,u,l,m,o);case n.G.enumBezier2:return Ue(t,u,l,m,o);default:(0,n.d)("")}break;case n.G.enumBezier:switch(h){case n.G.enumLine:return $s(t,l,u,m,o);case n.G.enumEllipticArc:return Js(t,l,u,m,o);case n.G.enumBezier:return function(t,e,s,n,i){if(i){if(0!==wr(e,s))return 2}else if(E(e,s))return 1;return 0!==rn(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}(t,l,u,m,o);case n.G.enumRationalBezier2:return tn(t,l,u,m,o);case n.G.enumBezier2:return en(t,l,u,m,o);default:(0,n.d)("")}break;case n.G.enumRationalBezier2:switch(h){case n.G.enumLine:return ei(t,l,u,m,o);case n.G.enumEllipticArc:return si(t,l,u,m,o);case n.G.enumBezier:return tn(t,u,l,m,o);case n.G.enumRationalBezier2:return function(t,e,s,n,i){if(i){const n=wr(e,s);if(0!==n){if(t){if(1===n){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(E(e,s))return 1;return 0!==oi(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}(t,l,u,m,o);case n.G.enumBezier2:return ni(t,l,u,m,o);default:(0,n.d)("")}break;case n.G.enumBezier2:switch(h){case n.G.enumLine:return ze(t,l,u,m,o);case n.G.enumEllipticArc:return Ue(t,l,u,m,o);case n.G.enumBezier:return en(t,u,l,m,o);case n.G.enumRationalBezier2:return ni(t,u,l,m,o);case n.G.enumBezier2:return function(t,e,s,n,i){if(i){if(0!==wr(e,s))return 2}else if(E(e,s))return 1;return 0!==je(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}(t,l,u,m,o);default:(0,n.d)("")}break;default:(0,n.d)("")}}function wr(t,e,s=!0){if(!s&&!Tr(t,e))return 0;const i=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.G.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint1())&&n.getControlPoint2().equals(i.getControlPoint2())?s:0}if(r===n.G.enumEllipticArc)return Sr(t,e,!1)?s:0;if(r===n.G.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===n.G.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.G.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint2())&&n.getControlPoint2().equals(i.getControlPoint1())?s:0}if(r===n.G.enumEllipticArc)return Sr(t,e,!0)?s:-1;if(r===n.G.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===n.G.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}return 0}function Tr(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==n.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function Nr(t,e,s,i,r,o,a){!r&&o&&(0,n.a)("");const h=e.getGeometryType(),m=s.getGeometryType(),l=Math.max(a,Y(e,s));if(i&&(i.length=0),r&&(r.length=0),o&&(o.length=0),h===n.G.enumLine&&m===n.G.enumLine)return ot(e,s,i,r,o,l,!1,!1);let u=e,c=s,g=e.getStartXY(),d=e.getEndXY(),_=!1,p=!1;g.compare(d)>0&&(u=e.clone(!0).reverse(),_=!0),g=s.getStartXY(),d=s.getEndXY(),g.compare(d)>0&&(c=s.clone(!0).reverse(),p=!0);let f=0;switch(h){case n.G.enumLine:switch(m){case n.G.enumEllipticArc:f=yr(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumBezier:f=sn(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumRationalBezier2:f=ii(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumBezier2:f=Oe(t,c,u,i,o,r,l,!1,0,!0);break;default:(0,n.d)("")}break;case n.G.enumEllipticArc:switch(m){case n.G.enumLine:f=yr(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumEllipticArc:f=Er(t,u,c,i,r,o,l,!1,!1,!1);break;case n.G.enumBezier:f=nn(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumRationalBezier2:f=ri(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumBezier2:f=We(t,c,u,i,o,r,l,!1,0,!0);break;default:(0,n.d)("")}break;case n.G.enumRationalBezier2:switch(m){case n.G.enumLine:f=ii(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumEllipticArc:f=ri(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumBezier:f=on(t,c,u,i,o,r,l,!1,!1,!0);break;case n.G.enumRationalBezier2:f=oi(t,u,c,i,r,o,l,!1,!1,!1);break;case n.G.enumBezier2:f=ai(t,u,c,i,r,o,l,!1,0,!1);break;default:(0,n.d)("")}break;case n.G.enumBezier2:switch(m){case n.G.enumLine:f=Oe(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumEllipticArc:f=We(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumBezier:f=an(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumRationalBezier2:f=ai(t,c,u,i,o,r,l,!1,0,!0);break;case n.G.enumBezier2:f=je(t,u,c,i,r,o,l,!1,!1,!1);break;default:(0,n.d)("")}break;case n.G.enumBezier:switch(m){case n.G.enumLine:f=sn(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumEllipticArc:f=nn(t,u,c,i,r,o,l,!1,0,!1);break;case n.G.enumBezier:f=rn(t,u,c,i,r,o,l,!1,!1,!1);break;case n.G.enumRationalBezier2:f=on(t,u,c,i,r,o,l,!1,!1,!1);break;case n.G.enumBezier2:f=an(t,u,c,i,r,o,l,!1,0,!1);break;default:(0,n.d)("")}break;default:(0,n.d)("")}if(_){if(r){for(let t=0;t<f;t++)r[t]=1-r[t];r.reverse()}i&&i.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function Ar(t,e,s){return e===s?0:(e>s&&(s=(0,r.c)(e,e=s)),t.cut(e,s,!0).calculateUpperLength2D())}function Gr(t,e,s,n,i,o,a,h,m,l,u,c,g){if(!o)return 0;const d=(t,e)=>{for(let s=0;s<o;++s){let n=e[s];if((0,r.a8)(n,0,1)){n=(0,r.aD)(n);continue}const i=t.getCoord2D(n);n<.5?i.equals(t.getStartXY())&&Ar(t,0,n)<=V(t)&&(e[s]=0):i.equals(t.getEndXY())&&Ar(t,n,1)<=V(t)&&(e[s]=1)}};d(e,n),d(s,i),function(t,e,s,n,i){const o=[],a=[],h=[];for(let m=0,l=i;m<l;m++)o.push(t.calculateSubLengthFromStart(s[m])),a.push(e.calculateSubLengthFromStart(n[m])),(0,r.a8)(s[m],0,1)&&(0,r.a8)(n[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(n[m]))&&h.push(m);if(0===h.length||h.length===i)return;h.sort((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:n[t]<n[e]?-1:n[t]>n[e]?1:0);let m=-1;for(const l of h){if(m>=0&&s[l]===s[m]&&s[l]===s[m]){m=l;continue}m=l;const h=[];h.length=i;for(let t=0;t<h.length;++t)h[t]=t;h.sort((t,e)=>{const s=o[l],n=a[l],i=o[t]-s,r=a[t]-n,h=i*i+r*r,m=o[e]-s,u=a[e]-n,c=m*m+u*u;return h<c?-1:h>c?1:0});for(let o=0;o<i;o++){const i=h[o];if(i===l||s[i]===s[l]&&n[i]===n[l]||(0,r.a8)(s[i],0,1)&&(0,r.a8)(n[i],0,1))continue;const a=(s,n,i,o)=>{const a=new p,h=new r.X;h.setWithEps(1);const m=new r.X;m.set(n,h.eps()),t.queryCoord2DE(m,a);const l=new p;t.queryCoord2DE(new r.X(s),l);let u=!1;return a.eq(l)&&(m.set(o,h.eps()),e.queryCoord2DE(m,a),e.queryCoord2DE(new r.X(i),l),u=a.eq(l)),!u},m=r.P.getNAN();t.queryCoord2D(s[i],m);const u=r.P.getNAN();if(e.queryCoord2D(n[i],u),0===r.P.distance(m,u)&&a(s[l],s[i],n[l],n[i]))break;const c=new r.E(n[i],n[l]);c.normalizeNoNAN();const g=new r.E(s[i],s[l]);g.normalizeNoNAN();let d=-1,_=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY,x=s[i];m.assign(t.getCoord2D(x));for(let o=0;o<5;o++){const o=e.getClosestCoordinateOnInterval(m,c,-1);u.assign(e.getCoord2D(o));const h=r.P.distance(m,u);if(x=t.getClosestCoordinateOnInterval(u,g,-1),x===s[l]&&o===n[l]){d=1;break}m.assign(t.getCoord2D(x));const p=r.P.distance(u,m);if(!(p<f&&h<_)){d=0;break}if(0===p&&0===h){a(s[l],s[i],n[l],n[i])?(s[i]=x,n[i]=o,d=0):d=1;break}f=p,_=h}if(-1===d&&(d=(0,r.a8)(s[i],0,1)||(0,r.a8)(n[i],0,1)?0:1),1!==d)break;s[i]=s[l],n[i]=n[l]}}}(e,s,n,i,o);const _=[];for(let t=0,e=o;t<e;t++)_.push(t);const f=(t,e)=>g?(0,r.aE)(i[t],n[t],i[e],n[e]):(0,r.aE)(n[t],i[t],n[e],i[e]);if(_.length>1){_.sort(f);const t=Math.max(V(e),V(s));let o=0;for(let a=1,h=_.length;a<h;a++){const h=n[_[o]],m=n[_[a]],l=i[_[o]],u=i[_[a]];if(h!==m||l!==u){if(Ar(e,h,m)<=t&&Ar(s,l,u)<=t&&!((0,r.a8)(h,0,1)&&(0,r.a8)(l,0,1)||(0,r.a8)(m,0,1)&&(0,r.a8)(u,0,1))){const t=r.P.distance(e.getCoord2D(h),s.getCoord2D(l)),n=r.P.distance(e.getCoord2D(m),s.getCoord2D(u));if(t<=n)continue;if(n<t){_[o]=_[a];continue}continue}o++,_[o]=_[a]}}if(_.length=o+1,1===_.length&&0!==_[0]&&(n[0]=n[_[0]],i[0]=i[_[0]],_[0]=0),_.length>2){const t=r.E.constructEmpty(),o=r.E.constructEmpty();t.setCoords(n[_[0]],n[_.at(-1)]),o.setCoords(i[_[0]],i[_.at(-1)]);let a=!0;for(let e=1,s=_.length-1;e<s;e++)if(!t.containsCoordinate(n[_[e]])||!o.containsCoordinate(i[_[e]])){a=!1;break}if(a){const n=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let i=0;i<n.length;i++){let h=(0,r.q)(t.vmin,t.vmax,n[i]);const m=e.getCoord2D(h);if(!s.isCloserThanDistance(m,o,l)){a=!1;break}h=(0,r.q)(o.vmin,o.vmax,n[i]);const u=s.getCoord2D(h);if(!e.isCloserThanDistance(u,t,l)){a=!1;break}}}a&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t){const t=0,r=0;b(e,s,n[0],i[0],l,1,[t],[r])&&(_.push(1),n[1]=t,i[1]=r,_.sort(f))}if(u&&1===_.length){let t=!0;for(let o=0,a=_.length;o<a;o++)if(!(0,r.a8)(n[_[o]],0,1)||!(0,r.a8)(i[_[o]],0,1)||0!==r.P.distance(e.getCoord2D(n[_[o]]),s.getCoord2D(i[_[o]]))){t=!1;break}if(t)return 0}let x=0;for(let t=0,s=_.length;t<s;t++){if(h&&h.push(n[_[t]]),m&&m.push(i[_[t]]),a){const s=r.P.getNAN();e.queryCoord2D(n[_[t]],s),a.push(s)}x++}return x}function qr(t,e,s,n,i,o,a,h,m){if((0,r.a8)(s,0,1)&&(0,r.a8)(n,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(n))){const l=1e-12,u=new p,c=Number.EPSILON;if(t.queryDerivative(new r.X(s,c),u),u.isTrueZero()){const e=1===s?-l:l;t.queryDerivative(new r.X(s,c).add(e),u)}1===s&&u.negateThis();const g=new p;if(e.queryDerivative(new r.X(n,c),g),g.isTrueZero()){const t=1===s?-l:l;e.queryDerivative(new r.X(n,c).add(t),g)}1===n&&g.negateThis(),u.isZero()||u.normalize(),g.isZero()||g.normalize();const d=u.dotProduct(g),_=u.crossProduct(g);_.scaleError(3);const f=()=>{if(m)return.001;{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(d.ge(r.U)&&(_.isZero()||Math.abs(_.value())<f()))return S(t,e,s,n,i,o,a,h)}return 0}function Mr(t,e,s,i,o){let a=-1,h=-1,m=-1,l=-1;{const n=[0,e],r=[e,0],o=[0,i],u=[i,0];for(let e=0;e<2&&-1===a;++e)for(let i=0;i<2;++i)if(t[n[e]].equals(s[o[i]])){a=n[e],h=r[e],m=o[i],l=u[i];break}}if(-1===a){const n=new c;n.setFromPoints(t,e+1);const r=new c;return r.setFromPoints(s,i+1),r.inflate(o),n.isIntersectingW(r)?-1:0}{const u=(0,r.d)(e+1,Number.NaN),c=gs(t,e+1,u);(0,n.g)(c>1);let g=0,d=0;for(let t=0;t<c;++t)a===u[t]&&(d=t,g++),h===u[t]&&g++;if(2!==g)return-1;const _=(0,r.d)(i+1,Number.NaN),p=gs(s,i+1,_);(0,n.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===_[t]&&(f=t,g++),l===_[t]&&g++;if(2!==g)return-1;const x=t[u[(d+c-1)%c]],P=t[u[(d+1)%c]],y=s[_[(f+p-1)%p]],E=s[_[(f+1)%p]],C=t[a],v=[x,P,y,E],S=[0,1,2,3];S.sort((t,e)=>r.P.compareVectorsOrigin(C,v[t],v[e]));let b=S[0];for(let t=1;t<4;t++){if(S[t]!==(b+1)%4)return-1;b=S[t]}{const t=x.sub(C),e=E.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),r=i*t.length(),a=i*e.length();if(r<=o||a<=o)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),r=i*t.length(),a=i*e.length();if(r<=o||a<=o)return-1}}return 1}}var Fr=i.V;class Xr extends K{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,n.g)(0),0}calculateUpperLength3D(){return(0,n.g)(0),0}changeEndPoints3D(t,e){(0,n.g)(0)}getClosestCoordinate3D(t,e,s){return(0,n.g)(0),0}getBoundary(){return wt(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?tt(this,t):et(this,t);const n=Fr.getInterpolation(e),i=this.getStartAttributeAsDbl(e,s),o=this.getEndAttributeAsDbl(e,s);return(0,r.ad)(n,i,o,t,Fr.getDefaultValue(e))}constructFromCoords(t,e,s,n){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,n)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,n.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Xr.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let n=0,i=Fr.getComponentCount(s);e<i;e++){const e=this.queryInterval(s,n);t.setIntervalEnvelope(s,n,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,M(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,M(this,1,1,0))):(0,n.t)("env type not impl")}applyTransformation(t){(0,n.g)(t instanceof a.T);const e=new r.P;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new Xr({vd:this.m_description})}calculateLength2D(){return Math.sqrt(ut(this))}calculateLength3D(t){return(0,n.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return(0,n.g)(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return $(this,t,e)}queryCoord3D(t,e){(0,n.g)(0)}getCoordZ(t){return function(t,e){const s=t.getStartZ(),n=t.getEndZ();return(0,r.q)(s,n,e)}(this,t)}queryCoord2DE(t,e){st(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=x.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(r.M.constructDouble(t)),e.addThis(s)}getCoordX(t){return tt(this,t)}getCoordY(t){return et(this,t)}cut(t,e,s){const n=new Vr;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createLine();n&&i.assignVertexDescription(this.m_description);const o=r.P.getNAN();if($(this,t,o),i.setStartXYCoords(o.x,o.y),$(this,e,o),i.setEndXYCoords(o.x,o.y),!n)for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),r=Fr.getComponentCount(n);for(let s=0;s<r;s++){const r=this.getAttributeAsDbl(t,n,s);i.setStartAttribute(n,s,r);const o=this.getAttributeAsDbl(e,n,s);i.setEndAttribute(n,s,o)}}}queryDerivative(t,e){!function(t,e,s){const n=p.constructPoint2D(t.getStartXY()),i=p.constructPoint2D(t.getEndXY());s.setCoordsE(i.x.subE(n.x),i.y.subE(n.y))}(this,0,e)}getClosestCoordinate(t,e){return r.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const n=new r.P;this.queryCoord2D(e.vmin,n);const i=new r.P;this.queryCoord2D(e.vmax,i);const o=r.P.getClosestCoordinate(n,i,t,!1);return B.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const n=(t-this.m_YStart)/s;let i=tt(this,n);return 1===n&&(i=this.m_XEnd),i}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return(0,n.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new Xr;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new r.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=r.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new r.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return at(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,i,r=1){return(0,n.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,n.a)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,s,n){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const i=(e-this.m_YStart)/t;return i<0||i>1?0:(s&&(s[0]=tt(this,i)),n&&(n[0]=i),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const i=(e-this.m_XStart)/t;return i<0||i>1?0:(s&&(s[0]=et(this,i)),n&&(n[0]=i),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=(0,r.s)(t.vmin,0,1);const n=new r.P;return this.queryCoord2D(s,n),e.setCoords({pt:n}),s=(0,r.s)(t.vmax,0,1),this.queryCoord2D(s,n),void e.mergeNe(n)}(0,n.t)("3d dst not impl")}orientBottomUp(){it(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return function(t,e){const s=t.getStartXYZ();s.z*=e;const n=t.getEndXYZ();return n.z*=e,s.norm(1)+n.norm(1)}(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoordsForStitcher(t,e){nt(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,n.g)(0),0}readFromBufferStream(t,e){(0,n.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){nt(this,t,e)}static isIntersectingLineLine(t,e,s,n){return rt(t,e,s,n)}static isIntersectingLineLine_(t,e,s,n){return rt(t,e,s,n)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,n,i){return Nr(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){e.length<1&&(0,n.q)("");const i=at(this,t,s,!1);return i>=0?(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==Ir(!1,this,t,e,s)}}Xr.type=n.G.enumLine;class Vr{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new Xr,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,n.d)("bad constructor params"))}assignCopy(t){return t instanceof Vr?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Vr){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,n.d)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,n.g)(0)}createImpl(t){switch(t){case n.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Xr,this.m_mask|=1,this.m_active=1);break;case n.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new Ni,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case n.G.enumBezier:4&this.m_mask||(this.m_curves=new vn,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case n.G.enumBezier2:8&this.m_mask||(this.m_curves=new Qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case n.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new jt,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,n.a)("")}}create(t){t===n.G.enumLine?this.createLine():t===n.G.enumEllipticArc?this.createEllipticArc():t===n.G.enumBezier?this.createCubicBezier():t===n.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===n.G.enumBezier2?this.createQuadraticBezier():(0,n.a)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,n.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(n.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(n.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(n.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(n.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(n.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,n.d)("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,n.d)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Vr?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,n.t)("seg comparison not yet impl"),!1)}}},95213:(t,e,s)=>{s.d(e,{$:()=>A,A:()=>X,B:()=>R,C:()=>$,D:()=>Y,E:()=>Ft,F:()=>z,G:()=>J,H:()=>Tt,I:()=>O,J:()=>I,K:()=>E,L:()=>P,M:()=>y,N:()=>x,O:()=>C,P:()=>At,Q:()=>_,R:()=>v,S:()=>k,T:()=>U,U:()=>Mt,V:()=>g,W:()=>c,X:()=>u,Y:()=>T,Z:()=>N,_:()=>tt,a:()=>lt,a0:()=>G,a1:()=>q,a2:()=>bt,a3:()=>rt,a4:()=>nt,a5:()=>it,a6:()=>w,b:()=>mt,c:()=>ot,d:()=>S,e:()=>gt,f:()=>et,g:()=>st,h:()=>pt,i:()=>Pt,j:()=>ut,k:()=>yt,l:()=>dt,m:()=>ht,n:()=>F,o:()=>xt,p:()=>_t,q:()=>b,r:()=>at,s:()=>ft,t:()=>It,u:()=>Dt,v:()=>Et,w:()=>vt,x:()=>St,y:()=>Ct,z:()=>Q});var n=s(83661),i=s(79187),r=s(55537);const o=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],a=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],h=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],m=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],l=[4,8,4,8,1],u=25;function c(){return(0,n.d)(u,Number.NaN)}let g=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return h[t]}static getPersistence(t){return m[t]}static getPersistenceSize(t){return l[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return a[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return o[t]}static isDefaultValue(t,e){return(0,n.F)(o[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=(0,n.d)(u,Number.NaN),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,r=14;for(;s<r;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let o=0;for(s=0,r=this.getAttributeCount();s<r;s++){const e=this.getSemantics(s),n=t.getComponentCount(e),i=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=o;for(let t=0;t<n;t++)this.m_defaultPointAttributes[o]=i,o++}}};var d=g;function _(){return(0,n.d)(14,0)}class p{static getInstance(){return p.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new d(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new d(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new d(t);return this.m_map.set(t,s),s}}function f(t){return p.getInstance().FindOrAdd(t)}function x(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:f(s)}function P(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:f(s)}function y(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:f(s)}function E(){return p.getInstance().GetVD2D()}function C(){return p.getInstance().GetVD3D()}function v(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let n=0,i=t.getAttributeCount();n<i;n++)s[n]=e.getAttributeIndex(t.getSemantics(n))}p.s_thisInstance=new p;class S{static construct(t,e,s){return new S(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new S(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new S;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,n.a)(t.x-e.x)+(0,n.a)(t.y-e.y)+(0,n.a)(t.z-e.z)}static sqrDistanceCoords(t,e,s,i,r,o){return(0,n.a)(t-i)+(0,n.a)(e-r)+(0,n.a)(s-o)}static distance(t,e){return Math.sqrt(S.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,n.a5)(this.z,t.z,e)}static compareByLength(t,e,s,n){return(0,r.g)(0),0}isEqualCoords(t,e,s,n){return(0,r.g)(0),this.x===t&&this.y===e&&this.z===s}isEqualsTols(t,e,s){return(0,r.g)(0),!1}isEqualCoordsTols(t,e,s,n,i){return(0,r.g)(0),!1}static st_isEqual(t,e,s,n){return(0,r.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,s){return(0,r.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return S.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return S.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,n=this.x*t.y-t.x*this.y;return new S(e,s,n)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,n=e.x*t.z-t.x*e.z,i=t.x*e.y-e.x*t.y;return this.x=s,this.y=n,this.z=i,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return S.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return(0,r.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,r.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,r.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,s,n=!1){return(0,r.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return(0,r.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,r.g)(0),{}}static average(t,e){return(0,r.g)(0),{}}static size(){return S.dimensions}static lerp(t,e,s){const i=new S;return(0,n.x)(t,e,s,i),i}static slerp(t,e,s){return(0,r.g)(0),{}}static compareVectors(t,e){return(0,r.g)(0),0}static selectRightHandedBasisFromNormal(t,e,s){const n=t.getUnitVector(),i=n.createAPerpendicular(),r=new S;r.setCrossProductVector(n,i),r.normalizeThis(),e.setCoordsPoint3D(i),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new S(0,0,1)),this.crossProductVector(new S(1,0,0)),this.crossProductVector(new S(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce((t,s,n)=>e[t]>e[n]?t:n,0)];return s.normalizeThis(),s}calculateAngle(t){return(0,r.g)(0),0}static crossDotSign(t,e,s){return(0,r.g)(0),0}static isBisectorRobust(t,e,s){return(0,r.g)(0),0}static compareZOrder(t,e){return(0,r.g)(0),!1}}S.dimensions=3;class b{static constructEmpty(){return new b(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,n,i,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=n,this.ymax=i,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,s){(0,r.g)(0)}getEnvelope2D(){return new i.Envelope2D(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new n.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,n.c)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,n.c)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,n.c)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,n,i,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=n,this.ymax=i,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,s,n=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}const I=-559038737;var D=g;function w(t,e,s){switch(t){case 0:return new V(e,s);case 1:return new Y(e,s);case 2:return new X(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new F(e,s);default:(0,r.a)("")}}function T(t,e){const s=D.getComponentCount(t);return w(D.getPersistence(t),e*s,D.getDefaultValue(t))}function N(t,e){const s=D.getComponentCount(t);return w(D.getPersistence(t),e*s)}function A(t,e){return new X(t,e)}function G(t,e){return new F(t,e)}function q(t,e){return new Y(t,e)}class M{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>M.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const n=1.25*t,i=new this.m_a.constructor(n);i.set(this.m_a),this.m_a=i,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&(0,r.a)(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,i){return this.getPersistence()===t.getPersistence()&&function(t,e,s,i,r){if(t.getPersistence()!==e.getPersistence())return!1;const o=t.getPersistence()<=1,a=t.size(),h=e.size();if(i>a||i>h)return!1;if(r)if(o){for(let o=s;o<i;o++)if(!(0,n.a5)(t.read(o),e.read(o),r))return!1}else for(let n=s;n<i;n++){let s=t.read(n)-e.read(n);if(s<0&&(s=-s),s>r)return!1}else for(let n=s;n<i;n++){const s=t.read(n),i=e.read(n);if(s!==i){if(o&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}(this,t,e,s,i)}insertRange(t,e,s,n){const i=this.m_size;this.checkResize(Math.max(0,n)+s),this.m_a.copyWithin(t+s,t,n>=0?n:i),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,s,n,i,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;n&&this.checkResize(Math.max(0,a)+n),this.m_a.copyWithin(t+n,t,a>=0?a:m),this.m_a.set(h.readRange(s,n),t),i||this.reverseRange(t,n,o)}writeRange(t,e,s,n,i,o){(0,r.g)(this.getPersistence()===s.getPersistence());const a=s;if((t<0||e<0||n<0)&&(0,r.a)(),a.size()<n+e&&(0,r.a)(),0===e)return;this.size()<e+t&&this.resize(e+t);const h=a.m_a.subarray(n,n+e);!function(t,e,s,n){if((e<0||s<0)&&(0,r.a)(),0===s)return;if(1===s)return void(t[e]=n[0]);let i=n;s<n.length&&(i=n.subarray(0,s)),t.set(i,e)}(this.m_a,t,e,h)}insertAttributes(t,e,s,n){const i=D.getComponentCount(s);this.m_a.copyWithin(t+i,t,n>=0?n:this.m_size);for(let n=0;n<i;n++)this.m_a[t+n]=e.getAttributeAsDbl(s,n)}insertAttributesFromPoints(t,e,s,i,o){(0,r.g)(D.getPersistence(i)===this.getPersistence());const a=D.getComponentCount(i),h=this.m_size;if(this.checkResize(Math.max(0,o)+a*s),this.m_a.copyWithin(t+a*s,t,o>=0?o:h),0===i){const i=new n.P;for(let n=t,r=0;r<s;r++,n+=2)e[r].queryXY(i),this.m_a[n]=i.x,this.m_a[n+1]=i.y}else if(1===a)for(let n=t,r=0;r<s;r++,n++)this.m_a[n]=e[r].getAttributeAsDbl(i,0);else for(let n=t,r=0;r<s;r++,n+=a)for(let t=0;t<a;t++)this.m_a[n+t]=e[r].getAttributeAsDbl(i,t)}eraseRange(t,e,s){this.m_size<t+e&&(0,r.a)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!==0)&&(0,r.a)(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let n=t,i=t+e;n<i;n+=s){let t=n,e=n+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(t,e,s){(e<t||e>s||t>s)&&(0,r.q)("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,M.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}M.s_constructMin=2,M.s_resizeMin=30;class F extends M{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new F({ctor:Int8Array,copy:this})}restrictedClone(t){return new F({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class X extends M{getPersistence(){return 2}clone(){return new X({ctor:Int32Array,copy:this})}restrictedClone(t){return new X({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,n.i)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class V extends M{getPersistence(){return 0}clone(){return new V({ctor:Float32Array,copy:this})}restrictedClone(t){return new V({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class Y extends M{getPersistence(){return 1}getArray(){return this.m_a}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&(0,r.a)();const n=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(n,s,n)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new n.P(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,n,i,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*n),this.m_a.copyWithin(t+2*n,t,r>=0?r:o),i)for(let i=s,r=t,o=0;o<n;++o,++i){const t=e[i];this.m_a[r++]=t.x,this.m_a[r++]=t.y}else for(let i=s+n-1,r=t,o=0;o<n;++o,--i){const t=e[i];this.m_a[r++]=t.x,this.m_a[r++]=t.y}}queryRange(t,e,s,n,i){if((t<0||e<0)&&(0,r.a)(),!n&&(i<=0||e%i!==0)&&(0,r.a)(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+e);s.set(o)}writeRangeFromArray(t,e,s,n,i){if((t<0||e<0)&&(0,r.a)(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let o=s;e<s.length&&(o=s.subarray(0,e)),this.m_a.set(o,t)}clone(){return new Y({ctor:Float64Array,copy:this})}restrictedClone(t){return new Y({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}class R{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new X(0),this.m_bucketedIndices=new X(0)}static sortEx(t,e,s,n,i=32){s-e<=i?n.userSort(e,s,t):(new R).sort(t,e,s,n,i)}sort(t,e,s,n,i=32){if(s-e<=i)return void n.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let i=e;i<s;i++){const e=n.getValue(t.read(i));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let i=e;i<s;i++){const s=t.read(i),r=n.getValue(s),o=this.getBucket(r);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(i-e,s)}let i=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,i),i+=e}for(let i=e;i<s;i++){const s=this.m_bucketedIndices.read(i-e),r=n.getValue(s),o=this.getBucket(r),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void n.userSort(e,s,t);let h=0;for(let s=0,i=this.m_buckets.size();s<i;s++){const i=h;h=this.m_buckets.read(s),h>i&&n.userSort(e+i,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,n){if(t<2||s===e)return!1;const i=Math.min(R.c_maxBuckets,t);return this.m_buckets.resize(i),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(n),this.m_dy=(s-e)/(i-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}R.c_maxBuckets=65536;class k{capacity(){return this.capacity_}constructor(t){this.m_buffer=new Int32Array(0),this.m_firstFree=-1,this.m_last=0,this.size_=0,this.capacity_=0,this.stride=t}size(){return this.size_}deleteElement(t){t<this.m_last?(this.m_buffer[t*this.stride]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.size_--}getField(t,e){return this.m_buffer[t*this.stride+e]}setField(t,e,s){this.m_buffer[t*this.stride+e]=s}elementToIndex(t){return t}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}t=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[t*this.stride];this.size_++;for(let e=t*this.stride;e<t*this.stride+this.stride;e++)this.m_buffer[e]=-1;return t}newElementPset(t){let e=this.m_firstFree;if(-1===e){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}e=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[e*this.stride];this.size_++;const s=e*this.stride;for(let e=0;e<t.length;e++)this.m_buffer[s+e]=t[e];return e}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.size_=0,t&&(this.m_buffer=new Int32Array(0),this.capacity_=0)}setCapacity(t){t>this.capacity_&&this.grow_(t)}swap(t,e){const s=t*this.stride,n=e*this.stride;for(let t=0;t<this.stride;t++){const e=this.m_buffer[n+t];this.m_buffer[n+t]=this.m_buffer[s+t],this.m_buffer[s+t]=e}}swapField(t,e,s){const n=this.m_buffer[this.stride*e+s];this.m_buffer[this.stride*e+s]=this.m_buffer[this.stride*t+s],this.m_buffer[this.stride*t+s]=n}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}grow_(t){null==this.m_buffer&&(this.m_buffer=new Int32Array(0));const e=this.stride*t,s=new Int32Array(e);s.set(this.m_buffer,0),this.m_buffer=s,this.capacity_=t}}class L{constructor(t,e,s){this.m_extent=new i.Envelope2D,this.m_dataExtent=new i.Envelope2D,this.m_childExtents=[new i.Envelope2D,new i.Envelope2D,new i.Envelope2D,new i.Envelope2D],this.m_elementNodes=new k(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new k(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){this.m_quadTreeNodes.deleteAll(!1),this.m_elementNodes.deleteAll(!1),this.m_data.length=0,this.m_freeData.length=0,this.reset_(t,e)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let n;n=-1===s?this.m_root:this.getQuad_(s);const i=this.getHeight(n),r=this.getExtent(n),o=this.insert_(t,e,i,r,n,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,r.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,r.g)(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,r.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,r.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>L.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new i.Envelope2D;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let n=t;do{s.push(this.getQuadrant_(n)),n=this.getParent_(n)}while(n!==this.m_root);const r=s.length;for(let t=0;t<r;t++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const r=new i.Envelope2D;r.setCoords({env2D:t}),r.inflateCoords(e,e);const o=[],a=[];o.push(this.m_root),a.push(this.m_extent.clone());const h=(0,n.m)(i.Envelope2D,4);let m=0;for(;o.length>0;){let t=!1;const e=o.at(-1),n=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(n)){if(m+=this.getSubTreeElementCount(e),s>0&&m>=s)return s}else if(r.isIntersecting(n)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(r)&&(m++,s>0&&m>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){L.setChildExtents_(n,h);for(let t=0;t<4;t++){const s=this.getChild_(e,t);-1!==s&&this.getSubTreeElementCount_(s)>0&&r.isIntersecting(h[t])&&(o.push(s),a.push(h[t].clone()))}}}return m}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new B(this,t,e)}getIteratorForQT(){return new B(this)}getSortedIterator(t,e){return new H(this.getIterator(t,e))}getSortedIteratorForQT(){return new H(this.getIteratorForQT())}visitLeavesNearest(t,e,s,n){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.a)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,n,r,o,a){if(!n.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,o,a);if(!o)for(let t=r;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);const h=new i.Envelope2D;h.setCoords({env2D:n});let m,l=r;for(m=s;m<this.m_height&&this.canPushDown_(l);m++){L.setChildExtents_(h,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(l,s);-1===e&&(e=this.createChild_(l,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),l=e,h.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,m,h,l,o,r,a,-1)}insertDuplicates_(t,e,s,r,o,a,h){if(!a){if(!r.containsEnvelope(e))return-1;this.setSubTreeElementCount_(o,this.getSubTreeElementCount_(o)+1),this.setContainedSubTreeElementCount_(o,this.getContainedSubTreeElementCount_(o)+1)}const m=Math.max(e.width(),e.height());let l=-1;const u=[],c=[],g=[];u.push(o),c.push(r.clone()),g.push(s);const d=(0,n.m)(i.Envelope2D,4);for(;u.length>0;){let s=!1;const n=u.at(-1),i=c.at(-1),r=g.at(-1);if(u.pop(),c.pop(),g.pop(),r+1<this.m_height&&this.canPushDown_(n)&&m<=Math.max(i.width(),i.height())/2&&(s=!0),s){L.setChildExtents_(i,d);let t=!1;for(let s=0;s<4;s++)if(t=d[s].containsEnvelope(e),t){let t=this.getChild_(n,s);-1===t&&(t=this.createChild_(n,s)),u.push(t),c.push(d[s].clone()),g.push(r+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(d[t].isIntersecting(e)){let e=this.getChild_(n,t);-1===e&&(e=this.createChild_(n,t)),u.push(e),c.push(d[t].clone()),g.push(r+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else l=this.insertAtQuad_(t,e,r,i,n,a,o,h,l),a=!1}return 0}insertAtQuad_(t,e,s,n,i,r,o,a,h){this.getFirstElement_(i);const m=this.getLastElement_(i);let l=-1;if(r){if(i===o)return a;this.disconnectElementHandle_(a),l=a}else-1===h?(l=this.createElement_(),this.setDataValues_(this.getData_(l),t,e)):l=this.createElementFromDuplicate_(h);return this.setQuad_(l,i),-1!==m?(this.setPrevElement_(l,m),this.setNextElement_(m,l)):this.setFirstElement_(i,l),this.setLastElement_(i,l),this.setLocalElementCount_(i,this.getLocalElementCount_(i)+1),this.canFlush_(i)&&this.flush_(s,n,i),l}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),n=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:n,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:n,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:n}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:n})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),n=this.getLastElement_(e),i=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):n===t?(this.setNextElement_(i,-1),this.setLastElement_(e,i)):(this.setPrevElement_(r,i),this.setNextElement_(i,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===L.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let n;const r=new i.Envelope2D;let o=this.getFirstElement_(s),a=-1,h=-1;do{h=this.getData_(o),n=this.getElementValue_(h),r.setCoords({env2D:this.getBoundingBoxValue_(h)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(n,r,t,e,s,!0,o):this.insert_(n,r,t,e,s,!0,o),o=a}while(-1!==o)}canPushDown_(t){return this.getLocalElementCount_(t)>=L.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){(0,r.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&L.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>L.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const n=e<<L.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,n)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,s)}}L.m_quadrantMask=3,L.m_heightBitShift=2,L.m_flushingCount=5;class B{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new n.P,this.m_queryEnd=new n.P,this.m_queryBox=new i.Envelope2D,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new i.Envelope2D,new i.Envelope2D,new i.Envelope2D,new i.Envelope2D],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof i.Envelope2D)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===r.G.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new n.P,e=new n.P,s=new i.Envelope2D;let r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){const n=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(n)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){r=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){r=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),n=this.m_extentsStack.at(-1);L.setChildExtents_(n,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let n=0;n<4;n++){const r=this.m_quadTree.getChild_(s,n);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[n].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new i.Envelope2D;s.setCoords({env2D:this.m_childExtents[n]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[n].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[n].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class H{constructor(t){this.m_bucketSort=new R,this.m_sortedHandles=new X(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,n){n.sort(t,s,(t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,r.g)(0),{}}}class z{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class U{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new k(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||((0,r.g)(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,i,r,o=-1){if(-1===o&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===U.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,h,m,l,u;if(r?(a=e!==U.st_nullNode()?this.m_comparator.compare(this,s,e):-1,h=t!==U.st_nullNode()?this.m_comparator.compare(this,s,t):1):(a=-1,h=1),i&&(0===a||0===h)){this.m_comparator.onAddUniqueElementFailedImpl(s);const n=0===a?e:t;return this.setDuplicateElement_(n,o),-1}u=e!==U.st_nullNode()&&t!==U.st_nullNode()?this.m_random>(0,n.J)(this.m_random)>>1:e!==U.st_nullNode(),u?(l=a,m=e):(l=h,m=t);let c=-1,g=-1,d=!0;for(;;){if(l<0){const t=this.getLeft(m);if(t===U.st_nullNode()){g=m,c=this.newNode_(s),this.setLeft_(m,c),this.setParent_(c,m);break}m=t}else{const t=this.getRight(m);if(t===U.st_nullNode()){g=this.getNext(m),c=this.newNode_(s),this.setRight_(m,c),this.setParent_(c,m);break}m=t}d&&(l*=-1,d=!1)}return this.bubbleUp_(c),this.getParent(c)===U.st_nullNode()&&this.setRoot_(c,o),this.addToList_(g,c,o),c}replaceElementAtPosition(t,e,s,n,i=-1){if(n){const n=this.getNext(t);let r=-1;n!==U.st_nullNode()&&(r=this.m_comparator.compare(this,e,n));const o=this.getPrev(t);let a=-1;if(o!==U.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?n:o;return i===U.st_nullNode()&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),i=this.m_defaultTreap),this.setDuplicateElement_(t,i),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==U.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),U.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),n=-1;for(;s!==U.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(n=s,s=this.getRight(s))}return n}searchUpperBound(t,e=-1){let s=this.getRoot(e),n=-1;for(;s!==U.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(n=s,s=this.getLeft(s)):s=this.getRight(s)}return n}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=U.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let n;-1!==t?(n=this.getPrev(t),this.setPrev_(t,e)):n=this.getLast_(s),this.setPrev_(e,n),-1!==n&&this.setNext_(n,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return k.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const i=this.getPriority_(t);for(;e!==U.st_nullNode()||s!==U.st_nullNode();){const r=e!==U.st_nullNode()?this.getPriority_(e):(0,n.j)(),o=s!==U.st_nullNode()?this.getPriority_(s):(0,n.j)();if(i<=Math.min(r,o))return;r<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==U.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let n;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),n=this.getLeft(s),this.setRight_(e,n),n!==U.st_nullNode()&&this.setParent_(n,e),this.setLeft_(s,e),n=this.getParent(s),n!==U.st_nullNode()&&(this.getLeft(n)===e?this.setLeft_(n,s):this.setRight_(n,s))}rotateRight_(t){const e=this.getParent(t),s=t;let n;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),n=this.getRight(s),this.setLeft_(e,n),n!==U.st_nullNode()&&this.setParent_(n,e),this.setRight_(s,e),n=this.getParent(s),n!==U.st_nullNode()&&(this.getLeft(n)===e?this.setLeft_(n,s):this.setRight_(n,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==U.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,n.J)(this.m_random),this.m_random&(0,n.j)()>>1}maxPriority(){return(0,r.g)(0),0}getMaxDepthHelper_(t){return t===U.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===U.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let n=this.getRoot_(s),i=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,n);if(a<0){const e=this.getLeft(n);if(e===U.st_nullNode()){r=n,i=this.newNode_(t),this.setLeft_(n,i),this.setParent_(i,n);break}n=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(n,s),-1;const o=this.getRight(n);if(o===U.st_nullNode()){r=this.getNext(n),i=this.newNode_(t),this.setRight_(n,i),this.setParent_(i,n);break}n=o}o++}return this.bubbleUp_(i),this.getParent(i)===U.st_nullNode()&&this.setRoot_(i,s),this.addToList_(r,i,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),i}removeFromList_(t,e){const s=this.getPrev(t),n=this.getNext(t);-1!==s?this.setNext_(s,n):this.setFirst_(n,e),-1!==n?this.setPrev_(n,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),i=this.getRight(t),r=this.getParent(t),o=t;if(-1!==s&&-1!==i){let a;this.m_random=(0,n.J)(this.m_random),a=this.m_random>(0,n.j)()>>1?this.getNext(t):this.getPrev(t);const h=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1!==r?this.getLeft(r)===t?this.setLeft_(r,a):this.setRight_(r,a):this.setRoot_(a,e),h?(s===a?(this.setLeft_(a,t),this.setParent_(i,a)):i===a&&(this.setRight_(a,t),this.setParent_(s,a)),this.setParent_(t,a),r=a):(this.setParent_(s,a),this.setParent_(i,a),r=this.getParent(t),o=a),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const a=-1!==s?s:i;-1===r?this.setRoot_(a,e):this.getLeft(r)===o?this.setLeft_(r,a):this.setRight_(r,a),-1!==a&&this.setParent_(a,r),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,n.j)());let s=U.st_nullNode(),i=U.st_nullNode();const r=this.getRoot_(e),o=r===t;if(o&&(s=this.getLeft(r),i=this.getRight(r),s===U.st_nullNode()&&i===U.st_nullNode()))return this.removeFromList_(r,e),this.freeNode_(r,e),void this.setRoot_(U.st_nullNode(),e);this.bubbleDown_(t);const a=this.getParent(t);a!==U.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,U.st_nullNode()):this.setRight_(a,U.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(s===U.st_nullNode()||this.getParent(s)!==U.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===U.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===U.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class O{constructor(t){this.m_lists=new k(6),this.m_listOfLists=O.st_nullNode(),void 0===t?(this.m_listNodes=new k(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new k(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,r.g)(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){(0,r.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,r.g)(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==O.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==O.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==O.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){(0,r.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,r.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const n=this.newNode_();let i=-1;if(e!==O.st_nullNode()&&(i=this.getPrev(e),this.setPrev_(e,n)),this.setNext_(n,e),i!==O.st_nullNode()&&this.setNext_(i,n),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,n),e===O.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(n,e),-1!==e&&this.setNext_(e,n),this.m_lists.setField(t,1,n)}return this.setData(n,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(n,t),n}deleteElement(t,e){const s=this.getPrev(e),n=this.getNext(e);return s!==O.st_nullNode()?this.setNext_(s,n):this.m_lists.setField(t,0,n),n!==O.st_nullNode()?this.setPrev_(n,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),n}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==O.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,r.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class W extends z{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const n=t.getElement(s),i=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(n);return i<r?-1:i===r?j.isLeft_(e)&&j.isRight_(n)?-1:j.isLeft_(n)&&j.isRight_(e)?1:0:1}}class j{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new k(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new k(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new U,this.m_secondaryTreaps.setComparator(new W(this)),this.m_secondaryLists=new O}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.p)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.p)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.p)(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new X(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),n=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,n),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.p)("");const e=this.m_intervalHandles[t];let s;-1===e&&(0,r.a)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let n=this.getSecondaryFromInterval_(e),i=-1;i=this.m_secondaryTreaps.getTreapData(n),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),n),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),n),s=this.m_secondaryTreaps.size(n),0===s&&(this.m_secondaryTreaps.deleteTreap(n),this.setSecondaryToTertiary_(i,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(i),a=this.getLptr_(i),h=this.getRptr_(i);for(;!(s>0||i===this.m_root||-1!==a&&-1!==h);)i===this.getLptr_(o)?-1!==a?(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(i,-1),this.setPptr_(i,-1)):-1!==h?(this.setLptr_(o,h),this.setPptr_(h,o),this.setRptr_(i,-1),this.setPptr_(i,-1)):(this.setLptr_(o,-1),this.setPptr_(i,-1)):-1!==a?(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(i,-1),this.setPptr_(i,-1)):-1!==h?(this.setRptr_(o,h),this.setPptr_(h,o),this.setRptr_(i,-1),this.setPptr_(i,-1)):(this.setRptr_(o,-1),this.setPptr_(i,-1)),this.m_tertiaryNodes.deleteElement(i),i=o,n=this.getSecondaryFromTertiary_(i),s=-1!==n?this.m_secondaryTreaps.size(n):0,a=this.getLptr_(i),h=this.getRptr_(i),o=this.getPptr_(i)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof n.E?new Z(this,t,e):((0,r.g)(0),{})}getIterator(){return new Z(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const n=t.read(s),i=this.getValue_(n);i!==e&&(this.m_endIndicesUnique.push(n),e=i)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new X(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=(0,n.d)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){const n=e.read(t);let i=s[n>>1];if(-1!==i){const t=this.getSecondaryFromInterval_(i);this.setRightEnd_(i,this.m_secondaryLists.addElement(t,n))}else i=this.insertIntervalEnd_(n,this.m_root),s[n>>1]=i}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,n=e,i=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let l=Number.NaN,u=Number.NaN,c=!0;const g=this.getMin_(m),d=this.getMax_(m);let _=-1;for(;c;){h=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(_);if(d<e){if(-1!==n)if(_===this.getDiscriminantIndex1_(n))s=n,l=e,n=this.getLptr_(n),u=-1!==n?this.getDiscriminant_(n):Number.NaN;else if(u>e){const t=this.createTertiaryNode_(_);e<l?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,n),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(n,t)),s=t,l=e,n=-1,u=Number.NaN}a=h;continue}if(g>e){if(-1!==n)if(_===this.getDiscriminantIndex1_(n))s=n,l=e,n=this.getRptr_(n),u=-1!==n?this.getDiscriminant_(n):Number.NaN;else if(u<e){const t=this.createTertiaryNode_(_);e<l?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,n),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(n,t)),s=t,l=e,n=-1,u=Number.NaN}o=h+1;continue}let m=-1;m=-1===n||_!==this.getDiscriminantIndex1_(n)?this.createTertiaryNode_(_):n,i=this.getSecondaryFromTertiary_(m),-1===i&&(i=this.createSecondary_(m),this.setSecondaryToTertiary_(m,i));const p=this.addEndIndex_(i,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,i),this.setLeftEnd_(r,p),-1!==n&&_===this.getDiscriminantIndex1_(n)||(e<l?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==n&&(u<e?this.setLptr_(m,n):this.setRptr_(m,n),this.m_bOfflineDynamic&&this.setPptr_(n,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.p)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],n=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(n))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;return s=t<e?t+(e-t>>1)+2:-(t+2),s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const n=this,i={userSort(t,e,s){n.sortEndIndicesHelper_(s,t,e)},getValue:t=>n.getValue_(t)};(new R).sort(t,e,s,i)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,(t,e)=>{const s=this.getValue_(t),n=this.getValue_(e);return s<n||s===n&&j.isLeft_(t)&&j.isRight_(e)?-1:1})}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return j.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return j.isLeft_(t)?e.xmin:e.xmax}}class Z{constructor(t,e,s){this.m_query=n.E.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return(0,r.d)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new n.E;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||(0,r.p)(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class Q{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new X(0),this.m_sortedEndIndicesBlue=new X(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new O,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.p)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new i.Envelope2D(e))}endConstruction(){this.m_bAddRedRed||(0,r.p)(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||(0,r.p)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.p)(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||(0,r.p)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.p)(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new j(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new j(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new j(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new j(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new j(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=n.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),n=this.getAdjustedValue_(e,!1);return s>n?this.sweepRed_():s<n?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=n.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&((0,n.w)(this.m_queuedIndicesRed,this.m_envelopesRed.length,-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=n.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&((0,n.w)(this.m_queuedIndicesBlue,this.m_envelopesBlue.length,-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.d)("should not be called"),!1}sortYEndIndices_(t,e,s,n){const i=this,r={userSort(t,e,s){i.sortYEndIndicesHelper_(s,t,e,n)},getValue:t=>i.getAdjustedValue_(t,n)};(new R).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,n){t.sort(e,s,(t,e)=>{const s=this.getAdjustedValue_(t,n),i=this.getAdjustedValue_(e,n);return s<i||s===i&&this.isBottom_(t)&&this.isTop_(e)?-1:1})}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const n=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?n.ymin-s:n.ymax+s}}var K=g;class ${constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new $(this.tolerance+t,this.resolution)}scale(t){return new $(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function J(t,e,s,i,r){const o=i*i,a=t.sub(e),h=s.sub(e),m=a.sqrLength(),l=h.sqrLength();if(m<=o||l<=o)return!0;const u=(0,n.a)(a.crossProduct(h));return(u<=o*m||u<=o*l)&&a.dotProduct(h)>=0}function tt(t,e,s){return n=>0===s?(n+t)*e:1*(n-t*e)/e}function et(t,e){const s=new i.Envelope2D;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function st(t,e){const s=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(s);const n=i.Envelope2D.constructEmpty();return e.queryLooseEnvelope(n),s.mergeEnvelope2D(n),s}function nt(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function it(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function rt(t,e,s){const n=i.Envelope2D.constructEmpty();return n.setFromPoints(t,e),ct(0,null,n.calculateToleranceFromEnvelope(),s,!1)}function ot(t,e,s){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function at(t,e,s){return ct(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function ht(t,e,s){return at(t,e.queryInterval(1,0),s)}function mt(t,e,s){const n=i.Envelope2D.constructEmpty();return e.queryEnvelope(n),ot(t,n,s)}function lt(t,e,s=!1){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ut(t,e,s){const n=i.Envelope2D.constructEmpty();return e.queryEnvelope(n),lt(t,n,s)}function ct(t,e,s,n,i){const r=new $(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!i||n)&&null!==e)){const s=e.getResolution(t);r.resolution=s,n&&(r.resolution*=2)}return n&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01),r.total()<s?new $(s,0):r}function gt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function dt(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function _t(t){return t>=3}function pt(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function ft(t,e){t.getImpl().setIsSimple(3,e)}function xt(t,e,s,i){if((0,n.a)(e.x-t.x)+(0,n.a)(e.y-t.y)<=s*s){const s=t.z,r=e.z;return(0,n.a5)(s,r,i)}return!1}function Pt(t){return t>=4}function yt(t,e){return t===r.G.enumPolygon?_t(e):e>=1}function Et(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(n),e.queryLooseEnvelope(r),n.inflateCoords(s,s),r.inflateCoords(s,s);const o=i.Envelope2D.constructEmpty();o.setCoords({env2D:n}),o.intersect(r);const a=t.querySegmentIterator(),h=e.querySegmentIterator(),m=i.Envelope2D.constructEmpty(),l=i.Envelope2D.constructEmpty(),u=new Q;u.setTolerance(s);let c=!1;for(u.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(o)&&(c=!0,u.addRedEnvelope(a.getStartPointIndex(),m));if(u.endRedConstruction(),!c)return null;let g=!1;for(u.startBlueConstruction();h.nextPath();)for(;h.hasNextSegment();)h.nextSegment().queryLooseEnvelope(l),l.isIntersecting(o)&&(g=!0,u.addBlueEnvelope(h.getStartPointIndex(),l));return u.endBlueConstruction(),g?u:null}function Ct(t,e,s,n,r){t.getGeometryType(),e.getGeometryType();const o=i.Envelope2D.constructEmpty(),a=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(s,s),a.inflateCoords(s,s);const h=i.Envelope2D.constructEmpty();h.setCoords({env2D:o}),h.intersect(a);const m=new Q;m.setTolerance(s);let l=!1;m.startRedConstruction();for(let e=0,s=t.getPathCount();e<s;e++)t.queryLoosePathEnvelope(e,o),o.isIntersecting(h)&&(l=!0,m.addRedEnvelope(e,o));if(m.endRedConstruction(),!l)return null;let u=!1;m.startBlueConstruction();for(let t=0,s=e.getPathCount();t<s;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(h)&&(u=!0,m.addBlueEnvelope(t,a));return m.endBlueConstruction(),u?m:null}function vt(t,e,s){const n=i.Envelope2D.constructEmpty(),r=i.Envelope2D.constructEmpty();t.queryLooseEnvelope(n),e.queryEnvelope(r),n.inflateCoords(s,s),r.inflateCoords(s,s);const o=i.Envelope2D.constructEmpty();o.setCoords({env2D:n}),o.intersect(r);const a=t.querySegmentIterator(),h=new Q;h.setTolerance(s);let m=!1;for(h.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(n),n.isIntersecting(o)&&(m=!0,h.addRedEnvelope(a.getStartPointIndex(),n));if(h.endRedConstruction(),!m)return null;let l=!1;h.startBlueConstruction();for(let t=0,s=e.getPointCount();t<s;t++){const s=e.getXY(t);o.contains(s)&&(l=!0,h.addBlueEnvelope(t,i.Envelope2D.construct(s.x,s.y,s.x,s.y)))}return h.endBlueConstruction(),l?h:null}function St(t,e,s){const r=i.Envelope2D.constructEmpty(),o=i.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=i.Envelope2D.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Q;h.setTolerance(s);let m=!1;h.startRedConstruction();const l=new n.P;for(let e=0,s=t.getPointCount();e<s;e++)t.queryXY(e,l),a.contains(l)&&(m=!0,h.addRedEnvelope(e,i.Envelope2D.construct(l.x,l.y,l.x,l.y)));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();const c=new n.P;for(let t=0,s=e.getPointCount();t<s;t++)e.queryXY(t,c),a.contains(c)&&(u=!0,h.addBlueEnvelope(t,i.Envelope2D.construct(c.x,c.y,c.x,c.y)));return h.endBlueConstruction(),u?h:null}function bt(t){const e=new i.Envelope2D;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){const s=new i.Envelope2D;if(t.queryLooseEnvelope(s),s.isEmpty())return null;t.getGeometryType();const n=new L(s,8);let o=-1;const a=new i.Envelope2D;let h=!1;do{for(let i=0,m=t.getPathCount();i<m;i++)if(t.queryLoosePathEnvelope(i,a),a.isIntersecting(e)){if(o=n.insertEx(i,a,o),-1===o){h&&(0,r.d)("build_quad_tree_for_paths"),s.assign(t.calculateEnvelope2D(!1)),h=!0,n.reset(s,8);break}h=!1}}while(h);return n}(t,e)}function It(t,e){if(!e){const e=new i.Envelope2D;t.queryLooseEnvelope(e);const s=new L(e,8);let n=-1;const o=new i.Envelope2D,a=t.querySegmentIterator();let h=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const i=a.nextSegment(),m=a.getStartPointIndex();if(i.queryLooseEnvelope(o),n=s.insertEx(m,o,n),-1===n){h&&(0,r.d)(""),e.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(e,8),a.resetToFirstPath();break}}return s}const s=new i.Envelope2D;t.queryLooseEnvelope(s);const n=new L(s,8);let o=-1;const a=new i.Envelope2D,h=t.querySegmentIterator();let m=!1;for(;h.nextPath();)for(;h.hasNextSegment();){const i=h.nextSegment(),l=h.getStartPointIndex();if(i.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=n.insertEx(l,a,o),-1===o)){m&&(0,r.d)(""),s.assign(t.calculateEnvelope2D(!1)),m=!0,n.reset(s,8),h.resetToFirstPath();break}}return n}function Dt(t,e){if(e){const s=new L(e,8),o=new n.P,a=new i.Envelope2D;let h=!1;for(let n=0;n<t.getPointCount();n++)o.setCoordsPoint2D(t.getXY(n)),e.contains(o)&&(a.setCoords({pt:o}),-1!==s.insert(n,a)||(h&&(0,r.d)(""),h=!0,s.reset(t.calculateEnvelope2D(),8),n=-1));return s}return(0,r.t)("no-extent version not yet impl"),null}function wt(t,e,s,n,i){let r=!1;const o=i.vmin,a=i.vmax;for(let i=s;i<e;i+=n){const e=t.read(i);e<o?(r=!0,t.write(i,o)):e>a&&(r=!0,t.write(i,a))}return r}function Tt(t,e,s,n){if(!t.hasAttribute(s))return!1;const i=t.getGeometryType();if(i===r.G.enumGeometryCollection){const i=t,r=i.getGeometryCount();let o=0;for(let t=0;t<r;++t)o|=Tt(i.getGeometry(t),e,s,n)?1:0;return!!o}if((0,r.i)(i)){const i=t,o=K.getPersistence(s),a=K.getComponentCount(s),h=i.getPointCount();if(1===o){const t=wt(i.getAttributeStreamRef(s),h*a,n,a,e);return t&&i.notifyModified(),t}if(2===o){const t=wt(i.getAttributeStreamRef(s),h*a,n,a,e);return t&&i.notifyModified(),t}(0,r.d)("snap_coordinate not implemented")}if(i===r.G.enumEnvelope){const i=t,r=i.queryInterval(s,n);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&i.setIntervalEnvelope(s,n,r),o}if(i===r.G.enumPoint){const i=t;let r=i.getAttributeAsDbl(s,n),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setAttributeBasic(s,n,r),o}if((0,r.f)(i)){const i=t;let r=i.getStartAttributeAsDbl(s,n),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setStartAttribute(s,n,r),r=i.getEndAttributeAsDbl(s,n),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setEndAttribute(s,n,r),o}(0,r.d)("snap_coordinate not implemented")}var Nt=g;class At{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=E(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=C(),this.ensureAttributes(),this.setXYZ(new S(t.x,t.y,t.z))):(this.m_description=E(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=E()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new n.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new S;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Nt.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;(0,r.q)("")}const s=Nt.getComponentCount(t);(e<0||e>=s)&&(0,r.q)("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]:Nt.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:(0,r.q)(""));const n=Nt.getComponentCount(t);(e<0||e>=n)&&(0,r.q)("");let i=this.m_description.getAttributeIndex(t);i<0&&(this.addAttribute(t),i=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(i)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=Nt.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,n)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=E();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof Ft)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof b){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new n.E;if(this.isEmpty())return s.setEmpty(),s;const i=this.getAttributeAsDbl(t,e);return s.vmin=i,s.vmax=i,s}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){const e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,r.t)("3d not impl")}}transformAttribute(t,e,s,n,i){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=tt(s,n,i);this.setAttributeBasic(t,e,o(r))}createInstance(){return new At({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=E(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&(0,n.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.G.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let t=0,i=this.m_description.getTotalComponentCount()-2;t<i;t++)if(!(0,n.a5)(this.m_attribs[t],s.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){const t=new At({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,n.c)(this.m_description,this.m_description=e.m_description),e.x=(0,n.c)(this.x,this.x=e.x),e.y=(0,n.c)(this.y,this.y=e.y),e.m_attribs=(0,n.c)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Nt.getComponentCount(t);for(let n=0;n<s;n++){const s=this.getAttributeAsDbl(t,n);Number.isNaN(s)&&this.setAttributeBasic(t,n,e)}}lerp(t,e,s){if(t.getDescription()!==e.getDescription()&&(0,r.a)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const i=c();t.queryValues(i,i.length);const o=c();e.queryValues(o,o.length);const a=c();let h=i,m=o;const l=a;let u=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),i=Nt.getInterpolation(e),r=Nt.getComponentCount(e),o=Nt.getDefaultValue(e);(0,n.a9)(i,h,m,l,u,r,s,o),h=h.slice(r),m=m.slice(r),u+=r}return this.setValues(a,u),this}static lerp(t,e,s,n){n.lerp(t,e,s)}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,n.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return n.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=E());const e=_();v(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let n=1,i=t.getAttributeCount();n<i;n++){const i=e[n];if(-1!==i){const e=this.m_description.getPointAttributeOffset(i)-2,r=t.getPointAttributeOffset(n)-2,o=Nt.getComponentCount(t.getSemantics(n));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),t[0]=this.x,t[1]=this.y,(0,n.b)(t,this.m_attribs,2,0,s-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,n.b)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let n=1,i=e.getAttributeCount();n<i;n++){const i=e.getSemantics(n);let r=Nt.getComponentCount(i);if(this.m_description.hasAttribute(i)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(i))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Nt.getDefaultValue(i);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),this.x=t[0],this.y=t[1],(0,n.b)(this.m_attribs,t,0,2,s-2)}dbgDefaultAttribs(){}}At.type=r.G.enumPoint;var Gt=g;function qt(t,e){return e*(t.getTotalComponentCount()-2)}class Mt{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new i.Envelope2D(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new i.Envelope2D(t.env2D);else if(t.move)this.m_envelope2D=new i.Envelope2D(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new i.Envelope2D(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=i.Envelope2D.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=(0,n.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const s=e,o=t.getTotalComponentCount()-2;if(s.m_description!==t&&(s.releaseAttributes_(),s.m_description=t,o&&(s.m_data.m_attributes=(0,n.d)(2*o,Number.NaN))),o){(0,r.g)(this.m_attributes&&s.m_data.m_attributes);const t=2*o;(0,n.b)(s.m_data.m_attributes,this.m_attributes,0,0,t)}s.m_data.m_envelope2D=new i.Envelope2D(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new i.Envelope2D(this.m_envelope2D),e.releaseAttributes(),t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,s,n,i){(0,r.g)(0)}queryInterval(t,e,s,n){if(this.isEmpty())return void n.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(n):1===s?this.m_envelope2D.queryIntervalY(n):(0,r.q)(""));const i=Gt.getComponentCount(e);(s<0||s>=i)&&(0,r.q)("");const o=t.getAttributeIndex(e);if(o>=0)return n.vmin=this.m_attributes[qt(t,0)+t.getPointAttributeOffset(o)-2+s],void(n.vmax=this.m_attributes[qt(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=Gt.getDefaultValue(e);return void n.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new n.E;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=(0,n.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}let Ft=class t{constructor(t){if(this.m_EnvelopeType=4,this.m_description=E(),void 0===t)this.m_data=new Mt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Mt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Mt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Mt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Mt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Mt({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Mt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Mt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,s,n,i){(0,r.g)(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=this.queryInterval(t,e);n.vmin=s,n.vmax=s,this.setIntervalEnvelope(t,e,n)}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new i.Envelope2D(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.G.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new n.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),n=Gt.getComponentCount(e);for(let s=0;s<n;s++){const n=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,n)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,n){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:n})}setEnvelope(t){if(t instanceof i.Envelope2D)this.m_data.m_envelope2D=new i.Envelope2D(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=n.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof i.Envelope2D)return e.isValid()||(0,r.a)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(e);if(e instanceof t){if(e.m_data.isEmpty())return;const t=e.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(e.m_data.m_envelope2D);for(let s=1,n=t.getAttributeCount();s<n;s++){const n=t.getSemantics(s),i=Gt.getComponentCount(n);for(let t=0;t<i;t++){const s=e.queryInterval(n,t),i=this.queryInterval(n,t);i.merge(s),this.setIntervalEnvelope(n,t,i)}}return}if(e instanceof At){const t=e;if(t.isEmpty())return;const s=t.getDescription();if(this.mergeVertexDescription(s),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let e=1,n=s.getAttributeCount();e<n;e++){const n=s.getSemantics(e),i=Gt.getComponentCount(n);for(let e=0;e<i;e++){const s=t.getAttributeAsDbl(n,e),i=this.queryInterval(n,e);i.mergeCoordinate(s),this.setIntervalEnvelope(n,e,i)}}return}(0,r.t)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),n=Gt.getComponentCount(s);for(let e=0;e<n;e++){const n=t.queryInterval(s,e),i=this.queryInterval(s,e);i.intersect(n),this.setIntervalEnvelope(s,e,i)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s);if(!e.hasAttribute(n))continue;const i=Gt.getComponentCount(n);for(let e=0;e<i;e++){const s=t.queryInterval(n,e),i=this.queryInterval(n,e);i.intersect(s),this.setIntervalEnvelope(n,e,i)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=new n.E(s);if(i.normalize(),0===t){if(i.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=i.vmin,this.m_data.m_envelope2D.xmax=i.vmax):1===e?(this.m_data.m_envelope2D.ymin=i.vmin,this.m_data.m_envelope2D.ymax=i.vmax):(0,r.q)("")}else this.setAttributeAsDblImpl(0,t,e,i.vmin),this.setAttributeAsDblImpl(1,t,e,i.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new n.E(s,i))}queryInterval(t,e){const s=new n.E;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,r.t)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,r.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new t({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=E()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,r.g)(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,i=2*(this.m_description.getTotalComponentCount()-2);t<i;t++)if(!(0,n.a5)(this.m_data.m_attributes[t],s.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.t)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new t({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumEnvelope&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,n.c)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,n.c)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,n.c)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.a)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.q)(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let n=1;n<s;n++){const s=this.m_description.getSemantics(n),i=Gt.getComponentCount(s);for(let n=0;n<i;n++)e.setAttributeBasic(s,n,this.getAttributeAsDblImpl(t%2,s,n))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=E();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=Gt.getComponentCount(t);for(let n=0;n<s;n++){const s=this.queryInterval(t,n);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,n,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const n=t.getDescription();for(let e=1,s=n.getAttributeCount();e<s;e++){const s=n.getSemantics(e),i=Gt.getComponentCount(s);for(let e=0;e<i;e++){const n=t.getAttributeAsDbl(s,e);this.setInterval(s,e,n,n)}}}assignVertexDescriptionImpl(t){const e=_();v(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,r=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=(0,n.d)(2*i,Number.NaN));for(let o=1;o<t.getAttributeCount();o++){const a=e[o];if(-1!==a){const e=t.getPointAttributeOffset(o)-2,h=Gt.getComponentCount(t.getSemantics(o)),m=this.m_description.getPointAttributeOffset(a)-2;(0,n.b)(s,this.m_data.m_attributes,e,m,h),(0,n.b)(s,this.m_data.m_attributes,i+e,r+m,h)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&(0,r.B)(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=Gt.getComponentCount(e)&&(0,r.q)("");const n=this.m_description.getAttributeIndex(e);return n>=0?this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(n)-2+s]:g.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,n){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=n:0===s?this.m_data.m_envelope2D.xmax=n:(0,r.q)(""):1===s?this.m_data.m_envelope2D.ymin=n:0===s?this.m_data.m_envelope2D.xmin=n:(0,r.q)(""));const i=Gt.getComponentCount(e);(s<0||s>=i)&&(0,r.q)(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=n}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}};Ft.type=r.G.enumEnvelope,Object.freeze(Object.defineProperty({__proto__:null,Envelope:Ft,EnvelopeData:Mt},Symbol.toStringTag,{value:"Module"}))}}]);
|