@arcgis/core 4.32.0-next.20250128 → 4.32.0-next.20250130
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/TrackGraphic.js +1 -1
- package/applications/Components/SelectionOperation.d.ts +1 -2
- package/applications/Components/SketchTooltipControls.d.ts +1 -2
- package/applications/Components/basemapUtils.d.ts +1 -2
- package/applications/Components/drawUtils.d.ts +1 -2
- package/applications/Components/fontUtils.d.ts +1 -2
- package/applications/Components/getDefaultUnits.d.ts +1 -2
- package/applications/Components/gfxUtils.d.ts +1 -2
- package/applications/Components/layerOriginUtils.d.ts +4 -2
- package/applications/Components/layersEffectsJsonUtils.d.ts +1 -2
- package/applications/Components/previewSymbol2D.d.ts +1 -2
- package/applications/Components/reactiveUtils.d.ts +1 -2
- package/applications/Components/styleUtils.d.ts +1 -2
- package/applications/Components/svgUtils.d.ts +3 -2
- package/applications/Components/webStyleSymbolUtils.d.ts +1 -2
- package/applications/Excalibur/videoViewUtils.d.ts +1 -2
- package/applications/ExperienceBuilder/sketchUtils.d.ts +3 -2
- package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +2 -2
- package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +3 -2
- package/applications/KnowledgeStudio/resourceSerializationUtils.d.ts +4 -2
- package/applications/MapViewer/mediaUtils.d.ts +2 -2
- package/applications/MapViewer/templateUtils.d.ts +4 -2
- package/applications/SceneViewer/colorUtils.d.ts +1 -2
- package/applications/SceneViewer/devEnvironmentUtils.d.ts +3 -2
- package/applications/SceneViewer/layerUtils.d.ts +2 -2
- package/applications/SceneViewer/sceneViewerUtils.d.ts +15 -2
- package/applications/SceneViewer/symbolUtils.d.ts +1 -2
- package/applications/Urban/meshUtils.d.ts +1 -2
- package/applications/WebEditor/sketchUtils.d.ts +2 -2
- package/arcade.d.ts +2 -2
- package/assets/components/assets/icon/hammerCoin16.json +1 -0
- package/assets/components/assets/icon/hammerCoin24.json +1 -0
- package/assets/components/assets/icon/hammerCoin32.json +1 -0
- package/assets/components/assets/icon/hammerLock16.json +1 -0
- package/assets/components/assets/icon/hammerLock24.json +1 -0
- package/assets/components/assets/icon/hammerLock32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/06d72622590dbd38c5de.js +1 -0
- package/assets/esri/core/workers/chunks/07c5f3fc475c57f5a7a7.js +1 -0
- package/assets/esri/core/workers/chunks/08c4b585290efc98ca5d.js +1 -0
- package/assets/esri/core/workers/chunks/{41f7287832d407f13ce5.js → 09b77f82c22530b44daa.js} +1 -1
- package/assets/esri/core/workers/chunks/0b62871b89dcb4c70457.js +1 -0
- package/assets/esri/core/workers/chunks/0bafa546602b776caf2f.js +1 -0
- package/assets/esri/core/workers/chunks/0ebdf0d1fd2034b24519.js +972 -0
- package/assets/esri/core/workers/chunks/{e89439cc20b7f4c6a9d1.js → 0ef5b0f8aa8a09acd6e0.js} +1 -1
- package/assets/esri/core/workers/chunks/117e7a12af77c761efb5.js +1 -0
- package/assets/esri/core/workers/chunks/122ed10cac9f192e1eec.js +1 -0
- package/assets/esri/core/workers/chunks/12964a4b16113cdc9c93.js +1 -0
- package/assets/esri/core/workers/chunks/149bad940feb0764b350.js +1 -0
- package/assets/esri/core/workers/chunks/1891c9aa162c5df1d27c.js +1 -0
- package/assets/esri/core/workers/chunks/1ab83753d9eec0463461.js +1 -0
- package/assets/esri/core/workers/chunks/{304722106439951da6e1.js → 1accbc048b74857269e4.js} +1 -1
- package/assets/esri/core/workers/chunks/{0edf5cd5d004631c3959.js → 1cbeac3301b6943bb28a.js} +1 -1
- package/assets/esri/core/workers/chunks/1d51c064045e9c47bd2e.js +1 -0
- package/assets/esri/core/workers/chunks/1f443b99653708470f31.js +1 -0
- package/assets/esri/core/workers/chunks/{7d49b5bc9eb102e467ab.js → 220b12654b94c94f8d8a.js} +1 -1
- package/assets/esri/core/workers/chunks/22e11a8abc70b6571a2b.js +1 -0
- package/assets/esri/core/workers/chunks/2345344be4b0e487d3a6.js +1 -0
- package/assets/esri/core/workers/chunks/{6eb829a7959df2269b0e.js → 24c94f97a76646d415ae.js} +1 -1
- package/assets/esri/core/workers/chunks/258b46b58a4860942f7c.js +1 -0
- package/assets/esri/core/workers/chunks/25c8cc30faade043c8dc.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/2c6f2fdf274c0258621e.js +1 -0
- package/assets/esri/core/workers/chunks/2ff63a71213f618377d6.js +1 -0
- package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{985ae30627429832b2a9.js → 32f5f00aab55ef16dcf1.js} +1 -1
- package/assets/esri/core/workers/chunks/380d37ceb8cf52bad190.js +1 -0
- package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +1 -0
- package/assets/esri/core/workers/chunks/3e872e5e528dca7bee0c.js +1 -0
- package/assets/esri/core/workers/chunks/3ec51b75d1a86dad6cb1.js +1 -0
- package/assets/esri/core/workers/chunks/4263eee3247aaf4e64bf.js +1 -0
- package/assets/esri/core/workers/chunks/448ee44c7f594e5b2551.js +1 -0
- package/assets/esri/core/workers/chunks/476205ee4414ed80666a.js +1 -0
- package/assets/esri/core/workers/chunks/4b56c0c109e10d7409b8.js +1 -0
- package/assets/esri/core/workers/chunks/{95e786366bc471bd0730.js → 4c5279fedf982a174706.js} +1 -1
- package/assets/esri/core/workers/chunks/4cab082b8432ddc05345.js +1 -0
- package/assets/esri/core/workers/chunks/{1e1306527fb38c5894eb.js → 5a536de1ecae424bad05.js} +1 -1
- package/assets/esri/core/workers/chunks/5adeb979f178944b9ce5.js +1 -0
- package/assets/esri/core/workers/chunks/5be7cf1564e756c24066.js +1 -0
- package/assets/esri/core/workers/chunks/{f09c95c3d79205ee5a84.js → 5e9bf6d0db82526b8a8c.js} +5 -5
- package/assets/esri/core/workers/chunks/{57ebfa7f163a1b40cd1e.js → 61795bde00f2e16d04f1.js} +1 -1
- package/assets/esri/core/workers/chunks/{568fe969e8f914f042ca.js → 627cbe662d58cda62e7e.js} +1 -1
- package/assets/esri/core/workers/chunks/{6d179eb8edcefb91d5d7.js → 69ab4b780f7223cfd7dd.js} +1 -1
- package/assets/esri/core/workers/chunks/6d79ec15d1858839f576.js +1 -0
- package/assets/esri/core/workers/chunks/6e25742ceedea7fb1b97.js +1 -0
- package/assets/esri/core/workers/chunks/6e8905f20101c1f4509d.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +1 -0
- package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{50beab30e120ba39d212.js → 76794184ba8c2e66745e.js} +1 -1
- package/assets/esri/core/workers/chunks/7810579a5a780933cdc9.js +1 -0
- package/assets/esri/core/workers/chunks/{e45dba512ebee97f0af2.js → 78242f2bf742b33d99fa.js} +1 -1
- package/assets/esri/core/workers/chunks/7966c245a073c85f04b1.js +1 -0
- package/assets/esri/core/workers/chunks/{fa0d968733d581bc2e4d.js → 7d120f8b01fe719eb257.js} +1 -1
- package/assets/esri/core/workers/chunks/7e23c15b2a02116f7189.js +1 -0
- package/assets/esri/core/workers/chunks/7f87cf3d6a365d987f69.js +1 -0
- package/assets/esri/core/workers/chunks/83edac97a52b26ead1ea.js +314 -0
- package/assets/esri/core/workers/chunks/881ddbdeb40336208e90.js +1 -0
- package/assets/esri/core/workers/chunks/{ec9d5af8887854e821c8.js → 88cbaa91c495d86f4bb0.js} +1 -1
- package/assets/esri/core/workers/chunks/{11c999b976ed805b0608.js → 89e3f7880abd014a62c0.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3ae5ea96898de327147.js → 8bd51b5b392dfacc922f.js} +1 -1
- package/assets/esri/core/workers/chunks/8e6301006abdf47cc88d.js +1 -0
- package/assets/esri/core/workers/chunks/{9466e53ff270f6eb42c9.js → 9011704b258ecbfb6d9b.js} +2 -2
- package/assets/esri/core/workers/chunks/{9466e53ff270f6eb42c9.js.LICENSE.txt → 9011704b258ecbfb6d9b.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/92984981afcbb95828cd.js +1 -0
- package/assets/esri/core/workers/chunks/934857de20f6f5c15188.js +1 -0
- package/assets/esri/core/workers/chunks/95ad76e58452b60fb79f.js +1 -0
- package/assets/esri/core/workers/chunks/9725398f6d56c8ba54ae.js +1 -0
- package/assets/esri/core/workers/chunks/97310e6eec87eeaf58f0.js +1 -0
- package/assets/esri/core/workers/chunks/9ffa27d0517bad84572e.js +1 -0
- package/assets/esri/core/workers/chunks/a39977478a6c57d2e8fb.js +1 -0
- package/assets/esri/core/workers/chunks/{f355ca70abadb2155839.js → a61d05354348385f41b5.js} +1 -1
- package/assets/esri/core/workers/chunks/af917f69d9c6e9937263.js +1 -0
- package/assets/esri/core/workers/chunks/b18620fc15707e4413a1.js +1 -0
- package/assets/esri/core/workers/chunks/b1baf39daf5725404be5.js +1 -0
- package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{39a6fe4cdb205f4925fb.js → b68bddd0c4ca91493543.js} +1 -1
- package/assets/esri/core/workers/chunks/bc50585615f07d5ec1a9.js +1 -0
- package/assets/esri/core/workers/chunks/bf9bc52a3c559108c19a.js +2 -0
- package/assets/esri/core/workers/chunks/{b5d4255db21dfd3b3b13.js.LICENSE.txt → bf9bc52a3c559108c19a.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/c04091eea7089dc2e864.js +1 -0
- package/assets/esri/core/workers/chunks/{b9369c5415f5b3bda5cf.js → c1d80a709148e3373a82.js} +1 -1
- package/assets/esri/core/workers/chunks/c249ad935f54d3b49ae3.js +1 -0
- package/assets/esri/core/workers/chunks/{759618564e68fc09dc36.js → c57b9f2b9c229e68919d.js} +1 -1
- package/assets/esri/core/workers/chunks/c74441fbe0f63633796f.js +1 -0
- package/assets/esri/core/workers/chunks/{7fd48f0a2b35779e680a.js → c7a94e569c905f97244a.js} +1 -1
- package/assets/esri/core/workers/chunks/c80d542935803bf869f8.js +1 -0
- package/assets/esri/core/workers/chunks/{bc0183350841e09d71fa.js → c8a0089e080140db9076.js} +1 -1
- package/assets/esri/core/workers/chunks/{d71a5c029fc9f4820589.js → cee3a38b92a48a58c4d0.js} +1 -1
- package/assets/esri/core/workers/chunks/d1678945cf6a58f76863.js +1 -0
- package/assets/esri/core/workers/chunks/{9ed1691eab19dfb1cf04.js → d1718ad93e3271b0525e.js} +1 -1
- package/assets/esri/core/workers/chunks/{d5b373fe244e5dce1548.js → d27a199fd8e2ade69254.js} +1 -1
- package/assets/esri/core/workers/chunks/d3a8aabdbfb59dd433e3.js +1 -0
- package/assets/esri/core/workers/chunks/d599ba865da87b487b1b.js +1 -0
- package/assets/esri/core/workers/chunks/da1157e288dbc6ba842a.js +1 -0
- package/assets/esri/core/workers/chunks/{8584ccce34972e28c040.js → da77eefaad83c0644380.js} +1 -1
- package/assets/esri/core/workers/chunks/dd46ec81cebe1a0a7b9c.js +1 -0
- package/assets/esri/core/workers/chunks/dd9be173cddc16a354ed.js +1 -0
- package/assets/esri/core/workers/chunks/debfb75a94b66b58cbbc.js +1 -0
- package/assets/esri/core/workers/chunks/{5a83f90b55a5efbe1ef2.js → df3d1a8d3f11d52eb30d.js} +1 -1
- package/assets/esri/core/workers/chunks/e0de91eacf3a3b7eda55.js +51 -0
- package/assets/esri/core/workers/chunks/e444ec05a8a1dfbd21a8.js +1 -0
- package/assets/esri/core/workers/chunks/e4651d577d297386268e.js +1 -0
- package/assets/esri/core/workers/chunks/e468bf4ec7402942ad8c.js +1 -0
- package/assets/esri/core/workers/chunks/f200dca22f9f9bbb8670.js +1 -0
- package/assets/esri/core/workers/chunks/f2fae056a81f12b56b04.js +1 -0
- package/assets/esri/core/workers/chunks/f429d95eb986f3d215f3.js +1 -0
- package/assets/esri/core/workers/chunks/f8367c21fa91435c7c53.js +1 -0
- package/assets/esri/themes/base/_Ui.scss +6 -0
- package/assets/esri/themes/base/_mixins.scss +0 -7
- package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +0 -2
- package/assets/esri/themes/base/widgets/_Bookmarks.scss +0 -5
- package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +0 -2
- package/assets/esri/themes/base/widgets/_Features.scss +0 -5
- package/assets/esri/themes/base/widgets/_LayerList.scss +0 -2
- package/assets/esri/themes/base/widgets/_TableList.scss +0 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ar.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bg.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bs.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ca.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_cs.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_da.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_de.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_el.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_en.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_es.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_et.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fi.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_he.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hu.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_id.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_it.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ja.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ko.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lt.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lv.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_nl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_no.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-BR.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-PT.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ro.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ru.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sk.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sv.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_th.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_tr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_uk.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_vi.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-CN.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-HK.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-TW.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_no.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_no.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
- package/chunks/AtmosphereCompositing.glsl.js +2 -2
- package/chunks/BlendLayers.glsl.js +1 -1
- package/chunks/BlendWeights.glsl.js +1 -1
- package/chunks/BloomBlur.glsl.js +23 -23
- package/chunks/BloomComposition.glsl.js +3 -3
- package/chunks/BloomDepthAdjust.glsl.js +2 -2
- package/chunks/Blur.glsl.js +1 -1
- package/chunks/Bufferer-DjC-SKTJ.js +5 -0
- package/chunks/ChapmanAtmosphere.glsl.js +2 -2
- package/chunks/CheckerBoard.glsl.js +2 -2
- package/chunks/Clouds.glsl.js +14 -14
- package/chunks/CloudsComposition.glsl.js +1 -1
- package/chunks/ColorMaterial.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +4 -4
- package/chunks/Compositing.glsl.js +2 -2
- package/chunks/DefaultMaterial.glsl.js +16 -15
- package/chunks/{Distance2DCalculator-C9BrfErD.js → Distance2DCalculator-8-JrFGHH.js} +1 -1
- package/chunks/EdgeDetect.glsl.js +2 -2
- package/chunks/EdgeShader.glsl.js +2 -2
- package/chunks/Envelope.js +1 -1
- package/chunks/FocusAreaColor.glsl.js +2 -2
- package/chunks/FocusAreaMask.glsl.js +1 -1
- package/chunks/Fog.glsl.js +3 -3
- package/chunks/GeodeticDistanceCalculator-BsWHOuqE.js +5 -0
- package/chunks/Geometry.js +1 -1
- package/chunks/HUDCompositing.glsl.js +1 -1
- package/chunks/HUDMaterial.glsl.js +24 -24
- package/chunks/Haze.glsl.js +3 -3
- package/chunks/HazeCompositing.glsl.js +2 -2
- package/chunks/Heatmap.glsl.js +1 -1
- package/chunks/HeatmapDensity.glsl.js +5 -5
- package/chunks/HighlightApply.glsl.js +2 -2
- package/chunks/HighlightDownsample.glsl.js +2 -2
- package/chunks/HighlightToSingle.glsl.js +2 -2
- package/chunks/ImageMaterial.glsl.js +4 -4
- package/chunks/LaserlinePath.glsl.js +1 -1
- package/chunks/Laserlines.glsl.js +1 -1
- package/chunks/LineCallout.glsl.js +1 -1
- package/chunks/LineMarker.glsl.js +8 -8
- package/chunks/Magnifier.glsl.js +4 -4
- package/chunks/MeasurementArrow.glsl.js +2 -2
- package/chunks/NativeLine.glsl.js +4 -4
- package/chunks/NoiseTextureAtlas.glsl.js +34 -34
- package/chunks/OITBlend.glsl.js +3 -3
- package/chunks/OperatorClip.js +1 -1
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeneralize.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticDistance.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/OverlayCompositing.glsl.js +1 -1
- package/chunks/Path.glsl.js +9 -9
- package/chunks/Pattern.glsl.js +3 -3
- package/chunks/Point2D.js +1 -1
- package/chunks/PointRenderer.glsl.js +1 -1
- package/chunks/Precipitation.glsl.js +1 -1
- package/chunks/ProjectionTransformation.js +1 -1
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/RasterColorizer.glsl.js +9 -9
- package/chunks/RealisticTree.glsl.js +3 -3
- package/chunks/RibbonLine.glsl.js +32 -32
- package/chunks/SSAO.glsl.js +2 -2
- package/chunks/SSAOBlur.glsl.js +1 -1
- package/chunks/ShadedColorMaterial.glsl.js +3 -3
- package/chunks/ShadowCastAccumulate.glsl.js +2 -2
- package/chunks/ShadowCastVisualize.glsl.js +4 -4
- package/chunks/ShadowHighlight.glsl.js +2 -2
- package/chunks/{SideCalculator2D-Bf4QCxCR.js → SideCalculator2D-BNwb5gvz.js} +1 -1
- package/chunks/SimpleAtmosphere.glsl.js +8 -8
- package/chunks/SingleHighlightApply.glsl.js +1 -1
- package/chunks/SingleHighlightBlur.glsl.js +6 -7
- package/chunks/SlicePlaneMaterial.glsl.js +2 -2
- package/chunks/Stars.glsl.js +2 -2
- package/chunks/Terrain.glsl.js +2 -2
- package/chunks/TextureOnly.glsl.js +2 -2
- package/chunks/Viewshed.glsl.js +2 -2
- package/chunks/WaterSurface.glsl.js +7 -7
- package/chunks/distanceOperator.js +1 -1
- package/chunks/relateOperator.js +1 -1
- package/core/QueueProcessor.js +5 -0
- package/core/accessorSupport/decorators.d.ts +4 -2
- package/core/has.js +1 -1
- package/core/jsonMap.js +1 -1
- package/core/lang.d.ts +1 -2
- package/core/libs/gl-matrix-2/factories/vec2f64.js +1 -1
- package/core/mathUtils.js +1 -1
- package/core/promiseUtils.d.ts +5 -2
- package/core/quantity.d.ts +3 -2
- package/core/reactiveUtils.d.ts +5 -2
- package/core/scheduling.d.ts +2 -2
- package/core/sql/WhereClauseCache.js +1 -1
- package/core/sql.d.ts +1 -2
- package/core/sql.js +1 -1
- package/core/units.d.ts +9 -2
- package/core/urlUtils.d.ts +5 -2
- package/core/workers.d.ts +1 -2
- package/editing/sharedTemplates/executor/builders/bufferLineToPolygon.js +1 -1
- package/editing/sharedTemplates/executor/builders/bufferPointToPolygon.js +1 -1
- package/editing/sharedTemplates/executor/builders/bufferPolygonToPolygon.js +1 -1
- package/editing/sharedTemplates/executor/builders/connectionPoint.js +1 -1
- package/editing/sharedTemplates/executor/builders/equallySpaced.js +1 -1
- package/editing/sharedTemplates/executor/builders/offsetLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/offsetPrimaryLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtAllVerticesOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtBeginningOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtBeginningOfRadial.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtEndOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtInteriorVertices.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtIntersectionVerticesOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtNotBeginningOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtNotEndOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtPolygonCentroid.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtPolygonNotStart.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtPolygonStart.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointIdentity.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointPrimaryIdentity.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonBoundaryTwoPoint.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonIdentity.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonPrimaryIdentity.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonVertices.js +1 -1
- package/editing/sharedTemplates/executor/builders/radialLines.js +1 -1
- package/editing/sharedTemplates/executor/builders/twoPointLines.js +1 -1
- package/editing/sharedTemplates/executor/createTemplateExecutor.js +5 -0
- package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
- package/editing/sharedTemplates/executor/support/executorUtils.js +1 -1
- package/editing/sharedTemplates/executor/support/getBuilder.js +5 -0
- package/editing/templateUtils.js +1 -1
- package/form/elements/inputs.d.ts +11 -2
- package/form/elements.d.ts +7 -2
- package/geometry/coordinateFormatter.d.ts +11 -2
- package/geometry/geometryEngine.d.ts +37 -2
- package/geometry/geometryEngineAsync.d.ts +37 -2
- package/geometry/operators/affineTransformOperator.d.ts +3 -2
- package/geometry/operators/alphaShapeOperator.d.ts +3 -2
- package/geometry/operators/areaOperator.d.ts +2 -2
- package/geometry/operators/autoCompleteOperator.d.ts +2 -2
- package/geometry/operators/boundaryOperator.d.ts +3 -2
- package/geometry/operators/bufferOperator.d.ts +3 -2
- package/geometry/operators/centroidOperator.d.ts +2 -2
- package/geometry/operators/clipOperator.d.ts +3 -2
- package/geometry/operators/containsOperator.d.ts +3 -2
- package/geometry/operators/convexHullOperator.d.ts +4 -2
- package/geometry/operators/crossesOperator.d.ts +3 -2
- package/geometry/operators/cutOperator.d.ts +2 -2
- package/geometry/operators/densifyOperator.d.ts +3 -2
- package/geometry/operators/differenceOperator.d.ts +3 -2
- package/geometry/operators/disjointOperator.d.ts +3 -2
- package/geometry/operators/distanceOperator.d.ts +2 -2
- package/geometry/operators/equalsOperator.d.ts +3 -2
- package/geometry/operators/extendOperator.d.ts +2 -2
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/generalizeOperator.d.ts +3 -2
- package/geometry/operators/geodesicBufferOperator.d.ts +5 -2
- package/geometry/operators/geodesicProximityOperator.d.ts +6 -2
- package/geometry/operators/geodeticAreaOperator.d.ts +4 -2
- package/geometry/operators/geodeticDensifyOperator.d.ts +5 -2
- package/geometry/operators/geodeticDistanceOperator.d.ts +4 -2
- package/geometry/operators/geodeticLengthOperator.d.ts +4 -2
- package/geometry/operators/graphicBufferOperator.d.ts +2 -2
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBoundary.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorConvexHull.js +1 -1
- package/geometry/operators/gx/operatorDifference.js +1 -1
- package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
- package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
- package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorLocateBetween.js +1 -1
- package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/gx/operatorProject.js +1 -1
- package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
- package/geometry/operators/gx/operatorShapePreservingProject.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSinglePartToMultiPart.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/integrateOperator.d.ts +2 -2
- package/geometry/operators/intersectionOperator.d.ts +4 -2
- package/geometry/operators/intersectsOperator.d.ts +3 -2
- package/geometry/operators/isNearOperator.d.ts +2 -2
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/labelPointOperator.d.ts +3 -2
- package/geometry/operators/lengthOperator.d.ts +2 -2
- package/geometry/operators/linesToPolygonsOperator.d.ts +2 -2
- package/geometry/operators/locateBetweenOperator.d.ts +2 -2
- package/geometry/operators/minimumBoundingCircleOperator.d.ts +3 -2
- package/geometry/operators/multiPartToSinglePartOperator.d.ts +2 -2
- package/geometry/operators/offsetOperator.d.ts +3 -2
- package/geometry/operators/overlapsOperator.d.ts +3 -2
- package/geometry/operators/polygonOverlayOperator.d.ts +2 -2
- package/geometry/operators/polygonSlicerOperator.d.ts +4 -2
- package/geometry/operators/projectOperator.d.ts +5 -2
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/proximityOperator.d.ts +4 -2
- package/geometry/operators/relateOperator.d.ts +4 -2
- package/geometry/operators/reshapeOperator.d.ts +2 -2
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/shapePreservingProjectOperator.d.ts +5 -2
- package/geometry/operators/shapePreservingProjectOperator.js +1 -1
- package/geometry/operators/simplifyOperator.d.ts +4 -2
- package/geometry/operators/support/geographicTransformationUtils.d.ts +4 -2
- package/geometry/operators/support/geographicTransformationUtils.js +1 -1
- package/geometry/operators/support/initNoPeFactory.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/operators/symmetricDifferenceOperator.d.ts +3 -2
- package/geometry/operators/touchesOperator.d.ts +3 -2
- package/geometry/operators/unionOperator.d.ts +3 -2
- package/geometry/operators/withinOperator.d.ts +3 -2
- package/geometry/projection.d.ts +5 -2
- package/geometry/support/geodesicUtils.d.ts +5 -2
- package/geometry/support/jsonUtils.d.ts +2 -2
- package/geometry/support/meshUtils.d.ts +6 -2
- package/geometry/support/normalizeUtils.d.ts +2 -2
- package/geometry/support/scaleUtils.js +1 -1
- package/geometry/support/webMercatorUtils.d.ts +6 -2
- package/geometry.d.ts +7 -2
- package/interfaces.d.ts +72 -94
- package/intl.d.ts +16 -2
- package/kernel.d.ts +2 -2
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/catalog/catalogUtils.d.ts +2 -2
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/cypherUtils.d.ts +1 -2
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/knowledgeGraph/supportUtils.d.ts +4 -2
- package/layers/mixins/APIKeyMixin.d.ts +1 -1
- package/layers/mixins/ArcGISCachedService.d.ts +1 -1
- package/layers/mixins/ArcGISImageService.d.ts +1 -1
- package/layers/mixins/ArcGISMapService.d.ts +1 -1
- package/layers/mixins/BlendLayer.d.ts +1 -1
- package/layers/mixins/CustomParametersMixin.d.ts +1 -1
- package/layers/mixins/DisplayFilteredLayer.d.ts +1 -1
- package/layers/mixins/FeatureEffectLayer.d.ts +1 -1
- package/layers/mixins/FeatureLayerBase.d.ts +1 -1
- package/layers/mixins/FeatureReductionLayer.d.ts +1 -1
- package/layers/mixins/ImageryTileMixin.d.ts +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/OperationalLayer.d.ts +1 -1
- package/layers/mixins/OrderedLayer.d.ts +1 -1
- package/layers/mixins/PortalLayer.d.ts +1 -1
- package/layers/mixins/PublishableLayer.d.ts +1 -1
- package/layers/mixins/RasterPresetRendererMixin.d.ts +1 -1
- package/layers/mixins/RefreshableLayer.d.ts +1 -1
- package/layers/mixins/ScaleRangeLayer.d.ts +1 -1
- package/layers/mixins/SceneService.d.ts +1 -1
- package/layers/mixins/SublayersOwner.d.ts +1 -1
- package/layers/mixins/TemporalLayer.d.ts +1 -1
- package/layers/mixins/TemporalSceneLayer.d.ts +1 -1
- package/layers/ogc/wcsUtils.d.ts +1 -2
- package/layers/ogc/wfsUtils.d.ts +2 -2
- package/layers/orientedImagery/transformations/imageToWorld.d.ts +1 -2
- package/layers/orientedImagery/transformations/worldToImage.d.ts +1 -2
- package/layers/support/DisplayFilterInfo.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/TrackInfo.js +1 -1
- package/layers/support/TrackPartInfo.js +5 -0
- package/layers/support/arcadeUtils.d.ts +1 -2
- package/layers/support/arcadeUtils.js +1 -1
- package/layers/support/csvUtils.d.ts +1 -2
- package/layers/support/displayFilterUtils.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/fieldUtils.d.ts +8 -2
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/layerOriginUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterFieldUtils.js +1 -1
- package/layers/support/rasterFunctionConstants.d.ts +15 -2
- package/layers/support/rasterFunctionUtils.d.ts +105 -2
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/libs/linkchartlayout/LinkChartLayout.js +1 -1
- package/package.json +3 -3
- package/pointCloudRenderers.d.ts +5 -2
- package/popup/content.d.ts +9 -2
- package/rasterRenderers.d.ts +7 -2
- package/renderers/mixins/VisualVariablesMixin.d.ts +1 -1
- package/renderers/support/jsonUtils.d.ts +1 -2
- package/renderers/support/utils.d.ts +2 -2
- package/renderers.d.ts +9 -2
- package/request.js +1 -1
- package/rest/closestFacility.d.ts +1 -2
- package/rest/featureService/utils.d.ts +1 -2
- package/rest/find.d.ts +1 -2
- package/rest/geometryService.d.ts +21 -2
- package/rest/geoprocessor.d.ts +2 -2
- package/rest/identify.d.ts +1 -2
- package/rest/imageService.d.ts +19 -2
- package/rest/knowledgeGraphService.d.ts +11 -2
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/locator.d.ts +4 -2
- package/rest/networkService.d.ts +1 -2
- package/rest/networks/queryAssociations.d.ts +1 -2
- package/rest/networks/synthesizeAssociationGeometries.d.ts +1 -2
- package/rest/networks/trace.d.ts +1 -2
- package/rest/places.d.ts +3 -2
- package/rest/print.d.ts +2 -2
- package/rest/query.d.ts +11 -2
- package/rest/route.d.ts +1 -2
- package/rest/serviceArea.d.ts +1 -2
- package/rest/symbolService.d.ts +1 -2
- package/smartMapping/labels/bins.d.ts +1 -2
- package/smartMapping/labels/clusters.d.ts +1 -2
- package/smartMapping/popup/clusters.d.ts +1 -2
- package/smartMapping/popup/templates.d.ts +1 -2
- package/smartMapping/raster/renderers/classBreaks.d.ts +1 -2
- package/smartMapping/raster/renderers/colormap.d.ts +1 -2
- package/smartMapping/raster/renderers/flow.d.ts +1 -2
- package/smartMapping/raster/renderers/rgb.d.ts +1 -2
- package/smartMapping/raster/renderers/shadedRelief.d.ts +1 -2
- package/smartMapping/raster/renderers/stretch.d.ts +1 -2
- package/smartMapping/raster/renderers/uniqueValue.d.ts +1 -2
- package/smartMapping/raster/renderers/vectorField.d.ts +1 -2
- package/smartMapping/raster/support/colorRamps.d.ts +5 -2
- package/smartMapping/raster/support/utils.d.ts +2 -2
- package/smartMapping/renderers/color.d.ts +6 -2
- package/smartMapping/renderers/dotDensity.d.ts +1 -2
- package/smartMapping/renderers/dotDensity.js +1 -1
- package/smartMapping/renderers/heatmap.d.ts +2 -2
- package/smartMapping/renderers/heatmap.js +1 -1
- package/smartMapping/renderers/location.d.ts +1 -2
- package/smartMapping/renderers/opacity.d.ts +1 -2
- package/smartMapping/renderers/pieChart.d.ts +2 -2
- package/smartMapping/renderers/predominance.d.ts +1 -2
- package/smartMapping/renderers/relationship.d.ts +2 -2
- package/smartMapping/renderers/size.d.ts +5 -2
- package/smartMapping/renderers/support/rendererUtils.d.ts +1 -2
- package/smartMapping/renderers/type.d.ts +2 -2
- package/smartMapping/renderers/univariateColorSize.d.ts +2 -2
- package/smartMapping/statistics/heatmapStatistics.js +1 -1
- package/smartMapping/statistics/summaryStatisticsForAttributes.js +1 -1
- package/smartMapping/statistics/support/ageUtils.d.ts +1 -2
- package/smartMapping/statistics/support/predominanceUtils.d.ts +1 -2
- package/smartMapping/support/adapters/CSVLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/LayerAdapter.js +1 -1
- package/smartMapping/support/adapters/OGCFeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/PointCloudLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/StreamLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/histogramUtils.js +5 -0
- package/smartMapping/support/adapters/support/layerUtils.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/smartMapping/symbology/color.d.ts +7 -2
- package/smartMapping/symbology/dotDensity.d.ts +4 -2
- package/smartMapping/symbology/flow.d.ts +5 -2
- package/smartMapping/symbology/heatmap.d.ts +5 -2
- package/smartMapping/symbology/location.d.ts +3 -2
- package/smartMapping/symbology/pieChart.d.ts +5 -2
- package/smartMapping/symbology/predominance.d.ts +5 -2
- package/smartMapping/symbology/relationship.d.ts +5 -2
- package/smartMapping/symbology/size.d.ts +3 -2
- package/smartMapping/symbology/support/colorRamps.d.ts +4 -2
- package/smartMapping/symbology/type.d.ts +5 -2
- package/support/LayersMixin.d.ts +1 -1
- package/support/TablesMixin.d.ts +1 -1
- package/support/featureFlags.js +1 -1
- package/support/popupUtils.d.ts +4 -2
- package/support/revision.js +1 -1
- package/support/timeUtils.d.ts +3 -2
- package/symbols/support/cimConversionUtils.d.ts +1 -2
- package/symbols/support/cimSymbolUtils.d.ts +6 -2
- package/symbols/support/jsonUtils.d.ts +1 -2
- package/symbols/support/symbolUtils.d.ts +7 -2
- package/symbols.d.ts +29 -2
- package/tables/elements.d.ts +5 -2
- package/unionTypes.d.ts +12 -2
- package/versionManagement/utils.d.ts +2 -2
- package/versionManagement/versionAdapters/utils.d.ts +2 -2
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPointShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPolygonShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BitmapShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/HeatmapResolveShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OverlayShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TestShader.js +1 -1
- package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
- package/views/2d/engine/webgl/util/Matcher.js +1 -1
- package/views/2d/engine/webgl/util/createMatcher.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/ProcessorTileMessageQueue.js +1 -1
- package/views/2d/layers/features/aggregation/AAggregateSpatialIndex.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/AAggregateStrategy.js +1 -1
- package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/StorageSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/SubtypeProcessorSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureFilterEvaluator.js +5 -0
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/2d/layers/features/support/whereUtils.js +1 -1
- package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
- package/views/2d/tiling/TileQueue.js +1 -1
- package/views/3d/environment/ChapmanApproximation.glsl.js +3 -3
- package/views/3d/environment/ChapmanAtmosphere.glsl.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/ChapmanRaymarching.glsl.js +4 -4
- package/views/3d/environment/Clouds.glsl.js +1 -1
- package/views/3d/environment/CloudsComposition.glsl.js +1 -1
- package/views/3d/environment/CloudsComposition.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.glsl.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/LocalAtmosphere.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/NoiseTextureAtlas.glsl.js +1 -1
- package/views/3d/environment/Precipitation.glsl.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/environment/PrecipitationTechnique.js +1 -1
- package/views/3d/environment/SimpleAtmosphere.glsl.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/Tile.js +1 -1
- package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureData/FeatureDataStore.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
- package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/support/PBFDecoder.js +1 -1
- package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +10 -10
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/DecodeSymbolColor.glsl.js +2 -2
- package/views/3d/webgl-engine/collections/Component/SourceGeometry.js +1 -1
- package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/HighlightCellGridScreenSpacePass.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/HighlightReadBitmap.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/ScreenSizeScaling.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -9
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTextureCoordinates.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/AlignPixel.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDVisibility.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/raster/Colormap.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/raster/Common.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/raster/Projection.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/AnalyticalSkyModel.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeMaterialColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/FoamRendering.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MultipassGeometryTest.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Normals.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +7 -7
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/TerrainDepthTest.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/BackgroundGrid.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CameraSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/util/ColorConversion.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DoublePrecision.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/IsNaN.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/RgbaFloat16Encoding.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/RgbaFloatEncoding.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/TextureAtlasLookup.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/TextureOnly.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/BooleanBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/BooleanPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float2BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float2PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Float4sPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/FloatsPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Integer2BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Integer2PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/IntegerBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/IntegerDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/IntegerPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix3DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix3PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4PassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Texture2DDrawUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/TextureCubeBindUniform.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/glsl.js +5 -0
- package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/OpaqueEnvironment.js +1 -1
- package/views/3d/webgl-engine/effects/TransparentEnvironment.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomDepthAdjust.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +5 -0
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +5 -0
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/haze/HazeCompositing.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightPassParameters.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAAPassParameters.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAOParameters.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
- package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/Program.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureCompressionWorker.js +1 -1
- package/views/3d/webgl-engine/lib/TextureCompressionWorkerHandle.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/AtmosphereCompositing.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/BlendWeights.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Blur.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/CheckerBoard.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Compositing.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/EdgeDetect.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/FocusAreaMask.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDCompositing.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HeatmapDensity.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightToSingle.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/LaserlinePath.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Laserlines.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Magnifier.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +7 -7
- package/views/3d/webgl-engine/shaders/OverlayCompositing.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SSAO.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ScreenSpacePassAtmosphere.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SingleHighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SingleHighlightBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SlicePlaneMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/SphereIntersect.glsl.js +2 -2
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ToneMapping.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +2 -2
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/DiscardNonSilhouetteEdges.glsl.js +4 -4
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/DistanceFalloff.glsl.js +2 -2
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeShader.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineAmplitude.glsl.js +3 -3
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineOffset.glsl.js +7 -7
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/UnpackAttributes.glsl.js +7 -7
- package/views/3d/webgl.d.ts +3 -2
- package/views/BreakpointsOwner.d.ts +1 -1
- package/views/DOMContainer.d.ts +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/PopupView.d.ts +1 -1
- package/views/View.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/support/WhereClauseVisitor.js +5 -0
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/{QueueProcessor.js → ScheduledQueueProcessor.js} +1 -1
- package/views/support/colorUtils.d.ts +2 -2
- package/views/webgl/NoParameters.js +5 -0
- package/views/webgl/ShaderBuilder.js +5 -0
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/Uniform.js +5 -0
- package/views/webgl/testAppleAmdDrawArrays.js +1 -1
- package/widgets/Attachments/AttachmentsViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/profileUtils.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationSettings.js +5 -0
- package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/LinkChartLayoutSwitcher/LinkChartLayoutSwitcherViewModel.js +5 -0
- package/widgets/Print.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/smartMapping/support/utils.d.ts +3 -2
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
- package/widgets/support/widget.d.ts +8 -2
- package/assets/esri/core/workers/chunks/02be905f7e9185de78c3.js +0 -1
- package/assets/esri/core/workers/chunks/0b66fee87863e5775a6a.js +0 -1
- package/assets/esri/core/workers/chunks/1557446aa4525705a5b2.js +0 -1
- package/assets/esri/core/workers/chunks/1a8aaa92ccb90f646a8b.js +0 -1
- package/assets/esri/core/workers/chunks/1dc6b5b177022b80c473.js +0 -1
- package/assets/esri/core/workers/chunks/2118e9ffb24178ed7f59.js +0 -1
- package/assets/esri/core/workers/chunks/25a6641938a9ccab39b7.js +0 -1
- package/assets/esri/core/workers/chunks/2840705ae7fa909ab4ed.js +0 -1
- package/assets/esri/core/workers/chunks/2a4c6c2e9ba103720e22.js +0 -314
- package/assets/esri/core/workers/chunks/2e4f861c78ef820c0a3e.js +0 -1
- package/assets/esri/core/workers/chunks/349f31a1fb489fbfe60d.js +0 -1
- package/assets/esri/core/workers/chunks/34b31091e172e910d750.js +0 -1
- package/assets/esri/core/workers/chunks/371c2fd9d767612bbeb2.js +0 -1
- package/assets/esri/core/workers/chunks/37658a4e83a5b18acd37.js +0 -1
- package/assets/esri/core/workers/chunks/39f3e202d95725f405ec.js +0 -1
- package/assets/esri/core/workers/chunks/3cb56f509d8f7f340c45.js +0 -1
- package/assets/esri/core/workers/chunks/4086698137db0795187f.js +0 -1
- package/assets/esri/core/workers/chunks/454034bad60414a9ab7f.js +0 -1
- package/assets/esri/core/workers/chunks/483787099d2ba8b8022d.js +0 -1
- package/assets/esri/core/workers/chunks/4b38c008872bb9e10278.js +0 -1
- package/assets/esri/core/workers/chunks/4cccca778b060d8dcd06.js +0 -1
- package/assets/esri/core/workers/chunks/4e5cf2d489db2a57d3bd.js +0 -1
- package/assets/esri/core/workers/chunks/4eda602a909a4773cb27.js +0 -1
- package/assets/esri/core/workers/chunks/5595f19c1f332f504a81.js +0 -1
- package/assets/esri/core/workers/chunks/55da04abc8e1ea93caa9.js +0 -1
- package/assets/esri/core/workers/chunks/561fc48b06a43abe1cd0.js +0 -1
- package/assets/esri/core/workers/chunks/576b7961fe7771dacfd9.js +0 -1
- package/assets/esri/core/workers/chunks/5bb175106aee21025bc2.js +0 -1
- package/assets/esri/core/workers/chunks/5c57aa9fdc4e1bab61ac.js +0 -1
- package/assets/esri/core/workers/chunks/602c67fe1061ec5a3fa5.js +0 -1
- package/assets/esri/core/workers/chunks/61f985a9a393803e5350.js +0 -1
- package/assets/esri/core/workers/chunks/644e83f48752a34f0d1a.js +0 -1
- package/assets/esri/core/workers/chunks/64f1355f7f51ecb3af95.js +0 -1
- package/assets/esri/core/workers/chunks/68f5b077fc1f6f7636dd.js +0 -1
- package/assets/esri/core/workers/chunks/7388b57de8926acd1fc2.js +0 -1
- package/assets/esri/core/workers/chunks/76b8aa593a5279569267.js +0 -1
- package/assets/esri/core/workers/chunks/7705ca2cc8ac3307d4cd.js +0 -1
- package/assets/esri/core/workers/chunks/7719fe672ea74cdc87be.js +0 -1
- package/assets/esri/core/workers/chunks/7ae1f26ded268099f429.js +0 -1
- package/assets/esri/core/workers/chunks/7c95721c077c70f31b53.js +0 -1
- package/assets/esri/core/workers/chunks/82a69eba9bacca8437bd.js +0 -1
- package/assets/esri/core/workers/chunks/8a13cd313d309281dbb9.js +0 -1
- package/assets/esri/core/workers/chunks/933089d069853f6e509a.js +0 -1
- package/assets/esri/core/workers/chunks/9848e9b9cc62328bfeb4.js +0 -1
- package/assets/esri/core/workers/chunks/9a30ad773c22bde61c64.js +0 -1
- package/assets/esri/core/workers/chunks/9bcead430045cbd9941c.js +0 -1
- package/assets/esri/core/workers/chunks/9bd22cdf6eb158555906.js +0 -1
- package/assets/esri/core/workers/chunks/a418af538ee98de7822a.js +0 -1
- package/assets/esri/core/workers/chunks/b1ce435e3850255e0b24.js +0 -1
- package/assets/esri/core/workers/chunks/b31096f20b9ed1446c3a.js +0 -1
- package/assets/esri/core/workers/chunks/b5d4255db21dfd3b3b13.js +0 -2
- package/assets/esri/core/workers/chunks/b5ee6c203f536bdb6708.js +0 -1
- package/assets/esri/core/workers/chunks/b882f921387e21fb263d.js +0 -1
- package/assets/esri/core/workers/chunks/bf9144a5d1fdebec6c4d.js +0 -1
- package/assets/esri/core/workers/chunks/c12bdf6fd7f631e3f79e.js +0 -971
- package/assets/esri/core/workers/chunks/c14afb5a090c58e66235.js +0 -1
- package/assets/esri/core/workers/chunks/c58f559eb68035ebe3da.js +0 -1
- package/assets/esri/core/workers/chunks/c62614bf6ba530924ca1.js +0 -1
- package/assets/esri/core/workers/chunks/c67322bb54dcf699fe23.js +0 -1
- package/assets/esri/core/workers/chunks/d0672714fffe04d5632a.js +0 -51
- package/assets/esri/core/workers/chunks/d5ca87a4ecf096430a21.js +0 -1
- package/assets/esri/core/workers/chunks/d9c34e07627d93d4670b.js +0 -1
- package/assets/esri/core/workers/chunks/e21259a75af746895d6c.js +0 -1
- package/assets/esri/core/workers/chunks/e2c49c1dc02249cf6fd2.js +0 -1
- package/assets/esri/core/workers/chunks/e36a4a049ea8b5589d28.js +0 -1
- package/assets/esri/core/workers/chunks/f43277fdbdbb0f49fe52.js +0 -1
- package/assets/esri/core/workers/chunks/f73bbf3a08adaa37581d.js +0 -1
- package/assets/esri/core/workers/chunks/f9656b0d3c1df8ad19af.js +0 -1
- package/chunks/Bufferer-BhfWVXPl.js +0 -5
- package/chunks/Clipper-a9xfvRaw.js +0 -5
- package/chunks/CrackAndCluster-CHWFqqYQ.js +0 -5
- package/chunks/GeodeticDistanceCalculator-Cnd3ZMKD.js +0 -5
- package/chunks/Intersector-K1VmdfQW.js +0 -5
- package/chunks/OperatorDifference.js +0 -5
- package/chunks/OperatorIntersection.js +0 -5
- package/chunks/OperatorSimplify.js +0 -5
- package/chunks/OperatorUnion.js +0 -5
- package/layers/support/TrackLabelClass.js +0 -5
- package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +0 -5
- package/views/2d/layers/features/support/FeatureFilter.js +0 -5
- package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +0 -5
- package/views/3d/webgl-engine/core/shaderModules/Uniform.js +0 -5
- package/views/3d/webgl-engine/core/shaderModules/interfaces.js +0 -5
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNode.js +0 -5
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNodeColorEffects.js +0 -5
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNodeGeometryMasking.js +0 -5
- /package/chunks/{GeometryCleaner-DVgW95-D.js → GeometryCleaner-BEJM7I4l.js} +0 -0
- /package/views/{3d/webgl-engine/core/shaderTechnique → webgl}/BindType.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[2189],{54573:(t,e,s)=>{s.d(e,{a:()=>m,b:()=>l,c:()=>h});var i=s(79187),n=s(55537),r=s(35368),o=s(95213),a=s(83661);function h(t,e,s,i,n){return m(t,e,null,s,i,n)}function m(t,e,s,r,a,m){const l=t.getGeometryType();if(l===n.G.enumPoint){const s=t.getXY();return e.contains(s)?t:t.createInstance()}if(l===n.G.enumEnvelope){const s=i.J.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 c=e.clone();{const e=new i.J;if(t.queryLooseEnvelope(e),c.containsEnvelope(e))return t;if(!c.isIntersecting(e))return t.createInstance();0===a&&(e.intersect(c),e.inflate(Math.max(.1*e.maxDimension(),1)),e.intersect(c),c.assign(e))}let g=r;if((null!==s||Number.isNaN(g))&&(g=(0,o.a)(s,c,!1).total()),l===n.G.enumGeometryCollection){const e=t,s=t.createInstance();for(let t=0,i=e.getGeometryCount();t<i;t++){const i=e.getGeometry(t);if(i.isEmpty())continue;const n=h(i,c,g,a,m);n.isEmpty()||(n===i?s.addGeometry(n.clone()):s.addGeometry(n))}return s}(0,n.i)(l)||(0,n.t)("Clip: geometry not supported");const _=t.getImpl().getAccelerators();if(null!==_){const t=_.getRasterizedGeometry();(0,n.g)(null===t)}switch(l){case n.G.enumMultiPoint:{const e=t;let s;const i=e.getPointCount(),r=e.getImpl().getAttributeStreamRef(0);let o=0;for(let t=0;t<i;t++){const i=r.readPoint2D(2*t);c.contains(i)||(0===o&&(s=e.createInstance()),o<t&&s.addPoints(e,o,t),o=t+1)}return o>0&&s.addPoints(e,o,i),0===o?e:((0,n.g)(null!==s),s)}case n.G.enumPolygon:case n.G.enumPolyline:return d=t,p=g,f=a,new u(c,m).clipMultiPath2(d,p,f);default:(0,n.c)("")}var d,p,f}function l(t,e,s,n,r,o){const a=new u(e,o),h=new i.J;return t.queryLooseEnvelope(h),e.containsEnvelope(h)?t:e.isIntersecting(h)?a.clipPolesOut(t,r):t.createInstance()}class u{constructor(t,e){this.m_shape=new r.E,this.m_geometry=r.n,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new i.J(t),this.m_progressTracker=e}progress_(){}clipMultiPath2(t,e,s){return t.getGeometryType()===n.G.enumPolygon?this.clipPolygonOrProjectedPolyline2(t,s):this.clipPolyline(t,e)}clipPolygonOrProjectedPolyline2(t,e){const s=t.getGeometryType()===n.G.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return t.createInstance();const o=i.J.constructEmpty();t.queryLooseEnvelope(o),this.m_geometry=s?this.m_shape.addGeometry(t):this.m_shape.addGeometry(t,this.m_extent);const h=i.J.constructEmpty(),m=i.J.constructEmpty(),l=new a.P,c=new a.P,g=new Array(9),_=new Array(9),d=(0,a.m)(a.P,9);let p=null;const f=new r.L,x=[];let P=!1;for(let t=0;!P&&t<4;t++){let e=!1;const i=!!(1&t);let a=0;switch(t){case 0:a=this.m_extent.xmin,e=o.xmin<=a&&o.xmax>=a;break;case 1:a=this.m_extent.ymin,e=o.ymin<=a&&o.ymax>=a;break;case 2:a=this.m_extent.xmax,e=o.xmin<=a&&o.xmax>=a;break;case 3:a=this.m_extent.ymax,e=o.ymin<=a&&o.ymax>=a}if(e){P=!0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==r.n;){let o=!0,y=-1,E=-1;const C=this.m_shape.getFirstVertex(e);let S=C;do{this.progress_(),p=this.m_shape.getSegment(S);let e=p;if(null===e){const t=this.m_shape.getNextVertex(S);if(t===r.n){(0,n.g)(s),0===y&&x.push(S);break}this.m_shape.queryXY(S,l),f.setStartXY(l),this.m_shape.queryXY(t,c),f.setEndXY(c),e=f}e.queryLooseEnvelope(h);let C=u.checkSegmentIntersection(h,t,a);e.isCurve()&&0===C&&e.isCurve()&&(f.setStartXY(e.getStartXY()),f.setEndXY(e.getEndXY()),this.m_shape.replaceCurveWithLine(S),e=f,f.queryEnvelope(h),C=u.checkSegmentIntersection(h,t,a));let v=0,b=r.n;if(-1===C){const s=e.intersectionWithAxis2D(i,a,g,_);if(s>0){let t=null;if(e.isCurve()){t=d,(0,n.g)(s<=9);for(let t=0;t<s;t++)i?d[t].setCoords(g[t],a):d[t].setCoords(a,g[t]);v=this.m_shape.splitSegmentAxisAware(S,_,s,t,i?1:0)}else v=this.m_shape.splitSegmentAxisAware(S,_,s,null,-1)}else v=0;v+=1;let r=S,h=this.m_shape.getNextVertex(r);e=null;for(let e=0;e<v;e++){this.m_shape.queryXY(r,l),this.m_shape.queryXY(h,c),p=this.m_shape.getSegment(r);let e=p;null===e&&(f.setStartXY(l),f.setEndXY(c),e=f),e.queryEnvelope(m);let s=u.checkSegmentIntersection(m,t,a);e.isCurve()&&0===s&&(this.m_shape.replaceCurveWithLine(r),f.setStartXY(l),f.setEndXY(c),e=f,e.queryEnvelope(m),s=u.checkSegmentIntersection(m,t,a)),-1===s&&(i?Math.abs(l.y-a)<Math.abs(c.y-a)?(l.y=a,this.m_shape.setXY(r,l)):(c.y=a,this.m_shape.setXY(h,c)):Math.abs(l.x-a)<Math.abs(c.x-a)?(l.x=a,this.m_shape.setXY(r,l)):(c.x=a,this.m_shape.setXY(h,c)),p=this.m_shape.getSegment(r),e=p,null===e&&(f.setStartXY(l),f.setEndXY(c),e=f),e.queryEnvelope(m),s=u.checkSegmentIntersection(m,t,a),-1===s&&(s=u.checkSegmentIntersectionLoose(m,t,a)));const n=y;y=s,-1===E&&(E=y),0===n&&1===y||1===n&&0===y||0===n&&0===y&&x.push(r),1===y&&(P=!1,o=!1),r=h,b=r,h=this.m_shape.getNextVertex(h)}}if(0===v){const t=y;y=C,-1===E&&(E=y),0===t&&y>=1||t>=1&&0===y||0===t&&0===y&&x.push(S),1===y&&(P=!1,o=!1),b=this.m_shape.getNextVertex(S)}if(S=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,a):this.m_shape.removeVertex(e,!1)}x[1]=x.at(-1),x.length=2}}while(S!==C);if(!o){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,a):this.m_shape.removeVertex(e,!1)}}x.length=0,e=o||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()===n.G.enumPolygon&&y.setFillRule(t.getFillRule()),y}clipPolyline(t,e){const s=i.J.constructEmpty(),n=i.J.constructEmpty(),o=new Array(9),h=new Array(9),m=new r.S;let l=t;const c=i.J.constructEmpty();t.queryLooseEnvelope(c);for(let e=0;e<4;e++){let i=!1;const r=!!(1&e);let g=0;switch(e){case 0:g=this.m_extent.xmin,i=c.xmin<=g&&c.xmax>=g;break;case 1:g=this.m_extent.ymin,i=c.ymin<=g&&c.ymax>=g;break;case 2:g=this.m_extent.xmax,i=c.xmin<=g&&c.xmax>=g;break;case 3:g=this.m_extent.ymax,i=c.ymin<=g&&c.ymax>=g}if(!i)continue;const _=l;l=t.createInstance();const d=_.getImpl().querySegmentIterator();d.resetToFirstPath();const p=new a.P,f=new a.P;for(;d.nextPath();){let t=-1,i=!0;for(;d.hasNextSegment();){this.progress_();const a=d.nextSegment(),c=a.isDegenerate(0);a.queryLooseEnvelope(s);const _=u.checkSegmentIntersection(s,e,g);if(-1===_){const s=a.intersectionWithAxis2D(r,g,o,h);let _=0;p.assign(a.getStartXY());for(let d=0;d<=s;d++){const x=d<s?h[d]:1;if(_===x)continue;a.queryCut(_,x,m,!1);const P=m.get();let y=!1;if(P.getStartXY().equals(p)||(P.setStartXY(p),y=!0),d<s&&(r?(f.x=o[d],f.y=g):(f.x=g,f.y=o[d]),P.getEndXY().equals(f)||(P.setEndXY(f),y=!0)),y&&P.normalizeAfterEndpointChange(),!c&&P.isDegenerate(0))continue;P.queryEnvelope(n);let E=u.checkSegmentIntersection(n,e,g);if(-1===E){const t=P.getStartXY(),s=P.getEndXY();y=!1,r?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=u.checkSegmentIntersection(n,e,g),-1===E&&(E=u.checkSegmentIntersectionLoose(n,e,g))}p.assign(P.getEndXY()),_=x,t=E,t>=1?(l.addSegment(P,i),i=!1):i=!0}}else t=_,t>=1?(l.addSegment(a,i),i=!1):i=!0}}}return l}static checkSegmentIntersection(t,e,s){switch(e){case 0:return t.xmin<s&&t.xmax<=s?0:t.xmin>=s?t.xmax===s?2:1:-1;case 1:return t.ymin<s&&t.ymax<=s?0:t.ymin>=s?t.ymax===s?2:1:-1;case 2:return t.xmin>=s&&t.xmax>s?0:t.xmax<=s?t.xmin===s?2:1:-1;case 3:return t.ymin>=s&&t.ymax>s?0:t.ymax<=s?t.ymin===s?2:1:-1}return(0,n.c)(""),0}static checkSegmentIntersectionLoose(t,e,s){switch(e){case 0:{const e=Math.abs(t.xmin-s),i=Math.abs(t.xmax-s);return t.xmin<s?e>i?0:1:((0,n.c)(""),1)}case 1:{const e=Math.abs(t.ymin-s),i=Math.abs(t.ymax-s);return t.ymin<s?e>i?0:1:((0,n.c)(""),1)}case 2:{const e=Math.abs(t.xmin-s),i=Math.abs(t.xmax-s);return t.xmax>s?e<i?0:1:((0,n.c)(""),1)}case 3:{const e=Math.abs(t.ymin-s),i=Math.abs(t.ymax-s);return t.ymax>s?e<i?0:1:((0,n.c)(""),1)}}return(0,n.c)(""),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 a.P;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==r.n;e=this.m_shape.getNextPath(e)){let s=this.m_shape.getFirstVertex(e);for(let i=0,n=this.m_shape.getPathSize(e);i<n;i++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,t),this.m_extent.xmin!==t.x&&this.m_extent.xmax!==t.x&&this.m_extent.ymin!==t.y&&this.m_extent.ymax!==t.y||(this.m_shape.setUserIndex(s,this.m_verticesOnExtentIndex,this.m_verticesOnExtent.length),this.m_verticesOnExtent.push(s))}this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmin),this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmax),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymin),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymax),this.fixPaths()}densifyAlongClipExtent(t){const e=new a.P(0,0),s=new a.P(0,0),i=new Array(2048);for(let o=this.m_shape.getFirstPath(this.m_geometry);o!==r.n;o=this.m_shape.getNextPath(o)){const r=this.m_shape.getFirstVertex(o);let h=r;do{const r=this.m_shape.getNextVertex(h);this.m_shape.queryXY(h,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){h=r;continue}if(this.isCurve(h)){h=r;continue}const m=e.clone(),l=new a.P(0,0);if(o){const i=e.y-this.m_extent.ymin;l.y=(0,a.d)(s.y-e.y),m.y=t*(0,a.e)(Math.floor(Math.abs(i)/t),i)+this.m_extent.ymin,l.y<0&&(m.y+=t)}else{const i=e.x-this.m_extent.xmin;l.x=(0,a.d)(s.x-e.x),m.x=t*(0,a.e)(Math.floor(Math.abs(i)/t),i)+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,n.c)(""),c>0){const s=Math.trunc(c/t)+2;i.length<s&&(i.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,n.g)(r<=i.length),i[r]=h,r++)}0!==r&&this.m_shape.splitSegment(h,i,r)}h=r}while(h!==r)}}splitSegments(t,e){let s=-1;const i=new a.P,n=[];for(let o=this.m_shape.getFirstPath(this.m_geometry);o!==r.n;o=this.m_shape.getNextPath(o)){let a=this.m_shape.getFirstVertex(o),h=r.n;for(let r=0,m=this.m_shape.getPathSize(o);r<m;r++,a=h)if(this.progress_(),h=this.m_shape.getNextVertex(a),this.m_shape.queryXY(a,i),(t?i.y===e:i.x===e)&&(this.m_shape.queryXY(h,i),t?i.y===e:i.x===e)){if(this.isCurve(a))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(a,s)&&(n.push(a),this.m_shape.setUserIndex(a,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(n.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),n.length<3)return;n.sort(((t,e)=>this.compareVertices(t,e)));const o=new a.P,h=new a.P,m=new a.P;h.setNAN();let l=-1,u=[],c=[];const g=this.m_shape.createUserIndex(),_=this.m_shape.createUserIndex();for(let s=0,r=n.length;s<r;s++){const r=n[s];if(this.m_shape.queryXY(r,i),!i.isEqualPoint2D(h)){if(-1===l){l=s,h.setCoordsPoint2D(i);continue}for(let i=l;i<s;i++){const s=n[i],r=this.m_shape.getNextVertex(s),a=this.m_shape.getPrevVertex(s);let m=!1;this.m_shape.queryXY(r,o),h.compare(o)<0&&(t?o.y===e:o.x===e)&&(this.isCurve(s)||(u.push(s),m=!0,this.m_shape.setUserIndex(s,_,1))),this.m_shape.queryXY(a,o),h.compare(o)<0&&(t?o.y===e:o.x===e)&&(this.isCurve(a)||(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),n=this.m_shape.getUserIndex(e,_);if(1===s){const t=this.m_shape.getPrevVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(i)){const n=a.P.distance(h,m);s=a.P.distance(m,i)/n,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,i),c.push(r),this.m_shape.setUserIndex(r,g,1),this.m_shape.setUserIndex(r,_,-1)}}if(1===n){const t=this.m_shape.getNextVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(i)){const t=a.P.distance(h,m);s=a.P.distance(h,i)/t,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const n=this.m_shape.getNextVertex(e);this.m_shape.setXY(n,i),c.push(n),this.m_shape.setUserIndex(n,g,-1),this.m_shape.setUserIndex(n,_,1)}}}const r=u;u=c,c=r,c.length=0,l=s,h.setCoordsPoint2D(i)}}this.m_shape.removeUserIndex(g),this.m_shape.removeUserIndex(_)}resolveOverlaps(t,e){const s=new a.P,i=[];let o=-1;for(let n=0,a=this.m_verticesOnExtent.length;n<a;n++){this.progress_();const a=this.m_verticesOnExtent[n];if(a===r.n)continue;const h=this.m_shape.getNextVertex(a);if(this.m_shape.queryXY(a,s),(t?s.y===e:s.x===e)&&(this.m_shape.queryXY(h,s),t?s.y===e:s.x===e)){if(this.isCurve(a))continue;-1===o&&(o=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(a,o)&&(i.push(a),this.m_shape.setUserIndex(a,o,-2)),-2!==this.m_shape.getUserIndex(h,o)&&(i.push(h),this.m_shape.setUserIndex(h,o,-2))}}if(0===i.length)return void(-1!==o&&this.m_shape.removeUserIndex(o));(0,n.g)(-1!==o),i.sort(((t,e)=>this.compareVertices(t,e)));for(let t=0,e=i.length;t<e;t++){const e=i[t];this.m_shape.setUserIndex(e,o,t)}const h=new a.P,m=new a.P;m.setNAN();let l=-1;for(let n=0,a=i.length;n<a;n++){this.progress_();const a=i[n];if(a!==r.n&&(this.m_shape.queryXY(a,s),!s.isEqualPoint2D(m))){if(-1!==l)for(;;){let s=!1;const a=n;for(let u=l;u<a;u++){const a=i[u];if(a===r.n)continue;let l=r.n;const c=this.m_shape.getNextVertex(a);this.m_shape.queryXY(c,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(a)||(l=c));let g=r.n;const _=this.m_shape.getPrevVertex(a);if(this.m_shape.queryXY(_,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(_)||(g=_)),l===r.n||g===r.n){if(l!==r.n||g!==r.n){for(let c=u+1;c<n;c++){const n=i[c];if(n===r.n)continue;const u=this.m_shape.getNextVertex(n);let _=r.n;this.m_shape.queryXY(u,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(n)||(_=u));const d=this.m_shape.getPrevVertex(n);let p=r.n;if(this.m_shape.queryXY(d,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(d)||(p=d)),_!==r.n&&p!==r.n){this.beforeRemoveVertex(n,i,o),this.m_shape.removeVertex(n,!1),this.beforeRemoveVertex(_,i,o),this.m_shape.removeVertex(_,!1),s=!0;break}if(l!==r.n&&p!==r.n){this.removeOverlap(i,a,l,n,p,o),s=!0;break}if(g!==r.n&&_!==r.n){this.removeOverlap(i,n,_,a,g,o),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(a,i,o),this.m_shape.removeVertex(a,!1),this.beforeRemoveVertex(l,i,o),this.m_shape.removeVertex(l,!1),s=!0}if(!s)break}l=n,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(o)}beforeRemoveVertex(t,e,s){let i=this.m_shape.getUserIndex(t,s);(0,n.g)(i>=0),e[i]=r.n,i=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),(0,n.g)(i>=0),this.m_verticesOnExtent[i]=r.n;const o=this.m_shape.getPathFromVertex(t);o!==r.n&&this.m_shape.getFirstVertex(o)===t&&(this.m_shape.setFirstVertex(o,r.n),this.m_shape.setLastVertex(o,r.n))}removeOverlap(t,e,s,i,n,r){this.m_shape.setNextVertex(e,i),this.m_shape.setPrevVertex(i,e),this.m_shape.setPrevVertex(s,n),this.m_shape.setNextVertex(n,s),this.beforeRemoveVertex(i,t,r),this.m_shape.removeVertexInternal(i,!1),this.beforeRemoveVertex(n,t,r),this.m_shape.removeVertexInternal(n,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(t){for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==r.n;e=this.m_shape.getNextPath(e)){const s=this.m_shape.getPathSize(e);if(s<3)continue;let i=this.m_shape.getFirstVertex(e);const n=new a.P;this.m_shape.queryXY(i,n);let r=n.y===t&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const o=new a.P;this.m_shape.queryXY(i,o);let h=o.y===t&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const m=new a.P;for(let e=0,a=s-2;e<a;e++,i=this.m_shape.getNextVertex(i)){this.progress_(),this.m_shape.queryXY(i,m);const e=m.y===t;h&&r&&e&&(o.x-n.x)*(m.x-o.x)<=0?(this.m_shape.removeVertex(this.m_shape.getPrevVertex(i),!1),o.setCoordsPoint2D(m),h=e&&!this.isCurve(i)):(n.setCoordsPoint2D(o),r=h,o.setCoordsPoint2D(m),h=e&&!this.isCurve(i))}}}fixPaths(){for(let t=0,e=this.m_verticesOnExtent.length;t<e;t++){const e=this.m_verticesOnExtent[t];e!==r.n&&this.m_shape.setPathToVertex(e,r.n)}const t=this.m_shape.hasCurves();let e=0,s=0;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==r.n;){const i=this.m_shape.getFirstVertex(t);if(i===r.n||t!==this.m_shape.getPathFromVertex(i)){const e=t;t=this.m_shape.getNextPath(t),this.m_shape.setFirstVertex(e,r.n),this.m_shape.removePathOnly(e);continue}let n=i,o=0;do{this.m_shape.setPathToVertex(n,t),o++,n=this.m_shape.getNextVertex(n)}while(n!==i);this.m_shape.setRingAreaValid(t,!1),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(i)),this.m_shape.setPathSize(t,o),s+=o,e++,t=this.m_shape.getNextPath(t)}for(let i=0,o=this.m_verticesOnExtent.length;i<o;i++){let o=this.m_verticesOnExtent[i];if(o===r.n)continue;let a=this.m_shape.getPathFromVertex(o);if(a!==r.n)continue;a=this.m_shape.insertPath(this.m_geometry,r.n);let h=!1,m=0;const l=o;do{this.m_shape.setPathToVertex(o,a),m++,t&&m<=2&&(h||=this.isCurve(o)),o=this.m_shape.getNextVertex(o)}while(o!==l);if(h?0===m:m<=2){let t=this.m_shape.getUserIndex(l,this.m_verticesOnExtentIndex);(0,n.g)(t>=0),this.m_verticesOnExtent[t]=r.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]=r.n),this.m_shape.removeVertex(e,!1));const s=a;a=this.m_shape.getNextPath(a),this.m_shape.setFirstVertex(s,r.n),this.m_shape.removePathOnly(s)}else this.m_shape.setClosedPath(a,!0),this.m_shape.setPathSize(a,m),this.m_shape.setFirstVertex(a,l),this.m_shape.setLastVertex(a,this.m_shape.getPrevVertex(l)),this.m_shape.setRingAreaValid(a,!1),s+=m,e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let i=0;for(let t=this.m_shape.getFirstGeometry();t!==r.n;t=this.m_shape.getNextGeometry(t))i+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(i)}dbgCheckPathFirst(){}isCurve(t){return null!==this.m_shape.getSegment(t)}compareVertices(t,e){const s=new a.P;this.m_shape.queryXY(t,s);const i=new a.P;return this.m_shape.queryXY(e,i),s.compare(i)}clipPolesOut(t,e){return this.clipPolygonOrProjectedPolyline2(t,e)}}},86117:(t,e,s)=>{s.d(e,{C:()=>st,N:()=>l,P:()=>L,a:()=>S,b:()=>Z,c:()=>at,d:()=>$,e:()=>nt,f:()=>et,g:()=>v,h:()=>K,i:()=>d,j:()=>rt,k:()=>ot,l:()=>f,m:()=>_,n:()=>H,p:()=>Q,r:()=>g,s:()=>tt,t:()=>p,u:()=>z,v:()=>c});var i=s(95213),n=s(55537),r=s(83661),o=s(35368),a=s(79187),h=s(90237),m=s(11878);class l{assign(t){this.m_reason=t.m_reason,this.m_vertexIndex1=t.m_vertexIndex1,this.m_vertexIndex2=t.m_vertexIndex2}constructor(t,e,s){void 0!==t?(this.m_reason=t,this.m_vertexIndex1=e,this.m_vertexIndex2=s):(this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-2)}clear(){this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-1}}class u{constructor(t,e){this.m_monotoneParts=(0,r.m)(o.S,16),this.m_xOrds=(0,r.f)(16,Number.NaN),this.m_inputPoint=r.P.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=t,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bTestBorder=!!e,this.m_bBreak=!1}_DoOne(t){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(t.getStartXY())||this.m_inputPoint.equals(t.getEndXY())))return void(this.m_bBreak=!0);if(t.getStartY()===this.m_inputPoint.y&&t.getStartY()===t.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const e=Math.min(t.getStartX(),t.getEndX()),s=Math.max(t.getStartX(),t.getEndX());this.m_inputPoint.x>e&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let e=!1;const s=Math.max(t.getStartX(),t.getEndX());if(this.m_inputPoint.x>s)e=!0;else if(this.m_inputPoint.x>=Math.min(t.getStartX(),t.getEndX())){const i=t.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);e=!Number.isNaN(i)&&i<=this.m_inputPoint.x}if(e){if(this.m_inputPoint.y===t.getStartY()){if(this.m_inputPoint.y<t.getEndY())return}else if(this.m_inputPoint.y===t.getEndY()&&this.m_inputPoint.y<t.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=t.getStartY()>t.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(t){const e=t.getClosestCoordinate(this.m_inputPoint,!1),s=t.getCoord2D(e);return r.P.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(t){this.m_inputPoint.setCoordsPoint2D(t),this.m_miny=t.y-this.m_tolerance,this.m_maxy=t.y+this.m_tolerance}processSegment(t){const e=t.queryInterval(0,1);if(e.vmin>this.m_maxy||e.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(t))return!0;if(e.vmin>this.m_inputPoint.y||e.vmax<this.m_inputPoint.y)return!1;let s=0;if(t.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=t.getMonotonicParts(this.m_monotoneParts,!0),(0,n.g)(this.m_monotoneParts.length>=s)),s>0)for(let t=0;t<s;t++){const e=this.m_monotoneParts[t].get(),s=r.E.construct(e.getStartY(),e.getEndY());if(!(s.vmin>this.m_inputPoint.y||s.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(t),this.m_bBreak)return!0;return!1}result(){return(0,n.g)(0),2}}function c(t,e,s){if(t.isEmpty())return 0;const i=a.J.constructEmpty();if(t.queryLooseEnvelope(i),i.inflateCoords(s,s),!i.contains(e))return 0;const r=t.getImpl().getAccelerators();if(r){r.getRasterizedGeometry()&&(0,n.g)(0);const i=r.getQuadTree();if(i)return function(t,e,s,i){const n=new a.J;t.queryLooseEnvelope(n),n.inflateCoords(i,i);const r=0===t.getFillRule(),o=new u(r,i);o.setInputPoint(s);const h=n.clone();h.xmax=s.x+i,h.ymin=s.y-i,h.ymax=s.y+i;const m=t.getImpl().querySegmentIterator(),l=e.getIterator(h,i);for(let t=l.next();-1!==t;t=l.next())if(m.resetToVertex(e.getElement(t),-1),m.hasNextSegment()){const t=m.nextSegment();if(o.processSegment(t))return-1}return o._Result()?1:0}(t,i,e,s)}return function(t,e,s){const i=0===t.getFillRule(),n=new u(i,s);n.setInputPoint(e);const r=t.getImpl().querySegmentIterator();for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(n.processSegment(t))return-1}return n._Result()?1:0}(t,e,s)}function g(t,e){const s=t.getPointCount();return!(s<16)&&2*s+Math.log(s)/Math.log(2)*1*e<1*s*e}function _(t,e,s){const i=function(t,e,s){return e.isEmpty()?0:c(t,e.getXY(),s)}(t,e,s);return i?1===i?1:2:0}function d(t,e,s){const i=c(t,e,s);return i?1===i?1:2:0}function p(t,e,s,i,r){if(t.getGeometryType()===n.G.enumPolygon)!function(t,e,s,i,n){for(let r=0;r<s;r++)n[r]=d(t,e[r],i)}(t,e,s,i,r);else if(t.getGeometryType()===n.G.enumEnvelope){const n=a.J.constructEmpty();t.queryEnvelope(n),function(t,e,s,i,n){if(t.isEmpty()){for(let t=0;t<s;t++)n[t]=0;return}const r=t.clone();r.inflateCoords(.5*-i,.5*-i);const o=t.clone();o.inflateCoords(.5*i,.5*i);for(let t=0;t<s;t++)r.contains(e[t])?n[t]=1:o.contains(e[t])?n[t]=2:n[t]=0}(n,e,s,i,r)}else(0,n.r)("")}function f(t,e,s,r,o){const h=t.getGeometryType();h===n.G.enumPolyline?function(t,e,s,r,o){const h=t.getImpl(),m=h.getAccelerators();let l=null;m&&(l=m.getRasterizedGeometry());let u=s;for(let t=0;t<s;t++)o[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,i.w)(h)),t){let i=null;const n=h.querySegmentIterator(),m=new a.J;for(let a=0;a<s&&u;a++)if(1===o[a]){m.setCoords(e[a]),null===i?i=t.getIterator(m,r):i.resetIterator(m,r);let s=-1;for(let h=i.next();-1!==h;h=i.next()){if(n.resetToVertex(t.getElement(h),s),s=n.getPathIndex(),n.nextSegment().isIntersectingPoint(e[a],r)){o[a]=2,u--;break}o[a]=0}}return}}const t=h.querySegmentIterator();for(;t.nextPath()&&u;)for(;t.hasNextSegment()&&u;){const i=t.nextSegment();for(let t=0;t<s&&u;t++)1===o[t]&&i.isIntersectingPoint(e[t],r)&&(o[t]=2,u--)}}for(let t=0;t<s;t++)1===o[t]&&(o[t]=0)}(t,e,s,r,o):(0,n.f)(h)?(0,n.g)(0):(0,n.r)("")}class x{freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){this.m_lists.deleteElement(t)}newList_(){return this.m_lists.newElement()}Init_(t){(0,n.g)(0)}constructor(t){this.m_listNodes=new i.S(2),this.m_listOfLists=x.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===t&&(t=!0),this.m_bAllowNavigationBetweenLists=t,this.m_lists=new i.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!==x.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!==x.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!==x.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==x.st_nullNode()&&this.m_lists.setField(s,2,e)}this.freeList_(t)}reserveLists(t){this.m_lists.setCapacity(t)}addElement(t,e){this.m_lists.getField(t,0);const s=this.m_lists.getField(t,1),i=this.newNode_();return s!==x.st_nullNode()?(this.m_listNodes.setField(s,1,i),this.m_lists.setField(t,1,i)):(this.m_lists.setField(t,0,i),this.m_lists.setField(t,1,i)),this.m_listNodes.setField(i,0,e),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}deleteElementDirect(t,e,s){e!==x.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,x.st_nullNode())),this.freeNode_(s)}deleteElementSearch(t,e){let s=-1,i=this.getFirst(t);for(;i!==e;)s=i,i=this.getNext(i);this.deleteElementDirect(t,s,e)}concatenateLists(t,e){const s=this.m_lists.getField(t,1),i=this.m_lists.getField(e,0);if(i!==x.st_nullNode()&&(s!==x.st_nullNode()?(this.m_listNodes.setField(s,1,i),this.m_lists.setField(t,1,this.m_lists.getField(e,1))):(this.m_lists.setField(t,0,i),this.m_lists.setField(t,1,this.m_lists.getField(e,1)))),this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==x.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==x.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=x.st_nullNode()}isEmpty(t){return(0,n.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}function P(t=-1){return{m_value:t,m_line:new o.L,m_segment:null,m_segmentInfo:new o._(-1),m_env:new r.E(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class y extends i.r{constructor(t,e,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new l,this.m_tempSimpleEdge1=P(),this.m_tempSimpleEdge2=P(),this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n,this.m_currentNode=-1,this.m_prevX1=Number.NaN,this.m_prevX2=Number.NaN,this.m_prevY=Number.NaN,this.m_prevX=0,this.m_sweepY=Number.NaN,this.m_sweepX=0,this.m_ptSweep=new r.P,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=t,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=e,this.m_tolerance10=10*e,this.m_bIsSimple=s;const i=Math.trunc(Math.min(3*t.getTotalPointCount()/2,67)),n=Math.min(7,i);this.m_simpleEdgesCache.length=n}tryGetCachedEdge_(t){const e=this.m_simpleEdgesCache[(t&(0,r.n)())%this.m_simpleEdgesCache.length];return e&&e.m_value===t?e:null}tryDeleteCachedEdge_(t){const e=(t&(0,r.n)())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[e];s&&s.m_value===t&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[e]=null)}tryCreateCachedEdge_(t){const e=(t&(0,r.n)())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[e];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=P(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=t,this.m_simpleEdgesCache[e]=s,s)}initSimpleEdge_(t,e){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(t,e)||t.m_bCurve||(this.m_shape.queryLineConnector(e,t.m_line,!0),t.m_segment=t.m_line,t.m_env.setCoordsNoNAN(t.m_line.getStartX(),t.m_line.getEndX()),t.m_env.vmax+=this.m_tolerance,t.m_line.orientBottomUp(),t.m_bHorizontal=t.m_line.getEndY()===t.m_line.getStartY(),t.m_bHorizontal||(t.m_dxdy=(t.m_line.getEndX()-t.m_line.getStartX())/(t.m_line.getEndY()-t.m_line.getStartY())))}initSimpleEdgeHelper_(t,e){if(t.m_segment=this.m_shape.getSegment(e),t.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(e),t.m_bCurve=null!==t.m_segment,t.m_bCurve){const e=t.m_segment.clone();return e.orientBottomUp(),t.m_segment=e,t.m_env=t.m_segment.queryInterval(0,0),t.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(t,e){const s=t.getStartXY(),i=t.getEndXY(),n=e.getStartXY(),o=e.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(n)&&this.m_sweepY===s.y){this.m_ptSweep.assign(i.compare(o)<0?i:o);const s=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-n)>this.m_tolerance)return s<n?-1:1}const a=s.compare(n)<0?n:s,h=i.compare(o)<0?i:o;let m=0,l=0;for(let s=1;s<5;s++){(0,r.D)(a,h,s/5,this.m_ptSweep);const i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),o=Math.abs(i-n);o>m&&(m=o,l=i<n?-1:1)}return 0===l?this.errorCracking():l}compareNonHorizontal_(t,e){if(t.m_line.getStartY()===e.m_line.getStartY()&&t.m_line.getStartX()===e.m_line.getStartX())return t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(t,e);if(t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(t,e);const s=this.compareNonHorizontalLowerEnd_(t,e),i=this.compareNonHorizontalUpperEnd_(t,e);return s<0&&i<0?-1:s>0&&i>0?1:this.errorCracking()}compareHorizontal1Case1_(t,e){if(t.getEndX()>e.getEndX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getEndX()-t.getStartX())<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(t,e){if(t.getStartX()<e.getStartX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getStartX()-t.getEndX())<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(t,e){const s=r.P.getNAN();s.setSub(e.getEndXY(),e.getStartXY()),s.rightPerpendicularThis(),s.normalize();const i=r.P.getNAN();i.setSub(t.getStartXY(),e.getStartXY());const n=r.P.getNAN();n.setSub(t.getEndXY(),e.getStartXY());const o=i.dotProduct(s),a=n.dotProduct(s),h=Math.abs(o),m=Math.abs(a);if(h<m){if(h<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return o<0&&a<0?-1:o>0&&a>0?1:this.errorCracking()}compareHorizontal1_(t,e){return t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.compareHorizontal1Case1_(t,e):t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()?this.compareHorizontal1Case2_(t,e):this.compareHorizontal1Case3_(t,e)}compareHorizontal2_(t,e){return t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()&&t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(t,e){let s=1;if(t.m_line.getStartY()<e.m_line.getStartY()){s=-1;const i=t;t=e,e=i}const i=t.m_line,n=e.m_line,r=i.getStartX()-n.getStartX(),o=e.m_dxdy*(i.getStartY()-n.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:n.isIntersectingPoint(i.getStartXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}compareNonHorizontalUpperEnd_(t,e){let s=1;if(e.m_line.getEndY()<t.m_line.getEndY()){s=-1;const i=t;t=e,e=i}const i=t.m_line,n=e.m_line,r=i.getEndX()-n.getStartX(),o=e.m_dxdy*(i.getEndY()-n.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:n.isIntersectingPoint(i.getEndXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new l(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const t=6;this.m_nonSimpleResult=new l(t,this.m_vertex1,this.m_vertex2)}else this.m_prev1=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n;return-1}compareSegments_(t,e,s,i){if(s.m_env.vmax<i.m_env.vmin)return-1;if(i.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!i.m_bCurve){let t=s.m_bHorizontal?1:0;return t|=i.m_bHorizontal?2:0,0===t?this.compareNonHorizontal_(s,i):1===t?this.compareHorizontal1_(s.m_line,i.m_line):2===t?-1*this.compareHorizontal1_(i.m_line,s.m_line):this.compareHorizontal2_(s.m_line,i.m_line)}if(this.m_bIntersectionDetected)return-1;const n=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let r,a;if(n&&t===this.m_prev1?r=this.m_prevX1:(r=Number.NaN,this.m_prev1=o.n),n&&e===this.m_prev2?a=this.m_prevX2:(a=Number.NaN,this.m_prev2=o.n),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(r)){this.m_prev1=t;const e=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);r=e,this.m_prevX1=e}if(Number.isNaN(a)){this.m_prev2=e;const t=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=t,this.m_prevX2=t}const h=(0,o.N)(!0,!0,s.m_segment,i.m_segment,this.m_tolerance,!0);return 0!==h?2===h?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(i.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(r-a)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,i.m_segment):r<a?-1:r>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=o.n,this.m_prev2=o.n,this.m_vertex1=o.n,this.m_vertex2=o.n}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const i=t.getElement(s),n=e;return this.m_currentNode=s,this.compareSegments(n,n,i,i)}compareSegments(t,e,s,i){let n=this.tryGetCachedEdge_(t);null===n?this.m_vertex1===e?n=this.m_tempSimpleEdge1:(this.m_vertex1=e,n=this.tryCreateCachedEdge_(t),null===n&&(n=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=t),this.initSimpleEdge_(n,e)):this.m_vertex1=e;let r=this.tryGetCachedEdge_(s);return null===r?this.m_vertex2===i?r=this.m_tempSimpleEdge2:(this.m_vertex2=i,r=this.tryCreateCachedEdge_(s),null===r&&(r=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(r,i)):this.m_vertex2=i,this.compareSegments_(e,i,n,r)}onDelete(t){this.tryDeleteCachedEdge_(t)}onSet(t){this.tryDeleteCachedEdge_(t)}onEndSearch(t){this.tryDeleteCachedEdge_(t)}onAddUniqueElementFailed(t){this.tryDeleteCachedEdge_(t)}}class E{constructor(t,e){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=r.P.getNAN(),this.m_line1=new o.L,this.m_seg1=null,this.m_env=r.E.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=t,this.m_tolerance=e}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(t){this.m_pointOfInterest.assign(t)}compare(t,e){const s=t.getElement(e);return this.compareVertex(t,e,s)}compareVertex(t,e,s){let i,n=this.m_shape.getSegment(s),h=!0;if(null==n)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),n=this.m_line1,i=this.m_line1.getStartY()===this.m_line1.getEndY();else{const t=a.J.constructEmpty();n.queryLooseEnvelope(t),t.queryIntervalX(this.m_env),i=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(i)return this.m_currentNode=e,this.m_bIntersectionDetected=!0,0;let m=0;if(h){(0,o.W)(this.m_line1);const t=this.m_line1.getStartXY(),e=new r.P;e.setSub(this.m_line1.getEndXY(),t),e.rightPerpendicularThis();const s=new r.P;s.setSub(this.m_pointOfInterest,t),m=e.dotProduct(s),m/=e.length()}else m=n.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:(n.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 C{constructor(t,e){this.m_lists=new x(!1),this.m_hash=e,this.m_hashBuckets=new Int32Array(t),this.m_hashBuckets.fill(C.st_nullNode()),this.m_bitFilter=new Int32Array(10*t+31>>5)}reserveElements(t){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,t)),this.m_lists.reserveNodes(t)}addElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const i=e%this.m_hashBuckets.length;let n=this.m_hashBuckets[i];return n===x.st_nullNode()&&(n=this.m_lists.createList(),this.m_hashBuckets[i]=n),this.m_lists.addElement(n,t)}deleteElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%this.m_hashBuckets.length,i=this.m_hashBuckets[s];i===x.st_nullNode()&&(0,n.t)("");let r=this.m_lists.getFirst(i),o=x.st_nullNode();for(;r!==x.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)===x.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=x.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 x.st_nullNode();const s=t%this.m_hashBuckets.length,i=this.m_hashBuckets[s];return i===x.st_nullNode()?x.st_nullNode():this.m_lists.getFirst(i)}getNextInBucket(t){return this.m_lists.getNext(t)}findNode(t){const e=this.m_hash.getHash(t);let s=this.getFirstInBucket(e);for(;s!==x.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 x.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===x.st_nullNode()&&(0,n.t)(""),this.m_lists.deleteElementSearch(i,t),this.m_lists.getFirst(i)===x.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=x.st_nullNode())}getElement(t){return this.m_lists.getData(t)}static st_nullNode(){return x.st_nullNode()}clear(){(0,n.g)(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function S(t,e,s,i,n){const r=new D(n);return r.m_shape=t,r.m_sqrTolerance=e*e,r.m_cellSize=2*e,r.m_invCellSize=1/r.m_cellSize,r.m_geometry=s,r.m_bTrackChanges=i,r.m_bHasSegmentParentage=t.hasSegmentParentage(),r.clusterNonReciprocal()}function v(t,e,s,i,n){const r=t-s,o=e-i;return r*r+o*o<=n}function b(t,e,s,i,n,o){const a={pt:new r.P,weight:0,rank:0,bMerged:!1},h=s+n;let m=!1,l=t.x;t.x!==e.x&&(i===o&&(l=(t.x*s+e.x*n)/h),m=!0);let u=t.y;return t.y!==e.y&&(i===o&&(u=(t.y*s+e.y*n)/h),m=!0),i!==o?i>o?(a.rank=i,a.weight=s,a.pt=t):(a.rank=o,a.weight=n,a.pt=e):(a.pt.setCoords(l,u),a.weight=h,a.rank=i),a.bMerged=m,a}function I(t,e){const s=(0,r.L)(t);return(0,r.J)(s,e)}class w{constructor(t,e,s,i,n){this.m_workPt=new r.P,this.m_shape=t,this.m_sqrTolerance=s,this.m_invCellSize=i,this.m_origin=e.clone(),this.m_hashValues=n}getHash(t){return this.m_shape.getUserIndex(t,this.m_hashValues)}calculateHashFromVertex(t){this.m_shape.queryXY(t,this.m_workPt);const e=this.m_workPt.x-this.m_origin.x,s=Math.trunc(e*this.m_invCellSize+.5),i=this.m_workPt.y-this.m_origin.y;return I(s,Math.trunc(i*this.m_invCellSize+.5))}equal(t,e){return(0,n.g)(0),!1}}class D{constructor(t){this.m_origin=r.P.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=o.n,this.m_bucketArray=new Array(4),this.m_bucketHash=new Array(4),this.m_dbgCandidateCheckCount=0,this.m_nsr=new l,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new x,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=t}progress_(){}collectClusterCandidates(t,e){const s=r.P.getNAN();this.m_shape.queryXY(t,s);const i=(s.x-this.m_origin.x)*this.m_invCellSize,n=(s.y-this.m_origin.y)*this.m_invCellSize,o=Math.trunc(i),a=Math.trunc(n);let h=0;for(let t=0;t<=1;t+=1)for(let e=0;e<=1;e+=1){const s=I(o+t,a+e),i=this.m_hashTable.getFirstInBucket(s);i!==C.st_nullNode()&&(this.m_bucketArray[h]=i,this.m_bucketHash[h]=s,h++)}for(let t=h-1;t>=1;t--){const e=this.m_bucketArray[t];for(let s=t-1;s>=0;s--)if(e===this.m_bucketArray[s]){this.m_bucketHash[s]=-1,h--,t!==h&&(this.m_bucketHash[t]=this.m_bucketHash[h],this.m_bucketArray[t]=this.m_bucketArray[h]);break}}for(let i=0;i<h;i++)this.collectNearestNeighbourCandidates(t,this.m_bucketHash[i],s,this.m_bucketArray[i],e)}collectNearestNeighbourCandidates(t,e,s,i,n){const o=r.P.getNAN();for(let r=i;r!==C.st_nullNode();r=this.m_hashTable.getNextInBucket(r)){const i=this.m_hashTable.getElement(r);t===i||-1!==e&&this.m_shape.getUserIndex(i,this.m_hashValues)!==e||(this.m_shape.queryXY(i,o),v(s.x,s.y,o.x,o.y,this.m_sqrTolerance)&&n.push(r))}}mergeClusters(t,e,s){let n=this.m_shape.getUserIndex(t,this.m_newClusters);const r=this.m_shape.getUserIndex(e,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,t),this.m_shape.setUserIndex(t,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,e):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(e,this.m_newClusters,i.S.impossibleIndex2());const o=this.mergeVertices(t,e);if(s){const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e)}return o}mergeVertices(t,e){const s=r.P.getNAN();this.m_shape.queryXY(t,s);const i=r.P.getNAN();this.m_shape.queryXY(e,i);const n=this.m_shape.getRank(t),o=this.m_shape.getRank(e),a=this.m_shape.getWeight(t),h=this.m_shape.getWeight(e);let m,l,u,c,g=!1;if(n===o?(m=n,l=a+h,u=s.x,s.x!==i.x&&(u=(s.x*a+i.x*h)/l,g=!0),c=s.y,s.y!==i.y&&(c=(s.y*a+i.y*h)/l,g=!0)):(n>o?(u=s.x,c=s.y,l=a,m=n):(u=i.x,c=i.y,l=h,m=o),g=!s.equals(i)),g&&(this.m_shape.setXYMonotonic(t,u,c),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(t)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(t,s),this.m_shape.setSegmentParentageBreakVertex(e,s)}return this.m_shape.setWeight(t,l),this.m_shape.setRank(t,m),g}needsClustering(){const t={stack:[],error:void 0,hasError:!1};try{(0,h.b)(t,(0,r.i)((()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)})),!1);const e=this.m_shape.getSelectedCount(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const n=Math.max(s.height(),s.width())/((0,r.q)()-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 w(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new C(4*e/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let a=!1;for(let t=0;t<2;t++){const e=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==o.n;n=s.next()){if(this.progress_(),t>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===i.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],i=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,i))return this.m_nsr=new l(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(i)),a=!0,a;this.mergeClusters(n,i,!1)}e.length=0}0===t&&this.m_hashTable.addElement(n,s)}}return a}catch(e){t.error=e,t.hasError=!0}finally{(0,h.c)(t)}}clusterNonReciprocal(){const t=this.m_shape.getSelectedCount(),e=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=e.getLowerLeft();const s=Math.max(e.height(),e.width())/((0,r.q)()-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 w(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new C(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!==o.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!==o.n;s=e.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===i.S.impossibleIndex2())continue;let e=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,e);let r=!1;for(;this.collectClusterCandidates(s,t),0!==t.length;){let e=0;for(let i=0,n=t.length;i<n;i++){this.progress_();const r=t[i],o=this.m_hashTable.getElement(r);this.m_hashTable.deleteNode(r);const a=i+1===n;e|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==e,n||=0!==e,t.length=0,!e)break}r&&(e=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,e)}t.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const t=r.P.getNAN();for(let e=this.m_clusters.getFirstList();e!==x.st_nullNode();e=this.m_clusters.getNextList(e)){let s=this.m_clusters.getFirst(e);const i=this.m_clusters.getElement(s);this.m_shape.queryXY(i,t);const n=this.m_shape.getRank(i),r=this.m_shape.getWeight(i);for(s=this.m_clusters.getNext(s);s!==x.st_nullNode();s=this.m_clusters.getNext(s)){const e=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(e,t)||(this.m_shape.setXYMonotonicPoint2D(e,t),this.m_shape.setGeometryModifiedWithVertex(e,!0)):this.m_shape.setXYMonotonicPoint2D(e,t),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentageBreakVertex(i)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(i,t),this.m_shape.setSegmentParentageBreakVertex(e,t)}this.m_shape.setWeight(e,r),this.m_shape.setRank(e,n)}}}}class T{constructor(){this.m_inputParts=[],this.m_resultParts1=[],this.m_resultParts2=[],this.m_resultSegments=[],this.m_freeSegments=[],this.m_inputSegments=[],this.m_param1=[],this.m_param2=[],this.m_tolerance=0,this.m_toleranceZ=0,this.m_point=new i.P,this.m_pointWeight=1,this.m_maxDensifyLimit=0,this.m_pointRank=0,this.m_changed1=!1,this.m_changed2=!1,this.m_adaptiveDensify=!1}clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(t,e,s,i,n,r,o,a,h,m){return function(t,e,s,i,n,r,o,a,h,m){return{segmentIndex:t,weightStart:e,rankStart:s,weightEnd:i,rankEnd:n,weightInterior:r,rankInterior:o,segmentParentage:m,u:N(a,h)}}(t,e,s,i,n,r,o,a,h,m)}pushSegment(t,e,s,i,n,r,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,e,s,i,n,r,o,a,h,m)),this.m_inputSegments.push(t),this.m_inputParts.length-1}getResultSegmentCount(t){return this.m_adaptiveDensify?0===t?this.m_param1.length-1:this.m_param2.length-1:0===t?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(t,e){return 0===t?this.m_resultParts1[e]:this.m_resultParts2[e]}getResultSegment(t,e){return this.m_resultSegments[this.getResultPart_(t,e).segmentIndex].get()}getSegmentChanged(t){return 0===t?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(t,e){return this.getResultPart_(t,e).weightStart}getResultSegmentStartPointRank(t,e){return this.getResultPart_(t,e).rankStart}getResultSegmentSegmentParentage(t,e){return this.getResultPart_(t,e).segmentParentage}getResultSegmentStartPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakStart}getResultSegmentEndPointWeight(t,e){return this.getResultPart_(t,e).weightEnd}getResultSegmentEndPointRank(t,e){return this.getResultPart_(t,e).rankEnd}getResultSegmentEndPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakEnd}getResultSegmentInteriorRank(t,e){return this.getResultPart_(t,e).rankInterior}getResultSegmentInteriorWeight(t,e){return this.getResultPart_(t,e).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(t,e){2!==this.m_inputSegments.length&&(0,n.c)(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=t;const s=(0,r.s)(t*T.c_smallToleranceFactor);let i=!1;const a=this.m_inputParts[0],h=this.m_inputParts[1],m=this.m_inputSegments[a.segmentIndex],l=this.m_inputSegments[h.segmentIndex];if(e||5&(0,o.i)(!0,m,l,t,!0)){const e=(0,o.K)(!0,m,l,null,this.m_param1,this.m_param2,t);0===e&&(0,n.c)("");const u=new Array(e);for(let t=0;t<e;++t)u[t]=r.P.getNAN();const c=new Float64Array(e),g=new Int32Array(e),_=new Array(e),d=new Array(e);for(let t=0;t<e;++t)_[t]={bBigMove:!1,bIsBreak:!1},d[t]={bBigMove:!1,bIsBreak:!1};for(let t=0;t<e;t++){const e=this.m_param1[t],n=this.m_param2[t];let o,p=a.rankInterior,f=a.weightInterior;0===e?(p=a.rankStart,f=a.weightStart,o=a.u.bBreakStart):1===e?(p=a.rankEnd,f=a.weightEnd,o=a.u.bBreakEnd):(this.m_changed1=!0,o=!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 S=1,v=0,b=r.P.getNAN();if(E===C){const i=m.getCoord2D(e),o=l.getCoord2D(n);S=f+y,v=p,(0,r.D)(i,o,y/S,b);const a=r.P.sqrDistance(b,i),h=r.P.sqrDistance(b,o);_[t].bBigMove=a>s,d[t].bBigMove=h>s,this.m_changed1||i.equals(b)||(this.m_changed1=!0),this.m_changed2||o.equals(b)||(this.m_changed2=!0)}else if(E>C){b=m.getCoord2D(e);const i=l.getCoord2D(n);S=f,v=p;const o=r.P.sqrDistance(b,i);_[t].bBigMove=!1,d[t].bBigMove=o>s,this.m_changed2||i.equals(b)||(this.m_changed2=!0)}else{b=l.getCoord2D(n),S=y,v=P;const i=m.getCoord2D(e),o=r.P.sqrDistance(b,i);_[t].bBigMove=o>s,d[t].bBigMove=!1,this.m_changed1||i.equals(b)||(this.m_changed1=!0)}u[t].assign(b),c[t]=S,g[t]=v,_[t].bIsBreak=o||x,d[t].bIsBreak=o||x,i||=_[t].bBigMove||d[t].bBigMove}const p=a.rankInterior,f=a.weightInterior;let x=0,P=-1;for(let s=0;s<=e;s++){const i=s<e?this.m_param1[s]:1;if(i!==x){const n=this.allocResultSegment(),o=this.m_resultSegments[n];let h,l,d,y;m.queryCut(x,i,o,!1),o.get().snapControlPoints(t*t);let E=!1,C=!1,S=!1,v=!1,b=!1,I=r.P.getNAN(),w=r.P.getNAN();-1!==P?(l=g[P],h=c[P],E=_[P].bBigMove,I.assign(u[P]),S=_[P].bIsBreak,b=!0):(h=a.weightStart,l=a.rankStart,I=o.get().getStartXY(),S=a.u.bBreakStart),s<e?(y=g[s],d=c[s],C=_[s].bBigMove,w.assign(u[s]),v=_[s].bIsBreak,b=!0):(d=a.weightEnd,y=a.rankEnd,w=o.get().getEndXY(),v=a.u.bBreakEnd),b&&o.get().setCoordsForIntersector(I,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(n,h,l,d,y,f,p,S,v,a.segmentParentage));const D=this.m_resultParts1.at(-1);D.u.bBigMoveStart=E,D.u.bBigMoveEnd=C,x=i,P=s}else-1===P&&(P=s)}const y=new Array(e);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,r.p)(this.m_param2)):2===e&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=(0,r.b)(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),y[1]=(0,r.b)(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 i=s<e?this.m_param2[s]:1;if(i!==x){const n=this.allocResultSegment(),o=this.m_resultSegments[n];let a,m,_,p;l.queryCut(x,i,o,!1),o.get().snapControlPoints(t*t);let f=r.P.getNAN(),S=r.P.getNAN(),v=!1,b=!1,I=!1,w=!1,D=!1;if(-1!==P){const t=y[P];a=c[t],m=g[t],f.assign(u[t]),I=d[t].bBigMove,v=d[t].bIsBreak,D=!0}else a=h.weightStart,m=h.rankStart,f=o.get().getStartXY(),v=h.u.bBreakStart;if(s!==e){const t=y[s];_=c[t],p=g[t],S.assign(u[t]),w=d[t].bBigMove,b=d[t].bIsBreak,D=!0}else _=h.weightEnd,p=h.rankEnd,S=o.get().getEndXY(),b=h.u.bBreakEnd;D&&o.get().setCoordsForIntersector(f,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(n,a,m,_,p,C,E,v,b,h.segmentParentage));const T=this.m_resultParts2.at(-1);T.u.bBigMoveStart=I,T.u.bBigMoveEnd=w,x=i,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 F(this).intersectCurves(t,e):this.intersectLines(t,e)}intersect2DEx(t,e,s,i,o){this.m_point.assignCopy(e),1!==this.m_inputSegments.length&&(0,n.c)(""),this.m_tolerance=t,this.m_changed1=!1,this.m_changed2=!1;const a=(0,r.s)(t*T.c_smallToleranceFactor);let h=!1;const m=this.m_inputParts[0],l=this.m_inputSegments[m.segmentIndex];if(o||l.isIntersectingPoint(e.getXY(),t,!0)){this.m_param1=(0,r.f)(16,Number.NaN);const n=l.getClosestCoordinate(e.getXY(),!1);this.m_param1[0]=n;let o=m.rankInterior,u=m.weightInterior;0===n?(o=m.rankStart,u=m.weightStart):1===n?(o=m.rankEnd,u=m.weightEnd):this.m_changed1=!0;let c=o;const g=s,_=i;c===g&&l.isCurve()&&(c=g+1);let d=1,p=0;const f=new r.P;if(c===g){const t=l.getCoord2D(n),s=e.getXY();d=u+_,p=o,(0,r.D)(t,s,_/d,f),this.m_changed1||t.equals(f)||(this.m_changed1=!0),this.m_changed2||s.equals(f)||(this.m_changed2=!0),h=r.P.sqrDistance(f,t)>a}else c>g?(f.assign(l.getCoord2D(n)),d=u,p=o,this.m_changed2||f.equals(e.getXY())||(this.m_changed2=!0)):(f.assign(l.getCoord2D(n)),d=_,p=g,this.m_changed1||f.equals(e.getXY())||(this.m_changed1=!0),h=r.P.sqrDistance(f,e.getXY())>a);let x=0,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 i=this.allocResultSegment(),n=this.m_resultSegments[i];l.queryCut(x,s,n),n.get().snapControlPoints(t*t);let r=m.weightStart,o=m.weightEnd,a=m.rankStart,h=m.rankEnd;const u=m.rankInterior,c=m.weightInterior;let g=m.u.bBreakStart,_=m.u.bBreakEnd;-1!==P&&(r=d,a=p,g=!0,n.get().setCoordsForIntersector(f,n.get().getEndXY(),!0)),e!==y&&(o=d,h=p,_=!0,n.get().setCoordsForIntersector(n.get().getStartXY(),f,!0)),x=s,this.m_resultParts1.push(this.newIntersectionPart_(i,r,a,o,h,c,u,g,_,m.segmentParentage))}P=e}return this.m_point.setXY(f),this.m_pointWeight=d,this.m_pointRank=p,h?3:2}return 0}intersect3D(t,e,s,i){return(0,n.g)(0),1}intersect3DEx(t,e,s,i,r,o,a){return(0,n.g)(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(t){this.m_freeSegments.push(t)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new o.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 o.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 o.S({segment:t}),s=this.m_resultSegments.length;return this.m_resultSegments.push(e),s}}function N(t,e){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:t,bBreakEnd:e}}function A(){return{bBigMove:!1,bIsBreak:!1}}T.maxWeight=.1*Number.MAX_VALUE,T.c_smallToleranceFactor=.01,T.c_maxGeometryTypeToRankDelta=8;class G{constructor(){this.start=null,this.end=null,this.equalEdge=null,this.segmentIndex=-1,this.segmentParentage=-1,this.weight=0,this.rank=0}hasSegment(){return this.segmentIndex>=0}transferAttributes(t,e,s){if(1===e.getDescription().getAttributeCount())return;const n=t.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=t.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),o=new i.P;e.queryStart(o),s?(o.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(o)):(o.setXY(r),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(o)),e.queryEnd(o),s?(o.setXY(r),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(o)):(o.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(o))}copyFromWhenOverlap(t,e,s){this.equalEdge=e,e.equalEdge=this,this.segmentIndex=t.parent.allocResultSegmentFromBuffer(t.parent.m_resultSegments[e.segmentIndex]),this.segmentParentage=e.segmentParentage,this.weight=e.weight,this.rank=e.rank,s?(this.start.copyFrom(e.start),this.end.copyFrom(e.end)):(this.start.copyFrom(e.end),this.end.copyFrom(e.start),t.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}}class M{constructor(){this.hash=0,this.pt=new r.P,this.prevInChain=null,this.nextInChain=null,this.prevInHash=null,this.nextInHash=null,this.prevEqual=null,this.nextEqual=null,this.weight=0,this.rank=0,this.bBigMove=!1,this.bIsBreak=!1}copyFrom(t){this.pt.assign(t.pt),this.weight=t.weight,this.rank=t.rank,this.bBigMove=t.bBigMove,this.bIsBreak=t.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let t=this;for(;null!==t.prevEqual;t=t.prevEqual);return t}}function q(t,e,s,i){return{edge1:t,edge2:e,recursion:s,bIsIntersecting:i}}class F{constructor(t){this.m_pairs=[],this.m_chainOrigin1=null,this.m_chainOrigin2=null,this.m_newNodes=[],this.m_hashTableOfEquals=[],this.m_hashTableOfEqualsSize=0,this.m_origin=new r.P,this.m_cell=new r.P,this.parent=t}addSegment(t,e,s,i,r,o,a,h,m,l,u){const c=this.newNode(this.parent.m_resultSegments[t].get().getStartXY(),s,i,m),g=this.newNode(this.parent.m_resultSegments[t].get().getEndXY(),r,o,l);this.newEdge(c,g,t,a,h,u),null===this.m_chainOrigin1?this.m_chainOrigin1=c:null===this.m_chainOrigin2?this.m_chainOrigin2=c:(0,n.g)(0)}intersectCurvesHelper(t,e,s,i,a){const h=this.getSegment(t).get(),m=this.getSegment(e).get();if(h.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(t,e,s,i);if(0!==l)return l;const u=(0,r.s)(.01*s);let c=!1,g=this.processSharpCorners(h,m,s,a>4);const _=g>0;if(!_){if(!(i||5&(0,o.N)(!0,!1,h,m,s,!0)))return 0;g=(0,o.K)(!0,h,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===g&&(0,n.c)("");const d=h.getGeometryType(),p=m.getGeometryType(),f=(0,r.m)(r.P,g),x=(0,r.m)(r.P,g),P=new Array(g),y=new Array(g),E=new Array(g),C=new Array(g),S=(0,r.v)(A,g),v=(0,r.v)(A,g);let b=!1,I=!1;for(let i=0;i<g;i++){const n=this.parent.m_param1[i],o=this.parent.m_param2[i];let a=t.rank,l=t.weight,g=!0,w=!1;0===n?(a=t.start.rank,l=t.start.weight,w=t.start.bIsBreak):1===n?(a=t.end.rank,l=t.end.weight,w=t.end.bIsBreak):(b=!0,g=!1);let D=e.rank,N=e.weight,A=!1,G=!0;0===o?(D=e.start.rank,N=e.start.weight,A=e.start.bIsBreak):1===o?(D=e.end.rank,N=e.end.weight,A=e.end.bIsBreak):(I=!0,G=!1);let M=a,q=D;if(M===q&&(M*=T.c_maxGeometryTypeToRankDelta,q*=T.c_maxGeometryTypeToRankDelta,M+=V(d,h,!1),q+=V(p,m,!1)),g&&G&&q===M){const t=h.getCoord2D(n),e=m.getCoord2D(o);t.equals(e)&&(q=M-1)}let F=1,Y=0,X=1,R=0;const k=new r.P,L=new r.P,B=h.getCoord2D(n),H=m.getCoord2D(o);if(_&&r.P.distance(B,H)>s)k.setCoordsPoint2D(B),L.setCoordsPoint2D(H),F=l,X=N,Y=a,R=D,S[i].bBigMove=!1,v[i].bBigMove=!1,w=!0,A=!0;else if(M===q){X=F=l+N,R=Y=a,(0,r.D)(B,H,N/F,k),L.setCoordsPoint2D(k);const t=r.P.sqrDistance(k,B),e=r.P.sqrDistance(k,H);S[i].bBigMove=t>u,v[i].bBigMove=e>u,b||B.equals(k)||(b=!0),I||H.equals(L)||(I=!0)}else if(M>q){k.setCoordsPoint2D(B),L.setCoordsPoint2D(k),X=F=l,R=Y=a;const t=r.P.sqrDistance(k,H);S[i].bBigMove=!1,v[i].bBigMove=t>u,I||H.equals(L)||(I=!0)}else{L.setCoordsPoint2D(H),k.setCoordsPoint2D(L),X=F=N,R=Y=D;const t=r.P.sqrDistance(k,B);S[i].bBigMove=t>u,v[i].bBigMove=!1,b||B.equals(k)||(b=!0)}f[i].assign(k),x[i].assign(L),P[i]=F,y[i]=X,E[i]=Y,C[i]=R,S[i].bIsBreak=w||A,v[i].bIsBreak=w||A,c||=S[i].bBigMove||v[i].bBigMove,i>0&&(n!==this.parent.m_param1[i-1]&&o!==this.parent.m_param2[i-1]||(E[i]<=E[i-1]?(f[i].assign(x[i-1]),P[i]=y[i-1],E[i]=C[i-1],x[i].assign(x[i-1]),y[i]=y[i-1],C[i]=C[i-1],S[i].bBigMove||=S[i-1].bBigMove,v[i].bBigMove||=v[i-1].bBigMove,S[i].bIsBreak||=S[i-1].bIsBreak,v[i].bIsBreak||=v[i-1].bIsBreak):(f[i-1].assign(f[i]),P[i-1]=P[i],E[i-1]=E[i],x[i-1].assign(x[i]),y[i-1]=y[i],C[i-1]=C[i],S[i-1].bBigMove||=S[i].bBigMove,v[i-1].bBigMove||=v[i].bBigMove,S[i-1].bIsBreak||=S[i].bIsBreak,v[i-1].bIsBreak||=v[i].bIsBreak)))}if(!(b||I||2!==g||d===n.G.enumLine&&p===n.G.enumLine)){if(this.processDoublyConnectedEdges(t,e,a+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;(0,n.g)(0)}this.parent.m_changed1||=b,this.parent.m_changed2||=I;let w=t,D=t.end.weight,N=t.end.rank,G=t.end.bBigMove,M=t.end.bIsBreak,q=0,F=-1;for(let e=0;e<=g;e++){const i=e<g?this.parent.m_param1[e]:1;if(i!==q){const n=this.parent.allocResultSegment(),o=this.parent.m_resultSegments[n];let a,m,l,u;h.queryCut(q,i,o,!1),o.get().snapControlPoints(s*s);let c=!1,_=!1,d=!1,p=!1;const x=new r.P,y=new r.P;-1!==F?(m=E[F],a=P[F],d=S[F].bBigMove,c=S[F].bIsBreak,x.assign(f[F])):(a=t.start.weight,m=t.start.rank,d=t.start.bBigMove,c=t.start.bIsBreak,x.assign(o.get().getStartXY())),e<g?(u=E[e],l=P[e],p=S[e].bBigMove,_=S[e].bIsBreak,y.assign(f[e])):(l=D,u=N,p=G,_=M,y.assign(o.get().getEndXY()));let C=w;i<1&&(this.splitEdgeInPlace(w),C=w.getNextInChain()),this.updateSegmentOnly(w,n),0===w.start.hash||w.start.pt.equals(x)||(this.m_newNodes.push(w.start),this.removeNodeFromHash(w.start),w.start.hash=0),0===w.end.hash||w.end.pt.equals(y)||(this.m_newNodes.push(w.end),this.removeNodeFromHash(w.end),w.end.hash=0),w.start.pt.assign(x),w.end.pt.assign(y),w.start.bBigMove||=d,w.end.bBigMove||=p,w.start.bIsBreak||=c,w.end.bIsBreak||=_,w.start.weight=a,w.start.rank=m,w.end.weight=l,w.end.rank=u,w=C,q=i,F=e}else-1===F&&(F=e)}const Y=w.getNextInChain(),X=[];X.length=g;for(let t=0;t<g;t++)X[t]=t;g>2?(X.sort(((t,e)=>(0,r.G)(this.parent.m_param2[t],this.parent.m_param2[e]))),this.parent.m_param2.sort(r.G)):2===g&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=(0,r.b)(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),X[1]=(0,r.b)(X[0],X[0]=X[1])),w=e,D=e.end.weight,N=e.end.rank,G=e.end.bBigMove,M=e.end.bIsBreak,q=0,F=-1;for(let t=0;t<=g;t++){const i=t<g?this.parent.m_param2[t]:1;if(i!==q){const n=this.parent.allocResultSegment(),o=this.parent.m_resultSegments[n];let a,h,l,u;m.queryCut(q,i,o,!1),o.get().snapControlPoints(s*s);const c=new r.P,_=new r.P;let d=!1,p=!1,f=!1,P=!1;if(-1!==F){const t=X[F];a=y[t],h=C[t],c.assign(x[t]),f=v[t].bBigMove,d=v[t].bIsBreak}else a=e.start.weight,h=e.start.rank,f=e.start.bBigMove,d=e.start.bIsBreak,c.assign(o.get().getStartXY());if(t!==g){const e=X[t];l=y[e],u=C[e],_.assign(x[e]),P=v[e].bBigMove,p=v[e].bIsBreak}else l=D,u=N,P=G,p=M,_.assign(o.get().getEndXY());let E=w;i<1&&(this.splitEdgeInPlace(w),E=w.getNextInChain()),this.updateSegmentOnly(w,n),0===w.start.hash||w.start.pt.equals(c)||(this.m_newNodes.push(w.start),this.removeNodeFromHash(w.start),w.start.hash=0),0===w.end.hash||w.end.pt.equals(_)||(this.m_newNodes.push(w.end),this.removeNodeFromHash(w.end),w.end.hash=0),w.start.pt.assign(c),w.end.pt.assign(_),w.start.bBigMove||=f,w.end.bBigMove||=P,w.start.bIsBreak||=d,w.end.bIsBreak||=p,w.start.weight=a,w.start.rank=h,w.end.weight=l,w.end.rank=u,w=E,q=i,F=t}else-1===F&&(F=t)}const R=w.getNextInChain();return this.postProcessResultPartsForCurves(t,Y,e,R,a+1),c?3:2}intersectCurves(t,e){2!==this.parent.m_inputSegments.length&&(0,n.c)(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=t,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=(0,r.o)(16);const s=a.J.constructEmpty();for(let t=0;t<2;t++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex]),i=a.J.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex].queryLooseEnvelope(i),s.mergeEnvelope2D(i);const n=this.parent.m_inputParts[t];this.addSegment(e,0,n.weightStart,n.rankStart,n.weightEnd,n.rankEnd,n.weightInterior,n.rankInterior,n.u.bBreakStart,n.u.bBreakEnd,n.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(q(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,e));let i=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,i=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 i}tryOverlapIntersectCurves(t,e,s,i){const a=this.parent.m_resultSegments[t.segmentIndex].get(),h=this.parent.m_resultSegments[e.segmentIndex].get(),m=a.getStartXY().equals(h.getStartXY())&&a.getEndXY().equals(h.getEndXY()),l=a.getStartXY().equals(h.getEndXY())&&a.getEndXY().equals(h.getStartXY());if(!m&&!l)return 0;const u=(0,o.X)(a,h,!0);if(0!==u&&(0,o.Y)(a,h)&&t.segmentParentage===e.segmentParentage){let t=!1;if(u>0)t=a.equals(h);else{(0,n.g)(-1===u);const e=new o.S({segment:h});e.get().reverse(),t=a.equals(e.get())}if(t)return 1}const c=s*T.c_smallToleranceFactor;let g=!1;if(0===u){const t=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let e=0,i=t.length;e<i;++e){const i=t[e],n=new r.P;a.queryCoord2D(i,n);const o=h.getClosestCoordinate(n,!1),m=new r.P;h.queryCoord2D(o,m);const l=r.P.distance(n,m);if(l>s)return 0;g||=l>c}for(let e=0,i=t.length;e<i;++e){const i=t[e],n=new r.P;h.queryCoord2D(i,n);const o=a.getClosestCoordinate(n,!1),m=new r.P;a.queryCoord2D(o,m);const l=r.P.distance(n,m);if(l>s)return 0;g||=l>c}}let _=t.rank,d=e.rank;return _===d&&(_*=T.c_maxGeometryTypeToRankDelta,d*=T.c_maxGeometryTypeToRankDelta,_+=V(a.getGeometryType(),a,!0),d+=V(h.getGeometryType(),h,!0)),_>d?(e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):d>_?(t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)):t.segmentParentage<=e.segmentParentage?(t.weight=t.weight+e.weight,e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):(e.weight=t.weight+e.weight,t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)),g?3:2}postProcessResultPartsForCurves(t,e,s,i,o){o===(0,r.H)()&&(0,n.c)("curve_helper");for(let s=t;s!==e;s=s.getNextInChain())this.updateSegmentToNodes(s);for(let t=s;t!==i;t=t.getNextInChain())this.updateSegmentToNodes(t);for(let a=t;a!==e;a=a.getNextInChain()){const t=a.end.pt.sub(a.start.pt);for(let e=s;e!==i;e=e.getNextInChain()){let s=0;if(a.start.pt.equals(e.start.pt)&&a.end.pt.equals(e.end.pt)?s=1:a.start.pt.equals(e.end.pt)&&a.end.pt.equals(e.start.pt)&&(s=-1),!s){let s=a.start.pt.equals(e.start.pt)?1:0;if(s||(s=a.end.pt.equals(e.end.pt)?2:0,s||(s=a.end.pt.equals(e.start.pt)?3:0,s||(s=a.start.pt.equals(e.end.pt)?4:0))),s){const i=e.end.pt.sub(e.start.pt),r=t.dotProduct(i);let h;switch(s){case 1:case 2:h=r>0;break;case 3:case 4:h=r<0;break;default:(0,n.c)("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(q(a,e,o,!1))}continue}const i=this.parent.m_resultSegments[a.segmentIndex],h=this.parent.m_resultSegments[e.segmentIndex],m=[.5,.25,.75];for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new r.P;i.get().queryCoord2D(e,n);const o=h.get().getClosestCoordinate(n,!1),a=new r.P;if(h.get().queryCoord2D(o,a),r.P.distance(n,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(q(a,e,o,!1));continue}for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new r.P;h.get().queryCoord2D(e,n);const o=i.get().getClosestCoordinate(n,!1),a=new r.P;if(i.get().queryCoord2D(o,a),r.P.distance(n,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(q(a,e,o,!1));continue}a.equalEdge=e,e.equalEdge=a;let l=a.rank,u=e.rank;l===u&&(l*=T.c_maxGeometryTypeToRankDelta,u*=T.c_maxGeometryTypeToRankDelta,l+=V(i.get().getGeometryType(),i.get(),!0),u+=V(h.get().getGeometryType(),h.get(),!0)),l>u||l===u&&a.segmentParentage<=e.segmentParentage?(i.copyTo(h,!1),e.segmentParentage=a.segmentParentage,-1===s&&h.get().reverse()):(h.copyTo(i,!1),a.segmentParentage=e.segmentParentage,-1===s&&i.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(t.start),e&&this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(s.start),i&&this.updateAttachedEdgesAfterNodeChange(i.start)}processDoublyConnectedEdges(t,e,s,i){s===(0,r.H)()&&(0,n.c)("curve_helper");const a=this.getSegment(t).get(),h=this.getSegment(e).get(),m=a.getStartXY().equals(h.getStartXY())&&a.getEndXY().equals(h.getEndXY())?1:a.getEndXY().equals(h.getStartXY())&&a.getStartXY().equals(h.getEndXY())?-1:0;if(0!==m){const n=new o.S;a.queryCut(0,.5,n),n.get().snapControlPoints(i*i);const r=new o.S;a.queryCut(.5,1,r),r.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(r);let l=h.getClosestCoordinate(t.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),h.queryCut(0,l,n),n.get().snapControlPoints(i*i),h.queryCut(l,1,r),r.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(r),m>0?(this.m_pairs.push(q(t,e,s,!1)),this.m_pairs.push(q(t.getNextInChain(),e.getNextInChain(),s,!1))):(this.m_pairs.push(q(t,e.getNextInChain(),s,!1)),this.m_pairs.push(q(t.getNextInChain(),e,s,!1))),!0}return!1}newNode(t,e,s,i){const n=new M;return this.m_newNodes.push(n),n.pt=t,n.rank=s,n.weight=e,n.bIsBreak=i,n}newEdge(t,e,s,i,n,r){const o=new G;return o.start=t,o.end=e,t.nextInChain=o,e.prevInChain=o,o.segmentIndex=s,o.segmentParentage=r,o.rank=n,o.weight=i,o}splitEdgeInPlace(t){t.segmentIndex=-1;const e=new G,s=new M;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=e,s.prevInChain=t,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=t.weight,s.rank=t.rank,s.bIsBreak=!1,s.bBigMove=!1,e.start=s,e.segmentIndex=-1,e.end=t.end,e.end.prevInChain=e,e.rank=t.rank,e.weight=t.weight,e.segmentParentage=t.segmentParentage,t.end=s,t.equalEdge&&(t.equalEdge.equalEdge=null),t.equalEdge=null}updateSegmentOnly(t,e){t.segmentIndex=e}updateAttachedEdgesAfterNodeChange(t){for(let e=t.equalListHead();null!==e;e=e.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(e)}updateAttachedEdgesAfterNodeChangeImpl(t){const e=t.prevInChain;if(e&&e.hasSegment()){const s=this.getSegment(e).get();t.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(e.start.pt,e.end.pt,!1),s.ensureXYMonotone())}const s=t.nextInChain;if(s&&s.hasSegment()){const e=this.getSegment(s).get();t.pt.equals(e.getStartXY())||(e.setCoordsForIntersector(s.start.pt,s.end.pt,!1),e.ensureXYMonotone())}}updateSegmentToNodes(t){const e=this.getSegment(t).get();t.start.pt.equals(e.getStartXY())&&t.end.pt.equals(e.getEndXY())||(e.setCoordsForIntersector(t.start.pt,t.end.pt,!1),e.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(t.end)}getSegment(t){return this.parent.m_resultSegments[t.segmentIndex]}clusterNodes(t){let e=!1;const s=[],i=[],n=[];for(let t=0,e=this.m_newNodes.length;t<e;t++){const s=this.m_newNodes[t];if(null===s)continue;let i=s;for(let n=t+1;n<e;n++){const t=this.m_newNodes[n];null!==t&&s.pt.equals(t.pt)&&(i.nextInHash=t,t.prevInHash=i,i=t,this.m_newNodes[n]=null)}}for(let o=0,a=this.m_newNodes.length;o<a;o++){const a=this.m_newNodes[o];if(null==a)continue;for(a.hash=this.calculateHash(a.pt);;){const o=(0,r.o)(4),h=this.hashTableBinsToCheck(a,o);for(let e=0;e<h;e++)if(null!==o[e])for(let h=o[e];null!==h;){const e=h.nextInHash;r.P.distance(a.pt,h.pt)<=t&&(s.push(h),this.removeNodeFromHash(h),h.hash=0,n.push(h),i.push(h)),h=e}let m=!1;for(const t of s)if(!a.pt.equals(t.pt)){const s=b(a.pt,t.pt,a.weight,a.rank,t.weight,t.rank);a.pt.assign(s.pt),a.weight=s.weight,a.rank=s.rank,m=!0,e=!0}if(s.length=0,!m)break;a.hash=this.calculateHash(a.pt)}n.push(a),i.push(a);for(let t=a.nextInHash;null!==t;){t.prevInHash=null;const e=t.nextInHash;t.nextInHash=null,n.push(t),i.push(t),t=e}const h=a.hash;let m=null,l=null;for(const t of i)a!==t&&(t.hash=h,t.pt.assign(a.pt),t.rank=a.rank,t.weight=a.weight),t.prevInHash=m,m&&(m.nextInHash=t),t.prevEqual=l,t.nextEqual=null,l&&(l.nextEqual=t),l=t,m=t;const u=h%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[u],null!==this.m_hashTableOfEquals[u]&&(this.m_hashTableOfEquals[u].prevInHash=m),this.m_hashTableOfEquals[u]=i[0],this.m_hashTableOfEqualsSize+=i.length,i.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,e)for(const t of n)this.updateAttachedEdgesAfterNodeChange(t)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const t=this.m_hashTableOfEquals;this.m_hashTableOfEquals=(0,r.o)(2*t.length),this.m_hashTableOfEqualsSize=0;for(const e of t){let t=e;for(;t;){const e=t.nextInHash;t.nextInHash=null,t.prevInHash=null,this.addNodeToHashImpl(t),t=e}}}}addNodeToHashImpl(t){const e=t.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[e];t.nextInHash=s,null!==s&&(s.prevInHash=t),this.m_hashTableOfEquals[e]=t,this.m_hashTableOfEqualsSize++}removeNodeFromHash(t){const e=t.hash%this.m_hashTableOfEquals.length,s=t.prevInHash,i=t.nextInHash;s?s.nextInHash=i:this.m_hashTableOfEquals[e]=i,i&&(i.prevInHash=s),this.m_hashTableOfEqualsSize--,t.prevInHash=null,t.nextInHash=null}hashTableBinsToCheck(t,e){const s=(t.pt.x-this.m_origin.x)/this.m_cell.x,i=(t.pt.y-this.m_origin.y)/this.m_cell.y,n=(0,r.q)()-1,o=Math.round((0,r.c)(s,-2147483646,n)),a=Math.round((0,r.c)(i,-2147483646,n));let h=o|a<<32;h=(0,r.l)(h),e[0]=this.m_hashTableOfEquals[h%this.m_hashTableOfEquals.length];let m=o+1|a<<32;m=(0,r.l)(m);let l=1;e[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],e[1]!==e[0]&&(l=2);let u=o+1|a+1<<32;u=(0,r.l)(u),e[l]=this.m_hashTableOfEquals[u%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}l++;let c=o|a+1<<32;c=(0,r.l)(c),e[l]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}return l++,l}calculateHash(t){const e=(t.x-this.m_origin.x)/this.m_cell.x,s=(t.y-this.m_origin.y)/this.m_cell.y,i=(0,r.q)()-1;let n=Math.round((0,r.c)(e,-2147483646,i))|Math.round((0,r.c)(s,-2147483646,i))<<32;return n=(0,r.l)(n),0===n&&(n=1),n}processSharpCorners(t,e,s,i){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,t.getStartXY().equals(e.getStartXY())){const n=[0,0],r=[0,0],a=(0,o.Z)(t,e,0,0,s,2,n,r,i);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(n[t]),this.parent.m_param2.push(r[t]);return a+1}}if(t.getEndXY().equals(e.getEndXY())){const n=[0,0],r=[0,0],a=(0,o.Z)(t,e,1,1,s,2,n,r,i);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(n[t]),this.parent.m_param2.push(r[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),a+1}}if(t.getStartXY().equals(e.getEndXY())){const n=[0,0],r=[0,0],a=(0,o.Z)(t,e,0,1,s,2,n,r,i);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(n[t]),this.parent.m_param2.push(r[t]);return a+1}}if(t.getEndXY().equals(e.getStartXY())){const n=[0,0],r=[0,0],a=(0,o.Z)(t,e,1,0,s,2,n,r,i);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(n[t]),this.parent.m_param2.push(r[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),a+1}}return 0}}function V(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.c)("")}return s?5-i:i}class Y extends y{constructor(t){super(t.m_shape,t.m_tolerance,!1),this.m_parent=t}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const i=t.getElement(s),n=this.m_parent.getEdgeOriginVertices(e),r=this.m_parent.m_edgeVertices.getFirstElement(n),o=this.m_parent.getEdgeOriginVertices(i),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(e,r,i,a)}}class X extends E{constructor(t){super(t.m_shape,t.m_tolerance),this.m_parent=t}compare(t,e){if(this.m_bIntersectionDetected)return-1;const s=t.getElement(e),i=this.m_parent.getEdgeOriginVertices(s),n=this.m_parent.m_edgeVertices.getFirstElement(i);return this.m_currentNode=e,this.compareVertex(t,e,n)}}class R extends i.r{constructor(t){super(),this.pt1=r.P.getNAN(),this.pt2=r.P.getNAN(),this.m_shape=t}compare(t,e,s){this.m_shape.queryXY(e,this.pt1);const i=t.getElement(s);return this.m_shape.queryXY(i,this.pt2),this.pt1.compare(this.pt2)}}class k{constructor(t){this.m_point=r.P.getNAN(),this.m_pt=r.P.getNAN(),this.m_shape=t}setPoint(t){this.m_point.setCoordsPoint2D(t)}compare(t,e){const s=t.getElement(e);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class L{constructor(t,e){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new i.S(8),this.m_clusters=new i.S(5),this.m_clusterVertices=new x(!1),this.m_edgeVertices=new x(!1),this.m_helperPoint=new i.P,this.m_eventQ=new i.T,this.m_sweepStructure=new i.T,this.m_bComplications=!1,this.m_sweepComparator=null,this.m_tempEdgeBuffer=[],this.m_modifiedClusters=[],this.m_edgesToInsertInSweepStructure=[],this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1,this.m_progressCounter=0,this.m_segmentIntersector=new T,this.m_segBuf1=new o.S,this.m_segBuf2=new o.S,this.m_sweepPoint=new r.P(0,0),this.m_tolerance=0,this.m_toleranceSqr=0,this.m_sweepPointCluster=-1,this.m_vertexClusterIndex=-1,this.m_bCracked=!1,this.m_bSweepPointClusterWasModified=!1,this.m_progressTracker=t,this.m_bTrackChanges=e}hadComplications(){return this.m_bComplications}sweep(t,e){const s=new m.T;s.setSwapCoordinates(),t.applyTransformation(s),this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e;let i=this.sweepImpl_();return t.applyTransformation(s),i||(this.fillEventQueuePass2(),i=this.sweepImpl_()||i),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(t,e){this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const i=t.filterClosePoints(e,!0,!1,this.m_bTrackChanges,o.n);this.m_bComplications=1===i,s||=1===i}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(t,e){return this.m_edges.getField(t,0+e)}setEdgeCluster_(t,e,s){this.m_edges.setField(t,0+e,s)}getEdgeOriginVertices(t){return this.m_edges.getField(t,2)}setEdgeOriginVertices_(t,e){this.m_edges.setField(t,2,e)}getNextEdgeEx(t,e){return this.m_edges.getField(t,3+e)}setNextEdgeEx_(t,e,s){this.m_edges.setField(t,3+e,s)}getEdgeSweepNode(t){return this.m_edges.getField(t,7)}setEdgeSweepNode_(t,e){this.m_edges.setField(t,7,e)}getNextEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,3+s)}setNextEdge_(t,e,s){const i=this.getEdgeEnd(t,e);this.m_edges.setField(t,3+i,s)}getPrevEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,5+s)}setPrevEdge_(t,e,s){const i=this.getEdgeEnd(t,e);this.m_edges.setField(t,5+i,s)}getClusterVertices(t){return this.m_clusters.getField(t,0)}setClusterVertices_(t,e){this.m_clusters.setField(t,0,e)}getClusterSweepEdgeList(t){return this.m_clusters.getField(t,2)}setClusterSweepEdgeList_(t,e){this.m_clusters.setField(t,2,e)}getClusterFirstEdge(t){return this.m_clusters.getField(t,1)}setClusterFirstEdge_(t,e){this.m_clusters.setField(t,1,e)}getClusterEventQNode(t){return this.m_clusters.getField(t,3)}setClusterEventQNode_(t,e){this.m_clusters.setField(t,3,e)}newCluster_(t){const e=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(e,s),t!==o.n&&(this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)),e}deleteCluster_(t){this.m_clusters.deleteElement(t)}addVertexToCluster_(t,e){const s=this.getClusterVertices(t);this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)}newEdge_(t){const e=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(e,s),-1!==t&&this.m_edgeVertices.addElement(s,t),e}addVertexToEdge_(t,e){const s=this.getEdgeOriginVertices(t);this.m_edgeVertices.addElement(s,e)}deleteEdge_(t){this.m_edges.deleteElement(t);const e=this.m_edgesToInsertInSweepStructure.findIndex((e=>e===t));e>=0&&(0,r.C)(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.c)(""),this.addEdgeToClusterImpl_(t,e)}addEdgeToClusterImpl_(t,e){const s=this.getClusterFirstEdge(e);if(-1!==s){const i=this.getNextEdge(s,e);this.setPrevEdge_(i,e,t),this.setNextEdge_(t,e,i),this.setNextEdge_(s,e,t),this.setPrevEdge_(t,e,s)}else this.setPrevEdge_(t,e,t),this.setNextEdge_(t,e,t),this.setClusterFirstEdge_(e,t)}getEdgeEnd(t,e){return this.getEdgeCluster(t,0)===e?0:1}mergeClusters_(t,e){this.dbgCheckCluster_(t),this.dbgCheckCluster_(e);const s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1));let i=this.getClusterFirstEdge(t),n=this.getClusterFirstEdge(e);if(-1!==n){let s=n,r=n,o=!1;do{this.dbgCheckEdge_(s),o=!1;const i=this.getEdgeEnd(s,e),a=this.getNextEdgeEx(s,i);if(this.getEdgeCluster(s,i+1&1)===t){this.disconnectEdge_(s);const t=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(t),this.deleteEdge_(s),s===a){n=-1;break}n===s&&(n=this.getClusterFirstEdge(e),r=a,o=!0)}s=a}while(s!==r||o);if(-1!==n){do{const i=this.getEdgeEnd(s,e),n=this.getNextEdgeEx(s,i);this.setEdgeCluster_(s,i,t),s=n}while(s!==r);if(i=this.getClusterFirstEdge(t),-1!==i){const e=this.getNextEdge(i,t),s=this.getNextEdge(n,t);e===i?(this.setClusterFirstEdge_(t,n),this.addEdgeToClusterImpl_(i,t),this.setClusterFirstEdge_(t,i)):s===n&&this.addEdgeToClusterImpl_(n,t),this.setNextEdge_(n,t,e),this.setPrevEdge_(e,t,n),this.setNextEdge_(i,t,s),this.setPrevEdge_(s,t,i)}else this.setClusterFirstEdge_(t,n)}}const r=this.getClusterVertices(t),o=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(o);-1!==e;e=this.m_clusterVertices.getNext(e)){const s=this.m_clusterVertices.getElement(e);this.m_shape.setUserIndex(s,this.m_vertexClusterIndex,t)}this.m_clusterVertices.concatenateLists(r,o),this.deleteCluster_(e),this.dbgCheckCluster_(t)}mergeEdges_(t,e){this.dbgCheckEdge_(t),this.dbgCheckEdge_(e);const s=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),n=this.getEdgeCluster(e,0),r=this.getEdgeCluster(e,1),o=this.getEdgeOriginVertices(t),a=this.getEdgeOriginVertices(e);if(this.m_edgeVertices.concatenateLists(o,a),e===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,t),e===this.getClusterFirstEdge(i)&&this.setClusterFirstEdge_(i,t),this.disconnectEdge_(e),this.deleteEdge_(e),!(s===n&&i===r||i===n&&s===r)){const t=this.getClusterXY(s),e=this.getClusterXY(n);t.isEqualPoint2D(e)?(s!==n&&this.mergeClusters_(s,n),i!==r&&this.mergeClusters_(i,r)):(i!==n&&this.mergeClusters_(i,n),s!==r&&this.mergeClusters_(s,r))}this.dbgCheckEdge_(t)}disconnectEdge_(t){const e=this.getEdgeCluster(t,0),s=this.getEdgeCluster(t,1);this.disconnectEdgeFromCluster_(t,e),this.disconnectEdgeFromCluster_(t,s)}disconnectEdgeFromCluster_(t,e){const s=this.getNextEdge(t,e),i=this.getPrevEdge(t,e),n=this.getClusterFirstEdge(e);s!==t?(this.setNextEdge_(i,e,s),this.setPrevEdge_(s,e,i),n===t&&this.setClusterFirstEdge_(e,s)):this.setClusterFirstEdge_(e,-1)}applyIntersectorToEditShape_(t,e,s){let i=this.m_edgeVertices.getFirst(t);const n=this.m_edgeVertices.getElement(i),r=this.getClusterFromVertex(n),o=this.m_shape.getNextVertex(n),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(n),m=this.m_shape.getXY(o);let l=!1,u=!1;const c=e.getResultSegment(s,0).getStartXY(),g=e.getResultSegment(s,e.getResultSegmentCount(s)-1).getEndXY();h.equals(c)||(l=!0),m.equals(g)||(u=!0),this.m_shape.splitSegmentWithIntersector(n,e,s,!0,!0);const _=this.m_bTrackChanges&&e.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(n,!0),i=this.m_edgeVertices.getNext(i);-1!==i;i=this.m_edgeVertices.getNext(i)){const t=this.m_edgeVertices.getElement(i),n=this.getClusterFromVertex(t)===r;this.m_shape.splitSegmentWithIntersector(t,e,s,n,!0),_&&this.m_shape.setGeometryModifiedWithVertex(t,!0)}if(l&&this.updateClusterXY(!0,r,c,e.getResultSegmentStartPointWeight(s,0),e.getResultSegmentStartPointRank(s,0)),u){const t=e.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,g,e.getResultSegmentEndPointWeight(s,t),e.getResultSegmentEndPointRank(s,t))}}createEdgesAndClustersFromSplitEdge_(t,e,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(t),r=this.getEdgeCluster(t,0),o=this.getEdgeCluster(t,1);let a=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(a);const h=i.S.impossibleIndex3();this.setEdgeSweepNode_(a,h),this.m_tempEdgeBuffer.push(a),this.addEdgeToCluster(a,r);const m=e.getResultSegmentCount(s);for(let t=1;t<m;t++){const t=this.newCluster_(-1);this.m_modifiedClusters.push(t),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(a,t);const e=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,h),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(e,t),a=e}this.addEdgeToCluster(a,o);for(let t=this.m_edgeVertices.getFirst(n);-1!==t;t=this.m_edgeVertices.getNext(t)){let e=this.m_edgeVertices.getElement(t);if(this.getClusterFromVertex(e)===r){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_vertexClusterIndex)}processSplitHelper1_(t,e,s){const n=this.getEdgeCluster(e,0),r=this.getClusterXY(n),o=this.getEdgeCluster(e,1),a=this.getClusterXY(o),h=s.getResultSegmentCount(t);let m=s.getResultSegment(t,0);const l=m.getStartXY();if(r.isEqualPoint2D(l)||(this.m_bComplications||r.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)),!this.m_bComplications&&h>1){const t=r.compare(a),e=m.getEndXY();(r.compare(e)!==t||e.compare(a)!==t||e.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(t,h-1);const u=m.getEndXY();a.isEqualPoint2D(u)||(this.m_bComplications||a.compare(this.m_sweepPoint)*u.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(o,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(o)),this.m_tempEdgeBuffer.push(e);for(let t=0,s=this.m_tempEdgeBuffer.length;t<s;t++){const s=this.m_tempEdgeBuffer[t],n=this.getEdgeSweepNode(s);i.S.isValidElement(n)&&(this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(s,-1));const r=i.S.impossibleIndex3();s!==e&&this.getEdgeSweepNode(s)!==r&&(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(t,e){const s=this.m_sweepStructure.getElement(t);return this.m_sweepComparator.compare(this.m_sweepStructure,s,e),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(t,e),!0)}fixIntersection_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t),i=this.m_sweepStructure.getElement(e);let r=null,o=null;const a=this.getEdgeOriginVertices(s),h=this.m_edgeVertices.getFirstElement(a),m=this.getEdgeOriginVertices(i),l=this.m_edgeVertices.getFirstElement(m),u=this.m_shape.querySegment(h,this.m_segBuf1,!1,!1);(0,n.g)(u),r=this.m_segBuf1.get();const c=this.m_shape.getNextVertex(h),g=this.m_shape.getWeight(h),_=this.m_shape.getSegmentParentageBreakVertex(h),d=this.m_shape.getWeight(c),p=this.m_shape.getSegmentParentageBreakVertex(c),f=this.m_shape.getSegmentWeight(h),x=this.m_shape.getRank(h),P=this.m_shape.getRank(c),y=this.m_shape.getSegmentRank(h),E=this.m_shape.getSegmentParentage(h),C=this.m_shape.querySegment(l,this.m_segBuf2,!1,!1);(0,n.g)(C),o=this.m_segBuf2.get();const S=this.m_shape.getNextVertex(l),v=this.m_shape.getWeight(l),b=this.m_shape.getSegmentParentageBreakVertex(l),I=this.m_shape.getWeight(S),w=this.m_shape.getSegmentParentageBreakVertex(S),D=this.m_shape.getSegmentWeight(l),T=this.m_shape.getRank(l),N=this.m_shape.getRank(S),A=this.m_shape.getSegmentRank(l),G=this.m_shape.getSegmentParentage(l);this.m_segmentIntersector.pushSegment(r,g,x,d,P,f,y,_,p,E),this.m_segmentIntersector.pushSegment(o,v,T,I,N,D,A,b,w,G),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,i,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e);let i=null;const r=this.getEdgeOriginVertices(s),o=this.m_edgeVertices.getFirstElement(r),a=this.m_shape.querySegment(o,this.m_segBuf1,!1,!1);(0,n.g)(a),i=this.m_segBuf1.get();const h=this.m_shape.getNextVertex(o),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),u=this.m_shape.getWeight(h),c=this.m_shape.getSegmentParentageBreakVertex(h),g=this.m_shape.getSegmentWeight(o),_=this.m_shape.getRank(o),d=this.m_shape.getRank(h),p=this.m_shape.getSegmentRank(o),f=this.m_shape.getSegmentParentage(o),x=this.getClusterFirstVertex(t);this.m_segmentIntersector.pushSegment(i,m,_,u,d,g,p,l,c,f),this.m_shape.queryPoint(x,this.m_helperPoint);const P=this.m_shape.getWeight(x),y=this.m_shape.getRank(x);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,y,P,!0),this.splitEdge_(s,-1,t,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let t=!0,e=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||e>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,t=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);i.S.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),e++):r!==i.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),o=this.getClusterXY(s);if(r.P.sqrDistance(n,o)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const a=n.compare(this.m_sweepPoint),h=o.compare(this.m_sweepPoint);return a<=0&&h>0?s:h<=0&&a>0?e:a>0&&h>0?i.S.impossibleIndex2():-1}fillEventQueue(){const t=new i.A(0),e=this.m_shape.queryVertexIteratorOnSelection();for(let s=e.next();s!==o.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 R(this.m_shape));const s=r.P.getNAN();s.setNAN();let n=-1;for(let e=0,i=t.size();e<i;e++){const i=t.read(e);if(this.m_shape.getXY(i).isEqualPoint2D(s)){const t=this.m_shape.getUserIndex(i,this.m_vertexClusterIndex);this.mergeClusters_(n,t);continue}n=this.getClusterFromVertex(i),this.m_shape.queryXY(i,s);const r=this.m_eventQ.addBiggestElement(i);this.setClusterEventQNode_(n,r)}}fillEventQueuePass2(){const t=new i.A(0);for(let e=this.m_eventQ.getFirst();-1!==e;e=this.m_eventQ.getNext(e)){const s=this.m_eventQ.getElement(e);t.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(t,0,t.size()),this.progress_(!0);for(let e=0,s=t.size();e<s;e++){const s=t.read(e),i=this.getClusterFromVertex(s),n=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(i,n)}}getAffectedEdges(t,e){const s=this.getClusterFirstEdge(t);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);i.S.isValidElement(s)&&e.push(n),n=this.getNextEdge(n,t)}while(n!==s)}updateClusterXY(t,e,s,i,n){const r=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(r);-1!==e;e=this.m_clusterVertices.getNext(e)){const r=this.m_clusterVertices.getElement(e);this.m_shape.setXYMonotonicPoint2D(r,s),this.m_shape.setWeight(r,i),this.m_shape.setRank(r,n),t&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}}splitEdge_(t,e,s,i){this.dbgCheckEdge_(t),-1!==e&&this.dbgCheckEdge_(e),this.disconnectEdge_(t),-1!==e&&this.disconnectEdge_(e),this.processSplitHelper1_(0,t,i),-1!==e&&this.processSplitHelper1_(1,e,i),-1!==s&&i.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t],s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1))}const n=this.getEdgeOriginVertices(t),r=-1!==e?this.getEdgeOriginVertices(e):-1;if(this.applyIntersectorToEditShape_(n,i,0),-1!==r)this.applyIntersectorToEditShape_(r,i,1);else{const t=i.getResultPoint().getXY();this.updateClusterXY(i.getResultPointChanged(),s,t,i.getResultPointWeight(),i.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(t,i,0),-1!==e&&this.createEdgesAndClustersFromSplitEdge_(e,i,1),this.m_edgeVertices.deleteList(n),this.deleteEdge_(t),-1!==e&&(this.m_edgeVertices.deleteList(r),this.deleteEdge_(e));for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let s=this.getClusterEventQNode(e);if(-1===s){const t=this.getClusterFirstVertex(e);if(s=this.m_eventQ.addUniqueElement(t),-1===s){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),i=this.getClusterFromVertex(s);this.mergeClusters_(i,e)}else this.setClusterEventQNode_(e,s)}}this.m_modifiedClusters.length=0}getClusterXY(t){const e=this.getClusterFirstVertex(t);return this.m_shape.getXY(e)}getClusterFirstVertex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}dbgCheckEdge_(t){}dbgCheckCluster_(t){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(t){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new Y(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const t=[];let e=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=i.S.impossibleIndex2(),r=i.S.impossibleIndex3();for(let i=this.m_eventQ.getFirst();-1!==i;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(i);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const e=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===e,!a){let s=e;do{const e=this.getEdgeSweepNode(s);-1===e?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):e!==r&&t.push(e),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==e)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),t.length>0){this.m_bContinuingSegmentChainOptimization=1===t.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let e=0,s=t.length;e<s;e++){const s=this.m_sweepStructure.getElement(t[e]);this.setEdgeSweepNode_(s,n)}let e=n,s=n;for(let i=0,r=t.length;i<r;i++){const r=t[i];if(e===n){const t=this.m_sweepStructure.getPrev(r);if(-1!==t){const s=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(s)!==n&&(e=t)}else e=-1}if(s===n){const t=this.m_sweepStructure.getNext(r);if(-1!==t){const e=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(e)!==n&&(s=t)}else s=-1}if(e!==n&&s!==n)break}for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.m_sweepStructure.getElement(s);this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(i,-1)}t.length=0,this.m_prevNeighbour=e,this.m_nextNeighbour=s,-1!==e&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(e,s):-1===e&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===e&&(e=new X(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 k(this.m_shape)),s.setPoint(this.m_sweepPoint),i=this.m_eventQ.searchUpperBound(s)):i=this.m_eventQ.getNext(i)}return this.m_bCracked}setEditShape_(t){this.m_shape=t,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(t.getSelectedCount()+32),this.m_clusters.setCapacity(t.getSelectedCount()),this.m_clusterVertices.reserveLists(t.getSelectedCount()),this.m_clusterVertices.reserveNodes(t.getSelectedCount()),this.m_edgeVertices.reserveLists(t.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(t.getSelectedCount()+32);for(let e=this.m_shape.getFirstGeometry();e!==o.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!==o.n;s=this.m_shape.getNextPath(s)){const e=this.m_shape.getPathSize(s),i=this.m_shape.getFirstVertex(s);if(i===o.n)continue;let n=this.m_shape.getNextVertex(i);if(n===o.n||n===i)continue;let r=-1;t.selected(i)&&(r=this.newCluster_(i));let a=-1;-1!==r&&t.selected(n)&&(a=this.newEdge_(i),this.addEdgeToCluster(a,r));let h=a;for(let t=0,s=e-2;t<s;t++){const t=this.m_shape.getNextVertex(n);let e=-1;if(this.m_shape.selected(n)){const s=this.newCluster_(n);-1!==h&&this.addEdgeToCluster(h,s),this.m_shape.selected(t)&&(e=this.newEdge_(n),this.addEdgeToCluster(e,s))}h=e,n=t}if(this.m_shape.isClosedPath(s)){const t=this.m_shape.getNextVertex(n);if(this.m_shape.selected(n)){const e=this.newCluster_(n);if(-1!==h&&this.addEdgeToCluster(h,e),this.m_shape.selected(t)){const t=this.newEdge_(n);this.addEdgeToCluster(t,e),this.addEdgeToCluster(t,r)}}}else{let t=-1;this.m_shape.selected(n)&&(t=this.newCluster_(n),-1!==h&&this.addEdgeToCluster(h,t))}}else for(let t=this.m_shape.getFirstPath(e);t!==o.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,i=this.m_shape.getPathSize(t);s<i;s++)this.m_shape.selected(e)&&this.newCluster_(e),e=this.m_shape.getNextVertex(e)}this.fillEventQueue()}progress_(t=!1){}dbgCheckSweepStructure_(){}}function B(t){for(let e=t.getFirstGeometry();e!==o.n;e=t.getNextGeometry(e))if((0,n.h)(t.getGeometryType(e)))return!0;return!1}function H(t,e,s,i,n){if(!B(e))return!1;let r=new O(n);if(r.m_shape=e,r.m_tolerance=s,r.m_bAllowCoincident=t,r.m_bNeedsNonSimpleResult=null!==i,r.needsCrackingImpl_())return i&&i.assign(r.m_nonSimpleResult),!0;const o=new m.T;o.setSwapCoordinates(),e.applyTransformation(o),r=new O(n),r.m_shape=e,r.m_tolerance=s,r.m_bAllowCoincident=t,r.m_bNeedsNonSimpleResult=null!==i;const a=r.needsCrackingImpl_();return e.applyTransformation(o),!!a&&(i&&i.assign(r.m_nonSimpleResult),!0)}function z(t,e,s,i){const r=e.getGeometryType();if((0,n.h)(r))return new O(i).crackAWithBMultiPath_(t,e,s);(0,n.b)("crack_A_with_B")}function U(t,e){return{t,index:e}}class O{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 o.S,s=new o.S,r=a.J.constructEmpty(),h=a.J.constructEmpty(),m=!1,l=new i.P,u=new T,c=this.m_shape.getTotalPointCount(),g=c*c*2,_=this.m_shape.queryVertexIteratorOnSelection();for(let i=_.next();i!==o.n;i=_.next()){const a=this.m_shape.getGeometryType(_.currentGeometry());let c=1,d=1,p=1,f=0,x=0,P=0;const y=this.m_shape.getSegmentParentage(i);let E=!1,C=!1,S=null,v=!1;if((0,n.j)(a))c=this.m_shape.getWeight(i),f=this.m_shape.getRank(i);else{if(S=this.getSegment_(i,e),null===S)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);d=this.m_shape.getWeight(t),x=this.m_shape.getRank(t),C=this.m_shape.getSegmentParentageBreakVertex(t)}if(S.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),S.isDegenerate(this.m_tolerance)){if(!S.isDegenerate(0))continue;v=!0,S=null}}const b=new o.V({copy:_});let I=b.next();I!==o.n&&(I=b.next());let w=0;for(;I!==o.n;I=b.next()){if(0!==w){w--;continue}if(this.m_shape.getTotalPointCount()>g)return t;this.progress_();const a=this.m_shape.getGeometryType(b.currentGeometry());let D=null,T=!1,N=0,A=0,G=0,M=0,q=0,F=0,V=!1,Y=!1;const X=this.m_shape.getSegmentParentage(I);if((0,n.j)(a))N=this.m_shape.getWeight(I),M=this.m_shape.getRank(I);else{if(D=this.getSegment_(I,s),null===D)continue;const t=this.m_shape.getVertexIndex(I);N=this.m_shape.getWeightWithIndex(t),M=this.m_shape.getRankWithIndex(t),G=this.m_shape.getSegmentWeightWithIndex(t),F=this.m_shape.getSegmentRankWithIndex(t),V=this.m_shape.getSegmentParentageBreakVertex(I);{const t=this.m_shape.getNextVertex(I);A=this.m_shape.getWeight(t),q=this.m_shape.getRank(t),Y=this.m_shape.getSegmentParentageBreakVertex(t)}if(D.queryLooseEnvelope(h),D.isDegenerate(this.m_tolerance)){if(!D.isDegenerate(0))continue;T=!0,D=null}}let R=0,k=0;if(null!==S&&null!==D)r.isIntersectingNe(h)&&0!==(0,o.N)(!0,!0,S,D,this.m_tolerance,!0)&&(u.pushSegment(S,c,f,d,x,p,P,E,C,y),u.pushSegment(D,N,M,A,q,G,F,V,Y,X),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&&(w+=k-1),u.clear());else if(null!==S){const e=this.m_shape.getXY(I);if(r.contains(e)){if(u.pushSegment(S,c,f,d,x,p,P,E,C,y),this.m_shape.queryPoint(I,l),u.intersect2DEx(this.m_tolerance,l,M,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=o.n;for(let e=this.m_shape.getNextVertex(I);e!==o.n&&e!==I&&(D=this.getSegment_(e,s),t=e,null!=D&&D.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=I;e!==o.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===D)continue;{const e=this.m_shape.getXY(i);if(h.inflateCoords(this.m_tolerance,this.m_tolerance),h.contains(e)){if(u.pushSegment(D,N,M,A,q,G,F,V,Y,X),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),w+=k-1,v){let t=o.n;for(let e=this.m_shape.getNextVertex(i);e!==o.n&&e!==i&&(D=this.getSegment_(e,s),t=e,null!=D&&D.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=i;e!==o.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(;S=this.getSegment_(i,e),null!=S&&(S.queryEnvelope(r),S.isDegenerate(this.m_tolerance));){if(!(R>1)){t=!0;break}i=_.next(),R--,(0,n.g)(i!==o.n)}if(t)break}}}return t}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new L(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let t=!1;const e=new i.A(0);e.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let t=0,i=s.next();i!==o.n;++t,i=s.next())e.write(t,i);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),e.add(o.n);const a=this.m_shape.createUserIndex(),h=this.m_shape.createUserIndex();this.m_sweepComparator=new y(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let m=null;const u=[],c=[];let g=0;const _=new r.P;for(let s=e.read(g++);s!==o.n;){this.m_shape.queryXY(s,_);let i=!1;do{let t=this.m_shape.getNextVertex(s),n=this.m_shape.getPrevVertex(s);i||=t!==o.n||n!==o.n,t===o.n||this.m_shape.selected(t)||(t=o.n),n===o.n||this.m_shape.selected(n)||(n=o.n),t!==o.n&&this.m_shape.compareVerticesSimpleY(s,t)<0&&(c.push(s),c.push(t)),n!==o.n&&this.m_shape.compareVerticesSimpleY(s,n)<0&&(c.push(n),c.push(n));const r=this.m_shape.getUserIndex(s,a);-1!==r&&(u.push(r),this.m_shape.setUserIndex(s,a,-1));const m=this.m_shape.getUserIndex(s,h);-1!==m&&(u.push(m),this.m_shape.setUserIndex(s,h,-1)),s=e.read(g++)}while(s!==o.n&&this.m_shape.isEqualXYPoint2D(s,_));if(!i&&(null===m&&(m=new E(this.m_shape,this.m_tolerance)),m.setPoint(_),this.m_sweepStructure.searchUpperBound(m),m.intersectionDetected())){t=!0,this.m_bNeedsNonSimpleResult&&((0,n.c)("needsCrackingIMpl_"),this.m_nonSimpleResult=new l(6,-1,-1));break}let d=1===u.length&&2===c.length;const p=32;u.length>p&&(0,r.p)(u);let f=-1,x=-1;if(!d)for(let e=0,s=u.length;e<s;e++){const s=u[e],i=this.m_sweepStructure.getPrev(s);if(-1!==i&&-1===u.indexOf(i))if(-1===f)f=i;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new l(6,-1,-1)}const n=this.m_sweepStructure.getNext(s);if(-1!==n&&-1===u.indexOf(n))if(-1===x)x=n;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new l(6,-1,-1)}if(-1!==f&&-1!==x)break}if(t&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(_.y,_.x),!d){for(let t=0,e=u.length;t<e;t++){const e=u[t];this.m_sweepStructure.deleteNode(e)}u.length=0}if(!d&&-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=c.length;e<s;e+=2){const s=c[e],i=c[e+1];let n;if(d?(n=this.m_sweepStructure.replaceElementAtPosition(u[0],s,!0,!0),u.length=0,d=!1):n=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),t=!0;break}-1===this.m_shape.getUserIndex(i,a)?this.m_shape.setUserIndex(i,a,n):this.m_shape.setUserIndex(i,h,n)}if(t)break;c.length=0}return this.m_shape.removeUserIndex(a),this.m_shape.removeUserIndex(h),t}checkForIntersections_(t,e){const s=this.m_sweepStructure.getElement(t);this.m_sweepComparator.compare(this.m_sweepStructure,s,e);const i=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),i}getSegment_(t,e){return O.st_getSegment(this.m_shape,t,e)}static st_getSegment(t,e,s){return t.querySegment(e,s,!1,!1)?s.get():null}dbgPrintSweepEdge(t){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(t=null){}dbgCheckSweepStructure(){}progress_(t=!1){this.m_progressCounter++}crackAWithBMultiPath_(t,e,s){const r=a.J.constructEmpty();t.queryLooseEnvelope(r);const h=a.J.constructEmpty();if(e.queryLooseEnvelope(h),h.inflateCoords(s,s),!h.isIntersecting(r))return t;const m=t.getImpl(),l=m.getAccelerators();let u=null,c=null;l&&(c=l.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))&&(u=(0,i.w)(m,h),c=u);const g=c?c.getIteratorForQT():null,_=e.querySegmentIterator(),d=t.querySegmentIterator(),p=new Array(15),f=[];for(;_.nextPath();)for(;_.hasNextSegment();){const t=_.nextSegment();if(c){g.resetIterator(t,s);for(let e=g.next();-1!==e;e=g.next()){this.progress_();const i=c.getElement(e);if(d.resetToVertex(i,-1),d.hasNextSegment()){const e=d.nextSegment().intersect(t,null,p,null,s);for(let t=0;t<e;t++){const e=p[t];if(0===e||1===e)continue;const s=U(e,d.getStartPointIndex());f.push(s)}}}}else{const e=a.J.constructEmpty();if(t.queryLooseEnvelope(e),e.inflateCoords(s,s),!r.isIntersecting(e))continue;for(d.resetToFirstPath();d.nextPath();)for(;d.hasNextSegment();){const i=d.nextSegment(),n=a.J.constructEmpty();if(i.queryLooseEnvelope(n),!n.isIntersecting(e))continue;const r=i.intersect(t,null,p,null,s);for(let t=0;t<r;t++){const e=p[t];if(0===e||1===e)continue;const s=U(e,d.getStartPointIndex());f.push(s)}}}}if(0===f.length)return t;f.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 x=t.createInstance();for(x.getGeometryType()===n.G.enumPolygon&&x.setFillRule(t.getFillRule()),d.resetToFirstPath();d.nextPath()&&!d.hasNextSegment(););(0,n.g)(d.hasNextSegment());let P=d.nextSegment();const y=new o.S;let E=-1;for(let t=0,e=f.length;t<e;){const s=f[t].index;let i=t+1;for(;i<e&&f[i].index===s;)++i;for(;d.getStartPointIndex()<s;){this.progress_();const t=d.hasNextSegment(),e=d.getPathIndex();if((t||!d.isClosingSegment()||d.isCurve())&&((0,n.g)(null!==P),x.addSegment(P,E!==e)),E=e,!t){for(d.isPathClosed();d.nextPath()&&!d.hasNextSegment(););(0,n.g)(d.hasNextSegment())}P=d.nextSegment()}let r=0;for(let e=t;e<i;e++){const t=f[e].t;if(t===r)continue;(0,n.g)(null!==P),P.queryCut(r,t,y),r=t;const s=d.getPathIndex();x.addSegment(y.get(),E!==s),E=s}const o=d.hasNextSegment();if((o||!d.isClosingSegment()||d.isCurve())&&((0,n.g)(null!=P),P.queryCut(r,1,y),x.addSegment(y.get(),!1)),o)P=d.nextSegment();else{for(;d.nextPath()&&!d.hasNextSegment(););P=d.hasNextSegment()?d.nextSegment():null}t=i}if(null!==P){const t=d.getPathIndex();(d.hasNextSegment()||!d.isClosingSegment()||d.isCurve())&&x.addSegment(P,E!==t),E=t}let C=d.hasNextSegment();for(;;){if(!C){for(;d.nextPath()&&(C=d.hasNextSegment(),!C););if(!C)break}P=d.nextSegment();const t=d.getPathIndex();C=d.hasNextSegment(),(C||!d.isClosingSegment()||d.isCurve())&&x.addSegment(P,E!==t),E=t}return x}constructor(t){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new l,this.m_tolerance=0,this.m_sweepComparator=null,this.m_progressCounter=0,this.m_bTrackChanges=!1,this.m_bNeedsNonSimpleResult=!1,this.m_bAllowCoincident=!0,this.m_sweepStructure=new i.T,this.m_progressTracker=t}}function W(){return Number.isNaN(this.radius.value())}function j(t,e,s,i){return{pt:t.clone(),t:e,err:s,checkCount:i}}O.s_bForceBruteForce=!0;class J{constructor(t,e,s,i,n){this.m_left=t,this.m_tracker=n,this.m_eps=s,this.m_trackerCounter=0,this.m_tolerance=i,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc={ptStart:new r.P,ptEnd:new r.P,center:new o.T,radius:new r.I,fcenter:new o.R,fradius2:new r.M,maxError:Number.NaN,isLine:W}}closeToCircularArc(t,e,s,i,n,a){if(this.m_circleCheckCounter++,a.maxError=0,!J.checkSweepAngle(t,e))return!1;if(a.ptStart.setCoordsPoint2D(s),a.ptEnd.setCoordsPoint2D(n),t.isCircular()){const e=t;return a.fradius2=r.M.constructDouble(e.getSemiMajorAxis()).mulDouble(e.getSemiMajorAxis()),a.radius.set(e.getSemiMajorAxis()),a.fcenter.assignPoint2D(e.getCenter()),a.center.set(e.getCenter()),!0}const h=a.ptEnd.sub(a.ptStart).clone();if(h.leftPerpendicularThis(),h.normalize(),Math.abs(h.dotProduct(i.sub(a.ptStart)))<=this.m_eps)return!!this.confirmIsLine(a,h)&&(a.radius.set(Number.NaN),a.center.setCoords(0,0),!0);{const s=a.ptEnd.sub(a.ptStart),n=i.sub(a.ptStart),r=s.crossProduct(n);if(0===r)return!1;const o=.5*s.sqrLength(),h=.5*n.sqrLength();let m=o*n.y-h*s.y;m/=r;let l=s.x*h-n.x*o;l/=r;const u=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*u>this.m_eps)return!1;const c=m+a.ptStart.x,g=l+a.ptStart.y;a.radius.set(u),a.center.setCoords(c,g);const _=this.maxCircleApproximationError(t,e,a);if(_>this.m_eps)return a.maxError=_,!1}const m=(new o.R).assignPoint2D(a.ptStart),l=(new o.R).assignPoint2D(a.ptEnd).sub(m),u=(new o.R).assignPoint2D(i).sub(m),c=l.crossProduct(u);if(c.isZero())return!1;const g=l.sqrLength().mulDouble(.5),_=u.sqrLength().mulDouble(.5),d=g.mul(u.y).sub(_.mul(l.y)),p=l.x.mul(_).sub(u.x.mul(g)),f=d.mul(d).add(p.mul(p)),x=c.clone();x.invertThis(),a.fradius2=f.mul(x).mul(x),a.fcenter.setCoords(d.mul(x).add(m.x),p.mul(x).add(m.y)),a.center.setWithEps(a.fcenter.asPoint2D()),a.radius.setWithEps(Math.sqrt(a.fradius2.toDouble()));const P=o.T.constructPoint2D(a.ptStart).subE(a.center),y=o.T.constructPoint2D(a.ptEnd).subE(a.center);if(!P.dotProduct(y).gt(r.F))return!1;const E=this.maxCircleApproximationError(t,e,a);return a.maxError=E,E<=this.m_eps}static checkSweepAngle(t,e){if(t.getGeometryType()===n.G.enumEllipticArc){const s=t,i=(0,o.U)(s,e.vmin),n=(0,o.U)(s,e.vmax);return!(Math.abs(n-i)>.5*r.t)}return!0}confirmIsLine(t,e){const s=t.ptEnd.sub(t.ptStart);return!(Math.abs(e.dotProduct(s.mul(.25)))>this.m_eps||Math.abs(e.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(t,e,s){const i=[.25,.75],o=[.1,.25,.75,.9];let a,h;t.getGeometryType()===n.G.enumEllipticArc?(a=i,h=i.length):(a=o,h=o.length);let m=0;for(let i=0;i<h;++i){const n=new r.P;t.queryCoord2D((0,r.w)(e.vmin,e.vmax,a[i]),n);const o=n.sub(s.center.value()).length(),h=Math.abs(o-s.radius.value());h>m&&(m=h)}return m}approximateWithCirclesImpl(t,e){let s=1;e&&e.push(0);const i=(0,r.f)(9,Number.NaN);let n;t?n=this.m_left.getMonotonicPartParams(i.length,i):(i[0]=0,i[1]=1,n=2);const o=[],a=[],h=new r.P(0,0);for(let t=1;t<n;t++){const n=new r.E(i[t-1],i[t]);for(this.m_bReversedLeft=!J.goodOrientation(this.m_left,n),this.m_bReversedLeft?(o.push(j(h,n.vmin,0,0)),o.push(j(h,n.vmax,0,0))):(o.push(j(h,n.vmax,0,0)),o.push(j(h,n.vmin,0,0))),o[0].pt=this.m_left.getCoord2D(o[0].t),o[1].pt=this.m_left.getCoord2D(o[1].t);o.length>1;){this.progress_();const t=o.at(-1);let i=t.checkCount,n=t.err;const h=t.pt.clone(),m=t.t,l=o[o.length-2].t,u=.5*(m+l),c=this.m_left.getCoord2D(u);if(n<=this.m_eps||i>=5){const t=new r.E;if(t.setCoords(m,l),this.closeToCircularArc(this.m_left,t,h,c,o[o.length-2].pt,this.m_leftArc)){e&&(this.m_bReversedLeft?a.push(m):e.push(l)),s++,o.pop();continue}i=0,n=this.m_leftArc.maxError}t.t=u,t.pt.setCoordsPoint2D(c),n*=.125,i++,t.err=n,t.checkCount=i,o.push(j(h,m,n,i))}this.m_bReversedLeft&&e&&(e.length=e.length+a.length,(0,r.a)(e,a.reverse(),e.length-a.length,0,a.length),a.length=0),o.length=0}return s}approximateWithCirclesImplPolyline(t){const e=new o.a,s=[];if(!this.approximateWithCirclesImpl(!0,s))return e;let i=0;const n=this.m_left.getStartXY();e.startPath(n);for(let a=1;a<s.length;++a)if(t)e.lineTo(this.m_left.getCoord2D(s[a]));else{const t=new r.P;this.m_left.queryCoord2D(s[a],t);const h=new r.P;this.m_left.queryCoord2D(.5*(s[a]+i),h);const m=new o.p;m.constructCircularArcThreePoint(n,t,h),e.addSegment(m,!1),n.assign(t),i=s[a]}return e}static goodOrientation(t,e){const s=t.getCoord2D(e.vmin),i=t.getCoord2D(e.vmax);return s.compare(i)<0}progress_(t=!1){}}function Z(t,e,s,i,n,r,o){!function(t,e,s,i,n,r){t.hasCurves()?(t.setCurveStitcherPointer(i),i.m_impl=new it(r,!1,null),i.m_impl.buildMonotonicCurveParentage(t,e,s,n)):i.m_impl=null}(t,e,s,n,r,o)}function Q(t,e,s,r){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 o.E;const m=new i.P,l=new o.S,u=[],c=[],g=[],_=t.getDescription().getAttributeCount()>1,d=a.querySegmentIterator();for(;d.nextPath();){let t=!0;for(;d.hasNextSegment();){const i=d.isClosingSegment(),r=d.nextSegment();if(!r.isCurve()){h.addSegment(r,t,i),t=!1;continue}let a,p=!1;const f=!0,x=!0;switch(r.getGeometryType()){case n.G.enumEllipticArc:case n.G.enumRationalBezier2:a=(0,o.B)(r,e,s,f,x,c,g,u),p=!0;break;default:a=(0,o.A)(r,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)),_&&t&&(r.queryCoord(u[0],m),l.get().setStart(m)),_&&(r.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))),_&&(r.queryCoord(u[t+1],m),l.get().setEnd(m)),h.addSegment(l.get(),!1,i&&t+1===e)}}return h}function K(t,e,s,i,n,r,o,a){t.hasCurves()?(t.setCurveStitcherPointer(r),r.m_impl=new it(a,!0,n),r.m_impl.buildMonotonicCurveParentage(t,e,s,o),function(t,e,s){ht.fixCurveTwoPointLoops(t,e,s)}(t,s,a)):r.m_impl=null}function $(t,e){return e||(e=a.J.constructEmpty()),function(t,e){let s=e.isEmpty()?t:(0,i.a)(null,e,!0).total();return s>t&&(s=t),.125*s}(t,e)}function tt(t,e){return.125*t}function et(t,e){return 3*t+3*e}class st{constructor(){this.m_impl=null}stitchCurves(t,e,s,i){this.m_impl&&(this.m_impl.stitchCurves(t,e,s),i&&this.clearStitcher(t))}clearStitcher(t){this.m_impl&&(this.m_impl.clearStitcher(t),this.m_impl=null)}getOriginalVertexIndex(t,e){return this.m_impl.getOriginalVertexIndex(t,e)}getOriginalSegmentTypeInfo(t){return this.m_impl.getOriginalSegmentTypeInfo(t)}}class it{constructor(t,e,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=t,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=0,this.m_progressCounter=0,this.m_bIsSimple=e}buildMonotonicCurveParentage(t,e,s,r){const a=!1;if(!t.hasCurves())return;(0,n.g)(!t.hasSegmentParentage()),this.m_type=1,this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=t.createUserIndex()),this.m_tolerance=s;const h=new i.P,m=new o.S,u=[],c=[],g=[];for(let i=t.getFirstGeometry();i!==o.n;i=t.getNextGeometry(i))for(let r=t.getFirstPath(i);r!==o.n;r=t.getNextPath(r)){let i=t.getPathSize(r),_=t.getFirstVertex(r),d=0,p=-1;for(let f=0;f<i;f++){let x=t.getNextVertex(_);if(!t.querySegment(_,m,!0,!1)){_=x;continue}if(0===d){p=t.getVertexIndex(_);const e=it.regularizeCurve(t,m.get(),_,s);if(e>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new l(13,p,-1)),d=e,i=t.getPathSize(r),x=t.getNextVertex(_);const s=t.querySegment(_,m,!0,!1);(0,n.g)(s)}}else d--;const P=t.getVertexIndex(_);let y;-1!==this.m_originalVertexIndex&&t.setUserIndex(_,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,o.B)(m.get(),e,s,a,!0,c,g,u),E=!0;break;default:{const t=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();y=(0,o.A)(m.get(),e,s,t,a,c,u)}}const C=this.m_originalPlanarSegments.length;if(t.setSegmentParentageAndBreak(_,C,!0),!c[1].isNAN()){let e=null;e=E?new o.Q({points:c,weights:g}):new o.F({cp:c}),e.snapControlPoints(s*s),t.setSegmentToIndex(P,e)}const S=E?2:3;for(let e=1,i=y,n=S;e<i;++e,n+=S){m.get().queryCoord(u[e],h);const i=t.insertVertex(r,x,h);if(-1!==this.m_originalVertexIndex&&t.setUserIndex(i,this.m_originalVertexIndex,p),!c[n+1].isNAN())if(E){const e=new o.Q({points:c.slice(n),weights:g.slice(n)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(i),e)}else{const e=new o.F({cp:c.slice(n)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(i),e)}t.setSegmentParentageAndBreak(i,C,!1)}y>1&&(f+=y-1,i=t.getPathSize(r)),this.m_originalPlanarSegments.push(m.releaseSegment()),_=x}}}stitchCurves(t,e,s){it.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){it.st_stitchCurvesImpl(null,t,o.n,0,!0)}getOriginalVertexIndex(t,e){return-1!==this.m_originalVertexIndex&&e!==o.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.b)("")}}return-1}progress_(t=!1){this.m_progressCounter++}processSpan_(t,e,s,i,r,a,h){if(e===s&&0===i)return(0,n.g)(t.getNextVertex(e)===o.n),t.setSegmentToIndex(t.getVertexIndex(e),null),void t.setSegmentParentageAndBreak(e,-1);const m=t.getNextVertex(e);{let e=2;for(let i=m;i!==s;i=t.getNextVertex(i))e++;(0,n.g)(e===i)}if(null===r){t.setSegmentToIndex(t.getVertexIndex(e),null);for(let e=m;e!==s;)e=t.removeVertex(e,!0);return}const l=t.getXY(e),u=t.getXY(s);if(r.isClosed()){if(l.isEqualPoint2D(u)&&l.isEqualPoint2D(r.getStartXY())){let n;if(n=this.verifySegmentFitness(t,e,s,i,r,a,h)){const i=r.clone();return i.dropAllAttributes(),n<0&&i.reverse(),this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),i)}}}else if(l.isEqualPoint2D(r.getStartXY())){if(u.isEqualPoint2D(r.getEndXY())){const n=r.clone();if(n.dropAllAttributes(),this.verifySegmentFitness(t,e,s,i,n,a,h))return this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),n)}}else if(u.isEqualPoint2D(r.getStartXY())&&l.isEqualPoint2D(r.getEndXY())){const n=r.getReversed();if(n.dropAllAttributes(),this.verifySegmentFitness(t,e,s,i,n,a,h))return this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),n)}this.processSpanSplitSegment(t,e,s,i,r,a,h)}processSpanSplitSegment(t,e,s,i,n,o,a){if(n.isLine())return;if(this.fitSegmentToSpan(t,e,s,i,n,o,a))return;const h=a*a;let m=i,l=e;const u=t.getXY(e);let c=n.getClosestCoordinate(u,!1);const g=n.getCoord2D(c);let _=!1;const d=r.P.sqrDistance(u,g);if(d>h){const i=t.getNextVertex(e);if(this.approximateSpanSection(t,e,n,o,a),i===s)return;l=i,_=!0,m-=1}let p=s;const f=t.getXY(s);c=n.getClosestCoordinate(f,!1);const x=n.getCoord2D(c);let P=!1;const y=r.P.sqrDistance(f,x);if(y>h){const e=t.getPrevVertex(s);if(this.approximateSpanSection(t,e,n,o,a),e===l)return;p=e,P=!0,m-=1}if((_||P)&&this.fitSegmentToSpan(t,l,p,m,n,o,a))return;let E=!1;if(!_&&d>0){const s=t.getNextVertex(e);if(this.approximateSpanSection(t,e,n,o,a),s===p)return;l=s,_=!0,E=!0,m-=1}if(!P&&y>0){const e=t.getPrevVertex(s);if(this.approximateSpanSection(t,e,n,o,a),e===l)return;p=e,P=!0,E=!0,m-=1}if(E&&this.fitSegmentToSpan(t,l,p,m,n,o,a))return;let C=l;for(;;){const e=t.getNextVertex(C);if(this.approximateSpanSection(t,C,n,o,a),C=e,C===p)return}}fitSegmentToSpan(t,e,s,i,a,h,m){const l=0===this.m_type,u=[];if(u.push(t.getXY(e)),l){let r=e;const o=32;if(i>o){const e=BigInt(i-1),a=BigInt(o-1);let h=a,m=0n;for(let s=1;s<i;s++,h+=a)if(r=t.getNextVertex(r),h>=m+e){m+=e;const s=t.getXY(r);u.push(s)}(0,n.g)(r===s)}else{for(let e=1;e<i;e++){r=t.getNextVertex(r);const e=t.getXY(r);u.push(e)}(0,n.g)(r===s)}}else{let n=e;const r=new o.S;for(;;){t.querySegment(n,r,!1,!0);const e=[.1,.25,.4,.5,.6,.75,.9,1];let o=0;for(const t of e)(2===i||1&o)&&u.push(r.get().getCoord2D(t)),o++;if(n=t.getNextVertex(n),n===s)break}}const c=(()=>{let t=u[0].compare(u.at(-1));if(0===t){const e=new r.K(0);(function(t,e,s){if(s.reset(),e<3)return;const i=t[0].clone(),n=i.x,o=i.y,a=t[1].clone(),h=new r.P;for(let n=2;n<e;n++)h.assign(t[n]),s.pe((h.x-i.x)*(a.y-o)),i.assign(a),a.assign(h);s.pe((n-i.x)*(a.y-o))})(u,u.length,e),t=e.getResult()>=0?-1:1}return t>0})();c&&u.reverse();const g=a.clone();if(g.dropAllAttributes(),g.setSegmentFromCoords(u,u.length),c&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitness(t,e,s,i,g,h,m)){this.removeSpan(t,e,s);const i=t.getVertexIndex(e);return t.setSegmentToIndex(i,g),!0}return!1}approximateSpanSection(t,e,s,a,h){const m=new o.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,i,n){const r=(0,o.O)(e),a=Math.max(4*r,s);new J(e,null,a,Number.NaN,n).approximateWithCirclesImpl(!1,i)}(0,m.get(),h,s,this.m_progressTracker);const n=t.getNextVertex(e),a=t.getPathFromVertex(e),l=new i.P;let u=e;for(let e=1,i=s.length;e<i;e++){const i=s[e],h=m.get().getCoord2D(s[e-1]),c=m.get().getCoord2D((0,r.w)(s[e-1],i,.5));m.get().queryCoord(i,l);const g=l.getXY(),_=new o.p;_.constructCircularArcThreePoint(h,g,c);let d=o.n;i<1&&(d=t.insertVertex(a,n,l)),t.setSegmentToIndex(t.getVertexIndex(u),_),u=d}return}{const s=(0,r.m)(r.P,3);m.get().queryControlPoints(s);const i=[0,0,0];m.get().queryWeights(i);const n=(0,o.H)(i),a=new o.p;return(0,o.I)(s,n*n,null,!1,a),void t.setSegmentToIndex(t.getVertexIndex(e),a)}}(0,n.c)("approximate_span_section_")}}verifySegmentFitness(t,e,s,i,n,r,o){return 0===this.m_type?this.verifySegmentFitnessLines(t,e,s,i,n,r,o):this.verifySegmentFitnessCurves(t,e,s,i,n,r,o)}verifySegmentFitnessCurves(t,e,s,i,n,a,h){const m=t.getXY(e),l=t.getXY(s);if(!m.isEqualPoint2D(n.getStartXY())||!l.isEqualPoint2D(n.getEndXY()))return 0;let u=0;if(n.isClosed()){const t=n.getCoord2D(.1).sub(m);u=n.getCoord2D(.7).sub(m).crossProduct(t)>=0?1:-1}const c=new Array(o.J.s_maxMonotonicPartParams);let g=n.getMonotonicPartParams(c.length,c);g--;const _=new o.L,d=[1,.5,.75,.25];let p=0,f=e;const x=m.clone();for(;;){const e=t.getNextVertex(f);let i=t.getSegment(f);null===i&&(t.queryLineConnector(f,_,!0),i=_);for(let t=e===s?1:0;t<d.length;t++){const e=i.getCoord2D(d[t]);if(!n.isCloserThanDistance(e,r.E.unit(),h))return 0}if(g>1)for(let t=1;t<g;){const e=n.getCoord2D(c[t]);i.isCloserThanDistance(e,r.E.unit(),h)?(c[g-1]=(0,r.b)(c[t],c[t]=c[g-1]),g--):t++}if(u){const t=i.getCoord2D(.25);p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t),t.assign(i.getCoord2D(.75)),p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t)}if(f=e,f===s)return g>1?0:u?p<0?-u:u:1}}verifySegmentFitnessLines(t,e,s,i,r,o,a){return(0,n.g)(0),0}removeSpan(t,e,s){t.setSegmentToIndex(t.getVertexIndex(e),null);const i=t.getNextVertex(e);i!==s&&t.removeVertices(i,s)}static st_stitchCurvesImpl(t,e,s,i,n){if(e.hasSegmentParentage())return e.hasCurves()?it.st_stitchCurvesFromCurvesImpl(t,e,s,i,n):it.st_stitchCurvesFromLinesImpl(t,e,s,i,n)}static st_stitchCurvesFromLinesImpl(t,e,s,i,r){let a=s===o.n?e.getFirstGeometry():s;for(;a!==o.n;){for(let s=e.getFirstPath(a);s!==o.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!==o.n;){let c=e.getSegmentParentage(u);if(-1===c||h){h=!1,s++,u=e.getNextVertex(u),m=!0;continue}let g,_,d=0;if(m?(g=e.getPrevVertex(u),_=u,(0,n.g)(g!==o.n),(0,n.g)(_!==g),(0,n.g)(-1===e.getSegmentParentage(g)||l===g)):(g=u,_=e.getNextVertex(g),s++,(0,n.g)(_!==o.n),(0,n.g)(_!==g),c=e.getSegmentParentage(_)),d=2,m=!1,-1===c||e.getSegmentParentageBreakVertex(_)){u=_;continue}let p=e.getNextVertex(_);for(s++;s<a&&p!==o.n;){_=p,d++;const t=e.getSegmentParentage(p);if(-1===t||e.getSegmentParentageBreakVertex(p))break;(0,n.g)(t===c),s++,p=e.getNextVertex(p)}if(!r){const s=t.m_originalPlanarSegments[c];t.processSpan_(e,g,_,d,s,c,i)}u=_}}if(s!==o.n)break;a=e.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(t,e,s,i,r){let a=s===o.n?e.getFirstGeometry():s;for(;a!==o.n;)if((0,n.x)(e.getGeometryType(a))){for(let s=e.getFirstPath(a);s!==o.n;s=e.getNextPath(s)){let a=e.getPathSize(s);const h=e.isClosedPath(s);h&&(a+=1);let m=e.getFirstVertex(s);if(h){if(-1!==e.getSegmentParentage(m)){let t=m;for(let i=0;!e.getSegmentParentageBreakVertex(t);i++){if(i===a){m=e.getFirstVertex(s),e.setSegmentParentageBreakVertex(t,!0);break}t=e.getPrevVertex(t)}}}else(0,n.g)(-1===e.getSegmentParentage(m)||e.getSegmentParentageBreakVertex(m));let l=m;for(let s=0;s<a&&l!==o.n;){const h=e.getSegmentParentage(l);if(-1===h){s++,l=e.getNextVertex(l);continue}let m=0,u=o.n;const c=l;m=1;let g=e.getNextVertex(c);for(;s<a&&g!==o.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===o.n)break;if(!r){const s=t.m_originalPlanarSegments[h];t.processSpan_(e,c,u,m,s,h,i)}l=u}}if(s!==o.n)break;a=e.getNextGeometry(a)}else a=s===o.n?e.getNextGeometry(a):o.n}static regularizeCurve(t,e,s,i){let n=e.snapControlPoints(i*i);if(n){const i=t.getVertexIndex(s),n=e.clone();t.setSegmentToIndex(i,n)}if(e.getGeometryType()===o.F.type){const r=[],o=e.calculateSpecialPointsForCracking(i,r);if(o>0){t.splitSegment(s,r,o),n=t.snapControlPoints(s,o+1,i*i)||n;for(let e=0;e<o;e++)s=t.getNextVertex(s),t.setSegmentParentageBreakVertex(s,!0);return o}}return n?0:-1}}function nt(t,e,s,i,n){return new ht(t,s,e,i,n).do_()}function rt(t,e,s){const n=(0,i.f)(t);return v(e.getX(),e.getY(),s.getX(),s.getY(),(0,r.s)(n))}function ot(t,e,s=1,n=1,r=1,o=1){if(n>o)return t;if(o>n)return e;const a=new i.P;return function(t,e,s,i,n,r,o,a,h){const m=t.equals(e);if(i>r)return o.assignCopy(t),h[0]=i,a[0]=s,m;if(r>i)return o=e,h[0]=r,a[0]=n,m;o.assignCopy(t);const l=b(t.getXY(),e.getXY(),s,i,n,r);o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank}(t,e,s,n,r,o,a,[0],[0]),a}function at(t){return(0,i.f)(t)}class ht{constructor(t,e,s,i,n){this.m_shape=t,this.m_progressTracker=e,this.m_tolerance=s,this.m_bFilterDegenerateSegments=i,this.m_bTrackChanges=n,this.m_progressCounter=0}do_(){const t=new i.C(this.m_tolerance.tolerance,this.m_tolerance.resolution),e=at(t);let s=(0,i.n)(t);const a=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.c)("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let i=-1;0===t&&(i=this.firstCrack_(),h||=i>0);const r=this.cluster_(e);if(this.m_shape.dbgVerifyMonotone(),h||=r,this.m_bFilterDegenerateSegments){const t=0!==this.m_shape.filterClosePoints(e,!0,!1,this.m_bTrackChanges,o.n);h||=t,this.m_shape.dbgVerifyMonotone()}const u=this.m_shape.snapControlPointsOnSelection(a*a);h||=u,this.m_shape.dbgCheckSelection();let c=!1;if((0===t&&-1===i||l||H(!0,this.m_shape,s,null,this.m_progressTracker))&&(c=this.crack_(a),h||=c,this.m_shape.dbgVerifyMonotone()),!c&&!ht.fixCurveTwoPointLoops(this.m_shape,e,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return h&&function(t){if(!t.hasSegmentParentage())return;const e=new i.A(0),s=t.queryVertexIteratorOnSelection();for(let t=s.next();t!==o.n;t=s.next())e.add(t);if(0===e.size())return;t.sortVerticesSimpleByY(e,0,e.size()),e.add(o.n);const n=r.P.getNAN();t.queryXY(e.read(0),n);let a=0;const h=r.P.getNAN();for(let s=1,i=e.size();s<i;s++){{const i=e.read(s);i!==o.n?t.queryXY(i,h):h.setNAN()}if(!h.isEqualPoint2D(n)){let i=!1,r=-2;for(let n=a;n<s;++n){const s=e.read(n);if(t.getSegmentParentageBreakVertex(s)){i=!0;break}let a=t.getSegmentParentage(s);const h=t.getPrevVertex(s);if(h!==o.n){let e=t.getSegmentParentage(h);if(-1===a&&(a=e),-1===e&&(e=a),a!==e){i=!0;break}}if(-2!==r&&a!==r){i=!0;break}r=a}if(i)for(let i=a;i<s;++i)t.setSegmentParentageBreakVertex(e.read(i),!0);n.setCoordsPoint2D(h),a=s}}}(this.m_shape),h}cluster_(t){return S(this.m_shape,t,o.n,this.m_bTrackChanges,this.m_progressTracker)}crack_(t){return function(t,e,s,i){if(!B(t))return!1;const n=new O(i);n.m_shape=t,n.m_tolerance=e,n.m_bTrackChanges=s;let r=!1;const o=t.hasCurves()?5:15;return r=t.getTotalPointCount()<o?n.crackBruteForce_():n.crackerPlaneSweep_(),r}(this.m_shape,t,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(t,e,s){if(!t.hasCurves())return!1;t.dbgVerifyCurves();const a=t.createUserIndexUninitialized(),h=new i.A(0),m=t.queryVertexIteratorOnSelection();for(let e=m.next();e!==o.n;e=m.next())h.add(e),t.setUserIndex(e,a,-1);if(0===h.size())return!1;h.add(o.n),t.sortVerticesSimpleByY(h,0,h.size()-1);let l=0;const u=t.getXY(h.read(l)),c=new r.P(Number.NaN,Number.NaN),g=[];for(let e=1,s=h.size();e<s;++e){const s=h.read(e),i=s!==o.n?t.getXY(s):c;if(i.equals(u))continue;const n=[];for(let s=l;s<e;s++){const e=h.read(s),i=t.getPrevVertex(e);if(i!==o.n&&-1===t.getUserIndex(i,a)){const e=mt(t.getXY(i),t.getSegment(i));0!==r.P.sqrDistance(u,e.otherPt)&&(e.vert=i,e.dir=-1,n.push(e)),t.setUserIndex(i,a,1)}const m=t.getNextVertex(e);if(m!==o.n&&-1===t.getUserIndex(e,a)){const s=mt(t.getXY(m),t.getSegment(e));0!==r.P.sqrDistance(u,s.otherPt)&&(s.vert=e,s.dir=1,n.push(s)),t.setUserIndex(e,a,1)}}if(n.length>1){n.sort(((t,e)=>ut(t,e)));const t=mt(c.clone(),null);n.push(t);let e=0;for(let t=1,s=n.length;t<s;t++)if(!n[t].otherPt.equals(n[t-1].otherPt)){if(t-e>1&&null!==n[e].seg){let s=!1;const i=e;for(let r=e+1;r<t;r++)if(!lt(n[i],n[r])){s=!0;break}if(s)for(let s=e;s<t&&null!==n[s].seg;s++)g.push(n[s].vert)}e=t}}l=e,u.setCoordsPoint2D(i)}for(const s of g){const i=t.getSegment(s);(0,n.g)(null!==i);const o=t.getXY(s),a=t.getXY(t.getNextVertex(s));if(r.P.distance(o,a)<3*e)t.setSegmentToIndex(t.getVertexIndex(s),null);else{const e=i.lengthToT(.5*i.calculateLength2D());t.splitSegment(s,[e],1)}}return t.removeUserIndex(a),g.length>0}firstCrack_(){const t=this.m_shape.getEnvelope2D(this.m_progressTracker),e=(0,i.a)(null,t,!0).total();if(4*e<this.m_tolerance.total()){let t=!1;const s=1.1*e,i=e,n=this.cluster_(s);t||=n;let r=0;this.m_bFilterDegenerateSegments&&(r=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,o.n));const a=this.crack_(i);return t||=a,t?1:r?2:0}return-1}progress_(t=!1){this.m_progressCounter++,!t&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function mt(t,e){return{otherPt:t,seg:e,vert:-1,dir:0}}function lt(t,e){if((0,n.g)(t.otherPt.equals(e.otherPt)),null===t.seg)return null===e.seg;if(null===e.seg)return!1;const s=t.seg.getGeometryType();if(s!==e.seg.getGeometryType())return!1;if(s===n.G.enumBezier){const s=t.seg,i=e.seg;let n=s.getControlPoint1(),o=s.getControlPoint2();-1===t.dir&&(o=(0,r.b)(n,n=o));let a=i.getControlPoint1(),h=i.getControlPoint2();return-1===e.dir&&(h=(0,r.b)(a,a=h)),n.equals(a)&&o.equals(h)}if(s===n.G.enumRationalBezier2){const s=t.seg,i=e.seg,n=s.getControlPoint1(),o=i.getControlPoint1();if(!n.equals(o))return!1;const a=[0,0,0];s.queryWeights(a),-1===t.dir&&(a[2]=(0,r.b)(a[0],a[0]=a[2]));const h=[0,0,0];return i.queryWeights(h),-1===e.dir&&(h[2]=(0,r.b)(h[0],h[0]=h[2])),a[0]===h[0]&&a[1]===h[1]&&a[2]===h[2]}(0,n.c)("")}function ut(t,e){const s=t.otherPt.compare(e.otherPt);return 0!==s?s:function(t,e){if(null===t.seg||null===e.seg)return null!==t.seg?-1:null!==e.seg?1:0;const s=t.seg.getGeometryType(),i=e.seg.getGeometryType();return s<i?-1:s>i?1:0}(t,e)}},95213:(t,e,s)=>{s.d(e,{$:()=>$,A:()=>I,B:()=>R,C:()=>K,D:()=>q,E:()=>Ft,F:()=>F,G:()=>c,H:()=>N,I:()=>O,J:()=>X,K:()=>P,L:()=>y,M:()=>tt,N:()=>rt,O:()=>u,P:()=>At,Q:()=>E,R:()=>C,S:()=>k,T:()=>U,U:()=>S,V:()=>g,W:()=>Y,X:()=>bt,Y:()=>it,Z:()=>nt,_:()=>x,a:()=>ot,a0:()=>Tt,a1:()=>ut,a2:()=>wt,a3:()=>Et,a4:()=>St,a5:()=>vt,a6:()=>Ct,b:()=>d,c:()=>lt,d:()=>at,e:()=>Pt,f:()=>gt,g:()=>Z,h:()=>dt,i:()=>pt,j:()=>yt,k:()=>D,l:()=>p,m:()=>mt,n:()=>_t,o:()=>ht,p:()=>b,q:()=>xt,r:()=>z,s:()=>st,t:()=>et,u:()=>ft,v:()=>_,w:()=>It,x:()=>V,y:()=>qt,z:()=>M});var i=s(83661),n=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 new Array(u)}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,i.a6)(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=new Array(u),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=14;for(;s<n;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let r=0;for(s=0,n=this.getAttributeCount();s<n;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=r;for(let t=0;t<i;t++)this.m_defaultPointAttributes[r]=n,r++}}};class _{static construct(t,e,s){return new _(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new _(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new _;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,i.s)(t.x-e.x)+(0,i.s)(t.y-e.y)+(0,i.s)(t.z-e.z)}static sqrDistanceCoords(t,e,s,n,r,o){return(0,i.s)(t-n)+(0,i.s)(e-r)+(0,i.s)(s-o)}static distance(t,e){return Math.sqrt(_.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,i.af)(this.z,t.z,e)}static compareByLength(t,e,s,i){return(0,r.g)(0),0}isEqualCoords(t,e,s,i){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,i,n){return(0,r.g)(0),!1}static st_isEqual(t,e,s,i){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 _.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return _.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new _(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return _.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return(0,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,i=!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 _.dimensions}static lerp(t,e,s){const n=new _;return(0,i.z)(t,e,s,n),n}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 i=t.getUnitVector(),n=i.createAPerpendicular(),r=new _;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new _(0,0,1)),this.crossProductVector(new _(1,0,0)),this.crossProductVector(new _(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce(((t,s,i)=>e[t]>e[i]?t:i),0)];return s.normalizeThis(),s}calculateAngle(t){return(0,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}}_.dimensions=3;class d{static constructEmpty(){return new d(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,s){(0,r.g)(0)}getEnvelope2D(){return new n.J(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new i.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,i.b)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,i.b)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,i.b)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,s,i=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}const p=-559038737;var f=g;function x(t,e,s){switch(t){case 0:return new w(e,s);case 1:return new D(e,s);case 2:return new I(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new b(e,s);default:(0,r.t)("")}}function P(t,e){const s=f.getComponentCount(t);return x(f.getPersistence(t),e*s,f.getDefaultValue(t))}function y(t,e){const s=f.getComponentCount(t);return x(f.getPersistence(t),e*s)}function E(t,e){return new I(t,e)}function C(t,e){return new b(t,e)}function S(t,e){return new D(t,e)}class v{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>v.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&(0,r.t)(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,n){return this.getPersistence()===t.getPersistence()&&function(t,e,s,n,r){if(t.getPersistence()!==e.getPersistence())return!1;const o=t.getPersistence()<=1,a=t.size(),h=e.size();if(n>a||n>h)return!1;if(r)if(o){for(let o=s;o<n;o++)if(!(0,i.af)(t.read(o),e.read(o),r))return!1}else for(let i=s;i<n;i++){let s=t.read(i)-e.read(i);if(s<0&&(s=-s),s>r)return!1}else for(let i=s;i<n;i++){const s=t.read(i),n=e.read(i);if(s!==n){if(o&&Number.isNaN(s)&&Number.isNaN(n))continue;return!1}}return!0}(this,t,e,s,n)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,s,i,n,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;i&&this.checkResize(Math.max(0,a)+i),this.m_a.copyWithin(t+i,t,a>=0?a:m),this.m_a.set(h.readRange(s,i),t),n||this.reverseRange(t,i,o)}writeRange(t,e,s,i,n,o){(0,r.g)(this.getPersistence()===s.getPersistence());const a=s;if((t<0||e<0||i<0)&&(0,r.t)(),a.size()<i+e&&(0,r.t)(),0===e)return;this.size()<e+t&&this.resize(e+t);const h=a.m_a.subarray(i,i+e);!function(t,e,s,i){if((e<0||s<0)&&(0,r.t)(),0===s)return;if(1===s)return void(t[e]=i[0]);let n=i;s<i.length&&(n=i.subarray(0,s)),t.set(n,e)}(this.m_a,t,e,h)}insertAttributes(t,e,s,i){const n=f.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let i=0;i<n;i++)this.m_a[t+i]=e.getAttributeAsDbl(s,i)}insertAttributesFromPoints(t,e,s,n,o){(0,r.g)(f.getPersistence(n)===this.getPersistence());const a=f.getComponentCount(n),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===n){const n=new i.P;for(let i=t,r=0;r<s;r++,i+=2)e[r].queryXY(n),this.m_a[i]=n.x,this.m_a[i+1]=n.y}else if(1===a)for(let i=t,r=0;r<s;r++,i++)this.m_a[i]=e[r].getAttributeAsDbl(n,0);else for(let i=t,r=0;r<s;r++,i+=a)for(let t=0;t<a;t++)this.m_a[i+t]=e[r].getAttributeAsDbl(n,t)}eraseRange(t,e,s){this.m_size<t+e&&(0,r.t)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!=0)&&(0,r.t)(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let i=t,n=t+e;i<n;i+=s){let t=i,e=i+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(t,e,s){(e<t||e>s||t>s)&&(0,r.s)("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,v.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}}}v.s_constructMin=2,v.s_resizeMin=30;class b extends v{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new b({ctor:Int8Array,copy:this})}restrictedClone(t){return new b({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class I extends v{getPersistence(){return 2}clone(){return new I({ctor:Int32Array,copy:this})}restrictedClone(t){return new I({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,i.q)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class w extends v{getPersistence(){return 0}clone(){return new w({ctor:Float32Array,copy:this})}restrictedClone(t){return new w({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class D extends v{getPersistence(){return 1}getArray(){return this.m_a}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&(0,r.t)();const i=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(i,s,i)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new i.P(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let n=s,r=t,o=0;o<i;++o,++n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}else for(let n=s+i-1,r=t,o=0;o<i;++o,--n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}}queryRange(t,e,s,i,n){if((t<0||e<0)&&(0,r.t)(),!i&&(n<=0||e%n!=0)&&(0,r.t)(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+e);s.set(o)}writeRangeFromArray(t,e,s,i,n){if((t<0||e<0)&&(0,r.t)(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let o=s;e<s.length&&(o=s.subarray(0,e)),this.m_a.set(o,t)}clone(){return new D({ctor:Float64Array,copy:this})}restrictedClone(t){return new D({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}var T=g;function N(){return new Array(14)}class A{static getInstance(){return A.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new T(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new T(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new T(t);return this.m_map.set(t,s),s}}function G(t){return A.getInstance().FindOrAdd(t)}function M(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:G(s)}function q(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:G(s)}function F(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:G(s)}function V(){return A.getInstance().GetVD2D()}function Y(){return A.getInstance().GetVD3D()}function X(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}A.s_thisInstance=new A;class R{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new I(0),this.m_bucketedIndices=new I(0)}static sortEx(t,e,s,i,n=32){s-e<=n?i.userSort(e,s,t):(new R).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let n=e;n<s;n++){const e=i.getValue(t.read(n));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let n=e;n<s;n++){const s=t.read(n),r=i.getValue(s),o=this.getBucket(r);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(n-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let n=e;n<s;n++){const s=this.m_bucketedIndices.read(n-e),r=i.getValue(s),o=this.getBucket(r),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let s=0,n=this.m_buckets.size();s<n;s++){const n=h;h=this.m_buckets.read(s),h>n&&i.userSort(e+n,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(R.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}R.c_maxBuckets=65536;class k{constructor(t){this.m_buffer=null,this.m_firstFree=-1,this.m_last=0,this.m_size=0,this.m_capacity=0,this.m_bufferSize=0,this.m_stride=0,this.m_stride=t,this.m_realStride=t,this.m_blockSize=Math.trunc(k.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>k.st_blockPower][1+(t&k.st_blockMask)]=k.st_deadVertex,!0}deleteElement(t){(t>>k.st_blockPower)*this.m_blockSize*this.m_realStride+(t&k.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>k.st_blockPower][t&k.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>k.st_blockPower][(t&k.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>k.st_blockPower][(t&k.st_blockMask)+e]=s}getStride(){return this.m_stride}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.m_capacity){const t=0!==this.m_capacity?Math.trunc(2*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<k.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>k.st_blockPower][t&k.st_blockMask];this.m_size++;const e=this.m_buffer[t>>k.st_blockPower],s=t&k.st_blockMask;for(let t=0;t<this.m_stride;t++)e[s+t]=-1;return t}elementToIndex(t){return(t>>k.st_blockPower)*this.m_blockSize+(t&k.st_blockMask)/this.m_realStride}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.m_size=0,t&&(this.m_buffer=null,this.m_capacity=0)}size(){return this.m_size}setCapacity(t){t>this.m_capacity&&this.grow(t)}capacity(){return this.m_capacity}swap(t,e){const s=this.m_buffer[t>>k.st_blockPower],i=this.m_buffer[e>>k.st_blockPower],n=t&k.st_blockMask,r=e&k.st_blockMask;for(let t=0;t<this.m_stride;t++){const e=s[n+t];s[n+t]=i[r+t],i[r+t]=e}}swapField(t,e,s){const i=this.m_buffer[t>>k.st_blockPower],n=this.m_buffer[e>>k.st_blockPower],r=(t&k.st_blockMask)+s,o=(e&k.st_blockMask)+s,a=i[r];i[r]=n[o],n[o]=a}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}ensureBufferBlocksCapacity(t){if(this.m_buffer.length<t){const e=new Array(t);for(let t=0;t<this.m_buffer.length;t++)e[t]=this.m_buffer[t];this.m_buffer=e}}grow(t){null===this.m_buffer&&(this.m_bufferSize=0,this.m_buffer=new Array(8));const e=Math.trunc((t+this.m_blockSize-1)/this.m_blockSize);if(this.ensureBufferBlocksCapacity(e),1===e){let e=0;const s=t*this.m_realStride;for(;s>k.st_sizes[e];)e++;const i=new Int32Array(k.st_sizes[e]);1===this.m_bufferSize?(i.set(this.m_buffer[0]),this.m_buffer[0]=i):(this.m_buffer[this.m_bufferSize]=i,this.m_bufferSize++),this.m_capacity=Math.trunc(i.length/this.m_realStride)}else{if(1===this.m_bufferSize&&this.m_buffer[0].length<k.st_realBlockSize){const t=new Int32Array(k.st_realBlockSize);t.set(this.m_buffer[0]),this.m_buffer[0]=t,this.m_capacity=this.m_blockSize}for(;this.m_bufferSize<e;)this.m_buffer[this.m_bufferSize++]=new Int32Array(k.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}k.st_realBlockSize=16384,k.st_blockMask=16383,k.st_blockPower=14,k.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],k.st_deadVertex=-2125315821;class L{constructor(t,e,s){this.m_extent=new n.J,this.m_dataExtent=new n.J,this.m_childExtents=[new n.J,new n.J,new n.J,new n.J],this.m_elementNodes=new k(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new k(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){(0,r.g)(0)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,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 n.J;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const 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 n.J;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,i.m)(n.J,4);let m=0;for(;o.length>0;){let t=!1;const e=o.at(-1),i=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(i)){if(m+=this.getSubTreeElementCount(e),s>0&&m>=s)return s}else if(r.isIntersecting(i)){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_(i,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,i){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.t)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,r,o,a){if(!i.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 n.J;h.setCoords({env2D:i});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 _=(0,i.m)(n.J,4);for(;u.length>0;){let s=!1;const i=u.at(-1),n=c.at(-1),r=g.at(-1);if(u.pop(),c.pop(),g.pop(),r+1<this.m_height&&this.canPushDown_(i)&&m<=Math.max(n.width(),n.height())/2&&(s=!0),s){L.setChildExtents_(n,_);let t=!1;for(let s=0;s<4;s++)if(t=_[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),u.push(t),c.push(_[s].clone()),g.push(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(_[t].isIntersecting(e)){let e=this.getChild_(i,t);-1===e&&(e=this.createChild_(i,t)),u.push(e),c.push(_[t].clone()),g.push(r+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else l=this.insertAtQuad_(t,e,r,n,i,a,o,h,l),a=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let l=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),l=a}else-1===h?(l=this.createElement_(),this.setDataValues_(this.getData_(l),t,e)):l=this.createElementFromDuplicate_(h);return this.setQuad_(l,n),-1!==m?(this.setPrevElement_(l,m),this.setNextElement_(m,l)):this.setFirstElement_(n,l),this.setLastElement_(n,l),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),l}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===L.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const r=new n.J;let o=this.getFirstElement_(s),a=-1,h=-1;do{h=this.getData_(o),i=this.getElementValue_(h),r.setCoords({env2D:this.getBoundingBoxValue_(h)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(i,r,t,e,s,!0,o):this.insert_(i,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 i=e<<L.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,s)}}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 i.P,this.m_queryEnd=new i.P,this.m_queryBox=new n.J,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new n.J,new n.J,new n.J,new n.J],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof n.J)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 i.P,e=new i.P,s=new n.J;let r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){const i=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(i)}),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),i=this.m_extentsStack.at(-1);L.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let i=0;i<4;i++){const r=this.m_quadTree.getChild_(s,i);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[i].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new n.J;s.setCoords({env2D:this.m_childExtents[i]}),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[i].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[i].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class H{constructor(t){this.m_bucketSort=new R,this.m_sortedHandles=new I(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,((t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s)))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,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,n,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),n&&(0===a||0===h)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===a?e:t;return this.setDuplicateElement_(i,o),-1}u=e!==U.st_nullNode()&&t!==U.st_nullNode()?this.m_random>(0,i.N)(this.m_random)>>1:e!==U.st_nullNode(),u?(l=a,m=e):(l=h,m=t);let c=-1,g=-1,_=!0;for(;;){if(l<0){const t=this.getLeft(m);if(t===U.st_nullNode()){g=m,c=this.newNode_(s),this.setLeft_(m,c),this.setParent_(c,m);break}m=t}else{const t=this.getRight(m);if(t===U.st_nullNode()){g=this.getNext(m),c=this.newNode_(s),this.setRight_(m,c),this.setParent_(c,m);break}m=t}_&&(l*=-1,_=!1)}return this.bubbleUp_(c),this.getParent(c)===U.st_nullNode()&&this.setRoot_(c,o),this.addToList_(g,c,o),c}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==U.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==U.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===U.st_nullNode()&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==U.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),U.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==U.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==U.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=U.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return k.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const n=this.getPriority_(t);for(;e!==U.st_nullNode()||s!==U.st_nullNode();){const r=e!==U.st_nullNode()?this.getPriority_(e):(0,i.n)(),o=s!==U.st_nullNode()?this.getPriority_(s):(0,i.n)();if(n<=Math.min(r,o))return;r<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==U.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==U.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==U.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==U.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==U.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==U.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,i.N)(this.m_random),this.m_random&(0,i.n)()>>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 i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===U.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===U.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===U.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),n=this.getRight(t),r=this.getParent(t),o=t;if(-1!==s&&-1!==n){let a;this.m_random=(0,i.N)(this.m_random),a=this.m_random>(0,i.n)()>>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_(n,a)):n===a&&(this.setRight_(a,t),this.setParent_(s,a)),this.setParent_(t,a),r=a):(this.setParent_(s,a),this.setParent_(n,a),r=this.getParent(t),o=a),s=this.getLeft(t),n=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==n&&this.setParent_(n,t)}const a=-1!==s?s:n;-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,i.n)());let s=U.st_nullNode(),n=U.st_nullNode();const r=this.getRoot_(e),o=r===t;if(o&&(s=this.getLeft(r),n=this.getRight(r),s===U.st_nullNode()&&n===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()?n: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 i=this.newNode_();let n=-1;if(e!==O.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==O.st_nullNode()&&this.setNext_(n,i),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===O.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==O.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==O.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==O.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,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 i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?j.isLeft_(e)&&j.isRight_(i)?-1:j.isLeft_(i)&&j.isRight_(e)?1:0:1}}class j{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new k(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new k(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new U,this.m_secondaryTreaps.setComparator(new W(this)),this.m_secondaryLists=new O}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.r)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.r)(""),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.r)(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new I(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.r)("");const e=this.m_intervalHandles[t];let s;-1===e&&(0,r.t)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(i),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),i),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),i),s=this.m_secondaryTreaps.size(i),0===s&&(this.m_secondaryTreaps.deleteTreap(i),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(n),a=this.getLptr_(n),h=this.getRptr_(n);for(;!(s>0||n===this.m_root||-1!==a&&-1!==h);)n===this.getLptr_(o)?-1!==a?(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setLptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(o,-1),this.setPptr_(n,-1)):-1!==a?(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setRptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(o,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=o,i=this.getSecondaryFromTertiary_(n),s=-1!==i?this.m_secondaryTreaps.size(i):0,a=this.getLptr_(n),h=this.getRptr_(n),o=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof i.E?new J(this,t,e):((0,r.g)(0),{})}getIterator(){return new J(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new I(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=(0,i.f)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){const i=e.read(t);let n=s[i>>1];if(-1!==n){const t=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(t,i))}else n=this.insertIntervalEnd_(i,this.m_root),s[i>>1]=n}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let l=Number.NaN,u=Number.NaN,c=!0;const g=this.getMin_(m),_=this.getMax_(m);let d=-1;for(;c;){h=o+(a-o>>1),d=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(d);if(_<e){if(-1!==i)if(d===this.getDiscriminantIndex1_(i))s=i,l=e,i=this.getLptr_(i),u=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(u>e){const t=this.createTertiaryNode_(d);e<l?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,l=e,i=-1,u=Number.NaN}a=h;continue}if(g>e){if(-1!==i)if(d===this.getDiscriminantIndex1_(i))s=i,l=e,i=this.getRptr_(i),u=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(u<e){const t=this.createTertiaryNode_(d);e<l?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,l=e,i=-1,u=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||d!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(d):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&d===this.getDiscriminantIndex1_(i)||(e<l?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(u<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.r)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;return s=t<e?t+(e-t>>1)+2:-(t+2),s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new R).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,((t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&j.isLeft_(t)&&j.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return j.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return j.isLeft_(t)?e.xmin:e.xmax}}class J{constructor(t,e,s){this.m_query=i.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.c)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new i.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.r)(""),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 Z{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new I(0),this.m_sortedEndIndicesBlue=new I(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new O,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.r)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new n.J(e))}endConstruction(){this.m_bAddRedRed||(0,r.r)(""),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.r)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.r)(""),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.r)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.r)(""),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=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&(this.m_queuedIndicesRed.length=this.m_envelopesRed.length,this.m_queuedIndicesRed.fill(-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=i.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&(this.m_queuedIndicesBlue.length=this.m_envelopesBlue.length,this.m_queuedIndicesBlue.fill(-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.c)("should not be called"),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new R).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,((t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1}))}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}var Q=g;class K{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new K(this.tolerance+t,this.resolution)}scale(t){return new K(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function $(t,e,s,n,r){const o=n*n,a=t.sub(e),h=s.sub(e),m=a.sqrLength(),l=h.sqrLength();if(m<=o||l<=o)return!0;const u=(0,i.s)(a.crossProduct(h));return(u<=o*m||u<=o*l)&&a.dotProduct(h)>=0}function tt(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function et(t,e){const s=new n.J;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function st(t,e){const s=n.J.constructEmpty();t.queryLooseEnvelope(s);const i=n.J.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function it(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function nt(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function rt(t,e,s){const i=n.J.constructEmpty();return i.setFromPoints(t,e),ct(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function ot(t,e,s){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function at(t,e,s){return ct(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function ht(t,e,s){return at(t,e.queryInterval(1,0),s)}function mt(t,e,s){const i=n.J.constructEmpty();return e.queryEnvelope(i),ot(t,i,s)}function lt(t,e,s=!1){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ut(t,e,s){const i=n.J.constructEmpty();return e.queryEnvelope(i),lt(t,i,s)}function ct(t,e,s,i,n){const r=new K(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}return i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01),r.total()<s?new K(s,0):r}function gt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function _t(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function dt(t){return t>=3}function pt(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function ft(t,e){t.getImpl().setIsSimple(3,e)}function xt(t,e,s,n){if((0,i.s)(e.x-t.x)+(0,i.s)(e.y-t.y)<=s*s){const s=t.z,r=e.z;return(0,i.af)(s,r,n)}return!1}function Pt(t){return t>=4}function yt(t,e){return t===r.G.enumPolygon?dt(e):e>=1}function Et(t,e,s){const i=n.J.constructEmpty(),r=n.J.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.J.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=e.querySegmentIterator(),m=n.J.constructEmpty(),l=n.J.constructEmpty(),u=new Z;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,i,r){t.getGeometryType(),e.getGeometryType();const o=n.J.constructEmpty(),a=n.J.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(s,s),a.inflateCoords(s,s);const h=n.J.constructEmpty();h.setCoords({env2D:o}),h.intersect(a);const m=new Z;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 St(t,e,s){const i=n.J.constructEmpty(),r=n.J.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.J.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=new Z;h.setTolerance(s);let m=!1;for(h.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(i),i.isIntersecting(o)&&(m=!0,h.addRedEnvelope(a.getStartPointIndex(),i));if(h.endRedConstruction(),!m)return null;let l=!1;h.startBlueConstruction();for(let t=0,s=e.getPointCount();t<s;t++){const s=e.getXY(t);o.contains(s)&&(l=!0,h.addBlueEnvelope(t,n.J.construct(s.x,s.y,s.x,s.y)))}return h.endBlueConstruction(),l?h:null}function vt(t,e,s){const r=n.J.constructEmpty(),o=n.J.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=n.J.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Z;h.setTolerance(s);let m=!1;h.startRedConstruction();const l=new i.P;for(let e=0,s=t.getPointCount();e<s;e++)t.queryXY(e,l),a.contains(l)&&(m=!0,h.addRedEnvelope(e,n.J.construct(l.x,l.y,l.x,l.y)));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();const c=new i.P;for(let t=0,s=e.getPointCount();t<s;t++)e.queryXY(t,c),a.contains(c)&&(u=!0,h.addBlueEnvelope(t,n.J.construct(c.x,c.y,c.x,c.y)));return h.endBlueConstruction(),u?h:null}function bt(t){const e=new n.J;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){const s=new n.J;if(t.queryLooseEnvelope(s),s.isEmpty())return null;t.getGeometryType();const i=new L(s,8);let o=-1;const a=new n.J;let h=!1;do{for(let n=0,m=t.getPathCount();n<m;n++)if(t.queryLoosePathEnvelope(n,a),a.isIntersecting(e)){if(o=i.insertEx(n,a,o),-1===o){h&&(0,r.c)("build_quad_tree_for_paths"),s.assign(t.calculateEnvelope2D(!1)),h=!0,i.reset(s,8);break}h=!1}}while(h);return i}(t,e)}function It(t,e){if(!e){const e=new n.J;t.queryLooseEnvelope(e);const s=new L(e,8);let i=-1;const o=new n.J,a=t.querySegmentIterator();let h=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const n=a.nextSegment(),m=a.getStartPointIndex();if(n.queryLooseEnvelope(o),i=s.insertEx(m,o,i),-1===i){h&&(0,r.c)(""),e.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(e,8),a.resetToFirstPath();break}}return s}const s=new n.J;t.queryLooseEnvelope(s);const i=new L(s,8);let o=-1;const a=new n.J,h=t.querySegmentIterator();let m=!1;for(;h.nextPath();)for(;h.hasNextSegment();){const n=h.nextSegment(),l=h.getStartPointIndex();if(n.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=i.insertEx(l,a,o),-1===o)){m&&(0,r.c)(""),s.assign(t.calculateEnvelope2D(!1)),m=!0,i.reset(s,8),h.resetToFirstPath();break}}return i}function wt(t,e){if(e){const s=new L(e,8),o=new i.P,a=new n.J;let h=!1;for(let i=0;i<t.getPointCount();i++)o.setCoordsPoint2D(t.getXY(i)),e.contains(o)&&(a.setCoords({pt:o}),-1!==s.insert(i,a)||(h&&(0,r.c)(""),h=!0,s.reset(t.calculateEnvelope2D(),8),i=-1));return s}return(0,r.b)("no-extent version not yet impl"),null}function Dt(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let n=s;n<e;n+=i){const e=t.read(n);e<o?(r=!0,t.write(n,o)):e>a&&(r=!0,t.write(n,a))}return r}function Tt(t,e,s,i){if(!t.hasAttribute(s))return!1;const n=t.getGeometryType();if(n===r.G.enumGeometryCollection){const n=t,r=n.getGeometryCount();let o=0;for(let t=0;t<r;++t)o|=Tt(n.getGeometry(t),e,s,i)?1:0;return!!o}if((0,r.i)(n)){const n=t,o=Q.getPersistence(s),a=Q.getComponentCount(s),h=n.getPointCount();if(1===o){const t=Dt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}if(2===o){const t=Dt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}(0,r.c)("snap_coordinate not implemented")}if(n===r.G.enumEnvelope){const n=t,r=n.queryInterval(s,i);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&&n.setIntervalEnvelope(s,i,r),o}if(n===r.G.enumPoint){const n=t;let r=n.getAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setAttributeBasic(s,i,r),o}if((0,r.f)(n)){const n=t;let r=n.getStartAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setStartAttribute(s,i,r),r=n.getEndAttributeAsDbl(s,i),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setEndAttribute(s,i,r),o}(0,r.c)("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=V(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=Y(),this.ensureAttributes(),this.setXYZ(new _(t.x,t.y,t.z))):(this.m_description=V(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=V()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new i.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new _;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]: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.s)("")}const s=Nt.getComponentCount(t);(e<0||e>=s)&&(0,r.s)("");const i=this.m_description.getAttributeIndex(t);return i>=0?this.m_attribs[this.m_description.getPointAttributeOffset(i)-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.s)(""));const i=Nt.getComponentCount(t);(e<0||e>=i)&&(0,r.s)("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=Nt.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return 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 d){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new i.E;if(this.isEmpty())return s.setEmpty(),s;const n=this.getAttributeAsDbl(t,e);return s.vmin=n,s.vmax=n,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.b)("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=tt(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new At({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.t)();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=V(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&(0,i.a)(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,n=this.m_description.getTotalComponentCount()-2;t<n;t++)if(!(0,i.af)(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.t)("wrong geometry type");const e=t;e.m_description=(0,i.b)(this.m_description,this.m_description=e.m_description),e.x=(0,i.b)(this.x,this.x=e.x),e.y=(0,i.b)(this.y,this.y=e.y),e.m_attribs=(0,i.b)(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 i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,e,s){if(t.getDescription()!==e.getDescription()&&(0,r.t)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const n=c();t.queryValues(n,n.length);const o=c();e.queryValues(o,o.length);const a=c();let h=n,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),n=Nt.getInterpolation(e),r=Nt.getComponentCount(e),o=Nt.getDefaultValue(e);(0,i.O)(n,h,m,l,u,r,s,o),h=h.slice(r),m=m.slice(r),u+=r}return this.setValues(a,u),this}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,i.a)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return i.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=M(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=V());const e=N();X(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=Nt.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),t[0]=this.x,t[1]=this.y,(0,i.a)(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,i.a)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=Nt.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Nt.getDefaultValue(n);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,i.a)(this.m_attribs,t,0,2,s-2)}dbgDefaultAttribs(){}}At.type=r.G.enumPoint;var Gt=g;function Mt(t,e){return e*(t.getTotalComponentCount()-2)}class qt{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new n.J(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new n.J(t.env2D);else if(t.move)this.m_envelope2D=new n.J(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 n.J(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=n.J.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const s=e,o=t.getTotalComponentCount()-2;if(s.m_description!==t&&(s.releaseAttributes_(),s.m_description=t,o&&(s.m_data.m_attributes=new Array(2*o))),o){(0,r.g)(this.m_attributes&&s.m_data.m_attributes);const t=2*o;(0,i.a)(s.m_data.m_attributes,this.m_attributes,0,0,t)}s.m_data.m_envelope2D=new n.J(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new n.J(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,i,n){(0,r.g)(0)}queryInterval(t,e,s,i){if(this.isEmpty())return void i.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(i):1===s?this.m_envelope2D.queryIntervalY(i):(0,r.s)(""));const n=Gt.getComponentCount(e);(s<0||s>=n)&&(0,r.s)("");const o=t.getAttributeIndex(e);if(o>=0)return i.vmin=this.m_attributes[Mt(t,0)+t.getPointAttributeOffset(o)-2+s],void(i.vmax=this.m_attributes[Mt(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=Gt.getDefaultValue(e);return void i.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new i.E;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}let Ft=class t{constructor(t){if(this.m_EnvelopeType=4,this.m_description=V(),void 0===t)this.m_data=new qt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new qt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new qt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new qt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new qt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new qt({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 qt,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 qt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,s,i,n){(0,r.g)(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=M(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new n.J(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 i.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=Gt.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof n.J)this.m_data.m_envelope2D=new n.J(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=i.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof n.J)return e.isValid()||(0,r.t)(""),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,i=t.getAttributeCount();s<i;s++){const i=t.getSemantics(s),n=Gt.getComponentCount(i);for(let t=0;t<n;t++){const s=e.queryInterval(i,t),n=this.queryInterval(i,t);n.merge(s),this.setIntervalEnvelope(i,t,n)}}}else 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,i=s.getAttributeCount();e<i;e++){const i=s.getSemantics(e),n=Gt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.getAttributeAsDbl(i,e),n=this.queryInterval(i,e);n.mergeCoordinate(s),this.setIntervalEnvelope(i,e,n)}}}else(0,r.b)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=Gt.getComponentCount(s);for(let e=0;e<i;e++){const i=t.queryInterval(s,e),n=this.queryInterval(s,e);n.intersect(i),this.setIntervalEnvelope(s,e,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=Gt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=new i.E(s);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):(0,r.s)("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,s,n){this.setIntervalEnvelope(t,e,new i.E(s,n))}queryInterval(t,e){const s=new i.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.b)("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=V()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,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,n=2*(this.m_description.getTotalComponentCount()-2);t<n;t++)if(!(0,i.af)(this.m_data.m_attributes[t],s.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.b)("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.t)("wrong geometry type");const e=t;e.m_description=(0,i.b)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,i.b)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,i.b)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.t)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.s)(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=Gt.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=Gt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let e=1,s=i.getAttributeCount();e<s;e++){const s=i.getSemantics(e),n=Gt.getComponentCount(s);for(let e=0;e<n;e++){const i=t.getAttributeAsDbl(s,e);this.setInterval(s,e,i,i)}}}assignVertexDescriptionImpl(t){const e=N();X(t,this.m_description,e);let s=null;const n=t.getTotalComponentCount()-2,r=this.m_description?this.m_description.getTotalComponentCount()-2:0;n>0&&(s=new Array(2*n),s.fill(Number.NaN));for(let o=1;o<t.getAttributeCount();o++){const a=e[o];if(-1!==a){const e=t.getPointAttributeOffset(o)-2,h=Gt.getComponentCount(t.getSemantics(o)),m=this.m_description.getPointAttributeOffset(a)-2;(0,i.a)(s,this.m_data.m_attributes,e,m,h),(0,i.a)(s,this.m_data.m_attributes,n+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.z)(""),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.s)("");const i=this.m_description.getAttributeIndex(e);return i>=0?this.m_data.m_attributes[Mt(this.m_description,t)+this.m_description.getPointAttributeOffset(i)-2+s]:g.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,i){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=i:0===s?this.m_data.m_envelope2D.xmax=i:(0,r.s)(""):1===s?this.m_data.m_envelope2D.ymin=i:0===s?this.m_data.m_envelope2D.xmin=i:(0,r.s)(""));const n=Gt.getComponentCount(e);(s<0||s>=n)&&(0,r.s)(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[Mt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=i}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:qt},Symbol.toStringTag,{value:"Module"}))},79187:(t,e,s)=>{s.d(e,{J:()=>r});var i=s(55537),n=s(83661);class r{static construct(t,e,s,i){return new r(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new 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 n.P.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(t){void 0!==t.xmin?(this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax):void 0!==t.x?(this.xmin=t.x,this.xmax=t.x,this.ymin=t.y,this.ymax=t.y):void 0!==t.pt1?(this.xmin=t.pt1.x,this.ymin=t.pt1.y,this.xmax=t.pt2.x,this.ymax=t.pt2.y,this.normalize()):void 0!==t.env2D?(this.xmin=t.env2D.xmin,this.xmax=t.env2D.xmax,this.ymin=t.env2D.ymin,this.ymax=t.env2D.ymax,this.normalize()):void 0!==t.pt?(this.xmin=t.pt.x,this.xmax=t.pt.x,this.ymin=t.pt.y,this.ymax=t.pt.y):void 0!==t.center?(this.xmin=t.center.x-.5*t.width,this.xmax=this.xmin+t.width,this.ymin=t.center.y-.5*t.height,this.ymax=this.ymin+t.height,this.normalize()):(0,i.b)("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let t=1,i=2*e;t<i;t+=2){if(!this.isEmpty()){for(let i=t,n=2*e;i<n;i+=2)this.mergeNeCoords(s[i],s[i+1]);return}this.setCoords({x:s[t],y:s[t+1]}),t+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new n.P(this.xmin,this.ymin)}getLowerRight(){return new n.P(this.xmax,this.ymin)}getUpperLeft(){return new n.P(this.xmin,this.ymax)}getUpperRight(){return new n.P(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new n.P(this.xmin,this.ymin);case 1:return new n.P(this.xmin,this.ymax);case 2:return new n.P(this.xmax,this.ymax);default:return new n.P(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,o=e.y-t.y;if(Math.abs(n)>Math.abs(o)?s&r.XMASK?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&r.XMASK?(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s&r.YMASK?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):i&r.YMASK?(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),o=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),o=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=(0,n.m)(n.P,4);this.queryCorners(s);const i=(0,n.m)(n.P,4);t.queryCorners(i);for(let t=0;t<4;t++)for(let r=0;r<4;r++){const o=n.P.sqrDistance(s[t],i[r]);o>e&&(e=o)}return e}sqrMaxMinDistance(t){const e=n.P.sqrDistance(t,this.getLowerLeft()),s=n.P.sqrDistance(t,this.getUpperLeft()),i=n.P.sqrDistance(t,this.getLowerRight()),r=n.P.sqrDistance(t,this.getUpperRight());let o,a=Math.max(e,s);return o=Math.max(e,i),a>o&&(a=o),o=Math.max(s,r),a>o&&(a=o),o=Math.max(i,r),a>o&&(a=o),a}sqrMinDistance(t){return this.contains(t)?0:this.sqrDistance(t)}sqrMaxDistance(t){let e=n.P.sqrDistance(t,this.getLowerLeft());return e=Math.max(n.P.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(n.P.sqrDistance(t,this.getUpperRight()),e),e=Math.max(n.P.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=(0,n.c)(t.x,this.xmin,this.xmax),s=(0,n.c)(t.y,this.ymin,this.ymax);return n.P.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new n.P;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:(0,i.t)("query_side")}return e}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){return this.isEmpty()?(0,n.g)():(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*(0,n.g)()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}r.XLESSXMIN=1,r.YLESSYMIN=4,r.XMASK=3,r.YMASK=12},89473:(t,e,s)=>{s.d(e,{I:()=>u});var i=s(55537),n=s(76061),r=s(35368),o=s(79187),a=s(95213),h=s(54573),m=s(83661),l=s(32406);class u{constructor(t,e,s,n){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=i.G.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=t,this.m_sr=e,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=t.getGeometryType()}intersect(t){const e=this.tryFastImplementation(t);if(null!==e)return e;const s=(0,a.s)(this.m_intersectorGeom,t),i=(0,a.a)(this.m_sr,s,!0).total(),n=o.J.constructEmpty();this.m_intersectorGeom.queryEnvelope(n);const r=o.J.constructEmpty();t.queryEnvelope(r),n.inflateCoords(2*i,2*i),n.intersect(r),n.inflateCoords(100*i,100*i);let u=(0,h.c)(this.m_intersectorGeom,n,0,0,this.m_progressTracker),c=(0,h.c)(t,n,0,0,this.m_progressTracker);return t.getDimension()>this.m_intersectorGeom.getDimension()&&(u=(0,m.b)(c,c=u)),(0,l.i)(c,u,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,a.s)(this.m_intersectorGeom,t),i=(0,a.a)(this.m_sr,s,!0).total(),n=o.J.constructEmpty();this.m_intersectorGeom.queryEnvelope(n);const r=o.J.constructEmpty();t.queryEnvelope(r),n.inflateCoords(2*i,2*i),n.intersect(r),n.inflateCoords(100*i,100*i);let u=(0,h.c)(this.m_intersectorGeom,n,0,0,this.m_progressTracker),c=(0,h.c)(t,n,0,0,this.m_progressTracker);t.getDimension()>this.m_intersectorGeom.getDimension()&&(u=(0,m.b)(c,c=u));const g=(0,l.c)(c,u,this.m_sr,this.m_progressTracker);return this.prepareVector(t.getDescription(),this.m_dimensionMask,g)}init(t,e,s,n=null){(0,i.g)(0)}static intersectPoints(t,e,s){const i=(0,a.s)(t,e),n=(0,a.a)(s,i,!0);return(0,l.e)(t,e,n)}tryFastImplementation(t){const e=t.getGeometryType();if(this.m_intersectorGeomType===i.G.enumPoint&&e===i.G.enumPoint){const e=u.intersectPoints(t,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const t=new r.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}return e}if(e===i.G.enumEnvelope&&this.m_intersectorGeomType===i.G.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const e=t,s=this.m_intersectorGeom,i=new a.E({copy:e});return i.intersect(s),i}const s=(0,a.s)(t,this.m_intersectorGeom),n=(0,a.a)(this.m_sr,s,!0),m=t.isEmpty(),c=this.m_intersectorGeom.isEmpty();let g=m||c;if(!g){const e=function(t,e,s){const n=new o.J;t.queryEnvelope(n);const r=new o.J;e.queryEnvelope(r);const a=new o.J(r);if(a.inflate(2*s),!a.isIntersecting(n))return 4;const h=t.getGeometryType(),m=e.getGeometryType();if(h===i.G.enumEnvelope&&n.containsEnvelope(a))return 1;if(m===i.G.enumEnvelope){const t=new o.J(n);if(t.inflate(2*s),r.containsEnvelope(t))return 2}return 0}(this.m_intersectorGeom,t,n.total());if(4===e)g=!0;else{if(2&e)return this.m_intersectorGeom;if(1&e)return t}}if(g){const s=(0,i.e)(e),n=(0,i.e)(this.m_intersectorGeomType);return s<n?u.ReturnEmpty(t,m):s>n||0===s&&e===i.G.enumMultiPoint&&this.m_intersectorGeomType===i.G.enumPoint?this.ReturnEmptyIntersector():u.ReturnEmpty(t,m)}if(e===i.G.enumEnvelope&&0===(0,i.e)(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.G.enumEnvelope&&0===(0,i.e)(e)){const s=e===i.G.enumEnvelope?t:this.m_intersectorGeom,r=e===i.G.enumEnvelope?this.m_intersectorGeom:t,a=o.J.constructEmpty();return s.queryEnvelope(a),(0,h.c)(r,a,n.total(),0,this.m_progressTracker)}if(0===(0,i.e)(e)&&(0,i.e)(this.m_intersectorGeomType)>0||(0,i.e)(e)>0&&0===(0,i.e)(this.m_intersectorGeomType)){if(e===i.G.enumMultiPoint)return(0,l.f)(t,this.m_intersectorGeom,n);if(e===i.G.enumPoint)return(0,l.g)(t,this.m_intersectorGeom,n);if(this.m_intersectorGeomType===i.G.enumMultiPoint)return(0,l.f)(this.m_intersectorGeom,t,n);if(this.m_intersectorGeomType===i.G.enumPoint)return(0,l.g)(this.m_intersectorGeom,t,n);(0,i.c)("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(t,e){return e?t:t.createInstance()}prepareVector(t,e,s){let i=0;return 1&e?(s[0]||(s[0]=new r.M({vd:t})),i++):s.shift(),2&e?(s[i]||(s[i]=new r.a({vd:t})),i++):s.splice(i,1),4&e?s[i]||(s[i]=new r.P({vd:t})):s.splice(i,1),new n.S(s)}}},31139:(t,e,s)=>{s.d(e,{O:()=>a});var i=s(76061),n=s(55537),r=s(95213),o=s(54573);class a{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i){return new h(t,e,s,i)}execute(t,e,s,i){return function(t,e,s,i){return(0,o.a)(t,e,s,Number.NaN,0,i)}(t,e,s,i)}}class h extends i.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_index=-1,t||(0,n.t)(""),this.m_envelope=e,this.m_inputGeometryCursor=t,this.m_spatialRefImpl=s,this.m_tolerance=(0,r.a)(s,e,!1).total()}next(){let t;return(t=this.m_inputGeometryCursor.next())?((0,n.d)(t),this.m_index=this.m_inputGeometryCursor.getGeometryID(),(0,o.c)(t,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},5247:(t,e,s)=>{s.d(e,{O:()=>h});var i=s(76061),n=s(55537),r=s(35368),o=r.D;class a extends i.G{constructor(t,e,s,i,n,r){super(),this.m_densificator=new o(e,s,i,r,!1,n),this.m_index=-1,this.m_inputGeoms=t}tock(){return!0}getRank(){return 1}next(){let t=null;for(;t=this.m_inputGeoms.next();)return(0,n.d)(t),this.m_index=this.m_inputGeoms.getGeometryID(),this.densify(t);return null}getGeometryID(){return this.m_index}densify(t){return this.m_densificator.densify(t)}}class h{getOperatorType(){return 10202}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}executeMany(t,e,s,i,n,r=12e3){return new a(t,e,s,i,r,n)}execute(t,e,s,i,n,o=12e3){return(0,r.d)(t,e,s,i,n,o)}}},31085:(t,e,s)=>{s.d(e,{O:()=>g});var i=s(76061),n=s(55537),r=s(89473),o=s(83661),a=s(35368),h=s(79187),m=s(95213),l=s(54573),u=s(32406),c=s(86117);class g{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i){return new _(t,e,s,i)}execute(t,e,s,n){return this.executeMany(new i.S([t]),new i.S([e]),s,n).next()}}class _ extends i.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_index=-1,this.m_inputGeoms=t,this.m_spatialReference=s;const n=e.next();this.m_geomSubtractor=n||new a.P}next(){const t=this.m_inputGeoms.next();return t?((0,n.d)(t),(0,n.n)(t),this.m_index=this.m_inputGeoms.getGeometryID(),function(t,e,s,i){if(t.isEmpty()||e.isEmpty())return t;const g=t.getDimension(),_=e.getDimension();if(g>_)return t;const d=t.getGeometryType(),p=e.getGeometryType(),f=new h.J,x=new h.J,P=new h.J;t.queryEnvelope(f),e.queryEnvelope(x),P.setCoords({env2D:f}),P.mergeEnvelope2D(x);const y=(0,m.a)(s,P,!0),E=(0,m.f)(y),C=new h.J;if(C.setCoords({env2D:f}),C.inflateCoords(E,E),!C.isIntersecting(x))return t;if(1===g&&2===_){const o=function(t,e,s,i,o){const l=new m.E;t.queryEnvelope(l);const u=new h.J;e.queryEnvelope(u),l.merge(u);const c=.1*l.width(),g=.1*l.height();l.inflateCoords(c,g);const _=new a.P;_.addEnvelope(l,!1);const d=_.getImpl();if(s===n.G.enumPolygon){const t=e.getImpl();d.add(t,!0)}else d.addEnvelope(e,!0);return new r.I(_,i,-1,o).tryFastImplementation(t)}(t,e,p,s,i);if(o)return o}if(d===n.G.enumPoint){let s;switch((0,n.f)(p)?(s=new a.a({vd:e.getDescription()}),s.addSegment(e,!0)):s=e,p){case n.G.enumPolygon:return function(t,e,s){return 0===(0,c.m)(e,t,s.total())?t:t.createInstance()}(t,s,y);case n.G.enumPolyline:return function(t,e,s){const i=t.getXY(),n=e.querySegmentIterator(),r=(0,m.f)(s),a=r*r;for(;n.nextPath();)for(;n.hasNextSegment();){const e=n.nextSegment(),m=new h.J;if(e.queryEnvelope(m),m.inflateCoords(r,r),!m.contains(i))continue;if(e.isIntersectingPoint(i,s.total()))return t.createInstance();let l=e.getStartXY();if(o.P.sqrDistance(i,l)<=a)return t.createInstance();if(l=e.getEndXY(),o.P.sqrDistance(i,l)<=a)return t.createInstance()}return t}(t,s,y);case n.G.enumMultiPoint:return function(t,e,s){const i=e.getImpl().getAttributeStreamRef(0),n=e.getPointCount(),r=t.getXY(),a=(0,m.f)(s),h=a*a,l=new o.P;for(let e=0;e<n;e++)if(i.queryPoint2D(2*e,l),o.P.sqrDistance(l,r)<=h)return t.createInstance();return t}(t,s,y);case n.G.enumEnvelope:return function(t,e,s){const i=new h.J;e.queryEnvelope(i),i.inflate(s.total());const n=t.getXY();return i.contains(n)?t.createInstance():t}(t,s,y);case n.G.enumPoint:return function(t,e,s){const i=(0,m.f)(s),n=i*i,r=t.getXY(),a=e.getXY();return o.P.sqrDistance(r,a)<=n?t.createInstance():t}(t,s,y);default:(0,n.t)("invalid shape type")}}else if(d===n.G.enumMultiPoint)switch(p){case n.G.enumPolygon:return function(t,e,s){const i=new h.J;e.queryEnvelope(i),i.inflate(s.total());const n=t.getPointCount();let r=!1;const a=(0,o.f)(n,!1),m=new o.P;for(let o=0;o<n;o++)t.queryXY(o,m),i.contains(m)&&0!==(0,c.i)(e,m,s.total())&&(r=!0,a[o]=!0);if(!r)return t;const l=t.createInstance();for(let e=0;e<n;e++)a[e]||l.addPoints(t,e,e+1);return l}(t,e,y);case n.G.enumEnvelope:return function(t,e,s){const i=new h.J;e.queryEnvelope(i),i.inflate(s.total());const n=t.getPointCount();let r=!1;const a=(0,o.f)(n,!1),m=new o.P;for(let e=0;e<n;e++)t.queryXY(e,m),i.contains(m)&&(r=!0,a[e]=!0);if(!r)return t;const l=t.createInstance();for(let e=0;e<n;e++)a[e]||l.addPoints(t,e,e+1);return l}(t,e,y);case n.G.enumPoint:return function(t,e,s){const i=t.getImpl().getAttributeStreamRef(0),n=t.getPointCount(),r=e.getXY();let a=!1;const h=(0,o.f)(n,!1),l=(0,m.f)(s),u=l*l,c=new o.P;for(let t=0;t<n;t++)i.queryPoint2D(2*t,c),o.P.sqrDistance(c,r)<=u&&(a=!0,h[t]=!0);if(!a)return t;const g=t.createInstance();for(let e=0;e<n;e++)h[e]||g.addPoints(t,e,e+1);return g}(t,e,y)}const S=new h.J(f);S.inflate(100*y.total());const v=(0,l.c)(e,S,0,0,i);return(0,u.b)(t,v,s,i)}(t,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},32932:(t,e,s)=>{s.d(e,{O:()=>m});var i=s(76061),n=s(55537),r=s(89473),o=s(35368),a=s(95213);class h extends i.G{constructor(t,e,s,i,o){super(),this.m_smallCursor=null,this.m_progressTracker=i,this.m_geomIntersector=e.next(),this.m_intersector=new r.I(this.m_geomIntersector,s,o,i),this.m_index=-1,this.m_inputGeoms=t,this.m_dimensionMask=o,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&(0,n.t)("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let t;if(null!==this.m_smallCursor){if(t=this.m_smallCursor.next(),t)return t;this.m_smallCursor=null}for(;t=this.m_inputGeoms.next();)return(0,n.d)(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 m{getOperatorType(){return 1e4}accelerateGeometry(t,e,s){if(!this.canAccelerateGeometry(t))return!1;(0,a.m)(e,t,!0);let i=0;return t.getGeometryType()!==n.G.enumPolygon&&t.getGeometryType()!==n.G.enumPolyline||!(0,o.c)(t)||0===s||(i|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),!!i}canAccelerateGeometry(t){return(0,o.c)(t)}supportsCurves(){return!0}executeMany(t,e,s,i,n=-1){return new h(t,e,s,i,n)}execute(t,e,s,o){if(t.getGeometryType()===n.G.enumPoint&&e.getGeometryType()===n.G.enumPoint)return r.I.intersectPoints(t,e,s);const a=new i.S([t]),h=new i.S([e]),m=this.executeMany(a,h,s,o,-1).next();return m||(0,n.c)("null output"),m}}},32406:(t,e,s)=>{s.d(e,{O:()=>gt,T:()=>j,a:()=>W,b:()=>k,c:()=>U,d:()=>O,e:()=>H,f:()=>R,g:()=>B,i:()=>z,j:()=>L,k:()=>$,l:()=>st,n:()=>A,p:()=>X,q:()=>v,s:()=>V});var i,n,r,o=s(76061),a=s(55537),h=s(35368),m=s(86117),l=s(95213),u=s(79187),c=s(83661),g=s(90237);class _{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 _.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 d(t){return 1n<<(0x3fn&BigInt(t))}function p(t){return t>>6}class f{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=d(t),s=p(t);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&e)}setBit(t){const e=d(t),s=p(t);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=e}clearBit(t){}flipBit(t){const e=d(t),s=p(t);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=e,0n!==(this.m_bits[s]&e)}clear(){this.m_bits.length=0}isZero(){let t=0;return this.m_bits.forEach((e=>{t|=e?2:1})),!(2&t)}equals(t){if(this===t)return!0;if(this.m_bits.length!==t.m_bits.length)return!1;let e=0;return this.m_bits.forEach(((s,i)=>{e|=s===t.m_bits[i]?2:1})),!(1&e||(t.m_bits.forEach(((t,s)=>{e|=t===this.m_bits[s]?2:1})),1&e))}notEquals(t){return!this.equals(t)}assignOr(t){return t.m_bits.forEach(((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]|=t})),this}assignSubtract(t){return t.m_bits.forEach(((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=~t)})),this}assignAnd(t){return t.m_bits.forEach(((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=t)})),this}assignXor(t){return t.m_bits.forEach(((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]^=t})),this}getHashCode(){return this.m_bits.reduce(((t,e)=>(0,c.k)(t,e)),(0,c.l)(0))}getUnorderedBitIterator(){return new _(this)}}class x{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 P extends l.r{constructor(t){super(),this.m_bufferLeft=new h.S,this.m_bufferRight=new h.S,this.m_intervalLeft=c.E.constructEmpty(),this.m_intervalRight=c.E.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=t}compare(t,e,s){const i=e,n=t.getElement(s);this.m_helper.querySegmentXY(i,this.m_bufferLeft),this.m_helper.querySegmentXY(n,this.m_bufferRight);const r=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(r.getStartX(),r.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=r.getStartY()===r.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(r.getStartY()===o.getStartY()&&r.getStartX()===o.getStartX())return a?1:-1;if(r.getEndY()===o.getEndY()&&r.getEndX()===o.getEndX())return a?-1:1}let m=r.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const t=r.getEndY(),e=o.getEndY(),s=Math.min(t,e);let i=.5*(s+this.m_yScanline);i===this.m_yScanline&&(i=s),m=r.intersectionOfYMonotonicWithAxisX(i,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(i,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(t){this.m_yScanline=t}}class y{constructor(t){this.m_segmentBuffer=new h.S,this.m_point=c.P.getNAN(),this.m_parent=t}setPointXY(t){this.m_point.assign(t)}compare(t,e){const s=t.getElement(e);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const i=this.m_segmentBuffer.get(),n=new c.E;if(n.setCoords(i.getStartX(),i.getEndX()),this.m_point.x<n.vmin)return-1;if(this.m_point.x>n.vmax)return 1;const r=i.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<r?-1:this.m_point.x>r?1:0}}function E(t,e){return{parentage:t,rank:e}}function C(t,e){const s=t.length;if(s!==e.length)return!1;const i=t[0].parentage;if(i!==e[0].parentage)return!1;if(-1===i)return!0;for(let i=1;i<s;++i)if(t[i].parentage!==e[i].parentage)return!1;return!0}function S(t,e,s){s.length=0;let i=!1;{let n=t.getHalfEdgeVertexIterator(e);for(;n!==h.n;){const e=t.getVertexFromVertexIterator(n),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);i||=o>=0,s.push(E(o,r)),n=t.incrementVertexIterator(n)}}{let n=t.getHalfEdgeVertexIterator(t.getHalfEdgeTwin(e));for(;n!==h.n;){const e=t.getVertexFromVertexIterator(n),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);i||=o>=0,s.push(E(o,r)),n=t.incrementVertexIterator(n)}}i&&s.sort(((t,e)=>t.rank>e.rank?-1:t.rank<e.rank?1:t.parentage<e.parentage?-1:t.parentage>e.parentage?1:0)),-1===s[0].parentage&&(s.length=1)}(r=i||(i={}))[r.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",r[r.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",r[r.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding",function(t){t[t.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",t[t.enumPathBreakNode=2]="enumPathBreakNode"}(n||(n={}));class v{constructor(){this.m_shape=null,this.m_clusterData=new l.S(8),this.m_clusterVertices=new l.S(2),this.m_firstCluster=h.n,this.m_lastCluster=h.n,this.m_halfEdgeData=new l.S(8),this.m_chainData=new l.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,i.enumInputModeBuildGraph,null,e,!1):this.setEditShapeImpl_(t,i.enumInputModeBuildGraph,null,e,s)}setAndSimplifyEditShapeAlternate(t,e,s=null,n=!1){const r=[];r.push(e),this.m_simplifiedGeometry=e,n?this.setEditShapeImpl3D_(t,i.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(t,i.enumInputModeSimplifyAlternate,r,s,t.getGeometryType(e)===a.G.enumPolygon)}setAndSimplifyEditShapeWinding(t,e,s=null){const n=[];n.push(e),this.m_simplifiedGeometry=e,this.setEditShapeImpl_(t,i.enumInputModeSimplifyWinding,n,s,!0)}removeShape(){null!==this.m_shape&&(-1!==this.m_geometryIDIndex&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),-1!==this.m_clusterIndex&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),-1!==this.m_halfEdgeIndex&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),-1!==this.m_segmentParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),-1!==this.m_segmentIndexHe&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),-1!==this.m_clusterBreakNodeIndex&&(this.deleteUserIndexForClusters(this.m_clusterBreakNodeIndex),this.m_clusterBreakNodeIndex=-1),this.deleteEdgeBitSets_(),this.deleteChainBitSets_(),this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_shape=null,this.m_clusterData.deleteAll(!0),this.m_clusterVertices.deleteAll(!0),this.m_firstCluster=h.n,this.m_lastCluster=h.n,this.m_halfEdgeData.deleteAll(!0),this.m_edgeIndices.length=0,this.m_clusterIndices.length=0,this.m_chainIndices.length=0,this.m_chainData.deleteAll(!0),this.m_universeChain=h.n,this.m_chainAreas=null)}getClusterHalfEdge(t){return this.m_clusterData.getField(t,2)}queryXY(t,e){const s=this.getClusterVertexIndex_(t);e.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(t,e){(0,a.g)(0)}getClusterParentage(t){return this.m_clusterData.getField(t,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(t){return this.m_clusterData.getField(t,3)}getNextCluster(t){return this.m_clusterData.getField(t,4)}getClusterChain(t){return this.m_clusterData.getField(t,6)}getClusterVertexIterator(t){return this.m_clusterData.getField(t,7)}incrementVertexIterator(t){return this.m_clusterVertices.getField(t,1)}getVertexFromVertexIterator(t){return this.m_clusterVertices.getField(t,0)}getClusterUserIndex(t,e){const s=this.getClusterIndex_(t),i=this.m_clusterIndices[e];return i.size()<=s?-1:i.read(s)}setClusterUserIndex(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1),n.write(i,s)}hasClusterUserIndexFlags(t,e,s){if(-1===e)return!1;const i=this.getClusterUserIndex(t,e);return-1!==i&&!!(s&i)}setClusterUserIndexFlags(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1);let r=n.read(i);-1===r&&(r=0),n.write(i,s|r)}clearClusterUserIndexFlags(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1);let r=n.read(i);-1===r&&(r=0),n.write(i,~s&r)}createUserIndexForClusters(t=-1){const e=new l.A(this.m_clusterData.capacity(),t);for(let t=0,s=this.m_clusterIndices.length;t<s;t++)if(null===this.m_clusterIndices[t])return this.m_clusterIndices[t]=e,t;return this.m_clusterIndices.push(e),this.m_clusterIndices.length-1}deleteUserIndexForClusters(t){this.m_clusterIndices[t]=null}getHalfEdgeOrigin(t){return this.m_halfEdgeData.getField(t,1)}getHalfEdgeTo(t){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(t))}getHalfEdgeTwin(t){return this.m_halfEdgeData.getField(t,4)}getHalfEdgePrev(t){return this.m_halfEdgeData.getField(t,5)}getHalfEdgeNext(t){return this.m_halfEdgeData.getField(t,6)}getHalfEdgeChain(t){return this.m_halfEdgeData.getField(t,2)}getHalfEdgeFaceParentage(t){return this.getChainParentage(this.getHalfEdgeChain(t))}getHalfEdgeVertexIterator(t){return this.m_halfEdgeData.getField(t,7)}getHalfEdgeFromXY(t,e){this.queryXY(this.getHalfEdgeOrigin(t),e)}getHalfEdgeToXY(t,e){this.queryXY(this.getHalfEdgeTo(t),e)}isHalfEdgeCurve(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}getHalfEdgeFromXYZ(t,e){(0,a.g)(0)}getHalfEdgeToXYZ(t,e){(0,a.g)(0)}getHalfEdgeParentage(t){return this.m_halfEdgeData.getField(t,3)&v.c_EdgeParentageMask}getHalfEdgeUserIndex(t,e){const s=this.getHalfEdgeIndex_(t),i=this.m_edgeIndices[e];return i.size()<=s?-1:i.read(s)}setHalfEdgeUserIndex(t,e,s){const i=this.getHalfEdgeIndex_(t),n=this.m_edgeIndices[e];n.size()<=i&&n.resize(this.m_halfEdgeData.size(),-1),n.write(i,s)}createUserIndexForHalfEdges(t){void 0===t&&(t=-1);const e=new l.A(this.m_halfEdgeData.capacity(),t);for(let t=0,s=this.m_edgeIndices.length;t<s;t++)if(null===this.m_edgeIndices[t])return this.m_edgeIndices[t]=e,t;this.m_edgeIndices.push(e);const s=this.m_edgeIndices.length-1;return(0,a.g)(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(t){this.m_edgeIndices[t]=null}deleteEdgesBreakFaces_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.getHalfEdgeChain(s),n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeChain(n);this.setChainHalfEdge_(i,h.n),this.setChainHalfEdge_(r,h.n),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolygonExterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolygonBoundary(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolylineInterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolylineExterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonInterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonExterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonBoundary(t,e){return(0,a.g)(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(t){return this.m_chainData.getField(t,1)}getChainParentage(t){return this.m_chainData.getField(t,2)}getChainParent(t){return this.m_chainData.getField(t,3)}getChainFirstIsland(t){return this.m_chainData.getField(t,4)}getChainNextInParent(t){return this.m_chainData.getField(t,5)}getChainNext(t){return this.m_chainData.getField(t,7)}getChainArea(t){const e=this.getChainIndex_(t);let s=this.m_chainAreas.read(e);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(t),s=this.m_chainAreas.read(e)),s}getChainPerimeter(t){return(0,a.g)(0),0}getChainUserIndex(t,e){const s=this.getChainIndex_(t),i=this.m_chainIndices[e];return i.size()<=s?-1:i.read(s)}setChainUserIndex(t,e,s){const i=this.getChainIndex_(t),n=this.m_chainIndices[e];n.size()<=i&&n.resize(this.m_chainData.size(),-1),n.write(i,s)}createUserIndexForChains(){const t=new l.A(this.m_chainData.capacity(),-1);for(let e=0,s=this.m_chainIndices.length;e<s;e++)if(null===this.m_chainIndices[e])return this.m_chainIndices[e]=t,e;return this.m_chainIndices.push(t),this.m_chainIndices.length-1}deleteUserIndexForChains(t){this.m_chainIndices[t]=null}extractPolygonFromChainAndIslands(t,e,s,i){const n=e===h.n?t.createGeometry(a.G.enumPolygon):e,r=new h.S;this.extractPolygonPathFromChain_(t,n,s,i,r);for(let e=this.getChainFirstIsland(s);e!==h.n;e=this.getChainNextInParent(e))this.extractPolygonPathFromChain_(t,n,e,i,r);return n}getGeometryID(t){const e=this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex);return(0,a.g)(e>=0),1<<Math.min(e,31)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_clusterIndex)}getHalfEdgeFromVertex(t){return this.m_shape.getUserIndex(t,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(t){if((0,a.g)(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const e=this.getChainUserIndex(t,this.m_chainBitSetIndex);(0,a.g)(e>=0);let s=this.m_chainBitSets.at(e);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(t){(0,a.g)(this.m_bBuildGeometryParentageSets);const e=new f,s=t=>{const s=this.getChainHalfEdge(t);let i=s;do{const t=this.getEdgeBitSet_(i);null!==t&&e.assignOr(t);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(i));null!==s&&e.assignOr(s),i=this.getHalfEdgeNext(i)}while(i!==s)};s(t);for(let e=this.getChainFirstIsland(t);e!==h.n;e=this.getChainNextInParent(e))s(t);return e}getChainPolygons(t){return(0,a.g)(0),[]}getGeometriesFromBits(t){if(!this.m_bBuildGeometryParentageSets||null===t)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let t=this.m_shape.getFirstGeometry();t!==h.n;t=this.m_shape.getNextGeometry(t))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex),t)}const e=[],s=t.getUnorderedBitIterator();for(let t=s.next();t!==_.npos();t=s.next())(0,a.g)(this.m_geometryMapID.has(t)),e.push(this.m_geometryMapID.get(t));return e}getVertexDominant(t,e){if(e===h.n)return t;const s=this.getClusterFromVertex(t);return this.getVertexDominantFromCluster(s,e)}getVertexDominantFromCluster(t,e){if(e!==h.n){let s=h.n;for(let i=this.getClusterVertexIterator(t);i!==h.n;i=this.incrementVertexIterator(i)){const t=this.getVertexFromVertexIterator(i);s===h.n&&(s=t);const n=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(n)===e){s=t;break}}return s}{const e=this.getClusterVertexIterator(t);return e!==h.n?this.getVertexFromVertexIterator(e):h.n}}isBreakNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode)}setBreakNode(t,e){(0,a.g)(-1!==this.m_clusterBreakNodeIndex),e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode)}isStrongPathNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode)}setStrongPathNode(t,e){if(-1===this.m_clusterBreakNodeIndex){if(!e)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getHalfEdgeUserIndex(t,this.m_segmentParentageIndex);return e>=0?e:-1}isCrossroadAhead(t){const e=this.getHalfEdgeNext(t);if(this.isStrongPathNode(this.getHalfEdgeOrigin(e)))return!0;const s=this.getHalfEdgeTwin(e),i=this.getHalfEdgeNext(s);return t!==this.getHalfEdgeTwin(i)}isCrossroadBehind(t){return(0,a.g)(0),!1}getHalfEdgeConnector(t,e){const s=this.getClusterHalfEdge(t);if(s===h.n)return h.n;let i=s,n=h.n,r=h.n;do{if(this.getHalfEdgeTo(i)===e)return i;if(n===h.n){if(n=this.getClusterHalfEdge(e),n===h.n)return h.n;r=n}if(this.getHalfEdgeTo(r)===t)return i=this.getHalfEdgeTwin(r),i;i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i)),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(i!==s&&r!==n);return h.n}querySegmentXY(t,e){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const t=this.m_shape.getSegmentFromIndex(s);e.copyFrom(t,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe);const i=this.m_shape.getSegmentFromIndex(s);e.copyFrom(i,!0),e.get().reverse()}return}}e.createLine();const s=e.get(),i=c.P.getNAN();this.getHalfEdgeFromXY(t,i),s.setStartXY(i),this.getHalfEdgeToXY(t,i),s.setEndXY(i)}isCurveEdge(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}compareEdgeAnglesCurveHelper_(t,e,s){const i=new h.S,n=new h.S;this.querySegmentXY(t,i),this.querySegmentXY(e,n);const r=i.get(),o=n.get();if(r.equals(o))return 0;const m=new c.P;this.getHalfEdgeFromXY(t,m);const l=new c.P;this.getHalfEdgeToXY(t,l);const u=new c.P;this.getHalfEdgeToXY(e,u),(0,a.g)(!l.isEqualPoint2D(u));const g=r.getTangent(0),_=o.getTangent(0);return c.P.compareVectors(g,_)}compareEdgeAnglesHelper_(t,e,s){if(t===e)return 0;if(this.isHalfEdgeCurve(t)||this.isHalfEdgeCurve(e))return this.compareEdgeAnglesCurveHelper_(t,e,s);const i=c.P.getNAN();this.getHalfEdgeToXY(t,i);const n=c.P.getNAN();if(this.getHalfEdgeToXY(e,n),i.isEqualPoint2D(n))return 0;const r=c.P.getNAN();this.getHalfEdgeFromXY(t,r);const o=c.P.getNAN();o.setSub(i,r);const a=c.P.getNAN();return a.setSub(n,r),!s||a.y>=0&&o.y>0?c.P.compareVectors(o,a):0}compareEdgeAngles_(t,e){return this.compareEdgeAnglesHelper_(t,e,!1)}compareEdgeAnglesForPair_(t,e){return this.compareEdgeAnglesHelper_(t,e,!0)}compareEdgeAngles3D_(t,e){return(0,a.g)(0),0}compareEdgeAnglesForPair3D_(t,e){return(0,a.g)(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(t,e){}deleteEdgeInternal_(t){const e=this.getHalfEdgeChain(t),s=this.getHalfEdgeTwin(t),i=this.getHalfEdgeChain(s);(0,a.g)(i===e),(0,a.g)(t===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(t));let n=this.getHalfEdgeNext(t);n===s&&(n=this.getHalfEdgeNext(n),n===t&&(n=h.n));const r=this.getChainIndex_(e),o=this.m_chainAreas.read(r);Number.isNaN(o)||(this.setChainArea_(e,Number.NaN),this.setChainPerimeter_(e,Number.NaN));const m=this.getChainHalfEdge(e);m!==t&&m!==s||this.setChainHalfEdge_(e,n),this.updateVertexToHalfEdgeConnection_(t,!0),this.deleteEdgeImpl_(t)}getFirstUnvisitedHalfEdgeOnCluster_(t,e,s){let i=e!==h.n?e:this.getClusterHalfEdge(t);if(i===h.n)return h.n;const n=i;for(;;){if(1!==this.getHalfEdgeUserIndex(i,s))return i;const t=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));if(t===n)return h.n;i=t}}removeSpikes_(){let t=!1;const e=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==h.n;s=this.getNextCluster(s)){let i=h.n;for(;;){let n=this.getFirstUnvisitedHalfEdgeOnCluster_(s,i,e);if(n===h.n)break;i=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));let r=n;for(;;){const s=this.getHalfEdgeNext(r),o=this.getHalfEdgePrev(r),a=this.getHalfEdgeTwin(r);if(o===a){if(this.deleteEdgeInternal_(r),t=!0,i!==r&&i!==a||(i=h.n),r===n||o===n){if(n=s,r===n||o===n)break;r=s;continue}}else this.setHalfEdgeUserIndex(r,e,1);if(r=s,r===n)break}}}return this.deleteUserIndexForHalfEdges(e),t}progress_(t,e=!1){}newCluster_(){const t=this.m_clusterData.newElement();return this.m_clusterData.setField(t,1,0),t}newHalfEdgePair_(){const t=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0);const e=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0),this.setHalfEdgeTwin_(t,e),this.setHalfEdgeTwin_(e,t),t}newChain_(){const t=this.m_chainData.newElement();return this.m_chainData.setField(t,2,0),t}deleteChain_(t){return(0,a.g)(0),0}getClusterIndex_(t){return this.m_clusterData.elementToIndex(t)}setClusterVertexIterator_(t,e){this.m_clusterData.setField(t,7,e)}setClusterHalfEdge_(t,e){this.m_clusterData.setField(t,2,e)}setClusterParentage_(t,e){this.m_clusterData.setField(t,1,e)}setPrevCluster_(t,e){this.m_clusterData.setField(t,3,e)}setNextCluster_(t,e){this.m_clusterData.setField(t,4,e)}setClusterVertexIndex_(t,e){this.m_clusterData.setField(t,5,e)}getClusterVertexIndex_(t){return this.m_clusterData.getField(t,5)}setClusterChain_(t,e){this.m_clusterData.setField(t,6,e)}addClusterToExteriorChain_(t,e){this.setClusterChain_(e,t)}getHalfEdgeIndex_(t){return this.m_halfEdgeData.elementToIndex(t)}setHalfEdgeOrigin_(t,e){this.m_halfEdgeData.setField(t,1,e)}setHalfEdgeTwin_(t,e){this.m_halfEdgeData.setField(t,4,e)}setHalfEdgePrev_(t,e){this.m_halfEdgeData.setField(t,5,e)}setHalfEdgeNext_(t,e){this.m_halfEdgeData.setField(t,6,e)}setHalfEdgeChain_(t,e){this.m_halfEdgeData.setField(t,2,e)}setHalfEdgeParentage_(t,e){this.m_halfEdgeData.setField(t,3,e)}getHalfEdgeParentageMask_(t){return this.m_halfEdgeData.getField(t,3)}setHalfEdgeVertexIterator_(t,e){this.m_halfEdgeData.setField(t,7,e)}updateVertexToHalfEdgeConnectionHelper_(t,e){const s=e?h.n:t;for(let e=this.getHalfEdgeVertexIterator(t);e!==h.n;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);this.m_shape.setUserIndex(t,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(t,e){t!==h.n&&(this.updateVertexToHalfEdgeConnectionHelper_(t,e),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(t),e))}getChainIndex_(t){return this.m_chainData.elementToIndex(t)}setChainHalfEdge_(t,e){this.m_chainData.setField(t,1,e)}setChainParentage_(t,e){this.m_chainData.setField(t,2,e)}setChainParent_(t,e){this.m_chainData.setField(t,3,e);const s=this.getChainFirstIsland(e);this.setChainNextInParent_(t,s),this.setChainFirstIsland_(e,t)}setChainFirstIsland_(t,e){this.m_chainData.setField(t,4,e)}setChainNextInParent_(t,e){this.m_chainData.setField(t,5,e)}setChainPrev_(t,e){this.m_chainData.setField(t,6,e)}setChainNext_(t,e){this.m_chainData.setField(t,7,e)}setChainArea_(t,e){const s=this.getChainIndex_(t);this.m_chainAreas.write(s,e)}setChainPerimeter_(t,e){const s=this.getChainIndex_(t);this.m_chainPerimeters.write(s,e)}updateChainAreaAndPerimeter_(t){const e=this.m_shape.hasCurves(),s=new c.K(0),i=new c.K(0),n=this.getChainHalfEdge(t),r=c.P.getNAN(),o=c.P.getNAN(),a=c.P.getNAN();this.getHalfEdgeFromXY(n,r),o.setCoordsPoint2D(r);let m=n;do{this.getHalfEdgeToXY(m,a),e&&this.isCurveEdge(m)||i.pe(c.P.distance(o,a)),this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==t&&s.pe((a.x-r.x-(o.x-r.x))*(a.y-r.y+(o.y-r.y))*.5),o.setCoordsPoint2D(a),m=this.getHalfEdgeNext(m)}while(m!==n);if(e){const e=new h.S;m=n;do{this.getHalfEdgeToXY(m,a);const n=this.isCurveEdge(m);if(n&&(this.querySegmentXY(m,e),i.pe(e.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==t&&n){const t=e.get().calculateArea2DHelper();s.pe(t)}m=this.getHalfEdgeNext(m)}while(m!==n)}const l=this.getChainIndex_(t);this.m_chainAreas.write(l,s.getResult()),this.m_chainPerimeters.write(l,i.getResult())}getChainTopmostEdge_(t){return(0,a.g)(0),0}planeSweepParentage_(t,e){const s=new P(this),i=new l.T;i.setCapacity(Math.trunc(this.m_pointCount/2)),i.setComparator(s);const n=[],r=this.createUserIndexForHalfEdges();let o=null;const a=c.P.getNAN();for(let m=this.getFirstCluster();m!==h.n;m=this.getNextCluster(m)){this.progress_(e);const u=this.getClusterHalfEdge(m);if(u!==h.n){if(n.length=0,!this.tryOptimizedInsertion_(i,r,n,m,u)){this.queryXY(m,a),s.setY(a.y);let t=u;do{const e=this.getHalfEdgeUserIndex(t,r);-1!==e&&(i.deleteNode(e),this.setHalfEdgeUserIndex(t,r,l.S.impossibleIndex2())),t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(u!==t);t=u;do{if(-1===this.getHalfEdgeUserIndex(t,r)){const e=i.addElement(t);n.push(e)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(u!==t)}for(let e=n.length-1;e>=0;e--){const s=n[e],o=i.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,r,s),this.planeSweepParentagePropagateParentage_(i,s,t)}}else if(this.getClusterChain(m)===h.n){null===o&&(o=new y(this)),this.queryXY(m,a),o.setPointXY(a);const t=i.searchLowerBound(o);let e=this.m_universeChain;if(-1!==t){let s=i.getElement(t);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(i,t)),s!==h.n&&(e=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(e,m)}}this.deleteUserIndexForHalfEdges(r)}planeSweepParentagePropagateParentage_(t,e,s){const n=t.getElement(e),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==h.n)return;const o=this.getLeftSkipPolylines_(t,e),m=this.getHalfEdgeTwin(n),l=this.getHalfEdgeChain(m);let u=this.getChainParent(r),c=this.getChainParent(l);if(o===h.n)u===h.n&&(l===r?(this.setChainParent_(l,this.m_universeChain),c=this.m_universeChain,u=c):(c===h.n&&(this.setChainParent_(l,this.m_universeChain),c=this.m_universeChain),this.setChainParent_(r,l),u=l));else{const t=this.getHalfEdgeChain(o);if(c===h.n){if(this.getChainArea(t)<=0){const e=this.getChainParent(t);this.setChainParent_(l,e),c=e}else this.setChainParent_(l,t),c=t;l===r&&(u=c)}}u===h.n&&(this.trySetChainParentFromTwin_(r,l),u=this.getChainParent(r)),(0,a.g)(u!==h.n),s===i.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(t,e,n,o):s===i.enumInputModeSimplifyWinding?this.propagateParentageWinding_(t,e,n,o,m,r,l):s===i.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(t,e,n,o,m,r,l)}propagateParentageBuildGraph_(t,e,s,i){let n,r=e;i===h.n?(r=t.getNext(r),n=this.getHalfEdgeChain(s)):n=this.getHalfEdgeChain(i);let o=null,a=this.getChainParentage(n);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(n));-1!==r;r=t.getNext(r)){const e=t.getElement(r),s=this.getHalfEdgeTwin(e);n=this.getHalfEdgeChain(e);const i=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let t=this.getChainBitSet(i);t=new f({copy:t}),t.assignOr(o),this.setChainBitSet_(i,t);let s=this.getChainBitSet(n);const r=this.getLeftEdgeBitSet_(e),a=new f({copy:o});if(a.assignSubtract(r),a.isZero())break;s=new f({copy:s}),s.assignOr(a),this.setChainBitSet_(n,s),o=s}const h=this.getChainParentage(i),m=h|a;m!==h&&this.setChainParentage_(i,m);let l=this.getChainParentage(n);const u=a&~this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeParentageIndexLeft);if(u&&(l|=u,this.setChainParentage_(n,l)),0===u)break;a=l}}propagateParentageWinding_(t,e,s,i,n,r,o){if(r===o)return;let m=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);m+=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex);let l=0;const u=[],c=[];c.push(0);for(let s=t.getFirst();s!==e;s=t.getNext(s)){const e=t.getElement(s),i=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(e),r=this.getHalfEdgeChain(i);if(n!==r){let t=this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeWindingNumberIndex);t+=this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex),l+=t;let s=!1;0!==u.length&&u.at(-1)===r&&(c.pop(),u.pop(),s=!0),(0,a.g)(this.getChainParent(r)!==h.n),s&&this.getChainParent(r)===n||(c.push(l),u.push(n))}}if(l+=m,0!==u.length&&u.at(-1)===o&&(c.pop(),u.pop()),0!==l){if(0===c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(r,e)}}else if(0!==c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(r,e)}}propagateParentageAlternate_(t,e,s,i,n,r,o){const a=this.m_simplifiedGeometry,m=this.getGeometryID(a);if(i===h.n)this.setChainParentage_(o,this.m_universeGeomID),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,m):this.setChainParentage_(r,this.m_universeGeomID);else{const t=this.getChainParentage(o);if(0===t){const t=this.getHalfEdgeChain(i),e=this.getChainParentage(t);this.setChainParentage_(o,e),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,e===m?this.m_universeGeomID:m):this.setChainParentage_(r,e)}else 1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,t===m?this.m_universeGeomID:m):this.setChainParentage_(r,t)}}tryOptimizedInsertion_(t,e,s,i,n){let r=n,o=-1,a=h.n,m=0;do{if(2===m)return!1;const t=this.getHalfEdgeUserIndex(r,e);if(-1!==t){if(-1!==o)return!1;o=t}else{if(a!==h.n)return!1;a=r}m++,r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(n!==r);return a!==h.n&&-1!==o&&(this.setHalfEdgeUserIndex(t.getElement(o),e,l.S.impossibleIndex2()),t.setElement(o,a),s.push(o),!0)}trySetChainParentFromTwin_(t,e){const s=this.getChainArea(t);if(0===s)return!1;const i=this.getChainArea(e);if(s>0&&i<0||s<0&&i>0)return this.setChainParent_(t,e),!0;{const s=this.getChainParent(e);if(s!==h.n)return this.setChainParent_(t,s),!0}return!1}createHalfEdges_(t,e){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=e.size();s<n;s++){const n=e.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(n),m=this.m_shape.getGeometryFromPath(o),l=this.m_shape.getGeometryType(m);if((0,a.h)(l)){const e=this.m_shape.getNextVertex(n);if(e===h.n)continue;const s=this.m_shape.getUserIndex(e,this.m_clusterIndex);if(r===s)continue;const o=this.newHalfEdgePair_(),u=this.getHalfEdgeTwin(o),c=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(c,0,n),this.m_clusterVertices.setField(c,1,-1),this.setHalfEdgeVertexIterator_(o,c),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,r);const g=this.getClusterHalfEdge(r);if(g===h.n)this.setClusterHalfEdge_(r,o),this.setHalfEdgePrev_(o,u),this.setHalfEdgeNext_(u,o);else{const t=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,u),this.setHalfEdgeNext_(u,g),this.setHalfEdgeNext_(t,o),this.setHalfEdgePrev_(o,t)}this.setHalfEdgeOrigin_(u,s);const _=this.getClusterHalfEdge(s);if(_===h.n)this.setClusterHalfEdge_(s,u),this.setHalfEdgeNext_(o,u),this.setHalfEdgePrev_(u,o);else{const t=this.getHalfEdgePrev(_);this.setHalfEdgePrev_(_,o),this.setHalfEdgeNext_(o,_),this.setHalfEdgeNext_(t,u),this.setHalfEdgePrev_(u,t)}const d=this.getGeometryID(m);if(t===i.enumInputModeBuildGraph){const t=l===a.G.enumPolygon?d:0;if(this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,t),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndexLeft,t),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const t=new f,e=this.m_shape.getGeometryUserIndex(m,this.m_geometryIDIndex);t.setBit(e),this.setEdgeBitSet_(o,t),this.setEdgeBitSet_(u,null),this.setLeftEdgeBitSet_(u,t),this.setLeftEdgeBitSet_(o,null)}}else if(t===i.enumInputModeSimplifyWinding){const t=this.m_shape.getXY(n),s=this.m_shape.getXY(e);let i=0,r=0;t.compare(s)<0?i=1:r=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,i),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeWindingNumberIndex,r)}else t===i.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const p=l===a.G.enumPolygon?v.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,d|p),this.setHalfEdgeParentage_(u,d|p)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let t=0,s=e.size();t<s;t++){const s=e.read(t);if(this.m_shape.getSegment(s)){const t=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);t!==h.n&&(this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(t,e){{const s=this.getHalfEdgeVertexIterator(e);if(s!==h.n){const i=this.getHalfEdgeVertexIterator(t);this.m_clusterVertices.setField(s,1,i),this.setHalfEdgeVertexIterator_(t,s),this.setHalfEdgeVertexIterator_(e,h.n)}}const s=this.getHalfEdgeTwin(t),i=this.getHalfEdgeTwin(e);{const t=this.getHalfEdgeVertexIterator(i);if(t!==h.n){const e=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(t,1,e),this.setHalfEdgeVertexIterator_(s,t),this.setHalfEdgeVertexIterator_(i,h.n)}}if(-1!==this.m_segmentIndexHe){let n=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==n){if(-2===n){const s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,s)}if(n=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===n){const t=this.getHalfEdgeUserIndex(i,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,t)}}}}sortHalfEdgesByAngle_(t){const e=[];for(let s=this.getFirstCluster();s!==h.n;s=this.getNextCluster(s)){e.length=0;const n=this.getClusterHalfEdge(s);if(n!==h.n){let r=n;do{e.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(e.length>1){let r=!0;e.length>2?(e.sort(((t,e)=>this.compareEdgeAngles_(t,e))),e.push(e[0])):this.compareEdgeAnglesForPair_(e[0],e[1])>0?e[1]=(0,c.b)(e[0],e[0]=e[1]):r=!1;let o=e[0],a=o,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a),u=h.n;for(let s=1,n=e.length;s<n;s++){const n=e[s],r=this.getHalfEdgeTwin(n),c=this.getHalfEdgeOrigin(r);if(c!==m||n===a)this.updateVertexToHalfEdgeConnection_(u,!1),u=h.n,a=n,m=c,l=r;else{if(t===i.enumInputModeBuildGraph){const t=this.getHalfEdgeParentageMask_(a)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(a,t),this.setHalfEdgeParentage_(l,t),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let t,e,s;t=this.getEdgeBitSet_(a),e=this.getEdgeBitSet_(n),s=new f({copy:t}),s.assignOr(e),this.setEdgeBitSet_(a,s),t=this.getEdgeBitSet_(l),e=this.getEdgeBitSet_(r),s=new f({copy:t}),s.assignOr(e),this.setEdgeBitSet_(l,s),t=this.getLeftEdgeBitSet_(a),e=this.getLeftEdgeBitSet_(n),s=new f({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(a,s),t=this.getLeftEdgeBitSet_(l),e=this.getLeftEdgeBitSet_(r),s=new f({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(l,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const t=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),e=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,t),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeWindingNumberIndex,e)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const t=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),e=this.getHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,t),this.setHalfEdgeUserIndex(l,this.m_tmpHalfEdgeOddEvenNumberIndex,e)}this.mergeVertexListsOfEdges_(a,n),this.deleteEdgeImpl_(n),u=a,e[s]=h.n,n===o&&(e[0]=h.n,o=h.n)}}if(this.updateVertexToHalfEdgeConnection_(u,!1),u=h.n,!r){o=h.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s!==h.n){o=s;break}}n!==o&&this.setClusterHalfEdge_(s,o);continue}o=h.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s===h.n)continue;if(o===h.n){o=s,a=o,m=this.getHalfEdgeTo(a),l=this.getHalfEdgeTwin(a);continue}if(s===a)continue;const i=this.getHalfEdgeTwin(s),n=this.getHalfEdgeOrigin(i);this.setHalfEdgeNext_(l,s),this.setHalfEdgePrev_(s,l),a=s,m=n,l=i}this.setClusterHalfEdge_(s,o)}}}}sortHalfEdgesByAngle3D_(t){(0,a.g)(0)}buildChains_(t){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,h.n);let e=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let t=this.getFirstCluster();t!==h.n;t=this.getNextCluster(t)){const i=this.getClusterHalfEdge(t);if(i!==h.n){let t=i;do{if(1!==this.getHalfEdgeUserIndex(t,s)){const i=this.newChain_();this.setChainHalfEdge_(i,t),this.setChainPrev_(i,e),this.setChainNext_(e,i);let n=null;this.m_bBuildGeometryParentageSets&&(n=new f),e=i;let r=0,o=t;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(r|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&n.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,i),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==t);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(i,n),this.setChainParentage_(i,r)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==i)}}this.m_chainAreas=new l.k(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new l.k(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(t){(0,a.g)(0)}simplifyAlternate_(){(0,a.g)(0)}simplifyWinding_(){(0,a.g)(0)}setEditShapeImpl_(t,e,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=t,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let o=this.m_shape.getTotalPointCount();if(s){o=0;for(let t=0,e=s.length;t<e;t++)o+=this.m_shape.getPointCount(s[t])}const m=new l.A(0);let u=0,g=0;{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==h.n;){this.m_shape.setGeometryUserIndex(t,this.m_geometryIDIndex,g++);for(let e=this.m_shape.getFirstPath(t);e!==h.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,i=this.m_shape.getPathSize(e);s<i;s++)m.add(t),t=this.m_shape.getNextVertex(t)}(0,a.j)(this.m_shape.getGeometryType(t))||(u+=this.m_shape.getPathCount(t)),null!=s?(t=e<s.length?s[e]:h.n,e++):t=this.m_shape.getNextGeometry(t)}}this.m_universeGeomID=1<<Math.min(g,31),this.m_pointCount=m.size(),this.m_shape.sortVerticesSimpleByY(m,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(n,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,u)),this.m_clusterIndex=this.m_shape.createUserIndex();const _=c.P.getNAN();let d=0;const p=c.P.getNAN();for(let t=0;t<=this.m_pointCount;t++){if(t<this.m_pointCount){const e=m.read(t);this.m_shape.queryXY(e,p)}else p.setNAN();if(!_.isEqualPoint2D(p)){if(d<t){const e=this.newCluster_();let s=h.n,i=-1;for(let n=d;n<t;n++){i=m.read(n),this.m_shape.setUserIndex(i,this.m_clusterIndex,e);const t=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(t,0,i),this.m_clusterVertices.setField(t,1,s),s=t;const r=this.m_shape.getPathFromVertex(i),o=this.m_shape.getGeometryFromPath(r),a=this.getGeometryID(o);this.setClusterParentage_(e,this.getClusterParentage(e)|a)}this.setClusterVertexIterator_(e,s),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(i)),this.m_lastCluster!==h.n&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===h.n&&(this.m_firstCluster=e)}d=t,_.setCoordsPoint2D(p)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let t=0;t<this.m_pointCount;t++){const e=m.read(t);if(this.m_shape.getSegmentParentageBreakVertex(e)){const t=this.getClusterFromVertex(e);this.setBreakNode(t,!0)}}}this.progress_(n,!0);{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==h.n;){for(let e=this.m_shape.getFirstPath(t);e!==h.n;e=this.m_shape.getNextPath(e)){if(this.m_shape.isStrongPathStart(e)){const t=this.m_shape.getFirstVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(e)){const t=this.m_shape.isClosedPath(e)?this.m_shape.getFirstVertex(e):this.m_shape.getLastVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}}null!=s?(t=e<s.length?s[e]:h.n,e++):t=this.m_shape.getNextGeometry(t)}}if(e===i.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),e===i.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),e===i.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(e,m),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(e),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(e),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(e,n),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(t,e,s,i,n){(0,a.g)(0)}cleanSetEditShapeImpl_(){-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){(0,a.g)(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(t){const e=this.getHalfEdgeNext(t),s=this.getHalfEdgePrev(t),i=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(i),r=this.getHalfEdgePrev(i);e!==i&&(this.setHalfEdgeNext_(r,e),this.setHalfEdgePrev_(e,r)),s!==i&&(this.setHalfEdgeNext_(s,n),this.setHalfEdgePrev_(n,s));const o=this.getHalfEdgeOrigin(t);this.getClusterHalfEdge(o)===t&&(n!==t?this.setClusterHalfEdge_(o,n):this.setClusterHalfEdge_(o,h.n));const a=this.getHalfEdgeOrigin(i);this.getClusterHalfEdge(a)===i&&(e!==i?this.setClusterHalfEdge_(a,e):this.setClusterHalfEdge_(a,h.n)),this.m_halfEdgeData.deleteElement(t),this.m_halfEdgeData.deleteElement(i)}getLeftSkipPolylines_(t,e){let s=e;for(;;){if(s=t.getPrev(s),-1===s)return h.n;{const e=t.getElement(s);if(this.getHalfEdgeChain(e)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(e)))return e}}}checkStructureAfterDirtySweep_(){const t=(0,c.s)(this.m_checkDirtyPlanesweepTolerance),e=new c.P,s=new c.P,i=new c.P,n=new c.P,r=new c.P;for(let o=this.getFirstCluster();o!==h.n;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==h.n){let o=a;this.getHalfEdgeFromXY(o,e),this.getHalfEdgeToXY(o,s),i.setSub(s,e);let h=i.sqrLength();do{const a=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==a){this.getHalfEdgeToXY(o,n),r.setSub(n,e);const a=r.sqrLength(),m=r.crossProduct(i),l=m*m/(a*h);if(Math.min(a,h)*l<=t&&r.dotProduct(i)>=0)return!1;i.assign(r),h=a,s.assign(n)}}while(o!==a)}}return!0}extractPolygonPathFromChain_(t,e,s,i,n){const r=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(s);let a=o,m=h.n;const u=new l.P;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=h.n;const o=this.getHalfEdgeOrigin(a);if(i===h.n){const t=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(t)}else for(let t=this.getClusterVertexIterator(o);t!==h.n;t=this.incrementVertexIterator(t)){const e=this.getVertexFromVertexIterator(t);s===h.n&&(s=e);const n=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(n)===i){s=e;break}}let l;if(m===h.n&&(m=t.insertPath(e,h.n),t.setClosedPath(m,!0)),this.m_shape===t?l=t.addVertex(m,s):(this.m_shape.queryPoint(s,u),l=t.addPoint(m,u)),this.isHalfEdgeCurve(a)&&(this.querySegmentXY(a,n),t.setSegmentToIndex(t.getVertexIndex(l),n.get().clone())),r){const e=this.getSegmentParentage(a);t.setSegmentParentageAndBreak(l,e,this.isBreakNode(o))}}a=this.getHalfEdgeNext(a)}while(a!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;(0,a.g)(-1!==this.m_clusterBreakNodeIndex),(0,a.g)(-1===this.m_segmentParentageIndex);for(let t=this.getFirstCluster();t!==h.n;t=this.getNextCluster(t)){let e=0;const s=this.getClusterHalfEdge(t);if(s!==h.n){let t=s;do{e++,t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==s&&e<3)}2!==e&&this.setBreakNode(t,!0)}let t=[],e=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let i=this.getFirstCluster();i!==h.n;i=this.getNextCluster(i)){const n=this.getClusterHalfEdge(i);if(n!==h.n){let i=!1,r=n;do{let n=r;for(;-1===this.getHalfEdgeUserIndex(n,s);){const r=this.getHalfEdgeNext(n),o=this.getHalfEdgeTwin(n);S(this,n,e);const a=e.at(-1).parentage;if(!i){const e=this.getHalfEdgeOrigin(n);if(!this.isBreakNode(e)){const e=this.getHalfEdgePrev(n);n!==e&&(S(this,e,t),i=!0)}}if(i&&!C(e,t)){const t=this.getHalfEdgeOrigin(n);this.setBreakNode(t,!0)}t=(0,c.b)(e,e=t),i=!0;const h=this.getHalfEdgeOrigin(r);this.isBreakNode(h)&&(i=!1),this.setHalfEdgeUserIndex(n,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(n,s,1),this.setHalfEdgeUserIndex(o,s,1),n=r}r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(t){return null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=new x((t=>t.getHashCode()),((t,e)=>t.equals(e))),this.m_uniqueBitSets.add(this.getEmptySet())),null===t?this.getEmptySet():this.m_uniqueBitSets.has(t)?this.m_uniqueBitSets.get(t):(this.m_uniqueBitSets.add(t),t)}getLeftEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);return(0,a.g)(e>=0),(0,a.g)(this.m_edgeBitSets.at(e)),this.m_edgeBitSets.at(e)}getEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);return(0,a.g)(e>=0),this.m_edgeBitSets.at(e)}setEdgeBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setLeftEdgeBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setChainBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(t,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=e:(this.setChainUserIndex(t,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(e))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new f),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(t){}dbgVerifyEdgeSegment(t){}}function b(t,e,s){return{vertex0:t,vertex1:e,dir:s}}v.c_EdgeParentageMask=~(1<<31),v.c_EdgeBitMask=1<<31;class I{constructor(t){this.m_shape=null,this.m_spikes=[],this.m_points=new l.A(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=t}executeImpl_(t,e){if(this.m_shape=t,t.getPathCount(e)<2&&t.getPointCount(e)<6)return;this.m_points.resize(0);for(let s=t.getFirstPath(e);s!==h.n;s=t.getNextPath(s)){let e=t.getFirstVertex(s);for(let i=0,n=t.getPathSize(s);i<n;i++,e=t.getNextVertex(e))this.m_points.add(e)}this.m_pointsIndex=t.createUserIndex();for(let e=0,s=this.m_points.size();e<s;++e)t.setUserIndex(this.m_points.read(e),this.m_pointsIndex,e);t.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const i=t.getXY(s);let n=1,r=0;const o=[];for(let e=1;e<this.m_points.size();e++){const a=this.m_points.read(e);if(a===h.n)continue;if(-1===t.getUserIndex(a,this.m_pointsIndex))continue;const m=t.getXY(a);if(m.isEqualPoint2D(i))n++;else{if(n>1){for(let s=r;s<e;s++){const e=this.m_points.read(s);if(-1===t.getUserIndex(e,this.m_pointsIndex))continue;const n=t.getNextVertex(e),r=t.getPrevVertex(e);if(e!==n&&!t.isEqualXYPoint2D(n,i)){const t=b(e,n,1);o.push(t)}if(e!==r&&r!==n&&!t.isEqualXYPoint2D(r,i)){const t=b(e,r,-1);o.push(t)}}o.length>0&&this.processBunch_(o,i)}s=a,i.assign(m),n=1,r=e}}if(0===this.m_dissolvedEdges)return t.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let m=t.getPointCount(e);for(let e=0;e<this.m_points.size();e++){const s=this.m_points.read(e);if(s===h.n)continue;if(-1!==t.getUserIndex(s,this.m_pointsIndex)){t.setUserIndex(s,this.m_pointsIndex,-1);continue}const i=t.getPathFromVertex(s);t.getFirstVertex(i)===s&&t.setFirstVertex(i,h.n),t.freeVertex(s),this.m_points.write(e,h.n),m--}const l=t.createPathUserIndex();let u=t.getPathCount(e);for(let s=0,i=this.m_points.size();s<i;++s){if(this.m_points.read(s)===h.n)continue;let i=this.m_points.read(s);if(-1!==t.getUserIndex(i,this.m_pointsIndex))continue;let n=t.getPathFromVertex(i),r=-1;if(2===t.getPathUserIndex(n,l)){n=h.n;for(let e=t.getNextVertex(i);e!==i;e=t.getNextVertex(e)){const s=t.getPathFromVertex(e);if(2!==t.getPathUserIndex(s,l)){n=s,i=e;break}}n===h.n&&(n=t.insertPath(e,h.n),t.setClosedPath(n,!0),u++),(0,a.g)(n!==h.n)}t.setPathUserIndex(n,l,2),r=t.getFirstVertex(n);let o=0,m=!1,c=i;do{r===c&&(m=!0),t.setUserIndex(c,this.m_pointsIndex,1);const e=t.getPathFromVertex(c);e!==n&&(2!==t.getPathUserIndex(e,l)&&(t.setPathUserIndex(e,l,1),t.setFirstVertex(e,h.n)),t.setPathToVertex(c,n)),o++,c=t.getNextVertex(c)}while(c!==i);m||t.setFirstVertex(n,i),t.setPathSize(n,o)}for(let s=t.getFirstPath(e);s!==h.n;){const e=t.getNextPath(s);1!==t.getPathUserIndex(s,l)&&t.getFirstVertex(s)!==h.n||(t.removePathOnly(s),u--),s=e}t.setGeometryVertexCount(e,m),t.setGeometryPathCount(e,u),t.removePathUserIndex(l),t.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,t.dbgVerifyVertexCounts(),t.filterClosePoints(0,!0,!1,!1,e)}processBunch_(t,e){t.sort(((t,s)=>{const i=this.m_shape.getXY(t.vertex1).sub(e),n=this.m_shape.getXY(s.vertex1).sub(e),r=c.P.compareVectors(i,n);return 0===r?t.dir<s.dir?-1:1:r}));let s=0;const i=this.m_shape.getXY(t[0].vertex1);let n=1;const r=this.m_shape.hasCurves();for(let e=1,o=t.length;e<o;e++){const a=this.m_shape.getXY(t[e].vertex1);if(!(a.isEqualPoint2D(i)&&(n++,e+1<o))){if(2===n){const e=t[s],i=t[s+1],n=e.dir;if(n!==i.dir){let t=!0;if(r&&(t=!this.m_shape.isCurve(1===e.dir?e.vertex0:e.vertex1)&&!this.m_shape.isCurve(1===i.dir?i.vertex0:i.vertex1)),t){if(1===n){const t=e.vertex0,s=i.vertex0;this.m_shape.setNextVertex(t,s),this.m_shape.setPrevVertex(s,t),this.m_shape.getPrevVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const n=e.vertex1,r=i.vertex1;this.m_shape.setPrevVertex(n,r),this.m_shape.setNextVertex(r,n),this.m_shape.getNextVertex(n)===r&&(this.m_shape.setUserIndex(n,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}else{const t=e.vertex0,s=i.vertex0;this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(s,t),this.m_shape.getNextVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const n=e.vertex1,r=i.vertex1;this.m_shape.setNextVertex(n,r),this.m_shape.setPrevVertex(r,n),this.m_shape.getPrevVertex(n)===r&&(this.m_shape.setUserIndex(n,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}i.assign(a),s=e,n=1}}t.length=0}}class w{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,c.b)(e,e=s));const i=c.P.getNAN(),n=c.P.getNAN();return this.m_shape.queryXY(e,i),this.m_shape.queryXY(s,n),(0,a.g)(!i.equals(n)),i.y<n.y}getStart(t){const e=this.getEnd1(t),s=this.getEnd2(t);return this.m_shape.getNextVertex(e)===s?e:s}getEnd1(t){return this.m_end1Nodes[t]}getEnd2(t){return this.m_end2Nodes[t]}freeEdge(t){this.m_end1Nodes[t]=this.m_firstFree,this.m_firstFree=t}newEdge(t){if(-1!==this.m_firstFree){const e=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[e],this.m_end1Nodes[e]=t,this.m_end2Nodes[e]=this.m_shape.getNextVertex(t),e}const e=this.m_end1Nodes.length;return this.m_end1Nodes.push(t),this.m_end2Nodes.push(this.m_shape.getNextVertex(t)),e}getShape(){return this.m_shape}getPath(t){return this.m_shape.getPathFromVertex(this.getEnd1(t))}}let D=class extends l.r{constructor(t){super(),this.m_line1=new h.L,this.m_line2=new h.L,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_edges;let r;this.m_leftElm===e?r=this.m_leftx:(this.m_seg1=n.getSegment(e),this.m_seg1?r=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(n.getShape().queryLineConnector(n.getStart(e),this.m_line1,!0),this.m_seg1=this.m_line1,r=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=r,this.m_leftElm=e);let o,h=n.getSegment(i);if(h?o=h.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(n.getShape().queryLineConnector(n.getStart(i),this.m_line2,!0),h=this.m_line2,o=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),r===o){const t=n.isBottomUp(e),s=n.isBottomUp(i),m=t?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=s?h.getEndY():h.getStartY(),u=Math.min(m,l);let c=.5*(u+this.m_helper.m_yScanline);c===this.m_helper.m_yScanline&&(c=u),r=this.m_seg1.intersectionOfYMonotonicWithAxisX(c,0),o=h.intersectionOfYMonotonicWithAxisX(c,0),r===o&&(0,a.l)("")}return r<o?-1:r>o?1:0}reset(){this.m_leftElm=-1}};class T{constructor(t){this.m_node=-1,this.m_index=0,this.m_sortedVertices=t.m_sortedVertices,this.m_sortedVerticesArray=t.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const t=this.m_node;if(-1===t)return h.n;const e=this.m_sortedVertices.getData(t);return this.m_node=this.m_sortedVertices.getNext(t),e}if(this.m_index<this.m_sortedVerticesArray.size()){const t=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,t}return h.n}}class N{constructor(t){this.m_edges=null,this.m_shape=null,this.m_AET=new l.T,this.m_yScanline=0,this.m_geometry=h.n,this.m_unknownRingOrientationCount=-1,this.m_sortedVertices=null,this.m_sortedVerticesArray=null,this.m_unknownNodes=[],this.m_node1UserIndex=-1,this.m_node2UserIndex=-1,this.m_pathOrientationIndex=-1,this.m_pathParentageIndex=-1,this.m_pathParentsIndex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_progressTracker=t,this.m_AET.disableBalancing(),this.m_sweepComparator=new D(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 w(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(t),!this.m_AET.isAutoBalancing()){let e=0;for(let s=0,i=t.length;s<i;s++)-1!==t[s]&&e++;(e>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let e=0,s=t.length;e<s;e++){const s=t[e];s!==h.n&&this.insertEdge_(s,-1)}for(let t=0;t<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;t++){const s=this.m_unknownNodes[t],i=this.m_AET.getElement(s),n=this.m_edges.getPath(i),r=this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex);let o=h.n;if(0===r){let t=this.m_AET.getPrev(s),i=s,n=!1;for(;t!==l.T.st_nullNode();){const e=this.m_AET.getElement(t),s=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(s,this.m_pathOrientationIndex)){o=s;break}i=t,t=this.m_AET.getPrev(t)}if(t===l.T.st_nullNode())n=!0,t=i;else{const e=this.m_AET.getElement(t);n=this.m_edges.isBottomUp(e),t=this.m_AET.getNext(t),n=!n}do{const s=this.m_AET.getElement(t),r=this.m_edges.getPath(s);if(0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)){if(n!==this.m_edges.isBottomUp(s)){const t=this.m_shape.getFirstVertex(r);this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(r,this.m_shape.getPrevVertex(t)),e=!0}if(this.m_shape.setPathUserIndex(r,this.m_pathOrientationIndex,n?3:2),!n){let t=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);2===t?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),t=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),(0,a.g)(3===t)):(0,a.g)(3===t);const e=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,r),this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,e),this.m_shape.setPathUserIndex(r,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return e}o=r,i=t,t=this.m_AET.getNext(t),n=!n}while(i!==s)}}return e}processBunchForRingOrientationRemoveEdges_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.m_shape.getUserIndex(s,this.m_node1UserIndex),n=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==i){const t=this.m_AET.getElement(i);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==n){const t=this.m_AET.getElement(n);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let r=-1;-1!==i&&-1!==n?(this.m_AET.deleteNode(i),this.m_AET.deleteNode(n),t[e]=h.n):r=-1!==i?i:n,-1!==r&&(this.insertEdge_(s,r)||this.m_AET.deleteNode(r),t[e]=h.n)}}dbgVerifyRingOrientation_(){}insertEdge_(t,e){const s=c.P.getNAN(),i=c.P.getNAN();this.m_shape.queryXY(t,s);const n=this.m_shape.getNextVertex(t);this.m_shape.queryXY(n,i);let r=!1;if(s.y<i.y){r=!0;const s=this.m_edges.newEdge(t);let i;-1===e?i=this.m_AET.addElement(s):(i=e,this.m_AET.setElement(i,s)),-1===this.m_shape.getUserIndex(n,this.m_node1UserIndex)?this.m_shape.setUserIndex(n,this.m_node1UserIndex,i):this.m_shape.setUserIndex(n,this.m_node2UserIndex,i);const o=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(i)}const o=this.m_shape.getPrevVertex(t);if(this.m_shape.queryXY(o,i),s.y<i.y){r=!0;const s=this.m_edges.newEdge(o);let i;-1===e?i=this.m_AET.addElement(s):(i=e,this.m_AET.setElement(i,s)),-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,i):this.m_shape.setUserIndex(o,this.m_node2UserIndex,i);const n=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(i)}return r}fixRingSelfTangency_(){const t=[],e=[];let s=-1,i=-1;const n=new c.P;let r=h.n,o=h.n,m=-1;const l=new T(this);for(let a=l.next();a!==h.n;a=l.next()){const h=new c.P;this.m_shape.queryXY(a,h);const l=this.m_shape.getPathFromVertex(a);n.equals(h)&&o===l?(-1===i&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),i=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,i,-1)),-1===m&&(m=e.length,this.m_shape.setUserIndex(r,i,m),e.push(1),-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,r),t.push(l))),this.m_shape.setUserIndex(a,i,m),e[e.length-1]++):(m=-1,n.assign(h)),r=a,o=l}if(0===t.length)return!1;(0,a.g)(-1!==s);for(let n=0,r=t.length;n<r;n++){const r=t[n];let o=this.m_shape.getPathUserIndex(r,s);const a=this.m_shape.getUserIndex(o,i),h=[],m=[];h.push(o),m.push(a);for(let t=this.m_shape.getNextVertex(o);t!==o;t=this.m_shape.getNextVertex(t)){const s=t,n=this.m_shape.getUserIndex(s,i);if(-1!==n){if(0===m.length){m.push(n),h.push(s);continue}if(m.at(-1)===n){const r=h.at(-1);this.m_shape.peelALoopIntoAPath(r,s),this.m_shape.setUserIndex(t,i,-1),e[n]--,1===e[n]&&(e[n]=0,m.pop(),h.pop()),o=r,t=r}else h.push(t),m.push(n)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(i),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(t=!1){}fixRingOrientationImplMain_(){const t={stack:[],error:void 0,hasError:!1};try{let e,s=!1;const i=(0,g.b)(t,(0,c.i)((()=>{this.m_sortedVerticesArray=null})),!1);if(null===this.m_sortedVertices){const t=this.m_shape.getPointCount(this.m_geometry);e=new l.A(0);for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++)e.add(s),s=this.m_shape.getNextVertex(s)}this.m_shape.sortVerticesSimpleByY(e,0,t),this.progress_(!0),this.m_sortedVerticesArray=e}else i.bForget=!0;if(this.m_bFixSelfTangency&&(s=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const t=this.m_shape.getFirstPath(this.m_geometry),e=this.m_shape.getRingArea(t);if(this.m_shape.setExterior(t,!0),e<0){const e=this.m_shape.getFirstVertex(t);return this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(e)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t))this.m_shape.setPathUserIndex(t,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(t,this.m_pathParentsIndex,-1);const n=[];this.m_yScanline=Number.NaN;const r=c.P.getNAN();this.m_unknownRingOrientationCount=this.m_shape.getPathCount(this.m_geometry),this.m_node1UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node1UserIndex,-1),this.m_node2UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node2UserIndex,-1);const o=new T(this);for(let t=o.next();t!==h.n&&(this.progress_(),this.m_shape.queryXY(t,r),r.y!==this.m_yScanline&&n.length&&(s=this.processBunchForRingOrientationTest_(n)||s,this.m_sweepComparator.reset(),n.length=0),n.push(t),this.m_yScanline=r.y,0!==this.m_unknownRingOrientationCount);t=o.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(n)||s,n.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(e){t.error=e,t.hasError=!0}finally{(0,g.c)(t)}}fixRingOrientationImplSimplify_(){const t=[];for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==h.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(e,this.m_pathOrientationIndex)){this.m_shape.setExterior(e,!0);for(let s=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s!==h.n;){const i=this.m_shape.getPathUserIndex(s,this.m_pathParentageIndex);t.push(s),this.m_shape.setExterior(s,!1),this.m_shape.setPathUserIndex(s,this.m_pathParentageIndex,e),s=i}let s=e,i=t.length;for(let t=this.m_shape.getNextPath(e);i>0&&t!==h.n;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==e){s=h.n;break}s=t}if(0!==i){s=e;for(let e=0,i=t.length;e<i;e++){const i=t[e];this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,l.l),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),i),s=i}}t.length=0,e=this.m_shape.getNextPath(s)}else e=this.m_shape.getNextPath(e);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const t=this.m_shape.createPathUserIndex();let e=0;const s=[];for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==h.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)){this.m_shape.setExterior(i,!0),this.m_shape.setPathUserIndex(i,t,e),e++;for(let t=this.m_shape.getPathUserIndex(i,this.m_pathParentageIndex);t!==h.n;){const e=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);s.push(t),this.m_shape.setExterior(t,!1),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,i),t=e}let n=i,r=s.length,o=e;for(let e=this.m_shape.getNextPath(i);r>0&&e!==h.n;e=this.m_shape.getNextPath(e),--r){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==i){n=h.n;break}n=e,this.m_shape.setPathUserIndex(e,t,-o),o++}if(0!==r){n=i,o=e;for(let e=0,i=s.length;e<i;e++){const i=s[e];this.m_shape.setPathUserIndex(i,t,-o),o++,this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,l.l)}n=i}e=o,s.length=0,i=this.m_shape.getNextPath(n)}else i=this.m_shape.getNextPath(i);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),t}}function A(t,e,s,i,n,r){const o=new G(r);return o.m_shape=t,o.m_geometry=e,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=i,o.m_polylineDegeneracies=n,o.m_bHasSegmentParentage=t.hasSegmentParentage(),o.m_bHasSegments=t.hasCurves(),o.simplify_()}class G{constructor(t){this.m_shape=null,this.m_geometry=h.n,this.m_sortedVertices=new l.I,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=h.n,this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_bHasSegmentParentage=!1,this.m_bHasSegments=!1,this.m_progressTracker=t}compareAngles_(t,e){if(this.m_bHasSegments)return this.compareAnglesCurves_(t,e);const s=this.m_bunchEdgeEndPoints[t],i=new c.P;this.m_shape.queryXY(s,i);const n=new c.P,r=this.m_bunchEdgeEndPoints[e];if(this.m_shape.queryXY(r,n),i.equals(n))return 0;const o=this.m_bunchEdgeCenterPoints[t],h=new c.P;this.m_shape.queryXY(o,h);const m=this.m_bunchEdgeCenterPoints[e],l=new c.P;this.m_shape.queryXY(m,l);const u=new c.P;u.setSub(i,h);const g=new c.P;return g.setSub(n,l),(u.isZero()||g.isZero())&&(0,a.l)(""),c.P.compareVectors(u,g)}compareAnglesCurves_(t,e){const s=this.m_bunchEdgeEndPoints[t],i=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeCenterPoints[t],r=this.m_bunchEdgeCenterPoints[e],o=this.m_shape.getNextVertex(n)===s,m=this.m_shape.getNextVertex(r)===i,l=new h.S,u=new c.P;o?(this.m_shape.querySegment(n,l,!1,!0),u.assign(l.get().getTangent(0))):(this.m_shape.querySegment(s,l,!1,!0),u.assign(l.get().getTangent(1)),u.negateThis());const g=new c.P;return m?(this.m_shape.querySegment(r,l,!1,!0),g.assign(l.get().getTangent(0))):(this.m_shape.querySegment(i,l,!1,!0),g.assign(l.get().getTangent(1)),g.negateThis()),(u.isZero()||g.isZero())&&(0,a.l)(""),c.P.compareVectors(u,g)}beforeRemoveVertex_(t,e){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(t),e){const e=this.m_shape.getPathFromVertex(t);if(e!==h.n&&this.m_shape.getFirstVertex(e)===t){const s=this.m_shape.getNextVertex(t);if(s!==t){if(this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s);{const s=this.m_shape.getPrevVertex(t);if(s!==t&&this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s)}}this.m_shape.setFirstVertex(e,h.n),this.m_shape.setLastVertex(e,h.n)}}}processBunch_(){let t=!1;const e=new c.P(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,i=0,n=!0;for(;s!==this.m_nextVertexToProcess;){const t=this.m_sortedVertices.getData(s);n&&(this.m_shape.queryXY(t,e),n=!1);const r=this.m_shape.getPrevVertex(t),o=this.m_shape.getNextVertex(t);this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex)!==l.l&&(this.m_bunchEdgeEndPoints.push(r),this.m_shape.setUserIndex(r,this.m_userIndexSortedAngleIndexToVertex,l.l),this.m_bunchEdgeCenterPoints.push(t),this.m_bunchEdgeIndices.push(i++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==l.l&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,l.l),this.m_bunchEdgeCenterPoints.push(t),this.m_bunchEdgeIndices.push(i++)),s=this.m_sortedVertices.getNext(s)}if(this.m_bunchEdgeEndPoints.length<2){1===this.m_bunchEdgeEndPoints.length&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort(((t,e)=>this.compareAngles_(t,e)));for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t],s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,t)}const r=this.processCrossOvers_(e);for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t];if(-1===e)continue;const s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!r)break;t=!0}return t}processCrossOvers_(t){let e=!1,s=!0;for(;s;){s=!1;let i=0;-1===this.m_bunchEdgeIndices[i]&&(i=this.getNextEdgeIndex_(i));let n=this.getNextEdgeIndex_(i);for(let r=0,o=this.m_bunchEdgeIndices.length;r<o&&-1!==i&&-1!==n&&i!==n;r++){const r=this.m_bunchEdgeIndices[i],o=this.m_bunchEdgeIndices[n],a=this.m_bunchEdgeEndPoints[r],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a),l=!0);let u=this.m_shape.getNextVertex(h),c=!1;this.m_shape.isEqualXYPoint2D(u,t)||(u=this.m_shape.getPrevVertex(h),c=!0);const g=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=c?this.m_shape.getPrevVertex(u):this.m_shape.getNextVertex(u);let d=!1;(this.removeSpike_(m)||this.removeSpike_(u)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(g)||this.removeSpike_(_))&&(d=!0),m!==u&&(!d&&this.m_shape.isEqualXY(a,h)&&(d=this.resolveOverlap_(l,c,m,a,u,h)),!d&&this.m_shape.isEqualXY(g,_)&&(d=this.resolveOverlap_(!l,!c,m,g,u,_)),!d&&this.m_shape.isEqualXY(a,_)&&(d=this.resolveOverlap_(l,!c,m,a,u,_)),!d&&this.m_shape.isEqualXY(g,h)&&(d=this.resolveOverlap_(!l,c,m,g,u,h))),d&&(e=!0),s||=d,i=d?this.getNextEdgeIndex_(i):n,n=this.getNextEdgeIndex_(i)}}if(!e){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let i=this.getNextEdgeIndex_(s);for(let n=0,r=this.m_bunchEdgeIndices.length;n<r&&-1!==s&&-1!==i&&s!==i;n++){const n=this.m_bunchEdgeIndices[s],r=this.m_bunchEdgeIndices[i],o=this.m_bunchEdgeEndPoints[n],a=this.m_bunchEdgeEndPoints[r];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,t)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),u=this.getDirection_(m,a),c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),g=u?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,u,o,h,c,a,m,g);1!==_?0===_?(s=this.getNextEdgeIndex_(s),i=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),i=this.getNextEdgeIndex_(s)):e=!0}}return e}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===a.G.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)&&new j(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 l.A(0);this.m_shape.dbgVerifyMonotone();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,e),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(e),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let t=0;t<e;t++){const e=s.read(t),i=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,i)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(t=!0);let i=0,n=!1;do{n=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const e=new c.P(0,0);this.m_firstCoincidentVertex!==l.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),e);let s=0,r=this.m_firstCoincidentVertex;for(;r!==l.I.st_nullNode()&&(r=this.m_sortedVertices.getNext(r),r!==l.I.st_nullNode());){this.progress_();const t=this.m_sortedVertices.getData(r),i=c.P.getNAN();if(this.m_shape.queryXY(t,i),e.equals(i))s++;else{if(s>0){this.m_nextVertexToProcess=r;const t=this.processBunch_();r=this.m_nextVertexToProcess,r!==l.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(r),i),t&&(n=!0)}e.setCoordsPoint2D(i),this.m_firstCoincidentVertex=r,s=0}}this.m_nextVertexToProcess=-1,s>0&&this.processBunch_()&&(n=!0),i++>10&&(0,a.c)(""),n&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(n=!0),t||=n}while(n);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),t=function(t,e,s,i,n){const r=new N(n);return r.m_shape=t,r.m_geometry=e,r.m_sortedVertices=s,r.m_bFixSelfTangency=i,r.fixRingOrientation_()}(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||t,this.m_shape.dbgVerifyCurves(),t}getDirection_(t,e){return this.m_shape.getNextVertex(e)!==t}detectAndResolveCrossOver_(t,e,s,i,n,r,o,a){if(i===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(r),-1;const h=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),m=this.m_shape.getUserIndex(n,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),u=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),g=new Array(8),_=new Array(4);g[0]=0,_[0]=h,g[1]=0,_[1]=m,g[2]=1,_[2]=l,g[3]=1,_[3]=u;for(let t=1;t<4;t++){const e=_[t],s=g[t];let i=t-1;for(;i>=0&&_[i]>e;)_[i+1]=_[i],g[i+1]=g[i],i--;_[i+1]=e,g[i+1]=s}let d=0;if(g[0]&&(d|=1),g[1]&&(d|=2),g[2]&&(d|=4),g[3]&&(d|=8),5!==d&&10!==d)return 0;if(t!==e&&(a=(0,c.b)(r,r=a)),t)this.m_shape.setNextVertex(a,i),this.m_shape.setPrevVertex(i,a),this.m_shape.setNextVertex(n,o),this.m_shape.setPrevVertex(o,n),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,i),this.m_shape.setNextVertex(i,a),this.m_shape.setPrevVertex(n,o),this.m_shape.setNextVertex(o,n),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(i),e=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(i,e,!0),this.m_shape.setSegmentParentageAndBreak(o,t,!0)}if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(i),e=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,n),this.m_shape.setSegmentToIndex(e,s)}}return 1}resolveOverlap_(t,e,s,i,n,r){return this.resolveOverlapOddEven_(t,e,s,i,n,r)}resolveOverlapOddEven_(t,e,s,i,n,r){if(t!==e){t||(n=(0,c.b)(s,s=n),r=(0,c.b)(i,i=r));const e=this.m_shape.getNextVertex(n),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,e),this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(n,o),this.m_shape.setPrevVertex(o,n),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(s),e=this.m_shape.getVertexIndex(n),i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const r=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,r),this.m_shape.setSegmentToIndex(e,i)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(s),e=this.m_shape.getSegmentParentage(n);this.m_shape.setSegmentParentageAndBreak(s,e,!0),this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}this.removeSpike_(n)}else{const o=t?s:i,a=e?n:r,h=t?i:s,m=e?r:n;let l=null;if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null);const e=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(e,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let u=-1;this.m_bHasSegmentParentage&&(u=this.m_shape.getSegmentParentage(m));let c=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(h,m),this.m_shape.setPrevVertex(m,h);let g=m;for(;g!==a;){const t=this.m_shape.getPrevVertex(g),e=this.m_shape.getNextVertex(g);if(this.m_shape.setPrevVertex(g,e),this.m_shape.setNextVertex(g,t),c||=g===o,this.m_bHasSegments&&g!==o){const t=this.m_shape.getVertexIndex(e),s=l;l=this.m_shape.getSegmentFromIndex(t),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(t,s)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(e);this.m_shape.setSegmentParentagePreserveBreak(e,u),u=t}g=e}let _=null;if(!c){const t=this.m_shape.getPrevVertex(a),e=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,e),this.m_shape.setNextVertex(a,t),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null)}}let d=-1,p=-1;if(this.m_bHasSegmentParentage&&(d=c?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(h)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(m,h),this.beforeRemoveVertex_(m,!0),this.m_shape.removeVertexInternal(m,!0),this.removeAngleSortInfo_(h),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,d,!0),this.m_shape.setSegmentParentageAndBreak(h,p,!0)),_){const t=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(t,_)}}return!0}cleanupSpikes_(){let t=!1;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==h.n;){const s=this.m_shape.getNextPath(e);let i=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n&&n>1;){this.progress_();const{v:r,bModified:o}=this.checkAndCleanupSpike_(e,i);if(r===h.n)break;o?(t=!0,i=r,s=0,n=this.m_shape.getPathSize(e)):(i=r,s++)}e=s}return t}checkAndCleanupSpike_(t,e){const s={v:h.n,bModified:!1};let i=this.m_shape.getPrevVertex(e),n=this.m_shape.getNextVertex(e),r=h.n,o=h.n;for(;this.m_shape.isEqualXY(i,n)&&(r=i,o=n,n!==e);)i=this.m_shape.getPrevVertex(i),n=this.m_shape.getNextVertex(n);if(r===h.n)return s.v=n,s;s.bModified=!0;for(let t=this.m_shape.getNextVertex(r);this.beforeRemoveVertex_(t,!1),t!==o;t=this.m_shape.getNextVertex(t));if(r===e)return this.m_polylineDegeneracies!==h.n?this.m_shape.movePath(this.m_polylineDegeneracies,h.n,t):this.m_shape.removePath(t),s.v=h.n,s;{const t=this.m_shape.peelALoopIntoAPath(r,o);this.m_polylineDegeneracies!==h.n?this.m_shape.movePath(this.m_polylineDegeneracies,h.n,t):this.m_shape.removePath(t)}return s.v=r,s}removeSpike_(t){let e=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(t),i=h.n,n=h.n;for(;this.m_shape.isEqualXY(e,s)&&(i=e,n=s,s!==t);)e=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(s);if(i===h.n)return!1;if(this.m_shape.peelALoop(i,n),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0)),this.removeAngleSortInfo_(i),this.m_polylineDegeneracies===h.n)for(let t=this.m_shape.getNextVertex(n);;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(t),null),this.m_shape.removeVertexInternal(t,!1),t===n)break;t=e}else{for(let t=n;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===n)break}const t=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,h.n,n,n,t)}return!0}fixOrphanVertices_(){let t=0;for(let t=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==t;t=this.m_sortedVertices.getNext(t)){const e=this.m_sortedVertices.getData(t);this.m_shape.setPathToVertex(e,h.n)}let e=0;for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==h.n;){const i=this.m_shape.getFirstVertex(s);if(i===h.n||this.m_shape.getPathFromVertex(i)!==h.n){const t=s;s=this.m_shape.getNextPath(s),this.m_shape.removePathOnly(t);continue}this.m_shape.setPathToVertex(i,s);let n=1;for(let t=this.m_shape.getNextVertex(i);t!==i;t=this.m_shape.getNextVertex(t))this.m_shape.setPathToVertex(t,s),n++;this.m_shape.setRingAreaValid(s,!1),this.m_shape.setPathSize(s,n),this.m_shape.setLastVertex(s,this.m_shape.getPrevVertex(i)),e+=n,t++,s=this.m_shape.getNextPath(s)}for(let s=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==s;s=this.m_sortedVertices.getNext(s)){const i=this.m_sortedVertices.getData(s);if(this.m_shape.getPathFromVertex(i)!==h.n)continue;const n=[!1],r=this.m_shape.insertClosedPath(this.m_geometry,h.n,i,i,n);e+=this.m_shape.getPathSize(r),t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,e);let s=0;for(let t=this.m_shape.getFirstGeometry();t!==h.n;t=this.m_shape.getNextGeometry(t))s+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(t+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}getPrevEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(this.m_bunchEdgeIndices.length+t-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}transferVertexData_(t,e){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex),i=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(t,e),this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,i)}removeAngleSortInfo_(t){const e=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);-1!==e&&(this.m_bunchEdgeIndices[e]=-1,this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(t=!1){}}var M=a.h,q=a.f,F=a.e;function V(t){switch(t){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:(0,a.g)(0,"unrecognized cut side")}return 3}function Y(t,e,s,i,n,r,o){const h=new j(n);h.m_bOGCOutput=!0;const m=t.getGeometryType()===a.G.enumPolygon&&1===t.getFillRule()&&!(0,l.h)(i);return h.planarSimplifyImpl_(t,e,m,s,i,n,r,o)}function X(t,e,s,i,n,r,o,a){return new j(r).planarSimplifyImpl_(t,e,s,i,n,r,o,a)}function R(t,e,s){return function(t,e,s){const i=t.createInstance(),n=(0,c.m)(c.P,100),r=new Array(100),o=t.getPointCount();let h=!0;const l=2===e.getDimension();1!==e.getDimension()&&2!==e.getDimension()&&(0,a.c)("");for(let a=0;a<o;){const o=t.queryCoordinates(n,n.length,a,-1)-a;l?(0,m.t)(e,n,o,s.total(),r):(0,m.l)(e,n,o,s.total(),r);let u=0;for(let e=0;e<o;e++)0===r[e]&&(h&&(h=!1,i.addPoints(t,0,a)),u!==e&&i.addPoints(t,a+u,a+e),u=e+1);h||u===o||i.addPoints(t,a+u,a+o),a+=o}return h?t:i}(t,e,s)}function k(t,e,s,i){if(t.isEmpty()||e.isEmpty()||t.getDimension()>e.getDimension())return J(Z(t),t,0,"-");const n=new u.J;t.queryEnvelope(n);const r=new u.J;e.queryEnvelope(r);const o=new u.J;o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const c=(0,l.a)(s,o,!0),g=r.clone(),_=(0,l.f)(c);if(g.inflateCoords(_,_),!n.isIntersecting(g))return J(Z(t),t,0,"-");const d=new j(i),p=new h.E,f=p.addGeometry(Z(t)),x=p.addGeometry(Z(e));let P=0,y=0,E=null;if(p.hasCurves()){E=new m.C;const t=p.getEnvelope2D(i);y=(0,m.s)(c.total());const e=(0,m.d)(c.total(),t);P=(0,m.f)(e,y),(0,m.b)(p,e,c.total(),12e3,E,null,i)}d.setEditShapeCrackAndCluster(p,c.add(P));const C=d.difference(f,x);null!==E&&E.stitchCurves(p,C,y,!0);const S=J(p.getGeometry(C),t,0,"-");return M(S.getGeometryType())&&(S.getImpl().setIsSimple(4,c.total()),S.getGeometryType()===a.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}function L(t,e,s,i){if(t.getDimension()>e.getDimension())return J(Z(t),t,0,"^");if(t.getDimension()<e.getDimension())return J(Z(e),t,0,"^");if(t.isEmpty())return J(Z(e),t,0,"^");if(e.isEmpty())return J(Z(t),t,0,"^");const n=new u.J;t.queryEnvelope(n);const r=new u.J;e.queryEnvelope(r);const o=new u.J;o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const c=(0,l.a)(s,o,!0),g=new j(i),_=new h.E,d=_.addGeometry(Z(t)),p=_.addGeometry(Z(e));let f=0,x=null;if(_.hasCurves()){x=new m.C;const t=_.getEnvelope2D(i);f=(0,m.s)(c.total());const e=(0,m.d)(c.total(),t);(0,m.b)(_,e,c.total(),12e3,x,null,i)}g.setEditShapeCrackAndCluster(_,c);const P=g.symmetricDifference(d,p);null!==x&&x.stitchCurves(_,P,f,!0);const y=J(_.getGeometry(P),t,0,"^");return M(y.getGeometryType())&&(y.getImpl().setIsSimple(4,c.total()),y.getGeometryType()===a.G.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function B(t,e,s){return function(t,e,s){if(t.isEmpty())return t.createInstance();if(e.isEmpty())return t.createInstance();const i=[new c.P],n=[0],r=2===e.getDimension();1!==e.getDimension()&&2!==e.getDimension()&&(0,a.c)(""),i[0]=t.getXY(),r?(0,m.t)(e,i,1,s.total(),n):(0,m.l)(e,i,1,s.total(),n);let o=0===n[0];return o?t.createInstance():t}(t,e,s)}function H(t,e,s){return t.isEmpty()||e.isEmpty()?t.createInstance():(0,m.j)(s,t,e)?new l.P({copy:(0,m.k)(t,e)}):t.createInstance()}function z(t,e,s,i){const n=u.J.constructEmpty();t.queryEnvelope(n);const r=u.J.constructEmpty();e.queryEnvelope(r);const o=u.J.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const c=(0,l.a)(s,o,!0),g=new u.J(r),_=(0,l.f)(c);if(g.inflateCoords(_,_),!n.isIntersecting(g)){if(t.getDimension()<=e.getDimension())return J(Z(t.createInstance()),t,0,"&");if(t.getDimension()>e.getDimension())return J(Z(e.createInstance()),t,0,"&")}const d=new j(i),p=new h.E,f=p.addGeometry(Z(t)),x=p.addGeometry(Z(e));let P=0,y=0,E=null;if(p.hasCurves()){E=new m.C;const t=p.getEnvelope2D(i);y=(0,m.s)(c.total());const e=(0,m.d)(c.total(),t);P=(0,m.f)(e,y),(0,m.b)(p,e,c.total(),12e3,E,null,i)}d.setEditShapeCrackAndCluster(p,c.add(P));const C=d.intersection(f,x);null!==E&&E.stitchCurves(p,C,y,!0);const S=J(p.getGeometry(C),t,0,"&");return M(S.getGeometryType())&&(S.getImpl().setIsSimple(4,c.total()),S.getGeometryType()===a.G.enumPolygon&&S.getImpl().updateOGCFlagsProtected()),S}function U(t,e,s,i){const n=new Array(3),r=u.J.constructEmpty();t.queryEnvelope(r);const o=u.J.constructEmpty();e.queryEnvelope(o);const c=u.J.constructEmpty();c.setCoords({env2D:r}),c.mergeEnvelope2D(o);const g=(0,l.a)(s,c,!0),_=new u.J(o),d=(0,l.f)(g);if(_.inflateCoords(d,d),!r.isIntersecting(_)){if(t.getDimension()<=e.getDimension()){const e=J(Z(t.createInstance()),t,0,"&");return n[e.getDimension()]=e,n}if(t.getDimension()>e.getDimension()){const s=J(Z(e.createInstance()),t,0,"&");return n[s.getDimension()]=s,n}}const p=new j(i),f=new h.E,x=f.addGeometry(Z(t)),P=f.addGeometry(Z(e));let y=0,E=0,C=null;if(f.hasCurves()){C=new m.C;const t=f.getEnvelope2D(i);E=(0,m.s)(g.total());const e=(0,m.d)(g.total(),t);y=(0,m.f)(e,E),(0,m.b)(f,e,g.total(),12e3,C,null,i)}p.setEditShapeCrackAndCluster(f,g.add(y)),f.dbgVerifyCurves();const S=p.intersectionEx(x,P);for(const e of S){null!==C&&C.stitchCurves(f,e,E,!1);const s=J(f.getGeometry(e),t,0,"&");M(s.getGeometryType())&&(s.getImpl().setIsSimple(4,g.total()),s.getGeometryType()===a.G.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),n[s.getDimension()]=s}return null!==C&&C.clearStitcher(f),n}function O(t,e,s,i,n,r=!1){0===e&&(0,a.t)("not enough geometries to dissolve");let o=0;for(let s=0,i=e;s<i;s++)o=Math.max(t[s].getDimension(),o);if(2===o||1===o)return new j(i).dissolveMultiPaths_(o,!1,t,e,s,n,r);let m=0,u=-1;for(let s=0,i=e;s<i;s++)t[s].getDimension()===o&&(-1===u&&(u=s),t[s].isEmpty()||(u=s,m++));if(m<2)return Z(t[u]);const c=l.b.constructEmpty(),g=new h.E;let _=h.n;for(let s=0,i=e;s<i;s++)if(t[s].getDimension()===o&&!t[s].isEmpty()){_===h.n?_=g.addGeometry(Z(t[s])):g.appendGeometry(_,Z(t[s]));const e=l.b.constructEmpty();t[s].queryLooseEnvelope(e),c.mergeEnv3D(e)}const d=(0,l.a)(s,c.getEnvelope2D(),!0),p=new j(i);if(r){const t=(0,l.d)(s,c.getEnvelopeZs(),!0);return p.planarSimplify3DImpl_(g,d,t,0,!0)}return p.m_bOGCOutput=!0,p.planarSimplifyMultiPoints(g,d,!1,-1)}function W(t,e,s,i,n,r=!1){e<2&&(0,a.t)("not enough geometries to dissolve");let o=0;for(let s=0,i=e;s<i;s++)o=Math.max(t[s].getDimension(),o);if(2===o||1===o)return new j(i).dissolveMultiPaths_(o,!0,t,e,s,n,r);const m=l.b.constructEmpty(),u=new h.E;let c=h.n,g=0,_=-1;for(let s=0,i=e;s<i;s++)if(t[s].getDimension()===o&&(-1===_&&(_=s),!t[s].isEmpty())){_=s,c===h.n?c=u.addGeometry(Z(t[s])):u.appendGeometry(c,Z(t[s]));const e=l.b.constructEmpty();t[s].queryLooseEnvelope(e),m.mergeEnv3D(e),g++}if(g<2)return Z(t[_]);const d=0===o?s:null,p=(0,l.a)(d,m.getEnvelope2D(),!0),f=new j(i);if(r){const t=(0,l.d)(d,m.getEnvelopeZs(),!0);return f.m_bOGCOutput=!0,f.planarSimplify3DImpl_(u,p,t,0,!0)}return f.planarSimplifyMultiPoints(u,p,!0,-1)}class j{constructor(t){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=c.P.getNAN(),this.m_dummyPt2=c.P.getNAN(),this.m_fromEdgeForPolylines=h.n,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=t}linesToPolygonsImpl(t,e){let s=0,i=0,n=null;if(t.hasCurves()){n=new m.C;const r=t.getEnvelope2D(this.m_progressTracker);i=(0,m.s)(e.total());const o=(0,m.d)(e.total(),r);s=(0,m.f)(o,i),(0,m.b)(t,o,e.total(),12e3,n,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,e.add(s));const r=this.m_topoGraph.createUserIndexForChains(),a=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(a,r,1);for(let t=this.m_topoGraph.getChainFirstIsland(a);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,r,1);const l=[];for(let e=this.m_topoGraph.getFirstChain();e!==h.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,r))continue;this.m_topoGraph.setChainUserIndex(e,r,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,r,1);if(0===this.m_topoGraph.getChainArea(e))continue;const s=this.m_topoGraph.extractPolygonFromChainAndIslands(t,h.n,e,h.n);null!=n&&n.stitchCurves(t,s,i,!1);const o=t.getGeometry(s);l.push(o)}return new o.S(l)}autoCompleteImpl(t,e,s){let i=0,n=0,r=null;if(t.hasCurves()){r=new m.C;const e=t.getEnvelope2D(this.m_progressTracker);n=(0,m.s)(s.total());const o=(0,m.d)(s.total(),e);i=(0,m.f)(o,n),(0,m.b)(t,o,s.total(),12e3,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,s.add(i));const a=this.m_topoGraph.getGeometryID(e),l=this.m_topoGraph.createUserIndexForChains(),u=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(u,l,1);for(let t=this.m_topoGraph.getChainFirstIsland(u);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,l,1);const c=[];for(let e=this.m_topoGraph.getFirstChain();e!==h.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,l))continue;this.m_topoGraph.setChainUserIndex(e,l,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,l,1);if(0!==this.m_topoGraph.getChainParentage(e))continue;const s=this.m_topoGraph.getChainHalfEdge(e);let i=s,o=!1;do{const t=this.m_topoGraph.getHalfEdgeTwin(i);if(this.m_topoGraph.getHalfEdgeChain(t)!==e&&this.m_topoGraph.getHalfEdgeParentage(i)&a){o=!0;break}i=this.m_topoGraph.getHalfEdgeNext(i)}while(i!==s);if(!o)continue;if(0===this.m_topoGraph.getChainArea(e))continue;const m=this.m_topoGraph.extractPolygonFromChainAndIslands(t,h.n,e,h.n);null!==r&&r.stitchCurves(t,m,n,!1);const u=t.getGeometry(m);c.push(u)}return new o.S(c)}setEditShape(t,e=!1){null===this.m_topoGraph&&(this.m_topoGraph=new v),this.m_topoGraph.setEditShape(t,this.m_progressTracker,!0,e)}setEditShapeCrackAndCluster(t,e){(0,m.e)(t,e,this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e))t.getGeometryType(e)===a.G.enumPolygon&&A(t,e,-1,this.m_bOGCOutput,h.n,this.m_progressTracker);this.setEditShape(t)}setHalfEdgeOrientations_(t,e){const s=this.m_topoGraph.getShape();for(let i=s.getFirstGeometry();i!==h.n;i=s.getNextGeometry(i))if(i===e)for(let e=s.getFirstPath(i);e!==h.n;e=s.getNextPath(e)){let i=s.getFirstVertex(e);if(i===h.n)continue;let n=s.getNextVertex(i);for(;n!==h.n;){const e=this.m_topoGraph.getClusterFromVertex(i),r=this.m_topoGraph.getClusterFromVertex(n),o=this.m_topoGraph.getHalfEdgeConnector(e,r);if(o!==h.n){const e=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,t,1),this.m_topoGraph.setHalfEdgeUserIndex(e,t,2)}i=n,n=s.getNextVertex(i)}}}flushVertices_(t,e){const s=this.m_topoGraph.getShape(),i=s.hasSegmentParentage(),n=new h.S,r=s.insertPath(t,h.n);e.push(e[0]);const o=e.length;let a=h.n;for(let t=0;t<o;t++){const h=e[t];if(a=s.addVertex(r,h),!i)continue;const m=this.m_topoGraph.getClusterFromVertex(h);if(t>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(a,!0),t<o-1){const i=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(e[t+1])),r=this.m_topoGraph.getSegmentParentage(i);s.setSegmentParentageAndBreak(a,r,t>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(i)&&(this.m_topoGraph.querySegmentXY(i,n),s.setSegmentToIndex(s.getVertexIndex(a),n.get().clone()))}}if(i){const t=this.m_topoGraph.getClusterFromVertex(e[o-1]);this.m_topoGraph.isBreakNode(t)&&s.setSegmentParentageBreakVertex(a,!0)}s.setClosedPath(r,!0)}processPolygonCuts_(t,e,s,i){const n=this.m_topoGraph.getGeometryID(s),r=this.m_topoGraph.getGeometryID(i),o=[],m=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s)){const i=this.m_topoGraph.getClusterHalfEdge(s);if(i===h.n)continue;let u=i;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(u,l)){let s=u,i=u,h=!1,c=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,l,1),h||this.m_topoGraph.getHalfEdgeParentage(s)&r&&this.m_topoGraph.getHalfEdgeFaceParentage(s)&n&&(i=s,h=!0),h){const e=this.m_topoGraph.getHalfEdgeOrigin(s),i=this.m_topoGraph.getClusterVertexIterator(e),n=this.m_topoGraph.getVertexFromVertexIterator(i);o.push(n),-1!==t&&this.m_topoGraph.getHalfEdgeParentage(s)&r&&(c|=this.m_topoGraph.getHalfEdgeUserIndex(s,t))}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==i);if(h&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(i))>0){const t=m.createGeometry(a.G.enumPolygon);this.flushVertices_(t,o),-1!==e&&m.setGeometryUserIndex(t,e,c)}o.length=0}u=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(u))}while(u!==i)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(t,e,s,i){this.m_topoGraph.removeSpikes_();let n=-1;-1!==t&&(n=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(n,s)),this.processPolygonCuts_(n,t,e,s),-1!==n&&(this.m_topoGraph.deleteUserIndexForHalfEdges(n),n=-1);const r=this.m_topoGraph.getShape();for(let t=r.getFirstGeometry();t!==h.n;t=r.getNextGeometry(t))t!==e&&t!==s&&i.push(t);i.sort(((t,e)=>{const s=r.getFirstPath(t),i=r.getRingArea(s),n=r.getFirstPath(e),o=r.getRingArea(n);return i<o?-1:i>o?1:0}))}cut(t,e,s,i,n){const r=this.m_topoGraph.getShape().getGeometryType(s),o=this.m_topoGraph.getShape().getGeometryType(i),h=(0,a.e)(r),m=(0,a.e)(o);2!==h||1!==m?1!==h||1!==m?(0,a.c)(""):new K(this,t,e,s,i,n).Do():this.cutPolygonPolyline_(e,s,i,n)}progress_(t=!1){}isGoodParentage(t){return t>=0&&t<this.m_maskLookup.length&&this.m_maskLookup[t]}normalizeInputGeometry(t){const e=t.getGeometryType();if(e===a.G.enumEnvelope){const e=new h.P({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===a.G.enumPoint){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if((0,a.f)(e)){const e=new h.a({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==a.G.enumMultiPoint&&e!==a.G.enumPolyline&&e!==a.G.enumPolygon&&(0,a.t)("Unexpected geometry type"),t}dissolveNonSimplePolygons(t,e,s,i){(0,a.g)(e>0);const n=new h.E;let r=0,o=-1;for(let s=0,i=e;s<i;s++)2===t[s].getDimension()&&(-1===o&&(o=s),t[s].isEmpty()||(r++,n.addGeometry(t[s])));return 0===r?((0,a.g)(o>=0),this.normalizeInputGeometry(t[o])):this.planarSimplifyPolygons(n,s,!0,!1,-1,!0)}dissolveMultiPaths_(t,e,s,i,n,r,o){(0,a.g)(t>=1&&t<=2),(0,a.g)(i>0);const g=8&r?1:2,_=l.b.constructEmpty();let d=0,p=-1,f=!0;for(let e=0,n=i;e<n;e++)if(s[e].getDimension()===t&&(-1===p&&(p=e),!s[e].isEmpty())){p=e,d++;const i=l.b.constructEmpty();if(s[e].queryLooseEnvelope(i),_.mergeEnv3D(i),2===t&&f&&s[e].getGeometryType()===a.G.enumPolygon)if(16&r){const t=[0],i=s[e].getImpl().getIsSimple(0,t),n=this.m_bOGCOutput?5===i:(0,l.e)(i);f&&=n}else{const t=(0,l.i)(s[e],0);f&&=t}}if(d<2&&((0,a.g)(p>=0),0===d||!(16&r)))return this.normalizeInputGeometry(s[p]);if(!f){const t=(0,l.a)(e?null:n,_.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,i,t,r)}const x=s.slice(0,i),P=(0,l.a)(n,_.getEnvelope2D(),!0),y=10*(0,l.f)(P);let E=new l.C(0,0);if(o&&(E=(0,l.d)(n,_.getEnvelopeZs(),!0)),1===d&&1===t&&2===g&&!e)return o?((0,a.g)(0),{}):this.m_bOGCOutput?Y(x[p],P,!1,-1,this.m_progressTracker,g,!1):X(x[p],P,!1,!1,-1,this.m_progressTracker,g,!1);const C=new l.g;C.startConstruction();let S=2===t?3:4,v=0;for(let s=0,n=i;s<n;s++){if(x[s].getDimension()!==t||x[s].isEmpty())continue;let i=x[s].getGeometryType();if(i!==a.G.enumEnvelope){if((0,a.f)(i)?(x[s]=this.normalizeInputGeometry(x[s]),i=a.G.enumPolyline):(0,a.g)((0,a.h)(i)),1===t){(0,a.g)(i===a.G.enumPolyline);let t=-1;if(o)(0,a.g)(0,"3d not implemented yet");else{const e=[0];t=x[s].getImpl().getIsSimple(P.total(),e)}if(this.m_bOGCOutput?5!==t:!(0,l.e)(t))if(e)S=-1;else{o?(0,a.g)(0,"3d not implemented yet"):this.m_bOGCOutput?x[s]=Y(x[s],P,!1,-1,this.m_progressTracker,g,!1):x[s]=X(x[s],P,!1,!1,-1,this.m_progressTracker,g,!1);const t=[0];(0,a.g)((0,l.e)(x[s].getImpl().getIsSimple(P.total(),t)))}}else{(0,a.g)(i===a.G.enumPolygon);const t=[0],e=x[s].getImpl().getIsSimple(0,t);(0,a.g)((0,l.h)(e))}const n=x[s].getImpl();for(let t=0,e=n.getPathCount();t<e;t++){const e=u.J.constructEmpty();n.queryLoosePathEnvelope(t,e),e.inflateCoords(y,y),C.addEnvelope(v,e),v++}}else{(0,a.g)(i===a.G.enumEnvelope);const t=u.J.constructEmpty();x[s].queryLooseEnvelope(t),t.inflateCoords(y,y),C.addEnvelope(v,t),v++,S=-1}}C.endConstruction();const b=v,w=(0,c.f)(b,-2147483647),D=(0,c.f)(b,-1);let T=0;p=-1,v=0;for(let e=0,s=i;e<s;e++){if(x[e].getDimension()!==t)continue;if(-1===p&&(p=e),x[e].isEmpty())continue;p=e,T++;const s=x[e].getGeometryType();if((0,a.h)(s))for(let t=0,s=x[e].getPathCount();t<s;t++)D[v]=e,w[v]=-t-1,v++;else(0,a.g)(s===a.G.enumEnvelope),D[v]=e,w[v]=-1,v++}if(T<2&&2===t)return(0,a.g)(p>=0),this.normalizeInputGeometry(x[p]);let N=b;for(;C.next()&&N>0;){this.progress_();const t=C.getHandleA(),e=C.getHandleB(),s=C.getElement(t),i=C.getElement(e);D[s]!==D[i]&&(w[s]<0&&(N--,w[s]=-(w[s]+1)),w[i]<0&&(N--,w[i]=-(w[i]+1)))}const A=new h.E;let G,M=!1,q=0;for(let e=0,s=i;e<s;e++){if(x[e].getDimension()!==t||x[e].isEmpty())continue;const s=x[e].getGeometryType(),i=q;let n=0,r=0;const o=(0,a.h)(s)?x[e]:null;for(let t=i,s=w.length;t<s&&D[t]===e;t++)w[t]>=0&&(n++,r+=o?o.getPathSize(w[t]):(0,a.v)(x[e])),q++;if(r>.95*(0,a.v)(x[e])){A.addGeometry(this.normalizeInputGeometry(x[e]));for(let t=i;t<q;t++)w[t]<0&&(w[t]=-(w[t]+1))}else{if(0===n){M=!0;continue}{M=!0,(0,a.g)((0,a.h)(s)),(0,a.g)(null!=o);const t=new h.P({vd:x[e].getDescription()}),n=new h.a({vd:x[e].getDescription()}),r=s===a.G.enumPolygon?t:n;for(let t=i;t<q;t++)w[t]>=0&&r.addPath(o,w[t],!0);A.addGeometry(r)}}}if(A.getFirstGeometry()!==h.n){const s=2===t,i=e?(0,l.a)(null,_.getEnvelope2D(),!0):P;let n=new l.C(0,0);if(o&&(n=e?(0,l.d)(null,_.getEnvelopeZs(),!0):E),2===t&&!(2&r)){A.collapseAllGeometriesToFirst();let t=0,e=null;if(A.hasCurves()&&!A.hasSegmentParentage()){e=new m.C;const s=A.getEnvelope2D(this.m_progressTracker);t=(0,m.s)(i.total());const n=(0,m.d)(i.total(),s);(0,m.b)(A,n,i.total(),12e3,e,null,this.m_progressTracker)}(function(t,e,s,i){s>0&&(0,m.a)(t,s,e,!1,i),new I(i).executeImpl_(t,e)})(A,A.getFirstGeometry(),i.total(),this.m_progressTracker),null!==e&&e.stitchCurves(A,h.n,t,!0)}if(o)G=this.planarSimplify3DImpl_(A,i,n,g,!0);else if(2===t)G=this.planarSimplifyPolygons(A,i,s,e,-1,!1);else{const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=g,G=this.planarSimplifyPolylines(A,i,e,t,-1)}if(!M){const t=[0];S=G.getImpl().getIsSimple(i.total(),t)}}else(0,a.g)(M),(0,a.g)(p>=0),G=2===t?new h.P({vd:x[p].getDescription()}):new h.a({vd:x[p].getDescription()});if(M){let t=0;for(let e=0,s=w.length;e<s;e++){const s=D[e];if(!(s<0)&&w[e]<0){const i=x[s].getGeometryType(),n=(0,a.h)(i)?x[s]:null;if(n){const s=-(w[e]+1);t+=n.getPathSize(s)}else t+=4}}G.reserve(G.getPointCount()+t);for(let t=0,e=w.length;t<e;t++){const e=D[t];if(!(e<0)&&w[t]<0){const s=x[e].getGeometryType(),i=(0,a.h)(s)?x[e]:null;if(i){const e=-(w[t]+1);G.addPath(i,e,!0)}else s===a.G.enumEnvelope?G.addEnvelope(x[e],!1):((0,a.g)((0,a.f)(s)),G.addSegment(x[e],!0))}}}let F=0;if(2===t?-1!==S&&(S=3,F=e?0:P.total()):((0,a.g)(1===t),e||-1===S||(F=P.total())),o||G.getImpl().setIsSimple(S,F),!e&&M)if(2===t){if(!o)return(new gt).execute(G,n,!1,this.m_progressTracker);(0,a.g)(0,"3d not yet implemented")}else 1===t&&1!==g&&(G=o?((0,a.g)(0),{}):function(t,e,s,i){const n=new j(i),r=new h.E,o=r.addGeometry(e),m=n.planarSimplifyNoCrackingAndCluster(t,r,o,s);return(0,a.g)(m,"planar_simplify_no_cracking_and_cluster"),r.getGeometry(o)}(this.m_bOGCOutput,G,g,this.m_progressTracker),G.getImpl().setIsSimple(S,F));return G}dissolveTopoGraphCommonEdges_(){const t=this.m_topoGraph.createUserIndexForHalfEdges(),e=[];for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s)){const i=this.m_topoGraph.getClusterHalfEdge(s);let n=i;if(i!==h.n)do{if(this.progress_(),1!==this.m_topoGraph.getHalfEdgeUserIndex(n,t)){const s=this.m_topoGraph.getHalfEdgeTwin(n);this.m_topoGraph.setHalfEdgeUserIndex(s,t,1),this.m_topoGraph.setHalfEdgeUserIndex(n,t,1);const i=this.m_topoGraph.getHalfEdgeFaceParentage(n);if(this.isGoodParentage(i)){const t=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(t)&&e.push(n)}}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==i)}this.m_topoGraph.deleteUserIndexForHalfEdges(t),this.m_topoGraph.deleteEdgesBreakFaces_(e)}chooseVertexByOrder(t,e,s,i){let n=(0,c.n)(),r=h.n;for(let i=this.m_topoGraph.getClusterVertexIterator(t);i!==h.n;i=this.m_topoGraph.incrementVertexIterator(i)){const t=this.m_topoGraph.getVertexFromVertexIterator(i),o=e.getUserIndex(t,s);o>=0&&o<n&&(n=o,r=t)}(0,a.g)(r!==h.n);let o=e.getUserIndex(r,i);return o>0&&(e.setUserIndex(r,i,--o),0===o&&e.setUserIndex(r,s,-1)),r}chooseVertexFromCluster_(t,e){return this.m_topoGraph.getVertexDominantFromCluster(t,e)}chooseVertexFromVertexCluster_(t,e){return this.m_topoGraph.getVertexDominant(t,e)}collectPolygonPathsPreservingFrom_(t,e,s,i,n){const r=this.m_topoGraph.getShape();if(r.getGeometryType(t)!==a.G.enumPolygon)return;const o=r.hasSegmentParentage(),m=new h.S;for(let a=r.getFirstPath(t);a!==h.n;a=r.getNextPath(a)){const t=r.getFirstVertex(a);this.m_topoGraph.getClusterFromVertex(t);const l=this.m_topoGraph.getHalfEdgeFromVertex(t);if(l===h.n)continue;const u=this.m_topoGraph.getHalfEdgeUserIndex(l,s);if(1===u||2===u)continue;const c=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(!this.isGoodParentage(c)){this.m_topoGraph.setHalfEdgeUserIndex(l,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(l,s,1);const g=r.insertPath(e,h.n);r.setClosedPath(g,!0);let _=l,d=t,p=this.m_topoGraph.getClusterFromVertex(d),f=1;do{this.progress_();const t=this.chooseVertexFromVertexCluster_(d,n),e=r.addVertex(g,t);if(this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,m),r.setSegmentToIndex(r.getVertexIndex(e),m.get().clone())),o){const t=this.m_topoGraph.getSegmentParentage(_);r.setSegmentParentageAndBreak(e,t,this.m_topoGraph.isBreakNode(p))}let a,l;-1!==i&&this.m_topoGraph.setClusterUserIndex(p,i,1),this.m_topoGraph.setHalfEdgeUserIndex(_,s,1),_=this.m_topoGraph.getHalfEdgeNext(_);do{a=1===f?r.getNextVertex(d):r.getPrevVertex(d),l=a!==h.n?this.m_topoGraph.getClusterFromVertex(a):h.n}while(l===p);const u=this.m_topoGraph.getHalfEdgeOrigin(_);if(u!==l){do{a=1===f?r.getPrevVertex(d):r.getNextVertex(d),l=a!==h.n?this.m_topoGraph.getClusterFromVertex(a):h.n}while(l===p);if(u!==l){l=u;const t=this.m_topoGraph.getClusterVertexIterator(l);a=this.m_topoGraph.getVertexFromVertexIterator(t)}else f=-f}p=l,d=a}while(_!==l)}}topoOperationPolygonPolygonHelper_(t,e,s,i,n,r){this.progress_(!0),t!==h.n&&this.collectPolygonPathsPreservingFrom_(t,s,n,r,i),e!==h.n&&this.collectPolygonPathsPreservingFrom_(e,s,n,r,i);const o=new h.S,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const m=a.hasSegmentParentage();for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===h.n)continue;let l=e;do{this.progress_();const t=this.m_topoGraph.getHalfEdgeUserIndex(l,n);if(1!==t&&2!==t){const t=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(t)){const t=a.insertPath(s,h.n);a.setClosedPath(t,!0);let e=l;do{const s=this.m_topoGraph.getHalfEdgeVertexIterator(e);let l=h.n;if(s!==h.n)l=this.m_topoGraph.getVertexFromVertexIterator(s);else{const t=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(e));l=this.m_topoGraph.getVertexFromVertexIterator(t),l=a.getNextVertex(l)}const u=this.chooseVertexFromVertexCluster_(l,i),c=a.addVertex(t,u);if(m){const t=this.m_topoGraph.getSegmentParentage(e),s=this.m_topoGraph.getHalfEdgeOrigin(e);a.setSegmentParentageAndBreak(c,t,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,o),a.setSegmentToIndex(a.getVertexIndex(c),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(e,n,1),-1!==r){const t=this.m_topoGraph.getClusterFromVertex(u);this.m_topoGraph.setClusterUserIndex(t,r,1)}e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,n,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==e)}}topoOperationPolygonPolygon_(t,e,s,i=!1){this.dissolveTopoGraphCommonEdges_();const n=this.m_topoGraph.getShape(),r=n.createGeometry(a.G.enumPolygon),o=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(t,e,r,s,o,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(o),i||A(n,r,3,this.m_bOGCOutput,h.n,this.m_progressTracker),r}topoOperationPolyline_(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(h.n,t,!1,s).first}topoOperationMultiPoint_(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(a.G.enumMultiPoint),s=t.insertPath(e,h.n);for(let e=this.m_topoGraph.getFirstCluster();e!==h.n;e=this.m_topoGraph.getNextCluster(e)){const i=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(i)){let i=h.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==h.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);i===h.n&&(i=e);const n=t.getGeometryFromPath(t.getPathFromVertex(e)),r=this.m_topoGraph.getGeometryID(n);if(this.isGoodParentage(r)){i=e;break}}t.addVertex(s,i)}}return e}intersection(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=(0,a.e)(s),r=(0,a.e)(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o|m]=!0;let l=h.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===n&&2===r?this.topoOperationPolygonPolygon_(t,e,l):1===n&&r>0||1===r&&n>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===n||0===r?this.topoOperationMultiPoint_():void(0,a.c)("")}topoOperationPolygonPolygonEx(t,e,s){const i=this.m_topoGraph.getShape(),n=i.createGeometry(a.G.enumPolygon),r=i.createGeometry(a.G.enumPolyline),o=i.createGeometry(a.G.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=h.n;const l=this.m_topoGraph.createUserIndexForHalfEdges(),u=this.m_topoGraph.createUserIndexForClusters();i.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(t,e,n,s,l,u),i.dbgVerifyCurves();const c=i.hasSegmentParentage(),g=new h.S;for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===h.n)continue;let n=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(n,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l),a=e|o;if(2===a){let m=this.m_topoGraph.getHalfEdgeParentage(n);if(this.isGoodParentage(m)){const _=i.insertPath(r,h.n);let d=n;const p=this.chooseVertexFromCluster_(t,s);let f=i.addVertex(_,p);if(c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone())),this.m_topoGraph.setClusterUserIndex(t,u,1);do{this.progress_();const t=this.m_topoGraph.getHalfEdgeTo(d),r=this.chooseVertexFromCluster_(t,s);if(f=i.addVertex(_,r),c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}if(this.m_topoGraph.setHalfEdgeUserIndex(d,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l,1),this.m_topoGraph.setClusterUserIndex(t,u,1),d=this.m_topoGraph.getHalfEdgeNext(d),e=this.m_topoGraph.getHalfEdgeUserIndex(d,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l),a=e|o,2!==a)break;if(m=this.m_topoGraph.getHalfEdgeParentage(d),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(d,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l,1);break}this.m_topoGraph.isHalfEdgeCurve(n)&&d!==n&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone()))}while(d!==n)}else this.m_topoGraph.setHalfEdgeUserIndex(n,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l,1)}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==e)}for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){if(this.progress_(),1===this.m_topoGraph.getClusterUserIndex(t,u))continue;const e=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(e)){m===h.n&&(m=i.insertPath(o,h.n));const e=this.m_topoGraph.getClusterVertexIterator(t);let n=h.n;if(e!==h.n){n=this.m_topoGraph.getVertexFromVertexIterator(e);const t=this.chooseVertexFromVertexCluster_(n,s);i.addVertex(m,t)}}}this.m_topoGraph.deleteUserIndexForClusters(u),this.m_topoGraph.deleteUserIndexForHalfEdges(l),i.dbgVerifyCurves(),A(i,n,3,this.m_bOGCOutput,h.n,this.m_progressTracker);const _=[h.n,h.n,h.n];return _[0]=o,_[1]=r,_[2]=n,_}topoOperationPolylinePolylineOrPolygonEx(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(h.n,t,!0,s)}topoOperationMultiPoint(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(a.G.enumMultiPoint),s=t.insertPath(e,h.n);for(let e=this.m_topoGraph.getFirstCluster();e!==h.n;e=this.m_topoGraph.getNextCluster(e)){const i=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(i)){let i=h.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==h.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);i===h.n&&(i=e);const n=t.getGeometryFromPath(t.getPathFromVertex(e)),r=this.m_topoGraph.getGeometryID(n);if(this.isGoodParentage(r)){i=e;break}}t.addVertex(s,i)}}return e}intersectionEx(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=F(s),r=F(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o|m]=!0;let l=h.n;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===n&&2===r)return this.topoOperationPolygonPolygonEx(t,e,l);if(1===n&&r>0||1===r&&n>0){const{first:t,second:e}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[e,t]}if(0===n||0===r){const t=[];return t.push(this.topoOperationMultiPoint()),t}(0,a.c)("")}getCombinedHalfEdgeParentage(t){return this.m_topoGraph.getHalfEdgeParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t))}prevailingDirection(t,e){const s=this.getCombinedHalfEdgeParentage(e),i=this.m_topoGraph.getHalfEdgeOrigin(e),n=this.m_topoGraph.getHalfEdgeTo(e);let r=0,o=0;for(let a=this.m_topoGraph.getClusterVertexIterator(i);a!==h.n;a=this.m_topoGraph.incrementVertexIterator(a)){const i=this.m_topoGraph.getVertexFromVertexIterator(a),m=t.getPathFromVertex(i),l=t.getGeometryFromPath(m),u=this.m_topoGraph.getGeometryID(l),c=t.getFirstVertex(m),g=!!(u&s);g&&c===i&&(this.m_fromEdgeForPolylines=e);const _=t.getNextVertex(i);if(_!==h.n&&this.m_topoGraph.getClusterFromVertex(_)===n){if(r++,g){if(this.m_fromEdgeForPolylines===h.n&&c===_){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}o++}}else{const s=t.getPrevVertex(i);if(s!==h.n&&this.m_topoGraph.getClusterFromVertex(s)===n&&(r--,g)){if(this.m_fromEdgeForPolylines===h.n&&c===s){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}o--}}}return this.m_topoGraph.queryXY(i,this.m_dummyPt1),this.m_topoGraph.queryXY(n,this.m_dummyPt2),(0!==o?o:r)*c.P.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(t,e){const s=this.m_topoGraph.getHalfEdgePrev(t),i=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return h.n;const e=this.m_topoGraph.getHalfEdgeTwin(t);if(i===this.m_topoGraph.getHalfEdgeNext(e))return s}let n=i,r=h.n;for(;n!==t;){const t=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(t)){if(r!==h.n)return h.n;r=this.m_topoGraph.getHalfEdgeTwin(n)}n=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(n))}return r}tryMoveThroughCrossroadForward(t,e){const s=this.m_topoGraph.getHalfEdgeNext(t),i=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){const e=this.m_topoGraph.getHalfEdgeTwin(t);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return h.n;if(i===this.m_topoGraph.getHalfEdgePrev(e))return s}let n=i,r=h.n;for(;n!==t;){const t=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(t)){if(r!==h.n)return h.n;r=this.m_topoGraph.getHalfEdgeTwin(n)}n=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(n))}return r}isOnALoop(t,e){let s=t;const i=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let n=0;n<i;n++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,e))return!1;const i=this.m_topoGraph.getHalfEdgeNext(s);if(i===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=i,s===t)return!0}(0,a.c)("is_on_a_loop_")}restorePolylineParts(t,e,s,i,n,r,o,m,l,u){(0,a.g)(n===h.n&&r>=0&&o>=0||-1===r&&-1===o),(0,a.g)(-1===m&&1!==u.unsplitBehavior||-1!==m&&1===u.unsplitBehavior);const g=u.ogcRule,_=u.allCrossRoadsImpassable,d=1===u.unsplitBehavior,p=0===u.unsplitBehavior,f=this.m_topoGraph.getShape(),x=f.hasSegmentParentage();let P=t,y=this.m_topoGraph.getHalfEdgeTwin(P);const E=new h.S;this.m_fromEdgeForPolylines=h.n;let C=this.prevailingDirection(f,P),S=P,v=h.n,b=!1,I=!1,w=!1;if(!d)for(;;){const e=this.m_topoGraph.getHalfEdgePrev(P);if(e===y){w=!0;break}const i=this.m_topoGraph.getHalfEdgeNext(y);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(i))){b=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(e)!==i){if(_){b=!0;break}if(P=this.tryMoveThroughCrossroadBackwards(P,!0),P===h.n){b=!0;break}y=this.m_topoGraph.getHalfEdgeTwin(P)}else P=e,y=i;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){w=!0;break}if(P===t){v=t,I=!0;break}const n=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(n))break;S=P,C+=this.prevailingDirection(f,P)}if(v===h.n){for(P=t,y=this.m_topoGraph.getHalfEdgeTwin(P),v=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){w=!0;break}if(-1!==m){const t=this.m_topoGraph.getHalfEdgeOrigin(y);if(1===this.m_topoGraph.getClusterUserIndex(t,m)){b=!0;break}}const i=this.m_topoGraph.getHalfEdgePrev(y);if(this.m_topoGraph.getHalfEdgeTwin(t)!==i){if(e||_){b=!0;break}if(P=this.tryMoveThroughCrossroadForward(P,!0),P===h.n){b=!0;break}y=this.m_topoGraph.getHalfEdgeTwin(P)}else P=t,y=i;if(1===this.m_topoGraph.getHalfEdgeUserIndex(P,s)){w=!0;break}const n=this.getCombinedHalfEdgeParentage(P);if(!this.isGoodParentage(n))break;v=P,C+=this.prevailingDirection(f,P)}const e=this.m_topoGraph.getHalfEdgeOrigin(S);I=this.m_topoGraph.getHalfEdgeTo(v)===e}else if(this.m_fromEdgeForPolylines!==h.n){S=t,v=this.tryMoveThroughCrossroadBackwards(S,!1),(0,a.g)(v!==h.n);const e=this.m_topoGraph.getHalfEdgeTwin(S);this.m_topoGraph.getHalfEdgeNext(e)}let D=I;I||w||l&&(D=this.isOnALoop(t,s),D||(D=this.isOnALoop(y,s)));const T=C>=0;let N=!1;D&&b&&(I?(N=g,T&&(N||d||p)&&S!==t&&((0,a.g)(!d),S=t,N=!1)):(d||T&&p)&&(S=t));let A=0;for(P=S;y=this.m_topoGraph.getHalfEdgeTwin(P),this.m_topoGraph.setHalfEdgeUserIndex(P,s,1),this.m_topoGraph.setHalfEdgeUserIndex(y,s,1),A++,P!==v;)P=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1);T||(v=(0,c.b)(S,S=v),v=this.m_topoGraph.getHalfEdgeTwin(v),S=this.m_topoGraph.getHalfEdgeTwin(S));let G=f.insertPath(e,h.n);P=S;const M=this.m_topoGraph.getHalfEdgeOrigin(S);let q;q=-1!==r?this.chooseVertexByOrder(M,f,r,o):this.chooseVertexFromCluster_(M,n),this.m_topoGraph.isStrongPathNode(M)&&f.setStrongPathStart(G,!0);let F=f.addVertex(G,q),V=F;-1!==i&&this.m_topoGraph.setClusterUserIndex(M,i,1);let Y=0;const X=N?Math.trunc((A+1)/2):-1;let R=h.n,k=!0,L=h.n;for(;;){if(x){const t=this.m_topoGraph.getSegmentParentage(P),e=this.m_topoGraph.getHalfEdgeOrigin(P);f.setSegmentParentageAndBreak(V,t,k||this.m_topoGraph.isBreakNode(e))}k=!1,this.m_topoGraph.isHalfEdgeCurve(P)&&(this.m_topoGraph.querySegmentXY(P,E),f.setSegmentToIndex(f.getVertexIndex(V),E.get().clone())),R!==h.n&&-1!==o&&f.addToUserIndex(R,o,-1);const t=_?this.m_topoGraph.getHalfEdgeNext(P):this.tryMoveThroughCrossroadForward(P,!1),s=this.m_topoGraph.getHalfEdgeTo(P);let a;if(a=-1!==r?this.chooseVertexByOrder(s,f,r,o):this.chooseVertexFromCluster_(s,n),F=f.addVertex(G,a),L=s,-1!==i&&this.m_topoGraph.setClusterUserIndex(s,i,1),x&&this.m_topoGraph.isBreakNode(s)&&f.setSegmentParentageBreakVertex(F,!0),R=a,Y++,N&&Y===X&&(G=f.insertPath(e,h.n),F=f.addVertex(G,a),k=!0,-1!==o&&f.addToUserIndex(a,o,-1),R=h.n),P===v)break;P=t,V=F}L!==h.n&&this.m_topoGraph.isStrongPathNode(L)&&f.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(t,e){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,e,s,i){(0,a.g)(e===h.n||t===h.n);const n=this.m_topoGraph.getShape(),r=e=>t===h.n?e===h.n?n.getFirstGeometry():n.getNextGeometry(e):e===h.n?t:h.n,o=n.createGeometry(a.G.enumPolyline);let m=-1;s&&(m=this.m_topoGraph.createUserIndexForClusters());const l=this.m_topoGraph.createUserIndexForHalfEdges(),u=e===h.n?n.createUserIndex():-1,g=e===h.n?n.createUserIndex():-1;let _=-1;if(1===i.unsplitBehavior){_=this.m_topoGraph.createUserIndexForClusters();for(let t=r(h.n);t!==h.n;t=r(t))for(let e=n.getFirstPath(t);e!==h.n;e=n.getNextPath(e)){{const t=n.getFirstVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,_,1)}if(!n.isClosedPath(e)){const t=n.getLastVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,_,1)}}}if(e===h.n){let t=0;for(let e=r(h.n);e!==h.n;e=r(e))for(let s=n.getFirstPath(e);s!==h.n;s=n.getNextPath(s))if(n.isClosedPath(s)){let e=n.getFirstVertex(s);for(let i=0,r=n.getPathSize(s);i<r;i++,e=n.getNextVertex(e))n.setUserIndex(e,u,t++),n.setUserIndex(e,g,2)}else{const e=n.getFirstVertex(s);n.setUserIndex(e,u,t++),n.setUserIndex(e,g,1);let i=n.getNextVertex(e);for(let e=1,r=n.getPathSize(s)-1;e<r;++e)n.setUserIndex(i,u,t++),n.setUserIndex(i,g,2),i=n.getNextVertex(i);n.setUserIndex(i,u,t++),n.setUserIndex(i,g,1)}}for(let t=r(h.n);t!==h.n;t=r(t))for(let s=n.getFirstPath(t);s!==h.n;s=n.getNextPath(s)){let t=n.getFirstVertex(s);for(let r=0,a=n.getPathSize(s);r<a;r++,t=n.getNextVertex(t)){const s=this.m_topoGraph.getHalfEdgeFromVertex(t);if(s===h.n)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,l))continue;const n=this.getCombinedHalfEdgeParentage(s);if(this.isGoodParentage(n)){const t=0===r;this.restorePolylineParts(s,o,l,m,e,u,g,_,t,i)}}}let d=h.n;if(s){d=n.createGeometry(a.G.enumMultiPoint);let t=h.n;for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s))if(this.progress_(),1!==this.m_topoGraph.getClusterUserIndex(s,m)){const i=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(i)){t===h.n&&(t=n.insertPath(d,h.n));const i=this.m_topoGraph.getClusterVertexIterator(s);if(i!==h.n){let r;this.m_topoGraph.getVertexFromVertexIterator(i),r=-1!==u?this.chooseVertexByOrder(s,n,u,g):this.chooseVertexFromCluster_(s,e),n.addVertex(t,r)}}}}return-1!==g&&n.removeUserIndex(g),-1!==u&&n.removeUserIndex(u),-1!==m&&n.removeUserIndex(m),this.m_topoGraph.deleteUserIndexForHalfEdges(l),(0,c.h)(o,d)}difference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=(0,a.e)(s),r=(0,a.e)(i);if(n>r)return t;const o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o]=!0,2===n&&2===r){let s=h.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=t),this.topoOperationPolygonPolygon_(t,e,s)}if(1===n&&2===r){const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}if(1===n&&1===r){const e={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}if(0===n)return this.topoOperationMultiPoint_();(0,a.c)("")}symmetricDifference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=F(s),r=F(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);return(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o]=!0,this.m_maskLookup[o]=!0,this.m_maskLookup[m]=!0,2===n&&2===r?this.topoOperationPolygonPolygon_(t,e,h.n):1===n&&1===r?this.topoOperationPolyline_(h.n,this.m_bOGCOutput):0===n&&0===r?this.topoOperationMultiPoint():void(0,a.c)("")}planarSimplifyNoCrackingAndCluster(t,e,s,i){this.m_bOGCOutput=t,this.m_topoGraph=new v;const n=e.getFillRule(s),r=e.getGeometryType(s);if(1!==n||r===a.G.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(e,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const o=this.m_topoGraph.getGeometryID(s);if((0,a.g)(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0,e.getGeometryType(s)===a.G.enumPolygon||1===n&&e.getGeometryType(s)!==a.G.enumMultiPoint){e.setFillRule(s,0);const r=this.topoOperationPolygonPolygon_(s,h.n,h.n);if(e.swapGeometry(r,s),e.removeGeometry(r),1===n&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(t,e,s,i)}else if(e.getGeometryType(s)===a.G.enumPolyline){const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=i;const n=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),t);e.swapGeometry(n,s),e.removeGeometry(n)}else if(e.getGeometryType(s)===a.G.enumMultiPoint){const t=this.topoOperationMultiPoint_();e.swapGeometry(t,s),e.removeGeometry(t)}else(0,a.c)("");return!0}unsplitPolylineExact(t){return(0,a.g)(0),new h.a}planarSimplifyPolylines(t,e,s,i,n){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,a.g)(s===a.G.enumPolyline)}let r=0,o=0,l=null;if(t.hasCurves()&&!t.hasSegmentParentage()){l=new m.C;const s=t.getEnvelope2D(this.m_progressTracker);o=(0,m.s)(e.total());const i=(0,m.d)(e.total(),s);r=(0,m.f)(i,o),(0,m.b)(t,i,e.total(),12e3,l,null,this.m_progressTracker)}{const s=(0,m.c)(e.add(r));t.filterClosePoints(s,!1,!1,!1,h.n)}if(this.m_topoGraph=new v,4!==n&&5!==n)if(null===l&&s){const i=new m.P(this.m_progressTracker,!1);i.sweepVertical(t,e.total()),i.hadComplications()?((0,m.e)(t,e,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else(0,m.e)(t,e.add(r),this.m_progressTracker,!0,!1),s=!1;else s=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const u=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,u,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(s&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(t,e,!1,i,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const c=this.m_topoGraph.getGeometryID(u);(0,a.g)(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0;const g=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),i);null!==l&&l.stitchCurves(t,g,o,!0);const _=t.getGeometry(g);return s||_.getImpl().setIsSimple(4,e.total()),_}planarSimplifyMultiPoints(t,e,s,i){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,a.g)(s===a.G.enumMultiPoint)}this.m_topoGraph=new v,4!==i&&5!==i?((0,m.e)(t,e,this.m_progressTracker,!0,!1),s=!1):s=!1,t.removeSelection(),t.collapseAllGeometriesToFirst();const n=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(t,e,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const r=this.m_topoGraph.getGeometryID(n);(0,a.g)(r>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=r+1,this.m_maskLookup[r]=!0;const o=this.topoOperationMultiPoint(),l=t.getGeometry(o);return s||l.getImpl().setIsSimple(4,e.total()),l}planarSimplifyPolygons(t,e,s,i,n,r){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const i=t.getGeometryType(e);(0,a.g)(i===a.G.enumPolygon||i===a.G.enumPolyline&&s)}let o=0,l=0,u=null;if(t.hasCurves()&&!t.hasSegmentParentage()){u=new m.C;const s=t.getEnvelope2D(this.m_progressTracker);l=(0,m.s)(e.total());const i=(0,m.d)(e.total(),s);o=(0,m.f)(i,l),(0,m.b)(t,i,e.total(),12e3,u,null,this.m_progressTracker)}if(r){(0,m.e)(t,e.add(o),this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e))t.getGeometryType(e)===a.G.enumPolygon&&A(t,e,-1,!1,h.n,this.m_progressTracker)}if(this.m_topoGraph=new v,r||4===n||5===n)i=!1;else if(null===u&&i){const s=new m.P(this.m_progressTracker,!1);s.sweepVertical(t,e.total()),s.hadComplications()?((0,m.e)(t,e,this.m_progressTracker,!0,!1),i=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else(0,m.e)(t,e.add(o),this.m_progressTracker,!0,!1),i=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const c=t.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(t,c,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,c,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(i&&null===u),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(t,e,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(c);(0,a.g)(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0,t.setFillRule(c,0);const _=this.m_bOGCOutput&&s,d=_;let p=this.topoOperationPolygonPolygon_(c,h.n,h.n,d);_&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,t.removeGeometry(c),this.m_topoGraph=new v,this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,p,this.m_progressTracker),p=this.topoOperationPolygonPolygon_(p,h.n,h.n,!1)),null!==u&&u.stitchCurves(t,p,l,!0);const f=t.getGeometry(p);return f.setFillRule(0),i?f.getImpl().setIsSimple(3,0):(f.getImpl().setIsSimple(4,e.total()),f.getImpl().updateOGCFlagsProtected()),f}planarSimplify3DImpl_(t,e,s,i,n){return(0,a.g)(0),{}}planarSimplifyImpl_(t,e,s,i,n,r,o,m){if(t.isEmpty())return t.clone();const u=t.getGeometryType(),c=new h.E,g=c.addGeometry(t);if((0,l.h)(n)&&u===a.G.enumPolygon&&(s=!1,c.setFillRule(g,0)),m&&(t.hasAttribute(1)&&c.replaceNaNs(1,0),c.removeNaNVertices()),u===a.G.enumPolygon||u===a.G.enumPolyline&&s)return this.planarSimplifyPolygons(c,e,s,i,n,!1);if(u===h.a.type){const t={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=o,this.planarSimplifyPolylines(c,e,i,t,n)}if(u===a.G.enumMultiPoint)return this.planarSimplifyMultiPoints(c,e,i,n);(0,a.c)("what else?")}}function J(t,e,s,i){const n=t.getGeometryType();if(n===a.G.enumEnvelope){const e=new h.P({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(n===a.G.enumPoint&&("|"===i||"^"===i)){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(n===a.G.enumLine){const e=new h.a({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}if(n===a.G.enumMultiPoint&&"-"===i&&e.getGeometryType()===a.G.enumPoint){const e=new l.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}if(n===a.G.enumMultiPoint&&"&"===i&&e.getGeometryType()===a.G.enumPoint){const e=new l.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}return t}function Z(t){const e=t.getGeometryType();if(e===a.G.enumEnvelope){const e=new h.P({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===a.G.enumPoint){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(q(e)){const e=new h.a({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==a.G.enumMultiPoint&&e!==a.G.enumPolyline&&e!==a.G.enumPolygon&&(0,a.t)("Unexpected geometry type"),t}function Q(t,e,s,i){const n=s===h.n?t.getClusterHalfEdge(e):s;let r=n;(0,a.g)(t.getHalfEdgeOrigin(n)===e);do{i(r),r=t.getHalfEdgeNext(t.getHalfEdgeTwin(r))}while(r!==n)}class K{constructor(t,e,s,i,n,r){this.m_rParent=t,this.m_rTopoGraph=t.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(i),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(n),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=e,this.m_sideIndex=s,this.m_cuttee=i,this.m_cutter=n,this.m_rCutHandles=r,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){let e=0;const s=this.m_rShape.getPathSize(t);for(let i=this.m_rShape.getFirstVertex(t);e<s;e++,i=this.m_rShape.getNextVertex(i))this.m_rShape.setUserIndex(i,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(i)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(t){return 8|t}classifyStandardCut(t,e,s,i){const n=this.m_rShape.getPrevVertex(t),r=this.m_rShape.getNextVertex(t),o=n===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n)),a=r===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(r)),m=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i));let u=1,c=32,g=32;if(Q(this.m_rTopoGraph,e,l,(t=>{t===m&&(u=2),t===o&&(c=u),t===a&&(g=u)})),this.m_bConsiderTouch)32!==c&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|c),32!==g&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g);else{if(32===c||32===g)return 1;if(c===g&&o!==m&&o!==l&&a!==m&&a!==l)return 1;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|c),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g)}return 0}classifyTouchCut(t,e,s,i){const n=this.m_rShape.getPrevVertex(t),r=this.m_rShape.getNextVertex(t),o=n===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n)),a=r===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(r)),m=s===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=i===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i));if(!this.m_bConsiderTouch){let e;return(e=m===o||l===o)?this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))):(e=m===a||l===a)&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),e?0:1}if(o===h.n)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===h.n)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;if(o===a)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(l!==h.n){if(o===l)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===l)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;let s=1;Q(this.m_rTopoGraph,e,l,(e=>{if(e===o){const t=this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,t),s=2}else if(e===a){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=2}}))}else{if(o===m)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===m)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;let s=2;Q(this.m_rTopoGraph,e,m,(e=>{if(e===o){const t=this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,t),s=1}else if(e===a){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=1}}))}return 0}classifyCutVertex(t,e){let s=0,i=0;for(let n=this.m_rTopoGraph.getClusterVertexIterator(e);n!==h.n;n=this.m_rTopoGraph.incrementVertexIterator(n)){const r=this.m_rTopoGraph.getVertexFromVertexIterator(n);if(this.m_rShape.getGeometryFromVertex(r)===this.m_cutter){i++;const n=this.m_rShape.getPrevVertex(r),o=this.m_rShape.getNextVertex(r);s+=n===h.n||o===h.n?this.classifyTouchCut(t,e,n,o):this.classifyStandardCut(t,e,n,o)}}i&&s===i&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(t,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){const e=this.m_rShape.getPathSize(t);let s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,0);s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s)){const t=this.m_rTopoGraph.getClusterFromVertex(s);this.m_rTopoGraph.getClusterParentage(t)===this.m_IDBoth&&this.classifyCutVertex(s,t)}}const t=(t,e)=>{let s=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex);const i=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(t),this.m_rTopoGraph.getClusterFromVertex(e));return(this.m_rTopoGraph.getHalfEdgeParentage(i)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==h.n;e=this.m_rShape.getNextPath(e)){let s=this.m_rShape.getFirstVertex(e);const i=this.m_rShape.isClosedPath(e),n=this.m_rShape.getPathSize(e)+(i?1:0);let r=1,o=32;for(let e=this.m_rShape.getNextVertex(s);r<n;++r,s=e,e=this.m_rShape.getNextVertex(e)){const i=t(s,e);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=i),32!==o&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,o|i)}s=this.m_rShape.getLastVertex(e);let a=32;r=1;for(let e=this.m_rShape.getPrevVertex(s);r<n;++r,s=e,e=this.m_rShape.getPrevVertex(e)){const i=t(e,s);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=i),32!==a&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,a|i)}}let e=h.n,s=h.n,i=32;const n=this.m_rShape.hasSegmentParentage(),r=new h.S;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){const o=this.m_rShape.isClosedPath(t),m=this.m_rShape.getPathSize(t)+(o?1:0);let l=1,u=this.m_rShape.getFirstVertex(t),c=h.n,g=!0;for(let t=this.m_rShape.getNextVertex(u);l<m;++l,t=this.m_rShape.getNextVertex(t)){let o=this.m_rShape.getUserIndex(u,this.m_cutteeBreadcrumbsIndex);8===o?o=3:(o&=-9,4&o?o=4:3&~o||(o=3)),o!==i?(e!==h.n&&(c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i)),e=this.m_rShape.createGeometry(a.G.enumPolyline),s=this.m_rShape.insertPath(e,h.n),i=o,g=!0):this.m_rShape.getUserIndex(u,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==o&&(c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),s=this.m_rShape.insertPath(e,h.n),g=!0),c=this.m_rShape.addVertex(s,u);const m=this.m_rTopoGraph.getClusterFromVertex(u);!g&&n&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(c,!0);const l=this.m_rTopoGraph.getHalfEdgeFromVertex(u);if(n){const t=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(c,t,g||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,r),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(c),r.get().clone())),u=t,g=!1}c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i),e=h.n,s=h.n,i=32}}}function $(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return it(t,i);const o=(0,l.m)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=new u.J;return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.f)(r)){const r=t,o=new h.a({vd:r.getDescription()});return o.addSegment(r,!0),$(o,e,s,i,n)}(0,a.k)(r),(0,a.i)(r)||(0,a.b)("OGC simplify is not implemented for this geometry type");const m=t.getImpl().getIsSimple(o,[0]);let c=s?-1:m;if(5===c||0===c)return c;const g=new ct(t,e,c,n,!0);return r===a.G.enumMultiPoint||r===a.G.enumPolyline||r===a.G.enumPolygon?(c=g.isSimplePlanarImpl(),(0,l.e)(c)&&(c=5)):(0,a.c)(""),t.getImpl().setIsSimple(c,o),i&&i.assign(g.m_nonSimpleResult),c}function tt(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return it(t,i);const o=(0,l.m)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=u.J.constructEmpty();return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.f)(r)){const r=t,o=new h.a({vd:r.getDescription()});return o.addSegment(r,!0),tt(o,e,s,i,n)}const m=t.getImpl().getIsSimple(o,[0]);let c=s?-1:m;if(-1!==c)return c;const g=new ct(t,e,c,n,!1);return r===a.G.enumMultiPoint?c=g.multipointIsSimpleAsFeature():r===a.G.enumPolyline?c=g.polylineIsSimpleAsFeature():r===a.G.enumPolygon?c=g.polygonIsSimpleAsFeature():(0,a.c)(""),t.getImpl().setIsSimple(c,o),i&&i.assign(g.m_nonSimpleResult),c}function et(t,e,s,i){if(t.isEmpty())return t;const n=t.getGeometryType();if(n===a.G.enumPoint){const e=new m.N;if(it(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(n===a.G.enumEnvelope){const s=(0,l.m)(e,t,!0).total(),i=t,n=u.J.constructEmpty();return i.queryEnvelope(n),n.isDegenerate(s)?i.createInstance():t}if((0,a.f)(n)){const n=t,r=new h.a({vd:n.getDescription()});return r.addSegment(n,!0),et(r,e,s,i)}(0,a.k)(n);const r=(0,l.m)(e,t,!1).total(),o=t.getImpl().getIsSimple(r,[0]),c=s?-1:o;if((0,l.e)(c)){if(n===a.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}if((n===a.G.enumMultiPoint||n===a.G.enumPolyline)&&c>=1)return t;const g=new ct(t,e,c,i,!1);let _;return n===a.G.enumMultiPoint?_=g.multipointSimplifyAsFeature():n===a.G.enumPolyline?_=g.polylineSimplifyAsFeature():n===a.G.enumPolygon?_=g.polygonSimplifyAsFeature():(0,a.c)(""),_}function st(t,e,s,i){if(t.isEmpty())return t;const n=t.getGeometryType();if(n===a.G.enumPoint){const e=new m.N;if(it(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(n===a.G.enumEnvelope){const s=t,i=new u.J;s.queryEnvelope(i);const n=(0,l.m)(e,t,!0).total();return i.isDegenerate(n)?s.createInstance():t}if((0,a.f)(n)){const n=t,r=new h.a({vd:n.getDescription()});return r.addSegment(n,!0),st(r,e,s,i)}(0,a.k)(n),(0,a.i)(n)||(0,a.b)("OGC simplify is not implemented for this geometry type");const r=(0,l.m)(e,t,!1).total(),o=t.getImpl().getIsSimple(r,[0]),c=s?-1:o;if(5===c){if(n===a.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}return Y(t,(0,l.m)(e,t,!0),!1,c,i,0,!0)}function it(t,e){const s=t.getX(),i=t.getY();if(!Number.isFinite(s)||!Number.isFinite(i))return e&&(e.m_reason=2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0;if(t.hasAttribute(1)){const s=t.getZ();if(!Number.isFinite(s))return e&&(e.m_reason=Number.isNaN(s)?3:2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0}return 5}class nt{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 rt(t,e,s,i,n){return{x:t,y:e,ipath:s,ivertex:i,ipolygon:n}}function ot(t,e){return t.x===e.x&&t.y===e.y&&t.ipath===e.ipath&&t.ivertex===e.ivertex&&t.ipolygon===e.ipolygon}function at(t,e){t.x=e.x,t.y=e.y,t.ipath=e.ipath,t.ivertex=e.ivertex,t.ipolygon=e.ipolygon}function ht(t,e,s,i,n,r){return{x:t,y:e,ipath:s,ivertex:i,bBoundary:n,bEndPoint:r}}function mt(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 lt extends l.r{constructor(t){super(),this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_xy.read(2*e)-this.m_helper.m_xy.read(2*i);return n<0?-1:n>0?1:0}}class ut extends l.r{constructor(t){super(),this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_edges[e],r=this.m_helper.m_edges[i],o=n.getReversed(),a=r.getReversed();let h=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const t=o?n.m_segment.getStartY():n.m_segment.getEndY(),e=a?r.m_segment.getStartY():r.m_segment.getEndY(),s=Math.min(t,e);let i=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;i===this.m_helper.m_yScanline&&(i=s),h=n.m_segment.intersectionOfYMonotonicWithAxisX(i,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(i,0)}return h<m?-1:h>m?1:0}}class ct{constructor(t,e,s,i,n){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new l.I,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new l.T,this.m_xyToNode1=null,this.m_xyToNode2=null,this.m_pathOrientations=null,this.m_pathParentage=null,this.m_xy=null,this.m_pairs=[],this.m_pairIndices=null,this.m_pathsForOGCTests=[],this.m_curveStitcher=null,this.m_editShape=null,this.m_multiPathStitcher=null,this.m_nonSimpleResult=new m.N,this.m_progressCounter=0,this.m_progressTracker=i,this.m_geometry=t,this.m_knownSimpleResult=s,this.m_sr=e;const r=(0,l.m)(e,t,!1);this.m_toleranceIsSimple=r,this.m_toleranceIsSimpleClustering=(0,l.f)(r),this.m_toleranceIsSimpleCracking=(0,l.n)(r),this.m_toleranceSimplify=(0,l.m)(e,t,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=n,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const t=this.m_geometry.getGeometryType();return(0,a.h)(t)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?(0,a.h)(t)?this._CheckCracking()?this.m_geometry.getGeometryType()===a.G.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return(0,a.g)(0),7}generateSortedPairs(t){let e=null;(0,a.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 l.A(0),s&&(this.m_pathsForOGCTests.length=0);let n=0;for(let t=0;t<i;t++)if(this.m_pairs.push(2*t),this.m_pairs.push(2*t+1),this.m_pairIndices.add(2*t),this.m_pairIndices.add(2*t+1),s){for(;t>=e.getPathEnd(n);)n++;this.m_pathsForOGCTests.push(n)}const r=new l.B,o={parent:this,workPt:new c.P,userSort(t,e,i){i.sort(t,e,((t,e)=>this.parent.compareVerticesForPlanarClustering(t,e,s)))},getValue(t){const e=this.parent.m_pairs[t],s=e>>1;return this.parent.m_xy.queryPoint2D(2*s,this.workPt),this.workPt.y+(1&e?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};r.sort(this.m_pairIndices,0,2*i,o)}_TestToleranceDistancePlanar(t,e){const s=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1),n=this.m_xy.read(2*e),r=this.m_xy.read(2*e+1);return!(0,m.g)(s,i,n,r,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||0!==this.m_geometry.getDimension()&&s===n&&i===r}checkStructure(){const t=this.m_geometry.getGeometryType();if((0,a.h)(t)){const t=this.m_geometry.getImpl(),e=this.m_geometry.getGeometryType()===a.G.enumPolygon?3:2;for(let s=0,i=t.getPathCount();s<i;s++)if(t.getPathSize(s)<e){if(t.hasNonLinearSegments()&&t.hasNonLinearSegmentsPath(s)&&t.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new m.N(1,s,0),!1}}if((0,a.i)(t)){const t=this.m_geometry.getImpl(),e=t.getAttributeStreamRef(0);for(let s=0,i=t.getPointCount();s<i;s++)if(!e.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new m.N(2,s,0),!1;if(this.m_geometry.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,i=t.getPointCount();s<i;s++){const t=e.read(s);if(!Number.isFinite(t))return Number.isNaN(t)?this.m_nonSimpleResult=new m.N(3,s,0):this.m_nonSimpleResult=new m.N(2,s,0),!1}}}return!0}checkDegenerateSegments(t){const e=this.m_geometry.getImpl(),s=e.querySegmentIterator(),i=e.hasAttribute(1),n=i?(0,l.o)(this.m_sr,e,!1).total():0,r=e.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment();let a=e.calculateLowerLength2D();if(!(a>o||r&&e.isCurve()&&(a=e.calculateLength2D(),a>o))){if(t&&i){const t=e.getStartAttributeAsDbl(1,0),s=e.getEndAttributeAsDbl(1,0);if(Math.abs(s-t)>n)continue}return this.m_nonSimpleResult=new m.N(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return(0,a.g)(0),!1}_CheckClustering(){const t=this.m_geometry.getImpl();this.generateSortedPairs(t);const e=t.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new lt(this)),this.m_AET.setCapacity(e);for(let t=0,s=2*e;t<s;t++){this.progress_();const e=this.m_pairIndices.read(t),s=this.m_pairs[e],i=s>>1;if(1&s){const t=this.m_AET.search(i),e=this.m_AET.getPrev(t),s=this.m_AET.getNext(t);if(this.m_AET.deleteNode(t),e!==l.T.st_nullNode()&&s!==l.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new m.N(5,this.m_AET.getElement(e),this.m_AET.getElement(s)),!1}else{const t=this.m_AET.addElement(i),e=this.m_AET.getPrev(t);if(e!==l.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),i))return this.m_nonSimpleResult=new m.N(5,i,this.m_AET.getElement(e)),!1;const s=this.m_AET.getNext(t);if(s!==l.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),i))return this.m_nonSimpleResult=new m.N(5,i,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const t=this.m_geometry.getImpl(),e=t.getPointCount();return!t.hasNonLinearSegments()&&e<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new h.E,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new m.C;const t=u.J.constructEmpty();this.m_geometry.queryEnvelope(t);const e=(0,m.d)(this.m_toleranceSimplify.total(),t),s=new m.N;if((0,m.h)(this.m_editShape,e,this.m_toleranceSimplify.total(),12e3,s,this.m_curveStitcher,null,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!1}const t=new m.N;return(0,m.n)(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,t,this.m_progressTracker)?(null!=this.m_curveStitcher?(t.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex1),t.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex2),this.m_curveStitcher=null):(t.m_vertexIndex1=this.m_editShape.getVertexIndex(t.m_vertexIndex1),t.m_vertexIndex2=this.m_editShape.getVertexIndex(t.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(t),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator();for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(!e.isLastSegmentInPath()||!e.isLastPath()){s.resetTo(e);do{for(;s.hasNextSegment();){const i=s.nextSegment(),n=(0,h.i)(!0,t,i,this.m_toleranceIsSimpleCracking,!0);if(n){const t=2===n?7:6;return this.m_nonSimpleResult=new m.N(t,e.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let t=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),t=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(t)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=t.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const e=new Array(0),s=t.getPointCount();let i=Number.NaN,n=0;for(let t=0,r=2*s;t<r;t++){this.progress_();const s=this.m_pairIndices.read(t),r=this.m_pairs[s];if(1&r)continue;const o=r>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(e.length&&(a!==i||h!==n)){if(!this.processBunchForSelfIntersectionTest(e))return!1;e.length=0}e.push(o),i=a,n=h}return!!this.processBunchForSelfIntersectionTest(e)}checkSelfIntersectionsPolylinePlanar(){const t=this.m_geometry.getImpl(),e=[];for(let s=0,i=t.getPathCount();s<i;s++)e.push(t.isClosedPathInXYPlane(s));const s={x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1};let i,n,r;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,h=this.m_xy.readPoint2D(2*a),m=this.m_pathsForOGCTests[a];i=e[m],n=t.getPathStart(m),r=t.getPathEnd(m)-1,s.bEndPoint=a===n||a===r,this.m_bOGCRestrictions?s.bBoundary=!i&&s.bEndPoint:s.bBoundary=s.bEndPoint,s.ipath=m,s.x=h.x,s.y=h.y,s.ivertex=a}for(let o=1,a=this.m_pairIndices.size();o<a;o++){const a=this.m_pairIndices.read(o),h=this.m_pairs[a];if(1&h)continue;const l=h>>1,u=this.m_xy.readPoint2D(2*l),c=this.m_pathsForOGCTests[l];let g;c!==s.ipath&&(i=e[c],n=t.getPathStart(c),r=t.getPathEnd(c)-1);const _=l===n||l===r;g=this.m_bOGCRestrictions?!i&&_:_;const d=ht(u.x,u.y,c,l,g,_);if(d.x===s.x&&d.y===s.y)if(this.m_bOGCRestrictions){if(!(d.bBoundary&&s.bBoundary||d.ipath===s.ipath&&d.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new m.N(10,d.ivertex,s.ivertex),!1}else if(!d.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new m.N(7,d.ivertex,s.ivertex),!1;mt(s,d)}return!0}checkSelfIntersectionsPolylinePlanar3D(t){return(0,a.g)(0),!1}checkSelfIntersectionsPolygonsOGC(){const t=this.m_geometry.getImpl(),e=[];let s=-1,i=!1;for(let n=0,r=t.getPathCount();n<r;n++)t.isExteriorRingOGC(n)&&(i=!1,s++,n<r-1&&(t.isExteriorRingOGC(n+1)||(i=!0))),e.push(i?s:-1);const n={x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1};{const t=this.m_pairIndices.read(0),s=this.m_pairs[t]>>1,i=this.m_xy.readPoint2D(2*s),r=this.m_pathsForOGCTests[s];n.ipath=r,n.x=i.x,n.y=i.y,n.ivertex=s,n.ipolygon=e[r]}const r=[];for(let t=1,s=this.m_pairIndices.size();t<s;t++){const s=this.m_pairIndices.read(t),i=this.m_pairs[s];if(1&i)continue;const o=i>>1,a=this.m_xy.readPoint2D(2*o),h=this.m_pathsForOGCTests[o],l=rt(a.x,a.y,h,o,e[h]);if(l.x===n.x&&l.y===n.y){if(l.ipath===n.ipath)return this.m_nonSimpleResult=new m.N(11,l.ivertex,n.ivertex),!1;e[l.ipath]>=0&&e[l.ipath]===e[n.ipath]&&(0!==r.length&&ot(r.at(-1),n)||r.push({...n}),r.push(l))}at(n,l)}if(0===r.length)return!0;const o=new l.I(!0);e.fill(-1);let a=-1;const h=new c.P;for(let t=0,s=r.length;t<s;t++){const s=r[t];s.x===h.x&&s.y===h.y||(a=o.createList(0),h.x=s.x,h.y=s.y);let i=e[s.ipath];-1===i&&(i=o.createList(2),e[s.ipath]=i),o.addElement(i,a),o.addElement(a,i)}const u=[];for(let t=o.getFirstList();-1!==t;t=o.getNextList(t)){const s=o.getListData(t);if(1&s||!(2&s))continue;let i=-1;for(u.push(t),u.push(-1);u.length;){const t=u.at(-1);u.pop();const e=u.at(-1);u.pop();const s=o.getListData(e);if(1&s){i=2&s?e:t;break}o.setListData(e,1|s);for(let s=o.getFirst(e);-1!==s;s=o.getNext(s)){const i=o.getData(s);i!==t&&(u.push(i),u.push(e))}}if(-1!==i){const t=e.indexOf(i);return this.m_nonSimpleResult=new m.N(12,t,-1),!1}}return!0}_CheckValidRingOrientation(){const t=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(t.calculateArea2D()<=0)return this.m_nonSimpleResult=new m.N(8,1===t.getPathCount()?1:-1,-1),0;if(1===t.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new l.p(t.getPathCount(),0),this.m_pathParentage=new l.A(t.getPathCount(),-1);let e=-1,s=0;for(let i=0,n=t.getPathCount();i<n;i++){const n=t.calculateRingArea2D(i);if(this.m_pathOrientations.write(i,n<0?0:8),n>0)e=i,s=n;else{if(0===n)return this.m_nonSimpleResult=new m.N(8,i,-1),0;if((e<0||s<Math.abs(n))&&(this.m_nonSimpleResult=new m.N(9,i,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(i,e)}}this.m_unknownOrientationPathCount=t.getPathCount(),this.m_newEdges.length=0;const i=t.getPointCount();this.m_yScanline=Number.NaN;const n=[];this.m_xyToNode1=new l.A(i,l.T.st_nullNode()),this.m_xyToNode2=new l.A(i,l.T.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new ut(this));for(let t=0,e=2*i;this.m_unknownOrientationPathCount>0&&t<e;t++){const e=this.m_pairIndices.read(t),s=this.m_pairs[e];if(1&s)continue;const i=s>>1,r=this.m_xy.read(2*i+1);if(r!==this.m_yScanline&&n.length){if(!this.processBunchForRingOrientationTest(n))return 0;n.length=0}n.push(i),this.m_yScanline=r}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(n)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(t){if(1===t.length)return!0;for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const i=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(i,s,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort(((t,e)=>this.edgeAngleCompare(t,e)));let e=this.m_crossOverHelperList.getFirstList();-1===e&&(e=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let t=0,s=this.m_edges.length;t<s;t++)this.m_crossOverHelperList.addElement(e,t);let s=!0,i=-1,n=-1;for(;s;){s=!1;let t=this.m_crossOverHelperList.getFirst(e);if(-1===t)break;let r=this.m_crossOverHelperList.getNext(t);for(;-1!==r;){const o=this.m_crossOverHelperList.getData(t),a=this.m_crossOverHelperList.getData(r);if(i=this.m_edges[o].m_vertexIndex,n=this.m_edges[a].m_vertexIndex,i!==n)t=r,r=this.m_crossOverHelperList.getNext(t);else if(s=!0,this.m_crossOverHelperList.deleteElement(e,t),t=this.m_crossOverHelperList.getPrev(r),r=this.m_crossOverHelperList.deleteElement(e,r),-1===r||-1===t)break}}const r=this.m_crossOverHelperList.getListSize(e);if(this.m_crossOverHelperList.clear(e),r>0)return this.m_nonSimpleResult=new m.N(7,i,n),!1;for(let e=0,s=t.length;e<s;e++)this.recycleEdge(this.m_edges[e]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(t){for(let e=0,s=t.length;e<s;e++){const s=t[e];let i=this.m_xyToNode1.read(s);if(i!==l.T.st_nullNode()){const t=this.m_AET.getElement(i);this.m_freeEdges.push(t),this.m_AET.deleteNode(i),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode1.write(s,l.T.st_nullNode())}if(i=this.m_xyToNode2.read(s),i!==l.T.st_nullNode()){const t=this.m_AET.getElement(i);this.m_freeEdges.push(t),this.m_AET.deleteNode(i),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode2.write(s,l.T.st_nullNode())}}for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const i=this.m_recycledSegIter.previousSegment();if(i.getStartY()>i.getEndY()){const t=this.m_recycledSegIter.getStartPointIndex(),e=this.createEdge(i,s,this.m_recycledSegIter.getPathIndex(),!0);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=e):(n=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(n);this.m_xyToNode1.read(t)===l.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();if(n.getStartY()<n.getEndY()){const t=this.m_recycledSegIter.getEndPointIndex(),e=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!1);let i;this.m_freeEdges.length>0?(i=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[i]=e):(i=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(i);this.m_xyToNode1.read(t)===l.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}}for(let t=0,e=this.m_newEdges.length;t<e&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),i=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(i))){let t=-1,s=this.m_AET.getPrev(e),i=e,n=0;{let e=-1,r=null,o=-1,a=0;for(;s!==l.T.st_nullNode()&&(e=this.m_AET.getElement(s),r=this.m_edges[e],o=r.m_pathIndex,a=this.m_pathOrientations.read(o),!(3&a));)i=s,s=this.m_AET.getPrev(s);s===l.T.st_nullNode()?(n=1,s=i):(t=1==(3&a)?o:this.m_pathParentage.read(o),n=r.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),r=this.m_edges[e],o=r.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(n!==r.getRightSide())return this.m_nonSimpleResult=new m.N(8,o,-1),!1;const e=n&&!r.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new m.N(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),i=s,s=this.m_AET.getNext(s),n=n?0:1}while(i!==e)}}return this.m_newEdges.length=0,!0}createEdge(t,e,s,i){let n;return t.getGeometryType()===a.G.enumLine?n=this.createEdgeLine(t):(n=new nt,n.m_segment=t.clone()),n.m_vertexIndex=e,n.m_pathIndex=s,n.m_flags=0,n.setReversed(i),n}createEdgeLine(t){let e;return this.m_lineEdgesRecycle.length>0?(e=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),t.copyTo(e.m_segment)):(e=new nt,e.m_segment=t.clone()),e}recycleEdge(t){t.m_segment.getGeometryType()===a.G.enumLine&&this.m_lineEdgesRecycle.push(t)}static isShortSegment(t,e,s,i){let n=t.calculateLowerLength2D();if(n<=s){let r=!0;if(t.isCurve()&&(n=t.calculateLength2D(),r=n<=s),r){if(e){let e=t.getEndAttributeAsDbl(1,0);Number.isNaN(e)&&(e=0);let s=t.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-e)<=i}return!0}return!1}return!1}static isShortSegmentPoints(t,e,s,i,n){if(s){const s=t.getXYZ(),r=e.getXYZ();return(0,l.q)(s,r,i,n)}{const s=t.getXY(),n=e.getXY();return c.P.sqrDistance(s,n)<=i*i}}removeDegenerateSegmentsFromCurvedPath(t,e,s,i){const n=t.hasAttribute(1),r=t.querySegmentIterator();r.resetToPath(e),(0,a.g)(r.nextPath());const o=this.m_toleranceSimplify.total();let h=!1,m=!0;const u=new l.P,g=new l.P,_=new c.P;for(;r.hasNextSegment();){this.progress_();const t=r.nextSegment();if(ct.isShortSegment(t,n,o,s))if(h){if(t.queryEnd(g),ct.isShortSegmentPoints(u,g,n,o,s))continue;m&&(i.startPathPoint(u),m=!1),t.queryEnd(u),i.lineToPoint(u),h=!1}else _.assign(t.getStartXY()),t.queryStart(u),h=!0;else if(h)if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(_,t.getEndXY(),!1),e.setStart(u),ct.isShortSegment(e,n,o,s))continue;i.addSegment(e,m),m=!1,h=!1}else{if(t.queryEnd(g),ct.isShortSegmentPoints(u,g,n,o,s))continue;m&&(i.startPathPoint(u),m=!1),i.lineToPoint(g),h=!1}else i.addSegment(t,m),m=!1}if(m)return;if(!h)return;t.isClosedPath(e)?t.getPointByVal(t.getPathStart(e),u):t.getPointByVal(t.getPathEnd(e)-1,u);const d=i.querySegmentIterator();d.resetToLastPath(),d.resetToLastSegment();const p=i.getDescription().getAttributeCount()>1;for((0,a.g)(d.previousPath());d.hasPreviousSegment();){const t=d.previousSegment();if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(t.getStartXY(),u.getXY(),!1),!ct.isShortSegment(e,n,o,s)){p&&e.setEnd(u);const t=d.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.addSegment(e,!1)}}else if(t.queryStart(g),!ct.isShortSegmentPoints(g,u,n,o,s)){const t=d.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.lineToPoint(u)}}i.removePath(i.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const t=this.m_geometry.getImpl();this.m_multiVertexGeom=t;const e=t.getPointCount(),s=new Array(e);for(let t=0;t<e;t++)s[t]=t;s.sort(((t,e)=>this.compareVerticesMultiPoint(t,e)));for(let t=1;t<e;t++)if(0===this.compareVerticesMultiPoint(s[t-1],s[t]))return this.m_nonSimpleResult=new m.N(5,s[t-1],s[t]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let t=this.m_geometry.getImpl();const e=ct.hasNanZs(t);let s,i=this.m_geometry;e&&(s=this.m_geometry.clone(),t=s.getImpl(),s.replaceNaNs(1,l.V.getDefaultValue(1)),i=s),this.m_multiVertexGeom=t;const n=t.getPointCount(),r=new Array(n);for(let t=0;t<n;t++)r[t]=t;r.sort(((t,e)=>this.compareVerticesMultiPoint(t,e)));const o=new Array(n);o.fill(!1);let a=-1;for(let e=0;e<n;e++){const s=r[e];t.getXY(s).isFinite()&&((a<0||0!==this.compareVerticesMultiPoint(a,s))&&(o[s]=!0),a=s)}const h=this.m_geometry.createInstance();let m=0,u=0;for(let t=0;t<n;t++)o[t]?u=t+1:(m<u&&h.addPoints(i,m,u),m=t+1);return m<u&&h.addPoints(i,m,u),h.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),h}polylineSimplifyAsFeature(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator(),i=this.m_geometry.createInstance(),n=this.m_geometry,r=t.hasAttribute(1),o=r?(0,l.o)(this.m_sr,t,!0).total():0,a=[],h=[];let m=null;r&&(m=t.getAttributeStreamRef(1));const u=new l.P,g=t.hasNonLinearSegments(),_=this.m_toleranceSimplify.total();for(;e.nextPath();){if(s.nextPath(),t.getPathSize(e.getPathIndex())<2)continue;if(g&&t.hasNonLinearSegmentsPath(e.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(t,e.getPathIndex(),o,i);continue}s.resetToLastSegment();let l=0,d=0,p=!0,f=!0;for(;e.hasNextSegment();){this.progress_();const i=e.nextSegment(),n=s.previousSegment();if(e.getStartPointIndex()>s.getStartPointIndex())break;if(p){const s=e.getStartPointIndex();t.getXY(s).isNAN()||(p=!1,a.push(s))}if(f){const e=s.getEndPointIndex();t.getXY(e).isNAN()||(h.push(e),f=!1)}if(!p){const s=a.at(-1),n=e.getEndPointIndex();if(n-s>1){const e=new c.P;e.setSub(t.getXY(s),t.getXY(n)),l=e.length()}else l=i.calculateLength2D();if(l>_)a.push(n),l=0;else if(r){let t=m.read(s);Number.isNaN(t)&&(t=0);let e=m.read(n);Number.isNaN(e)&&(e=0),Math.abs(e-t)>o&&(a.push(n),l=0)}}if(!f){const e=h.at(-1),i=s.getStartPointIndex();if(i-e>1){const s=new c.P;s.setSub(t.getXY(e),t.getXY(i)),d=s.length()}else d=n.calculateLength2D();if(d>_)h.push(i),d=0;else if(r){let t=m.read(e);Number.isNaN(t)&&(t=0);let s=m.read(i);Number.isNaN(s)&&(s=0),Math.abs(s-t)>o&&(h.push(i),d=0)}}}if(a.length>0&&h.length>0&&(a.at(-1)<h.at(-1)?a.length>h.length?a.pop():h.pop():(a.at(-1)===h.at(-1)||h.pop(),h.pop())),h.length+a.length>=2){let t=!1;for(let e=0,s=a.length;e<s;e++)n.getPointByVal(a[e],u),t?i.lineToPoint(u):(i.startPathPoint(u),t=!0);for(let e=h.length-1;e>0;e--)n.getPointByVal(h[e],u),t?i.lineToPoint(u):(i.startPathPoint(u),t=!0);n.isClosedPath(e.getPathIndex())?i.closePathWithLine():h.length>0&&(n.getPointByVal(h[0],u),i.lineToPoint(u))}a.length=0,h.length=0}return r&&i.replaceNaNs(1,0),i.getImpl().setIsSimple(1,_),i}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!(0,l.h)(this.m_knownSimpleResult))return X(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const t=new h.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,i=0;if(t.hasCurves()){e=new m.C;const n=u.J.constructEmpty();this.m_geometry.queryEnvelope(n);const r=(0,m.d)(this.m_toleranceSimplify.total(),n);s=(0,m.s)(this.m_toleranceSimplify.total()),i=(0,m.f)(r,s),(0,m.b)(t,r,this.m_toleranceSimplify.total(),12e3,e,null,this.m_progressTracker)}if(!(0,l.h)(this.m_knownSimpleResult)){const e=this.m_toleranceSimplify.add(i);(0,m.e)(t,e,this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===a.G.enumPolygon&&A(t,t.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==e&&e.stitchCurves(t,t.getFirstGeometry(),s,!0)}const e=t.getGeometry(t.getFirstGeometry());return e.getGeometryType()===a.G.enumPolygon&&(e.getImpl().updateOGCFlagsProtected(),e.setFillRule(0)),e.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),e}progress_(){}static hasNanZs(t){if(t.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,i=t.getPointCount();s<i;s++){const t=e.read(s);if(Number.isNaN(t))return!0}}return!1}compareVerticesForPlanarClustering(t,e,s){if(t===e)return 0;const i=this.m_pairs[t],n=this.m_pairs[e],r=i>>1,o=n>>1,a=this.m_xy.readPoint2D(2*r);a.y+=1&i?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const h=this.m_xy.readPoint2D(2*o);h.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=a.compare(h);if(0===m&&s){const t=this.m_pathsForOGCTests[r]-this.m_pathsForOGCTests[o];return(0,c.d)(t)}return m}compareVerticesMultiPoint(t,e){if(t===e)return 0;const s=this.m_multiVertexGeom.getXY(t),i=this.m_multiVertexGeom.getXY(e),n=!s.isFinite(),r=!i.isFinite();if(n||r)return n<r?-1:n>r?1:0;if(s.y<i.y)return-1;if(s.y>i.y)return 1;if(s.x<i.x)return-1;if(s.x>i.x)return 1;for(let s=1;s<this.m_attributeCount;s++){const i=this.m_description.getSemantics(s),n=l.V.getComponentCount(i);for(let s=0;s<n;s++){const n=this.m_multiVertexGeom.getAttributeAsDbl(i,t,s),r=this.m_multiVertexGeom.getAttributeAsDbl(i,e,s),o=(0,c.j)(n,r);if(0!==o)return o}}return 0}edgeAngleCompare(t,e){if(t===e)return 0;const s=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&s.negateThis();const i=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&i.negateThis();const n=s.getQuarter(),r=i.getQuarter();if(r===n){const t=s.crossProduct(i);return t<0?1:t>0?-1:0}return n<r?-1:1}}class gt{getOperatorType(){return 10103}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}isSimpleAsFeature(t,e,s,i,n){const r=tt(t,e,s,i,n);return(0,l.j)(t.getGeometryType(),r)}isSimplePlanarDONOTUSE(t,e,s,i,n){const r=function(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return it(t,i);const o=(0,l.m)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=new u.J;return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.f)(r)){const r=t,o=new h.a({vd:r.getDescription()});return o.addSegment(r,!0),tt(o,e,s,i,n)}const m=t.getImpl().getIsSimple(o,[0]);let c=s?-1:m;if((0,l.e)(c)||0===c)return c;const g=new ct(t,e,c,n,!1);return r===a.G.enumMultiPoint||r===a.G.enumPolyline||r===a.G.enumPolygon?c=g.isSimplePlanarImpl():(0,a.c)(""),t.getImpl().setIsSimple(c,o),i&&i.assign(g.m_nonSimpleResult),c}(t,e,s,i,n);return(0,l.e)(r)}executeMany(t,e,s,i){return new _t(t,e,s,i)}execute(t,e,s,i){const n=new o.S([t]),r=this.executeMany(n,e,s,i).next();return r||(0,a.c)("null geometry"),r}}class _t extends o.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=t,this.m_spatialReference=e}next(){const t=this.m_inputGeometryCursor.next();return t?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(t)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(t){if(t||(0,a.t)(""),t.getGeometryType()===a.G.enumGeometryCollection){const e=(0,h.g)(t,-1),s=(new gt).executeMany(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),i=t.createInstance();for(let t=s.next();null!=t;t=s.next())i.addGeometry(t);return i}return et(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}},96546:(t,e,s)=>{s.d(e,{O:()=>u});var i=s(76061),n=s(55537),r=s(83661),o=s(35368),a=s(79187),h=s(31085),m=s(95213),l=s(32406);class u{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i=0){return new g(t,e,s,i)}execute(t,e,s,r){const o=new i.S([t,e]),a=new g(o,s,r,0).next();return a||(0,n.c)("null output"),a}}class c{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(t){this.binVertexCount+=t.vertexCount,this.geometries.push(t)}sort(){this.geometries.sort(((t,e)=>function(t,e){return r.P.compareZorder(t.location,e.location)?-1:t.location.equals(e.location)?0:1}(t,e)))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class g extends i.G{constructor(t,e,s,i,n=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=(0,r.o)(4),this.m_dimGeomCounts=(0,r.f)(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=(0,r.f)(4,!1),this.m_complexUnionGeoms=(0,r.o)(4),this.m_totalNonEmptyGeomCounters=(0,r.f)(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&i),this.m_bPreserveAllPathEnds=!!(8&i),this.m_inputGeoms=t,this.m_spatialReference=e,this.m_options=i,this.m_bIs3D=n}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let t=0;t<=this.m_maxDimension;t++)if(this.m_bHadGeometry[t]){this.m_complexUnionGeoms[t]=this.getResultGeometry(t);for(let e=t+1;e<=this.m_maxDimension;e++)this.m_complexUnionGeoms[e]=this.getResultGeometry(e),this.m_bHadGeometry[e]&&!this.m_complexUnionGeoms[e].isEmpty()&&(this.m_bIs3D?(0,n.g)(0):this.m_complexUnionGeoms[t]=(new h.O).execute(this.m_complexUnionGeoms[t],this.m_complexUnionGeoms[e],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&(0,n.c)(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===n.G.enumPoint){const t=new o.M({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||t.add(this.m_complexUnionGeoms[this.m_currentDim]),t}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(t){return this.m_readyGeoms[t]}finishDim(t,e,s){let i=e;if(!s)return 16&this.m_options?(i=(0,l.d)([i],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),i):i;if(1&this.m_options)return i;if(1===t)if(8&this.m_options||!(16&this.m_options||this.m_totalNonEmptyGeomCounters[t]>1))1===this.m_totalNonEmptyGeomCounters[t]&&(this.m_bIs3D?(0,n.g)(0):i=(new l.O).execute(i,this.m_spatialReference,!1,this.m_progressTracker));else{i=(0,l.d)([i],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const t=[0],e=i.getImpl().getIsSimple(0,t);(0,n.g)(this.m_bIs3D||(0,m.e)(e))}else this.m_bIs3D?(0,n.g)(0):i=(new l.O).execute(i,this.m_spatialReference,!1,this.m_progressTracker);if(0===t&&i.getGeometryType()===n.G.enumPoint){const t=new o.M({vd:i.getDescription()});i.isEmpty()||t.add(i),i=t}return i}static getLevel(t){const e=(0,n.v)(t);let s=e>0?(Math.log(e)-Math.log(32))/Math.log(4):0;return s<0&&(s=0),Math.floor(s)}step_(){if(this.m_bDone)return!0;let t;if(this.m_inputGeoms?(t=this.m_inputGeoms.next(),null===t?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(t),t.isEmpty()||this.m_totalNonEmptyGeomCounters[t.getDimension()]++)):t=null,null!==t){const e=t.getDimension();this.m_bHadGeometry[e]=!0,(e>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(e,!1,t),e>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(e))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?(0,l.d)(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):(0,l.a)(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&((0,n.g)(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,i=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,i)}}return this.m_bDone}addGeom(t,e,s){const i={geom:null,vertexCount:-1,bUnioned:!1,location:new r.P};i.geom=s;const o=(0,n.v)(s);i.vertexCount=o;const h=a.J.constructEmpty();s.queryEnvelope(h),i.location=o>0?h.getCenter():new r.P(0,0);const m=g.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 c,this.m_unionBins[t].set(m,l)),i.bUnioned=e,l.addPair(i),this.m_dimGeomCounts[t]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,t)}removeAllBinsWithLowerDimension(t){for(let e=0;e<t;e++)this.m_unionBins[e].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[e],this.m_dimGeomCounts[e]=0}collectGeometriesToUnion(t){if(1&this.m_options&&!this.m_bDone)return null;let e=null;const s=[];for(const e of this.m_unionBins[t].keys())s.push(e);(0,r.p)(s);for(let i=0;i<s.length;i++){if(-1===s[i])continue;const n=this.m_unionBins[t].get(s[i]);{const r=5e3,o=4,a=n.getBinVertexCount()>r&&n.geomCount()>=o;if(this.m_bDone||a){for(let n=0;n<i;n++){if(-1===s[n])continue;const i=this.m_unionBins[t].get(s[n]);i.sort(),this.m_dimGeomCounts[t]-=i.geomCount(),this.m_addedGeoms-=i.geomCount();for(const t of i.geomPairs())e||(e=new Array),e.push(t.geom);i.clear(),this.m_unionBins[t].delete(s[n]),s[n]=-1}n.sort(),this.m_dimGeomCounts[t]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const t of n.geomPairs())e||(e=new Array),e.push(t.geom);if(n.clear(),this.m_unionBins[t].delete(s[i]),s[i]=-1,!this.m_bDone)break}}}return e}checkAndThrow(t){this.m_bIs3D&&(t.getDimension()>1&&(0,n.m)(),t.hasAttribute(1)||(0,n.t)("Geometry must have Zs")),(0,n.d)(t)}}},12189:(t,e,s)=>{s.r(e),s.d(e,{$:()=>as,A:()=>Hs,B:()=>w,C:()=>As,D:()=>ws,E:()=>G,F:()=>vn,G:()=>He,H:()=>ys,I:()=>Fs,J:()=>H,K:()=>V,L:()=>ni,M:()=>Y,N:()=>qs,O:()=>ms,P:()=>yn,Q:()=>Sn,R:()=>le,S:()=>B,T:()=>F,U:()=>mi,V:()=>us,W:()=>ci,X:()=>li,Y:()=>Qs,Z:()=>O,_:()=>W,a:()=>ls,a0:()=>hs,a1:()=>Ri,a2:()=>Wi,a3:()=>en,a4:()=>Cn,a5:()=>Gs,a6:()=>k,a7:()=>Zi,a8:()=>Ji,a9:()=>Qe,aa:()=>Ui,ab:()=>hn,ac:()=>P,ad:()=>Un,ae:()=>On,af:()=>Wn,ag:()=>jn,ah:()=>Jn,b:()=>Hi,c:()=>Bi,d:()=>os,e:()=>ai,f:()=>Pe,g:()=>fe,h:()=>bs,i:()=>Xi,j:()=>Oi,k:()=>S,l:()=>Be,m:()=>vs,n:()=>ye,o:()=>En,p:()=>Nn,q:()=>Tn,r:()=>mt,s:()=>Yi,t:()=>Le,u:()=>Se,v:()=>ve,w:()=>Ee,x:()=>Ce,y:()=>T,z:()=>Ms});var i=s(79187),n=s(55537),r=s(35368),o=s(95213),a=s(83661),h=s(90237),m=s(11878),l=s(54573),u=s(5247),c=s(32406),g=s(31139),_=s(32932),d=s(76061),p=s(86117),f=s(96546),x=s(31085);class P{constructor(t){if(this.m_geom=this.m_sr=null,t){if(t.move)return this.m_geom=t.move.m_geom,t.move.m_geom=null,this.m_sr=t.move.m_sr,void(t.move.m_sr=null);if(t.copy)return this.m_geom=t.copy.m_geom?t.copy.m_geom.clone():null,void(this.m_sr=t.copy.m_sr);t.geom&&(this.m_geom=t.geom),t.sr&&(this.m_sr=t.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(t){this.m_geom=t}setSpatialReference(t){this.m_sr=t}equals(t,e){const s=t;return!(!this.m_sr&&s.m_sr||this.m_sr&&!s.m_sr||!this.m_geom&&s.m_geom||this.m_geom&&!s.m_geom||this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr)||this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,e))}clone(){let t=null;return this.m_geom&&(t=this.m_geom.clone()),new P({geom:t,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class y{constructor(t){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,t&&(this.m_peUnit=t,this.m_factor=t.getUnitFactor(),this.m_wkid=t.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit.getName()}getID(){return this.m_wkid}getConversionFactor(t){return this.getUnitType()!==t.getUnitType()&&(0,n.t)("unit type mismatch"),this.getUnitToBaseFactor()/t.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return(0,a.av)((0,a.l)(this.getUnitType()),(0,a.l)(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 E={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,6377397.155:[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],6377563.396:[4001,4188,4277,4278,4279],6377340.189:[4002,4299,4300],6377492.018:[4005,4273,4817],6377483.865280418:[4006,4293],6378293.645208759:[4007,4157,4302,4738,5464],6378206.4:[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],6378450.047:[4009,4268],6378300.789:[4010,4281],6378249.2:[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],6378249.145:[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104103,104305],6377276.345:[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],6377298.556:[4016,4298],6377304.063:[4018,4245],6378298.3:[4028,4903],6378136.2:4032,6378136.3:4033,6378249.144808011:[4034,4241],20922931.8:[4042,4243],6377301.243:[4044,4145,37203],6377299.151:[4045,4146],6377019.27:[4657,10256,10260,10265],6378306.3696:[4748,4752],6377295.664:[4751,37006],6378136.5:[7682,7683],6371008.7714:104047,6378418.941:[104700,104726,104760],6378586.581:[104701,104743],6378505.809:104702,6378544.823:104703,6378490.569:104704,6378470.757:[104705,104776],6378403.701:[104706,104750],6378434.181:[104707,104724,104739,104764],6378454.907:104708,6378400.653:104709,6378567.378:104710,6378546.957:[104711,104717,104780],6378476.853:[104712,104736],6378411.321:[104713,104728],6378647.541:[104714,104715],6378514.953:[104716,104782],6378421.989:[104718,104770],6378481.425:[104719,104753,104774,104781],6378518.001:[104720,104725],6378521.049:[104721,104723,104731,104745,104748],6378464.661:104722,6378436.619:104727,6378574.389:[104729,104730],6378472.281:[104732,104756],6378498.189:[104733,104746],6378449.421:[104734,104766],6378525.621:[104735,104754],6378466.185:104737,6378496.665:104738,6378643.579:104740,6378559.758:104741,6378414.369:[104742,104763,104772],6378441.801:104744,6378502.761:[104747,104759,104773,104775],6378617.061:104749,6378624.681:[104751,104765],6378468.623:104752,6378445.763:[104755,104758,104761],6378670.401:104757,6378438.753:104762,6378543.909:104767,6378605.783:104768,6378540.861:104769,6378443.325:[104771,104784],6378548.481:104777,6378463.746:104778,6378426.561:104779,6378453.688:104783,6378530.193:104785,6378376.271:[104800,104828],6378471.92:104801,6378472.931:104802,6378411.351:104803,6378380.991:104805,6378414.96:104806,6378345.09:[104807,104819,104844,104870],6378412.542:104808,6378470.401:104809,6378376.331:104810,6378379.031:104811,6378407.621:104812,6378376.811:[104813,104827],6378313.92:104814,6378414.93:104815,6378413.021:104816,6378380.381:104817,6378530.851:104818,6378591.521:104820,6378378.881:104821,6378408.481:[104822,104832],6378375.601:[104823,104838],6378408.041:104824,6378655.071:104825,6378409.151:104826,6378315.7:[104829,104840,104845,104851],6378285.86:[104830,104835,104859],6378379.301:104831,6378560.121:104833,6378531.821:104834,6378500.6:104836,6378376.041:104837,6378406.601:104839,6378438.991:104841,6378345.42:104842,6378593.86:104843,6378381.271:[104846,104847],6378413.671:104848,6378344.377:104849,6378563.891:104850,6378408.091:104852,6378377.671:104853,6378472.751:104854,6378412.511:104855,6378407.281:104856,6378534.451:104857,6378406.051:104858,6378532.921:104860,6378380.091:104861,6378408.941:104862,6378624.171:104863,6378377.411:104864,6378474.591:104865,6378407.141:104866,6378376.871:104867,6378375.251:104868,6378405.971:104869,6378437.651:104871};class C extends y{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 S(t){return new Ti}class v{constructor(t,e,s){void 0===t?(this.x=new a.I,this.y=new a.I,this.z=new a.I):t instanceof o.v?(this.x=new a.I(t.x),this.y=new a.I(t.y),this.z=new a.I(t.z)):t instanceof a.I?(this.x=t.clone(),this.y=e.clone(),this.z=s.clone()):(0,n.t)("EPoint3D constructor")}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y)).addE(this.z.mulE(t.z))}crossProduct(t){return new v(this.y.mulE(t.z).subE(this.z.mulE(t.y)),this.z.mulE(t.x).subE(this.x.mulE(t.z)),this.x.mulE(t.y).subE(this.y.mulE(t.x)))}crossProductVector(t){const e=this.y.mulE(t.z).subE(t.y.mulE(this.z)),s=t.x.mulE(this.z).subE(this.x.mulE(t.z)),i=this.x.mulE(t.y).subE(t.x.mulE(this.y));return new v(e,s,i)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(t,e){return t.sub(e).length()}negate(){return new v(this.x.negate(),this.y.negate(),this.z.negate())}add(t){return new v(this.x.addE(t.x),this.y.addE(t.y),this.z.addE(t.z))}sub(t){return new v(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 v(this.x.mulE(t),this.y.mulE(t),this.z.mulE(t))}div(t){return new v(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.v.construct(this.x.value(),this.y.value(),this.z.value())}}class b{constructor(t){this.m_origin=new o.v,this.m_normal=new o.v,this.m_axisX=new o.v,this.m_axisY=new o.v,(0,n.g)(0)}assign(t){return(0,n.g)(0),this}set(t,e,s,i){(0,n.g)(0)}setFromPoints(t,e,s){return(0,n.g)(0),!1}getCoord(t,e){return(0,n.g)(0),{}}getCoord2D(t){return(0,n.g)(0),{}}getCoordX(t,e){return(0,n.g)(0),0}getCoordY(t,e){return(0,n.g)(0),0}getCoordZ(t,e){return(0,n.g)(0),0}setPreferredAxisX(t){(0,n.g)(0)}getOrigin(){return(0,n.g)(0),{}}getNormal(){return(0,n.g)(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(t,e=!1){(0,n.g)(0)}setAxisY(t,e=!1){(0,n.g)(0)}recalculateAxisY(){(0,n.g)(0)}setOrigin(t){(0,n.g)(0)}setNormal(t,e){(0,n.g)(0)}intersect(t,e){return(0,n.g)(0),!1}intersectLine(t){return(0,n.g)(0),0}intersectLineEx(t,e){return(0,n.g)(0),0}closestCoordinate(t){return(0,n.g)(0),{}}projectVector(t){return(0,n.g)(0),{}}signedDistance(t){return(0,n.g)(0),0}distance(t){return(0,n.g)(0),0}}function I(t,e){return!1}function w(t,e,s,i,r=100,o=I){let h,m,l,u,c,g,_,d,p;(0,n.g)(i>0);let f,x,P,y=0,E=0;const C=(0,a.as)();e>s&&(s=(0,a.b)(e,e=s));const S=t(e),v=t(s);S<v?(h=m=l=e,u=c=g=S):(h=m=l=s,u=c=g=v);let b=0;for(;b<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));++b){if(Math.abs(E)>f){const t=(h-m)*(u-g);let i=(h-l)*(u-c),n=(h-l)*i-(h-m)*t;i=2*(i-t),i>0&&(n=-n),i=Math.abs(i);const r=E;E=y,Math.abs(n)>=Math.abs(i*r*.5)||n<=i*(e-h)||n>=i*(s-h)?(E=h>=p?e-h:s-h,y=(0,a.as)()*E):(y=n/i,d=h+y,(d-e<x||s-d<x)&&(y=p-h<0?-Math.abs(f):Math.abs(f)))}else E=h>=p?e-h:s-h,y=E*C;d=h+y,_=t(d),_<u?(d>=h?e=h:s=h,l=m,m=h,h=d,g=c,c=u,u=_):(d<h?e=d:s=d,_<=c||m===h?(l=m,m=d,g=c,c=_):(_<=g||l===h||l===m)&&(l=d,g=_))}return(0,a.h)(h,u)}function D(t,e,s){return t>s?t-=Math.ceil((t-s)/a.r)*a.r:t<e&&(t+=Math.ceil((e-t)/a.r)*a.r),t}function T(t,e,s){return function(t,e,s){const i=s.x,n=s.y;return N(t,e,Math.cos(i),Math.sin(i),Math.cos(n),Math.sin(n),0)}(t,e,s)}function N(t,e,s,i,n,r,a){const h=t/Math.sqrt(1-e*r*r),m=h+a,l=m*n*s,u=m*n*i,c=(h*(1-e)+a)*r;return o.v.construct(l,u,c)}function A(t,e,s){const i=new a.I,n=new a.I,r=new a.I,o=new a.I;i.setCos(s.x),n.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.I(t).divE(h),l=m.mulE(r).mulE(i),u=m.mulE(r).mulE(n),c=m.mul(1-e).mulE(o);return new v(l,u,c)}function G(t,e,s){const i=s.x,n=s.y,r=s.z,o=Math.atan2(n,i),h=Math.sqrt(i*i+n*n),m=Math.atan2(r,(1-e)*h);return a.P.construct(o,m)}function M(t,e,s){const i=1-e,n=t/Math.sqrt((0,a.s)(s.x)+(0,a.s)(s.y)+(0,a.s)(s.z)/i);return s.mul(n)}function q(t,e,s,i,n){const r=T(t,e,s),a=T(t,e,i);return G(0,e,o.v.lerp(r,a,n))}function F(t,e,s){const i=new o.v;return i.setCrossProductVector(e,s),Math.abs(Math.atan2(i.length(),e.dotProduct(s)))*t}function V(t,e,s,i,n){const r=s.getUnitVector(),a=i.getUnitVector(),h=e.getUnitVector(),m=new o.v;if(m.setCrossProductVector(r,a),!m.isZero()){m.normalizeThis();const e=h.sub(m.mul(m.dotProduct(h)));if(!e.isZero()){e.normalizeThis();const s=r.add(a).mul(.5);if(s.dotProduct(e)>s.dotProduct(r)){const s=Math.abs(m.dotProduct(h)),i=Math.asin(s);return n.assign(e.getUnitVector().mul(t)),i*t}}}const l=F(1,r,h),u=F(1,a,h);return l<=u?(n.assign(s),l*t):(n.assign(i),u*t)}function Y(t,e,s,i,r,m=0,l){if(2===m||3===m)return function(t,e,s,i,n,r=!1,h){const m=M(t,e,s);if(r){const r=new b({pt0:new o.v(0,0,0),pt1:i,pt2:n}),l=r.closestCoordinate(s),u=r.closestCoordinate(i),c=r.closestCoordinate(n),g=a.P.getClosestCoordinate(u,c,l),_=M(t,e,o.v.lerp(i,n,g)),d=o.v.distance(_,m);return h&&h.assign(_),(0,a.h)(g,d)}const l=s=>{const r=M(t,e,o.v.lerp(i,n,s));return o.v.distance(r,m)},u=o.v.distance(i,n);if(u>0){const s=U(t,u),{first:r,second:m}=w(l,0,1,s);return h&&h.assign(M(t,e,o.v.lerp(i,n,r))),(0,a.h)(r,m)}{const t=o.v.distance(s,i);return h&&h.assign(s),(0,a.h)(.5,t)}}(t,e,s,i,r,3===m,l);const u=G(0,e,s),c=s=>{const a=G(0,e,o.v.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,i){const n={stack:[],error:void 0,hasError:!1};try{const r=(0,h.b)(n,new En,!1);return Tn.geodeticDistance(t,e,s.x,s.y,i.x,i.y,r,null,null,Sn.PE_LINETYPE_GEODESIC),r.val}catch(t){n.error=t,n.hasError=!0}finally{(0,h.c)(n)}}(t,e,s,i);case 1:return function(t,e,s){const i={stack:[],error:void 0,hasError:!1};try{const n=(0,h.b)(i,new En,!1);return Tn.greatEllipticDistance(t,e,s.x,s.y,s.x,s.y,n,null,null),n.val}catch(t){i.error=t,i.hasError=!0}finally{(0,h.c)(i)}}(t,e,s);case 2:case 3:{const n=T(t,e,s),r=T(t,e,i);return o.v.distance(n,r)}default:(0,n.b)("")}}(t,e,u,a,m)},g=o.v.distance(i,r);if(g>0){const s=U(t,g),{first:n,second:h}=w(c,0,1,s);return l&&l.assign(M(t,e,o.v.lerp(i,r,n))),(0,a.h)(n,h)}{const t=c(0);return l&&l.assign(i),(0,a.h)(.5,t)}}function X(t,e,s,i,n,o){if(o[0]=Number.NaN,o[1]=Number.NaN,Math.abs(s.x-i.x)>Math.PI)return 0;if(Math.abs(s.y)>a.t||Math.abs(i.y)>a.t)return 0;if((Math.abs(s.y)===a.t||Math.abs(i.y)===a.t)&&s.x!==i.x)return 0;if(Math.abs(n)>=a.t)return 0;if(s.y>0&&i.y>0&&s.y>n&&i.y>n||s.y<0&&i.y<0&&s.y<n&&i.y<n)return 0;const h=r.T.constructPoint2D(s),m=r.T.constructPoint2D(i),l=A(1,e,h),u=A(1,e,m),c=l.crossProductVector(u);if(c.z.isZero())return a.E.construct(s.y,i.y).containsCoordinate(n)?(o[0]=s.x,1):0;const g=c.x.divE(c.z.negate()),_=c.y.divE(c.z.negate()),d=g.mulE(g).addE(_.mulE(_)).sqrt();if(d.isZero()||g.isZero()&&_.isZero())return 0===n?(o[0]=s.x,o[1]=i.x,2):0;const p=(1-e)*Math.tan(n)/d.value();if(Math.abs(p)>1)return 0;const f=Math.acos(p),x=Math.atan2(_.value(),g.value()),P=x-f;let y=x+f;const E=Math.min(s.x,i.x),C=Math.max(s.x,i.x);D(P,E,C),0!==n?D(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 R(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 k(t,e,s,i,n){i=(0,a.c)(i,-a.t,a.t),n=(0,a.c)(n,-a.t,a.t);const r=a.t-.03;let o;return o=i>r&&n>r||i<-r&&n<-r?function(t,e,s){let i=1;if(e<0&&(i=-1,e=-e,s=-s),0!==t){const n=t*t,r=n*t,o=[1,(1+11*t)/12,(1+118*t+241*n)/360,(1+1089*t+10419*n+8651*r)/20160,(1+9836*t+318246*n+1027436*r+r*t*458881)/1814400],h=e=>{let s=0;const i=(0,a.s)(e)/(t-1);for(let t=o.length-1;t>=0;--t)s=o[t]+s*i;return s*=-(0,a.s)(e/(1-t)),s},m=h(a.t-e);return(h(a.t-s)-m)*i}{const t=a.t-e,n=a.t-s,r=-4*(0,a.s)(Math.sin(t/2));return(-4*(0,a.s)(Math.sin(n/2))-r)*i}}(t,i,n):L(t,n)-L(t,i),.5*(s-e)*o*function(t){return 1-t}(t)}function L(t,e){if(0===e)return 0;const s=Math.sin(e);let i=s,n=s;if(0!==t){i/=1-t*s*s;const e=Math.sqrt(t);n=s*(0,a.A)(e*s)}return i+n}function B(t,e){return t/Math.sqrt(1-e)}function H(t,e){return(1-e)*t}function z(t,e,s){const i=s/(2*H(t,e)),n=i*i;return s*(1-n*(.16666666666666666-.008333333333333333*n))}function U(t,e){if(0!==e){const s=t*(0,a.aF)()/e;return Math.min(s,1e-10)}return 0}function O(t,e,s,h,m,l=!0){switch(W(h)){case 0:break;case 1:(0,n.t)("relation string length has to be 9 characters");break;default:(0,n.t)("relation string")}if(l){const i=function(t,e,s){return function(t){return"T*F**FFF*"===t}(t)?3:function(t){return"FF*FF****"===t}(t)?4:function(t,e,s){return!(0===e&&0===s||(2===e&&2===s?"F***T****"!==t:2!==e&&1!==e||0!==s||"F**T*****"!==t))}(t,e,s)?8:function(t,e,s){return e>s?"T*****T**"===t:1===e&&1===s&&"0********"===t}(t,e,s)?16:function(t){return"T**FF*FF*"===t}(t)?64:function(t){return"T*****FF*"===t}(t)?1:function(t,e,s){return e===s&&(1!==e?"T*T***T**"===t:"1*T***T**"===t)}(t,e,s)?32:0}(h,t.getDimension(),e.getDimension());if(0!==i)return mt(t,e,s,i,m)}let u=0;if("number"==typeof s)u=s;else{const n=i.J.constructEmpty();t.queryEnvelope(n);const r=i.J.constructEmpty();e.queryEnvelope(r);const a=i.J.constructEmpty();a.setCoords({env2D:n}),a.mergeEnvelope2D(r),u=(0,o.c)(s,a,!1)}const c=nt(t,u),g=nt(e,u);if(c.isEmpty()||g.isEmpty())return function(t,e,s){const o=(0,a.f)(9,-1);if(t.isEmpty()&&e.isEmpty())return tt(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.J.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.a5)(h)?0:-1}else o[2]=0,o[5]=-1;return m&&it(o),tt(o,s)}(c,g,h);const _=c.getGeometryType(),d=g.getGeometryType();let p=!1;switch(_){case n.G.enumPolygon:switch(d){case n.G.enumPolygon:p=function(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setAreaAreaPredicates_();const m=i.J.constructEmpty(),l=i.J.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.areaAreaDisjointPredicates_(t,e),u=!0),u||ct(t,e),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.computeMatrixTopoGraphHalfEdges_(n,m),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPolyline:p=j(c,g,u,h,m);break;case n.G.enumPoint:p=Q(c,g,u,h);break;case n.G.enumMultiPoint:p=J(c,g,u,h,m)}break;case n.G.enumPolyline:switch(d){case n.G.enumPolygon:p=j(g,c,u,rt(h),m);break;case n.G.enumPolyline:p=function(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setLineLinePredicates_();const m=i.J.constructEmpty(),l=i.J.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.lineLineDisjointPredicates_(t,e),u=!0),u||ct(t,e),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),et(n,h.m_topoGraph,h.m_clusterIndexA),et(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(n,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPoint:p=K(c,g,u,h,m);break;case n.G.enumMultiPoint:p=Z(c,g,u,h,m)}break;case n.G.enumPoint:switch(d){case n.G.enumPolygon:p=Q(g,c,u,rt(h));break;case n.G.enumPolyline:p=K(g,c,u,rt(h),m);break;case n.G.enumPoint:p=function(t,e,s,i){const n=t.getXY(),r=e.getXY(),o=(0,a.f)(9,-1);return a.P.sqrDistance(n,r)<=s*s?o[0]=0:(o[2]=0,o[6]=0),o[8]=2,tt(o,i)}(c,g,u,h);break;case n.G.enumMultiPoint:p=$(g,c,u,rt(h))}break;case n.G.enumMultiPoint:switch(d){case n.G.enumPolygon:p=J(g,c,u,rt(h),m);break;case n.G.enumPolyline:p=Z(g,c,u,rt(h),m);break;case n.G.enumMultiPoint:p=function(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setPointPointPredicates_();const m=new i.J,l=new i.J;t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.pointPointDisjointPredicates_(),u=!0),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.computeMatrixTopoGraphClusters_(n,m),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}(c,g,u,h,m);break;case n.G.enumPoint:p=$(c,g,u,h)}break;default:p=!1}return p}function W(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 j(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setAreaLinePredicates_();const m=i.J.constructEmpty(),l=i.J.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.areaLineDisjointPredicates_(t,e),u=!0),u||ct(t,e),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.m_clusterIndexB=h.m_topoGraph.createUserIndexForClusters(),et(m,h.m_topoGraph,h.m_clusterIndexB),h.computeMatrixTopoGraphHalfEdges_(n,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexB),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}function J(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setAreaPointPredicates_();const m=i.J.constructEmpty(),l=i.J.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.areaPointDisjointPredicates_(t),u=!0),u||ct(t,e),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.computeMatrixTopoGraphClusters_(n,m),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}function Z(t,e,s,n,a){const h=new st;h.resetMatrix_(),h.setPredicates_(n),h.setLinePointPredicates_();const m=i.J.constructEmpty(),l=i.J.constructEmpty();t.queryEnvelope(m),e.queryEnvelope(l);let u=!1;if(ut(m,l,s)&&(h.linePointDisjointPredicates_(t),u=!0),u||ct(t,e),!u){const i=new r.E,n=i.addGeometry(t),m=i.addGeometry(e);h.setEditShapeCrackAndCluster_(i,new o.C(s,0),a),h.m_clusterIndexA=h.m_topoGraph.createUserIndexForClusters(),et(n,h.m_topoGraph,h.m_clusterIndexA),h.computeMatrixTopoGraphClusters_(n,m),h.m_topoGraph.deleteUserIndexForClusters(h.m_clusterIndexA),h.m_topoGraph.removeShape()}return tt(h.m_matrix,h.m_scl)}function Q(t,e,s,n,r){const o=new st;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=i.J.constructEmpty();t.queryEnvelope(a);const h=e.getXY();let m=!1;if(gt(h,a,s)&&(o.areaPointDisjointPredicates_(t),m=!0),!m){const e=(0,p.i)(t,h,s);if(1===e)o.m_matrix[0]=0,o.m_matrix[2]=2,o.m_matrix[3]=-1,o.m_matrix[5]=1,o.m_matrix[6]=-1;else if(2===e)if(o.m_matrix[6]=-1,0!==t.calculateArea2D())o.m_matrix[0]=-1,o.m_matrix[3]=0,o.m_matrix[2]=2,o.m_matrix[5]=1;else{o.m_matrix[0]=0,o.m_matrix[3]=-1,o.m_matrix[5]=-1;const e=i.J.constructEmpty();t.queryEnvelope(e),o.m_matrix[2]=e.height()||e.width()?1:-1}else o.areaPointDisjointPredicates_(t)}return tt(o.m_matrix,n)}function K(t,e,s,n,o){const a=new st;a.resetMatrix_(),a.setPredicates_(n),a.setLinePointPredicates_();const h=i.J.constructEmpty();t.queryEnvelope(h);let m=!1;if(gt(e.getXY(),h,s)&&(a.linePointDisjointPredicates_(t),m=!0),!m){let i=null,n=!1,h=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&(mt(t,e,s,4,o)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(i=(0,r.b)(t),h=!mt(i,e,s,4,o),n=!0,a.m_matrix[0]=h?-1:0),a.m_matrix[6]=-1)),a.m_performPredicates[3]&&(null!==i&&i.isEmpty()?a.m_matrix[3]=-1:(n||(null==i&&(i=(0,r.b)(t)),h=!mt(i,e,s,4,o),n=!0),a.m_matrix[3]=h?0:-1)),a.m_performPredicates[5])if(null!==i&&i.isEmpty())a.m_matrix[5]=-1;else if(n&&!h)a.m_matrix[5]=0;else{null===i&&(i=(0,r.b)(t));const n=mt(i,e,s,3,o);a.m_matrix[5]=n?-1:0}if(a.m_performPredicates[2])if(0!==t.calculateLength2D())a.m_matrix[2]=1;else{const i=new r.M({vd:t.getDescription()});i.addPoints(t,0,t.getPointCount());const n=mt(i,e,s,3,o);a.m_matrix[2]=n?-1:0}}return tt(a.m_matrix,a.m_scl)}function $(t,e,s,n,r){const o=new st;o.resetMatrix_(),o.setPredicates_(n),o.setPointPointPredicates_();const h=i.J.constructEmpty();t.queryEnvelope(h);const m=e.getXY(),l=new a.P;let u=!1;if(gt(m,h,s)&&(o.pointPointDisjointPredicates_(),u=!0),!u){let e=!1,i=!0;const n=s*s;for(let s=0;s<t.getPointCount()&&(t.queryXY(s,l),a.P.sqrDistance(l,m)<=n?e=!0:i=!1,!e||i);s++);e?(o.m_matrix[0]=0,o.m_matrix[2]=i?-1:0,o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[2]=0,o.m_matrix[6]=0)}return tt(o.m_matrix,n)}function tt(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 et(t,e,s){const i=e.getGeometryID(t);for(let t=e.getFirstCluster();t!==r.n;t=e.getNextCluster(t)){if(!(e.getClusterParentage(t)&i))continue;const n=e.getClusterHalfEdge(t);if(n===r.n){e.setClusterUserIndex(t,s,0);continue}let o=n,a=0;do{const t=o;e.getHalfEdgeParentage(t)&i&&a++,o=e.getHalfEdgeNext(e.getHalfEdgeTwin(t))}while(o!==n);e.setClusterUserIndex(t,s,a)}}class st{nullFunc(){return(0,n.c)("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new c.q,this.m_matrix=(0,a.f)(9,0),this.m_maxDim=(0,a.f)(9,0),this.m_performPredicates=(0,a.f)(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.J.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),it(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.a5)(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.a5)(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.a5)(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.a5)(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.a5)(t);this.m_matrix[5]=e?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(t,e,1);const s=this.isPredicateKnown_(1);i&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(t,s,3);const e=this.isPredicateKnown_(3);i&&=e}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(t,e,s);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(t,e,s,5);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(t,s,e,7);const n=this.isPredicateKnown_(7);i&&=n}return i}areaLinePredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(1);i&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(t,e,s);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(t,e,s);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(t,e);const s=this.isPredicateKnown_(6);i&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(7);i&&=n}return i}lineLinePredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const n=this.isPredicateKnown_(1);i&&=n}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(t,s,e,this.m_clusterIndexB,this.m_clusterIndexA,3);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(t,e,s,this.m_clusterIndexA,5);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(t,s,e,this.m_clusterIndexB,7);const n=this.isPredicateKnown_(7);i&&=n}return i}areaPointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(0);i&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(2);i&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(5);i&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(6);i&&=s}return i}linePointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(6);i&&=n}return i}pointPointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}return i}interiorAreaInteriorArea_(t,e,s){if(2===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t);i&e&&i&s&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[s])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));i&e&&n&e&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(t,e,s,i){if(2===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t);n&e&&!(n&s)&&(this.m_matrix[i]=2)}boundaryAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[4])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);if(i&e&&i&s)this.m_matrix[4]=1;else if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),n=this.m_topoGraph.getClusterParentage(i);if(n&e&&n&s)return void(this.m_matrix[4]=0)}}boundaryAreaExteriorArea_(t,e,s,i){if(1===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));n&s||r&s||(this.m_matrix[i]=1)}interiorAreaInteriorLine_(t,e,s){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));i&e&&n&e&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(!(r&e)&&this.m_topoGraph.getHalfEdgeFaceParentage(t)&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[1]=0)}}}interiorAreaExteriorLine_(t,e,s){2!==this.m_matrix[2]&&this.m_topoGraph.getHalfEdgeParentage(t)&e&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(t,e,s,i){if(1===this.m_matrix[3])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);if(n&e&&n&s)this.m_matrix[3]=1;else if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(r&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2==0)return void(this.m_matrix[3]=0)}}}boundaryAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(r&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(t,e,s){if(1===this.m_matrix[5])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);i&e&&!(i&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(t,e){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(t),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));s&e||i&e||(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(!(r&e||this.m_topoGraph.getHalfEdgeFaceParentage(t)&e)){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[7]=0)}}}interiorLineInteriorLine_(t,e,s,i,n){if(1===this.m_matrix[0])return;const r=this.m_topoGraph.getHalfEdgeParentage(t);if(r&e&&r&s)this.m_matrix[0]=1;else if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(o&e&&o&s){const t=this.m_topoGraph.getClusterUserIndex(r,i),e=this.m_topoGraph.getClusterUserIndex(r,n);if(t%2==0&&e%2==0)return void(this.m_matrix[0]=0)}}}interiorLineBoundaryLine_(t,e,s,i,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(t),a=this.m_topoGraph.getClusterParentage(o);if(a&e&&a&s){const t=this.m_topoGraph.getClusterUserIndex(o,i),e=this.m_topoGraph.getClusterUserIndex(o,n);if(t%2==0&&e%2!=0)return void(this.m_matrix[r]=0)}}}interiorLineExteriorLine_(t,e,s,i){if(1===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);n&e&&!(n&s)&&(this.m_matrix[i]=1)}boundaryLineBoundaryLine_(t,e,s,i,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(o&e&&o&s){const t=this.m_topoGraph.getClusterUserIndex(r,i),e=this.m_topoGraph.getClusterUserIndex(r,n);if(t%2!=0&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(t,e,s,i,n){if(0!==this.m_matrix[n]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const e=this.m_topoGraph.getHalfEdgeTo(t);if(!(this.m_topoGraph.getClusterParentage(e)&s)&&this.m_topoGraph.getClusterUserIndex(e,i)%2!=0)return void(this.m_matrix[n]=0)}}interiorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[0]&&!(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(this.m_topoGraph.getChainParentage(s)&e)return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(t,e){2!==this.m_matrix[2]&&this.m_topoGraph.getClusterParentage(t)&e&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(t,e,s){if(0===this.m_matrix[3])return;const i=this.m_topoGraph.getClusterParentage(t);i&e&&i&s&&(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(t,e){1!==this.m_matrix[5]&&this.m_topoGraph.getClusterParentage(t)&e&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[6]&&!(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(!(this.m_topoGraph.getChainParentage(s)&e))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(t,e,s,i){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(t);n&e&&n&s&&this.m_topoGraph.getClusterUserIndex(t,i)%2==0&&(this.m_matrix[0]=0)}interiorLineExteriorPoint_(t,e,s,i){if(1!==this.m_matrix[2])if(-1===this.m_topoGraph.getClusterHalfEdge(t)){if(0!==this.m_matrix[2]&&!(this.m_topoGraph.getClusterParentage(t)&s))return void(this.m_matrix[2]=0)}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(t,e,s,i){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(t);n&e&&n&s&&this.m_topoGraph.getClusterUserIndex(t,i)%2!=0&&(this.m_matrix[3]=0)}boundaryLineExteriorPoint_(t,e,s,i){if(0===this.m_matrix[5])return;const n=this.m_topoGraph.getClusterParentage(t);!(n&e)||n&s||this.m_topoGraph.getClusterUserIndex(t,i)%2==0||(this.m_matrix[5]=0)}exteriorLineInteriorPoint_(t,e,s){if(0===this.m_matrix[6])return;const i=this.m_topoGraph.getClusterParentage(t);i&e||!(i&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(t,e,s){if(0===this.m_matrix[0])return;const i=this.m_topoGraph.getClusterParentage(t);i&e&&i&s&&(this.m_matrix[0]=0)}interiorPointExteriorPoint_(t,e,s,i){if(0===this.m_matrix[i])return;const n=this.m_topoGraph.getClusterParentage(t);!(n&e)||n&s||(this.m_matrix[i]=0)}computeMatrixTopoGraphHalfEdges_(t,e){let s=!1;const i=this.m_topoGraph.getGeometryID(t),n=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,i,n),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,i,n),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 i=this.m_topoGraph.getGeometryID(t),n=this.m_topoGraph.getGeometryID(e);for(let t=this.m_topoGraph.getFirstCluster();t!==r.n&&(s=this.m_predicatesCluster(t,i,n),!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 p.C,r=t.getEnvelope2D(s),o=(0,p.d)(e.total(),r);i=(0,p.f)(o,0),(0,p.b)(t,o,e.total(),12e3,n,null,s),n.clearStitcher(t)}(0,p.e)(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&&(0,c.n)(t,e,-1,!1,r.n,s);this.setEditShape_(t,s)}}function it(t){const e=t[1],s=t[2],i=t[5];t[1]=t[3],t[2]=t[6],t[5]=t[7],t[3]=e,t[6]=s,t[7]=i}function nt(t,e,s){const a=t.getGeometryType();if((0,n.f)(a)){const e=new r.a({vd:t.getDescription()});return e.addSegment(t,!0),e}if(a===n.G.enumEnvelope){const s=t,n=i.J.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.a({vd:t.getDescription()}),i=new o.P;return s.queryCornerByVal(0,i),e.startPathPoint(i),s.queryCornerByVal(2,i),e.lineToPoint(i),e}const a=new r.P({vd:t.getDescription()});return a.addEnvelope(s,!1),a}return t}function rt(t){return`${t[0]}${t[3]}${t[6]}${t[1]}${t[4]}${t[7]}${t[2]}${t[5]}${t[8]}`}class ot{nullFunc(){return(0,n.c)("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.J.constructEmpty(),this.m_envInter=i.J.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.J.constructEmpty(),u=i.J.constructEmpty(),c=i.J.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.w)(t,c):(0,o.a2)(t,c):l=(0,n.h)(e.getGeometryType())?(0,o.w)(e,c):(0,o.a2)(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.r)(""),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.r)(""),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.J.constructEmpty(),l=i.J.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.a6)(t,s,a):(0,n.h)(u)&&(0,n.h)(c)?(this.m_intersector=(0,o.a3)(t,s,a),this.m_bSwapElements=!1):(0,n.h)(u)&&!(0,n.h)(c)?(this.m_intersector=(0,o.a4)(t,s,a),this.m_bSwapElements=!1):!(0,n.h)(u)&&(0,n.h)(c)?(this.m_intersector=(0,o.a4)(s,t,a),this.m_bSwapElements=!0):(this.m_intersector=(0,o.a5)(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.J;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.J.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 at(t){return 2===t?1:1===t?2:128===t?64:64===t?128:t}function ht(t,e,s){let n;if(t instanceof an||null===t){const r=i.J.constructEmpty();r.setCoords({env2D:e}),r.mergeEnvelope2D(s),n=(0,o.c)(t,r,!1)}else n=t;return n}function mt(t,e,s,h,m){if(t.isEmpty()||e.isEmpty())return 4===h;(0,n.d)(t),(0,n.d)(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.J.constructEmpty();t.queryEnvelope(r);const o=i.J.constructEmpty();e.queryEnvelope(o);const a=ht(s,r,o);switch(n){case 4:return ut(r,o,a);case 2:return kt(o,r,a,!1);case 128:return kt(o,r,a,!0);case 1:return kt(r,o,a,!1);case 64:return kt(r,o,a,!0);case 3:return Rt(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.J;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(Ht(t,e,s))return!1;if(Ht(e,t,s))return!1;const n=new i.J;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 lt(e,t,s,at(h))}else if(u===n.G.enumPoint){if(c===n.G.enumEnvelope)return lt(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 an||null===s){const t=i.J.constructEmpty();t.setCoords({pt:r}),t.merge(h),m=(0,o.c)(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 Xt(h,r,m);case 1:case 64:return Xt(r,h,m);case 3:return Yt(r,h,m)}return!1}(t,e,s,h)}const g=i.J.constructEmpty();t.queryEnvelope(g);const _=i.J.constructEmpty();e.queryEnvelope(_);const d=ht(s,g,_);if(ut(g,_,d))return 4===h;let p=!1,f=null,x=null,P=null,y=null;switch((0,n.f)(u)?(f=new r.a({vd:t.getDescription()}),f.addSegment(t,!0),P=f,u=n.G.enumPolyline):P=t,(0,n.f)(c)?(x=new r.a({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=at(h)):u!==n.G.enumPolygon&&c!==n.G.enumEnvelope&&(h=at(h)),u){case n.G.enumPolygon:switch(c){case n.G.enumPolygon:p=function(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return ct(t,e,0,!0),1===Lt(t,e,s,!0)}(t,e,s);case 2:return vt(e,t,s,n);case 128:return bt(e,t,s);case 1:return vt(t,e,s,n);case 64:return bt(t,e,s);case 3:return St(t,e,s,n);case 8:return function(t,e,s){return ct(t,e),ee(t,e,s,null)}(t,e,s);case 32:return function(t,e,s,i){return ct(t,e),se(t,e,s,i)}(t,e,s,n)}return!1}(P,y,d,h,m);break;case n.G.enumPolyline:p=_t(P,y,d,h,m);break;case n.G.enumPoint:p=dt(P,y,d,h);break;case n.G.enumMultiPoint:p=pt(P,y,d,h);break;case n.G.enumEnvelope:p=ft(P,y,d,h,m)}break;case n.G.enumPolyline:switch(c){case n.G.enumPolygon:p=_t(y,P,d,h,m);break;case n.G.enumPolyline:p=function(t,e,s,n,o){switch(n){case 4:return function(t,e,s){ct(t,e);const i=t.getImpl(),n=e.getImpl();return!new ot(i,n,s,!0).next()||!Zt(t,e,s)}(t,e,s);case 2:return Nt(e,t,s,o);case 128:return At(e,t,s,o);case 1:return Nt(t,e,s,o);case 64:return At(t,e,s,o);case 3:return function(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Rt(r,o,s)&&(ct(t,e),!!Ot(t,e,s)||(t.hasNonLinearSegments()||e.hasNonLinearSegments()?O(t,e,s,"**F**FFF*",n,!1):jt(t,e,s,!1)))}(t,e,s,o);case 8:return function(t,e,s,n){ct(t,e);const o=[],a=Qt(t,e,s,o);if(-2===a){const r=i.J.constructEmpty(),o=i.J.constructEmpty(),a=i.J.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 O(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()&&Mt(m,h,s)}(t,e,s,o);case 32:return function(t,e,s,n){ct(t,e);const r=i.J.constructEmpty(),o=i.J.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o);const a=Ut(r,o,s),h=Ut(o,r,s),m=t.hasNonLinearSegments(),u=e.hasNonLinearSegments(),c=Qt(t,e,s,null);if(-1===c)return!1;if(1===c){if(a&&h)return!0;if(!m&&!u)return a&&!h?!Jt(e,t,s,!1):h&&!a?!Jt(t,e,s,!1):!Jt(t,e,s,!1)&&!Jt(e,t,s,!1)}const g=i.J.constructEmpty(),_=i.J.constructEmpty(),d=i.J.constructEmpty();let p,f;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:o}),_.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:g}),d.intersect(_);let x="";if(x+="1*",a){if(e.getPointCount()>10){if(f=(0,l.c)(e,d,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,d,s,0,n),p.isEmpty())return!1}else p=t;x+="***"}else p=t,x+="T**";return O(p,f,s,x,n,!1)}(t,e,s,o);case 16:return function(t,e,s,n){ct(t,e);const o=[],a=Qt(t,e,s,o);if(-2===a){const r=i.J.constructEmpty(),o=i.J.constructEmpty(),a=i.J.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 O(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()||!Mt(m,h,s)}(t,e,s,o)}return!1}(P,y,d,h,m);break;case n.G.enumPoint:p=xt(P,y,d,h);break;case n.G.enumMultiPoint:p=Pt(P,y,d,h);break;case n.G.enumEnvelope:p=yt(P,y,d,h,m)}break;case n.G.enumPoint:switch(c){case n.G.enumPolygon:p=dt(y,P,d,h);break;case n.G.enumPolyline:p=xt(y,P,d,h);break;case n.G.enumMultiPoint:p=Et(y,P,d,h)}break;case n.G.enumMultiPoint:switch(c){case n.G.enumPolygon:p=pt(y,P,d,h);break;case n.G.enumPolyline:p=Pt(y,P,d,h);break;case n.G.enumMultiPoint:p=function(t,e,s,n){switch(n){case 4:return function(t,e,s){const i=t,n=e,r=new ot(i,n,s,!1),o=s*s,h=new a.P,m=new a.P;for(;r.next();){const t=r.getRedElement(),e=r.getBlueElement();if(i.queryXY(t,h),n.queryXY(e,m),a.P.sqrDistance(h,m)<=o)return!1}return!0}(t,e,s);case 2:case 128:return Mt(e,t,s);case 1:case 64:return Mt(t,e,s);case 3:return function(t,e,s){const n=i.J.constructEmpty(),r=i.J.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!!Rt(n,r,s)&&(!!function(t,e,s){if(t.getPointCount()!==e.getPointCount())return!1;const i=new a.P,n=new a.P;let r=!0;const o=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,i),e.queryXY(s,n),a.P.sqrDistance(i,n)>o){r=!1;break}return!!r}(t,e,s)||Wt(t,e,s,!1,!0,!1))}(t,e,s);case 32:return function(t,e,s){return Wt(t,e,s,!1,!1,!0)}(t,e,s)}return!1}(P,y,d,h);break;case n.G.enumPoint:p=Et(P,y,d,h);break;case n.G.enumEnvelope:p=Ct(P,y,d,h)}break;case n.G.enumEnvelope:switch(c){case n.G.enumPolygon:p=ft(y,P,d,h,m);break;case n.G.enumPolyline:p=yt(y,P,d,h,m);break;case n.G.enumMultiPoint:p=Ct(y,P,d,h)}}return p}function lt(t,e,s,n,r){if(t.isEmpty()||e.isEmpty())return 4===n;const a=t.getXY(),h=i.J.constructEmpty();e.queryEnvelope(h);const m=function(t,e,s){let n;if(t instanceof an||null===t){const r=i.J.constructEmpty();r.setCoords({pt:e}),r.mergeEnvelope2D(s),n=(0,o.c)(t,r,!1)}else n=t;return n}(s,a,h);switch(n){case 4:return gt(a,h,m);case 2:case 128:return function(t,e,s){if(e.height()<=s||e.width()<=s)return!1;const n=i.J.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.J;return n.setCoords({pt:t}),Rt(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.J,r=new i.J;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 ut(t,e,s){const n=i.J.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),!t.isIntersecting(n)}function ct(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 gt(t,e,s,n){const r=i.J.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(s,s),!r.contains(t)}function _t(t,e,s,n,h){switch(n){case 4:return function(t,e,s){return ct(t,e,0,!0),1===Lt(t,e,s,!0)}(t,e,s);case 1:return function(t,e,s,n){const a=i.J.constructEmpty(),h=i.J.constructEmpty();return t.queryEnvelope(a),e.queryEnvelope(h),!!Ht(a,h,s)&&(ct(t,e),function(t,e,s,n){const a=[!1],h=Bt(t,e,s,a);if(a[0])return h;const m=i.J.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 st;a.resetMatrix_(),a.setPredicates_("T*****F**"),a.setAreaLinePredicates_();const h=i.J.constructEmpty(),m=i.J.constructEmpty();t.queryEnvelope(h),e.queryEnvelope(m);let l=!1;if(ut(h,m,s)&&(a.areaLineDisjointPredicates_(t,e),l=!0),l||ct(t,e),l)return tt(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(),tt(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.J.constructEmpty(),r=i.J.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!!Ht(n,r,s)&&(ct(t,e),2===Lt(t,e,s,!1))}(t,e,s);case 8:return It(t,e,s,h);case 16:return function(t,e,s){return ct(t,e),function(t,e,s,n){const r=t.getImpl(),o=e.getImpl(),h=r.querySegmentIterator(),m=o.querySegmentIterator(),u=(0,a.f)(2,Number.NaN),c=(0,a.f)(2,Number.NaN),g=new ot(r,o,s);let _=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();h.resetToVertex(t,-1),m.resetToVertex(e,-1);const i=h.nextSegment(),n=m.nextSegment();let r=0;if(oe(i,n)?!_&&n.isIntersecting(i,s)&&(_=!0):r=n.intersect(i,null,c,u,s),2===r)_=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!0;_=!0}}if(!_)return!1;const d=i.J.constructEmpty(),p=i.J.constructEmpty(),f=i.J.constructEmpty(),x=i.J.constructEmpty(),P=i.J.constructEmpty();if(t.queryEnvelope(d),e.queryEnvelope(p),Ut(p,d,s)){let i,r;if(f.setCoords({env2D:d}),f.inflateCoords(1e3*s,1e3*s),x.setCoords({env2D:p}),x.inflateCoords(1e3*s,1e3*s),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 O(i,r,s,"T********",n,!1)}return O(t,e,s,"T*****T**",n,!1)}(t,e,s,null)}(t,e,s)}return!1}function dt(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return 0===(0,p.m)(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return function(t,e,s){return 1===(0,p.i)(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return function(t,e,s){return 2===(0,p.i)(t,e,s)}(t,e.getXY(),s)}(t,e,s)}return!1}function pt(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return ct(t,e),1===function(t,e,s){const n=i.J.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new a.P,h=t.getImpl(),m=new r.P;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=(0,p.i)(l,o,s);if(1===t)return c=!0,4;if(2===t)return 4;g=!0}else g=!0;u||(!(0,p.r)(t,e.getPointCount()-1)||null!==h.getAccelerators()&&null!=h.getAccelerators().getQuadTree()?l=t:(t.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),u=!0)}return c?g?4:2:1}(t,e,s)}(t,e,s);case 1:return wt(t,e,s,!1);case 64:return wt(t,e,s,!0);case 8:return function(t,e,s){ct(t,e);const n=i.J.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new a.P;let h=!1;const m=t.getImpl(),l=new r.P;let u=t,c=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,o),n.contains(o)){const t=(0,p.i)(u,o,s);if(2===t)h=!0;else if(1===t)return!1}c||(!(0,p.r)(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){ct(t,e);const n=new i.J,o=new i.J,h=new i.J;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.P;let _=t,d=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,u),o.contains(u)){const t=(0,p.i)(_,u,s);0===t?l=!0:1===t&&(m=!0)}else l=!0;if(m&&l)return!0;d||(!(0,p.r)(t,e.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=t:(t.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),_=g),d=!0)}return!1}(t,e,s)}return!1}function ft(t,e,s,n,o){if(function(t,e,s){ct(t,e);const n=i.J.constructEmpty(),r=i.J.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),Ht(r,n,s))return!1;const o=r.getLowerLeft();return 0===(0,p.i)(t,o,0)&&!r.contains(t.getXY(0))&&!te(t,r,s)}(t,e,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Dt(t,e,s,!1);case 128:return Dt(t,e,s,!0);case 1:return Tt(t,e,s,!1,o);case 64:return Tt(t,e,s,!0,o);case 3:return function(t,e,s,n){const o=new i.J,a=new i.J;if(t.queryEnvelope(o),e.queryEnvelope(a),!Rt(o,a,s))return!1;const h=new r.P;return h.addEnvelope(e,!1),St(t,h,s,n)}(t,e,s,o);case 8:return function(t,e,s,n){ct(t,e);const o=new i.J,a=new i.J;if(t.queryEnvelope(o),e.queryEnvelope(a),Ht(a,o,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new r.P;return h.addEnvelope(e,!1),ee(t,h,s,n)}(t,e,s,o);case 32:return function(t,e,s,n){ct(t,e);const o=new i.J,a=new i.J;if(t.queryEnvelope(o),e.queryEnvelope(a),Ht(a,o,s))return!1;if(a.height()<=s||a.width()<=s)return!1;const h=new r.P;return h.addEnvelope(e,!1),se(t,h,s,n)}(t,e,s,o);case 16:return!1}return!1}function xt(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return ct(t,e),!$t(t,e.getXY(),s)}(t,e,s);case 1:case 64:return function(t,e,s){return ct(t,e),function(t,e,s){return $t(t,e,s)&&!re(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return ct(t,e),re(t,e.getXY(),s)}(t,e,s)}return!1}function Pt(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return ct(t,e),!Kt(t,e,s,!1)}(t,e,s);case 1:case 64:return function(t,e,s){const n=i.J.constructEmpty(),r=i.J.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),!Ht(n,r,s))return!1;ct(t,e);const o=Kt(t,e,s,!0);if(!o)return o;const a=t.getBoundary();return a.isEmpty()?o:!Mt(a,e,s)}(t,e,s);case 8:return function(t,e,s){ct(t,e);const i=t.getImpl(),n=e.getImpl(),o=new r.M,a=new ot(i,n,s,!1),h=i.querySegmentIterator();let m=!1;for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();h.resetToVertex(t,-1);const i=h.nextSegment(),r=n.getXY(e);i.isIntersectingPoint(r,s)&&(m=!0,o.addPoint2D(r))}if(!m)return!1;const l=t.getBoundary();return!l.isEmpty()&&Mt(l,o,s)}(t,e,s);case 16:return function(t,e,s){ct(t,e);const i=t.getImpl(),n=e.getImpl(),o=n.getPointCount(),h=(0,a.f)(o,!1),m=new ot(i,n,s,!1),l=i.querySegmentIterator();let u=!1;for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const i=l.nextSegment(),r=n.getXY(e);i.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 _=new r.M;for(let t=0;t<o;t++)h[t]&&_.addPoint2D(n.getXY(t));return!Mt(g,_,s)}(t,e,s)}return!1}function yt(t,e,s,o,h){if(function(t,e,s){const n=i.J.constructEmpty(),r=i.J.constructEmpty();t.queryEnvelope(n),e.queryEnvelope(r);const o=function(t,e,s){const n=i.J.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?!te(t,r,s):4===o}(t,e,s))return 4===o;if(4===o)return!1;switch(o){case 2:return Gt(t,e,s,!1);case 128:return Gt(t,e,s,!0);case 1:case 64:case 32:return!1;case 3:return function(t,e,s){const n=new i.J,r=new i.J;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s&&r.width()>s)&&Rt(n,r,s)}(t,e,s);case 8:return function(t,e,s,o){const h=new i.J,m=new i.J;if(t.queryEnvelope(h),e.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;const l=new i.J,u=new i.J;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 _=null,d=null;null!==g&&(_=g.getQuadTree(),null!==_&&(d=_.getIterator(m,s))),d||c.nextPath()||(0,n.c)("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!==d){const t=d.next();if(-1===t)break;c.resetToVertex(_.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.J;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.P;return C.addEnvelope(m,!1),It(C,t,s,o)}(t,e,s,h);case 16:return function(t,e,s){const o=new i.J,h=new i.J;if(t.queryEnvelope(o),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;const m=new i.J;if(m.setCoords({env2D:h}),m.inflateCoords(s,s),m.containsEnvelope(o))return!1;const l=new i.J;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,_=null;if(null!==c&&(g=c.getQuadTree(),null!==g&&(_=g.getIterator(h,s))),!_){const t=u.nextPath();(0,n.g)(t)}let d=!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!==_){const t=_.next();if(-1===t)break;u.resetToVertex(g.getElement(t),-1),p=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;p=u.nextSegment()}if(p.getGeometryType()===n.G.enumLine){if(f.assign(p.getStartXY()),x.assign(p.getEndXY()),0!==l.clipLine(f,x)){d=!0;break}}else{if(P.isIntersecting(p,s)){d=!0;break}if(y.isIntersecting(p,s)){d=!0;break}if(E.isIntersecting(p,s)){d=!0;break}if(C.isIntersecting(p,s)){d=!0;break}}}return d&&!0}(t,e,s)}return!1}function Et(t,e,s,i,n){switch(i){case 4:return Ft(t,e,s);case 2:case 128:return function(t,e,s){return qt(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return!Ft(t,e,s)}(t,e,s);case 3:return qt(t,e,s)}return!1}function Ct(t,e,s,n,r){switch(n){case 4:return function(t,e,s){const n=i.J.constructEmpty(),r=i.J.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),Ht(r,n,s))return!1;const o=i.J.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 Vt(t,e,s,!1);case 128:return Vt(t,e,s,!0);case 1:case 64:return!1;case 3:return function(t,e,s){const n=new i.J,r=new i.J;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s||r.width()>s)&&Rt(n,r,s)}(t,e,s);case 8:return function(t,e,s){const n=new i.J,r=new i.J,o=new i.J;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.J,r=new i.J;if(t.queryEnvelope(n),e.queryEnvelope(r),Ht(r,n,s))return!1;if(r.height()<=s||r.width()<=s)return!1;const o=new i.J,h=new i.J;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 St(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();if(t.queryEnvelope(r),e.queryEnvelope(o),!Rt(r,o,s))return!1;if(ct(t,e),Ot(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()?O(t,e,s,"**F**FFF*",n,!1):jt(t,e,s,!0))}function vt(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ht(r,o,s)&&(ct(t,e),ie(t,e,s,n))}function bt(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ht(r,o,s)&&(ct(t,e),2===Lt(t,e,s,!1))}function It(t,e,s,n){return ct(t,e),function(t,e,s,n){const r=t.getImpl(),o=e.getImpl(),h=r.querySegmentIterator(),m=o.querySegmentIterator(),u=(0,a.f)(2,Number.NaN),c=(0,a.f)(2,Number.NaN),g=new ot(r,o,s);let _=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();h.resetToVertex(t,-1),m.resetToVertex(e,-1);const i=h.nextSegment(),n=m.nextSegment();let r=0;if(oe(i,n)?!_&&n.isIntersecting(i,s)&&(_=!0):r=n.intersect(i,null,c,u,s),2===r)_=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!1;_=!0}}if(!_)return!1;const d=i.J.constructEmpty(),p=i.J.constructEmpty(),f=i.J.constructEmpty();let x,P;if(t.queryEnvelope(d),e.queryEnvelope(p),d.inflateCoords(1e3*s,1e3*s),p.inflateCoords(1e3*s,1e3*s),f.setCoords({env2D:d}),f.intersect(p),t.getPointCount()>10){if(x=(0,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 O(x,P,s,"F********",n,!1)}(t,e,s,n)}function wt(t,e,s,n,o){const h=i.J.constructEmpty(),m=i.J.constructEmpty();if(t.queryEnvelope(h),e.queryEnvelope(m),!Ht(h,m,s))return!1;ct(t,e);let l=!1;const u=new a.P,c=t.getImpl(),g=new r.P;let _=t,d=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,u),!h.contains(u))return!1;const r=(0,p.i)(_,u,s);if(1===r)l=!0;else if(0===r)return!1;if(n&&2===r)return!1;d||(!(0,p.r)(t,e.getPointCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?_=t:(t.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),_=g),d=!0)}return l}function Dt(t,e,s,n,r){const o=i.J.constructEmpty(),a=i.J.constructEmpty();return t.queryEnvelope(o),e.queryEnvelope(a),n?zt(a,o,s):Ht(a,o,s)}function Tt(t,e,s,n,o){const a=i.J.constructEmpty(),h=i.J.constructEmpty();if(t.queryEnvelope(a),e.queryEnvelope(h),!Ht(a,h,s))return!1;ct(t,e);const m=new r.P;return m.addEnvelope(e,!1),n?2===Lt(t,m,s,!1):ie(t,m,s,o)}function Nt(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ht(r,o,s)&&(ct(t,e),t.hasNonLinearSegments()||e.hasNonLinearSegments()?O(t,e,s,"******FF*",n,!1):Jt(e,t,s,!1))}function At(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ht(r,o,s)&&(ct(t,e),O(t,e,s,"T**FF*FF*",n,!1))}function Gt(t,e,s,o,a){const h=i.J.constructEmpty(),m=i.J.constructEmpty();if(t.queryEnvelope(h),e.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;if(o)return zt(m,h,s);if(!Ht(m,h,s))return!1;const l=i.J.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-s,-s);const u=i.J.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.c)("relational_operations");let g,_,d,p,f,x,P=!1;const y=t.hasNonLinearSegments();for(y&&(d=new r.L,p=new r.L,f=new r.L,x=new r.L,l.querySide(0,d),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(d,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(),_=t.getEndXY(),0!==l.clipLine(g,_)){P=!0;break}}return P}function Mt(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Ht(r,o,s)&&Wt(e,t,s,!0,!1,!1)}function qt(t,e,s,n){const r=i.J.constructEmpty(),o=i.J.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),Rt(r,o,s)}function Ft(t,e,s,i){return ne(t,e.getXY(),s)}function Vt(t,e,s,n,r){const o=i.J.constructEmpty(),h=i.J.constructEmpty();if(t.queryEnvelope(o),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;if(n)return zt(h,o,s);if(!Ht(h,o,s))return!1;let m=!1;const l=i.J.constructEmpty(),u=i.J.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 Yt(t,e,s,i){return a.P.sqrDistance(t,e)<=s*s}function Xt(t,e,s,i){return Yt(t,e,s)}function Rt(t,e,s,i){return Ht(t,e,s)&&Ht(e,t,s)}function kt(t,e,s,n,r){if(t.height()<=s||t.width()<=s)return!1;if(n)return zt(t,e,s);if(!Ht(t,e,s))return!1;const o=i.J.constructEmpty();return o.setCoords({env2D:t}),o.inflateCoords(-s,-s),o.intersect(e),!o.isEmpty()}function Lt(t,e,s,o,h){const m=new a.P,l=new a.P,u=i.J.constructEmpty(),c=i.J.constructEmpty(),g=t.getImpl(),_=e.getImpl(),d=_.getGeometryType(),f=new ot(g,_,s,!0);if(!f.next())return 1;if(Zt(t,e,s))return o?4:0;const x=new r.P;let P=t;const y=new r.P;let E=null;d===n.G.enumPolygon&&(E=e);const C=d===n.G.enumPolygon?(0,a.f)(g.getPathCount(),!1):[],S=(0,a.f)(_.getPathCount(),!1);let v=!1,b=!1,I=!1,w=!1,D=!1,T=!1;do{if(I&&D||w&&T)break;if(I&&w)break;const i=f.getRedElement(),r=f.getBlueElement();if(!S[r]&&(l.assign(e.getXY(e.getPathStart(r))),u.setCoords({env2D:f.getRedEnvelope()}),u.inflateCoords(s,s),u.contains(l))){if(0!==(0,p.i)(P,l,0)){if(w=!0,o)return 4}else T=!0;S[r]=!0}if(d===n.G.enumPolygon&&!C[i]&&(m.assign(t.getXY(t.getPathStart(i))),c.setCoords({env2D:f.getBlueEnvelope()}),c.inflateCoords(s,s),c.contains(m))){if(0!==(0,p.i)(E,m,0)){if(I=!0,o)return 4}else D=!0;C[i]=!0}if(v||(!(0,p.r)(t,e.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?P=t:(t.copyTo(x),x.getImpl().buildQuadTreeAccelerator(1),P=x),v=!0),d===n.G.enumPolygon&&!b){const s=e;!(0,p.r)(s,t.getPathCount()-1)||null!==_.getAccelerators()&&null!==_.getAccelerators().getQuadTree()?E=e:(s.copyTo(y),y.getImpl().buildQuadTreeAccelerator(1),E=y),b=!0}}while(f.next());if(!I&&!w)return 1;if(!D||!T){if(d===n.G.enumPolygon)for(let t=0,e=g.getPathCount();t<e;t++)if(!C[t]){D=!0;break}for(let t=0,e=_.getPathCount();t<e;t++)if(!S[t]){T=!0;break}}return I&&D||w&&T||I&&w?4:w?2:3}function Bt(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],_=new ot(h,m,s);let d=!1;for(;_.next();){const t=_.getRedElement(),e=_.getBlueElement();l.resetToVertex(t,-1),u.resetToVertex(e,-1);const i=l.nextSegment(),n=u.nextSegment();let r=0;if(oe(i,n)?!d&&n.isIntersecting(i,s)&&(d=!0):r=n.intersect(i,null,g,c,s),0!==r&&(d=!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(!d){o[0]=!0;const a=i.J.constructEmpty();t.queryEnvelope(a),a.inflateCoords(s,s);const l=new r.P;let u=t,c=!1;for(let s=0,r=e.getPathCount();s<r;s++)if(e.getPathSize(s)>0){const r=i.J.constructEmpty();if(e.queryPathEnvelope(s,r),!a.isIntersecting(r))return!1;{const t=e.getXY(e.getPathStart(s)),i=(0,p.v)(u,t,0);if((0,n.g)(-1!==i),0===i)return!1}c||(!(0,p.r)(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,_=i.J.constructEmpty();g.queryEnvelope(_),_.inflateCoords(s,s);const d=new r.P;let f=g,x=!1;for(let e=0,s=t.getPathCount();e<s;e++)if(t.getPathSize(e)>0){const s=i.J.constructEmpty();if(t.queryPathEnvelope(e,s),_.isIntersecting(s)){const s=t.getXY(t.getPathStart(e)),i=(0,p.v)(f,s,0);if((0,n.g)(-1!==i),1===i)return!1}x||(!(0,p.r)(g,t.getPathCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?f=g:(g.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),f=d),x=!0)}return!0}return!1}function Ht(t,e,s){const n=i.J.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),n.containsEnvelope(e)}function zt(t,e,s){const n=i.J.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),t.containsExclusiveEnvelope(n)}function Ut(t,e,s){const n=i.J.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 Ot(t,e,s,i){if(t.getPathCount()!==e.getPathCount()||t.getPointCount()!==e.getPointCount())return!1;if(t.hasNonLinearSegments()||e.hasNonLinearSegments())return t.equals(e);const n=new 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 i=t.getPathStart(s);i<e.getPathEnd(s);i++)if(t.queryXY(i,n),e.queryXY(i,r),a.P.sqrDistance(n,r)>h){o=!1;break}if(!o)break}return!!o}function Wt(t,e,s,i,n,r,o){const h=t.getImpl(),m=e.getImpl(),l=h.getPointCount(),u=m.getPointCount(),c=(0,a.f)(l,!1),g=n||r?(0,a.f)(u,!1):[],_=s*s,d=new ot(h,m,s);for(;d.next();){const t=d.getRedElement(),e=d.getBlueElement(),s=h.getXY(t),i=m.getXY(e);a.P.sqrDistance(s,i)<=_&&(c[t]=!0,(n||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,(n||i)&&p)return!1}if(i)return!0;let x=!1,P=!1;for(let t=0;t<u;t++){const e=g[t];if(x||=!e,P||=e,n&&x)return!1}return!!n||p&&f&&x&&P}function jt(t,e,s,i){return Jt(t,e,s,i)&&Jt(e,t,s,i)}function Jt(t,e,s,r){if((0,n.q)(t),(0,n.q)(e),e.isEmpty())return!1;let h=!0;const m=(0,a.f)(2,Number.NaN),l=(0,a.f)(2,Number.NaN),u=[],c=new he;let g;const _=i.J.constructEmpty(),d=i.J.constructEmpty(),p=i.J.constructEmpty();t.queryEnvelope(_),e.queryEnvelope(d),_.inflateCoords(s,s),d.inflateCoords(s,s),p.setCoords({env2D:_}),p.intersect(d);const f=t.getImpl().querySegmentIterator(),x=e.getImpl().querySegmentIterator(),P=e.getImpl().getAccelerators();let y=null,E=null,C=null,S=null;if(null!==P&&(y=P.getQuadTree(),E=P.getQuadTreeForPaths(),null!==E&&(S=E.getIteratorForQT())),null===y){const s=t.getPointCount(),i=e.getPointCount();s>10&&i>10&&(y=(0,o.w)(e.getImpl(),p))}for(null!==y&&(C=y.getIteratorForQT());f.nextPath();)for(;f.hasNextSegment();){let t=f.nextSegment();if(t.queryEnvelope(_),!_.isIntersecting(p))return h=!1,!1;if(null!==S&&(S.resetIterator(_,s),-1===S.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(d),d.inflateCoords(s,s),_.isIntersecting(d)&&(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(_),u.length=0,c.m_overlapEvents.length=0;let v=!1,b=!1,I=0;const w=(0,o.c)(null,_,!0);for(null!==C?C.resetIterator(t,s):(x.resetToFirstPath(),x.nextPath()||(0,n.c)("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(d),d.inflateCoords(s,s),_.isIntersecting(d)&&(e=t.intersect(i,null,m,l,s))}if(2===e&&(!r||l[0]<=l[1])){const t=f.getStartPointIndex(),e=f.getPathIndex(),i=x.getStartPointIndex(),n=x.getPathIndex();if(g=ae(t,e,m[0],m[1],i,n,l[0],l[1]),c.m_overlapEvents.push(g),u.push(u.length),!(v||g.m_scalarA0<I&&g.m_scalarA1<I))if(0===I&&E*(g.m_scalarA0-I)>s)v=!0;else if(0!==I&&E*(g.m_scalarA0-I)>w)v=!0;else if(I=g.m_scalarA1,E*(1-I)<=s||1===I){b=!0;break}}}if(!b){if(!v)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)>w)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 Zt(t,e,s){const i=t.getImpl(),n=e.getImpl(),r=i.querySegmentIterator(),o=n.querySegmentIterator(),a=new ot(i,n,s);for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();r.resetToVertex(t,-1),o.resetToVertex(e,-1);const i=r.nextSegment();if(o.nextSegment().isIntersecting(i,s))return!0}return!1}function Qt(t,e,s,i){const n=t.getImpl(),r=e.getImpl(),o=n.querySegmentIterator(),h=r.querySegmentIterator(),m=(0,a.f)(2,Number.NaN),l=new ot(n,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 n=o.nextSegment(),r=h.nextSegment();let g=0;if(oe(n,r)){if(r.isIntersecting(n,s))return-2}else g=n.intersect(r,null,m,null,s);if(g)if(2===g){const t=n.calculateLength2D(),e=m[0];if(t*(m[1]-e)>s)return c=1,c;u=!0}else if(c=0,i){const t=m[0],e=new a.P;n.queryCoord2D(t,e),i.push(e.x),i.push(e.y)}}return u?-2:c}function Kt(t,e,s,i){const n=t.getImpl(),r=e,o=r.getPointCount(),h=i?(0,a.f)(o,!1):[],m=new ot(n,r,s,!1),l=n.querySegmentIterator();for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const n=l.nextSegment(),o=r.getXY(e);if(n.isIntersectingPoint(o,s)){if(!i)return!0;h[e]=!0}}if(!i)return!1;for(let t=0;t<o;t++)if(!h[t])return!1;return!0}function $t(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.J.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.J.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 te(t,e,s,o){const h=t.querySegmentIterator(),m=t.getImpl().getAccelerators(),l=t.hasNonLinearSegments();let u=null,c=null,g=null,_=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,_=new r.L,e.querySide(0,u),e.querySide(1,c),e.querySide(2,g),e.querySide(3,_));const a=i.J.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(_,s))return!0}return!1}}if(l){u=new r.L,c=new r.L,g=new r.L,_=new r.L,e.querySide(0,u),e.querySide(1,c),e.querySide(2,g),e.querySide(3,_);const i=t.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.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(_,s))return!0}}else{const n=i.J.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 ee(t,e,s,n){const r=t.getImpl(),h=e.getImpl(),m=[0],u=(0,o.h)(r.getIsSimple(0,m))&&(0,o.h)(h.getIsSimple(0,m)),c=r.querySegmentIterator(),g=h.querySegmentIterator(),_=(0,a.f)(2,0),d=(0,a.f)(2,0),p=new ot(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 i=c.nextSegment(),n=g.nextSegment();let r=0;if(oe(i,n)){if(n.isIntersecting(i,s)){f=!0;break}}else r=n.intersect(i,null,d,_,s);if(2===r){const t=_[0],e=_[1],n=i.calculateLength2D();if(u&&(e-t)*n>s)return!1;f=!0}else if(r){const t=_[0],e=d[0];if(t>0&&t<1&&e>0&&e<1)return!1;f=!0}}if(!f)return!1;const x=i.J.constructEmpty(),P=i.J.constructEmpty(),y=i.J.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 O(E,C,s,"F********",n,!1)}function se(t,e,s,n){const r=t.getImpl(),h=e.getImpl(),m=[0],u=(0,o.h)(r.getIsSimple(0,m))&&(0,o.h)(h.getIsSimple(0,m)),c=i.J.constructEmpty(),g=i.J.constructEmpty(),_=i.J.constructEmpty();t.queryEnvelope(c),e.queryEnvelope(g);let d=!1;const p=Ut(c,g,s),f=Ut(g,c,s),x=r.querySegmentIterator(),P=h.querySegmentIterator(),y=(0,a.f)(2,Number.NaN),E=(0,a.f)(2,Number.NaN),C=new ot(r,h,s);for(;C.next();){const t=C.getRedElement(),e=C.getBlueElement();x.resetToVertex(t,-1),P.resetToVertex(e,-1);const i=x.nextSegment(),n=P.nextSegment();let r=0;if(oe(i,n)){if(n.isIntersecting(i,s))break}else r=n.intersect(i,null,E,y,s);if(2===r){const t=y[0],e=y[1],n=i.calculateLength2D();if(u&&(e-t)*n>s&&(d=!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 S=i.J.constructEmpty(),v=i.J.constructEmpty();let b,I;S.setCoords({env2D:c}),S.inflateCoords(1e3*s,1e3*s),v.setCoords({env2D:g}),v.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:S}),_.intersect(v);let w="";if(w+=d?"**":"T*",p){if(e.getPointCount()>10){if(I=(0,l.c)(e,_,s,0,n),I.isEmpty())return!1}else I=e;w+="****"}else I=e,w+="T***";if(f){if(t.getPointCount()>10){if(b=(0,l.c)(t,_,s,0,n),b.isEmpty())return!1}else b=t;w+="***"}else b=t,w+="T**";return O(b,I,s,w,n,!1)}function ie(t,e,s,n){const a=[!1],h=Bt(t,e,s,a);if(a[0])return h;const m=i.J.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 st;a.resetMatrix_(),a.setPredicates_("T*****F**"),a.setAreaAreaPredicates_();const h=i.J.constructEmpty(),m=i.J.constructEmpty();t.queryEnvelope(h),e.queryEnvelope(m);let l=!1;if(ut(h,m,s)&&(a.areaAreaDisjointPredicates_(t,e),l=!0),l||ct(t,e),l)return tt(a.m_matrix,a.m_scl);let u=new r.E,g=u.addGeometry(t),_=u.addGeometry(e),d=null,f=0;if(t.hasNonLinearSegments()||e.hasNonLinearSegments()){d=new p.C;const t=u.getEnvelope2D(n),e=(0,p.d)(s,t);f=(0,p.f)(e,0),(0,p.b)(u,e,s,12e3,d,null,n)}(0,p.e)(u,new o.C(s,0).add(f),n,!1,!1);const x=u.getGeometry(_).getBoundary();if(u.filterClosePoints(0,!0,!0,!1,r.n),(0,c.n)(u,g,-1,!1,r.n,n),0===u.getPointCount(g))return!1;(0,c.n)(u,_,-1,!1,r.n,n),a.setEditShape_(u,n);const P=0===u.getPointCount(_);if(!P){a.computeMatrixTopoGraphHalfEdges_(g,_),a.m_topoGraph.removeShape();const t=tt(a.m_matrix,a.m_scl);if(!t)return t}const y=u.getGeometry(g);return u=new r.E,g=u.addGeometry(y),_=u.addGeometry(x),a.setEditShape_(u,n),a.m_predicateCount=0,a.resetMatrix_(),a.setPredicates_(P?"T*****F**":"******F**"),a.setAreaLinePredicates_(),a.computeMatrixTopoGraphHalfEdges_(g,_),a.m_topoGraph.removeShape(),tt(a.m_matrix,a.m_scl)}(u,e,s,n)}function ne(t,e,s,i){const n=new a.P,r=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,n),a.P.sqrDistance(n,e)<=r)return!1;return!0}function re(t,e,s){const i=t.getBoundary();return!i.isEmpty()&&!ne(i,e,s)}function oe(t,e){return t.getGeometryType()!==n.G.enumLine||e.getGeometryType()!==n.G.enumLine}function ae(t,e,s,i,n,r,o,a){return{m_ivertexA:t,m_ipathA:e,m_scalarA0:s,m_scalarA1:i,m_ivertexB:n,m_ipathB:r,m_scalarB0:o,m_scalarB1:a}}class he{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(t,e){const s=this.m_overlapEvents[t],i=this.m_overlapEvents[e];if(s.m_ipathA<i.m_ipathA)return-1;if(s.m_ipathA===i.m_ipathA){if(s.m_ivertexA<i.m_ivertexA)return-1;if(s.m_ivertexA===i.m_ivertexA){if(s.m_scalarA0<i.m_scalarA0)return-1;if(s.m_scalarA0===i.m_scalarA0){if(s.m_scalarA1<i.m_scalarA1)return-1;if(s.m_scalarA1===i.m_scalarA1&&s.m_ivertexB<i.m_ivertexB)return-1}}}return 1}}function me(t,e,s){return e.m_projector.project(t,s)}function le(t,e,s,i,n){return t.m_projector.transformInPlaceZ(e,null,s,i,null,n)}function ue(t,e,s,a){if(t&&e&&e.isPannable()||(0,n.t)("fold_into_360_range_geodetic"),t.isEmpty())return t;if(4===s)return ce(t,e,a);let h=t;const m=h.getGeometryType();if((0,n.h)(m)){h=bs(t,e);const n=new i.J;h.queryEnvelope(n);const r=(0,o.a)(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=Ss(l,e,s,!0,m)),m+=a.width();h=l}else{if(m===n.G.enumEnvelope){const t=new r.P({vd:h.getDescription()});return t.addEnvelope(h,!1),ue(t,e,s,a)}if((0,n.f)(m)){const t=new r.a({vd:h.getDescription()});return t.addSegment(h,!0),ue(t,e,s,a)}}return ce(h,e,a)}function ce(t,e,s){if(t&&e&&e.isPannable()||(0,n.t)(""),t.isEmpty())return t;let i;const o=t.getGeometryType();if(o===n.G.enumEnvelope){const e=new r.P({vd:t.getDescription()});e.addEnvelope(t,!1),i=e}else if((0,n.f)(o)){const e=new r.a({vd:t.getDescription()});e.addSegment(t,!0),i=e}else i=t;const a=bs(i,e);return a.isEmpty()?a:xs(a,e,0,a!==t,0,s)}function ge(t,e,s,i){const n=e.getXYGridRange(),r=t.hasAttribute(1),h=t.hasAttribute(2);let m=new a.E,l=new a.E;r&&(m=e.getZGridRange()),h&&(l=e.getMGridRange());let u=(new g.O).execute(t,n,s,i);if(r){const e=u.queryInterval(1,0);m.contains(e)||(t===u&&(u=u.clone()),(0,o.a0)(u,m,1,0))}if(h){const e=u.queryInterval(2,0);l.contains(e)||(t===u&&(u=u.clone()),(0,o.a0)(u,l,2,0))}return u}class _e{constructor(t){this.m_inputPCSHorizonClipOption=0,this.m_outputPCSHorizonClipOption=0,this.m_bDontGeonormalizePolygon=!1,this.m_bClipOutCurvedPoles=!1,this.m_bNormalizeOutputGeometry=!1,this.m_bDontHackPolesInGeogToGeog=!1,this.m_centralMeridianOfOutputGCS=0,this.m_densificationStepInput=0,t||(0,n.t)(""),this.m_projTransform=t,this.m_bClipOutCurvedPoles=!1;const e=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=e.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(e.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),e.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,e.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=e.centralMeridianOfOutputGCS,this.m_densificationStepInput=e.densificationStep;const s=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=s.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=s.hasFlag(1073741824),this.m_bClipOutCurvedPoles=s.hasFlag(536870912)}project(t,e){if(this.m_projTransform.isIdentity()||t.isEmpty())return t;const s=t.getGeometryType();if(s===n.G.enumPoint)return this.projectPoint(t,e);const i=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),a=this.m_projTransform.getOutputSR();if(0===i&&i===r){const e=pe(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.c)("")}}projectPoint(t,e){const s=[t.getXY()];let i,n=null;(i=t.hasAttribute(1))&&(n=[t.getZ()]),this.transformInPlaceZ(s,n,1,s,n,null);const r=t.clone();return r.setXY(s[0]),i&&r.setZ(n[0]),r}projectMultiPoint(t,e){let s=new 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=As(s,i,this.m_inputPCSHorizonClipOption,e),s.isEmpty())return s;2===a&&Rs(i,0,s),Us(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=xs(s,ji(o),m,!1,0,e)),l&&(s=_s(s,o,this.m_outputPCSHorizonClipOption,e),Vs(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.c)("project_multi_path_")}projectEnvelope(t,e){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&t.hasAttribute(1);let i=a.E.constructEmpty();if(s&&(i=t.queryInterval(1,0)),i.width()>0){const s=t.clone();s.setInterval(1,0,i.vmin,i.vmin);const n=this.projectEnvelopeHelper(s,e);s.setInterval(1,0,i.vmax,i.vmax);const r=this.projectEnvelopeHelper(s,e);return n.merge(r),n}return this.projectEnvelopeHelper(t,e)}projectPolygon(t,e){(0,n.g)(t.getGeometryType()===n.G.enumPolygon),(0,n.g)(!this.m_projTransform.isIdentity()),(0,n.g)(!t.isEmpty());const s=this.m_projTransform.getInputSR(),o=this.m_projTransform.getOutputSR(),a=s.getCoordinateSystemType(),h=o.getCoordinateSystemType(),m=new r.P({copy:t});3===a&&(0,n.g)(0),3===h&&(0,n.g)(0);const g=2===a,_=2===h,d=g?s.getGCS():s,p=_?o.getGCS():o,f=!_&&!this.m_bDontHackPolesInGeogToGeog;let x=!1,P=As(m,s,this.m_inputPCSHorizonClipOption,e);if(P.isEmpty())return P;let y=this.m_densificationStepInput;const E=!Number.isNaN(y);let C;E&&(P=(new u.O).execute(P,y,0,0,e));let S=_?o.getPCSInfo():null,v=Number.NaN;g&&(v=s.getCentralMeridian());const b=null!==o.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const t=P;if(g&&(Bs(s,v,t),E)){const t=s.getUnitsPerMillimeter();y*=s.getGCS().getUnitsPerMillimeter()/t}if(Ws(this.m_projTransform,t,f),E){const t=s.getGCS().getUnitsPerMillimeter();y*=o.getGCS().getUnitsPerMillimeter()/t}C=t}else{let t=new r.a({vd:P.getDescription()});if(t.addAndExplicitlyOpenAllPaths(P,!1),g){if(Bs(s,v,t),E){const t=s.getUnitsPerMillimeter();y*=s.getGCS().getUnitsPerMillimeter()/t}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),r=n.getSouthPoleGeometry()===In.PE_POLE_LINE_CURVED,o=n.getNorthPoleGeometry()===In.PE_POLE_LINE_CURVED;if(r||o){const s=i.J.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.b)(t,s,d,0,0,e)}}}if(Ws(this.m_projTransform,t,f),E){const t=ji(s).getUnitsPerMillimeter();y*=ji(o).getUnitsPerMillimeter()/t}let n=Number.NaN;_?(S=o.getPCSInfo(),n=o.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(n=this.m_centralMeridianOfOutputGCS);let a=de(s)|de(o),h=10*p.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(a=3,h=10*p.getTolerance(0)),C=function(t,e,s,i,n,r,o,a,h){return new Je(t,null,s,e,i,n,o,a,r).geoNormalizePolygonGeometry(h)}(P,s,t,p,n,e,a,h,this.m_bNormalizeOutputGeometry),a=0}if(b&&((0,n.g)(!o.isPannable()),C=us(C,o,e)),_){if(!x){const t=p.getPannableExtent().width();if(C.queryInterval(0,0).width()>=t-10*p.getTolerance(0)){const t=S.getNorthPoleLocation(),e=S.getSouthPoleLocation(),s=S.getNorthPoleGeometry(),i=S.getSouthPoleGeometry();let n=0;s===In.PE_POLE_POINT&&t!==In.PE_POLE_OUTSIDE_BOUNDARY&&(n=1),i===In.PE_POLE_POINT&&e!==In.PE_POLE_OUTSIDE_BOUNDARY&&(n|=2),x||=0!==n}}C=_s(C,o,this.m_outputPCSHorizonClipOption,e),E&&(C=(new u.O).execute(C,y,0,0,e)),Xs(o,C,this.m_bNormalizeOutputGeometry)}return C.isEmpty()||x&&(C=(new c.O).execute(C,o,!1,e)),C}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.a({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 _=As(h,s,this.m_inputPCSHorizonClipOption,e);if(_.isEmpty())return _;let d=Number.NaN;m&&(d=s.getCentralMeridian());const p=null!==i.getGCSSplitLines();let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let P;if(x&&(_=(new u.O).execute(_,f,0,0,e)),this.m_bDontGeonormalizePolygon){if(m&&(Bs(s,d,_),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Ws(this.m_projTransform,_,g),x){const t=s.getGCS().getUnitsPerMillimeter();f*=i.getGCS().getUnitsPerMillimeter()/t}P=_}else{const t=new r.a({vd:_.getDescription()});if(t.addAndExplicitlyOpenAllPaths(_,!1),m&&(Bs(s,d,t),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Ws(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=de(s)|de(i),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,a=0),P=function(t,e,s,i,n,r,o,a,h){return new Je(t,null,s,e,i,n,o,a,r).geoNormalizePolylineGeometry(h)}(_,s,t,c,n,e,o,a,this.m_bNormalizeOutputGeometry),o=0}return p&&((0,n.g)(!i.isPannable()),P=us(P,i,e)),l&&(P=_s(P,i,this.m_outputPCSHorizonClipOption,e),x&&(P=(new u.O).execute(P,f,0,0,e)),Xs(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.m)(this.m_projTransform.getInputSR(),t,!0).total();if(s>100*a){const t=i.J.constructEmpty(),e=(0,o.a)(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.a;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(),i=new o.P(s),n=this.projectPoint(i,e),r=new o.E({vd:t.getDescription()});if(n.isEmpty())r.setEmpty();else{t.copyTo(r);const e=n.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.ax)(i,t,s),e!==r&&(0,a.a)(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 pe(m,l).transformPoints2D(t,s,i),h.isVertical()&&(0,n.g)(0),s;3===u&&(0,n.b)("image: transform_in_place_"),3===c&&(0,n.b)("image: transform_in_place_"),function(t,e,s,i,r){const o=i.getCoordinateSystemType();if(2===o){if(0===r)s!==t&&(0,a.ax)(s,t,e),function(t,e,s){const i=t.getPCSHorizon();if(i.getGeometryType()!==n.G.enumPolygon)if(i.getGeometryType()!==n.G.enumEnvelope)(0,n.t)("");else{const t=i;for(let i=0;i<s;i++)t.contains(e[i])||e[i].setNAN()}else{const n=t.getDefaultPrecisionSR().getTolerance(0),r=i;for(let t=0;t<s;t++)1!==(0,p.i)(r,e[t],n)&&e[t].setNAN()}}(i,s,e);else if(s!==t&&(0,a.ax)(s,t,e),i.isPannable()){const t=i.getTolerance(0);(function(t,e,s,i){for(let n=0;n<e;n++){if(t[n].y<s.ymin||t[n].y>s.ymax){t[n].setNAN();continue}const e=t[n].x;t[n].x=Es(e,s,i)}})(s,e,i.getPannableExtent(),t),Ps(s,e,i,0)}}else{(0,n.g)(1===o);const r=i.getTolerance(0),a=i.getPannableExtent();for(let i=0;i<e;i++)s[i].assign(Ns(t[i],a,r))}}(t,s,i,m,this.m_inputPCSHorizonClipOption),r!==e&&(0,a.a)(r,e,0,0,s),2===u&&Hs(m,0,i,s),Qs(this.m_projTransform,i,r,s,!1);let g=0;const _=2===c;if(_?g=l.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(g=this.m_centralMeridianOfOutputGCS),_&&0!==this.m_outputPCSHorizonClipOption||Ps(i,s,l.getGCS(),g),_){if(!fs(i,s,l,this.m_outputPCSHorizonClipOption))for(let t=0;t<s;++t)i[t].setNAN();Ms(l,i,s,!1)}let d=s;for(let t=0;t<s;++t)i[t].isNAN()&&(r&&(r[t]=Number.NaN),d--);return d}}function de(t){if(2!==t.getCoordinateSystemType())return 0;let e=0;const s=t.getPCSInfo(),i=s.getNorthPoleLocation(),n=s.getSouthPoleLocation(),r=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return r===In.PE_POLE_POINT&&i!==In.PE_POLE_OUTSIDE_BOUNDARY&&(e=1),o===In.PE_POLE_POINT&&n!==In.PE_POLE_OUTSIDE_BOUNDARY&&(e|=2),e}function pe(t,e){const s=t.getHorzUnitFactor(),i=e.getHorzUnitFactor();let n=1,r=1;const o=20015077/180;1===t.getUnit().getUnitType()&&(n=o),1===e.getUnit().getUnitType()&&(r=o);const a=s/i*(n!==r?n/r:1),h=new m.T;return h.setScaleCoords(a,a),h}let fe=class{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s){return!e||e.isIdentity()?t:new xe(t,e,s)}execute(t,e,s){return e.isIdentity()?t:me(t,e,s)}transform(t,e,s,i,n=!0){return n?function(t,e,s,i){t.m_projector.transformInPlaceZ(e,null,s,i,null,null);const n=i.slice(0,s).filter((t=>!t.isNAN()));for(let t=0,e=n.length;t<e;++t)i[t].assign(n[t]);return n.length}(t,e,s,i):le(t,e,s,i,null)}transform3D(t,e,s,i,r=!0){return(0,n.g)(0),0}foldInto360Range(t,e){return ce(t,e,null)}foldInto360RangeGeodetic(t,e,s){return ue(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.b)("not yet impl for geometry collection");const u=e.getPannableExtent();Number.isNaN(s)&&(s=u.getCenterX());const c=u.width(),g=.5*c,_=h>0,d=t.queryInterval(0,0);if(!_&&d.width()<g||!(0,n.i)(t.getGeometryType())){const e=d.getCenter();if(Math.abs(e-s)<=g)return t;{const i=new m.T,n=(0,a.ay)((s-e)/c)*c;i.setShiftCoords(n,0);const r=t.clone();return r.applyTransformation(i),r}}if(l===n.G.enumPolygon){let n=new r.a({vd:t.getDescription()});n.addAndExplicitlyOpenAllPaths(t,!1),_&&(n=Pe(n,e,2,h,Number.NaN,null,!0));const m=[];if(!i){{let s=t;_&&(s=new r.P,s.add(n,!1));const i=function(t,e,s){const i=Yi();e.querySpheroidData(i);const n=e.getGCS()!==e?e.getSRToGCSTransform():null,r=(0,a.m)(a.P,100),h=new o.v(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),n&&(new fe).transform(n,r,o,r,!1);for(let t=0;t<o;t++){if(r[t].isNAN())continue;r[t].scale(l);const e=T(i.majorSemiAxis,i.e2,r[t]);h.addThis(e)}e+=o}const u=G(i.majorSemiAxis,i.e2,h);u.scale(1/l);const c=t;if(!new He(e.getGCS(),u).project(c))return 0;s.length=t.getPathCount();const g=c.calculateArea2D()<0;for(let e=0,i=t.getPathCount();e<i;e++){const t=c.calculateRingArea2D(e),i=g?t<0:t>0;s[e]=i}return g?-1:1}(t,e,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 Je(null,i,n,null,e,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(l===n.G.enumPolyline){let i=new r.a({vd:t.getDescription()});return i.addAndExplicitlyOpenAllPaths(t,!1),_&&(i=Pe(i,e,2,h,Number.NaN,null,!0)),new Je(null,null,i,null,e,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(l===n.G.enumMultiPoint){const e=t,i=e.getAttributeStreamRef(0);let n,r=null,o=s,h=0;const m=.1*c;for(let s=0,l=e.getPointCount();s<l;s++){const e=i.read(2*s);let l=e-o;if(Math.abs(l)>g&&(l=(0,a.ay)(l/c)*c,h-=l,Math.abs(h)<m&&(h=0)),0!==h){r||(n=t.clone(),r=n.getAttributeStreamRef(0));const i=e+h;r.write(2*s,i)}o=e}return r?(n.notifyModified(),n):t}(0,n.c)("")}(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.ay)((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 _=0,d=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===d&&((0,n.h)(h)?(0===f&&Number.isNaN(s)&&(P=!0),f>0&&Number.isNaN(s)&&(s=x.getCenter(),P=!1),d=l.getPathEnd(f),f++):d=l.getPointCount(),Number.isNaN(s)?p=e:(p=s,_=0));let o=e-p;Math.abs(o)>r&&(o=(0,a.ay)(o/i)*i,_-=o,Math.abs(_)<.1*i&&(_=0));const m=e+_;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 i=new hn;return e.queryPrecisionDescriptor(i),ge(t,i,e,s)}let a=t;2!==r&&3!==r||!e.isPannable()||(a=ce(a,e,s));const h=new hn;if(e.queryPrecisionDescriptor(h),a=ge(a,h,e,s),0===r||a.isEmpty())return a;if(1===o){if(1===r){const t=new i.J;a.queryLooseEnvelope(t);const n=e.getPannableExtent(),r=.01*n.width();return n.xmin=t.xmin-r,n.xmax=t.xmax+r,(new g.O).execute(a,n,e,s)}return a}if(2===o){const t=e.getPCSHorizon();if(1===r||2===r){const i=(new _.O).execute(a,t,e,s);return i===t?i.clone():i}return a}if(3===o)return a;(0,n.c)("missing implementation")}(t,e,s,r)}};class xe extends d.G{constructor(t,e,s){super(),this.m_projTrans=e,this.m_progressTracker=s,this.m_index=-1,t||(0,n.t)(""),this.m_inputGeoms=t}next(){const t=this.m_inputGeoms.next();return null!=t?((0,n.q)(t),(0,n.d)(t),this.m_index=this.m_inputGeoms.getGeometryID(),me(t,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Pe(t,e,s,i,o,a,h=!1){t||(0,n.t)("Geometry.Geodetic_densify.densify");let m=t.getGeometryType();if((0,n.d)(t),(0,n.q)(t),t.isEmpty()||(0,n.j)(m))return t;const l=new be;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=Yi();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.P({vd:t.getDescription()});e.addEnvelope(t,!1),c=e,m=n.G.enumPolygon}else if((0,n.f)(m)){const e=new r.a({vd:t.getDescription()});e.addSegment(t,!0),c=e,m=n.G.enumPolyline}else c=t;if(4!==l.m_curveType){if(g=l.m_transform&&!l.m_transform.isIdentity()?(new fe).execute(c,l.m_transform,a):bs(c,l.m_gcs),g.isEmpty())return g;g=ye(l.m_rpu,g);let t=l.geodeticDensify(g);h||(t=(new fe).foldInto360RangeGeodetic(t,l.m_gcs,l.m_curveType)),d=l.m_transform&&!l.m_transform.isIdentity()?(new fe).execute(t,l.m_transform.getInverse(),a):t}else{let t;if(e.isPannable())t=bs(c,e);else{const s=e.getPCSHorizon();t=(new _.O).execute(c,s,e,a),t===s&&(t=s.clone())}if(g=t,g.isEmpty())return g;d=l.shapePreservingDensify(g)}return d}function ye(t,e){const s=new i.J;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(!Ce(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,_=new a.P(0,0),d=new a.P(0,0),p=new o.P;for(r.resetToFirstPath();r.nextPath();){let e=Number.NaN,s=0;for(;r.hasNextSegment();){const i=r.nextSegment();if(h.setCoordsPoint2D(i.getStartXY()),m.setCoordsPoint2D(i.getEndXY()),h.scale(t),m.scale(t),Number.isNaN(e)?(s=Fe(h.x,Number.NaN,s),_.setCoordsPoint2D(h)):_.setCoordsPoint2D(d),e=_.x,Ce(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=Fe(m.x,Number.NaN,s),d.setCoordsPoint2D(m)}else c.setCoordsPoint2D(m),ke(c),s=Fe(c.x,e,s),d.setCoords(s+c.x,c.y);if(Math.abs(d.x-m.x)<.5&&d.setCoordsPoint2D(m),u)i.queryCoord(0,p),g.setCoordsPoint2D(_),g.scale(1/t),p.setXY(g),r.isFirstSegmentInPath()?l.startPathPoint(p):l.lineToPoint(p),r.isLastSegmentInPath()&&!r.isPathClosed()&&(i.queryCoord(1,p),g.setCoordsPoint2D(d),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(_),g.scale(1/t),l.insertPoint2D(e,-1,g),r.isLastSegmentInPath()&&!r.isPathClosed()&&(g.setCoordsPoint2D(d),g.scale(1/t),l.insertPoint2D(e,-1,g))}}}return l}function Ee(t,e,s,i,n,r,o,h,m,l,u,c){const g=new a.P,_=new a.P,d=i.compare(n)>0;Me(d,i,n,g,_);const p=De(t,e,s,g,_,r,o,h,m,l,null,u,c);return d&&Ge(m,l,null,u),p}function Ce(t,e){return!(!yn(t.y,a.t)||!yn(e.y,a.t))||!(!yn(t.y,-a.t)||!yn(e.y,-a.t))}function Se(t,e){return!(!yn(t.y,a.t)||yn(e.y,a.t))||!(!yn(t.y,-a.t)||yn(e.y,-a.t))}function ve(t,e){return!(!yn(e.y,a.t)||yn(t.y,a.t))||!(!yn(e.y,-a.t)||yn(t.y,-a.t))}class be{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(),i=[],o=[],h=new r.S,m=t.getDescription().getAttributeCount()>1;for(;s.nextPath();){const t=[0];for(;s.hasNextSegment();){const r=s.nextSegment(),l=r.getStartXY(),u=r.getEndXY();l.scale(this.m_rpu),u.scale(this.m_rpu);const c=new a.P,g=new a.P,_=l.compare(u)>0;Me(_,l,u,c,g),i.length=0,o.length=0,this.m_maxLength>0?De(this.m_a,this.m_eSquared,this.m_curveType,c,g,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,m?o:null,i,t):(0,n.g)(0),_&&Ge(null,null,m?o:null,i),i[0].setCoordsPoint2D(r.getStartXY()),i.at(-1).setCoordsPoint2D(r.getEndXY());const d=1/this.m_rpu;for(let t=1,e=i.length-1;t<e;t++)i[t].scale(d);if(m){const t=qe(_,r,h);we(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),r,t,o,i,e)}else Ie(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),i,e)}}return e}shapePreservingDensify(t){const e=t.createInstance(),s=t.querySegmentIterator(),i=[],n=[],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=qe(m,t,o);i.length=0,n.length=0,Ae(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,a?n:null,i),m&&Ge(null,null,a?n:null,i),a?we(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),t,l,n,i,e):Ie(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),i,e)}return e}}function Ie(t,e,s,i){t&&i.insertPath2D(-1,null,0,0,!0);const n=i.getPathCount()-1;i.insertPointsFromPoints(n,-1,s,0,s.length-1,!0),e&&i.insertPoint2D(n,-1,s.at(-1))}function we(t,e,s,i,n,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=i.calculateLength2D();for(let e=1;e<r.length-1;e++){const s=i.lengthToT(n[e]*t);i.queryCoord(s,h),h.setXY(r[e]),a.lineToPoint(h)}}e&&(s.queryEnd(h),a.lineToPoint(h))}function De(t,e,s,i,n,r,o,m,l,u,c,g,_){const d={stack:[],error:void 0,hasError:!1};try{const p=(0,h.b)(d,new En,!1),f=(0,h.b)(d,new En,!1),x=(0,h.b)(d,new En,!1);Tn.geodeticDistance(t,e,i.x,i.y,n.x,n.y,x,p,f,s);const P=x.val,y=p.val,E=f.val;let C=y,S=E;C<0&&(C+=2*Math.PI),S<0&&(S+=2*Math.PI),l&&(l[0]=C),u&&(u[0]=S);let v=Number.NaN,b=Number.NaN;if(null!==c){const s=Nn.q90(t,e),n=Nn.q(t,e,i.y);v=(s-n)/P,b=(s+n)/P}const I=Se(i,n),w=ve(i,n),D=I||w,T=function(t,e,s){return!(!Re(t,e,s)||yn(t.y,a.t)||yn(t.y,-a.t)||yn(e.y,a.t)||yn(e.y,-a.t))}(i,n,m),N=(0,h.b)(d,new a.S(new En,new En),!1),A=new a.P,G=new a.P,M=new a.P;_[0]=Fe(i.x,Number.NaN,_[0]);let q=_[0];if(P<=r)return g.push(i.clone()),_[0]=Fe(n.x,Number.NaN,_[0]),null!=c&&c.push(0),D?(I&&Ve(i,n,c,g),w&&Ye(i,n,c,g)):T?Xe(i,n,y,v,b,c,g):o>0&&(G.setCoords(i.x-q,i.y),A.setCoords(n.x-_[0],n.y),q=Te()),g.push(n.clone()),P;const F=1+Math.ceil(P/r),V=P/(F-1),Y=new a.P;g.push(i.clone()),Y.setCoordsPoint2D(i),G.setCoords(i.x-_[0],i.y),null!==c&&c.push(0);for(let r=1;r<F;r++){let a;if(r<F-1){const n=r*V;Tn.geodeticCoordinate(t,e,i.x,i.y,n,y,N.at(0),N.at(1),s),A.setCoords(N.at(0).val,N.at(1).val),_[0]=Fe(A.x,Y.x,_[0]),M.setCoords(_[0]+A.x,A.y),a=r/(F-1)}else _[0]=Fe(n.x,Number.NaN,_[0]),A.setCoords(n.x-_[0],n.y),M.setCoordsPoint2D(n),a=1;D?(1===r&&I&&Ve(i,M,c,g),r===F-1&&w&&Ye(Y,n,c,g)):T?Re(Y,M,m)&&(i.x<n.x?Y.x>M.x&&(_[0]+=2*Math.PI,M.setCoords(_[0]+A.x,A.y)):Y.x<M.x&&(_[0]-=2*Math.PI,M.setCoords(_[0]+A.x,A.y)),Xe(Y,M,y,v,b,c,g)):o>0&&Te(),g.push(M.clone()),null!=c&&c.push(a),Y.setCoordsPoint2D(M),G.setCoordsPoint2D(A),q=_[0]}return P}catch(t){d.error=t,d.hasError=!0}finally{(0,h.c)(d)}}function Te(t,e,s,i,r,o,a,h,m,l,u,c,g,_,d){return(0,n.g)(0),0}function Ne(t,e,s,i){const n=T(t,e,s),r=T(t,e,i);return o.v.distance(n,r)}function Ae(t,e,s,i,n,r,o,h,m){const l=i.isCurve(),u=function(t,e){return t*Math.sqrt(1-e)}(t,e)*Math.PI*179/180;let c=r;r>0&&!(r>u)||(c=u),c=z(t,e,c);let g=o;!l||g>0||(g=.001);const _=g>0;let d=Number.NaN;_&&(d=z(t,e,g));const p=n.getPECoordSys(),f=1===n.getCoordinateSystemType(),x=n.getTolerance(0),P=i.getStartXY(),y=i.getEndXY(),E=new a.P,C=new a.P;if(f)E.setCoordsPoint2D(P),E.scale(s),C.setCoordsPoint2D(y),C.scale(s);else{const t=[P.x,P.y,y.x,y.y];vn.projToGeog(p,2,t),E.setCoords(t[0],t[1]),E.scale(s),C.setCoords(t[2],t[3]),C.scale(s)}let S=0,v=0;const b=[],I=[],w=[];b.push(y.clone()),I.push(C.clone()),w.push(1),m.push(P.clone()),null!==h&&h.push(v);const D=n.isPannable(),N=P.clone(),A=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let G=5;for(l||(_?(A[0]=.5,A[1]=.25,A[2]=.75,G=3):G=1);I.length>0;){const r=b.at(-1).clone();C.assign(I.at(-1));const o=w.at(-1);let u=!1,g=Number.NaN;const P=Ne(t,e,E,C);let y=c>=P&&Math.abs(E.y-C.y)<.9*Math.PI;f&&y&&(y=Math.abs(E.x-C.x)<.9*Math.PI);const M=new a.P,F=new a.P;let V=!1;if(l||_||!y||y&&(V=!0),i.calculateSubLength(v,o)<=x&&(V=!0),!V)for(let r=0;r<G;r++){const h=(0,a.w)(v,o,A[r]),m=new a.P;i.queryCoord2D(h,m);const l=new a.P;if(f)l.setCoords(m.x*s,m.y*s);else{const t=[m.x,m.y];vn.projToGeog(p,1,t),l.setCoords(t[0]*s,t[1]*s)}if(0===r&&(g=h,M.setCoordsPoint2D(m),F.setCoordsPoint2D(l),!y)){u=!0;break}if(f&&Math.abs(E.x-l.x)>=Math.PI){u=!0;break}if(c<Ne(t,e,E,l)){u=!0;break}if(_){const h=q(t,e,E,C,A[r]),m=h.clone();if(f?(m.x/=s,m.y/=s):(m.x/=s,m.y/=s,le(n.getGCSToSRTransform(),[m],1,[m],null)),m.isNAN()){const s=T(t,e,l),i=T(t,e,E),n=T(t,e,C),{first:r,second:o}=Y(t,e,s,i,n,2,null);if(o>d){u=!0;break}}else{if(D){const t=n.getPannableExtent().width(),e=(0,a.w)(i.getStartX(),i.getEndX(),.5);for(;m.x<e-.5*t;)m.x+=t;for(;m.x>=e+.5*t;)m.x-=t}const r=i.getClosestCoordinateOnInterval(m,new a.E(v,o),-1),l=i.getCoord2D(r);if(!f){const t=[l.x,l.y];vn.projToGeog(p,1,t),l.x=t[0],l.y=t[1]}l.x*=s,l.y*=s;let c=Ne(t,e,l,h);if(c>d){if(c<4*d){const s=T(t,e,l),i=T(t,e,E),n=T(t,e,C),{first:r,second:o}=Y(t,e,s,i,n,2,null);c=o}if(c>d){u=!0;break}}}}}u?(b.push(M.clone()),I.push(F.clone()),w.push(g)):(b.pop(),I.pop(),w.pop(),m.push(r.clone()),S+=P,null!==h&&h.push(S),N.setCoordsPoint2D(r),E.setCoordsPoint2D(C),v=o)}if(null!==h){const t=1/S;for(let e=0;e<h.length;e++)h[e]*=t}}function Ge(t,e,s,i){if(i.reverse(),null!==s&&s.reverse(),t){const s=t[0],i=e[0];t[0]=i,e[0]=s}}function Me(t,e,s,i,n){t?(i.setCoordsPoint2D(s),n.setCoordsPoint2D(e)):(i.setCoordsPoint2D(e),n.setCoordsPoint2D(s))}function qe(t,e,s){return t?(s.create(e.getGeometryType()),e.copyTo(s.get()),s.get().reverse(),s.get()):e}function Fe(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 Ve(t,e,s,i){if(t.y>0){const n=new a.P;n.setCoords(e.x,a.t),yn(t.x,n.x)||yn(e.y,n.y)||(i.push(n),null!==s&&s.push(0))}else{const n=new a.P;n.setCoords(e.x,-a.t),yn(t.x,n.x)||yn(e.y,n.y)||(i.push(n),null!==s&&s.push(0))}}function Ye(t,e,s,i){if(e.y>0){const n=new a.P;n.setCoords(t.x,a.t),yn(e.x,n.x)||yn(t.y,n.y)||(i.push(n),null!==s&&s.push(1))}else{const n=new a.P;n.setCoords(t.x,-a.t),yn(e.x,n.x)||yn(t.y,n.y)||(i.push(n),null!==s&&s.push(1))}}function Xe(t,e,s,i,n,r,o){if(function(t){return function(t,e){return 0===t||Math.abs(t)<=e}(t,Pn)}(s)){if(a.t-t.y>0){const e=new a.P;e.setCoords(t.x,a.t),o.push(e),null!==r&&r.push(i)}if(a.t-e.y>0){const t=new a.P;t.setCoords(e.x,a.t),o.push(t),null!==r&&r.push(i)}}else{if(a.t+t.y>0){const e=new a.P;e.setCoords(t.x,-a.t),o.push(e),null!==r&&r.push(n)}if(a.t+e.y>0){const t=new a.P;t.setCoords(e.x,-a.t),o.push(t),null!==r&&r.push(n)}}}function Re(t,e,s){return Math.abs(Math.abs(t.x-e.x)-Math.PI)<=s}function ke(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 Le(t,e,s,i){const n={stack:[],error:void 0,hasError:!1};try{const r=[s.x],o=[s.y-i],a=[s.x],m=[s.y+i];R(r,o),R(a,m);const l=(0,h.b)(n,new En,!1),u=(0,h.b)(n,new En,!1);return Tn.greatEllipticDistance(t,e,s.x,s.y,r[0],o[0],l,null,null),Tn.greatEllipticDistance(t,e,s.x,s.y,a[0],m[0],u,null,null),Math.min(l.val,u.val)}catch(t){n.error=t,n.hasError=!0}finally{(0,h.c)(n)}}function Be(t,e,s,n,r){const a=new i.J;s.queryEnvelope(a);const h=(0,o.m)(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,_=new m.T;_.setShiftCoords(-g,0);const d=s;d.applyTransformation(_);const p=new i.J;d.queryEnvelope(p);let f=null;if(p.xmax>e.xmax){let s=0;const n=new i.J;n.setCoords({env2D:e}),n.ymin-=1,n.ymax+=1;let a=d;for(;n.xmin<p.xmax;){p.xmax>n.xmax&&(a=Ss(a,t,2,!0,n.xmax));const i=(0,o.t)(a,n),h=(0,o.a)(null,i,!0).total(),m=(0,l.c)(a,n,h,Number.NaN,r);null===f?f=m===a?m.clone():m:(_.setShiftCoords(-s*u,0),m.applyTransformation(_),f.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=e.xmax+s*u}}else f=d;return f}class He{constructor(t,e){this.m_basisX=new o.v,this.m_basisY=new o.v,this.m_normal=new o.v,(0,n.g)(1===t.getCoordinateSystemType()),this.m_gcs=t;const s=Yi();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,i,n,r){return N(t,e,s,i,n,r,0)}(this.m_a,this.m_e2,h,m,l,u),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),o.v.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.q)(t);const e=t;return this.projectMultiVertex(e)}(0,n.t)("Gnomonic.project")}unproject(t,e,s){const h=t.getGeometryType();if((0,n.i)(h)){(0,n.q)(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 i=t.getPannableExtent(),n=a.P.construct(0,0);i.centerAt(n);const r=i.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 n=s.getXY(e),a=yn(n.y,i.ymax)||yn(i.ymin,n.y);e===s.getPathStart(t)?(h.setNAN(),m=0):h.isNAN()||a||(m=Oe(n.x,h.x,o,r,m)),n.x+=m,s.setXY(e,n),a||h.setCoordsPoint2D(n)}s.getImpl().notifyModifiedFlags(2001)}(this.m_gcs,0,m),function(t,e,s,h,m){const l=h.getGeometryType(),u=e.getPannableExtent();let g=h,_=!1,d=!1;if(l===n.G.enumPolygon){const s=new i.J,n=a.P.construct(0,0);s.setCoords({env2D:u}),s.centerAt(n),_=function(t,e,s,n,o){const h=function(t,e){const s=new i.J;e.queryEnvelope(s);const n=yn(t.ymax,s.ymax),o=yn(t.ymin,s.ymin),h=n||o;return!!h&&(function(t,e){const s=new r.P,n=new i.J;for(let i=0;i<e.getPathCount();i++){e.queryPathEnvelope(i,n);let r=yn(t.ymax,n.ymax),o=yn(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=yn(t.ymax,s.y),o=yn(t.ymin,s.y),!r&&!o)break}let c=u,g=!1,_=Number.NaN;do{const n=e.getXY(c);r=yn(t.ymax,n.y),o=yn(t.ymin,n.y);const m=h+(c+1-h)%l;if(r||o){let r=a.P.construct(_,n.y);s.insertPoint2D(i,-1,r);const o=e.getXY(m),h=yn(t.ymax,o.y),l=yn(t.ymin,o.y);h||l||(r=a.P.construct(o.x,n.y),g?s.setXY(s.getPointCount()-1,r):s.insertPoint2D(i,-1,r)),g=!0}else s.insertPoint2D(i,-1,n),_=n.x,g=!1;c=m}while(c!==u)}e.setEmpty(),e.add(s,!1)}(t,e),h)}(s,n),m=function(t,e,s,i,n){const o=[],a=[],h=.5*s.width();for(let r=0;r<i.getPathCount();r++){const m=i.getXY(i.getPathStart(r)),l=i.getXY(i.getPathEnd(r)-1),u=t[r]<0;if(Math.abs(m.x-l.x)>h){const t=ze(u,e,s,r,i,n);o.push(t),a.push(r)}else if(!u&&i.calculateRingArea2D(r)<0){const t=Ue(e,s,r,i,n);o.push(t),a.push(r)}}if(0===o.length)return!1;const m=new r.P({vd:i.getDescription()});let l=0,u=a[l];for(let t=0;t<i.getPathCount();t++)t===u?(m.add(o[l],!1),l++,l<a.length&&(u=a[l])):m.addPath(i,t,!0);return i.setEmpty(),i.add(m,!1),!0}(t,e,s,n,o);return h||m}(t,e,s,g,m);const h=function(t,e,s,n){const r=new i.J;s.queryEnvelope(r);const a=(0,o.m)(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.J,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=Be(t,e,m,0,n),h.add(m,!0));return h}(e,s,g,m);h!==g&&(d=!0),g=h}else g=(new fe).foldInto360RangeGeodetic(g,e,2);l===n.G.enumPolygon&&(_||d)&&(g=(new c.O).execute(g,e,!1,m)),g!==h&&(h.setEmpty(),h.add(g,!1))}(l,this.m_gcs,0,m,s)):m=xs(m,this.m_gcs,0,!0,0,s),m}(0,n.t)("Gnomonic.unproject")}projectPoint(t){const e=t.mul(this.m_rpu),s=T(this.m_a,this.m_e2,e),i=this.m_normal.dotProduct(s);if(i<=0)return a.P.construct(Number.NaN,Number.NaN);const n=this.m_d/i,r=s.mul(n).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 G(this.m_a,this.m_e2,e).divide(this.m_rpu)}projectMultiVertex(t){const e=t.getImpl();let s=!0;const i=new a.P,n=new a.P;for(let t=0,r=e.getPointCount();t<r;t++)e.queryXY(t,i),i.y*this.m_rpu>.5*Math.PI?n.assign(this.m_northPolePcs):i.y*this.m_rpu<.5*-Math.PI?n.assign(this.m_southPolePcs):n.assign(this.projectPoint(i)),e.setXY(t,n),n.isNAN()&&(s=!1);return e.notifyModifiedFlags(2001),s}unprojectMultiVertex(t,e){const s=e.getImpl(),i=t*t,n=!this.m_northPolePcs.isNAN(),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;n&&a.P.sqrDistance(e,this.m_northPolePcs)<=i?(o.setCoords(this.m_curvCenterRad.x,.5*Math.PI),o.scale(1/this.m_rpu)):r&&a.P.sqrDistance(e,this.m_southPolePcs)<=i?(o.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),o.scale(1/this.m_rpu)):o=this.unprojectPoint(e),s.setXY(t,o)}s.notifyModifiedFlags(2001)}}function ze(t,e,s,n,h,u){const c=new r.P,g=new r.P,_=new m.T,d=h.getXY(h.getPathStart(n)),p=h.getXY(h.getPathEnd(n)-1),f=s.width(),x=.5*f,P=new i.J;h.queryEnvelope(P);const y=Math.ceil(P.width()/f)+1;let E,C;d.x>p.x?(E=-f,C=t?s.ymin:s.ymax):(E=f,C=t?s.ymax:s.ymin),_.setShiftCoords(E,0),c.addPath(h,n,!0),g.add(c,!1);const S=new o.P;for(let t=0;t<y;t++)g.applyTransformation(_),g.getPointByVal(0,S),c.lineToPoint(S),c.addSegmentsFromPath(g,0,0,g.getSegmentCount()-1,!1);const v=c.getXY(0),b=c.getXY(c.getPointCount()-1);v.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-v.x)>x;)c.lineTo(I),I.x-=.5*E;c.lineTo(v);const w=s.getCenter().x,D=new i.J;c.queryEnvelope(D);let T=0;const N=D.getCenter().x;N-w>x?T=-Math.ceil((N-w-x)/f):w-N>x&&(T=Math.ceil((w-N-x)/f)),0!==T&&(_.setShiftCoords(T*f,0),c.applyTransformation(_));const A=new r.E,G=A.addGeometry(c);vs(A,G,e,0,2,!0,s.xmin),vs(A,G,e,0,2,!0,s.xmax);const M=A.getGeometry(G),q=(0,o.t)(M,s);q.inflateCoords(0,1);const F=(0,o.a)(null,q,!0);return(0,l.c)(M,s,F.total(),Number.NaN,u)}function Ue(t,e,s,n,h){const u=e.width(),c=.5*u,g=e.getCenter().x,_=new i.J;n.queryPathEnvelope(s,_);let d,p=0,f=_.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,_),f=_.getCenter().x}const x=new i.J;e.containsExclusiveEnvelope(_)?(d=!1,x.setCoords({env2D:e})):(d=!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),d){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);vs(a,c,t,0,2,!0,e.xmin),vs(a,c,t,0,2,!0,e.xmax),P=a.getGeometry(c);const _=(0,o.t)(P,e);_.inflateCoords(0,1);const d=(0,o.a)(null,_,!0).total();P=(0,l.c)(P,e,d,Number.NaN,h)}else P.addPath(n,s,!0);return P}function Oe(t,e,s,i,n){return n+t-e>s?n-=i:e-(n+t)>s&&(n+=i),n}function We(t,e,s,i,n,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 _=new r.E,d=_.addGeometry(e),p=_.getFirstPath(d);let f=-1,x=!0;const P=new a.P,y=new o.P;let E=r.n;const C=je*n/360;for(let t=_.getFirstVertex(p);t!==r.n;t=_.getNextVertex(t)){_.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=_.getPrevVertex(t);_.queryPoint(e,y);const s=_.insertVertex(p,t,y);P.x=c.x,_.setXY(s,P)}if(g){let e=E!==r.n?_.getNextVertex(E):_.getFirstVertex(p);const s=_.getPrevVertex(t);for(;e!==s;)e=_.removeVertex(e,!1);if(E!==r.n){const t=_.getXY(E),e=_.getXY(s);if(Math.abs(t.x-e.x)>C){_.queryPoint(E,y);const i=_.insertVertex(p,s,y);t.x=(0,a.w)(t.x,e.x,.5),_.setXY(i,t)}}}E=r.n}if(e&&(c.y=(0,a.e)(i,c.y),_.setXY(t,c),!x&&f!==e))if(c.x!==P.x){_.queryPoint(t,y);const e=_.insertVertex(p,t,y);_.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=_.getNextVertex(E);for(;t!==r.n;)t=_.removeVertex(t,!1)}const t=_.getFirstVertex(p);let e=_.getLastVertex(p);const s=_.getXY(t),i=_.getXY(e);if(!s.equals(i)&&(_.queryPoint(t,y),e=_.insertVertex(p,r.n,y),Math.abs(s.x-i.x)>C)){const t=_.insertVertex(p,e,y);s.x=(0,a.w)(s.x,i.x,.5),_.setXY(t,s)}}return e.assignCopy(_.getGeometry(d)),!0}const je=210;class Je{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=je*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.a({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,t,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=We(!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 _=c.getAttributeStreamRef(0),d=c.getPointCount();let p=0,f=_.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 S=!1;const v=c.hasNonLinearSegments(),b=new a.P;for(let t=1;t<d;++t){_.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<d?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.e)(this.m_width360,s-f),s=e+p,++x,S=0!==p,b.x=s)}else y||(0,o.$)(E,C,b,P)&&(y=!0);S&&(v&&(0,n.c)("error in geonormalize_ring_ for curves"),_.write(2*t,s)),f=s,E.setCoordsPoint2D(C),C.setCoordsPoint2D(b)}x&&c.notifyModified();const I=c.getXY(0),w=c.getXY(d-1);if(a.P.distance(I,w)<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.P({vd:this.m_inputPoly.getDescription()});for(let i=0,n=this.m_inputPoly.getPathCount();i<n;++i){const n=this.m_polygonRingFlags?this.m_polygonRingFlags[i]?1:0:-1;this.geonormalizeRing(i,n,o,s,t,e,a)}const h=this.m_pannableSR.getTolerance(0),m=this.m_pannableExtent.width()/180;Ts(a,this.m_pannableExtent,.1*h,!1);const g=i.J.constructEmpty();if(g.setCoords({env2D:this.m_pannableExtent}),t){let t=!0;for(let e=0;e<2;e++){t=!0;const e=i.J.constructEmpty();for(let s=0,i=a.getPathCount();s<i;s++)if(a.queryPathEnvelope(s,e),!(g.xmin<=e.xmin&&g.xmax>=e.xmax||e.xmin>=g.xmax||e.xmax<=g.xmin)){t=!1;break}if(t)break;g.move(.5*this.m_width360,0)}t||g.setCoords({env2D:this.m_pannableExtent})}let _=(0,l.c)(a,g,h,m,this.m_progressTracker),d=a!==_;const p=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,f=_.calculateArea2D();let x=0;if(f>0&&p<0)x=1;else if(f<=0&&p>0)if(0===f){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()),p>.99*t&&(x=-1)}}else x=-1;if(0!==x){const t=function(t,e){let s=new r.P({vd:t});s.addEnvelope(e,!1);const i=e.width()/180;return s=(new u.O).execute(s,i,0,0,null),s}(_.getDescription(),g);t.add(_,!1),d=!0,_=t}return d&&(_=(new c.O).execute(_,this.m_pannableSR,!1,this.m_progressTracker)),_}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.a5)()*4;let c=t,g=Number.NaN;const _=a.E.constructEmpty();this.m_bAdjustedAtPoles=0;let d=new r.a({vd:this.m_inputPoly.getDescription()});for(let t=0,l=this.m_inputPoly.getPathCount();t<l;++t){let l=s;const p=new r.a({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|=We(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,S=E.read(0),v=0;const b=new a.P,I=new a.P;let w=!1;const D=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-S;if(T.x=i,Math.abs(r)>this.m_GCSLargeDelta){if(l){const s=x+t-1;let i=x;(!y||t+1<P)&&(i+=t);const n=e.read(2*s),a=(e.read(2*i)-n)*o;Math.abs(r-a)>1*this.m_degree&&(l=!1)}l||(C-=(0,a.e)(this.m_width360,i-S),i=s+C,++v,w=0!==C,T.x=i)}w&&(D&&(0,n.c)("error in geonormalize_ring_ for curves"),E.write(2*t,i)),S=i,b.setCoordsPoint2D(I),I.setCoordsPoint2D(T)}if(v&&p.notifyModified(),c){let t=!1;if(!p.isEmpty()){const e=i.J.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),_.mergeCoordinate(e.xmin+s),_.mergeCoordinate(e.xmax+s),t=_.width()>=h,!t){const t=new m.T;t.setShiftCoords(s,0),p.applyTransformation(t)}}}d.add(p,!1),t&&(d=(()=>{const t=new r.a({vd:d.getDescription()});for(let e=0,s=d.getPathCount();e<s;++e){const s=new r.a({vd:d.getDescription()});s.addPath(d,e,!0);const i=xs(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);t.add(i,!1)}return t})(),c=!1)}else{const t=xs(p,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);d.add(t,!1)}}if(c)return d;const p=this.m_pannableSR.getTolerance(0),f=this.m_pannableExtent.width()/180;return Ts(d,this.m_pannableExtent,.1*p,!1),(0,l.c)(d,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.d)(h.x-o.x),u=i.J.constructEmpty();e.queryLooseEnvelope(u);const c=this.m_pannableExtent.getCenterX();let g=0,_=c-this.m_width360,d=c+this.m_width360;if(l>=0){let t=Math.ceil((_-u.xmin)/this.m_width360);for(t*=this.m_width360;_>u.xmin+t;)t+=this.m_width360;for(;_<u.xmax+t;)t-=this.m_width360;for(g=t,u.width()>720&&(d=_+360*Math.ceil(u.width()/360));d<u.xmax;)d+=this.m_width360}else{let t=Math.ceil((d-u.xmax)/this.m_width360);for(t*=this.m_width360;d<u.xmax+t;)t-=this.m_width360;for(;d>u.xmin+t;)t+=this.m_width360;for(g=t,u.width()>720&&(_=d-360*Math.ceil(u.width()/360));_>u.xmin;)_-=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.a({vd:e.getDescription()});E.add(e,!1),P.assign(e.getXY(s-1));let C=0,S=E.getXY(0).x;for(;l>0?x.xmax<d:x.xmin>_;)x.move(f,0),y.xd=f,e.applyTransformation(y),S+=f,this.m_pannableExtent.xmin<=S&&this.m_pannableExtent.xmax>=S&&(C=E.getPointCount()-1),e.setXY(0,P),P.assign(e.getXY(s-1)),E.addSegmentsFromPath(e,0,0,s-1,!1);const v=new r.P({vd:E.getDescription()});v.add(E,!1);const b=E.getXY(0),I=E.getXY(E.getPointCount()-1),w=l<0?t:!t,D=v.getPointCount()-1;if(w){const t=new a.P(I.x,this.m_pannableExtent.ymax);v.lineTo(t);const e=new a.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);v.lineTo(e);const s=new a.P(b.x,this.m_pannableExtent.ymax);v.lineTo(s)}else{const t=new a.P(I.x,this.m_pannableExtent.ymin);v.lineTo(t);const e=new a.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);v.lineTo(e);const s=new a.P(b.x,this.m_pannableExtent.ymin);v.lineTo(s)}if(v.interpolateAttributesPath(0,D,0),v.getImpl().changeRingStartPoint(C),p>this.m_width360){const t=new r.P({copy:v});y.setShiftCoords(this.m_width360,0),t.applyTransformation(y),v.add(t,!1)}return v}finalizeGeoNormalizeClosedRing(t,e,s){const o=new r.P({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.J.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 c.O).execute(o,this.m_pannableSR,!0,this.m_progressTracker);if(e!==o){const s=e.calculateArea2D();(0,a.d)(t)!==(0,a.d)(s)&&e.reverseAllPaths(),o.assignMove(e)}}let t;if(t=new r.P(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.P({vd:t.getDescription()});u.add(o,!1);const g=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(g){const t=u.calculateArea2D();u.setFillRule(1),u=(new c.O).execute(u,this.m_pannableSR,!0,this.m_progressTracker);const e=u.calculateArea2D();(0,a.d)(t)!==(0,a.d)(e)&&u.reverseAllPaths()}return u}geonormalize_ring_(t,e,s,i,r,o,a){(0,n.g)(0)}}function Ze(t){(0,n.g)(0);const e=function(t){const e=new oi({},!0);return e.m_WKID=t,e}(t),s=new Ke;return s.setVertProj_(e),s}function Qe(t){return!1}class Ke{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new Ti,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return(0,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 $e(t,e,s,i,n){if(t.equals(e))return!1;if(i){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<n;t++)i[t]=(i[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.e)(a),a/=e.m_XYToRadians)),Array.isArray(s)){const t=s;for(let e=0;e<n;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<n;e++){const s=e<<1;t[s]=t[s]*o+a,t[s+1]=t[s+1]*o}}return!0}function ts(){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.a6)(this.m_heightSign,t.m_heightSign)&&(0,a.a6)(this.m_heightMetersPerUnit,t.m_heightMetersPerUnit)&&(0,a.a6)(this.m_heightZ0,t.m_heightZ0)&&(0,a.a6)(this.m_XYToRadians,t.m_XYToRadians)&&(0,a.a6)(this.m_PrimeMeridianDegrees,t.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(t,e){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,e&&(0,n.g)(0),t&&(this.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=t.getPrimem().getLongitude())},initFromGcsAndVcs(t,e){const s=t?t.getPECoordSys():null,i=e?e.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,i)},processUnitParams(t){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=t.m_heightMetersPerUnit,this.m_heightSign=t.m_heightSign,this.m_heightZ0=t.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=t.m_XYToRadians,this.m_PrimeMeridianDegrees=t.m_PrimeMeridianDegrees)}}}class es{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=ts(),this.m_outputUnitParams=ts(),(0,n.g)(t),this.m_geogTran=t,this.m_vertTran=null,this.m_latestID=Cn.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const e=this.m_geogTran.getGeogcs1();Cn.getCode(e);const s=this.m_geogTran.getGeogcs2();Cn.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.c)("vcs not impl");const e=this.m_geogTran.getParameters();null!==e[Sn.PE_PARM_ND]&&(t=0===e[Sn.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.l)(this.m_latestID):(0,a.az)(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.b)("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=Pi(n),h=this.m_geogTran.getGeogcs2(),m=Pi(h);let l=-1,u=-1;l=a.getVcsCode(),u=m.getVcsCode(),s=zi(n,null,0,1),i=zi(h,null,0,1),l>0&&u>0?(r=Ze(l),o=Ze(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 ss(t,e,s,i,n,r,o){let a=null;e&&(a=e.getPEVerticalCoordSys());let h=null;t&&(h=t.getPECoordSys());let m=null;i&&(m=i.getPEVerticalCoordSys());let l=null;if(s&&(l=s.getPECoordSys()),!(h||a||l||m))return!1;const u=ts();u.initFromGcsAndVcsPe(h,a);const c=ts();return c.initFromGcsAndVcsPe(l,m),$e(u,c,n,r,o)}function is(t,e,s,i,n,r,o,a){const h=e,m=t,l=ts();l.initFromGcsAndVcsPe(m,h),a.assign(i?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&$e(l,a,n,r,o)}function ns(t,e,s,i,n,r,o,a,h){const m=ts(),l=ts();m.assign(s?e.m_inputUnitParams:e.m_outputUnitParams),l.assign(n?i.m_outputUnitParams:i.m_inputUnitParams),m.processUnitParams(t),l.processUnitParams(m),m.processUnitParams(l),a>0&&$e(m,l,r,o,a),h.assign(l)}function rs(t,e,s,i,n,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?Sn.PE_TRANSFORM_2_TO_1:Sn.PE_TRANSFORM_1_TO_2;a?Js():Zs(h,r,i,n,t)}}class os{supportsCurves(){return!0}accelerateGeometry(t,e,s){return as(t,e,s)}canAccelerateGeometry(t){return hs(t)}}function as(t,e,s){if(!hs(t))return!1;(0,o.a1)(e,t,!1);let i=0;const a=t.getGeometryType();return(0,n.h)(a)&&(0,r.c)(t)&&0!==s&&(i|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),(0,n.h)(a)&&(0,r.a6)(t)&&0!==s&&(i|=t.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),i>0}function hs(t){return(0,r.c)(t)||(0,r.a6)(t)}class ms extends os{getOperatorType(){return 8}execute(t,e,s,i){return mt(t,e,s,1,i)}}class ls extends os{getOperatorType(){return 3}execute(t,e,s,i=null){return mt(t,e,s,4,i)}}function us(t,e,s){const n=e.getGCSSplitLines();if(null===n)return t;const h=e.getGCS(),l=h.getPannableExtent().width(),u=i.J.constructEmpty();t.queryLooseEnvelope(u);const c=a.E.constructEmpty();u.queryIntervalX(c);const g=n.querySegmentIterator();let _=null;const d=new m.T;for(;g.nextPath();)for(;g.hasNextSegment();){const t=g.nextSegment(),e=t.queryInterval(0,0),s=a.E.constructEmpty();s.setCoordsFromEnvelope(e);let i=0;for(;s.vmax>c.vmin;)s.move(-l),i--;for(;s.vmin<=c.vmax;){if(s.isIntersecting(c)){null===_&&(_=new r.a);const e=new r.L({start:t.getStartXY(),end:t.getEndXY()});0!==i&&(d.setShiftCoords(i*l,0),e.applyTransformation(d)),_.addSegment(e,!0)}s.move(l),++i}}if(null!==_){const e=(0,o.m)(h,_,!0),i=(0,o.f)(e);return(0,p.u)(t,_,i,s)}return t}function cs(t,e,s){let i=t.getName();return sn(i)||(s||e>0?(i=t.toString(Sn.PE_STR_NAME_CANON|Sn.PE_STR_AUTH_NONE),i=function(t){return t.toLocaleUpperCase("en-US")}(i)):i=t.toString(Sn.PE_STR_AUTH_TOP)),i}function gs(t,e=-1){if((e>1||e<-1)&&(0,n.t)("verbosity"),-1===e)return t.toString();{const s=0===e?Sn.PE_STR_AUTH_TOP:Sn.PE_STR_AUTH_ALL;return t.toString(s)}}function _s(t,e,s,r){if(t.isEmpty()||1===s)return t;const a=t.getGeometryType();if(a===n.G.enumPoint){const i=t,n=i.getXY();return 0===fs([n],1,e,s)||n.isNAN()?i.setEmpty():i.setXY(n),t}if(a===n.G.enumMultiPoint){const i=t,n=t.createInstance(),r=i.getPointCount();n.reserve(r);const a=i.getAttributeStreamRef(0),h=i.getDescription().getAttributeCount()>1,m=new o.P,l=Float64Array.from(a.getArray());if(fs(l,r,e,s)>0)for(let t=0,e=2*r;t<e;t+=2)Number.isNaN(l[t])||(h?(i.getPointByVal(t>>1,m),m.setXYCoords(l[t],l[t+1]),n.add(m)):n.addXY(l[t],l[t+1]));return n}let h=t;const u=e.getOneDegreeGCSUnit(),c=90*u,d=180*u,p=360*u,f=e.getCentralMeridian(),P=.5*u,y=i.J.constructEmpty();h.queryEnvelope(y);const E=e.getGCSHorizon(),C=e.getGCSHorisonIsInclusive(),S=E.getGeometryType()===n.G.enumEnvelope,v=i.J.constructEmpty();E.queryEnvelope(v);const b=e.getGCS();if(2!==s&&4!==s||(v.xmin=f-d,v.xmax=v.xmin+p),4===s){if(!(y.width()>p-u)){const t=i.J.constructEmpty();t.setCoords({xmin:y.xmin-u,ymin:v.ymin,xmax:y.xmax+u,ymax:v.ymax}),h=(new g.O).execute(h,t,b,r);let e=Math.floor((f-y.getCenterX())/p);for(y.move(e*p,0);y.xmin>v.xmax;)e-=1,y.move(-p,0);for(;y.xmin<v.xmin;)e+=1,y.move(p,0);if(0!==e){const t=new m.T;t.setShiftCoords(e*p,0),h.applyTransformation(t)}return h}s=2}if(2===s&&(v.xmin=f-d,v.xmax=v.xmin+p),y.ymin<-c||y.ymax>c){const t=i.J.constructEmpty();if(t.setCoords({xmin:y.xmin-u,ymin:-c,xmax:y.xmax+u,ymax:c}),h=(new g.O).execute(h,t,b,r),h.isEmpty())return h;h.queryEnvelope(y)}if(C&&(v.ymax<y.ymin||v.ymin>y.ymax))return h.createInstance();y.width()>p&&(h=ws(h,f-d,p,b,!0,0,!0,r),h.queryEnvelope(y));let I=function(t,e,s,i,n){return t>=s&&e<=i?0:Is(.5*(e+t),s,i,n)}(y.xmin,y.xmax,v.xmin,v.xmax,p);if(0!==I&&y.move(I,0),y.xmax>v.xmax||y.xmin<v.xmin){if(y.xmax>v.xmax)for(;y.xmin>=v.xmax;)y.move(-p,0),I-=p;for(;y.xmin<v.xmax-p;)y.move(p,0),I+=p}const w=(0,o.a1)(b,E,!1);if(0!==I){const t=new m.T;t.setShiftCoords(I,0),h.applyTransformation(t),I=0}if(C){if(S&&v.containsEnvelope(y))return h;const t=new Array(2);for(let e=0;e<2;e++){let s;if(S?s=(0,n.h)(a)?(0,l.c)(h,v,w,P,r):(0,l.c)(h,v,w,0,r):(s=(new _.O).execute(h,E,b,r),s===E&&(s=s.clone())),v.xmin<=y.xmin&&v.xmax>=y.xmax)return s;if(v.xmin>=y.xmin&&v.xmax<=y.xmax)return s;if(t[e]=s,0===e){y.move(-p,0);const t=new m.T;t.setShiftCoords(-p,0),h.applyTransformation(t)}}return(0,n.h)(a)?t[0].add(t[1],!1):(0,n.c)("intersect_with_GCS_horizon: unexpected geometry type"),t[0]}{if(v.ymax<y.ymin||v.ymin>y.ymax)return h;let t=0;for(;!h.isEmpty()&&y.xmax>v.xmin;){if(0!==t){const e=new m.T;e.setShiftCoords(t,0),h.applyTransformation(e)}if((new ls).execute(h,E,b,r)||(h=(new x.O).execute(h,E,b,r),E===h&&(h=h.clone())),0!==t){const e=new m.T;e.setShiftCoords(-t,0),h.applyTransformation(e)}t-=p,y.move(-p,0)}return h}}function ds(t,e,s,i,n,m){const l={stack:[],error:void 0,hasError:!1};try{if(2===m)return function(t,e,s,i,n){if(Math.abs(s.x-i.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>a.t||Math.abs(i.y)>a.t)return Number.NaN;if((Math.abs(s.y)===a.t||Math.abs(i.y)===a.t)&&s.x!==i.x)return Number.NaN;const{first:h,second:m}=(0,a.aE)(s.x,i.x);let l=n;if(l=D(l,h,m),!a.E.construct(s.x,i.x).containsCoordinate(l))return Number.NaN;const u=r.T.constructPoint2D(s),c=r.T.constructPoint2D(i),g=A(1,e,u),_=A(1,e,c),d=g.crossProductVector(_);if(d.z.isZero())return s.y;const p=d.x.divE(d.z.negate()),f=d.y.divE(d.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=T(1,e,a.P.construct(l,y)),C=o.v.construct(E.x,E.y,-E.z),S=d.value().dotProduct(E),v=d.value().dotProduct(C);return Math.abs(v)<Math.abs(S)&&(y=-y),y}(0,e,s,i,n);if(Math.abs(s.x-i.x)>=Math.PI||!ei(s.x,i.x,n))return Number.NaN;s.x>i.x&&(i=(0,a.b)(s,s=i));const u=(0,h.b)(l,new En,!1),c=(0,h.b)(l,new En,!1),g=(0,h.b)(l,new En,!1),_=s.clone();Tn.geodeticDistance(t,e,s.x,s.y,i.x,i.y,c,u,null,m);const d=c.val;let p=0,f=1;for(;d*(f-p)>1e-12*t;){const r=.5*(p+f);if(Tn.geodeticCoordinate(t,e,s.x,s.y,d*r,u.val,c,g,m),_.x=c.val,_.y=g.val,_.x===n)return _.y;if(ei(s.x,_.x,n))f=r;else{if(!ei(i.x,_.x,n))return Number.NaN;p=r}}return _.y}catch(t){l.error=t,l.hasError=!0}finally{(0,h.c)(l)}}function ps(t,e,s,i){for(let n=0,r=0;n<i;n++,r+=2)e[s+n].x=t[r],e[s+n].y=t[r+1]}function fs(t,e,s,r){if(0===e||1===r)return e;const h=function(t,e){let s;if(Array.isArray(t)){const i=t;s=new Float64Array(2*e);for(let t=0,n=0;t<e;t++,n+=2)s[n]=i[t].x,s[n+1]=i[t].y}else s=t;return s}(t,e);if(2===r){const i=s.getPannableExtentInGCS();let n=e;for(let t=0,s=2*e;t<s;t+=2)(h[t+1]>i.ymax||h[t+1]<i.ymin)&&(h[t]=Number.NaN,n--);return n?(Ds(h,e,i.xmin,i.width(),!0),t!==h&&ps(h,t,0,e),n):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 0;const _=i.J.constructEmpty();_.setFromPoints(h,e);const d=s.getGCSHorizon(),f=s.getGCSHorisonIsInclusive(),x=d.getGeometryType()===n.G.enumEnvelope,P=i.J.constructEmpty();if(d.queryEnvelope(P),f&&(P.ymax<_.ymin||P.ymin>_.ymax))return 0;if(f)if(Ds(h,e,P.getCenterX()-u,c,!0),g=e,x)for(let t=0,s=2*e;t<s;t+=2)P.containsCoords(h[t],h[t+1])||(h[t]=Number.NaN,g--);else{const t=(0,o.a1)(s.getGCS(),d,!1),i=new a.P;for(let s=0,n=2*e;s<n;s+=2)i.setCoords(h[s],h[s+1]),0!==(0,p.i)(d,i,t)||(h[s]=Number.NaN,g--)}else{Ds(h,e,-u,c,!0),g=e;const t=(0,o.a1)(s.getGCS(),d,!1),i=new a.P;for(let s=0,n=2*e;s<n;s+=2){i.setCoords(h[s],h[s+1]),i.isNAN()&&g--;const e=Is(i.x,P.xmin,P.xmax,c);i.x+=e,0!==(0,p.i)(d,i,t)&&(h[s]=Number.NaN,g--)}}return g>0&&Array.isArray(t)&&ps(h,t,0,e),g}function xs(t,e,s,i,r,o){if(e.isPannable()||(0,n.t)("fold_into_360_degree_range"),t.isEmpty())return t;let a,h;if(2===e.getCoordinateSystemType()){const t=e.getPannableExtent();h=t.xmin,a=t.width()}else{const t=e.getOneDegreeGCSUnit();a=360*t,h=s-180*t}return ws(t,h,a,e,i,r,!0,o)}function Ps(t,e,s,i){let n,r;if(2===s.getCoordinateSystemType()){const t=s.getPannableExtent();n=t.xmin,r=t.width()}else{const t=s.getOneDegreeGCSUnit();r=360*t,n=i-180*t}Ds(t,e,n,r)}function ys(t,e){const s=e.width();let i=(0,a.u)(t-e.vmin,s);return i<0&&(i+=s),e.snapClip(i+e.vmin)}function Es(t,e,s){return t>e.xmax&&t-e.xmax<s?e.xmax:t<e.xmin&&e.xmin-t<s?e.xmin:t}function Cs(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 Ss(t,e,s,i,n){const a=new r.E,h=a.addGeometry(t);return vs(a,h,e,(0,o.a1)(e,t,!1),s,i,n),a.getGeometry(h)}function vs(t,e,s,i,o,m,l){const u={stack:[],error:void 0,hasError:!1};try{(0,n.g)(Ri()),s.isPannable()||(0,n.r)("insert_geodetic_points");const c=s.getPannableExtent(),g=s.getGCS(),_=Yi();g.querySpheroidData(_);const d=g.getUnit().getUnitToBaseFactor(),p=_.majorSemiAxis,f=_.e2;let x=0;const P=new a.E;c.queryIntervalX(P);let y=null;const E=new Array(4);2===s.getCoordinateSystemType()?(y=s.getPECoordSys(),m?(E[0]=ys(l,P),E[1]=c.getCenterY(),vn.projToGeog(y,1,E),x=E[0]*d):(E[0]=c.getCenterX(),E[1]=l,vn.projToGeog(y,1,E),x=E[1]*d)):x=l*d,m||0===x||2===o||(0,n.r)("insert_geodetic_points: 1");const C=(0,h.b)(u,new En,!1),S=new a.P,v=new a.P,b=new a.P,I=new a.P,w=new a.P,D=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]=ys(b.x,P),E[1]=b.y,E[2]=ys(I.x,P),E[3]=I.y,Ls(y,2,E,0),w.x=E[0]*d,w.y=E[1]*d,D.y=E[3]*d):(w.x=b.x*d,w.y=b.y*d,D.y=I.y*d),D.x=(I.x-b.x)*Math.PI*2/P.width()+w.x;let i=0;const n=(0,a.m)(a.P,2);if(m){if(v.x=x,v.y=ds(p,f,w,D,x,o),Number.isNaN(v.y))break;n[0]=v,i=1}else if(2===o){const t=[0,0];if(i=X(0,f,w,D,x,t),!i)break;n[0].x=t[0],n[0].y=x,2===i&&(n[1].x=t[1],n[1].y=x)}else{if(v.x=si(p,f,w,D,o),Number.isNaN(v.x))break;v.y=0,n[0]=v,i=1}let r=-1;for(let h=0;h<i;h++){Tn.geodeticDistance(p,f,w.x,w.y,D.x,D.y,C,null,null,o);const i=C.val;Tn.geodeticDistance(p,f,w.x,w.y,n[h].x,n[h].y,C,null,null,o);const u=C.val;2===s.getCoordinateSystemType()?(E[0]=n[h].x/d,E[1]=n[h].y/d,vn.geogToProj(y,1,E),m?(S.y=E[1],S.x=l):(S.x=ii(E[0],b.x,I.x,P),S.y=l)):m?(S.x=l,S.y=n[h].y/d):(S.x=ii(n[h].x/d,b.x,I.x,P),S.y=l);const c=i>0?(0,a.c)(u/i,0,1):.5;if(0===c||1===c)continue;if(r>c)continue;const g=t.getPrevVertex(e);t.splitSegment(g,[c],1);const _=t.getNextVertex(g);t.setXYCoords(_,S.x,S.y),r=c}}while(0);b.setCoordsPoint2D(I)}}}catch(t){u.error=t,u.hasError=!0}finally{(0,h.c)(u)}}function bs(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.J.constructEmpty();t.queryEnvelope(r);const a=i.J.constructEmpty();a.setCoords({env2D:s}),a.xmin=r.xmin,a.xmax=r.xmax,a.inflateCoords(.01*a.height(),0);const h=(0,o.c)(e,r,!1);let m;return m=a.containsEnvelope(r)?t:(0,l.c)(t,a,h,0,null),m}function Is(t,e,s,i){return(0,a.ay)((.5*(s+e)-t)/i)*i}function ws(t,e,s,o,h,u,c,g){const _=t.getGeometryType(),d=a.E.constructEmpty();d.setCoords(e,e+s);const p=[0];if(_===n.G.enumPoint){const e=t;if(p[0]=e.getX(),Cs(p,d,c)){const e=h?t:t.clone();return e.setX(p[0]),e}return t}const x=i.J.constructEmpty();if(t.queryEnvelope(x),x.isEmpty())return t;if(_===n.G.enumMultiPoint){const e=h?t:t.clone(),s=e.getImpl(),i=s.getAttributeStreamRef(0),n=2*s.getPointCount();let r=!1;for(let t=0;t<n;t+=2)p[0]=i.read(t),Cs(p,d,c)&&(i.write(t,p[0]),r=!0);return r&&s.notifyModifiedFlags(2001),e}const P=a.E.constructEmpty();if(x.queryIntervalX(P),d.contains(P))return d.vmax,P.vmax,t;const y=i.J.constructEmpty();if(y.setCoords({env2D:x}),0===P.width()){let e=P.vmin;e+=Math.ceil((d.vmin-e)/s)*s,e=d.snapClip(e);const i=h?t:t.clone();return i.setAttributeBasic(0,0,e),i}if(_===n.G.enumEnvelope){const e=h?t:t.clone();return x.intersect(y),e.setEnvelope(x),e}const E=.1*Math.max(x.height(),x.width())*1;y.inflateCoords(0,E);let C=t;const S=o.getTolerance(0),v=new m.T;for(;;){const t=Math.floor((P.vmin-e)/s),i=Math.ceil((P.vmax-e)/s);if(!(i-t>3))break;{const r=Math.floor(.5*(i+t));y.xmin=x.xmin-E,y.xmax=e+s*r;const a=(0,l.c)(C,y,S,u,g);y.xmin=y.xmax,y.xmax=x.xmax+E;const h=(0,l.c)(C,y,S,u,g);v.setShiftCoords((r-i)*s,0),h.applyTransformation(v),_===n.G.enumPolygon?C=(new f.O).execute(a,h,o,g):(C=a,C.add(h,!1)),C.queryEnvelope(x),x.queryIntervalX(P)}}y.xmin=e,y.xmax=e+s;const b=i.J.constructEmpty();b.setCoords({env2D:y}),b.inflateCoords(S,0);const I=Math.floor((x.xmin-y.xmin)/s)*s;let w;I?(y.move(I,0),v.setShiftCoords(-I,0)):v.setIdentity(),w=_===n.G.enumPolyline?new r.a({vd:C.getDescription()}):new r.P({vd:C.getDescription()});const D=i.J.constructEmpty(),T=i.J.constructEmpty();for(;x.xmax>y.xmin;){const t=(0,l.c)(C,y,S,0,g);t.queryEnvelope(T);let e=!1;e=_===n.G.enumPolyline?!t.isEmpty()&&(T.width()>S||T.height()>S):!t.isEmpty()&&(_!==n.G.enumPolygon||T.width()>S),e&&(t.applyTransformation(v),t.queryEnvelope(T),w.queryEnvelope(D),D.inflateCoords(S,S),D.isIntersecting(T)&&_===n.G.enumPolygon?w=(new f.O).execute(w,t,o,g):w.add(t,!1)),y.move(s,0),v.shiftCoords(-s,0)}return w}function Ds(t,e,s,i,n=!0){const r=new a.E;r.setCoords(s,s+i);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,Cs(o,r,n),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],Cs(o,r,n),s[e]=o[0])}}}function Ts(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=Es(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=Es(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.J.constructEmpty();n.queryEnvelope(r),r.xmin=Es(r.xmin,e,s),r.xmax=Es(r.xmax,e,s),n.setEnvelope(r)}else if(o===n.G.enumPoint){const i=t;i.setX(Es(i.getX(),e,s))}else(0,n.c)("")}function Ns(t,e,s){const i=new a.P;return i.x=Es(t.x,e,s),i.y=t.y,i}function As(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()===Sn.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Yi();t.querySpheroidData(n);const r=s.getParameters();if(null===r[Sn.PE_PARM_LAM0])return 0;if(null===r[Sn.PE_PARM_PHI0])return 0;const o=[r[Sn.PE_PARM_LAM0].getValue(),r[Sn.PE_PARM_PHI0].getValue()];vn.geogToProj(s,1,o);const h=new a.P(o[0],o[1]),m=i.J.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,_=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;_-=g/180,g*=c,_*=c;for(let t=0;t<4;t++){const e=a.P.distance(l[t],h);if(e>g)u++;else if(e>_)return-1}if(0===u)return 1;if(4===u){const t=i.J.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.J.constructEmpty();h.queryEnvelope(s);const n=(0,o.c)(c,s,!1);m=(0,l.c)(t,s,n,5e4*e.getOneMeterPCSUnit(),r)}else(new ms).execute(h,t,c,r)||(m=(new _.O).execute(m,h,c,r),m===h&&(m=m.clone()))}else if(e.isPannable()){const t=i.J.constructEmpty();m.queryEnvelope(t);const o=e.getPannableExtent();o.containsEnvelope(t)||(Ts(m,o,e.getTolerance(0)),2!==s&&4!==s||(m=bs(m,e)),4!==s?m=xs(m,e,0,!0,1e5*e.getOneMeterPCSUnit(),r):h===n.G.enumPolygon&&t.width()>2*o.width()&&(m=ws(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 Ts(t,e.getPannableExtent(),e.getTolerance(0)),t;{const s=i.J.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.J(s.xmin-t,a.ymin,s.xmax+t,a.ymax);if(o=(new g.O).execute(o,n,e,r),o.isEmpty())return o}return h===n.G.enumPolygon&&s.width()>2*a.width()&&(o=ws(o,-2*a.width(),2*a.width(),e,!0,0,!0,r)),o}}function Gs(t,e){const s=e.getPointCount();if(!s)return;const i=e.getImpl(),n=i.getAttributeStreamRef(0),r=t;vn.geogToProj(r,s,n.getArray()),i.notifyModifiedFlags(2001)}function Ms(t,e,s,i){if(!s)return;const n=t.getPECoordSys();if(1===s){const s=[e[0].x,e[0].y];if(vn.geogToProj(n,1,s),i){const{first:i,second:n}=t.m_peCoordSysVal.getGeogToProjFactors();s[0]=i*(e[0].x-t.getCentralMeridian())+n}return void e[0].setCoords(s[0],s[1])}const 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(vn.geogToProj(n,c,l),i){const{first:s,second:i}=t.m_peCoordSysVal.getGeogToProjFactors();for(let t=0;t<c;++t)l[t<<1]=s*(e[u+t].x-m)+i}if(r)for(let t=0,s=u;t<c;t++,s++){const i=t<<1,n=l[i],r=(0,a.d)(n),u=e[s].x-m;r*(0,a.d)(u)<0&&Math.abs(n)>h&&(l[i]-=r*o)}ps(l,e,u,c),u+=c}}}function qs(t,e,s,i){const n=t.getSRToGCSTransform();return(new fe).transform(n,e,s,i,!1)}function Fs(t,e,s,n){const o=new r.M({vd:e.getDescription()});let a;o.addPoints(e,0,-1),a=(new fe).execute(o,t,n);const h=e.getPointCount();if(s.setEmpty(),t.getInputSR().isPannable()){if(h!==a.getPointCount())return!1;const n=new i.J;e.queryEnvelope(n);const r=new i.J;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 Vs(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=()=>{vn.geogToProj(h,i,l)};const c=t.isPannable()&&!s,g=c?t.getPannableExtent().width():0,_=179*g/360;if(t.isPannable()&&(m=t.getCentralMeridian(),s)){const e=t.m_peCoordSysVal.getGeogToProjFactors(),s=e.first,n=e.second;u=()=>{vn.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],i=(0,a.d)(s),n=o.read(e)-m;i*(0,a.d)(n)<0&&Math.abs(s)>_&&(l[e]+=-i*g)}o.writeRangeFromArray(0,2*i,l,!0,1),r.notifyModifiedFlags(2001)}function Ys(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const i=[e.getStartXY(),e.getEndXY()];Ms(t,i,2,s),e.setStartXY(i[0]),e.setEndXY(i[1]),e.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const i=(0,a.m)(a.P,4);e.queryControlPoints(i),Ks(t,i,4,s),e.setControlPoints(i)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===e.projectionBehavior())!function(t,e,s){ti(!0,t,0,e,s)}(t,e,s);else{const i=e.isClosed()&&e.isMajor(),n=[e.getStartXY(),i?e.getCenter():e.getEndXY()],r=[n[0].clone(),n[1].clone()];Ks(t,r,2,s);const o=new m.T;o.initializeFromTwoPointsArray(n,r),e.applyTransformation(o);const a=i?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.c)("")}}function Xs(t,e,s){if(!e.hasNonLinearSegments())return void Vs(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(),_=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,_,!1),Ys(t,_.get(),s),e||_.get().getStartXY().equals(m)||_.get().moveTo(m),n!==i)c.addSegment(_.get(),e);else{if(e){const t=new o.P;_.get().queryStart(t),c.startPathPoint(t)}c.closeLastPathWithSegment(_.get())}m.assign(_.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 _=g.getAttributeStreamRef(0),d=c.getAttributeStreamRef(0);for(let e=g.getPathStart(n),c=g.getPathEnd(n);e<c;){if(s=_.readRange(e,o),vn.geogToProj(i,o,s),h)for(let t=0;t<o;t++){const e=t<<1,i=s[e],n=(0,a.d)(i),r=_.read(2*(0+t))-u;n*(0,a.d)(r)<0&&Math.abs(i)>l&&(s[e]+=-n*m)}d.writeRangeFromArray(e,o,s,!0,1),e+=o,r-=o,o=Math.min(r,t)}}e.assignMove(c)}function Rs(t,e,s){let i=s.getPointCount();if(!i)return;const n=s.getImpl(),r=n.getAttributeStreamRef(0);let o=Math.min(i,1e3),h=0;const m=t.getPECoordSys();Number.isNaN(e)&&(e=0);const l=t.isPannable(),u=t.getOneDegreeGCSUnit(),c=360*u,g=179*u;let _;for(;i;){if(_=r.readRange(2*h,2*o),Ls(m,o,_,e),l)for(let t=0;t<o;t++){const s=t<<1,i=_[s]-e,n=(0,a.d)(i),o=r.read(2*(h+t));n*(0,a.d)(o)<0&&Math.abs(i)>g&&(_[s]+=-n*c)}r.writeRangeFromArray(2*h,2*o,_,!0,1),h+=o,i-=o,o=Math.min(i,1e3)}n.notifyModifiedFlags(2001)}function ks(t,e,s){switch(s.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const i=[s.getStartXY(),s.getEndXY()];Hs(t,e,i,2),s.setStartXY(i[0]),s.setEndXY(i[1]),s.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const i=(0,a.m)(a.P,4);s.queryControlPoints(i),$s(t,e,i,4),s.setControlPoints(i)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===s.projectionBehavior())!function(t,e,s){ti(!1,t,e,s,!1)}(t,e,s);else{const i=s.isClosed()&&s.isMajor(),n=[s.getStartXY(),i?s.getCenter():s.getEndXY()],r=[n[0].clone(),n[1].clone()];$s(t,e,r,2);const o=new m.T;o.initializeFromTwoPointsArray(n,r),s.applyTransformation(o);const a=i?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.c)("")}}function Ls(t,e,s,i){const r=vn.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 Bs(t,e,s){if(!s.hasNonLinearSegments())return void Rs(t,e,s);if(s.isEmpty())return;const i=t.getPECoordSys();Number.isNaN(e)&&(e=0);const n=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,i=-1;const n=c.getPathStart(r),h=n+c.getSegmentCountPath(r);c.isClosedPath(r)&&(i=h-1);const m=new a.P;for(let r=n;r<h;++r){if(c.getSegmentBuffer(r,g,!1),ks(t,e,g.get()),s||g.get().getStartXY().equals(m)||g.get().moveTo(m),r!==i)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 _=c.getAttributeStreamRef(0),d=u.getAttributeStreamRef(0);for(let s=c.getPathStart(r),u=c.getPathEnd(r);s<u;){if(o=_.readRange(2*s,2*g),Ls(i,g,o,e),n)for(let t=0;t<g;t++){const i=t<<1,n=o[i]-e,r=(0,a.d)(n),h=_.read(2*s);r*(0,a.d)(h)<0&&Math.abs(n)>l&&(o[i]+=-r*m)}d.writeRangeFromArray(2*s,2*g,o,!0,1),s+=g,h-=g,g=Math.min(h,t)}}s.assignMove(u)}function Hs(t,e,s,i){const n=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<i;){for(let e=t;e<i&&s[e].isNAN();++e)t++;let o=Math.min(256,i-t);if(o>0){for(let e=1,i=t+1;e<o;++e,++i)if(s[i].isNAN()){o=e;break}for(let e=0;e<o;e++){const i=e<<1;l[i]=s[t+e].x,l[i+1]=s[t+e].y}if(Ls(n,o,l,e),r)for(let i=0,n=t;i<o;++i,++n){const t=i<<1,r=s[n].x,o=l[t]-e,u=(0,a.d)(o);u*(0,a.d)(r)<0&&Math.abs(o)>m&&(l[t]-=u*h)}for(let e=0;e<o;e++){const i=e<<1;s[t+e].x=l[i],s[t+e].y=l[i+1]}t+=o}}}function zs(t,e,s,i){(0,n.g)(0)}function Us(t,e,s){let i=e.getPointCount();if(!i)return!1;const n=e.getImpl(),r=n.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=n.getAttributeStreamRef(1));const g=t.getDatumTransformation(),_=!!g&&1===g.getType();if(_||null===o||(zs(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(),_=[0];for(let t=1,e=2*i;t<e;)_[0]=g[t],c|=(0,a.aA)(_,s,o)?1:0,g[t]=_[0],t+=2;if(0!==e||1!==t){c=1;const s=r.getArray();for(let n=0,r=2*i;n<r;){let i=s[n];i*=t,i+=e,s[n]=i,s[n+1]*=t,n+=2}}return 0!==c&&n.notifyModifiedFlags(2001),!!c}let d=Math.min(i,1e3);const p=new Array(d),f=new Array(d);let x=null;null!==o&&(x=new Float64Array(d));let P=0,y=Number.NaN,E=Number.NaN;const C=360*u,S=u/l;s&&(E=90*u,y=89.9*l,f.fill(0));let v=!0,b=0;for(;i;){let t=!1;const e=r.readRange(2*P,2*d);for(let t=0;t<d;t++)p[t]=e[t<<1];if(s)for(let s=0;s<d;s++){const i=1+(s<<1),n=Math.abs(e[i])-y;if(n>0){const r=e[i];e[i]=(0,a.e)(y,r),f[s]=(0,a.e)(n,r),t=!0}}const n=e[0];if(_){const t=g;x&&o.queryRange(P,d,x,!0,1),t.transform(!1,e,x,d),x&&o.writeRangeFromArray(P,d,x,!0,1)}else g.transform(!1,e,d);v&&(b=e[0]-S*n,v=!1);for(let t=0;t<d;t++){const s=t<<1,i=e[s]-p[t]*S-b;Math.abs(i)>200&&(e[s]+=i>0?-C:C)}if(t){for(let t=0;t<d;t++)if(f[t]){const s=1+(t<<1);e[s]+=S*f[t],e[s]>E?e[s]=E:e[s]<-E&&(e[s]=-E)}f.fill(0)}r.writeRangeFromArray(2*P,2*d,e,!0,1),c&&o&&o.writeRangeFromArray(P,d,x,!0,1),P+=d,i-=d,d=Math.min(i,1e3)}return n.notifyModifiedFlags(2001),!0}function Os(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return function(t,e,s){const i=[e.getStartXY(),e.getEndXY()];let n=null;e.hasAttribute(1)&&(n=[0,0],n[0]=e.getAttributeAsDbl(0,1,0),n[1]=e.getAttributeAsDbl(1,1,0));const r=Qs(t,i,n,2,s);return e.setStartXY(i[0]),e.setEndXY(i[1]),n&&(e.setStartAttribute(1,0,n[0]),e.setEndAttribute(1,0,n[1])),e.normalizeAfterEndpointChange(),r}(t,e,s);case n.G.enumBezier:return function(t,e,s){const i=(0,a.m)(a.P,4);e.queryControlPoints(i);let n=null;e.hasAttribute(1)&&(n=[0,0,0,0],n[0]=e.getAttributeAsDbl(0,1,0),n[3]=e.getAttributeAsDbl(1,1,0),n[1]=(0,a.w)(n[0],n[3],.5),n[2]=n[1]);const r=Qs(t,i,n||null,i.length,s);return e.setControlPoints(i),n&&(e.setStartAttribute(1,0,n[0]),e.setEndAttribute(1,0,n[3])),e.normalizeAfterEndpointChange(),r}(t,e,s);case n.G.enumEllipticArc:return function(t,e,s){if(0===e.projectionBehavior())return function(t,e,s){const i=[e.getStartXY(),e.getEndXY(),e.getInteriorPoint(),e.getCenter()];let n=4;e.isDegenerateToLine()&&(n=2);const 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.w)(o[0],o[1],.5);o[2]=t,o[3]=t}const h=e.getStartXY().equals(e.getEndXY())&&!e.isDegenerateToLine(),m=Qs(t,i,o,n,s);return h?e.constructCircleCenterAndPoint(i[3],i[0],!e.isClockwise()):e.isDegenerateToLine()?e.constructLineCircularArc(i[0],i[1]):e.constructCircularArcThreePoint(i[0],i[1],i[2]),o&&(e.setStartAttribute(1,0,o[0]),e.setEndAttribute(1,0,o[1])),m}(t,e,s);const i=e.getStartXY().equals(e.getEndXY()),n=(0,a.m)(a.P,3),r=(0,a.m)(a.P,3);let o=null;n[0].assign(e.getStartXY()),n[1].assign(i?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.w)(o[0],o[1],.5),i&&(o[1]=o[2])),r[0].setCoordsPoint2D(n[0]),r[1].setCoordsPoint2D(n[1]);const l=new m.T;if(i||e.isDegenerateToLine())h=Qs(t,r,o,2,s),l.initializeFromTwoPoints(n[0],n[1],r[0],r[1]);else{const i=new a.P;e.queryCoord2D(.5,i),n[2].setCoordsPoint2D(i),r[2].setCoordsPoint2D(i),h=Qs(t,r,o,3,s),l.setFromTwoTriangles(n,r)}return l.isIdentity()||(e.applyTransformation(l),e.setStartXY(r[0]),e.setEndXY(i?r[0]:r[1]),e.normalizeAfterEndpointChange()),o&&(e.setStartAttribute(1,0,o[0]),e.setEndAttribute(1,0,i?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.c)("")}}function Ws(t,e,s){if(!e.hasNonLinearSegments())return Us(t,e,s);if(e.isEmpty())return!1;const i=e.createInstance();i.reserveParts(e.getPointCount(),e.getPathCount());const n=e.getImpl(),h=new r.S;for(let r=0,m=e.getPathCount();r<m;++r){let e=!0,m=-1;const l=n.getPathStart(r),u=l+n.getSegmentCountPath(r);n.isClosedPath(r)&&(m=u-1);const c=new a.P;for(let r=l;r<u;++r){if(n.getSegmentBuffer(r,h,!1),Os(t,h.get(),s),e||h.get().getStartXY().equals(c)||h.get().moveTo(c),r!==m)i.addSegment(h.get(),e);else{if(e){const t=new o.P;h.get().queryStart(t),i.startPathPoint(t)}i.closeLastPathWithSegment(h.get())}c.assign(h.get().getEndXY()),e=!1}}return e.assignMove(i),!0}function js(t,e,s,i,n,r){if(t.isIdentityGeogToGeog()){const s=90*t.getInputSR().getOneDegreeGCSUnit();let n=0;const r=[0];for(let t=0;t<i;t++)r[0]=e[t].y,n|=(0,a.aA)(r,-s,s)?1:0,e[t].y=r[0];return n}const o=t.getInputSR(),h=t.getOutputSR(),m=o.getVCS(),l=h.getVCS(),u=o.getOneDegreeGCSUnit(),c=90*u,g=h.getOneDegreeGCSUnit(),_=t.isVertical(),d=t.getDatumTransformation(),p=!!d&&1===d.getType();if(_||(s=null),!d||0===d.count()){let t=0;const n=[0];for(let s=0;s<i;s++)n[0]=e[s].y,t|=(0,a.aA)(n,-c,c)?1:0,e[s].y=n[0];return t|=ss(o.getGCS(),m,h.getGCS(),l,e,s,i)?1:0,t}p||null===s||zs();let f=Math.min(i,1024);const x=new Array(f),P=(0,a.f)(f,0);let y=0,E=Number.NaN,C=Number.NaN;const S=360*g,v=g/u;n&&(C=90*g,E=89.9*u);let b=!0,I=0,w=i;for(;w;){let t=!1;for(let t=0;t<f;t++)x[t]=e[t+y].x;if(n)for(let s=0;s<f;s++){const i=Math.abs(e[s+y].y)-E;if(i>0){const n=e[s+y].y;e[s+y].y=(0,a.e)(E,n),P[s]=(0,a.e)(i,n),t=!0}}const i=e[0].x;p?d.transform(!1,e,s,f):d.transform(!1,e,f),b&&(I=e[0].x-v*i,b=!1);for(let t=0;t<f;t++){const s=e[y+t].x-x[t]*v-I;Math.abs(s)>200&&(s>0?e[y+t].x-=S:e[y+t].x+=S)}if(t){for(let t=0;t<f;t++)P[t]&&(e[y+t].y+=v*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,w-=f,f=Math.min(w,1024)}return 1}function Js(t,e,s,i,r){return(0,n.g)(0),0}function Zs(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.aB)(s):s;const m=bn.geogToGeog(t,e,h,null,r);return o&&(0,a.aC)(h,s),m}function Qs(t,e,s,i,n,r){let o=0,a=!0,h=0;for(let r=0;r<i;++r)e[r].isNAN()?a||(o|=js(t,e.slice(h,r-h),s?s.slice(h,r-h):null,r-h,n),h=r,a=!0):a&&(h=r,a=!1);return a||(o|=js(t,0===h?e:e.slice(h),s?0===h?s:s.slice(h):null,i-h,n)),0!==o}function Ks(t,e,s,i){Ms(t,e,s,i)}function $s(t,e,s,n){Hs(t,e,s,n);const r=new i.J;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 ti(t,e,s,i,n){const r=(0,a.m)(a.P,3);let o=0,h=!1,m=!1;const l=i.isDegenerateToLine();l?(r[0].assign(i.getStartXY()),r[1].assign(i.getEndXY()),r[2].setCoords(0,0),o=2):i.isClosed()&&i.isMajor()?(h=!0,m=!i.isClockwise(),r[0].assign(i.getStartXY()),r[1].assign(i.getCenter()),r[2].setCoords(0,0),o=2):(r[0].assign(i.getStartXY()),r[1].assign(i.getEndXY()),r[2].assign(i.getInteriorPoint()),o=3),t?Ks(e,r,o,n):$s(e,s,r,o),l?i.constructLineCircularArc(r[0],r[1]):h?i.constructCircleCenterAndPoint(r[1],r[0],m):i.constructCircularArcThreePoint(r[0],r[1],r[2])}function ei(t,e,s){const i=(0,r.a8)(t),n=(0,r.a8)(e),o=(0,r.a7)(i,n),a=(0,r.a7)(i,(0,r.a8)(s));return 0===a||o>0&&a>0&&a<=o||o<0&&a<0&&a>=o}function si(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 X(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.b)(o,new En,!1),c=(0,h.b)(o,new En,!1),g=(0,h.b)(o,new En,!1),_=new a.E;if(_.setCoords(m.y,l.y),!_.containsCoordinate(0)||Math.abs(m.x-l.x)>=Math.PI)return Number.NaN;if(m.x===l.x)return m.x;Tn.geodeticDistance(t,e,m.x,m.y,l.x,l.y,c,u,null,r);const d=c.val;let p=0,f=1;const x=m.clone();for(;d*(f-p)>1e-12*t;){const s=.5*(p+f);if(Tn.geodeticCoordinate(t,e,m.x,m.y,d*s,u.val,c,g,r),x.x=c.val,x.y=g.val,_.setCoords(m.y,x.y),0===x.y)return x.x;if(_.containsCoordinate(0))f=s;else{if(_.setCoords(l.y,x.y),!_.containsCoordinate(0))return(0,n.g)(!1),Number.NaN;p=s}}return x.x}catch(t){o.error=t,o.hasError=!0}finally{(0,h.c)(o)}}function ii(t,e,s,i){const n=new a.E;n.setCoords(e,s);const r=i.width();let o=Math.floor((t-e)/r)*r+t;const h=n.getCenter();for(;Math.abs(o-h)>Math.abs(o+r-h);)o+=r;return o}class ni extends d.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 ri{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.J.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.J.constructEmpty(),this.m_pannableExtentGCS=i.J.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=t,this.m_WKID=Cn.getCode(t),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=cs(t,0,!0),this.m_hashCode=(0,a.az)(this.m_canonicalWkt)):this.m_hashCode=(0,a.N)(this.m_WKID);const s=this.m_peCoordSys.getType();this.m_csType=s===Sn.PE_TYPE_PROJCS?2:1,(0,n.g)(s===Sn.PE_TYPE_PROJCS||s===Sn.PE_TYPE_GEOGCS),s===Sn.PE_TYPE_PROJCS&&(t.loadConstants()||(0,n.t)("PeProjcs.loadConstants failed"));const r=s===Sn.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();s!==Sn.PE_TYPE_GEOGCS&&Cn.getCode(r),this.m_unit=function(t){const e=Gn(null);return t.getType()===Sn.PE_TYPE_PROJCS||t.getType()===Sn.PE_TYPE_GEOGCS?e.reset(t.getUnit()):(0,n.t)("PE_coord_sys"),e.get()||(0,n.c)("cannot create units from coord sys"),function(t){return t.getType()===Sn.PE_TYPE_LINUNIT?new Ti(t):t.getType()===Sn.PE_TYPE_ANGUNIT?new C(t):void(0,n.t)("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===Sn.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=In.generate(t,In.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||(0,n.c)("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()!==Sn.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 l=h[0].getNump(),u=h[0].getKind();let c,d;t=h[0].getInclusive()>0;const p=this.getOneDegreeGCSUnit(),P=90*p,y=360*p,E=370*p,C=180*p*Sn.PE_HORIZON_DELTA/Math.PI,S=i.J.constructEmpty();let v=null;if(l>1)for(let t=1;t<l;t++)if(h[t].getKind()===Sn.PE_HORIZON_LINE){v||(v=new r.a);const e=h[t].getCoord();v.startPathCoords(e[0][0],e[0][1]),v.lineToCoords(e[1][0],e[1][1])}if(u===Sn.PE_HORIZON_RECT){const e=h[0].getCoord();if(S.setFromPoints([new a.P(e[0][0],e[0][1]),new a.P(e[1][0],e[1][1])],2),Math.abs(S.ymax-P)<1e-7*C&&(S.ymax=P),Math.abs(S.ymin+P)<1e-7*C&&(S.ymin=-P),S.width()>E){const t=-400*p,e=t+5*y;S.setCoords({xmin:t,ymin:S.ymin,xmax:e,ymax:S.ymax})}const s=new o.E({env2D:S});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=t)}else{let e=this.getPCSInfo().isGcsHorizonMultiOverlap();const o=zi(s,null,0,1),u=[],E=new a.E;for(let t=0;t<l;t++){if(h[t].getKind()!==Sn.PE_HORIZON_POLY)continue;c=h[t].getSize();const e=h[t].getCoord(),s=i.J.constructEmpty();s.setFromPoints((0,a.aD)(e),c),u.push(new a.E(s.xmin,s.xmax)),s.width(),E.merge(u.at(-1))}let C=!1;const S=new a.E;E.width()>y&&u.length>1?(S.vmin=this.getCentralMeridian()-y,S.vmax=S.vmin+2*y,C=!0,e=!0):(S.vmin=E.vmin,S.vmax=S.vmin+y);const b=t=>{let e=0;for(;u[t].vmin+e<S.vmin;)e+=y;for(;u[t].vmax+e-y>S.vmin;)e-=y;return e};let I=new r.P;if(e){const t=new ni,e=(new f.O).executeMany(t,o,null);for(let s=0;s<l;s++){if(h[s].getKind()!==Sn.PE_HORIZON_POLY)continue;c=h[s].getSize();const i=h[s].getCoord();d=h[s].getInclusive()>0;const n=new r.P;if(n.addPathPoint2D((0,a.aD)(i),c-1,!0),C){const e=b(s),i=u[s].clone();i.move(e);let r=e;const o=new m.T;do{o.setShiftCoords(r,0);const e=n.clone();e.applyTransformation(o),t.tick(e),t.tock(),r+=y,i.move(y)}while(i.vmin<S.vmax)}else t.tick(n),e.tock()}I=e.next()}else{I=new r.P;for(let e=0;e<l;e++){if(h[e].getKind()!==Sn.PE_HORIZON_POLY)continue;c=h[e].getSize();const s=h[e].getCoord();if(d=h[e].getInclusive()>0,(0,n.g)(d===t),C){const t=new r.P;t.addPathPoint2D((0,a.aD)(s),c-1,!0);const i=b(e),n=u[e].clone();n.move(i);let o=i;const h=new m.T;do{if(0!==o){h.setShiftCoords(o,0);const e=new r.P({copy:t});e.applyTransformation(h),I.addPath(e,0,!0)}else I.addPath(t,0,!0);o+=y,n.move(y)}while(n.vmin<S.vmax)}else I.addPathPoint2D((0,a.aD)(s),c-1,!0)}}C&&(I=(new g.O).execute(I,new i.J(S.vmin,-P-p,S.vmax,P+p),o,null)),t?(new _.O).accelerateGeometry(I,o,1):(new x.O).accelerateGeometry(I,o,1),(new ls).accelerateGeometry(I,o,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=I,this.m_bGCSHorisonIsInclusive=t,this.m_GCSSplitLines=v)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==Sn.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.J.constructEmpty(),m=t[0].getNump();let l=!1;if(s===Sn.PE_HORIZON_RECT){const s=t[0].getCoord();h.setFromPoints((0,a.aD)(s),2),e=new o.E({env2D:h})}else{let s=-1;for(let e=0;e<m;e++)t[e].getKind()===Sn.PE_HORIZON_POLY&&(s=e);(0,n.g)(s>=0);const i=t[s].getSize()-1,o=t[s].getCoord(),h=new r.P;e=h,h.addPathPoint2D((0,a.aD)(o),i,!0),l=!0}if(this.getPCSInfo().isDensificationNeeded()){(0,n.g)(s!==Sn.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 _.O).accelerateGeometry(e,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=e)}updatePannableExtent(){const t=this.m_peCoordSys.getType();if(t===Sn.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.getPCSInfo().getCentralMeridian(),s=t.getGeogcs();s||(0,n.c)("");const r=[e+1/s.getUnit().getUnitFactor()*Math.PI,0];vn.geogToProj(t,1,r);const o=r[0],a=t.getParameters()[Sn.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=i.J.constructEmpty();h.queryEnvelope(m);const l=Math.abs(o-a),u=l+a,c=-1*l+a,g=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:c,ymin:_,xmax:u,ymax:g})}else if(t===Sn.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.c)("")}updatePannableExtentGCS(){const t=this.m_peCoordSys.getType();if(t===Sn.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.m_centralMeridian,s=t.getGeogcs();s||(0,n.c)("");const r=1/s.getUnit().getUnitFactor()*Math.PI,o=this.getGCSHorizon(),a=i.J.constructEmpty();o.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:e-r,ymin:a.ymin,xmax:e+r,ymax:a.ymax})}else if(t===Sn.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.c)("")}updateDomain(){if(1===this.m_csType){const t=400*this.getOneDegreeGCSUnit();this.m_domain=i.J.construct(-t,-t,t,t)}else{(0,n.g)(2===this.m_csType);const t=In.generate(this.m_peCoordSys,In.PE_PCSINFO_OPTION_DOMAIN);t||(0,n.c)("generate pcs info failed");const e=new i.J(t.getDomainMinx(),t.getDomainMiny(),t.getDomainMaxx(),t.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:e})}}updatePoles(){if(this.m_peCoordSys.getType()===Sn.PE_TYPE_PROJCS){const t=90*this.getOneDegreeGCSUnit(),e=[[0,t],[0,-t]];vn.geogToProj(this.m_peCoordSys,2,e);const s=this.getPCSInfo().getNorthPoleLocation()!==In.PE_POLE_OUTSIDE_BOUNDARY,i=this.getPCSInfo().getSouthPoleLocation()!==In.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(e[0][0],e[0][1]),i&&this.m_southPole.setCoords(e[1][0],e[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===Sn.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=vn.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.h)(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let t=!1;return t=this.m_domain.isEmpty(),t&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;if(t<0){if(t=0,this.m_WKID>0){const e=[0],s=[0];(function(t,e,s,i){return e<=0?(s[0]=0,i[0]=0,!1):(s[0]=e,i[0]=e,!0)})(this.m_peCoordSys.getType(),this.m_WKID,e,s)||(0,n.c)("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 oi{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 Ti,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 ai(t,e,s,i){return mi(!0,t,e,s,i)}function hi(t,e,s,r,a){return e.hasVCS()&&s.hasVCS()?((0,n.g)(0),{}):function(t,e,s,r){t&&e||(0,n.t)("!inputSR || !outputSR");const a=t.getLatestID(),h=e.getLatestID();if(3857===a&&4326===h){if(t.m_bDefaultDescriptor&&e.m_bDefaultDescriptor)return bi()}else if(4326===a&&3857===h&&t.m_bDefaultDescriptor&&e.m_bDefaultDescriptor)return Si||(Si=bi().getInverse()),Si;const m=i.J.constructEmpty();m.setCoords({env2D:s});const l=t.getCoordinateSystemType(),u=e.getCoordinateSystemType();if(0===l||0===u)return ui(t,e);if(r){const s=r.find(0,t.getGCS(),e.getGCS());if(s)return ui(t,e,s)}const c=t.getGCS().getLatestID(),g=e.getGCS().getLatestID();if(c>0&&c===g)return ui(t,e);const _=new yi(t,e,s);{const t=function(t){if(Ei.has(t.getHashCode()))return Ei.get(t.getHashCode())}(_);if(t)return t}if(!m.isEmpty()&&1!==l){t.getGCS();let e=new o.E({env2D:m});const s=t.getSRToGCSTransform();e=(new fe).execute(e,s,null),e.queryEnvelope(m)}let d=null;if(!s.isEmpty()){const s=t.getGCS().getPECoordSys(),i=e.getGCS().getPECoordSys();let n=null;if(!m.isEmpty()){const t=s.getPrimem().getLongitude(),e=s.getUnit().getUnitFactor();n=new An(m.xmin,m.ymin,m.xmax,m.ymax,t,e)}const r=1;let o=wn.getGTlist(s,i,2,wn.PE_GTLIST_OPTS_COMMON,n,r);o&&(d=Bn(o),o=null),n&&n.destroy()}return s.isEmpty(),null!==d&&0===d.count()&&(d=null),function(t,e){return Ei.set(t.getHashCode(),e),e}(_,ui(t,e,d||void 0))}(e,s,r,a)}function mi(t,e,s,i,n,r){return new di(t?2:1,e,s,i,n,r)}function li(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(t){return(0,a.a6)(this.centralMeridianOfOutputGCS,t.centralMeridianOfOutputGCS)&&(0,a.a6)(this.densificationStep,t.densificationStep)&&this.clipWithInputHorizon===t.clipWithInputHorizon&&this.clipWithOutputHorizon===t.clipWithOutputHorizon&&this.legacyHorizonClipping===t.legacyHorizonClipping&&this.normalizeResultGeometry===t.normalizeResultGeometry}}}function ui(t,e,s,i,n){return new di(1,t,e,s,i,n)}function ci(){return{flagsMask:0,setFlag(t,e){e?this.flagsMask|=t:this.flagsMask&=~t},hasFlag(t){return!!(this.flagsMask&t)}}}function gi(){return{m_extendedParams:li(),m_extendedParamsInternal:ci()}}function _i(){return gi()}let di=class t{constructor(t,e,s,i,r,o){let a,h;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,e&&s||(0,n.t)("!inputSR || !outputSR"),i&&0===i.getType()&&(i.m_bReadOnly=!0),this.m_bNormalize=!1,1!==t&&(a=e.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=e,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,(0,n.g)(!this.m_params),r&&(this.m_params=gi(),this.m_params.m_extendedParams=r),o&&(this.m_params||(this.m_params=gi()),this.m_params.m_extendedParamsInternal=o);let m=!1;const l=null!=i,u=e.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==u&&r){const t=r.centralMeridianOfOutputGCS;if(!Number.isNaN(t)&&s.isPannable()){const e=s.getPannableExtent(),i=e.getCenterX();if(i!==t){const s=Math.ceil(e.width());t+s!==i+s&&(m=!0)}}}const g=r&&r.normalizeResultGeometry;if(e.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const _=!l&&e.equalForProjection(s,this.m_bVertical);this.m_bIdentity=_&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(g&&this.m_outputSR.isPannable()&&(this.m_bNormalize=g),this.m_datumTran=i||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const e=new t(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return e.m_bIdentity=this.m_bIdentity,e.m_bVertical=this.m_bVertical,e.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,e.updateProjector(),e}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:_i().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:_i().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:_i().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new _e(this)}};const pi=new Map,fi=new Map,xi=new Map;function Pi(t){let e=t.getCode();if(e>0)return Di(e)||wi(Cn.coordsys(e));const s=t.getName();if(fi.has(s)){const e=fi.get(s);if(e&&e.deref()){const s=e.deref();if(s.m_peCoordSys.isEqual(t))return s}}return e=Cn.getCode(t),wi(e>0?Cn.coordsys(e):t)}class yi{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.av)(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=(0,a.av)(this.m_hashCode,(0,a.aw)(this.m_env.xmin)),this.m_hashCode=(0,a.av)(this.m_hashCode,(0,a.aw)(this.m_env.xmax)),this.m_hashCode=(0,a.av)(this.m_hashCode,(0,a.aw)(this.m_env.ymin)),this.m_hashCode=(0,a.av)(this.m_hashCode,(0,a.aw)(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 Ei=new Map;let Ci,Si,vi;function bi(){return Ci||(Ci=ai(mn(),un())),Ci}const Ii=new Map;function wi(t){const e=Gn(t),s=t.getCode();if(s>0){const t=Di(s);if(t)return t}const i=t.getName();let n=fi.get(i);if(n){const e=n.deref();if(e&&e.m_peCoordSys.isEqual(t))return e}const r=new ri(e.release());if(s>0)return r.setCached(),pi.set(s,new WeakRef(r)),fi.set(i,new WeakRef(r)),r;const o=cs(t,0,!1);if(n=xi.get(o),n){const t=n.deref();if(t)return t}return r.setCached(),xi.set(o,new WeakRef(r)),r}function Di(t){const e=pi.get(t);if(e)return e.deref()}class Ti extends y{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=(vi||(vi=Cn.unit(9001)),vi))))}getUnitType(){return 0}convertFromMeters(t){return t/this.getUnitToBaseFactor()}convertToMeters(t){return t*this.getUnitToBaseFactor()}}const Ni=["0","1","2","3","4","5","6","7","8","9","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"];function Ai(t,e,s,i,r){(0,n.g)(i>>5<r.length);let o=e,a=s;for(let e=i;e>=0;e-=2){const s=31&e,i=.5*(a+o);t>=i?(r[e>>5]|=1<<s,o=i):a=i}}let Gi=new Set;const Mi=2147483645n,qi=9007199254740990n,Fi="operation is not supported for unknown coordinate systems";var Vi;function Yi(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function Xi(t){!function(t){Mn=t,(0,n.g)(Mn)}(t)}function Ri(){return!!Cn}function ki(){return!!Mn}function Li(){return!!Cn||!!Mn}function Bi(t,e,s){return(0,n.g)(Li()),pn(t,void 0===e?0:e,0,!1)}function Hi(t,e){(0,n.g)(Li());const s=new an;let i;return Ri()?(i=function(t){const e=Gn(Cn.fromString(Sn.PE_TYPE_COORDSYS,t));return e.get()||(0,n.C)(t),Pi(e.release())}(t),s.setHorzProj_(i),s.m_vertcs=null,s.m_userWKID=i.getLatestID()):(i=qn(t),s.m_unit=i.isPCS?new Ti(i.metersOrRadiansPerUnit):new C(i.metersOrRadiansPerUnit)),gn(s.m_precisionDescriptor,i,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=t,s.calculateHashCode(),s.initDbgName(),s}function zi(t,e,s,i,r=!0){let o=null;return e&&((0,n.g)(0),o={}),function(t,e,s,i,r){t||(0,n.t)("!PE_coord_sys");const o=new an;let a;return a=r?Pi(t):new ri(t,!1),gn(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 Ui(t,e,s=!1){3===t.getCoordinateSystemType()&&(0,n.t)("image spatial reference cannot be altered");const i=new an,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 Oi(t,e,s){void 0===e&&(e=1),(e<=0||!Number.isFinite(e))&&(0,n.t)(""),t||1===e||(0,n.t)("null Unit has to have z_to_xy_factor equal to 1");const i=new an;i.m_unit=t;const r=t||new Ti(9001);return dn(i.m_precisionDescriptor,r,null,1),i.m_bDefaultDescriptor=!0,Number.isNaN(i.m_precisionDescriptor.m_falseX)&&(0,n.t)("NAN false X/Y are not allowed here"),i.m_localZToXYFactor=e,i.calculateHashCode(),i.initDbgName(),i}function Wi(t,e){return t.snapGeometry(e)}function ji(t){const e=t.getCoordinateSystemType();return 1===e?t:(3===e&&(0,n.g)(0),t.getGCS())}function Ji(t){return(0,n.g)(Li()),ki()?function(t){return(0,n.g)(ki()),!!Mn(t).isPCS||function(t){return Cn&&(0,n.r)("pe has been loaded. no-pe methods should not be used at this point."),xn||Vn(),xn.has(t)}(t)}(t):function(t){if(Ii.has(t))return Ii.get(t);{const e=function(t){return null!==Gn(Cn.coordsys(t)).get()}(t);return Ii.set(t,e),e}}(t)}function Zi(t){return null!==Gn(Cn.fromString(Sn.PE_TYPE_COORDSYS,t)).get()}let Qi;function Ki(){return Qi||(Qi=(()=>{const t=Math.trunc(Math.random()*(0,a.q)()),e=Date.now();return`|abba_000|${t.toString(16)}|${e.toString(16)}|`})()),Qi}var $i;($i=Vi||(Vi={}))[$i.utmDefault=0]="utmDefault",$i[$i.utmNorthSouth=1]="utmNorthSouth";let tn=0;function en(t=""){let e=`${Ki()}${tn++}`;return""!==t&&(e+=`|${t}`),e}function sn(t){return t.startsWith(Ki())}let nn,rn,on,an=class t{destroy(){(function(t){fi.delete(t.m_peCoordSys.getName()),xi.delete(cs(t.m_peCoordSys,0,!1))})(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():(0,n.c)("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 hn,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,cn(this.m_precisionDescriptor),Gi&&Gi.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Bi(this.m_userWKID):Hi(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 ai(this,this,null);let e=t?this.m_srToGcs:this.m_gcsToSr;if(e)return e;const s=this.getGCS();e=t?ai(this,s,null):ai(s,this,null);const i=e;return(t?this.m_srToGcs:this.m_gcsToSr)||(t?this.m_srToGcs=i:this.m_gcsToSr=i,e)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let t=this.getHashCodeHorizontal();const e=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();t=(0,a.av)(t,e),this.m_hashCode=(0,a.av)(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 Sn.PE_TYPE_GEOGCS:return 1;case Sn.PE_TYPE_PROJCS:return 2;default:return 0}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Ti)return 2;if(this.m_unit instanceof C)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.b)("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return(0,n.b)("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?gs(t):this.m_userWKT??""}getTextExtended(t){const e=this.getPECoordSys();return e?this.getPEVerticalCoordSys()?(this.getPEVerticalCoordSys(),(0,n.g)(0),""):gs(e,t):this.m_userWKT??""}getText2(t=-1){const e=this.getPECoordSys();return e?function(t,e){(e>1||e<-1)&&(0,n.t)("verbosity");let s=Sn.PE_STR_FMT_WKT2;return-1!==e&&(s|=0===e?Sn.PE_STR_AUTH_TOP:Sn.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 Ti?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof C?.001/(qn(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):((0,n.r)("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?((0,n.g)(0),""):""}getVerticalUnit(){return(0,n.b)("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.r)(Fi);else{if(1===t)return this;3===t&&(0,n.r)("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let e;if(this===mn()||this===ln())e=un();else{(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();t||(0,n.c)(""),e=zi(t,this.m_vertcs,0,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?e=this.m_geogSpatialReference:this.m_geogSpatialReference=e,e}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(t,e){if(0===t.length)return 0;t.length>e.length&&(0,n.t)("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&(0,n.r)(Fi),1===s)return(0,a.ax)(e,t,t.length),t.length;(0,n.g)(this.m_peCoordSysVal);const i=this.getSRToGCSTransform();return(new fe).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.u)(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=(0,a.u)(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const i=5*e,n=new Uint32Array(4);return Ai(s.x,-180,180,i-1,n),Ai(s.y,-90,90,i-2,n),function(t,e,s){const i=(0,a.f)(e,"R");let n=0,r=0;for(let s=0;s<e;s++){let o=t[n]>>r&31;if(r+=5,r>31){const e=37-r;o&=(1<<e)-1,r-=32,n++,o|=(t[n]&(1<<r)-1)<<e}const a=Ni[o];i[e-1-s]=a}return s>e?i.push(..."0".repeat(s-e)):s<e&&(i.length=s),i.join("")}(n,e,e)}isPannable(){const t=this.getCoordinateSystemType();return 0!==t&&3!==t&&((0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||(0,n.t)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||(0,n.t)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const t=this.getCoordinateSystemType();1!==t&&2!==t&&(0,n.t)("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(t){if(t.assign(this.m_precisionDescriptor),Number.isNaN(t.m_falseX))if(Ri()||(0,n.r)("projection engine is not loaded"),(0,n.g)(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const e=this.m_peCoordSysVal.getDomainXY();t.m_falseX=e.xmin,t.m_falseY=e.ymin}else t.m_falseX=-Number.MAX_VALUE,t.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(t){t.assign(this.m_precisionDescriptor),t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(t){if(this.m_bDefaultDescriptor)t.assign(this.m_precisionDescriptor);else{const e=this.getCoordinateSystemType();0===e?dn(t,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===e?(0,n.b)("image cs"):gn(t,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}horizontalEqual(t){return function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?t.m_hashCode===e.m_hashCode&&t.m_canonicalWkt===e.m_canonicalWkt:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)}verticalEqual(t){return null!==this.m_vertcs==(null!==t.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(t.m_vertcs))}equals(t){const e=t;if(this===e)return!0;if(!this.horizontalEqual(e)||!this.verticalEqual(e))return!1;if(!e.m_peCoordSysVal){if((0,n.g)(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==e.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(e.m_unit))return!1;if(this.m_localZToXYFactor!==e.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!e.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(e.m_precisionDescriptor))return!1;(0,n.g)(e.m_peCoordSysVal);let t=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(t)){const e=this.m_peCoordSysVal.getDomainXY();t=e.xmin,s=e.ymin}let i=e.m_precisionDescriptor.m_falseX,r=e.m_precisionDescriptor.m_falseY;if(Number.isNaN(i)){const t=e.m_peCoordSysVal.getDomainXY();i=t.xmin,r=t.ymin}return t===i&&s===r}return this.m_precisionDescriptor.equals(e.m_precisionDescriptor)}return!0}equalForProjection(t,e){if(this===t)return!0;const s=this.getCoordinateSystemType(),i=t.getCoordinateSystemType();if(0===s||0===i)return 0===s&&0===i?(!e||this.getZToXYFactor()===t.getZToXYFactor())&&(!this.getUnit()||!t.getUnit()||this.getUnit().equals(t.getUnit())):3!==s&&3!==i&&(null===this.getUnit()||null===t.getUnit()||(!e||this.getZToXYFactor()===t.getZToXYFactor())&&this.getUnit().equals(t.getUnit()));if(s!==i)return!1;if(3===s)return this.equals(t);if(function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?1===t.m_csType?t.m_peCoordSys.isEqual(e.m_peCoordSys):t.m_peCoordSys===e.m_peCoordSys:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)){if(!e)return!0;if(null!==this.m_vertcs==(null!==t.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(t.m_vertcs)}return!1}equalHorizontal(t){return this.horizontalEqual(t)}equalVertical(t){return(0,n.g)(0),!1}equalVerticalVCS(t){return(0,n.g)(0),!1}convergenceAngle(t){return(0,n.g)(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const t=this.m_peCoordSysVal.m_peCoordSys;return t||(0,n.c)("cannot clone coord sys"),t}return null}getPeVertcsCopy(){return(0,n.g)(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&(0,n.t)(Fi)}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 hn;this.queryDefaultPrecisionDescriptorWithoutFalseXY(t),this.m_defaultPrecisionSR=Ui(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.r)(""),(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.getAreaOfUse();return null===t?new P:new P({geom:t.clone(),sr:Bi(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,i=e.getGeometryCount();t<i;++t)s=this.snapGeometry(e.getGeometry(t))||s;return s}(0,n.c)("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 hn;this.queryPrecisionDescriptor(e);const s=t.getStartXY(),i=new a.P;i.x=fn(s.x,e.getFalseX(),e.getGridUnitsXY()),i.y=fn(s.y,e.getFalseY(),e.getGridUnitsXY());let r=!i.equals(s);const o=t.getEndXY(),h=new a.P;h.x=fn(o.x,e.getFalseX(),e.getGridUnitsXY()),h.y=fn(o.y,e.getFalseY(),e.getGridUnitsXY()),r||=!h.equals(o),r&&t.changeEndPoints2D(i,h);const m=(e,s,i)=>{let n=!1;{const r=t.getStartAttributeAsDbl(e,0),o=fn(r,s,i),h=!(0,a.a6)(o,r);n||=h,h&&t.setStartAttribute(e,0,o)}{const r=t.getEndAttributeAsDbl(e,0),o=fn(r,s,i),h=!(0,a.a6)(o,r);n||=h,h&&t.setEndAttribute(e,0,o)}return n};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(e,s,i,n){let r=!1;const o=new hn;if(this.queryPrecisionDescriptor(o),0===e){const e=s;for(let s=i;s<n;s++){const i=e.read(2*s),n=t.s_SnapValue(i,o.getFalseX(),o.getGridUnitsXY()),a=e.read(2*s+1),h=t.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());r=r||n!==i||h!==a,r&&(e.write(2*s,n),e.write(2*s+1,h))}}else if(1===e){const e=s;for(let s=i;s<n;s++){const i=e.read(s),n=t.s_SnapValue(i,o.getFalseZ(),o.getGridUnitsZ());r=r||!(0,a.a6)(n,i),r&&e.write(s,n)}}else if(2===e){const e=s;for(let s=i;s<n;s++){const i=e.read(s),n=t.s_SnapValue(i,o.getFalseM(),o.getGridUnitsM());r=r||!(0,a.a6)(n,i),r&&e.write(s,n)}}return r}static s_SnapValue(t,e,s){return(0,a.ay)((t-e)*s)/s+e}};class hn{constructor(){const t=qi,e=1e-4,s=.001,i=e*Number(t)*.5;this.m_precision=1,this.m_falseX=-i,this.m_falseY=-i,this.m_unitsXY=Number(t)/(2*i),this.m_falseM=-1e5,this.m_unitsM=1/e,this.m_falseZ=-1e5,this.m_unitsZ=1/e,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let t=7777,e=7777;return e=(0,a.av)(e,this.m_falseM),e=(0,a.av)(e,this.m_unitsM),t=(0,a.av)(t,this.m_unitsXY),e=(0,a.av)(e,this.m_toleranceXY),t=(0,a.av)(t,this.m_falseZ),e=(0,a.av)(e,this.m_toleranceZ),t=(0,a.av)(t,this.m_unitsZ),e=(0,a.av)(e,this.m_toleranceM),t=(0,a.av)(t,this.m_precision),(0,a.av)(t,e)}clone(){const t=new hn;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.J;switch(this.m_precision){case 0:{const e=hn.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(hn.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.c)("")}return t}getZGridRange(){const t=new a.E;switch(this.m_precision){case 0:{const e=hn.getLimit32()/this.getGridUnitsZ();t.setCoords(this.getFalseZ(),this.getFalseZ()+e)}break;case 1:{const e=Number(hn.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.c)("")}return t}getMGridRange(){const t=new a.E;switch(this.m_precision){case 0:{const e=hn.getLimit32()/this.getGridUnitsM();t.setCoords(this.getFalseM(),this.getFalseM()+e)}break;case 1:{const e=Number(hn.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.c)("")}return t}setTolerance(t,e){switch(e<0&&(0,n.t)("tol < 0"),Number.isFinite(e)||(0,n.t)("tol is not finite"),t){case 0:this.m_toleranceXY=e;break;case 1:this.m_toleranceZ=e;break;case 2:this.m_toleranceM=e;break;default:(0,n.t)("cannot set tolerance for this attribute")}}setGridParams(t,e,s){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(s)||(0,n.t)("grid params are not finite"),s<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseX=t,this.m_falseY=e,this.m_unitsXY=s}setZParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.t)("grid params are not finite"),e<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseZ=t,this.m_unitsZ=e}setMParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.t)("grid params are not finite"),e<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseM=t,this.m_unitsM=e}setPrecision(t){}equals(t){return this===t||(0,a.a6)(this.m_falseX,t.m_falseX)&&(0,a.a6)(this.m_falseY,t.m_falseY)&&this.equalsWithoutFalseXY(t)}snapPrecision(){if(2===this.m_precision)return;const t=(t,e,s,i)=>{if(!Number.isFinite(e)||!Number.isFinite(s))return s;if(s<1)return 1;if(!i)return s;const n=Number(t)/s;return Math.trunc((e+n-e)*s)>t&&(s=t/(e+n-e)),Math.max(1,s)},e=Number(0===this.m_precision?Mi:qi);this.m_unitsXY=t(e,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=t(e,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=t(e,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=t(e,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const t=(t,e,s,i)=>{if(s<1)return!1;if(!Number.isFinite(e)||!Number.isFinite(s))return!1;if(!i)return!0;const n=Number(t)/s;return!(BigInt((e+n-e)*s)>t)},e=0===this.m_precision?Mi:qi;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 mn(){return(!nn||Ri()&&null===nn.getPECoordSys())&&(nn=pn(3857,0,0,!0)),nn}function ln(){return(!rn||Ri()&&null===rn.getPECoordSys())&&(rn=pn(102100,0,0,!0)),rn}function un(){return(!on||Ri()&&null===on.getPECoordSys())&&(on=pn(4326,0,0,!0)),on}function cn(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.a5)(),t.m_toleranceZ=100*(0,a.a5)(),t.m_toleranceM=100*(0,a.a5)(),t.m_precision=2}function gn(t,e,s,i){const r=e instanceof ri;cn(t),t.m_precision=i,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const o=1e-4,a=.001,h=r?e.m_csType:e.isPCS?2:1;if(1===h){const s=(0===i?1/18e5:1e-9)*(r?e.getOneDegreeGCSUnit():Math.PI/e.metersOrRadiansPerUnit/180);t.m_unitsXY=1/s}else if(2===h){const s=(0===i?a:o)*(r?e.getOneMeterPCSUnit():1/e.metersOrRadiansPerUnit);t.m_unitsXY=1/s}else(0,n.t)("unrecognized cs type");t.m_falseM=-1e5,t.m_unitsM=1/(0===i?a:o),t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let m=0,l=0;0!==i&&1!==i||(m=2/t.m_unitsXY,l=2/t.m_unitsM),t.m_toleranceXY=Math.max(m,r?e.getUnitsPerMillimeter():2===h?.001/e.metersOrRadiansPerUnit:.001/(e.semiMajor*e.metersOrRadiansPerUnit)),t.m_toleranceM=Math.max(a,l),_n(t,s)}function _n(t,e){const s=1e-4,i=.001;if(t.m_falseZ=-1e5,e){const n=(0===t.m_precision?i:s)*e.getOneMeter();t.m_unitsZ=1/n}else t.m_unitsZ=1/(0===t.m_precision?i:s);t.m_unitsZ=Math.max(1,t.m_unitsZ);let n=0;0!==t.m_precision&&1!==t.m_precision||(n=2/t.m_unitsZ),t.m_toleranceZ=Math.max(e?e.getOneMeter()*i:i,n)}function dn(t,e,s,i){cn(t),t.m_precision=i;const n=0===i?Mi:qi,r=1e-4,o=.001;let a=1,h=1,m=.001;e&&(h=e.getUnitToBaseFactor()),e&&1===e.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===i?o:r)*Number(n)*.5,m=o/h),a/=h,t.m_falseX=-a,t.m_falseY=-a,t.m_unitsXY=Number(n)/(2*a),t.m_falseM=-1e5,t.m_unitsM=1/(0===i?o:r),t.m_unitsM=Math.max(1,t.m_unitsM),t.snapPrecision();let l=0,u=0;0!==t.m_precision&&1!==t.m_precision||(u=2/t.m_unitsM,l=2/t.m_unitsXY),t.m_toleranceXY=Math.max(l,m),t.m_toleranceM=Math.max(o,u),_n(t,s)}function pn(t,e,s,i){if(!i&&e<=0){if(3857===t)return mn();if(102100===t)return ln();if(4326===t)return un()}const r=new an;let o,a=null;return Ri()?(o=function(t){t<=0&&(0,n.B)(t);{const e=Di(t);if(e)return e}const e=Gn(Cn.coordsys(t));e.get()||(0,n.B)(t);const s=wi(e.release());return s.getLatestID()!==t&&pi.set(t,new WeakRef(s)),s}(t),e>0?a=null:e=0,r.setHorzProj_(o),r.m_vertcs=a):(o=qn(t),r.m_unit=o.isPCS?new Ti(o.metersOrRadiansPerUnit):new C(o.metersOrRadiansPerUnit)),gn(r.m_precisionDescriptor,o,a,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=t,r.calculateHashCode(),r.initDbgName(),r}function fn(t,e,s){return(0,a.ay)((t-e)*s)/s+e}let xn=null;const Pn=3552713678800501e-30;function yn(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,Pn)}let En,Cn,Sn,vn,bn,In,wn,Dn,Tn,Nn,An;function Gn(t){return{_this:t,get(){return this._this},reset(t){this._this=t},release(){const t=this._this;return this._this=null,t}}}let Mn=null;function qn(t){(0,n.g)(Mn);const e=Mn(t);return e.semiMajor=e.isPCS?Number.NaN:function(t){if(Cn&&(0,n.r)("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof t){const e=t.match(Fn);e&&2===e.length||(0,n.t)("bad gcs wkt");const s=Number.parseFloat(e[1]);return Number.isFinite(s)||(0,n.t)("bad gcs wkt"),s}return xn||Vn(),xn.has(t)||(0,n.r)("gcs wkid not found"),xn.get(t)}(t),e}const Fn=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Vn(){xn=new Map;for(const t in E){const e=Number.parseFloat(t),s=E[t];if(Array.isArray(s))for(const t of s)xn.set(t,e);else xn.set(s,e)}!function(){for(const t in E)delete E[t]}()}function Yn(t,e){return new kn(t,e)}const Xn=(0,a.l)(0),Rn=(0,a.l)(1);let kn=class t{constructor(e,s){if(e instanceof t)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=s?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=(0,a.av)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Rn:Xn));this.m_geogTranWrapper=new es(e),this.m_bInverted=s,this.m_hashCode=(0,a.av)(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Rn:Xn)}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?Sn.PE_STR_AUTH_TOP:Sn.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(e)}}getText2(t=-1){let e=Sn.PE_STR_FMT_WKT2;return-1!==t&&(e|=0===t?Sn.PE_STR_AUTH_TOP:Sn.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 t(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 Ln(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 i=ai(t,h,null);s=(new fe).execute(s,i,null),s.queryEnvelope(e)}if(!e.isEmpty()){const t=l.getPrimem().getLongitude(),s=l.getUnit().getUnitFactor();c=new An(e.xmin,e.ymin,e.xmax,e.ymax,t,s)}}let g=i;g>=(0,a.q)()&&(g=0);const _=[];let d=wn.PE_GTLIST_OPTS_COMMON;r||(d&=~wn.PE_GTLIST_OPTS_USABLE);for(let t=0;t<2;t++){_.length=0;const t=g,e=wn.getGTlist(l,u,2,d,c,t);let s=!1;if(e&&e.length>0)for(let t=0,o=e.length;t<o;t++){const o=Bn([e[t]]);if((0,n.g)(o),r&&o.referencesMissingData())s=!0;else if(_.push(o),i>0&&_.length===i)break}if(!s)break;0===g||(g=0)}return c&&c.destroy(),_}function Bn(t){(0,n.g)(null!==t);const e=new zn,s=t[0].getSteps();if(s){const i=t[0].getEntries();for(let t=0;t<s;t++){const s=0!==i[t].getDirection(),n=Yn(i[t].getGeogtran(),s);e.add(n)}return e.create()}return null}let Hn=class{constructor(t,e,s,i){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=i}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.av)(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.s)(""),this.m_transforms[t]}getInverse(){const t=new zn;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 i=this.m_inputSr,n=this.m_outputSr;if(t&&(n=(0,a.b)(i,i=n)),0===this.m_transforms.length)return void ss(i,null,n,null,e,null,s);let o=this.m_fastTrack;if(1===o)return void(0,r.a4)(t,this.m_transforms,(i=>{!function(t,e,s,i,n){const r=t.getVerttran(),o=t.getGeogtran();if(n>0){t.prepareOrThrow();const i=e?Sn.PE_TRANSFORM_2_TO_1:Sn.PE_TRANSFORM_1_TO_2;r?Js():Zs(o,n,s,null,i)}}(i.getWrapper(),t!==i.isInverted(),e,0,s)}));const h=ts();-1===o&&h.initFromGcsAndVcs(i,null);const m=ts();let l=t?this.m_transforms.length-1:0;const u=t?-1:1;for(let n=0,r=this.m_transforms.length;n<r;n++,l+=u){if(0===n){const n=this.m_transforms[l];is(i.getPECoordSys(),null,n.getWrapper(),t!==n.isInverted(),e,null,s,m),-1===o&&(h.equals(m)||(o=0)),h.assign(m)}else{const i=this.m_transforms[l-u],n=this.m_transforms[l];ns(h,i.getWrapper(),t!==i.isInverted(),n.getWrapper(),t!==n.isInverted(),e,null,s,m),-1===o&&(h.equals(m)||(o=0)),h.assign(m)}const r=this.m_transforms[l];rs(h,r.getWrapper(),t!==r.isInverted(),e,null,s,m),h.assign(m)}const c=this.m_transforms[l-u];(function(t,e,s,i,n,r,o,a){const h=ts();h.assign(s?e.m_inputUnitParams:e.m_outputUnitParams),h.processUnitParams(t);let m=null;i&&(m=i.getPECoordSys());const l=ts();l.initFromGcsAndVcsPe(m,null),l.processUnitParams(h),h.processUnitParams(l),a>0&&$e(h,l,r,null,a)})(h,c.getWrapper(),t!==c.isInverted(),n,0,e,0,s),-1===o&&(m.initFromGcsAndVcs(n,null),h.equals(m)||(o=0)),this.m_fastTrack=0===o?0:1}};class zn{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.s)(""),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 Hn(this.m_transforms,this.m_bNameIsSet?this.m_name:null,t,e);return s.m_bReadOnly=!0,this.clear(),s}}const Un=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:an,SpatialReferencePrecisionDescriptor:hn,create:Bi,createFromWKT:Hi,createImplFromPe:zi,createLocal:Oi,createWithNewPrecision:Ui,createWithNewVCS:function(t,e,s){return{}},getGCS:ji,getTempName:en,hasNoPe:ki,hasPe:Ri,injectNoPe:Xi,injectPe:function(t){if(Cn)return;!function(t){const e=t;Cn=e.PeFactory,(0,n.g)(Cn),An=e.PeGCSExtent,(0,n.g)(An),Tn=e.PeLineType,(0,n.g)(Tn),Nn=e.PeMath,(0,n.g)(Nn),En=e.PeDouble,(0,n.g)(En),Sn=e.PeDefs,(0,n.g)(Sn),vn=e.PeCSTransformations,(0,n.g)(vn),bn=e.PeGTTransformations,(0,n.g)(bn),In=e.PePCSInfo,(0,n.g)(In),wn=e.PeGTlistExtended,(0,n.g)(wn),Cn.initialize(),Dn=e.PeGTlistExtendedEntry,(0,n.g)(Dn),Sn.PE_TYPE_ANGUNIT=512,Sn.PE_STR_AUTH_ALL=2,In.PE_POLE_LINE_STRAIGHT=2,In.PE_POLE_LINE_CURVED=3,Sn.PE_PARM_LAM0=2,Sn.PE_PARM_PHI0=6,Sn.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,Sn.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,Sn.PE_PRJ_ALBERS=43007,Sn.PE_PRJ_CYLINDRICAL_EQAREA=43034,Sn.PE_TYPE_VERTCS=8,Sn.PE_LINETYPE_GEODESIC=0,Sn.PE_LINETYPE_LOXODROME=1,Sn.PE_LINETYPE_GREAT_ELLIPTIC=2,Sn.PE_LINETYPE_NORMAL_SECTION=3,wn.PE_GTLIST_OPTS_USABLE=1,Mn=null}(t);const e=Gi;Gi=null,e.forEach((t=>{const e=t.deref();e&&e.attachToPe()}))},isInitialized:Li,isTempName:sn,isValidWkid:Ji,isValidWkt:Zi,makeSpheroidData:Yi,snapGeometry:Wi,webMercator:mn,webMercator102100:ln,wgs84:un},Symbol.toStringTag,{value:"Module"})),On=Object.freeze(Object.defineProperty({__proto__:null,OperatorProject:fe},Symbol.toStringTag,{value:"Module"})),Wn=Object.freeze(Object.defineProperty({__proto__:null,CompositeGeographicTransformation:Hn,CompositeGeographicTransformationEditor:zn,createImpl:Bn,queryGtListImpl:Ln},Symbol.toStringTag,{value:"Module"})),jn=Object.freeze(Object.defineProperty({__proto__:null,GeographicTransformation:kn,create:function(t,e){const s=Cn.geogtran(t);return s||(0,n.B)(t),new kn(s,e)},createFromPe:Yn,createFromWKT:function(t,e){const s=Cn.fromString(Sn.PE_TYPE_GEOGTRAN,t);return s||(0,n.C)(t),new kn(s,e)}},Symbol.toStringTag,{value:"Module"})),Jn=Object.freeze(Object.defineProperty({__proto__:null,ProjectionTransformation:di,createEx:ai,createFromAoi:function(t,e,s,i){return hi(0,t,e,s,i)},createImpl:hi,createImplEx:mi,makeExtendedParams:li,makeExtendedParamsInternal:ci,queryTransformationList:function(t,e,s,i,r,o=!1){if(e&&s||(0,n.t)(""),1===t&&e.hasVCS()&&s.hasVCS())return(0,n.b)("hv xform not impl"),[];{const t=Ln(e,s,i,r,o),n=[];for(const e of t)n.push(e);return n}}},Symbol.toStringTag,{value:"Module"}))},35368:(t,e,s)=>{s.d(e,{$:()=>kn,A:()=>hn,B:()=>mn,C:()=>gr,D:()=>ln,E:()=>ar,F:()=>zs,H:()=>ns,I:()=>Un,J:()=>O,K:()=>Ir,L:()=>Gr,M:()=>d,N:()=>Sr,O:()=>L,P:()=>on,Q:()=>Vt,R:()=>Yt,S:()=>Mr,T:()=>C,U:()=>Cn,V:()=>rr,W:()=>et,X:()=>vr,Y:()=>br,Z:()=>Tr,_:()=>or,a:()=>zi,a0:()=>Ln,a1:()=>Mn,a2:()=>pn,a3:()=>dt,a4:()=>l,a5:()=>Oi,a6:()=>ct,a7:()=>sn,a8:()=>$i,b:()=>Wi,c:()=>ut,d:()=>an,e:()=>Ki,f:()=>lr,g:()=>E,h:()=>ur,i:()=>Cr,j:()=>hr,n:()=>ir,p:()=>rn,s:()=>u,z:()=>ue});var i=s(55537),n=s(95213),r=s(83661),o=s(79187),a=s(11878),h=s(76061);class m{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 l(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.N)(t);const i=e.length/(0,r.q)();for(let t=0;t<e.length;++t){const t=Math.trunc(s*i);s=(0,r.N)(s);const n=Math.trunc(s*i),o=e[t];e[t]=e[n],e[n]=o}}var c=n.V;const g="can not assign an empty point to a vertex";class _{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,n.x)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new m,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new n.y,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,n.x)();this.m_description=e,this.m_vertexAttributes=new m,this.m_envelopeData=new n.y,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,i.i)(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const i=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(i),o=s.getAttributeStreamRef(i),a=c.getComponentCount(i);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,r,o){this.addAttribute(t),this.isEmpty()||0===s&&1===r||(function(t,e,s,n,r){(e<0||s<0||n<1||e+n*(s-1)+1>t.size())&&(0,i.t)("Index out of bound");for(let i=e,o=e+n*(s-1)+1;i<o;i+=n)t.writeAsDbl(i,r(t.readAsDbl(i)))}(this.getAttributeStreamRef(t),e,this.getPointCount(),c.getComponentCount(t),(0,n.M)(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,n.z)(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,n.D)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.F)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.x)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,i.t)("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,i.t)("stream"),e&&c.getPersistence(t)!==e.getPersistence()&&(0,i.t)(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){const i=this.m_description.getSemantics(e);for(let n=0,r=c.getComponentCount(i);n<r;n++){const o=this.m_vertexAttributes.get(e).readAsDbl(r*t+n);s.setAttributeBasic(i,n,o)}}}setPointByVal(t,e){const s=e;s.isEmpty()&&(0,i.t)(g);const n=s.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,s.getX()),r.write(2*t+1,s.getY());for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),n=c.getComponentCount(i);for(let r=0;r<n;r++){const o=s.getAttributeAsDbl(i,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(t,e,s,n){(0,i.g)(0)}getPointByValAsArray(t,e,s,n){(0,i.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=c.getComponentCount(t);s>=n&&(0,i.s)("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):c.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=c.getComponentCount(t);n<r&&(0,i.s)("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=c.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){const r=c.getComponentCount(t);s>=r&&(0,i.s)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArray(t,e,s,n){(e<0||e>=this.m_pointCount)&&(0,i.s)("");const r=c.getComponentCount(t);n!==r&&(0,i.s)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let t=0;t<r;++t)a.writeAsDbl(e*r+t,s[t])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=n.v.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=c.getDefaultValue(1),s}setXYZ(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.J||t instanceof n.b?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 i=!1;const n=c.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let t=e,o=this.m_pointCount*n;t<o;t+=n)r.readAsDbl(t)!==s&&(r.writeAsDbl(t,s),i=!0);i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=c.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let t=0;t<i;t++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,r=this.m_pointCount*i;t<r;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,i.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,i.t)(""),this.m_envelopeData=new n.y({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,i.t)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.t)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*s,i=2*r,n=0;e<i;e+=2,n++)o.queryPoint2D(e,t[n]);return r}queryCoordinates3D(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.t)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=c.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<r;e++,l++)t[l].x=o.read(2*e),t[l].y=o.read(2*e+1),t[l].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;return 1&i||(s=(14&i)>>1,e[0]=n,n<t&&(s=-1)),s}setIsSimple(t,e,s=!1){if(2===t?(0,i.g)(this.getGeometryType()===i.G.enumPolyline):1===t?(0,i.g)(this.getGeometryType()===i.G.enumMultiPoint||this.getGeometryType()===i.G.enumPolyline):3===t&&(0,i.g)(this.getGeometryType()===i.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let i=t<<1;s||(i|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,i),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&(0,i.y)("Cannot do shallow clone on unprepared geometry");const s=t,n=this.getGeometryType(),r=s.getGeometryType();(0,i.g)(n===r||n===i.G.enumPolygon&&r===i.G.enumPolyline,"failure in copyToUnchcked"),s.clearAccelerators(),s.m_description=this.m_description,s.m_vertexAttributes.destroyAndSetSize(0),s.m_envelopeData.releaseAttributes();const o=this.m_description.getAttributeCount(),a=new m;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=c.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,s.m_envelopeData),s.m_flags=this.m_flags,s.m_simpleTolerance=this.m_simpleTolerance,n!==r){const t=[0];s.getIsSimple(0,t)>=3?s.setIsSimple(1,t[0]):s.setIsSimple(-1,0)}s.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),s.m_pointCount=this.m_pointCount,s.hasDirtyFlag(32)?((0,i.g)(!e),s.m_reservedPointCount=-1):s.m_reservedPointCount=s.m_pointCount;try{this.copyToImpl(s,e)}catch(t){throw s.setEmpty(),t}s.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,o){(t<0||t>=this.m_pointCount)&&(0,i.s)(""),(e<0||e>=this.m_pointCount)&&(0,i.s)(""),o.assignVertexDescription(this.m_description);const a=new Array(c.maxComponentCount()),h=new Array(c.maxComponentCount()),m=(0,n.G)();let l=0;for(let o=0;o<this.m_description.getAttributeCount();o++){const u=this.m_description.getSemantics(o),g=c.getInterpolation(u),_=c.getComponentCount(u),d=c.getDefaultValue(u);this.queryAttributeAsDbl(u,t,a,_),this.queryAttributeAsDbl(u,e,h,_),(0,i.g)(l+_<=n.O),(0,r.O)(g,a,h,m,l,_,s,d),l+=_}!function(t,e){const s=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,r.a)(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,i.t)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=(0,n.H)();(0,n.J)(t,this.m_description,e);const s=new m;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return!!(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=Number.MAX_SAFE_INTEGER;let t=0;t=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let e=0;e<this.m_description.getAttributeCount();e++){const s=this.m_description.getSemantics(e);let i=0;if(null!==this.m_vertexAttributes.get(e)){const n=c.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,c.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,(0,n.K)(s,t)),i=t;i<this.m_reservedPointCount&&(this.m_reservedPointCount=i)}}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new n.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),i=c.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const o=new r.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);o.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new n.y({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=o.J.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){(0,i.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.J?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&(0,i.t)(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,n.L)(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,n.L)(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=c.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,(0,n.L)(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&(0,i.t)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,i.z)("")}}class d extends _{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,e){t>this.getPointCount()&&(0,i.t)("invalid point index"),t<0&&(t=this.getPointCount());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(0===r)this.m_vertexAttributes.get(i).insert(o*t,e,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,i.t)(g),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(e.hasAttribute(r))this.m_vertexAttributes.get(i).insertAttributes(o*t,e,r,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.s)(""),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 i=0,a=this.m_description.getAttributeCount();i<a;i++){const a=this.m_description.getSemantics(i),h=n.V.getComponentCount(a);if(this.m_vertexAttributes.get(i))if(r.hasAttribute(a))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*h,e,s,a,o*h);else{const e=n.V.getDefaultValue(a);this.m_vertexAttributes.get(i).insertRange(h*t,e,h*s,h*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.t)("invalid point index"),t<0&&(t=this.getPointCount()),0===s)return;const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=n.V.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(0===o)this.m_vertexAttributes.get(i).insertRangeFromPoints(a*t,e,0,s,!0,a*r);else{const e=n.V.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a,a*r)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,i.s)("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i);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),i=n.V.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=n.V.getDefaultValue(s),r=n.V.getComponentCount(s);this.m_vertexAttributes.get(t).insertRange(r*e,i,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,i.t)(""),0===this.m_pointCount)return o;const a=this.getAttributeStreamRef(0);let h=null;const m=n.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,n){(0,i.g)(0)}add(t){t.isEmpty()&&(0,i.t)(g),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new r.P(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new n.v;i.setCoords(t,e,s),this.setXYZ(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,s){this===t&&(0,i.t)("Multi_point_impl.add");const r=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||r<e)&&(0,i.t)(""),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,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i),m=this.getAttributeStreamRef(i);if(o.hasAttribute(i)){const s=t.getAttributeStreamRef(i);m.insertRangeFromStream(h*r,s,e*r,a*r,!0,1,h*r)}else{const t=n.V.getDefaultValue(i);m.insertRange(h*r,t,a*r,h*r)}}}addPoints2D(t,e,s,n){let r=e;const o=n<0?r:n;if((r<0||s<0||s>r||o<s)&&(0,i.t)(""),s===o)return;r=o-s;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[s+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,s,n){let o=e;const a=n<0?o:n;if((o<0||s<0||s>o||a<s)&&(0,i.t)(""),this.addAttribute(1),s===a)return;o=a-s;const h=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);const m=this.getAttributeStreamRef(0),l=new 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)}getGeometryType(){return i.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new d({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,i.b)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.G.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):(0,i.b)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){(0,i.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}d.type=i.G.enumMultiPoint;class p{constructor(){this.m_EnvelopeType=5,this.envAabb=o.J.constructEmpty(),this.envRot=o.J.constructEmpty()}static constructEmpty(){return new p}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:f(t),y:x(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(f(t),x(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=f(t[i]),s=x(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=f(t[s]),i=x(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(f(t),x(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.R)();this.envRot.inflateCoords(e,e),e<0&&p.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function f(t){return t.x-t.y}function x(t){return t.x+t.y}class P 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 y{constructor(t){this.m_geoms=[],this.m_description=(0,n.x)(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,i.t)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&(0,i.t)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.G.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.D)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.F)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.x)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new r.E;const i=new r.E;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new n.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.J;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,i.b)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new o.J;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,i.b)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);(0,i.b)("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new y({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.t)("");const e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(const t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){const t=new 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,i.g)(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const t of this.m_geoms){const s=t.getBoundary();s&&e.m_geoms.push(s)}return t}clone(){return new y({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.G.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(s.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.t)("");const e=t;e!==this&&(this.m_geoms=(0,r.b)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.z)(e,t);this.assignVertexDescription(s)}}function E(t,e=-1){return new P(t,e)}y.type=i.G.enumGeometryCollection;class C{constructor(){this.x=r.I.getNAN(),this.y=r.I.getNAN()}static getNAN(){return new C}static constructPoint2D(t){const e=new C;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new C;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new C;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 C).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 C;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new C;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.ae.clone(),this.y=r.F.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return r.P.construct(this.x.value(),this.y.value())}}class S{constructor(){this.a11=new r.I(1),this.a12=new r.I(0),this.a21=new r.I(0),this.a22=new r.I(1)}clone(){const t=new S;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,r.b)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new r.I(1),n=new r.I(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new r.I(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.F)&&e.negateThis();const h=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(h),i.setE(h);const m=e.mulE(s);t[0]=this.a11.addE(m),t[1]=this.a22.subE(m)}else i=new r.I(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,r.b)(t[0],t[0]=t[1]),e[1]=(0,r.b)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var v=n.V;function b(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function I(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function w(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function D(t,e,s,n,o,a,h,m){let l=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),c=t,g=e,_=!1;l>u&&(g=(0,r.b)(c,c=g),n=(0,r.b)(s,s=n),u=(0,r.b)(l,l=u),_=!0);const d=0===s;{h[0]=d?1:0;const t=c.getCoord2D(h[0]);m[0]=g.getClosestCoordinate(t,!1);const e=g.getCoord2D(m[0]);if(r.P.distance(t,e)<=o){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(c.getCoord2D(e[i])),!g.isCloserThanDistance(t,new r.E(0,1),o)){s=!1;break}if(s)return _&&(m[0]=(0,r.b)(h[0],h[0]=m[0])),1}}if(l<=3*o)return 0;let p=(0,r.c)(Math.max(o/l,.1),0,.5),f=.01*o,x=0,P=0,y=p,E=-1,C=0,S=1/32;for(let t=0;;t++){(0,i.g)(t<4095);const e=d?p:1-p,s=c.getCoord2D(e),l=g.getClosestCoordinate(s,!1);if(l===n)return C;const u=g.getCoord2D(l),v=r.P.distance(s,u);if(0===t&&(E=v),v<=f?(S=.5,P=v,x=p):(y=p,E=v),Math.abs(P-E)>.1*f&&y-x>1e-16)p=(0,r.w)(x,y,S);else{if(h[C]=e,m[C]=l,_&&(m[C]=(0,r.b)(h[C],h[C]=m[C])),1===a||1===C)return 1===C&&h[0]>h[1]&&(h[1]=(0,r.b)(h[0],h[0]=h[1]),m[1]=(0,r.b)(m[0],m[0]=m[1])),C+1;C++,x=y,P=E,y=.8,E=-1,p=.8,S=1/32,f=10*o,t=0}}}function T(t,e,s,i,n,o,a,h,m){if((0,r.Y)(s,0,1)&&(0,r.Y)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,l=new C,u=(0,r.a5)();if(t.queryDerivative(new r.I(s,u),l),l.isTrueZero()){const e=1===s?-1e-12:m;t.queryDerivative(new r.I(s,u).add(e),l)}1===s&&l.negateThis();const c=new C;if(e.queryDerivative(new r.I(i,u),c),c.isTrueZero()){const t=1===s?-1e-12:m;e.queryDerivative(new r.I(i,u).add(t),c)}1===i&&c.negateThis(),l.isZero()||l.normalize(),c.isZero()||c.normalize();const g=l.dotProduct(c),_=l.crossProduct(c);_.scaleError(3);const d=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(g.ge(r.F)&&(_.isZero()||Math.abs(_.value())<d()))return D(t,e,s,i,n,o,a,h)}return 0}function N(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function A(t,e,s){t.m_XStart=e,t.m_YStart=s}function G(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function M(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function q(t,e){const s=new n.v;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)]:v.getDefaultValue(1)}(t,e),s}function F(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 V(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let i=1;i<t.m_description.getAttributeCount();i++){const n=t.m_description.getSemantics(i);for(let i=0,r=v.getComponentCount(n);i<r;i++){const r=X(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function Y(t,e,s){s.isEmpty()&&(0,i.z)(""),function(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=v.getComponentCount(r);for(let i=0;i<o;i++)R(t,e,r,i,s.getAttributeAsDbl(r,i))}}function X(t,e,s,n){if((e<0||e>1)&&(0,i.s)(""),0===s)return(n<0||n>=2)&&(0,i.s)(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=v.getComponentCount(s);(n<0||n>=r)&&(0,i.s)("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:v.getDefaultValue(s)}function R(t,e,s,n,r){if((e<0||e>1)&&(0,i.s)(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:(0,i.s)(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:(0,i.s)(""):(0,i.s)(""),void t.endPointModified();const o=v.getComponentCount(s);(n<0||n>=o)&&(0,i.s)("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function k(t,e){if(t===e)return;e.isEmpty()&&(0,i.z)("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=v.getComponentCount(n);for(let s=0;s<r;s++){let i=X(e,0,n,s);R(t,0,n,s,i),i=X(e,1,n,s),R(t,1,n,s,i)}}}function L(t){return t.absNorm()*(0,r.g)()}function B(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,r.g)()}function H(t,e,s){const i=new p;t.queryEnvelopeW(r.E.unit(),i);const n=new p;return e.queryEnvelopeW(r.E.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function z(t,e,s){const i=(0,r.an)(t,s),n=(0,r.an)(e,s);i.sort(((t,e)=>t.compare(e))),n.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){if(i[t].compare(n[t])<0)return-1;if(0!==i[t].compare(n[t]))return 1}return 0}var U=n.V;class O{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,n.x)(),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,n.W)(),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,n.x)());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,n.W)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);(0,i.c)("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.f)(2*t,Number.NaN)),(0,r.a)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,r.a)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,i.b)("not implemented"),0}snapControlPoints3D(){return(0,i.b)("not implemented"),!1}setCoordsForIntersector3D(t,e,s){(0,i.b)("not implemented")}transformAttribute(t,e,s,n,r){(0,i.b)("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.z)(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let s=1,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=U.getComponentCount(i);for(let s=0;s<r;s++)R(this,0,i,s,t.getAttributeAsDbl(i,s)),R(this,1,i,s,e.getAttributeAsDbl(i,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 q(this,0)}setStartXYZ(t){F(this,0,t)}setStartXYZCoords(t,e,s){F(this,0,n.v.construct(t,e,s))}queryStart(t){V(this,0,t)}setStart(t){Y(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return X(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,i.g)(0),0}setStartAttribute(t,e,s){R(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=U.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=U.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,i.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,i.g)(0),0}getEndXY(){return new 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 q(this,1)}setEndXYZ(t){F(this,1,t)}setEndXYZCoords(t,e,s){F(this,1,n.v.construct(t,e,s))}queryEnd(t){V(this,1,t)}setEnd(t){Y(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return X(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,i.g)(0),Math.trunc(0)}setEndAttribute(t,e,s){R(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.t)("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,r.a)(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=X(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(X(this,1,t,e)),s}calculateLength3D(t){return(0,i.g)(0),0}getCoord3D(t){return(0,i.g)(0),{}}getCoord2D(t){const e=r.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return(0,i.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=U.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=o.J.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,i),i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&r.P.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,r.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.b)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=U.getComponentCount(e);t<s;t++){const s=X(this,0,e,t);R(this,0,e,t,X(this,1,e,t)),R(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==n){const e=new Array(9),r=new Array(9),o=this.intersect(t,null,e,r,0);(0,i.g)(o<=9),0===o&&(0,i.c)(""),null!==s&&(s[0]=e[0]),null!==n&&(n[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,a=-1,h=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==n&&(n[0]=a),null!==s&&(s[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==n&&(n[0]=a),null!==s&&(s[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==s&&(s[0]=a),null!==n&&(n[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==s&&(s[0]=a),null!==n&&(n[0]=1)),o}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return(0,r.w)(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,i.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){const s=(0,n.H)();(0,n.J)(e,t.m_description,s);let i=null;const o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(i=new Array(2*o),(0,r.a)(i,e.getDefaultPointAttributes(),0,2,o),(0,r.a)(i,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let n=1;n<e.getAttributeCount();n++){const r=s[n];if(-1!==r){const s=t.m_description.getPointAttributeOffset(r)-2,h=e.getPointAttributeOffset(n)-2,m=v.getComponentCount(e.getSemantics(n));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[o+h]=t.m_attributes[a+s]}}t.m_attributes=i,t.m_description=e}(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.D)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.F)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.x)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.t)("wrong geometry type");const e=t;e.m_description=(0,r.b)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,r.b)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,r.b)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,r.b)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,r.b)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,r.b)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let t=0,s=2*(this.m_description.getTotalComponentCount()-2);t<s;t++)if(!(0,r.af)(this.m_attributes[t],i.m_attributes[t],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,e,s){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,i.t)("");const t=new a.T,n=0===e?s:0,r=1===e?s:0;t.setShiftCoords(n,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=U.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}O.s_maxMonotonicPartParams=8;class W extends O{constructor(t){super(t)}}class j extends W{isTrue3D(){return!0}constructor(t){super(t)}}function J(t,e,s){Z(e,t.getStartXY(),t.getEndXY(),s)}function Z(t,e,s,i){(0,r.D)(e,s,t,i)}function Q(t,e){return(0,r.w)(t.m_XStart,t.m_XEnd,e)}function K(t,e){return(0,r.w)(t.m_YStart,t.m_YEnd,e)}function $(t,e,s){e.value()<=.5?(0,r.a3)(2,C.constructPoint2D(t.getStartXY()),C.constructPoint2D(t.getEndXY()),e,s):(0,r.a4)(2,C.constructPoint2D(t.getStartXY()),C.constructPoint2D(t.getEndXY()),e,s)}function tt(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 et(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.b)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,r.b)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=(0,r.b)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function st(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:function(t,e){const s=rt(t,e.m_XStart,e.m_YStart),i=rt(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=rt(e,t.m_XStart,t.m_YStart),r=rt(e,t.m_XEnd,t.m_YEnd);return!(n<0&&r<0||n>0&&r>0)&&(ht(t)>ht(e)?at(t,e):at(e,t))}(t,e)?4:0}function it(t,e,s,i,n,o,a,h){null!==i&&(i.length=2),null!==n&&(n.length=2),null!==s&&(s.length=2);const m=function(t,e,s,i,n,o,a,h,m){const l=nt(t,e.getStartXY(),a,!1),u=nt(t,e.getEndXY(),a,!1),c=nt(e,t.getStartXY(),a,!1),g=nt(e,t.getEndXY(),a,!1);let _=0,d=0;if(!Number.isNaN(l)){let s=!1;h&&(0,r.Y)(l,0,1)&&t.getCoord2D(l).isEqualPoint2D(e.getStartXY())&&(_++,s=!0),s||(n&&(n[d]=l),o&&(o[d]=0),i&&(i[d]=r.P.construct(e.m_XStart,e.m_YStart)),d++)}if(!Number.isNaN(u)){let s=!1;h&&(0,r.Y)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(_++,s=!0),s||(2>d&&(n&&(n[d]=u),o&&(o[d]=1),i&&(i[d]=r.P.construct(e.m_XEnd,e.m_YEnd))),d++)}if(2!==d&&!Number.isNaN(c)&&!(0===l&&0===c||0===u&&1===c)){let s=!1;h&&(0,r.Y)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getStartXY())&&(_++,s=!0),s||(2>d&&(n&&(n[d]=0),o&&(o[d]=c),i&&(i[d]=r.P.construct(t.m_XStart,t.m_YStart))),d++)}if(2!==d&&!Number.isNaN(g)&&!(1===l&&0===g||1===u&&1===g)){let s=!1;h&&(0,r.Y)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(_++,s=!0),s||(2>d&&(n&&(n[d]=1),o&&(o[d]=g),i&&(i[d]=r.P.construct(e.m_XEnd,e.m_YEnd))),d++)}if(d>0)return m&&(o=(0,r.b)(n,n=o)),2===d&&n&&n[0]>n[1]&&(n[1]=(0,r.b)(n[0],n[0]=n[1]),o&&(o[1]=(0,r.b)(o[0],o[0]=o[1])),i&&(i[1]=(0,r.b)(i[0],i[0]=i[1]))),d;if(_>0)return 0;const p=function(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,h=o*n-i*a;if(0===h)return r.P.getNAN();const m=4*(0,r.a5)()*(Math.abs(o*n)+Math.abs(i*a)),l=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,c=o*u-l*a,g=4*(0,r.a5)()*(Math.abs(o*u)+Math.abs(l*a)),_=c/h,d=Math.abs(h),p=(g*d+m*Math.abs(c))/(h*h)+(0,r.a5)()*Math.abs(_);if(_<-p||_>1+p)return r.P.getNAN();const f=i*u-l*n,x=f/h,P=(4*(0,r.a5)()*(Math.abs(i*u)+Math.abs(l*n))*d+m*Math.abs(f))/(h*h)+(0,r.a5)()*Math.abs(x);if(x<-P||x>1+P)return r.P.getNAN();let y=(0,r.c)(_,0,1),E=(0,r.c)(x,0,1);const C=r.P.getNAN();J(t,y,C);const S=r.P.getNAN();if(J(e,E,S),!s||r.P.distance(C,S)>s){const i=r.P.getNAN();(0,r.D)(C,S,.5,i),y=t.getClosestCoordinate(i,!1),E=e.getClosestCoordinate(i,!1);const n=r.P.getNAN();J(t,y,n);const o=r.P.getNAN();J(e,E,o),n.subThis(o);const a=n.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:(i&&(i[0]=t.getCoord2D(p.x)),n&&(n[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,s,i,n,o,a,h);return i&&(i.length=m),n&&(n.length=m),s&&(s.length=m),m}function nt(t,e,s,i){const n=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?(n.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(n.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,n);let u=l.length(),c=3*u*(0,r.a5)();if(u<=Math.max(s,c))return i&&0===u?Number.NaN:h;if(l.setSub(e,o),u=l.length(),c=3*u*(0,r.a5)(),u<=Math.max(s,c))return i&&0===u?Number.NaN:m;l.setCoords(o.x-n.x,o.y-n.y);const g=l.length();if(g>0){const t=1/g;l.scale(t);const i=r.P.getNAN();i.setSub(e,n);const u=i.dotProduct(l),c=8*i.dotProductAbs(l)*(0,r.a5)();l.leftPerpendicularThis();const _=i.dotProduct(l),d=8*i.dotProductAbs(l)*(0,r.a5)(),p=Math.max(s,c);if(u<-p||u>g+p)return Number.NaN;const f=Math.max(s,d);if(Math.abs(_)<=f){let i=u*t;i=(0,r.c)(i,0,1);const l=r.P.getNAN();if(Z(i,n,o,l),r.P.distance(l,e)<=s){if(i<.5){if(r.P.distance(l,n)<=s&&r.P.distance(e,n)<=s)return h}else if(r.P.distance(l,o)<=s&&r.P.distance(e,o)<=s)return m;return a?1-i:i}}}return Number.NaN}function rt(t,e,s){const i=r.P.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=r.P.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const o=n.crossProduct(i),a=4*(0,r.a5)()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?-1:o<-a?1:0}function ot(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,o=i?t.m_YStart:t.m_YEnd,a=r.P.getNAN();return a.x=e.getEndX()-n,a.y=e.getEndY()-o,!(s.dotProduct(a)>3*(0,r.a5)()*s.dotProductAbs(a))||(a.x=e.getStartX()-n,a.y=e.getStartY()-o,s.dotProduct(a)<=3*(0,r.a5)()*s.dotProductAbs(a))}function at(t,e){const s=r.P.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!ot(t,e,s,!1)&&(s.negateThis(),!!ot(t,e,s,!0))}function ht(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}class mt{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&(0,i.s)("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&(0,i.s)("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,i.s)(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount()||(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,0))}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&(0,i.s)(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,i.r)(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.s)("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&(0,i.s)(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!=(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.s)(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&(0,i.s)(""),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 lt{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,i.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new lt;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0==--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,i.g)(this.uniqueUse())}setQuadTree(t){(0,i.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,i.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function ut(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function ct(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function gt(t,e){return t.readPoint2D(e+4)}function _t(t){const e=t.getGeometryType();return e===i.G.enumEllipticArc?10:e===i.G.enumBezier?4:e===i.G.enumRationalBezier2?5:e===i.G.enumBezier2?2:void(0,i.c)("")}function dt(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 o=4*(0,r.a5)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,r.a5)();if(1===t.getMaxDerivative()){(0,i.g)(s>0);const a=yt(t,0,e,(0,r.a5)(),o);return n[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 i=t.getMaxDerivative()-1;i>=0;i--){h=m,m=[];for(let l=0,c=h.length;l<c;l++){if(h[l][0]<h[l][1]){let c,g,_;if(i===t.getMaxDerivative()-1?({root:c,funcAtRoot:g,cRoots:_}=yt(t,i,r.E.construct(h[l][0],h[l][1]),a,.5*o)):({root:c,funcAtRoot:g,cRoots:_}=Et(t,i,r.E.construct(h[l][0],h[l][1]),0,.5*o)),1===_){if(0===i)u<s&&(h[l][0]<=e.vmin&&h[l][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),h[l][0]<=e.vmax&&h[l][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),n[u]=e.snapClip(c),u>0?n[u]-n[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 ft(t,e,s,i,n,o){const a=(0,r.m)(r.I,2),h=vt(new r.I(t),new r.I(e),new r.I(s),i,n,a);return o[0]=a[0].value(),o[1]=a[1].value(),h}function xt(t,e,s,i,n,o,a){const h=(0,r.m)(r.I,3),m=bt(new r.I(t),new r.I(e),new r.I(s),new r.I(i),n,o,h);return a[0]=h[0].value(),a[1]=h[1].value(),a[2]=h[2].value(),m}function Pt(t,e,s,i,n,o,a,h){return function(t,e,s,i,n,o,a,h){const m=new Array(s*s);m.fill(0),(0,r.a)(h,i,0,0,s);const l=new Array(s),u=new Array(s),c=new Array(s);let g=t(h,s,e);let _=0;for(_=0;_<100;_++){const i=g;for(let t=0;t<s;++t)u[t]=h[t];if(_%s==0){m.fill(0);for(let t=0;t<s;t++)m[t*s+t]=1}let a=0,d=0;for(let i=0;i<s;++i){for(let t=0;t<s;++t)l[t]=m[i*s+t];const r=g;g=Ct(t,e,h,l,n,o,s);const u=r-g;u>a&&(d=i,a=u)}for(let t=0;t<s;t++)l[t]=h[t]-u[t],c[t]=h[t]+(h[t]-u[t]);const p=t(c,s,e);if(p<i&&2*(i-2*g+p)*(0,r.s)(i-g-a)<(0,r.s)(i-p)*a){g=Ct(t,e,h,l,n,o,s);for(let t=0;t<s;++t)m[d*s+t]=m[(s-1)*s+t],m[(s-1)*s+t]=l[t]}if(i<=g)return t(h,s,e)}return g}(t,e,s,i,n,o,0,h)}function yt(t,e,s,n,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=s.vmax,l=0,u=Number.MAX_VALUE,c=t.getValue(e,h),g=t.getValue(e,m),_=0,d=0,p=0;if(c>=0&&g>=0||c<=0&&g<=0)return Math.abs(c)<Math.abs(g)?(a.funcAtRoot=c,a.root=h,a.cRoots=0===c?1:0,a):(a.funcAtRoot=g,a.root=m,a.cRoots=0===g?1:0,a);Math.abs(c)<Math.abs(g)&&(m=(0,r.b)(h,h=m),g=(0,r.b)(c,c=g)),l=h,_=c;let f=!0,x=0;for(;0!==g&&Math.abs(h-m)>n*Math.abs(m)+o;x++){let s=x>64;if(!s){d=c!==_&&g!==_?h*g*_/((c-g)*(c-_))+m*c*_/((g-c)*(g-_))+l*c*g/((_-c)*(_-g)):m-g*(m-h)/(g-c);const t=(3*h+m)/4;if(s=!(d>t&&d<m||d>m&&d<t),!s){const t=n*Math.abs(m)+o;if(f){const e=Math.abs(m-l);s=Math.abs(d-m)>=.5*e||e<t}else{const e=Math.abs(l-u);s=Math.abs(d-m)>=.5*e||e<t}}}if(s?(d=(h+m)/2,f=!0):f=!1,p=t.getValue(e,d),0===p)return a.root=d,a.funcAtRoot=p,a.cRoots=1,a;if(!s){const s=h-d,i=d-m;if(Math.abs(s)>10*Math.abs(i)){let s=m+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);(0,r.d)(c)*(0,r.d)(i)>0?(h=s,c=i):s=(0,r.w)(h,m,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=h-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);(0,r.d)(g)*(0,r.d)(s)>0?(m=i,g=s):i=(0,r.w)(h,m,.25)}}}u=l,l=m,_=g,(0,r.d)(c)*(0,r.d)(p)<0?(m=d,g=p):(h=d,c=p),Math.abs(c)<Math.abs(g)&&(m=(0,r.b)(h,h=m),g=(0,r.b)(c,c=g)),128===x&&(0,i.c)("Root_finder iterations exceeded")}return a.root=m,a.funcAtRoot=g,a.cRoots=1,a}function Et(t,e,s,n,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.b)(m,m=u),l=(0,r.b)(h,h=l));let c=.5*(h+l),g=Math.abs(l-h),_=g,d=t.getValue(e,c),p=t.getValue(e+1,c),f=4,x=1,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*d)>Math.abs(g*p)&&x++),g=_;let i=!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),i=Math.max(h,l);if(c===e){s=c,c=e+t,_=c-s;break}if(c===i){s=c,c=i-t,_=c-s;break}}}_=.5*(l-h),s=c,c=h+_,i=h===c||l===c}while(0);else for(;;){_=x*d/p,s=c,c-=_,i=c===s;const t=Math.min(h,l),e=Math.max(h,l);if(c<t){if(x>1){c=s,x--;continue}_=s-t,c=t}else if(c>e){if(x>1){c=s,x--;continue}_=s-e,c=e}break}if(i||Math.abs(_)<o){s!==c&&(d=t.getValue(e,c));break}d=t.getValue(e,c),p=t.getValue(e+1,c);const n=h,r=l;d<0?(m=d,h=c):(u=d,l=c),2===E&&(h===n&&l===r||y>1&&Math.abs(_)>=.5001*Math.abs(g))?P++:P=0,1===E?(f++,y=0):(f=0,y++)}return 100===C&&(0,i.c)("Root_finder iterations exceeded"),a.root=c,a.funcAtRoot=d,a.cRoots=1,a}function Ct(t,e,s,i,n,o,a){const h=i.slice(0,a);let m=0;for(let t=0;t<a;t++)m+=i[t]*i[t];if(m=Math.sqrt(m),m>0)for(let t=0;t<a;t++)h[t]/=m;let l=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(a);for(let e=0;e<a;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(h[t]),i=Math.abs(h[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<a;e++){const i=t[e];if(0===h[i])continue;let a=(n[i]-s[i])/h[i],m=(o[i]-s[i])/h[i];m<a&&(m=(0,r.b)(a,a=m)),a>l&&(l=a),m<u&&(u=m)}}let c=0;const g=(Math.abs(l)+Math.abs(u))*(0,r.a5)()*100,_=new Array(a),d=h.slice();function p(i,n){for(let t=0,e=a;t<e;t++)_[t]=s[t]+i*d[t];return t(_,a,e)}g>0&&(c=function(t,e,s,i,n,o){return function(t,e,s,i,n,o){const a=(0,r.as)();let h=i,m=t(h,e),l=s,u=n,c=t(l,e),g=t(u,e);m>c&&(m=c,h=l),m>g&&(m=g,h=u);let _=l,d=u,p=c,f=g;p>f&&(p=(0,r.b)(f,f=p),d=(0,r.b)(_,_=d));let x=h-_,P=_-d;const y=.5*Math.min(o,u-l),E=2*y;let C,S=0;for(C=0;C<100&&!(u-l<=E);++C){const s=l+.5*(u-l);let i=S>0;if(!i&&Math.abs(P)<=y&&(i=!0,S=3),!i){const t=h-_,e=h-d,s=t*(m-f);let n=e*(m-p),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*P/2)||r<=n*(l-h)||r>=n*(u-h)?(i=!0,S=3):(P=x,x=r/n)}i&&(P=h>=s?l-h:u-h,x=a*P,S--);let n=h+x;n<l+y?n=l+y:n>u-y&&(n=u-y);const r=t(n,e);r<m?(n>=h?(l=h,c=m):(u=h,g=m),d=_,_=h,h=n,f=p,p=m,m=r):(n<h?(l=n,c=r):(u=n,g=r),r<=p||_===h?(d=_,_=n,f=p,p=r):(r<=f||d===h||d===_)&&(d=n,f=r))}return h}(t,e,s,i,n,o)}(p,null,l,0,u,g));const f=p(c);for(let t=0,e=a;t<e;t++)s[t]=(0,r.c)(_[t],n[t],o[t]);return f}function St(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function vt(t,e,s,i,n,o){if(0===t.value())return n?(o[0].set(1),i.containsCoordinate(o[0].value())?1:0):St(e,s,i,o[0]);if(n){let e=2;return o[0].set(1),o[1].setE(s).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,r.b)(o[0],o[0]=o[1])),e}const a=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(r.ag));if(a.lt(r.F))return 0;const h=new r.I(e.value()>=0?1:-1),m=a.clone().sqrtThis(),l=new r.I(-.5).mulThisE(e.clone().addThisE(h.clone().mulThisE(m)));let u=0;o[0].setE(l.divE(t));const c=new r.I(o[0].value()),g=new r.I(t.value()).mulE(c).addE(new r.I(e.value()).mulE(c).addE(new r.I(s.value())));return g.isZero()||Gt(o[0],t,e,s,o[0]),i.containsCoordinate(o[0].value())&&u++,0!==m.value()&&0!==l.value()?(o[u].assign(s.divE(l)),c.set(o[u].value()),g.assign(new r.I(t.value()).mulE(c).addE(new r.I(e.value()).mulE(c).addE(new r.I(s.value())))),g.isZero()||Gt(o[u],t,e,s,o[u]),i.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,r.b)(o[0],o[0]=o[1])),u):u}function bt(t,e,s,n,o,a,h){if(0===t.value())return vt(e,s,n,o,a,h);if(a){let s=1;h[0].set(1);const i=h.slice(s),a=vt(t,e.addE(t),n.negate(),o,!1,i);if(a>0){s+=a;for(let t=1;t<s;t++)h[t].eq(r.ae)&&(h[s-1]=(0,r.b)(h[t],h[t]=h[s-1]),s--)}const m=h.slice(0,s);m.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)h[t]=m[t];return s}return function(t,e,s,n,o,a){const h=(0,r.m)(r.I,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.I,2),c=vt(t.mul(3),e.mul(2),s,o,!1,u);if(c<0)return n.isZero()?-1:0;for(let t=0;t<c;t++)o.containsCoordinate(u[t].value())&&h[m++].setE(u[t]);(0,r.Q)(h,0,m,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const g=(0,r.m)(r.I,5);g[0].set(o.vmin);for(let t=0;t<m;t++)g[1+t].setE(h[t]);g[1+m].set(o.vmax);const _=m+2;let d=1,p=0;{const i=g[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(n).isZero()){const r=wt(t,e,s,n);i.setError(r.estimateError(i.value())),a[p]=i,p++,d++}}for(let r=d;r<_;r++){const h=g[r].clone(),m=t.clone().mulThisE(h).addThisE(e).mulThisE(h).addThisE(s).mulThisE(h).addThisE(n).isZero();if(m||!g[r].eq(g[r-1])){if(m||Nt(g[r-1].value(),g[r].value(),g[r-1].clone().addThisE(g[r]).divThisByPower2(2),t,e,s,n,h)){if(p>0&&h.eq(a[p-1]))continue;if(p>=3&&(0,i.c)("cubic_polynomial_solver_too_many_roots"),m){const i=wt(t,e,s,n);h.setError(i.estimateError(h.value()))}a[p]=h,p++}if(g[r].value()===o.vmax)break;m&&r++}}return p}(t,e,s,n,o,h)}function It(t,e,s,n,o,a){return(a<e||e<0)&&(0,i.t)("nth_degree_real_roots"),function(t,e,s,i,n){const o=new Dt(t,e,s,(0,r.a5)());let a=0;if(2===o.truePower)a=vt(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=St(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=pt(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let t=0;t<a;t++)n[t].setError(o.getError(n[t].value()));return a}(t,e,s,n,o)}function wt(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class Dt{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=this.truePower-t+1;for(let s=0,i=this.truePower-t;s<=i;++s){e[s]=this.coefs[s+t].clone();let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new r.K(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new r.K(0),i=new r.I(1),n=new r.I(0);for(let t=0,r=this.power;t<=r;++t)n.addThisE(this.coefs[t].mulE(i)),s.pe(i.value()*this.coefs[t].eps()),i.mulThis(e);s.pe(n.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);const i=new r.I(1),n=new r.I(0);for(let s=0,r=this.truePower-e;s<=r;++s)n.addThisE(this.curCoefs[s].mulE(i)),i.mulThis(t);if(!n.isZero())return Math.pow(o*s.getResult()/Math.abs(n.value()),1/e)}return 0}}function Tt(t,e,s,i,n,o){let a=t,h=e,m=h-a;if(!o){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(h=(0,r.b)(a,a=h),n=(0,r.b)(s,s=n)),s>=0||n<=0)return!1}let l,u=!1,c=s,g=0;for(;g<100;g++){const t=i.calcF(c);if(l=i.calcDF(c),l.isZero())return!1;if(!t.value()||g>3&&t.isZero()){u=!0;break}o||(t.value()<0?a=c:h=c);const e=t.value()/l.value(),s=c-e;o||(s>=a&&s<=h||s>=h&&s<=a)&&Math.abs(e)<=.5*m?(c=s,m=Math.abs(e)):(m=Math.abs(.5*(h-a)),c=.5*(a+h))}return!!u&&(n.set(c,i.estimateError(c)),!0)}function Nt(t,e,s,i,n,r,o,a){return Tt(t,e,s.value(),wt(i,n,r,o),a,!1)}class At{constructor(t,e,s){this.coefs=(0,r.m)(r.I,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new r.I(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new r.I(t);return r.I.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new r.I(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function Gt(t,e,s,i,n){return Tt(0,0,t.value(),new At(e,s,i),n,!0)}var Mt=n.V;class qt extends W{constructor(t){void 0===t||(0,r.T)(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,i.c)("unexpected constructor args")}getBoundary(){return Wi(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),_s(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),_s(this)}getGeometryType(){return i.G.enumBezier2}queryEnvelope(t){if(2!==t.m_EnvelopeType)(0,i.b)("env type not impl");else{if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=bs(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[];ps(this,e);const s=new r.P;for(const i of e)this.queryCoord2D(i,s),t.mergeNe(s)}}}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,i.g)(0)}createInstance(){return new qt({vd:this.m_description})}calculateLength2D(){return fs(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 i=(0,r.m)(r.P,3);this.queryControlPoints(i),Bs(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=C.constructPoint2D(t[1]),n=new C;(0,r.a3)(2,C.constructPoint2D(t[0]),i,e,n);const o=new C;(0,r.a3)(2,i,C.constructPoint2D(t[2]),e,o);const a=new C;(0,r.a3)(2,n,o,e,a),s.setE(a)}else{const i=C.constructPoint2D(t[1]),n=new C;(0,r.a4)(2,C.constructPoint2D(t[0]),i,e,n);const o=new C;(0,r.a4)(2,i,C.constructPoint2D(t[2]),e,o);const a=new C;(0,r.a4)(2,n,o,e,a),s.setE(a)}}(i,e,s)}(this,t,e)}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.U)(this.getStartX(),this.m_cp.x,t),s=(0,r.U)(this.m_cp.x,this.getEndX(),t);return(0,r.U)(e,s,t)}{const e=(0,r.V)(this.getStartX(),this.m_cp.x,t),s=(0,r.V)(this.m_cp.x,this.getEndX(),t);return(0,r.V)(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.U)(this.getStartX(),this.m_cp.x,t),s=(0,r.U)(this.m_cp.x,this.getEndX(),t);return(0,r.U)(e,s,t)}{const e=(0,r.V)(this.getStartY(),this.m_cp.y,t),s=(0,r.V)(this.m_cp.y,this.getEndY(),t);return(0,r.V)(e,s,t)}}cut(t,e,s){const i=new Mr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Mt.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Mt.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){{const e=C.constructPoint2D(t[1]).subE(C.constructPoint2D(t[0])),i=new r.I(1).subE(s),n=C.constructPoint2D(t[2]).subE(C.constructPoint2D(t[1])),o=e.mulE(i).addE(n.mulE(s));return o.mulThisE(new r.I(2)),o}}(t,0,e))}(i,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&(0,i.t)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const n=(0,r.m)(r.P,3);this.queryControlPoints(n),qs(n,t,e,n),s.constructPoints(n)}splitBezierIgnoreAttributes(t,e,s){(0,i.g)(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Mt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.W)(o,a,h,n,Mt.getDefaultValue(e))}getClosestCoordinate(t,e){return ws(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return ws(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=ds(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)As(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.I,3),o=(0,r.m)(r.I,2),a=new r.E(0,1);let h=0;if(t){if(n[0]=new r.I(this.getStartY()).sub(e),n[1]=new r.I(this.m_cp.y).subE(new r.I(this.getStartY())).mulThisByPower2(2),n[2]=new r.I(this.getStartY()).add(this.getEndY()).subE(new r.I(this.m_cp.y).mulThisByPower2(2)),h=vt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.I(this.getStartX()).sub(e),n[1]=new r.I(this.m_cp.x).subE(new r.I(this.getStartX())).mulThisByPower2(2),n[2]=new r.I(this.getStartX()).add(this.getEndX()).subE(new r.I(this.m_cp.x).mulThisByPower2(2)),h=vt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.X)(s,h);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return I(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new o.J;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),qs(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return fs(this,t,!0)}lengthToT(t){return function(t,e){const s=fs(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==pt(new cs(t,e),r.E.unit(),1,n)&&(0,i.c)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,3);!function(t,e,s=!1){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),ks(i,e,s)}(this,e);const s=e[2],i=e[1],n=new r.P,o=s.y*i.x-s.x*i.y;n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60;const a=Ss(this);return n.x+=(e[0].x-t.x)*a,n.y+=(e[0].y-t.y)*a,n}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 n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.t)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=ds(t),a=L(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}n.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=gs(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,i.t)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.c)(t,0,1);let s=Es(this,1,e);return s.isZero()&&(s=Es(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Es(this,1,(0,r.c)(t,0,1))}getCurvature(t){const e=Es(this,1,t),s=Es(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersecting(t,e,s){return 0!==Cr(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new o.J;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){const s=ds(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,r.b)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,r.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=[t];if(!w(this,e))return!1;const s=this.getEndXY().sub(this.getStartXY()),i=s.length(),n=this.getControlPoint1();return n.sub(this.getStartXY()),!(Math.abs(n.crossProduct(s))/i>e[0])}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Ss(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),Ts(s,t,e)}setSegmentFromCoords(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 i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);let o=s[0].clone(),a=i;i>n&&(o=s[2].clone(),a=n);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 i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);s[0].clone();let o=i;return i>n&&(s[2].clone(),o=n),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return As(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&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.D)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&As(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Is(e,bs(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.b)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,r.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){_s(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,i,n){const o=new p;if(function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),Ts(i,e,s)}(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=new r.P,h=ws(t,e,r.E.unit(),!1);return t.queryCoord2D(h,a),r.P.distance(a,e)<=n?(i&&(i[0]=h),1):0}(this,t,e.length,e,s)}endPointModified(){_s(this)}clearEndPointModified(){}}qt.type=i.G.enumBezier2;var Ft=n.V;class Vt extends W{constructor(t){return void 0===t||(0,r.T)(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,i.t)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,i.b)("unexpected constructor param"))}getBoundary(){return Wi(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),ye(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),ye(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),ye(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.J){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 i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ce(s,this.m_weights,e);const i=new r.P;for(const s of e)this.queryCoord2D(s,i),t.mergeNe(i)}}}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 Vt({vd:this.m_description})}calculateLength2D(){return Se(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 i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),function(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const n=[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.I,m=new r.I,l=new r.I;if(s.value()<=.5){const t=(0,r.a0)(n[0],n[1],s),e=(0,r.a0)(n[1],n[2],s);h.setE((0,r.a0)(t,e,s));const i=(0,r.a0)(o[0],o[1],s),u=(0,r.a0)(o[1],o[2],s);m.setE((0,r.a0)(i,u,s));const c=(0,r.a0)(a[0],a[1],s),g=(0,r.a0)(a[1],a[2],s);l.setE((0,r.a0)(c,g,s))}else{const t=(0,r.a1)(n[0],n[1],s),e=(0,r.a1)(n[1],n[2],s);h.setE((0,r.a1)(t,e,s));const i=(0,r.a1)(o[0],o[1],s),u=(0,r.a1)(o[1],o[2],s);m.setE((0,r.a1)(i,u,s));const c=(0,r.a1)(a[0],a[1],s),g=(0,r.a1)(a[1],a[2],s);l.setE((0,r.a1)(c,g,s))}h.divThisE(l),m.divThisE(l);const u=new r.P(h.value(),m.value());ms([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,h.eps()),i.y.set(u.y,m.eps())}([C.constructPoint2D(i[0]),C.constructPoint2D(i[1]),C.constructPoint2D(i[2])],[new r.I(n[0]),new r.I(n[1]),new r.I(n[2])],e,s)}(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0)return void J(new Gr({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void J(new Gr({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}const i=(0,r.m)(r.P,3);this.queryControlPoints(i),ss(i,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 i=new Mr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Ft.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Ft.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=new Array(3);t.queryWeights(o),function(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const o=(0,r.m)(C,4);(function(t,e,s,n,o){const a=[C.constructPoint2D(t[0]),C.constructPoint2D(t[1]),C.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,s,n,o){(0,i.g)(!0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=C.constructCoords(0,0)}const h=we(a,e,0,n),m=function(t,e,s){if(s.toDouble()<=.5){const e=(0,r.a0)(t[0],t[1],s),i=(0,r.a0)(t[1],t[2],s);return(0,r.a0)(e,i,s)}{const e=(0,r.a1)(t[0],t[1],s),i=(0,r.a1)(t[1],t[2],s);return(0,r.a1)(e,i,s)}}(e,0,n),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=we([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,n).mul(2),g=m.sqr(),_=c.divE(g);o[1].setE(_)}(a,[new r.I(e[0]),new r.I(e[1]),new r.I(e[2])],0,n,o)})(t,e,0,s,o),n.setE(o[1])}(n,o,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.t)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,3);this.queryControlPoints(n);const o=[0,0,0];He(n,this.m_weights,t,e,n,o),s.setControlPointsAndWeights(n,o)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Ft.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.W)(o,a,h,n,Ft.getDefaultValue(e))}getClosestCoordinate(t,e){return Fe(this,t,r.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Fe(this,t,0,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=Ee(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)ke(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),o=(0,r.m)(r.I,2),a=new r.E(0,1);let h=0;const m=(0,r.m)(r.P,3);if(this.queryControlPoints(m),t){if(n[0]=new r.I(m[0].y).sub(e).mul(this.m_weights[0]),n[1]=new r.I(m[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.I(m[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=vt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.I(m[0].x).sub(e).mul(this.m_weights[0]),n[1]=new r.I(m[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.I(m[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=vt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.Q)(s,0,h,r.G);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return I(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.J)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.J.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),He(s,this.m_weights,t.vmin,t.vmax,s,[0,0,0]),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Se(this,t,!0)}lengthToT(t){return function(t,e){const s=Se(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==pt(new Ne(t,e),r.E.unit(),1,n)&&(0,i.c)(""),n[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=ns(e);if(1===s){const e=(0,r.m)(r.P,3);ks(t,e);const s=e[2].clone(),i=e[1].clone(),n=new r.P,o=s.y*i.x-s.x*i.y;return n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60,n}if(0===s)return new r.P(0,0);(0,i.g)(s>0);const n=t[1].sub(t[0]),o=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atan2(t,e),a=s*t*e,h=s*s,m=n.mul(2*(2+h)),l=o.mul(2*h-5),u=m.add(l).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return u.add(c).mul(i)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atanh(t/e),a=s*t*e,h=s*s,m=n.mul(4).sub(o.mul(5)),l=n.add(o).mul(2*h),u=m.add(l).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return u.add(c).mul(i)}}(e,s)}(this),s=Ae(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 n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.t)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=Ee(t),a=Ge(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}n.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Pe(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),Te(e,this.m_weights,t)}getDerivative(t){const e=(0,r.c)(t,0,1),s=(0,r.m)(r.P,4);return ve(this,1,e,s),s[1]}getCurvature(t){const e=(0,r.m)(r.P,4);ve(this,2,t,e);const s=e[1].sqrLength();return 0===s?Number.NaN:(e[1].divThis(Math.sqrt(s)),e[1].crossProduct(e[2])/s)}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,3);return this.queryControlPoints(t),Re(t)}getMonotonicPartParams(t,e){const s=Ee(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.b)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,r.b)(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!w(this,e)&&function(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();return n.subThis(t.getStartXY()),!(Math.abs(n.crossProduct(s))/i>e)}(this,e[0])}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ae(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,i.g)(0),0}queryEnvelopeW(t,e){Ye(this,t,e)}setSegmentFromCoords(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),i=r.P.sqrDistance(e[1],e[2]);let n=e[0].clone(),o=s;s>i&&(n=e[2].clone(),o=i);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(n)),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]),i=r.P.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return ke(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&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.D)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&ke(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],qe(e,Me(this))}reverseImpl(){this.m_weights[2]=(0,r.b)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=(0,r.m)(r.P,3);this.queryControlPoints(i);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 n.v;s.setCoordsPoint2DZ(i[t].mul(this.m_weights[t]),this.m_weights[t]);const r=new n.v;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.b)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,r.b)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,r.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){ye(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(Ye(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Ee(t);let h=0;const m=[];let l=a.specialPoints[0];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=xe(t,e,l,n);if(0===m.length)m.push(r);else if(r.t===r.tmin)(0,i.g)(m.at(-1).d<=r.d),m.at(-1).tmax=r.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,i.g)(m.at(-1).d>=r.d);const t=m.at(-1).tmin;m[m.length-1]=r,m.at(-1).tmin=t}else m.push(r);l=n}for(const t of m)if(t.d<=n){const e=t.t;s?(s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){ye(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,n,r,o){(n<=0||o<=0||r<0)&&(0,i.t)("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&(0,i.t)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}Vt.type=i.G.enumRationalBezier2;class Yt{static constructPoint2D(t){return new Yt(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 Yt(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Yt(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Yt(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}class Xt{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map((t=>t.clone())),(0,i.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map((t=>t.clone())),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map((t=>t.clone())),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}fmSubThis(t,e){return(0,i.g)(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].addThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,i.g)(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(t){return(0,i.g)(0),this}subNumber0(t){return(0,i.g)(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let s=e;s<=n;++s)this.m_elements[s].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=n+1;e<=i;++e)this.m_elements[e].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let i=s;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let s=r+1;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let i=0,n=e.power();i<=n;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(t){return(0,i.g)(0),this}mulBigint0(t){return(0,i.g)(0),this}mulBigIntThis(t){return(0,i.g)(0),this}mulInt320(t){return(0,i.g)(0),this}div0(t){return(0,i.g)(0),this}absThis(){return(0,i.g)(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let o=n.power();const a=n.power()-t.power();let h=a;for(e.m_elements=(0,r.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){s.assignMove(n);break}if(o===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[h]=s.clone()}h--,o--}s.updatePower(),e.updatePower()}divThis(t){return(0,i.g)(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,i.g)(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(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}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class Rt extends Xt{constructor(t){super(void 0===t?{zeroCtor:r.M}:{...t,zeroCtor:r.M})}clone(){return new Rt({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let t=e-1;t>=0;--t)s.mulThis(i),s.addThis(this.m_elements[t].abs());return s}}class kt extends Xt{constructor(t){super(void 0===t?{zeroCtor:Rt}:{...t,zeroCtor:Rt})}clone(){return new kt({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new Rt({coef0:t[s]}));return this.updatePower(),this}}function Lt(t,e,s,n,o,a,h,m,l,u,c,g,_,d,p,f,x,P=!1){const y={polypoly1:new kt,polypoly2:new kt,polyX2:new Rt,polyY2:new Rt,polyX2Deriv:new Rt,polyY2Deriv:new Rt,polypolyX1:new kt,polypolyY1:new kt,polypolyX1Deriv:new kt,polypolyY1Deriv:new kt,lazyPolypolyD1:new kt,lazyPolypolyD1Deriv:new kt,lazyPolyD2:new Rt,lazyPolyD2Deriv:null,polypoly11:new kt,polypoly12:new kt,tempPp:new kt,tempPp1:new kt,tempPp2:new kt,tempP:new Rt,tempP1:new Rt,tempP2:new Rt};y.polyX2.construct(h,m),y.polyY2.construct(l,u),y.polypolyX1.constructFromMPValues(t,e),y.polypolyY1.constructFromMPValues(s,n),y.polypoly11.assignCopy(y.polypolyX1),y.polypoly12.assignCopy(y.polypolyY1),c&&(y.lazyPolyD2.construct(c,g),y.polypoly11.mulElementThis(y.lazyPolyD2),y.polypoly12.mulElementThis(y.lazyPolyD2)),o?(y.lazyPolypolyD1.constructFromMPValues(o,a),y.lazyPolypolyD1Deriv=new kt({copy:y.lazyPolypolyD1}),y.lazyPolypolyD1Deriv.derivative1This(),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyX2),y.polypoly11.subThis(y.tempPp),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyY2),y.polypoly12.subThis(y.tempPp)):(y.polypoly11.sub0This(y.polyX2),y.polypoly12.sub0This(y.polyY2)),y.polypolyX1Deriv.assignCopy(y.polypolyX1),y.polypolyX1Deriv.derivative1This(),y.polypolyY1Deriv.assignCopy(y.polypolyY1),y.polypolyY1Deriv.derivative1This(),o&&(y.polypolyX1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyX1),y.polypolyX1Deriv.subThis(y.tempPp2),y.polypolyY1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyY1),y.polypolyY1Deriv.subThis(y.tempPp2)),y.polyX2Deriv.assignCopy(y.polyX2),y.polyX2Deriv.derivative1This(),y.polyY2Deriv.assignCopy(y.polyY2),y.polyY2Deriv.derivative1This(),c&&((0,i.g)(null===y.lazyPolyD2Deriv),y.lazyPolyD2Deriv=new Rt({copy:y.lazyPolyD2}),y.lazyPolyD2Deriv.derivative1This(),y.polyX2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyX2),y.polyX2Deriv.subThis(y.tempP1),y.polyY2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyY2),y.polyY2Deriv.subThis(y.tempP1)),y.polypoly1.assignCopy(y.polypoly11),y.polypoly1.mulElementThis(y.polyX2Deriv),y.tempPp.assignCopy(y.polypoly12),y.tempPp.mulElementThis(y.polyY2Deriv),y.polypoly1.addThis(y.tempPp),y.polypoly2.assignCopy(y.polypolyX1Deriv),y.polypoly2.mulElementThis(y.polyY2Deriv),y.tempPp.assignCopy(y.polypolyY1Deriv),y.tempPp.mulElementThis(y.polyX2Deriv),y.polypoly2.subThis(y.tempPp);let E=[];const C=[];x||(x=[]),f||(f=[]),Jt(y.polypoly11,y.polypoly12,y.tempP);let S=57,v=.25*Number.EPSILON;const b=[];let I=Zt(y.tempP,0,p,v,S,b);if(I<0)return-1;for(let t=0;t<I;t++){Rt.evaluateCoefs(y.polypoly11,r.M.constructDouble(b[t]),y.tempP1);const e=[];let s=Zt(y.tempP1,0,d,v,S,e);if(0!==s)if(Rt.evaluateCoefs(y.polypoly12,r.M.constructDouble(b[t]),y.tempP2),s<0){s=Zt(y.tempP2,0,d,v,S,e),s<0&&(0,i.c)("mp_curve_proximity");for(let i=0;i<s;i++)C.push((0,r.h)(e[i],b[t]))}else{const i=y.tempP2.absEvaluate(r.ai);i.mulThis(r.M.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(r.M.constructDouble(e[n]));s.absThis(),s.lt(i)&&C.push((0,r.h)(e[n],b[t]))}}}I=C.length,Jt(y.polypoly1,y.polypoly2,y.tempP),S=57,v=.25*Number.EPSILON;const w=[];let D=Zt(y.tempP,0,p,v,S,w);D<0&&(D=0);for(let t=0;t<D;t++){Rt.evaluateCoefs(y.polypoly1,r.M.constructDouble(w[t]),y.tempP1);const e=[];let s=Zt(y.tempP1,0,d,v,S,e);if(0!==s)if(Rt.evaluateCoefs(y.polypoly2,r.M.constructDouble(w[t]),y.tempP2),s<0){if(s=Zt(y.tempP2,0,d,v,S,e),s<0)continue;for(let i=0;i<s;i++)E.push((0,r.h)(e[i],w[t]))}else{const i=y.tempP2.absEvaluate(r.ai);i.mulThis(r.M.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(r.M.constructDouble(e[n]));s.absThis(),s.lt(i)&&E.push((0,r.h)(e[n],w[t]))}}}if(D=E.length,0===I&&0===D)return 0;E=E.concat(C),E.sort(((t,e)=>P?(0,r.G)(t.second,e.second):(0,r.G)(t.first,e.first)));const T=(0,r.y)(E,((t,e)=>t.first===e.first&&t.second===e.second));E=E.slice(0,T),f.length=0,x.length=0;for(const t of E)f.push(t.first),x.push(t.second);return(0,i.g)(f.length===x.length),x.length}function Bt(t,e,s,i,n,o,a,h,m,l,u){const c={polyIntersect:new Rt,polyX1:new Rt,polyY1:new Rt,polyX1Deriv:new Rt,polyY1Deriv:new Rt,lazyPolyD1:new Rt,lazyPolyD1Deriv:new Rt,tempP:new Rt,tempP1:new Rt,tempP2:new Rt,polypoly1Proximity:new kt,polypoly2Proximity:new kt};c.polyX1.construct(t,e),c.polyY1.construct(s,i),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.polyIntersect.assignCopy(c.polyX1),c.polyIntersect.mulThis(c.polyX1),c.polyIntersect.mulElementThis(a[0]),c.tempP.assignCopy(c.polyY1),c.tempP.mulThis(c.polyY1),c.tempP.mulElementThis(a[1]),c.polyIntersect.addThis(c.tempP),n?(c.lazyPolyD1.construct(n,o),c.tempP.assignCopy(c.lazyPolyD1),c.tempP.mulThis(c.lazyPolyD1),c.tempP.mulElementThis(a[2]),c.polyIntersect.addThis(c.tempP)):c.polyIntersect.add0(a[2]);{const n=a[0].clone(),o=n.clone();o.sqrThis();const h=a[1].clone(),m=h.clone();m.sqrThis();const l=a[2].clone(),u=n.clone();u.subThis(h),c.polyX1.construct(t,e),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1.construct(s,i),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(m),c.tempP.mulElementThis(l),c.polypoly1Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(h.mul(u).mul(l).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(n.mul(m)),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1),c.tempP1.mulElementThis(o.mul(h)),c.tempP.addThis(c.tempP1),c.tempP.add0(u.mul(u).mul(l)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulElementThis(u.mul(n).mul(h).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.construct0(n.mul(u).mul(u)),c.polypoly1Proximity.addElement(c.tempP),c.polypoly1Proximity.updatePower(),c.tempP.construct0(r.ah),c.polypoly2Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1Deriv),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1Deriv),c.tempP.addThis(c.tempP1),c.tempP.mulElementThis(n.mul(h)),c.polypoly2Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1Deriv),c.tempP.mulElementThis(u.mul(n)),c.polypoly2Proximity.addElement(c.tempP),c.polypoly2Proximity.updatePower()}const g=[],_=[];u||(u=[]);let d=2*c.polyIntersect.power()+58;const p=.5*Number.EPSILON,f=Zt(c.polyIntersect,0,m,p,d,_);if(f<0)return-1;Jt(c.polypoly1Proximity,c.polypoly2Proximity,c.tempP),d=2*c.tempP.power()+58;let x=Zt(c.tempP,0,m,p,d,g);if(x<0&&(x=0),0===f&&0===x)return 0;const P=g.concat(_);u.length=P.length,(0,r.a)(u,P,0,0,P.length),(0,r.p)(u);const y=(0,r.y)(u,((t,e)=>0===(0,r.G)(t,e)));return u.length=y,u.length}function Ht(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function zt(t,e,s,i,n,o,a){if(t.isZero())return o?(a[0].setInt32(1),n.containsCoordinate(1)?1:0):Ht(e,s,n,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)),n.containsCoordinate(a[1].value())||(e=1),n.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,r.b)(a[0],a[0]=a[1])),e}const h=e.clone();h.sqrThis();const m=t.clone();if(m.mulThis(s).ldexpThis(2).negateThis().addThis(h),m.LZ())return 0;const l=i+2,u=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(i),(n.isEmpty()||n.containsCoordinate(a[0].value()))&&g++,u.isZero()||c.isZero()||(a[g].setThis(s).divThis(c).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,r.b)(a[0],a[0]=a[1]))),g}function Ut(t,e,s,n,o,a,h,m){if(t.isZero())return zt(e,s,n,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.b)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.Q)(m,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let i=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),i=1),l(zt(t,e,s,o,a,h,m.slice(1)),i)}if(h){let s=0;a.containsCoordinate(1)&&(m[0].setInt32(1),s=1);const i=e.add(t),r=n.negate(),h=t.add(i).add(r).isZero();return l(zt(t,i,r,o,a,h,m.slice(s)),s)}const u=new r.M,c=new r.M,g=new r.M,_=e.clone();if(_.isZero())c.setThis(s),c.divThis(t),g.setThis(n),c.divThis(t);else{_.divThis(t).divDoubleThis(3).negateThis();const i=e.clone();i.sqrThis();const r=t.clone();r.sqrThis(),c.setThis(t),c.mulThis(s).mulDoubleThis(3).subThis(i).divThis(r).divDoubleThis(3),g.setThis(i),g.mulThis(e),g.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(s).mulDoubleThis(9),g.subThis(u),u.setThis(r),u.mulThis(n).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(_),ie(a,o,m,1)):(m[0].setThis(r.M.cubicRoot(g,o).add(_)),ie(a,o,m,1))}const d=g.clone();if(d.sqrThis().ldexpThis(-2),u.setThis(c.clone()),u.sqrThis().mulThis(c).divDoubleThis(27),d.addThis(u),d.isZero())return m[0].setThis(g),m[0].mulDoubleThis(3).divThis(c),m[1].setThis(m[0]),m[1].negateThis(),m[1].ldexpThis(-1),m[0].addThis(_),m[1].addThis(_),ie(a,o,m,2);if(d.GZ())return d.setThis(r.M.sqrt(d,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.addThis(d),m[0].setThis(r.M.cubicRoot(u,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.subThis(d),m[0].addThis(r.M.cubicRoot(u,o+8)),m[0].addThis(_),ie(a,o,m,1);u.setThis(c),u.divDoubleThis(3).negateThis(),(0,i.g)(u.GEZ());const p=r.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(_),p.addThis(_);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 Rt({zeroCtor:r.M});y.construct0(n),y.addElement(s),y.addElement(e),y.addElement(t);const E=new Rt({copy:y});E.derivative1This();let C=0;const S=(0,r.m)(r.M,4);S[C++].setThis(x),f.gt(x)&&f.lt(P)&&S[C++].setThis(f),p.gt(x)&&p.lt(P)&&S[C++].setThis(p),S[C++].setThis(P);const v=3*o;let b=52,I=Number.EPSILON;for(;b<v;)2*b<=v?(I*=I,b*=2):(I*=Number.EPSILON,b+=52);b+=2;let w=0,D=!1;for(let t=1;t<C;t++)if($t(y,E,S[t-1],S[t],I,b,m[0])){w=1,D=t+1<C;break}if(!w)return 0;if(D){const t=new Rt({zeroCtor:r.M,coef0:m[0]});t.negateThis(),t.addElement(r.ai);const e=new Rt({zeroCtor:r.M}),s=new Rt({zeroCtor:r.M});y.div(t,e,s),(0,i.g)(2===e.power()),(0,i.g)(0===s.power());const n=zt(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,m.slice(1));(0,i.g)(n>=0&&n<=2),w+=n}return ie(a,o,m,w)}function Ot(t,e,s,i,n,o,a,h,m){if(t.isZero())return Ut(e,s,i,n,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.b)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.Q)(m,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let n=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),n=1),l(Ut(t,e,s,i,o,a,h,m.slice(n)),n)}const u=new Rt({zeroCtor:r.M,coef0:n});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),h){let t=0;a.containsCoordinate(1)&&(m[0].setInt32(1),t=1);const e=new Rt({zeroCtor:r.M,coef0:r.M.constructInt32(-1)});e.addElement(r.M.constructInt32(1));const s=new Rt({zeroCtor:r.M}),i=new Rt({zeroCtor:r.M});return u.div(e,s,i),l(Ut(3===s.power()?s.getElement(3):r.ah.clone(),s.power()>=2?s.getElement(2):r.ah.clone(),s.power()>=1?s.getElement(1):r.ah.clone(),s.getElement(0),o,a,s.evaluate(r.ai).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=Ut(3===u.power()?u.getElement(3):r.ah.clone(),u.power()>=2?u.getElement(2):r.ah.clone(),u.power()>=1?u.getElement(1):r.ah.clone(),u.getElement(0),o,a,!1,m.slice(t));return e>0&&(t+=e),(0,r.Q)(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 _=se(u),d=r.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(_.lt(d)?_:d).mul(r.M.constructDouble(g)).toDouble(),ee(u,a,g,c,h,0,m,4)}function Wt(t,e){let s=t,i=e;i.power()>s.power()&&(i=(0,r.b)(s,s=i));const n=s.power()-i.power(),o=new Rt({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let t=0,e=s.power();t<e;t++)if(t>=n){const e=new Rt({copy:i.getElement(t-n)});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(),jt(s)}function jt(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Jt(t,e,s){const i=t.clone(),n=e.clone();for(jt(i),jt(n);0!==i.power()||0!==n.power();)Wt(i,n);s.assignMove(i.getElement(0))}function Zt(t,e,s,i,n,o){o.length=0;const a=t.power(),h=(0,r.m)(r.M,2*a+4),m=function(t,e,s,i,n,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=Ht(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(i),1!==s?0:(o[0].limitPrecisionThis(i),1)}return 2===t.power()?zt(t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):3===t.power()?Ut(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):4===t.power()?Ot(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):ee(t,e,s,i,h,0,o,a)}(t,s||r.E.unit(),i,n,0,h,h.length);if(m>0){o.length=0;for(let t=0;t<m;t++){const e=h[t].value();t>0&&e<=o.at(-1)||o.push(e)}return o.length}return m}function Qt(t,e,s){if((0,i.g)(s>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function Kt(t,e,s,n){if(t.power()<2)return Qt(t,s,n);(0,i.g)(n>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));const a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){const i=t.getElement(1);return i.negateThis(),i.divThis(t.getElement(2)),i.ldexpThis(-1),i.limitPrecisionThis(e),s[0].setThis(i),1}(0,i.g)(n>=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 $t(t,e,s,n,o,a,h){let m=s.clone(),l=n.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.b)(u,u=c),l=(0,r.b)(m,m=l));const _=g?l:m,d=g?m:l,p=m.add(l).ldexpThis(-1);p.limitPrecisionThis(a);const f=l.sub(m);f.limitPrecisionThis(a),f.absThis();const x=f.clone();let P=t.evaluate(p),y=e.evaluate(p);const E=new Rt({copy:t}),C=new Rt({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=r.ai.clone();i.ldexpThis(-(a+2));for(let n=64;n<s;){E.limitPrecisionThis(n),C.limitPrecisionThis(n);const r=E.evaluate(p),o=C.evaluate(p),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(i)&&(y.isZero()||h.divThis(y).absThis().lt(i)))break;E.assignCopy(t),C.assignCopy(e),n=Math.min(n+64,s)}P.limitPrecisionThis(a+2),y.limitPrecisionThis(a+2)}let S=4,v=1,b=0,I=0,w=1;const D=r.M.constructDouble(.25*o),T=r.M.constructDouble(.5001);let N=0;for(;++N<300;){if(N>32&&b>0||y.isZero()||2===w&&b>1||1===w&&S<4)w=1,v>1&&v--;else if(w=2,I>1){const t=f.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&v++}f.setThis(x);const t=new r.M;let e=!1;if(1===w)do{if(I>2){const e=f.clone();if(e.absThis(),e.ldexpThis(4),d.sub(_).ldexpThis(-1).gt(e)){if(p.equals(_)){t.setThis(p),p.setThis(_.add(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}if(p.equals(d)){t.setThis(p),p.setThis(d.sub(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}}}x.setThis(l.sub(m)),x.ldexpThis(-1),x.limitPrecisionThis(a),t.setThis(p),p.setThis(m.add(x)),p.limitPrecisionThis(a),p.lt(_)?p.setThis(_):p.gt(d)&&p.setThis(d),e=m.equals(p)||l.equals(p)}while(0);else for(;;){if(x.setThis(P.div(y)),x.limitPrecisionThis(a),1!==v&&x.mulDoubleThis(v),t.setThis(p),p.subThis(x),p.limitPrecisionThis(a),e=p.equals(t),p.lt(_)){if(v>1){p.setThis(t),v--;continue}x.setThis(t.sub(_)),p.setThis(_)}else if(p.gt(d)){if(v>1){p.setThis(t),v--;continue}x.setThis(t.sub(d)),p.setThis(d)}break}if(e||x.absLessAbs(D)){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(),i=l.clone();P.LZ()?(u.setThis(P),m.setThis(p)):(c.setThis(P),l.setThis(p)),2===w&&(m.equals(s)&&l.equals(i)||I>1&&!x.absLessAbs(T.mul(f)))?b++:b=0,1===w?(S++,I=0):(S=0,I++)}return N>=300&&(0,i.c)("Root_finder iterations exceeded"),h.setThis(p),!0}function te(t,e,s,i,n){const o=t.evaluate(s);if(o.isZero())return!0;const a=r.M.constructDouble(.5*i),h=s.clone();h.subThis(a);const m=t.evaluate(h),l=s.clone();l.addThis(a);const u=t.evaluate(l);if(m.LZ()&&u.GZ()||m.GZ()&&u.LZ())return!0;if(o.GZ()?m.LEZ()||u.LEZ():m.GEZ()||u.GEZ())return!0;const c=m.LEZ()&&u.LEZ(),g=m.GEZ()&&u.GEZ();let _=!1;return c?o.gt(m)&&o.gt(u)&&(_=!0):g&&o.lt(m)&&o.lt(u)&&(_=!0),!!_&&o.absThis().lt(r.M.constructDouble(1e-17))}function ee(t,e,s,n,o,a,h,m){(0,i.g)(s>0),(0,i.g)(m>=t.power());const l=h,u=[];let c=[];const g=new Rt({zeroCtor:t.m_zeroCtor}),_=new Rt({zeroCtor:t.m_zeroCtor}),d=new Rt({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=se(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 S=t,v=null;if(o){const e=new Rt({coef0:r.M.constructInt32(-1)});e.addElement(r.ai),v=new Rt,S=v;const s=new Rt,i=new Rt;for(t.div(e,s,i),v.assignCopy(s);S.evaluate(r.ai).isZero();)S.div(e,s,i),v.assignCopy(s)}let b=!1;if(S.power()>0&&S.getElement(0).isZero())for(b=!0,v||(v=new Rt({copy:S}),S=v);S.getElement(0).isZero();)v.shiftRight(1);let I=n+2*S.power()+2,w=s/Math.pow(2,S.power()+2),D=I;if(r.ah.gt(P)&&r.ah.lt(y))for(let t=0,e=S.power();t<e;t++)if(S.getElement(t).isZero()){u.push(r.ah.clone());break}for(let t=S.power()-1;t>0;t--)if(w*=2,I-=2,D-=2,S.power()-t!=1)if(S.power()-t!=2){_.assignMove(d),d.assignMove(S.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($t(_,g,c[t].first,c[t].second,w,I,s)){u.push(s);let i=s.sub(p);i.limitPrecisionThis(D),e.push((0,r.h)(c[t].first,i)),i=s.add(p),i.limitPrecisionThis(D),e.push((0,r.h)(i,c[t].second))}else e.push(c[t])}c=e,e=[],g.assignMove(_)}else{_.assignMove(S.derivative(t));const e=Kt(_,I,l,m);(0,i.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(D),c.push((0,r.h)(P.clone(),t));let e=1===u.length?y.clone():u[1].sub(p);t=u[0].add(p),t.limitPrecisionThis(D),e.limitPrecisionThis(D),c.push((0,r.h)(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(p),e.limitPrecisionThis(D),t=u[1].add(p),t.limitPrecisionThis(D),c.push((0,r.h)(t,e)),u.length>2&&(t=u[2].add(p),t.limitPrecisionThis(D),c.push((0,r.h)(t,y.clone()))))}else c.push((0,r.h)(P.clone(),y.clone()));g.assignCopy(_),d.assignMove(S.derivative(t-1))}else _.assignMove(S.derivative(t)),1===Qt(_,l,m)&&(l[0].gt(P)&&l[0].lt(y)&&!l[0].isZero()&&u.push(l[0].clone()),g.assignMove(_),d.assignMove(S.derivative(t-1)));u.sort(((t,e)=>t.compare(e))),0===c.length&&(g.assignMove(S.derivative(S.power())),g.isZero()||c.push((0,r.h)(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){$t(S,g,c[N].first,c[N].second,s,n,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])||te(S,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.ah.gt(P)&&r.ah.lt(y)&&(l[T++].setThis(r.ah),(0,r.Q)(l,0,T,((t,e)=>t.compare(e)))),o&&r.ai.gt(P)&&r.ai.lt(y)&&(l[T++].setThis(r.ai),(0,r.Q)(l,0,T,((t,e)=>t.compare(e)))),T}function se(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=r.ah.clone();for(let i=0,n=t.power();i<n;i++){const n=t.getElement(i);n.limitPrecisionThis(53),n.divThis(e).absThis(),n.gt(s)&&s.setThis(n)}return s.addThis(r.ai),s.mulThis(r.M.constructDouble(1+100*Number.EPSILON)),s}function ie(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=(0,r.b)(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=(0,r.b)(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=(0,r.b)(s[1],s[1]=s[2]))));for(let t=0;t<n;++t)s[t].limitPrecisionThis(e);return n}const ne=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],re=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],oe=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],ae=[[.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]],he=[[.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]],me=[[.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 le(t,e,s,i){const n=.5*(i-s),o=s+n,a=new r.K(0);for(let s=0,i=Math.trunc(t/2);s<i;++s){let i,h;switch(t){case 4:i=ne[s][0],h=ne[s][1];break;case 8:i=re[s][0],h=re[s][1];break;case 16:i=oe[s][0],h=oe[s][1];break;case 32:i=ae[s][0],h=ae[s][1];break;case 64:i=he[s][0],h=he[s][1];break;case 128:i=me[s][0],h=me[s][1];break;default:throw new Error("Quadrature_integral: invalid n")}const m=(0,r.ao)(-.5,i,o),l=(0,r.ao)(n,i,o);a.pe(e(m)*h),a.pe(e(l)*h)}return a.getResult()*n}function ue(t,e,s,n,o,a){return function(t,e,s,n,o,a){if(s<e&&(0,i.t)("xTo < xFrom"),s===e)return 0;const h=[0];let m=Number.MAX_VALUE;const l=[Number.MAX_VALUE];let u=0;const c=(0,r.f)(33,Number.NaN),g=(0,r.f)(33,Number.NaN),_=[0];c[0]=1;let d=0,p=0;for(let r=0;r<32;r++){if(u=ce(e,s,n,0===r,u,_),g[r]=u,r+1>=t){ge(r+1-t,t,c,g,0,h,l)||(0,i.c)("polynomial_interpolation");const e=o*Math.abs(h[0])+a,s=Math.abs(m-h[0]);if(s<=e&&Math.abs(l[0])<=e){if(d++,d>1&&(s<=.1*p||0===p||d>2))return h[0]}else d=0;p=s,m=h[0]}g[r+1]=g[r],c[r+1]=.25*c[r]}return h[0]}(t,e,s,a,n,o)}function ce(t,e,s,i,n,o){let a=n;if(i)return o[0]=1,a=.5*(e-t)*(s(t)+s(e)),a;const h=o[0],m=(e-t)/h,l=t,u=new 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 ge(t,e,s,i,n,o,a){let h=0,m=Math.abs(n-s[t]);const l=(0,r.f)(e,Number.NaN),u=(0,r.f)(e,Number.NaN);for(let r=0;r<e;++r){const e=Math.abs(n-s[t+r]);e<m&&(h=r,m=e),l[r]=i[t+r],u[r]=i[t+r]}let c=0,g=0,_=0;o[0]=i[t+h],h--;for(let i=1;i<e;i++){for(let r=0;r<e-i;r++){if(g=s[t+r]-n,_=s[t+r+i]-n,c=g-_,0===c)return!1;const e=(l[r+1]-u[r])/c;l[r]=g*e,u[r]=_*e}if(2*(h+1)<e-i){const t=h+1;a[0]=l[t]}else{const t=h;a[0]=u[t],h--}o[0]+=a[0]}return!0}class _e{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 de(t,e,s,n,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+n*u)return t+(0,r.w)(l,u,.5);const c=(0,r.m)(r.P,4),g=t=>(be(e,s,1,t,c),c[1].length());if(0===h&&m<8){(0,i.g)(m<8);let l=g(0),c=g(1);a[0]+=2,l>c&&(c=(0,r.b)(l,l=c),e[2]=(0,r.b)(e[0],e[0]=e[2]),s[2]=(0,r.b)(s[0],s[0]=s[2]));let _=l/(l+c),d=1,p=u;for(;_<1/32&&p>=o+n*p;){d/=4;const t=g(d);a[0]++,_=l/(t+l);const i=new r.P;if(ss(e,s,.5*d,i),p=r.P.distance(i,e[0]),p<=o){const t=new r.P;ss(e,s,d,t),p+=r.P.distance(t,i)}}if(1!==d){const i=(0,r.m)(r.P,3),l=[0,0,0];Be(e,s,d,e,s,i,l),t=de(t,i,l,n,o,a,0,m+1),h++,m++;continue}}let _=!1;const d=8;a[0]+=d;const p=le(d,g,0,1),f=16;a[0]+=f;const x=le(f,g,0,1);if(_=Math.abs(p-x)>o+n*u,!_)return t+x;if(h<8&&m<9){const i=(0,r.m)(r.P,3),l=[0,0,0];Be(e,s,.5,e,s,i,l),t=de(t,i,l,n,o,a,h+1,m+1),h++,m++;continue}const P=32;a[0]+=P;const y=le(P,g,0,1);if(_=Math.abs(x-y)>o+n*u,!_)return t+y;const E=64;a[0]+=E;const C=le(E,g,0,1);if(_=Math.abs(y-C)>o+n*u,!_)return t+C;const S=128;a[0]+=S;const v=le(S,g,0,1);return _=Math.abs(C-v)>o+n*u,t+v}}function pe(t,e,s,i,n){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 He(o,a,e,s,m,h),de(0,m,h,i,n,[0],0,0)}let fe=class{constructor(t,e,s){this.controlPoints=(0,r.an)(t,3),this.weights=[0,0,0],(0,r.a)(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new r.P;ss(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return be(this.controlPoints,this.weights,1,e,s),2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new r.P;ss(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return be(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;ss(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return be(this.controlPoints,this.weights,3,e,s),2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return(0,i.g)(0),0}};function xe(t,e,s,i){const n=function(t,e,s,i,n){return{tmin:0,tmax:0,t:0,d:0,pt:n.clone()}}(0,0,0,0,r.P.getNAN()),o=new Array(18),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,ns(h),1],l=os(h,s),u=os(h,i),c=pt(new fe(a,m,new r.P(0,0)),r.E.construct(l,u),18,o);ss(a,m,l,n.pt),n.t=l,n.d=r.P.distance(n.pt,new r.P(0,0));const g=new r.P;ss(a,m,u,g);const _=r.P.distance(g,new r.P(0,0));_<n.d&&(n.d=_,n.t=u,n.pt.assign(g));for(let t=0;t<c;t++){ss(a,m,o[t],g);const e=r.P.distance(g,new r.P(0,0));e<n.d&&(n.d=e,n.t=rs(h,o[t]),n.pt.assign(g))}return n}function Pe(t,e,s,i,n){let o=!0;const a=(0,r.m)(r.P,4),h=ue(5,e,s,i,n,(e=>(ve(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length())));o=!1;const m=ue(5,e,s,i,n,(e=>(ve(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 ye(t){t.m_cachedValues=null}function Ee(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new _e,s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Ce(s,i,e.specialPoints),qe(t,e),e}function Ce(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=(0,r.m)(r.I,8);i[0].set(0);let n=1;{const s=new r.I(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new r.I(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.I(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.I,2);let m=vt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.Y)(h[t].value(),0,1)||(i[n]=h[t],n++)}{const s=new r.I(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new r.I(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.I(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.I,2);let m=vt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.Y)(h[t].value(),0,1)||(i[n]=h[t],n++)}if(i[n].set(1),n++,n>2){(0,r.Q)(i,0,n,((t,e)=>(0,r.G)(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let t=0;t<n;t++)s[t]=i[t].value()}function Se(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Se(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Ee(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Ge(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=pe(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function ve(t,e,s,i){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=[0,0,0];t.queryWeights(o),be(n,o,e,s,i)}function be(t,e,s,n,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,n,r){(0,i.g)(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Ie(o,e,0,n),h=De(e,0,n),m=a.divide(h);if(r[0].assign(m),0===s)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],c=h*h,g=Ie(u,l,0,n).mul(2).divide(c);if(r[1].assign(g),1===s)return;const _=De(e,1,n),d=2*h*_,p=Ie(u,l,1,n).mul(2).sub(g.mul(d)).divide(c);if(r[2].assign(p),2===s)return;const f=Ie(u,l,2,n).mul(2),x=2*(_*_+h*De(e,2,n)),P=f.sub(p.mul(d).mul(2)).sub(g.mul(x)).divide(c);r[3].assign(P),3!==s&&(0,i.c)("")}(a,h,s,n,m);for(let t=0;t<=s;t++)o[t].setCoords(m[t].x,m[t].y)}function Ie(t,e,s,n){if(0===s){if(n<=.5){const s=new r.P;(0,r.Z)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r.Z)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r.Z)(2,s,i,n,o),o}{const s=new r.P;(0,r._)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r._)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r._)(2,s,i,n,o),o}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-n).add(t[2].mul(e[2]).sub(s).mul(n));return i.mulThis(2),i}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}(0,i.c)("")}function we(t,e,s,i){if(i.toDouble()<=.5){const s=new C;(0,r.a3)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new C;(0,r.a3)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new C;return(0,r.a3)(2,s,n,i,o),o}{const s=new C;(0,r.a4)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new C;(0,r.a4)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new C;return(0,r.a4)(2,s,n,i,o),o}}function De(t,e,s){if(0===e){const e=(0,r.w)(t[0],t[1],s),i=(0,r.w)(t[1],t[2],s);return(0,r.w)(e,i,s)}return 1===e?2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,i.c)("")}function Te(t,e,s){const i=(0,r.c)(s,0,1),n=(0,r.m)(r.P,4);if(be(t,e,3,i,n),n[1].isZero()){if(n[2].isZero())return n[3];{const t=n[2].clone();return 1===i&&t.negateThis(),t}}return n[1]}let Ne=class{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Se(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}};function Ae(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=ns(e);if(1===s)return vs(t);if(0===s)return 0;const n=[new r.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=n[1].crossProduct(n[2]);if(s<1){(0,i.g)(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const i=t*(1+s),n=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-(0,r.ap)(i)*n)/i}return o*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*o-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-n[1].x*n[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}(e,s)}function Ge(t){return function(t){return 256*(0,r.a5)()*t}(t.calculateUpperLength2D())}function Me(t){return t.m_cachedValues}function qe(t,e){t.m_cachedValues=e}function Fe(t,e,s,i,n){const o=(0,r.m)(r.P,3);t.queryControlPoints(o);const a=[0,0,0];t.queryWeights(a);const h=[0];return 1===Ve(o,a,e,r.E.unit(),i,n,1,h)?h[0]:Number.NaN}function Ve(t,e,s,o,a,h,m,l){(0,i.A)(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=ns(e),g=Yt.constructPoint2D(u[0]),_=Yt.constructPoint2D(u[1]),d=Yt.constructPoint2D(u[2]),p=r.M.constructDouble(c),f=p.clone();f.ldexpThis(1);const x=g.dotProduct(_.sub(g)).mul(p),P=p.mul(p.addDouble(2)),y=d.sub(_.mul(P.ldexp(1))),E=_.sqrLength().mul(p.mul(p).ldexp(1)).add(g.sqrLength().mul(p.ldexp(2).subDouble(1))).add(g.dotProduct(y)),C=d.sub(_.mul(f)).add(g.mul(f.subDouble(1))),S=_.mul(p).sub(g).dotProduct(C).mulDouble(3),v=_.dotProduct(d).mul(p.subDouble(3).mul(p)).ldexp(1),b=_.sqrLength().mul(p.mul(p).ldexp(2)),I=g.sqrLength().mul(p.ldexp(2).subDouble(3)),w=g.dotProduct(d.sub(_.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),D=d.sqrLength().addThis(v).addThis(b).addThis(I).addThis(w),T=g.add(d).sub(_.mul(f)),N=p.subDouble(1),A=d.sub(g).dotProduct(T).mul(N),G=new r.P(0,0),M=[];let q=new r.P;ss(u,e,o.vmin,q);let F=r.P.distance(q,G);if(F<=h&&M.push(new r.P(o.vmin,F)),o.vmin!==o.vmax&&(ss(u,e,o.vmax,q),F=r.P.distance(q,G),F<=h&&M.push(new r.P(o.vmax,F))),o.width()>0){const t=u[2].isZero(),s=(0,r.m)(r.M,4),i=Ot(A,D,S,E,x,58,o,t,s);for(let t=0;t<i;t++){if(!o.containsExclusiveCoordinate(s[t].toDouble()))continue;let i=s[t].toDouble();i=rs(e,i);const n=new r.P;ss(u,e,i,n),F=r.P.distance(n,G),F<=h&&M.push(new r.P(i,F))}}if(a){(0,i.g)(o.equals(r.E.unit()));{ss(u,e,-1,q,!0);const t=new r.P;ss(u,e,0,t);const s=new Gr({start:q,end:t}),i=s.getClosestCoordinate(G,!0);i<1&&(q=s.getCoord2D(i),F=r.P.distance(q,G),F<=h&&M.push(new r.P(i-1,F)))}{ss(u,e,2,q,!0);const t=new r.P;ss(u,e,o.vmax,t);const s=new Gr({start:t,end:q}),i=s.getClosestCoordinate(G,!0);i>0&&(q=s.getCoord2D(i),F=r.P.distance(q,G),F<=h&&M.push(new r.P(1+i,F)))}}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,n.N)(u,4,!1).total(),e=M[0].y;for(let s=1,i=M.length;s<i;s++)if(M[s].y>e+t){M.length=s;break}M.sort(((t,e)=>(0,r.G)(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 Ye(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),Xe(i,n,e,s)}function Xe(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=(0,r.m)(r.P,3);He(t,e,s.vmin,s.vmax,n,[0,0,0]),i.setFromPoints(n,3)}function Re(t){const e=(0,r.$)(t[0].y,t[1].y),s=(0,r.$)(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=(0,r.$)(t[0].x,t[1].x),s=(0,r.$)(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}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 i=(0,r.$)(t[0][s],t[2][s]);i>0?((0,r.$)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.$)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(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,o,a,h,m){(0,i.g)(s>=0&&s<=1&&o!==h&&a!==m),(0,i.g)(e[0]>0&&e[2]>0&&e[1]>=0);const l=[1,ns(e),1],u=os(e,s),c=(0,r.an)(t,3),g=(0,r.m)(n.v,3);$e(c,l,g);const _=(0,r.m)(n.v,3),d=(0,r.m)(n.v,3);as(g,u,o?_:null,h?d:null),hs(e,s,a,m);const p=Re(c);if(o){for(let t=0;t<3;++t)es(_[t],o[t]);ls(c,o),p&&Le(o)}if(h){for(let t=0;t<3;++t)es(d[t],h[t]);ls(c,h),p&&Le(h)}}function He(t,e,s,o,a,h){if((0,i.g)(s>=0&&o<=1&&s<=o),s===o){const i=new r.P,n=ts(t,e,s,i);return ms(t,i),a[0].assign(i),a[1].assign(i),a[2].assign(i),h[0]=n,h[1]=n,void(h[2]=n)}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)(n.v,3);{const i=[1,ns(e),1],n=os(e,s),r=os(e,o);$e(t,i,m),as(m,r,m,null),as(m,n>=r?1:n/r,null,m)}const l=[0,0,0];hs(e,o,l,null),hs(l,s/o,null,l);const u=Re(t),c=(0,r.m)(r.P,3);es(m[1],c[1]),ss(t,e,s,c[0]),ss(t,e,o,c[2]),ls(t,c);for(let t=0;t<3;++t)a[t].assign(c[t]),h[t]=l[t];u&&Le(a)}function ze(t,e,s){const i=ns(e),n=[1,i,1],o=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),(0,r.D)(t[0],t[1],o,s[1]),(0,r.D)(t[2],t[1],o,s[2]),new zs({cp:s}),new Vt({points:t,weight:i});let a=0,h=.1,m=0;for(let e=0;e<9;e++,h+=.1){const e=new r.P;ss(t,n,h,e);const i=new r.P;_i(s,h,i);const o=r.P.sqrDistance(e,i);o>a&&(a=o,m=h)}{const e=new r.P;ss(t,n,m,e);const i=[0];Ti(s,e,r.E.unit(),!1,-1,1,i);const o=new r.P;return _i(s,i[0],o),a=r.P.sqrDistance(e,o),Math.sqrt(a)}}function Ue(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==je(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Oe(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Je(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function We(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Qe(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function je(t,e,s,n,o,a,h,m,l,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!=a)for(let t=0;t<i;t++)a.push(0);if(null!=n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=B(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Gr({start:e.getStartXY(),end:e.getEndXY()}),i=it(t,s,n,o,a,h,m,u);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=(0,r.m)(r.P,3);e.queryControlPoints(g);const _=[0,0,0];e.queryWeights(_);const d=[1,ns(_),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),S=y.sub(P),v=d[0],b=d[1],I=d[2],w=v*b,D=v*I,T=b*I,N=E.dotProduct(f)*w,A=C.dotProduct(f)*D;let G=N,M=A-2*N,q=S.dotProduct(f)*T+A-A;const F=new Array(13),V=new Array(13);let Y=ft(q,M,G,r.E.unit(),!1,F);Y<0&&(F[0]=0,F[1]=1,Y=2);let X=0;for(let t=0,e=X;t<Y;++t){const i=new r.P;ss(g,d,F[t+e],i),V[X]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(V[X]))<=h&&(F[X]=F[t+e],X++)}const R=(0,r.m)(r.P,3),k=(0,r.m)(r.P,3);if(e.queryControlPoints(k),k[0].subThis(s.getStartXY()),k[1].subThis(s.getStartXY()),k[2].subThis(s.getStartXY()),function(t,e,s,i=!1){const n=(0,r.m)(r.P,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}(k,d,R,!1),Math.abs(p.x)>=Math.abs(p.y)){const t=p.y/p.x;q=R[2].y-R[2].x*t,M=R[1].y-R[1].x*t,G=R[0].y-R[0].x*t}else{const t=p.x/p.y;q=R[2].x-R[2].y*t,M=R[1].x-R[1].y*t,G=R[0].x-R[0].y*t}const L=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),z=[0,0];Y=ft(q,M,G,r.E.unit(),L,z);for(let t=0,e=X;t<Y;++t){F[t+e]=z[t];const i=new r.P;ss(g,d,F[t+e],i),V[X]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(V[X]))<=h&&(F[X]=F[t+e],X++)}(0,i.g)(X<F.length+4);for(let t=0;t<X;t++)F[t]=rs(_,F[t]);Y=e.intersectPoint(s.getStartXY(),z,h);for(let t=0;t<Y;t++)F[X]=z[t],V[X++]=0;Y=e.intersectPoint(s.getEndXY(),z,h);for(let t=0;t<Y;t++)F[X]=z[t],V[X++]=1;Y=s.intersectPoint(e.getStartXY(),z,h);for(let t=0;t<Y;t++)V[X]=z[t],F[X++]=0;Y=s.intersectPoint(e.getEndXY(),z,h);for(let t=0;t<Y;t++)V[X]=z[t],F[X++]=1;return 0===X?0:Dr(t,e,s,F,V,X,n,o,a,h,m,0,u)}function Je(t,e,s,i,n,o,h,m,l,u){if(Tn(s))return je(t,e,new Gr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,u);const c=B(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],_=[],d=(0,r.m)(r.P,4);{e.queryControlPoints(d);const t=(0,r.m)(r.P,4),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(d,4,t);const o=(0,r.m)(r.M,3),m=(0,r.m)(r.M,3),l=(0,r.m)(r.M,3),u=[0,0,0];e.queryWeights(u),Ke(t,u,o,m,l);const 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 p=Bt(o,2,m,2,l,2,c,0,r.E.unit(),r.E.unit(),g);if(p>0){let t=0;for(let i=0;i<p;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],_.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const i=0===t?s.getStartXY():s.getEndXY(),n=Fe(e,i,r.E.unit(),!1,-1),o=new r.P;e.queryCoord2D(n,o),r.P.distance(i,o)<=h&&(g.push(n),_.push(p[t]))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(d[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(d[e[t]],n)<=h&&(g.push(p[t]),_.push(i))}}return Dr(t,e,s,g,_,g.length,i,n,o,h,m,0,u)}function Ze(t,e,s,n,o,a,h,m,l,u){const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);if(s.queryControlPoints(g),z(c,g,3)<0)return Ze(t,s,e,n,a,o,h,m,l,!u);const _=B(e,s);if(e.isDegenerateToLineHelper(_)){const i=new Gr({start:e.getStartXY(),end:e.getEndXY()}),r=je(t,s,i,n,a,o,h,m,0,!u);if(o)for(let t=0;t<r;++t){const s=i.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(s,!1)}return r}if(s.isDegenerateToLineHelper(_)){const i=new Gr({start:s.getStartXY(),end:s.getEndXY()}),r=je(t,e,i,n,o,a,h,m,0,u);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,_)))return 0;const d=new Array(3);e.queryWeights(d);const f=new Array(3);s.queryWeights(f);const x=[1,ns(d),1],P=[1,ns(f),1],y=new r.E(0,1),E=new r.E(0,1);{const t=p.constructEmpty();Xe(c,x,new r.E(0,1),t);const e=p.constructEmpty();Xe(g,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(is(c,x,t,y),is(g,P,t,E),y.isEmpty()||E.isEmpty())return 0;He(c,x,y.vmin,y.vmax,c,x),He(g,P,E.vmin,E.vmax,g,P)}}const C=Nr(c,2,g,2,h);if(0===C)return 0;const S=[],v=[];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);Ke(c,x,t,e,s);const i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);Ke(g,P,i,n,o);const a=[],m=[],l=Lt(t,2,e,2,s,2,i,2,n,2,o,2,0,r.E.unit(),r.E.unit(),a,m);if(l>0)for(let t=0;t<l;t++){const e=new r.P;ss(g,P,m[t],e);const s=new r.P;ss(c,x,a[t],s),r.P.distance(s,e)<=h&&(S.push(a[t]),v.push(m[t]))}}for(let t=0;t<2;t++){let e,s,n;0===t?(e=c,s=g,n=P):(e=g,s=c,n=x);for(let o=0;o<2;o++){const a=0===o?0:e.length-1,m=new r.P,l=[0],u=Ve(s,n,e[a],r.E.unit(),!1,-1,1,l);(0,i.g)(1===u),ss(s,n,l[0],m),r.P.distance(e[a],m)<=h&&(0===t?(S.push(0===a?0:1),v.push(l[0])):(v.push(0===a?0:1),S.push(l[0])))}}if(0===S.length)return 0;if(!y.equalsRange(0,1))for(let t=0;t<S.length;++t)S[t]=Vt.recalculateParentT(y.vmin,y.vmax,S[t]);if(!E.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=Vt.recalculateParentT(E.vmin,E.vmax,v[t]);for(let t=0;t<S.length;++t)S[t]=rs(d,S[t]);for(let t=0;t<v.length;++t)v[t]=rs(f,v[t]);return Dr(t,e,s,S,v,S.length,n,o,a,h,m,0,u)}function Qe(t,e,s,i,n,o,a,h,m,l){if(e.isLine())return Ys(t,s,new Gr({start:e.getStartXY(),end:e.getEndXY()}),i,o,n,a,h,m,!l);if(s.isLine())return je(t,e,new Gr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,a,h,0,l);const u=B(e,s);if(H(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 _=Nr(c,2,g,2,a);if(0===_)return 0;const d=[],p=[];if(-1===_){const t=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=[0,0,0];e.queryWeights(o),Ke(c,o,t,i,n);const h=(0,r.m)(Yt,3);Ls(g,h);const m=Lt(t,2,i,2,n,2,[h[0].x,h[1].x,h[2].x],2,[h[0].y,h[1].y,h[2].y],2,null,0,0,r.E.unit(),r.E.unit(),d,p);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new r.P;s.queryCoord2D(p[i],n);const o=new r.P;e.queryCoord2D(d[i],o),r.P.distance(o,n)<=a&&(d[t]=d[i],p[t]=p[i],t++)}d.length=t,p.length=t}}for(let t=0;t<2;t++){let i;i=0===t?c:g;for(let n=0;n<2;n++){const o=0===n?0:i.length-1;let h;const m=new r.P;0===t?(h=ws(s,i[o],r.E.unit(),!1),s.queryCoord2D(h,m)):(h=Fe(e,i[o],r.E.unit(),!1,-1),e.queryCoord2D(h,m)),r.P.distance(i[o],m)<=a&&(0===t?(d.push(0===o?0:1),p.push(h)):(p.push(0===o?0:1),d.push(h)))}}return Dr(t,e,s,d,p,d.length,i,n,o,a,h,0,l)}function Ke(t,e,s,i,n){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),i[0].setDouble(t[0].y),i[0].mulThis(o),i[1].setDouble(t[1].y),i[1].mulThis(a),i[2].setDouble(t[2].y),i[2].mulThis(h),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function $e(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function ts(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const n=[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.U)(n[0],n[1],h),e=(0,r.U)(n[1],n[2],h);m=(0,r.w)(t,e,h);const s=(0,r.U)(o[0],o[1],h),i=(0,r.U)(o[1],o[2],h);l=(0,r.w)(s,i,h);const c=(0,r.U)(a[0],a[1],h),g=(0,r.U)(a[1],a[2],h);u=(0,r.U)(c,g,h)}else{const t=(0,r.V)(n[0],n[1],h),e=(0,r.V)(n[1],n[2],h);m=(0,r.V)(t,e,h);const s=(0,r.V)(o[0],o[1],h),i=(0,r.V)(o[1],o[2],h);l=(0,r.V)(s,i,h);const c=(0,r.V)(a[0],a[1],h),g=(0,r.V)(a[1],a[2],h);u=(0,r.V)(c,g,h)}return m/=u,l/=u,i.setCoords(m,l),ms(t,i),u}function es(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function ss(t,e,s,i,n){if(n){if(s<0)return void J(new Gr({start:t[0],end:t[0].add(Te(t,e,0).getUnitVector())}),s,i);if(s>1)return void J(new Gr({start:t[2],end:t[2].add(Te(t,e,1).getUnitVector())}),s-1,i)}ts(t,e,s,i)}function is(t,e,s,i){i.setEmpty();const n=[];n.push(new r.E(0,1));const o=.5*Math.max(s.width(),s.height());for(;n.length;){const a=n.at(-1);n.pop();const h=new p;if(Xe(t,e,a,h),h.isIntersectingW(s)){const t=Math.max(h.width(),h.height());if(s.containsW(h)||t<=o||a.width()<1e-12)i.merge(a);else{const t=a.getCenter();n.push(r.E.construct(a.vmin,t)),n.push(r.E.construct(t,a.vmax))}}}}function ns(t){return t[1]/Math.sqrt(t[0]*t[2])}function rs(t,e){const s=Math.sqrt(t[2]/t[0]);return e/(0,r.w)(s,1,e)}function os(t,e){const s=Math.sqrt(t[0]/t[2]);return e/(0,r.w)(s,1,e)}function as(t,e,s,o){(0,i.g)(e>=0&&e<=1),(new n.v).setCoordsPoint3D(t[0]),(new n.v).setCoordsPoint3D(t[1]),(new n.v).setCoordsPoint3D(t[2]);const a=new n.v,h=new n.v,m=new n.v;(0,r.a2)(3,t[0],t[1],e,a),(0,r.a2)(3,t[1],t[2],e,h),(0,r.a2)(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 hs(t,e,s,n){const o=[t[0],t[1],t[2]];(0,i.g)(e>=0&&e<=1&&s!==n);const a=(0,r.w)(o[0],o[1],e),h=(0,r.w)(o[1],o[2],e),m=(0,r.w)(a,h,e);s&&(s[0]=o[0],s[1]=a,s[2]=m),n&&(n[0]=m,n[1]=h,n[2]=o[2])}function ms(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.c)(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.c)(e.y,s.vmin,s.vmax)}function ls(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.c)(e[0].x,s.vmin,s.vmax),e[1].x=(0,r.c)(e[1].x,s.vmin,s.vmax),e[2].x=(0,r.c)(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.c)(e[0].y,s.vmin,s.vmax),e[1].y=(0,r.c)(e[1].y,s.vmin,s.vmax),e[2].y=(0,r.c)(e[2].y,s.vmin,s.vmax)}class us{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}class cs{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-fs(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}}function gs(t,e,s,i,n){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=ue(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=(0,r.U)(0,m,t),i=(0,r.U)(m,l,t);e=(0,r.U)(s,i,t)}else{const s=(0,r.V)(0,m,t),i=(0,r.V)(m,l,t);e=(0,r.V)(s,i,t)}return e*Cs(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=ue(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=(0,r.U)(0,m,t),i=(0,r.U)(m,l,t);e=(0,r.U)(s,i,t)}else{const s=(0,r.V)(0,m,t),i=(0,r.V)(m,l,t);e=(0,r.V)(s,i,t)}return e*Cs(a,1,t).length()}));return new r.P(u,c)}function _s(t){t.m_cachedValues=null}function ds(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new us;return ps(t,e.specialPoints),Is(t,e),e}function ps(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=(0,r.m)(r.I,8);i[0].set(0);let n=1;{const t=(0,r.m)(r.I,3);!function(t,e,s=!1){const i=new r.I(t[1][0]).subE(new r.I(t[0][0]));e[1]=i.mul(2),e[2]=new r.I(t[2][0]).subE(new r.I(t[1][0])).subE(i),s?e[0].set(0):e[0].set(t[0][0])}(s,t,!1);const e=(0,r.m)(r.I,2),o=new r.E(0,1);let a=St(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.Y)(e[t].value(),0,1)||(i[n]=e[t],n++)}{const t=(0,r.m)(r.I,3);!function(t,e,s=!1){const i=new r.I(t[1][1]).subE(new r.I(t[0][1]));e[1]=i.mul(2),e[2]=new r.I(t[2][1]).subE(new r.I(t[1][1])).subE(i),s?e[0].set(0):e[0].set(t[0][1])}(s,t,!1);const e=(0,r.m)(r.I,2),o=new r.E(0,1);let a=St(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.Y)(e[t].value(),0,1)||(i[n]=e[t],n++)}if(i[n].set(1),n++,n>2){(0,r.Q)(i,0,n,((t,e)=>t.value()-e.value()));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),e.length=n;for(let t=0;t<n;t++)e[t]=i[t].value()}function fs(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),xs(i,e,s)}function xs(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+xs(t,1,!1)}if(1===e)return Ps(t);const i=(0,r.m)(r.P,3);return Ms(t,e,i,null),Ps(i)}function Ps(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 i=(0,r.m)(r.P,3);ks(t,i,!0);const n=4*((0,r.s)(i[2].x)+(0,r.s)(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=(0,r.s)(i[1].x)+(0,r.s)(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(n))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/n,m=a/n,l=m-h*h,u=1+h;if(0===l)return h>=0&&u>=0||h<=0&&u<=0?Math.abs(.5*Math.sqrt(n)*(u*u-h*h)):.5*Math.sqrt(n)*(u*u+h*h);const c=Math.sqrt(l+u*u),g=Math.sqrt(m);return.5*Math.sqrt(n)*(u*c-h*g+l*Math.log(Math.abs((u+c)/(h+g))))}function ys(t,e){const s=(0,r.c)(e,0,1);let i=Cs(t,1,s);return i.isZero()&&(i=Cs(t,2,s)),i}function Es(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),Cs(i,e,s)}function Cs(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 Ss(t){const e=(0,r.m)(r.P,3);return t.queryControlPoints(e),vs(e)}function vs(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function bs(t){return t.m_cachedValues}function Is(t,e){t.m_cachedValues=e}function ws(t,e,s,n,o){(0,i.A)(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=Ds(a,e,m);if(s.containsCoordinate(m[0]))h=r.P.distance(e,l);else{m[0]=s.vmin,Bs(a,m[0],l),h=r.P.distance(l,e);const t=new r.P;Bs(a,s.vmax,t);const i=r.P.distance(t,e);h>i&&(l.setCoordsPoint2D(t),m[0]=s.vmax,h=i)}if(!n)return m[0];if(s.vmin<=0){const i=new r.P;t.queryCoord2DExtended(-1,i,!0);const n=new r.P;t.queryCoord2D(s.vmin,n);const o=new Gr({start:i,end:n}),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 i=new r.P;t.queryCoord2DExtended(2,i,!0);const n=new r.P;t.queryCoord2D(s.vmax,n);const o=new Gr({start:n,end:i}),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 Ds(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(n),h=o.dotProduct(i)+2*n.dotProduct(n),m=3*n.dotProduct(i),l=i.dotProduct(i),u=new Array(3),c=xt(l,m,h,a,r.E.unit(),!1,u),g=t[0].clone();let _=0,d=r.P.sqrDistance(t[0],e),p=r.P.sqrDistance(t[2],e);p<d&&(_=1,g.assign(t[2]),d=p);for(let s=0;s<c;s++){const i=new r.P;Bs(t,u[s],i),p=r.P.sqrDistance(i,e),p<d&&(d=p,g.assign(i),_=u[s])}return s&&(s[0]=_),g}function Ts(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=(0,r.m)(r.P,3);qs(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function Ns(t,e,s){s.setEmpty();const i=[];i.push(new r.E(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new p;if(Ts(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=n||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(r.E.construct(o.vmin,t)),i.push(r.E.construct(t,o.vmax))}}}}function As(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Gs(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Gs(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.$)(t[0][s],t[2][s]);i>0?((0,r.$)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.$)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(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 Ms(t,e,s,i){(new r.P).setCoordsPoint2D(t[0]),(new r.P).setCoordsPoint2D(t[1]),(new r.P).setCoordsPoint2D(t[2]);const n=new r.P,o=new r.P,a=new r.P;if((0,r.D)(t[0],t[1],e,n),(0,r.D)(t[1],t[2],e,o),(0,r.D)(n,o,e,a),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(a)),i){const e=t[2];i[0].assign(a),i[1].assign(o),i[2].assign(e)}}function qs(t,e,s,i){if(e===s){const s=new r.P;return Bs(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=(0,r.m)(r.P,3);Ms(t,s,n,null),Ms(n,e/s,null,n),Bs(t,e,n[0]),Bs(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function Fs(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Ys(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Vs(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Xs(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Ys(t,e,s,n,o,a,h,m,l,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!==a)for(let t=0;t<i;t++)a.push(0);if(null!==n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=B(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Gr({start:e.getStartXY(),end:e.getEndXY()}),i=it(t,s,n,o,a,h,m,u);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=Yt.constructPoint2D(s.getStartXY()),_=Yt.constructPoint2D(s.getEndXY()).sub(g),d=_.clone();d.leftPerpendicularThis();const p=Yt.constructPoint2D(e.m_cp).sub(Yt.constructPoint2D(e.getStartXY())),f=Yt.constructPoint2D(e.getEndXY()).sub(Yt.constructPoint2D(e.m_cp));let x=p.dotProduct(d).toDouble(),P=f.sub(p).dotProduct(d).toDouble();const y=(0,r.f)(12,Number.NaN),E=(0,r.f)(12,Number.NaN);let C=function(t,e,s,i){const n=new r.I,o=St(new r.I(t),new r.I(e),s,n);return i[0]=n.value(),o}(P,x,r.E.unit(),y);C<0&&(y[0]=0,y[1]=1,C=2);let S,v=0;for(let t=0,i=v;t<C;++t){const n=e.getCoord2D(y[t+i]);E[v]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(E[v]))<=h&&(y[v]=y[t+i],v++)}const b=(0,r.m)(r.P,3);e.queryControlPoints(b);{const t=(0,r.m)(Yt,3);if(Ls(b,t,!1),t[0]=t[0].sub(g),_.x.abs().gte(_.y.abs())){const e=_.y.div(_.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),x=t[1].y.sub(t[1].x.mul(e)).toDouble(),S=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=_.x.div(_.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),x=t[1].x.sub(t[1].y.mul(e)).toDouble(),S=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const I=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),w=[0,0];C=ft(P,x,S,r.E.unit(),I,w);for(let t=0,i=v;t<C;++t){y[t+i]=w[t];const n=e.getCoord2D(y[t+i]);E[v]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(E[v]))<=h&&(y[v]=y[t+i],v++)}(0,i.g)(v<y.length+4),C=e.intersectPoint(s.getStartXY(),w,h);for(let t=0;t<C;t++)y[v]=w[t],E[v++]=0;C=e.intersectPoint(s.getEndXY(),w,h);for(let t=0;t<C;t++)y[v]=w[t],E[v++]=1;C=s.intersectPoint(e.getStartXY(),w,h);for(let t=0;t<C;t++)E[v]=w[t],y[v++]=0;C=s.intersectPoint(e.getEndXY(),w,h);for(let t=0;t<C;t++)E[v]=w[t],y[v++]=0;return 0===v?0:Dr(t,e,s,y,E,v,n,o,a,h,m,0,u)}function Xs(t,e,s,i,n,o,h,m,l,u){if(Tn(s))return Ys(t,e,new Gr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,u);const c=B(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],_=[],d=(0,r.m)(r.P,3);{e.queryControlPoints(d);const t=(0,r.m)(r.P,3),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(d,3,t);const o=(0,r.m)(Yt,3);Ls(t,o);const m=[o[0].x,o[1].x,o[2].x],l=[o[0].y,o[1].y,o[2].y],u=(0,r.m)(r.M,3);u[0].setDouble(s.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(s.getSemiMajorAxis()),u[1].sqrThis(),u[2]=u[0],u[2].mul(u[1]),u[2].negate();const c=Bt(m,2,l,2,null,0,u,0,r.E.unit(),r.E.unit(),g);if(c>0){let t=0;for(let i=0;i<c;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],_.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(),i=[0];Ds(d,e,i);const n=new r.P;Bs(d,i[0],n),r.P.distance(e,n)<=h&&(g.push(i[0]),_.push(p[t]))}for(let t=0;t<2;t++){const e=[0,2];{const i=s.getClosestCoordinate(d[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(d[e[t]],n)<=h&&(g.push(p[t]),_.push(i))}}return Dr(t,e,s,g,_,g.length,i,n,o,h,m,0,u)}function Rs(t,e,s,i,n,o,a,h,m,l){const u=(0,r.m)(r.P,3);e.queryControlPoints(u);const c=(0,r.m)(r.P,3);if(s.queryControlPoints(c),z(u,c,3)<0)return Rs(t,s,e,i,o,n,a,h,m,!l);const g=B(e,s);if(H(e,s,a=Math.max(a,g)))return 0;if(function(t,e,s,i,n,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])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!l[0].equals(u[2]))return!1}return!!(l[0].equals(u[2])&&l[1].equals(u[1])&&l[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.b)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.b)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[2]),m&&(s[1]=(0,r.b)(s[0],s[0]=s[1]))),!0)}(e,s,i,n,o,0,0,0,l))return 2;const _=new r.E(0,1),d=new r.E(0,1);{const t=new p;Ts(u,r.E.unit(),t);const e=new p;Ts(c,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(Ns(u,t,_),Ns(c,t,d),_.isEmpty()||d.isEmpty())return 0;qs(u,_.vmin,_.vmax,u),qs(c,d.vmin,d.vmax,c)}}const f=Nr(u,2,c,2,a);if(0===f)return 0;const x=[],P=[];if(-1===f){const t=(0,r.m)(Yt,3);Ls(u,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=(0,r.m)(Yt,3);Ls(c,i);const n=Lt(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,0,r.E.unit(),r.E.unit(),x,P,l);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new r.P,i=new r.P;Bs(c,P[e],i),Bs(u,x[e],s),r.P.distance(s,i)<=a&&(x[t]=x[e],P[t]=P[e],t++)}x.length=t,P.length=t}}for(let t=0;t<2;t++){const e=0===t?u:c,s=0===t?c:u;for(let i=0;i<2;i++){const n=0===i?0:2,o=[0];Ds(s,e[n],o);const h=new r.P;Bs(s,o[0],h),r.P.distance(e[n],h)<=a&&(0===t?(x.push(0===n?0:1),P.push(o[0])):(P.push(0===n?0:1),x.push(o[0])))}}if(0===x.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=qt.recalculateParentT(_.vmin,_.vmax,x[t]);if(!d.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=qt.recalculateParentT(d.vmin,d.vmax,P[t]);return Dr(t,e,s,x,P,x.length,i,n,o,a,h,0,l)}function ks(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Ls(t,e,s=!1){const i=Yt.constructPoint2D(t[1]),n=i.sub(Yt.constructPoint2D(t[0]));e[1]=n.mul(r.M.constructInt32(2)),e[2]=Yt.constructPoint2D(t[2]).sub(i).sub(n),e[0]=s?new Yt(r.ah,r.ah):Yt.constructPoint2D(t[0])}function Bs(t,e,s,i){if(i){if(e<0)return void J(new Gr({start:t[0],end:t[0].add(ys(t,0).getUnitVector())}),e,s);if(e>1)return void J(new Gr({start:t[2],end:t[2].add(ys(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=t[1].clone(),n=new r.P;(0,r.Z)(2,t[0],i,e,n);const o=new r.P;(0,r.Z)(2,i,t[2],e,o);const a=new r.P;(0,r.Z)(2,n,o,e,a),s.assign(a)}else{const i=t[1].clone(),n=new r.P;(0,r._)(2,t[0],i,e,n);const o=new r.P;(0,r._)(2,i,t[2],e,o);const a=new r.P;(0,r._)(2,n,o,e,a),s.assign(a)}}var Hs=n.V;class zs extends W{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.T)(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,i.c)("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 Wi(this)}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=(0,r.m)(r.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,r.D)(t[0],t[1],2/3,e[1]),(0,r.D)(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.a2)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,r.a2)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),k(this,t)}getGeometryType(){return i.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,i.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=ei(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const s=(0,r.m)(r.I,8),n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=Ai(n,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 ii(this)}(0,i.g)(0)}createInstance(){return new zs({vd:this.m_description})}calculateLength2D(){return $s(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)}queryCoord2DExtends(t,e,s){const i=(0,r.m)(r.P,4);this.queryControlPoints(i),_i(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=new C;(0,r.a3)(2,C.constructPoint2D(t[0]),C.constructPoint2D(t[1]),e,i);const n=new C;(0,r.a3)(2,C.constructPoint2D(t[1]),C.constructPoint2D(t[2]),e,n);const o=new C;(0,r.a3)(2,C.constructPoint2D(t[2]),C.constructPoint2D(t[3]),e,o);const a=new C;(0,r.a3)(2,i,n,e,a);const h=new C;(0,r.a3)(2,n,o,e,h),(0,r.a3)(2,a,h,e,s)}else{const i=new C;(0,r.a4)(2,C.constructPoint2D(t[0]),C.constructPoint2D(t[1]),e,i);const n=new C;(0,r.a4)(2,C.constructPoint2D(t[1]),C.constructPoint2D(t[2]),e,n);const o=new C;(0,r.a4)(2,C.constructPoint2D(t[2]),C.constructPoint2D(t[3]),e,o);const a=new C;(0,r.a4)(2,i,n,e,a);const h=new C;(0,r.a4)(2,n,o,e,h),(0,r.a4)(2,a,h,e,s)}}(i,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.w)(this.getStartX(),this.m_cp[0].x,t),s=(0,r.w)(this.m_cp[0].x,this.m_cp[1].x,t),i=(0,r.w)(this.m_cp[1].x,this.getEndX(),t),n=(0,r.w)(e,s,t),o=(0,r.w)(s,i,t);return(0,r.w)(n,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.w)(this.getStartY(),this.m_cp[0].y,t),s=(0,r.w)(this.m_cp[0].y,this.m_cp[1].y,t),i=(0,r.w)(this.m_cp[1].y,this.getEndY(),t),n=(0,r.w)(e,s,t),o=(0,r.w)(s,i,t);return(0,r.w)(n,o,t)}cut(t,e,s){const i=new Mr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Hs.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Hs.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){pi(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.t)("Cubic_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4);gi(n,t,e,o),s.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&(0,i.t)("Cubic_bezier.split_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4),a=(0,r.m)(r.P,4);ci(n,t,o,a),e&&e.setControlPoints(o),s&&s.setControlPoints(a)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.getStartAttributeAsDbl(e,s),n=this.getEndAttributeAsDbl(e,s),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,h=Hs.getInterpolation(e);return(0,r.W)(h,i,n,a,Hs.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return Ni(this,t,r.E.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===Ni(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=ti(this);if(2===s.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)mi(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.P,4);return this.queryControlPoints(n),function(t,e,s,i,n){const o=(0,r.m)(r.I,4),a=(0,r.m)(r.I,3),h=new r.E(0,1);let m=0;if(e){if(Qs(t,o,!1),m=bt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;_i(t,a[e].value(),s),i[e]=s.x}}else if(Zs(t,o,!1),m=bt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;_i(t,a[e].value(),s),i[e]=s.y}if(n)for(let t=0;t<m;t++)n[t]=a[t].value();else i&&(0,r.Q)(i,0,m,r.G);return m}(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return I(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.J.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),gi(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return $s(this,t,!0)}lengthToT(t){return function(t,e){const s=$s(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==pt(new Mi(t,e),r.E.unit(),1,n)&&(0,i.c)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,4);Ws(this,e);const s=e[3],i=e[2],n=e[1],o=new r.P;o.x=(5*s.x*s.x*(7*i.y+16*n.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*n.x+140*i.x*n.y+112*n.x*n.y)-2*(s.y*(20*i.x*i.x+70*i.x*n.x+56*n.x*n.x)-7*(4*i.x+5*n.x)*(-i.y*n.x+i.x*n.y)))/840,o.y=(-5*s.y*s.y*(7*i.x+16*n.x)+s.y*(5*s.x*(7*i.y+16*n.y)-4*(10*i.x*i.y+35*i.y*n.x+28*n.x*n.y))+2*(-7*(4*i.y+5*n.y)*(i.y*n.x-i.x*n.y)+s.x*(20*i.y*i.y+70*i.y*n.y+56*n.y*n.y)))/840;const a=hi(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 n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.t)("calculate_sub_weightedCentroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=ti(t),a=Os(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}n.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Vi(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&(0,i.t)("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),di(e,t)}getDerivative(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),oi(e,1,t)}getCurvature(t){const e=ai(this,1,t),s=ai(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new o.J;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,4);return this.queryControlPoints(t),function(t){const e=(0,r.$)(t[0].y,t[1].y),s=(0,r.$)(t[1].y,t[2].y),i=(0,r.$)(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=(0,r.$)(t[0].x,t[1].x),s=(0,r.$)(t[1].x,t[2].x),i=(0,r.$)(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}(t)}getMonotonicPartParams(t,e){const s=ti(this),n=s.specialPointsCount();if((0,i.g)(O.s_maxMonotonicPartParams>=n),!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,r.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new r.I;return ri(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=this.getEndXY().sub(this.getStartXY()),s=e.length(),i=.1*t;let n=this.getControlPoint1();n.subThis(this.getStartXY());let r=Math.abs(n.crossProduct(e))/s;return!(r>i||(n=this.getControlPoint2(),n.subThis(this.getStartXY()),r=Math.abs(n.crossProduct(e))/s,r>i))}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return hi(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){Ii(this,t,e)}setSegmentFromCoords(t,e){!function(t,e,s){if((0,i.g)(s>=2),2===s){const i=new r.P;(0,r.D)(e[0],e[s-1],1/3,i);const n=new r.P;return(0,r.D)(e[0],e[s-1],2/3,n),void t.construct(e[0],i,n,e[s-1])}const n=e[0],o=e[s-1],a=[0,0],h=Ni(t,n,r.E.unit(),!1,Number.NaN,2,a),m=[0,0],l=Ni(t,o,r.E.unit(),!1,Number.NaN,2,m),u=[];for(let i=0;i<h;i++)for(let h=0;h<l;h++){const l=a[i],c=m[h],g=(i,a)=>{const h=[];h.length=s-2;const m=()=>{let t=0;for(let i=1,n=s-1;i<n;i++){t+=r.P.distance(e[i-1],e[i]);const s=t;h[i-1]=s}t+=r.P.distance(e[s-2],e[s-1]);for(let e=1,i=s-1;e<i;e++)h[e-1]/=t};let u=!1,g=!1;{const e=new Mr;l<=c?(t.queryCut(l,c,e,!0),i.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())):(t.queryCut(c,l,e,!0),i.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())),n.equals(i)&&(u=!0),o.equals(a)&&(g=!0)}m();let _=Number.MAX_VALUE;const d=i.clone(),p=a.clone();for(let t=0;t<5;t++)_=Yi(!0,!1,n,d,p,o,u,g,h,0,e,s);for(let t=0;t<30;t++){const t=d.clone();p.clone();const i=Yi(!0,!0,n,d,p,o,u,g,h,0,e,s);if(_<=i&&t.equals(d)&&t.equals(p))break;_=i}m();let f=!1,x=Number.EPSILON;const P=i.clone(),y=a.clone();for(let t=0;t<30;t++){const t=P.clone();y.clone();const i=Yi(f,!0,n,P,y,o,u,g,h,0,e,s);if(x<=i&&t.equals(P)&&t.equals(y))break;f=!0,x=i}return x<_?(i.assign(P),a.assign(y)):(i.assign(d),a.assign(p),x=_),x},_=new r.P,d=new r.P,p=[g(_,d),r.P.distance(n,_)+r.P.distance(_,d)+r.P.distance(d,o),_.x,_.y,d.x,d.y];u.splice(u.length,0,...p)}let c=u[0],g=u[1],_=0;for(let t=6;t<u.length;t+=6)u[t]<c&&(c=u[t],g=u[t+1],_=t);let d=_;for(let t=0;t<u.length;t+=6)t!==_&&u[t+1]<g&&Math.abs(c-u[t])<10*c&&(g=u[t+1],d=t);t.construct(n,new r.P(u[d+2],u[d+3]),new r.P(u[d+4],u[d+5]),o)}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=(0,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,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return function(t,e,s){s.length=0;{const e=new r.I;ri(t,e);const i=new C;if(pi(t,e,i),i.isZero())return e.isZero()||e.eq(new r.I(1))?0:(s.push(e.value()),1)}const i=(0,r.m)(r.I,4);js(t,i,!0);const n=(0,r.m)(r.I,4);Js(t,n,!0);const o=(0,r.m)(r.I,6),a=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),m=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));o[0]=n[1].mulE(n[1]).mulE(a).addE(i[1].mulE(i[1]).mulE(h)).addE(i[1].mulE(n[1]).mulE(m).mul(2)).mul(6),o[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const l=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(l).mul(156),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),g=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),_=i[1].mulE(i[3]).mulE(g).addE(n[1].mulE(n[3]).mulE(c)).mul(72),d=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),p=i[2].mulE(n[2]).mulE(d).mul(120),f=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),x=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(f).mul(36);o[2]=u.addE(_).addE(p).addE(x);const P=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),y=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),E=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),S=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);o[3]=P.addE(y).addE(E).addE(S),o[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),o[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const v=(0,r.m)(r.I,5),b=It(o,5,new r.E(0,1),!1,v,5);if(b>0){let i=Math.abs(t.getCurvature(0)),n=0;const o=Math.abs(t.getCurvature(1));(o>i||!Number.isFinite(o))&&(n=1);for(let e=0;e<b;e++){const s=Math.abs(t.getCurvature(v[e].value()));t.getCoord2D(v[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=v[e].value())}if((!Number.isFinite(i)||1/i<e)&&!(0,r.Y)(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}return 0}(this,t,e)}ensureXYMonotone(){return mi(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&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.D)(e,s,1/3,t.m_cp[0]),(0,r.D)(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&mi(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]),si(e,ei(this))}reverseImpl(){this.m_cp[1]=(0,r.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t;return!!this.m_cp[0].equals(e.m_cp[0])&&!!this.m_cp[1].equals(e.m_cp[1])}equalsImplTol(t,e){const s=t;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[1],e)}swapImpl(t){const e=t;e.m_cp[0]=(0,r.b)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,r.b)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,r.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){ii(this)}isIntersecting(t,e,s){return 0!==Cr(!1,this,t,e,s)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(Ii(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=ti(t);let h=0,m=a.specialPoints[0];const l=[];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=ni(t,e,m,n);if(0===l.length)l.push(r);else if(r.t===r.tmin)(0,i.g)(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){(0,i.g)(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);m=n}for(const t of l)if(t.d<=n){const e=t.t;s?(h>=s.length&&(0,i.s)(""),s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){ii(this)}clearEndPointModified(){}}zs.type=i.G.enumBezier;class Us{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Os(t){return function(t){return 256*(0,r.a5)()*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 js(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),Zs(i,e,s)}function Js(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),Qs(i,e,s)}function Zs(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function Qs(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function Ks(t,e,s=!1){const i=(0,r.m)(Yt,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(r.M.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(r.M.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(r.ah,r.ah):e[0]=i[0].clone()}function $s(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+$s(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=ti(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=Os(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=Fi(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function ti(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Us,s=(0,r.m)(r.I,8),i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=Ai(i,s);e.specialPoints=[];for(let t=0;t<n;t++)e.specialPoints.push(s[t].value());return si(t,e),e}function ei(t){let e=null;return e=t.m_cachedValues,e}function si(t,e){t.m_cachedValues=e}function ii(t){t.m_cachedValues=null}function ni(t,e,s,i){const n=new Array(18),o=(0,r.m)(r.P,4);t.queryControlPoints(o);const a=pt(new Di(o,e),r.E.construct(s,i),18,n),h=new r.P;t.queryCoord2D(s,h);let m=s,l=r.P.distance(h,e);const u=new r.P;t.queryCoord2D(i,u);const c=r.P.distance(u,e);c<l&&(l=c,m=i,h.assign(u));for(let s=0;s<a;s++){t.queryCoord2D(n[s],u);const i=r.P.distance(u,e);i<l&&(l=i,m=n[s],h.assign(u))}return function(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}(s,i,m,l,h)}function ri(t,e){const s=(0,r.m)(r.I,4);js(t,s,!0);const n=(0,r.m)(r.I,4);Js(t,n,!0);const o=s[3].clone(),a=s[2].clone(),h=s[1].clone(),m=n[3].clone(),l=n[2].clone(),u=n[1].clone(),c=a.mulE(h).addE(l.mulE(u)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(h).mul(12)).addE(l.mulE(l).mul(8).addE(m.mulE(u).mul(12))),_=o.mulE(a).addE(m.mulE(l)).mul(36),d=o.mulE(o).addE(m.mulE(m)).mul(36),p=(0,r.m)(r.I,3),f=bt(d,_,g,c,new r.E(0,1),!1,p);if((0,i.g)(f<=3),f>0){const s=ai(t,1,0).sqrLength(),i=ai(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let s=0;s<f;s++){const i=ai(t,1,p[s].value()).sqrLength();i<n&&(n=i,e=p[s])}}}function oi(t,e,s){const i=new r.P;return function(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}(t,e,s,i),i}function ai(t,e,s){const i=(0,r.m)(r.P,4);return t.queryControlPoints(i),oi(i,e,s)}function hi(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e),(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function mi(t){const e=(0,r.m)(r.P,4);t.queryControlPoints(e);const s=li(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function li(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.$)(t[0][s],t[3][s]);i>0?((0,r.$)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),(0,r.$)(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),(0,r.$)(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),(0,r.$)(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?((0,r.$)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.$)(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),(0,r.$)(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),(0,r.$)(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),(0,r.$)(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 ui(t,e,s){const i=new r.P,n=new r.P,o=new r.P,a=new r.P,h=new r.P;e<=.5?((0,r.Z)(2,t[0],t[1],e,i),(0,r.Z)(2,t[1],t[2],e,n),(0,r.Z)(2,t[2],t[3],e,o),(0,r.Z)(2,i,n,e,a),(0,r.Z)(2,n,o,e,h),(0,r.Z)(2,a,h,e,s)):((0,r._)(2,t[0],t[1],e,i),(0,r._)(2,t[1],t[2],e,n),(0,r._)(2,t[2],t[3],e,o),(0,r._)(2,i,n,e,a),(0,r._)(2,n,o,e,h),(0,r._)(2,a,h,e,s))}function ci(t,e,s,n){(0,i.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.Z)(2,t[0],t[1],e,o),(0,r.Z)(2,t[1],t[2],e,a),(0,r.Z)(2,t[2],t[3],e,h),(0,r.Z)(2,o,a,e,m),(0,r.Z)(2,a,h,e,l),(0,r.Z)(2,m,l,e,u)):((0,r._)(2,t[0],t[1],e,o),(0,r._)(2,t[1],t[2],e,a),(0,r._)(2,t[2],t[3],e,h),(0,r._)(2,o,a,e,m),(0,r._)(2,a,h,e,l),(0,r._)(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)),n&&(n[0].assign(u),n[1].assign(l),n[2].assign(h),n[3].assign(c))}function gi(t,e,s,n){if((0,i.g)(e>=0&&s<=1&&e<=s),e===s){const s=new r.P;return _i(t,e,s),n[0].assign(s),n[1].assign(s),n[2].assign(s),void n[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)n[e].assign(t[e]);return}const o=(0,r.m)(r.P,4);ci(t,s,o,null),ci(o,s>0?e/s:0,null,o),_i(t,e,o[0]),_i(t,s,o[3]),n[0].setCoordsPoint2D(o[0]),n[1].setCoordsPoint2D(o[1]),n[2].setCoordsPoint2D(o[2]),n[3].setCoordsPoint2D(o[3])}function _i(t,e,s,i){if(i){if(e<0)return void J(new Gr({start:t[0],end:t[0].add(di(t,0).getUnitVector())}),e,s);if(e>1)return void J(new Gr({start:t[3],end:t[3].add(di(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=new r.P;(0,r.Z)(2,t[0],t[1],e,i);const n=new r.P;(0,r.Z)(2,t[1],t[2],e,n);const o=new r.P;(0,r.Z)(2,t[2],t[3],e,o);const a=new r.P;(0,r.Z)(2,i,n,e,a);const h=new r.P;(0,r.Z)(2,n,o,e,h),(0,r.Z)(2,a,h,e,s)}else{const i=new r.P;(0,r._)(2,t[0],t[1],e,i);const n=new r.P;(0,r._)(2,t[1],t[2],e,n);const o=new r.P;(0,r._)(2,t[2],t[3],e,o);const a=new r.P;(0,r._)(2,i,n,e,a);const h=new r.P;(0,r._)(2,n,o,e,h),(0,r._)(2,a,h,e,s)}}function di(t,e){const s=(0,r.c)(e,0,1);let i=oi(t,1,s);return i.isZero()&&(i=oi(t,2,s),i.isZero()?i=oi(t,3,s):1===s&&i.negateThis()),i}function pi(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){const i=[C.constructPoint2D(t[0]),C.constructPoint2D(t[1]),C.constructPoint2D(t[2]),C.constructPoint2D(t[3])],n=new C;return function(t,e,s,i){{const e=r.ae.subE(s),n=e.sqr(),o=s.sqr(),a=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new r.I(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(o));i.setE(a.mulE(new r.I(3)))}}(i,0,s,n),n}(t,0,e))}(i,e,s)}function fi(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Ei(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function xi(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==Ci(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Pi(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==vi(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function yi(t,e,s,i,n){if(n){if(0!==vr(e,s))return t?4:2}else if(b(e,s))return 1;return 0!==bi(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Ei(t,e,s,i,n,o,a,h,m,l){if(null!==n&&(n.length=0),null!=o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],h=e.intersectPoint(s.getStartXY(),t,a);if(h>0){if(null!==n)for(let e=0;e<h;e++)n.push(t[e]);if(null!==o)for(let t=0;t<h;t++)o.push(0);if(null!=i)for(let s=0;s<h;s++){const n=new r.P;e.queryCoord2D(t[s],n),i.push(n)}}return h}const u=B(e,s);if(H(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 _=g.clone();_.leftPerpendicularThis();let d=3*c[3].dotProduct(_),p=2*c[2].dotProduct(_),f=c[1].dotProduct(_);const x=new Array(15),P=new Array(15);let y=ft(d,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,i=C;t<y;++t){const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}if(c[0].subThis(s.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;d=c[3].y-c[3].x*t,p=c[2].y-c[2].x*t,f=c[1].y-c[1].x*t,E=c[0].y-c[0].x*t}else{const t=g.x/g.y;d=c[3].x-c[3].y*t,p=c[2].x-c[2].y*t,f=c[1].x-c[1].y*t,E=c[0].x-c[0].y*t}const S=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),v=[0,0,0];y=xt(d,p,f,E,r.E.unit(),S,v);for(let t=0,i=C;t<y;++t){x[t+i]=v[t];const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}y=e.intersectPoint(s.getStartXY(),v,a);for(let t=0;t<y;t++)x[C]=v[t],P[C++]=0;y=e.intersectPoint(s.getEndXY(),v,a);for(let t=0;t<y;t++)x[C]=v[t],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),v,a)&&(P[C]=v[0],x[C++]=0),0!==s.intersectPoint(e.getEndXY(),v,a)&&(P[C]=v[0],x[C++]=1),0===C?0:Dr(t,e,s,x,P,C,i,n,o,a,h,0,l)}function Ci(t,e,s,i,n,o,h,m,l,u){if(Tn(s))return Ei(t,e,new Gr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,u);const c=B(e,s);if(H(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),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(p,4,t);const o=(0,r.m)(Yt,4);Ks(t,o);const m=[o[0].x,o[1].x,o[2].x,o[3].x],l=[o[0].y,o[1].y,o[2].y,o[3].y],u=(0,r.m)(r.M,3);u[0].setDouble(s.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(s.getSemiMajorAxis()),u[1].sqrThis(),u[2].setThis(u[0]),u[2].mulThis(u[1]),u[2].negateThis();const c=Bt(m,3,l,3,null,0,u,0,r.E.unit(),r.E.unit(),_);if(c>0){let t=0;for(let i=0;i<c;i++){const n=new r.P;e.queryCoord2D(_[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g.push(n.clone()),_[t]=_[i],d.push(o),t++)}_.length=t,g.length=t}}const f=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];Ti(p,e,r.E.unit(),!1,-1,1,i);const n=new r.P;_i(p,i[0],n),r.P.distance(e,n)<=h&&(_.push(i[0]),d.push(f[t]),g.push(n.clone()))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(p[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(p[e[t]],n)<=h&&(_.push(f[t]),d.push(i),g.push(n.clone()))}}return Dr(t,e,s,_,d,_.length,i,n,o,h,m,0,u)}function Si(t,e,s,n,o,a,h,m,l,u){const c=(0,r.m)(r.P,4);e.queryControlPoints(c);const g=(0,r.m)(r.P,4);if(s.queryControlPoints(g),z(c,g,4)<0)return Si(t,s,e,n,a,o,h,m,l,!u);const _=B(e,s);if(H(e,s,h=Math.max(h,_)))return 0;if(function(t,e,s,i,n,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])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!l[0].equals(u[3]))return!1}return!!(l[0].equals(u[3])&&l[1].equals(u[2])&&l[2].equals(u[1])&&l[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.b)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.b)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[3]),m&&(s[1]=(0,r.b)(s[0],s[0]=s[1]))),!0)}(e,s,n,o,a,0,0,0,u))return 2;const d=new r.E(0,1),f=new r.E(0,1);{const t=new p;wi(c,new r.E(0,1),t);const e=new p;wi(g,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(c,t,d),Gi(g,t,f),d.isEmpty()||f.isEmpty())return 0;gi(c,d.vmin,d.vmax,c),gi(g,f.vmin,f.vmax,g)}}const x=Nr(c,3,g,3,h);if(0===x)return 0;const P=[],y=[],E=[];let C=!1;if(-1===x){const t=(0,r.m)(Yt,4);Ks(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(Yt,4);Ks(g,i);const n=[],o=[],a=Lt(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,0,r.E.unit(),r.E.unit(),n,o);if(a>0)for(let t=0;t<a;t++){const e=new r.P;_i(g,o[t],e);const s=new r.P;_i(c,n[t],s),r.P.distance(s,e)<=h&&(P.push(s.clone()),E.push(o[t]),y.push(n[t]))}else-1===a&&(C=!0)}for(let t=0;t<2;t++){const e=0===t?c:g,s=0===t?g:c;for(let i=0;i<2;i++){const n=0===i?0:3,o=[0];Ti(s,e[n],r.E.unit(),!1,-1,1,o);const a=new r.P;_i(s,o[0],a),r.P.distance(e[n],a)<=h&&(0===t?(y.push(0===n?0:1),E.push(o[0])):(E.push(0===n?0:1),y.push(o[0])),P.push(a.clone()))}}if(0===y.length&&C){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const n=[0,0];if(2===function(t,e,s=!1){const i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=(0,r.m)(Yt,4);let o,a,h;Ks(i,n,!0);const m=n[3].x.isZero(),l=n[3].y.isZero();if(m||l)if(m&&!l){if(n[2].x.isZero())return 0;o=n[1].x.div(n[2].x).negate(),a=n[2].y.div(n[3].y),h=n[1].y.div(n[3].y)}else{if(m||!l)return 0;if(n[2].y.isZero())return 0;o=n[1].y.div(n[2].y).negate(),a=n[2].x.div(n[3].x),h=n[1].x.div(n[3].x)}else{n[2].x.divThis(n[3].x),n[1].x.divThis(n[3].x),n[2].y.divThis(n[3].y),n[1].y.divThis(n[3].y);const t=n[2].x.sub(n[2].y);if(t.isZero())return 0;o=n[1].x.sub(n[1].y).div(t).negate(),a=n[2].x.clone(),h=n[1].x.clone()}if(!s&&o.abs().value()>2)return 0;const u=[0,0],c=t.getStartXY().equals(t.getEndXY()),g=ft(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.b)(e[0],e[0]=e[1])),2}if(2===g&&u[1]>=0&&u[1]<=1){const t=o.toDouble()-u[1];if(s||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.b)(e[0],e[0]=e[1])),2}return 0}(t?e:s,n,!0)&&((0,i.g)(r.E.unit().containsCoordinate(n[0])),!r.E.unit().containsCoordinate(n[1]))){const e=new r.P;_i(t?c:g,n[0],e);const s=[0,0];1===Ti(t?g:c,e,r.E.unit(),!1,-1,2,s)&&(P.push(e.clone()),y.push(t?n[0]:s[0]),E.push(t?s[0]:n[0]))}}}if(0===y.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=zs.recalculateParentT(d.vmin,d.vmax,y[t]);if(!f.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=zs.recalculateParentT(f.vmin,f.vmax,E[t]);return Dr(t,e,s,y,E,y.length,n,o,a,h,m,0,u)}function vi(t,e,s,n,o,a,h,m,l,u){const c=B(e,s);if(s.isDegenerateToLineHelper(c)){const i=new Gr({start:s.getStartXY(),end:s.getEndXY()}),r=Ei(t,e,i,n,o,a,h,m,0,u);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const _=(0,r.m)(r.P,3);s.queryControlPoints(_);const d=new r.E(0,1),f=new r.E(0,1),x=[0,0,0];s.queryWeights(x);const P=[1,ns(x),1];{const t=new p;wi(g,new r.E(0,1),t);const e=new p;Xe(_,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,t,d),is(_,P,t,f),d.isEmpty()||f.isEmpty())return 0;gi(g,d.vmin,d.vmax,g),He(_,P,f.vmin,f.vmax,_,P)}}const y=Nr(g,3,_,2,h);if(0===y)return 0;const E=[],C=[],S=[];if(-1===y){const t=(0,r.m)(Yt,4);Ks(g,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);Ke(_,P,i,n,o);const a=[],m=[],l=Lt(i,2,n,2,o,2,e,3,s,3,null,0,0,r.E.unit(),r.E.unit(),m,a);if(l>0)for(let t=0;t<l;t++){const e=new r.P;_i(g,a[t],e);const s=new r.P;ss(_,P,m[t],s),r.P.distance(e,s)<=h&&(E.push(e.clone()),C.push(a[t]),S.push(m[t]))}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=_):(s=g,e=_);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t){const t=Ve(s,P,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),ss(s,P,a[0],m)}else{const t=Ti(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),_i(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(C.push(0===o?0:1),S.push(a[0])):(S.push(0===o?0:1),C.push(a[0])),E.push(m.clone()))}}if(0===C.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=zs.recalculateParentT(d.vmin,d.vmax,C[t]);if(!f.equalsRange(0,1))for(let t=0;t<S.length;++t)S[t]=Vt.recalculateParentT(f.vmin,f.vmax,S[t]);for(let t=0;t<S.length;++t)S[t]=rs(x,S[t]);return Dr(t,e,s,C,S,C.length,n,o,a,h,m,0,u)}function bi(t,e,s,n,o,a,h,m,l,u){const c=B(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const _=(0,r.m)(r.P,3);s.queryControlPoints(_);const d=Nr(g,3,_,2,h);if(0===d)return 0;const p=[],f=[],x=[];if(-1===d){const t=(0,r.m)(Yt,4);Ks(g,t);const i=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,r.m)(Yt,3);Ls(_,o);const a=Lt([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,i,3,n,3,null,0,0,r.E.unit(),r.E.unit(),x,f);if(a>0){let t=0;for(let i=0;i<a;i++){const n=new r.P;e.queryCoord2D(f[i],n);const o=new r.P;s.queryCoord2D(x[i],o),r.P.distance(n,o)<=h&&(p.push(n.clone()),f[t]=f[i],x[t]=x[i],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=_):(s=g,e=_);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t)Ds(s,e[o],a),Bs(s,a[0],m);else{const t=Ti(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),_i(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(f.push(0===o?0:1),x.push(a[0])):(x.push(0===o?0:1),f.push(a[0])),p.push(m.clone()))}}return Dr(t,e,s,f,x,f.length,n,o,a,h,m,0,u)}function Ii(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),wi(i,e,s)}function wi(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=(0,r.m)(r.P,4);gi(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class Di{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new r.P;_i(this.controlPoints,e,t);const s=oi(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new r.P;_i(this.controlPoints,e,t);const s=oi(this.controlPoints,1,e),i=oi(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new r.P;_i(this.controlPoints,e,t);const s=oi(this.controlPoints,1,e),i=oi(this.controlPoints,2,e),n=oi(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=oi(this.controlPoints,1,e),s=oi(this.controlPoints,2,e),i=oi(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=oi(this.controlPoints,2,e),s=oi(this.controlPoints,3,e);return 10*t.dotProduct(s)*2}case 5:{const t=oi(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}}function Ti(t,e,s,o,a,h,m){(0,i.A)(r.E.unit().contains(s)&&h>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);const l=[],u=new r.P;_i(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&&(_i(t,s.vmax,u),c=r.P.distance(u,e),c<=a&&l.push(new r.P(s.vmax,c))),s.width()>0){const i=new Array(18),n=pt(new Di(t,e),s,18,i);for(let s=0;s<n;s++)_i(t,i[s],u),c=r.P.distance(u,e),c>a||l.push(new r.P(i[s],c))}if(o){(0,i.g)(s.equals(r.E.unit()));{_i(t,-1,u,!0);const s=new r.P;_i(t,0,s);const i=new Gr({start:u,end:s}),n=i.getClosestCoordinate(e,!0);n<1&&(u.assign(i.getCoord2D(n)),c=r.P.distance(u,e),c<=a&&l.push(new r.P(n-1,c)))}{_i(t,2,u,!0);const i=new r.P;_i(t,s.vmax,i);const n=new Gr({start:i,end:u}),o=n.getClosestCoordinate(e,!0);o>0&&(u.assign(n.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 _=l[0].x;if(m[g++]=_,g<h){const e=(0,n.N)(t,4,!1).total(),s=l[0].y;for(let t=1,i=l.length;t<i;t++)if(l[t].y>s+e){l.length=t;break}l.sort(((t,e)=>(0,r.G)(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 Ni(t,e,s,i,n,o,a){const h=(0,r.m)(r.P,4);return t.queryControlPoints(h),Ti(h,e,s,i,n,o,a)}function Ai(t,e){e[0].set(0);let s=1;const n=(0,r.m)(r.I,4);Zs(t,n,!0);const o=(0,r.m)(r.I,4);Qs(t,o,!0);{const t=n[3].mul(3),i=n[2].mul(2),o=n[1].clone(),a=(0,r.m)(r.I,2);let h=vt(t,i,o,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.Y)(a[t].value(),0,1)||(e[s]=a[t],s++)}{const t=o[3].mul(3),i=o[2].mul(2),n=o[1].clone(),a=(0,r.m)(r.I,2);let h=vt(t,i,n,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.Y)(a[t].value(),0,1)||(e[s]=a[t],s++)}if(s+=function(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=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.I,2);let h=vt(o,n,i,new r.E(0,1),!1,a);h<0&&(h=0);let m=0;for(let t=0;t<h;t++)(0,r.Y)(a[t].value(),0,1)||(s[m].setE(a[t]),m++);return m}(n,o,e.slice(s)),e[s].set(1),s++,s>2){(0,r.Q)(e,0,s,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let i=0;const n=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.a5)(),h=new r.P;ui(t,e[0].value(),h);for(let m=1;m<s;m++){const s=new r.P;if(ui(t,e[m].value(),s),e[m].eq(n)||s.isEqualPoint2D(h,a)){if(0!==i){if(0===e[m].eps())n.setE(e[m]),o=0;else if(0!==o){const t=(0,r.s)(1/e[m].eps()),s=1/o,i=t+s;n.set((e[m].value()*t+n.value()*s)/i),o=1/i,n.setError(Math.sqrt(o))}e[i].setE(n),ui(t,n.value(),h)}}else i++,e[i].setE(e[m]),n.setE(e[m]),ui(t,n.value(),h),o=(0,r.s)(e[m].eps())}i++,s=i}return 1===s&&(s=2,e[1].set(1)),(0,i.g)(0===e[0].value()),(0,i.g)(1===e[s-1].value()),s}function Gi(t,e,s){s.setEmpty();const i=[];i.push(new r.E(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new p;if(wi(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=n||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(r.E.construct(o.vmin,t)),i.push(r.E.construct(t,o.vmax))}}}}class Mi{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-$s(this.b,e,!1):0}getError(t){return 0}}function qi(t,e,s,n,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<=n+s*l)return t+(0,r.w)(m,l,.5);const u=t=>oi(e,1,t).length();if(0===a){(0,i.g)(h<8);let m=u(0),c=u(1);o[0]+=2,m>c&&(c=(0,r.b)(m,m=c),e[3]=(0,r.b)(e[0],e[0]=e[3]),e[2]=(0,r.b)(e[1],e[1]=e[2]));let g=m/(m+c),_=1,d=l;for(;g<1/32&&d>=32*(n+s*d);){_/=4;const t=u(_);o[0]++,g=m/(t+m);const s=new r.P;if(_i(e,.5*_,s),d=r.P.distance(s,e[0]),d<=n){const t=new r.P;_i(e,_,t),d+=r.P.distance(t,s)}}if(1!==_){const i=(0,r.m)(r.P,4);ci(e,_,e,i),t=qi(t,i,s,n,o,0,h+1),a++,h++;continue}}const c=8;o[0]+=c;const g=le(c,u,0,1),_=16;o[0]+=_;const d=le(_,u,0,1);let p=Math.abs(g-d)>n+s*l;if(!p)return t+d;if(a<3){const i=(0,r.m)(r.P,4);ci(e,.5,e,i),t=qi(t,i,s,n,o,a+1,h+1),a++,h++;continue}const f=32;o[0]+=f;const x=le(f,u,0,1);if(p=Math.abs(d-x)>n+s*l,!p)return t+x;const P=64;o[0]+=P;const y=le(P,u,0,1);if(p=Math.abs(x-y)>n+s*l,!p)return t+y;const E=128;o[0]+=E;const C=le(E,u,0,1);return p=Math.abs(y-C)>n+s*l,t+C}}function Fi(t,e,s,i,n){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 gi(o,e,s,a),qi(0,a,i,n,[0],0,0)}function Vi(t,e,s,i,n){let o=!0;const a=ue(5,e,s,i,n,(e=>{const s=ai(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));o=!1;const h=ue(5,e,s,i,n,(e=>{const s=ai(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));return new r.P(a,h)}function Yi(t,e,s,i,n,o,a,h,m,l,u,c){let g=0,_=0,d=0,p=0,f=0,x=0,P=0;for(let e=1,a=c-1;e<a;e++){let a,h,l,c,y,E,C=-1,S=m[e-1];t&&(e>2?(S=(0,r.c)(2*m[e-2]-m[e-3],0,1),m[e-1]=S):2===e&&S<=m[0]&&(S=m[0]));for(let g=0;g<11&&(a=m[e-1],h=a*a,l=h*a,c=1-a,y=c*c,E=y*c,t)&&!(Math.abs(a-C)<1e-12)&&10!==g;g++){const t=s.x-2*i.x+n.x,l=s.x-3*i.x+3*n.x-o.x,c=s.y-2*i.y+n.y,g=s.y-3*i.y+3*n.y-o.y,_=s.x-i.x-2*t*a+l*h,d=-u[e].x+s.x*E+a*(3*i.x*y+a*(3*n.x-3*n.x*a+o.x*a)),p=s.y-i.y-2*c*a+g*h,f=-u[e].y+s.y*E+a*(3*i.y*y+a*(3*n.y-3*n.y*a+o.y*a));C=a;const x=a- -6*(_*d+p*f)/(6*(3*(0,r.s)(_)-(-2*t+2*l*a)*d)+6*(3*(0,r.s)(p)-(-2*c+2*g*a)*f));m[e-1]=(0,r.c)(x,e>1?m[e-2]:0,1)}g+=3*h*y*y,_+=3*l*E,d+=3*h*h*y;const v=-(E*s.x+l*o.x-u[e].x);p+=v*a*y,f+=v*h*c;const b=-(E*s.y+l*o.y-u[e].y);x+=b*a*y,P+=b*h*c}if(e){const t=g*d-_*_;Math.abs(t)>=1e-12*(Math.abs(g*d)+Math.abs(_*_))+1e-10?(a||(i.x=(p*d-f*_)/t,i.y=(x*d-P*_)/t),h||(n.x=(g*f-_*p)/t,n.y=(g*P-_*x)/t)):((0,r.D)(s,o,.3,i),(0,r.D)(s,o,.6,n))}let y=0;for(let t=1,e=c-1;t<e;t++){const e=m[t-1],a=1-e,h=s.mul((0,r.aj)(a)),l=i.mul(3*e*a*a),c=n.mul(3*e*e*a),g=o.mul((0,r.aj)(e));y+=h.add(l).add(c).add(g).sub(u[t]).sqrLength()}return y}function Xi(t,e,s,i){const n=t.getPathStart(e),o=t.getPathEnd(e);if(o-n<3)return;const a=2*n,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),i.pe((c.x-h.x)*(u.y-l)),h.setCoordsPoint2D(u),u.setCoordsPoint2D(c);i.pe((m-h.x)*(u.y-l))}function Ri(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var ki=n.V;class Li{static toSegType(t){let e=0;switch(t){case i.G.enumLine:e=1;break;case i.G.enumBezier:e=2;break;case i.G.enumEllipticArc:e=4;break;case i.G.enumRationalBezier2:e=8;break;case i.G.enumBezier2:e=16;break;default:(0,i.c)("")}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 Bi extends _{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?i.G.enumPolygon:i.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,i.g)(this.m_bPolygon);const e=this.getPathIndexFromPointIndex(t),s=this.getPathStart(e);if(s===t)return;const n=this.getPathEnd(e);(t>=n||t<s)&&(0,i.t)("change_ring_start_point");for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=ki.getComponentCount(i);this.m_vertexAttributes.get(e).rotate(s*r,t*r,n*r)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(s,t,n),this.m_curveData.m_segmentParamIndex.rotate(s,t,n))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new n.k(t),s=new r.K(0),i=new r.K(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new mt({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();Xi(this,r,n,i),Ri(0,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),Xi(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Bi.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),o=dt(s);for(let t=0;t<o;t++){const s=this.m_curveData.m_segmentParams.read(i+t),o=e.m_curveData.m_segmentParams.read(n+t);if(!(0,r.a6)(s,o))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=(0,n.Q)(1,0),this.m_pathFlags=(0,n.R)(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 Li),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,i.g)(0),0}calculatePathLength3D(t,e){return(0,i.g)(0),0}copyTo(t){(0,i.h)(t.getGeometryType())||(0,i.t)(""),this!==t&&super.copyTo(t)}swap(t){(0,i.g)(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,i.t)("Multi_path_impl::add");for(let s=0,i=t.getPathCount();s<i;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addSegmentsFromPath(t,e,s,n,r){if(this===t&&(0,i.t)("Multi_path_impl.add_segments_from_path"),r||0!==this.getPathCount()||(r=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||n<0||s+n>t.getSegmentCountPath(e))&&(0,i.s)("add_segments_from_path"),0===n)return;const o=t.getPathStart(e),a=t.isClosedPath(e)&&s+n===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let h=n;const m=o+s;let l=m+1;r&&(h++,l--),!r&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||(0,i.t)("add_segments_from_path: start point mismatch"));const u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange(),r){if(0===h)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const c=a?h-1:h;for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=ki.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(c>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=ki.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*u,t,c*i,i*u),a&&this.m_vertexAttributes.get(e).insertRange(i*u+c*i,t,i,i*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*u,t.m_vertexAttributes.get(n),i*l,c*i,!0,i,i*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(u+c),t.m_vertexAttributes.get(n),i*o,i,!0,i,i*(u+c))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=m;s<n;s++)e+=dt(t.m_curveData.m_segmentFlags.read(i)),i++;if(e>0){this.initSegmentData(e);let s=m,i=u-(r?0:1),o=0;for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),Bi.isNonLinearSegmentFlag(e)){o++;let n=t.m_curveData.m_segmentParamIndex.read(s);const r=dt(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentParams.read(n);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,n++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(o)}}if(a){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&(0,i.t)("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const i=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!Bi.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,i,!0),i.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,s)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const r=n?1:0;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++)if(this.m_vertexAttributes.get(t)){const i=this.m_description.getSemantics(t),n=ki.getComponentCount(i);this.m_vertexAttributes.get(t).reverseRange(n*(s+r),n*(e-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,i.t)("");const s=this.getPathStart(t),n=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=ki.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*s,i*n,i*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=s,i=s+n;e<i;e++){const s=this.m_curveData.m_segmentFlags.read(e);Bi.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(s,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(s,n,this.m_pointCount)}for(let s=t+1;s<=e;s++){const t=this.m_paths.read(s);this.m_paths.write(s-1,t-n)}if(this.m_pathFlags)for(let s=t+1;s<=e;s++){const t=this.m_pathFlags.read(s);this.m_pathFlags.write(s-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,s,r){this===e&&(0,i.t)("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,i.t)(""),t>o&&(0,i.t)(""),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),i=e.getDescription().getAttributeIndex(s),n=ki.getComponentCount(s);if(i>=0&&e.m_vertexAttributes.get(i))0!==l&&this.m_vertexAttributes.get(t).insertRangeFromStream(u*n,e.m_vertexAttributes.get(i),n*a,n,!0,n,n*m),this.m_vertexAttributes.get(t).insertRangeFromStream((u+l)*n,e.m_vertexAttributes.get(i),n*(a+l),n*(h-l),r,n,n*(m+l));else{const e=ki.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(u*n,e,n*h,n*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 i=0;i<h;i++)s+=dt(e.m_curveData.m_segmentFlags.read(t)),t++;if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,n.R)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,n.Q)(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,n.U)(s),t=a;let i=u,r=0;for(let s=0;s<h;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(Bi.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const n=dt(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<n;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++,i++}this.modifyCurveCounter(r)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,n,r){const o=this.getPathCount();(t>o||s<0)&&(0,i.t)(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,e,s,n,r,2*a);else{const t=ki.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=ki.getComponentCount(e),i=ki.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,s,n,r){const o=e.getImpl(),a=this.getPathCount();(t>a||s<0)&&(0,i.t)("");const h=n<0?o.getPointCount()-s:n;if(h>o.getPointCount()&&(0,i.t)(""),s>=o.getPointCount()&&(0,i.t)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,l=s;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const u=t<a?this.getPathStart(t):m;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),i=ki.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(u*i,s,i*l,i*h,r,i,i*m)}else{const s=ki.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(u*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,e,s,n,r,o,a){if(this===s&&(0,i.t)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),n<0&&(n=s.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||n>=s.getPathCount()||o>s.getPathSize(n))&&(0,i.s)(""),!o)return;if(this.mergeVertexDescription(s.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=s.m_pathFlags.read(n);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+e;o<0&&(o=s.getPathSize(n));const u=s.getPathStart(n),c=u+o;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=ki.getComponentCount(i),g=s.m_description.getAttributeIndex(i);if(g<0||!s.m_vertexAttributes.get(g)){const e=ki.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*l,e,c*n,n*h)}else this.m_vertexAttributes.get(t)?.insertRangeFromStream(n*(m+e),s.m_vertexAttributes.get(g),n*(u+r),o*n,a,n,n*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,o,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,o,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&(0,i.s)(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=ki.getComponentCount(s),n=ki.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange((h+e)*i,n,i*r,i*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl();if(t<0&&(t=this.getPathCount()),r<0&&(r=s.getPointCount()),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>s.getPointCount())&&(0,i.s)(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+e,u=0+r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=ki.getComponentCount(s);if(a.getDescription().getAttributeIndex(s)<0){const e=ki.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(i*l,e,u*i,i*h);continue}const c=a.getAttributeStreamRef(s);this.m_vertexAttributes.get(t).insertRangeFromStream(i*(m+e),c,i*(0+n),r*i,o,i,i*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,r,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,r,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.s)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=ki.getComponentCount(e),i=ki.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.s)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByVal(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=ki.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=ki.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&(0,i.s)("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,i.s)("Multi_path.remove_point");const o=n+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=ki.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*o,s,s*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=s;e>=t+1;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)Bi.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=Bi.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new n.P({x:t,y:e}))}startPath(t){this.startPathPoint(new n.P({pt:t}))}startPath3D(t){this.startPathPoint(new n.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new n.P({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&(0,i.t)("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new n.P({vd:this.m_description});t.copyCommonAttributesTo(i),s=i}else s=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,n.Q)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,n.R)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{const s=(0,n.G)(),i=new n.P({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=(0,n.z)(this.m_description,(0,n.W)()),s=(0,n.G)(),i=new n.P({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByVal(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new n.v(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=(0,n.G)(),s=new n.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,i.c)("");const e=this.getPathCount();if(t>e&&(0,i.t)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,i.c)("");const s=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=ki.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(i*r,this.m_vertexAttributes.get(t),i*n,i,!0,1,i*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,i.c)(""),t>this.getPathCount()&&(0,i.t)(""),this.m_pathFlags||(0,i.c)(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&(0,i.c)(""),this.isEmpty())return;this.m_pathFlags||(0,i.c)("");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 i=this.getPathStart(e),o=this.getPathSize(e),u=this.isClosedPath(e);if(o>0){const e=i+r;for(let s=0;s<a;s++)if(this.m_vertexAttributes.get(s)){const r=this.m_description.getSemantics(s),a=ki.getComponentCount(r);if(!h[s]){const e=a*(this.m_pointCount+t),i=(0,n.L)(r,e);h[s]=i}h[s].writeRange(e*a,o*a,this.m_vertexAttributes.get(s),i*a,!0,1),u&&h[s].writeRange((e+o)*a,a,this.m_vertexAttributes.get(s),i*a,!0,1)}if(s){if(null===m){const e=this.m_pointCount+t;m=(0,n.R)(e),l=(0,n.Q)(e)}m.writeRange(e,o,this.m_curveData.m_segmentFlags,i,!0,1),l.writeRange(e,o,this.m_curveData.m_segmentParamIndex,i,!0,1),u&&(m.write(e+o,1),l.write(e+o,-1))}}this.m_paths.write(e,i+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,i.t)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==s&&(this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,i.t)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,i.t)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),n=this.getPathEnd(t)-1;s.equals(this.getXY(n))||(0,i.t)("close_path_with_segment: start point mismatch");const r=e.getGeometryType();if(r===i.G.enumLine)return void this.closePathWithLine(t);{const t=_t(e);this.initSegmentData(t);const s=Li.toSegType(r),i=this.m_curveData.m_segmentFlags.read(n);if(i!==s)this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(n);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(n,s)}}const s=this.m_pathFlags.read(t);this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(t){return(0,i.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Bi.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.J)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=(0,n.G)(),r=new n.P({vd:s,attribBuffer:i,initDefaultValues:!1});for(let s=0,i=4;s<i;s++){const n=e?i-s-1:s;t.queryCornerByVal(n,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,i.t)("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new n.P;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new n.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const r=(0,n.G)(),o=new n.P({vd:s,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===i.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,i.t)("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,n.G)(),e=new n.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const r=_t(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=Li.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,n){for(let e=t;e<s-1;e++)this.isClosedPath(e)&&(0,i.t)("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,e,s,n);if(0!==o)for(let i=1;i<r;i++){const r=this.m_description.getSemantics(i);this.interpolateAttributesSemanticsImpl(r,t,e,s,n,o)}}interpolateAttributesSemantics(t,e,s,n,r){if(0===t)return;this.hasAttribute(t)||(0,i.t)("does not have the given attribute"),2===ki.getInterpolation(t)&&(0,i.t)("angular interpolation");for(let t=e;t<n-1;t++)this.isClosedPath(t)&&(0,i.t)("cannot interpolate across closed paths");const o=this.calculateSubLength2D(e,s,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,s,n,r,o)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(t,e,s,n){if(0===t)return;this.hasAttribute(t)||(0,i.t)("does not have the given attribute"),2===ki.getInterpolation(t)&&(0,i.t)("angular interpolation");const r=this.calculatePathSubLength2D(e,s,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,e,s,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,n,o){const a=this.querySegmentIterator(),h=this.getPathStart(e)+s,m=this.getPathStart(i)+n,l=ki.getComponentCount(t),u=new Array(ki.maxComponentCount());this.queryAttributeAsDbl(t,h,u,l);const c=new Array(ki.maxComponentCount());this.queryAttributeAsDbl(t,m,c,l);const g=new Array(ki.maxComponentCount());(0,r.a)(g,u,0,0,l);let _=0;const d=ki.getDefaultValue(t),p=ki.getInterpolation(t);a.resetToVertex(h,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===m)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,l),a.previousSegment();do{const e=a.nextSegment();if(a.getEndPointIndex()===m)return;_+=e.calculateLength2D(),(0,r.O)(p,u,c,g,0,l,_/o,d),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,l)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,n){const o=this.querySegmentIterator(),a=ki.getInterpolation(t),h=this.getPathStart(e)+s,m=this.getPathStart(e)+i;if(m===h)return;const l=ki.getComponentCount(t),u=new Array(ki.maxComponentCount());this.queryAttributeAsDbl(t,h,u,l);const c=new Array(ki.maxComponentCount());this.queryAttributeAsDbl(t,m,c,l);const g=new r.K(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const _=ki.getDefaultValue(t),d=new Array(ki.maxComponentCount());(0,r.a)(d,u,0,0,l);const p=0===n;let f=.5;do{const e=o.nextSegment();if(this.setAttributeFromArray(t,o.getStartPointIndex(),d,l),!p){const t=e.calculateLength2D();g.pe(t),f=g.getResult()/n}(0,r.O)(a,u,c,d,0,l,f,_)}while(o.getEndPointIndex()!==m)}querySegment(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.t)("get_segment"),this.getSegmentFromPath(n,r,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const e=this.getPathIndexFromPointIndex(t),s=t-this.getPathStart(e);return s>=this.getSegmentCountPath(e)&&(0,i.t)("get_segment"),this.getSegmentTypeFromPath(e,s)}getSegmentFromPath(t,e,s,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,i.c)("")}const m=s.get();let l,u=null;if(r?(u=(0,n.x)(),m.assignVertexDescription(u)):m.assignVertexDescription(this.m_description),l=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,N(m,this.getXY(o)),G(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=ki.getComponentCount(e);for(let t=0;t<s;t++){const s=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,s);const i=this.getAttributeAsDbl(e,l,t);m.setEndAttribute(e,t,i)}}if(Bi.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);gt(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,n=!1){const o={iSegment:-1},a=n?o:{iSegment:-1,tSegment:0};if(s.setEmpty(),this.isEmpty())return o;if((t<0||t>=this.getPathCount())&&(0,i.t)("query_point_along_path"),e<0)return o;const h=this.getPathSize(t);if(0===h)return o;if(1===h)return this.getPointByVal(this.getPathStart(t),s),a.tSegment=0,o.iSegment=this.getPathStart(t),o;const m=this.querySegmentIteratorAtVertex(this.getPathStart(t)),l=new r.K(0);for(;m.hasNextSegment();){const t=m.nextSegment(),i=t.calculateLength2D(),n=l.getResult();if(l.add(i),l.getResult()>=e){let r=e-n;r>i&&(r=i);const h=t.lengthToT(r);return t.queryCoord(h,s),a.tSegment=h,o.iSegment=m.getStartPointIndex(),o}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,s,n,o,a){{let t=0;for(let r=0;r<e;++r)n&&n[r].setEmpty(),o&&(o[r]=-1),a&&(a[r]=0),t>s[r]&&(0,i.t)("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 n&&this.getPointByVal(e,n[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,_=s[c];for(;u.hasNextSegment();){const t=u.nextSegment(),i=t.calculateLength2D(),r=l.getResult();for(l.add(i);l.getResult()>=_;){let h=_-r;h>i&&(h=i);const m=t.lengthToT(h);if(n&&t.queryCoord(m,n[g]),a&&(a[g]=m),o&&(o[g]=u.getStartPointIndex()),g++,c++,_=s[c],c===e)return g}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;n&&this.getPointByVal(e,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;n&&this.getPointByVal(e+1,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,s,n,o){{let r=0;for(let a=0;a<t;++a)s&&s[a].setEmpty(),n&&(n[a]=-1),o&&(o[a]=0),r>e[a]&&(0,i.t)("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 i=h.nextSegment(),r=i.calculateLength2D(),g=a.getResult();for(a.add(r);a.getResult()>=c;){let a=c-g;a>r&&(a=r);const m=i.lengthToT(a);if(s&&i.queryCoord(m,s[u]),o&&(o[u]=m),n&&(n[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),n&&(n[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),n&&(n[u]=t),u++}return u}querySegmentIterator(){return new mt({parent:this})}querySegmentIteratorAtVertex(t){return new mt({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 n.E&&(0,i.g)(0,"not implemented for Envelope"),e instanceof n.b&&(0,i.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,i.t)(""),this.isEmpty())return void e.setEmpty();const r=this.getAttributeStreamRef(0),a=o.J.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),s=2*this.getPathEnd(t);e<s;){const t=s-e;(0,i.g)(!(1&t)),a.mergePointsInterleaved(r,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){const n=this.querySegmentIterator();if(n.resetToPath(t),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const i=o.J.constructEmpty();s?t.queryEnvelope(i):t.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}else(0,i.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=dt(4)*this.m_curveData.m_arcCount+dt(2)*this.m_curveData.m_bezierCount+dt(8)*this.m_curveData.m_rbezier2Count+dt(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);Bi.isNonLinearSegmentFlag(s)&&(t+=dt(s))}const e=(0,n.U)(t);let s=0;for(let t=0,i=this.getPointCount();t<i;t++){const i=this.m_curveData.m_segmentFlags.read(t);if(Bi.isNonLinearSegmentFlag(i)){let n=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,s);const r=dt(i);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,i.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,n.Q)(0),this.m_pathFlags=(0,n.R)(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=(0,n.Q)(0),this.m_pathFlags=(0,n.R)(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Hi(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new Li),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;(0,i.p)("")}let r=0,o=e-1;for(;o>r;){const e=r+(o-r>>1);if(s<t.read(e))o=e-1;else{if(!(s>=t.read(e+1)))return e;r=e+1}}return r}getHighestPointIndex(t){(0,i.g)(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),n=this.getPathStart(t);let o=-1;const a=new r.P;a.y=Number.NEGATIVE_INFINITY,a.x=Number.NEGATIVE_INFINITY;for(let t=n+0;t<s;t++){const s=e.readPoint2D(2*t);-1===a.compare(s)&&(o=t,a.setCoordsPoint2D(s))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,i.t)("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let i,n;return e<0?(i=0,n=this.m_pointCount):(i=this.getPathStart(e),n=this.getPathEnd(e)),s.applyTransformation(t,2*i,n-i),void this.notifyModifiedFlags(2001)}const n=new this.m_segmentBufferCTor,o=this.getPathCount();let a=e<0?0:e;do{const i=this.getPathStart(a),o=this.getPathEnd(a),h=this.isClosedPath(a),m=s.readPoint2D(2*i);if(!this.hasNonLinearSegmentsPath(a)){s.applyTransformation(t,2*i,o-i);continue}const l=r.P.getNAN();for(let e=i;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){const r=h&&e+1===o;r&&s.writePoint2D(2*i,m),this.getSegmentBuffer(e,n,!0),n.get().applyTransformation(t);const a=this.m_curveData.m_segmentParamIndex.read(e);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),s.writePoint2D(2*e,n.get().getStartXY()),r&&s.writePoint2D(2*i,n.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,n){const r=this.getPathStart(t)+e,o=this.getPathStart(s)+n;(o<r||r<0||o>this.getPointCount()-1)&&(0,i.r)("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(r,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===o)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return h}calculatePathSubLength2D(t,e,s){const n=this.getPathStart(t)+e,r=this.getPathStart(t)+s;(n<0||r>this.getPointCount()-1)&&(0,i.r)("");const o=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||(0,i.t)("cannot iterate across an open path"),o.setCirculator(!0)),n===r)return 0;let a=0,h=0;o.resetToVertex(n,t);do{h+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=o.J.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&(0,i.t)("Multi_path_impl::add");let s=this.getPathCount();for(let i=0,n=t.getPathCount();i<n;i++)this.addPath(t,i,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.t)("getSegmentBuffer"),this.getSegmentFromPath(n,r,e,s)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.G.enumLine;case 2:return i.G.enumBezier;case 4:return i.G.enumEllipticArc;case 8:return i.G.enumRationalBezier2;case 16:return i.G.enumBezier2;default:(0,i.c)("")}}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),n=this.getPathEnd(e),o=n-s;for(let e=s;e<n;e++){const n=31&this.m_curveData.m_segmentFlags.read(e);if(1===n)continue;2!==n&&(0,i.b)("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),li(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 lt),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=(0,n.w)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new lt),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=(0,n.X)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Bi.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 Li),Bi.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 Li),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 Li);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,n.R)(e,1),this.m_curveData.m_segmentParamIndex=(0,n.Q)(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,n.U)(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 Li),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=(0,r.d)(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,s){(t<0||t>=this.getPointCount())&&(0,i.t)("Multi_path_impl.replace_segment"),(0,i.g)(e.isCurve());const r=this.getPathIndexFromPointIndex(t),o=this.getPathStart(r),a=(t-o+1)%this.getPathSize(r)+o;{const s=this.getXY(t),n=this.getXY(a),r=!s.isEqualPoint2D(e.getStartXY())||!n.isEqualPoint2D(e.getEndXY());(0,i.g)(!r)}const h=e.getDescription();this.mergeVertexDescription(h);const m=new Array(32),l=new n.P({vd:h,attribBuffer:m,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),c=dt(u),g=_t(e);let _,d=!1;c>=g?((0,i.g)(null!==this.m_curveData),d=!0,_=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(g),d=!1,_=this.m_curveData.m_curveParamWritePoint);const p=e.getGeometryType(),f=Li.toSegType(p);s||(e.queryStart(l),this.setPointByVal(t,l),e.queryEnd(l),this.setPointByVal(a,l)),this.m_curveData.m_segmentParamIndex.write(t,1!==f?_:-1),this.m_curveData.m_segmentFlags.write(t,f),1!==f&&e.writeInBufferStream(this.m_curveData.m_segmentParams,_),d||(this.m_curveData.m_curveParamWritePoint+=g),u!==f&&(this.incCurveType(u,-1),this.incCurveType(f,1),this.modifyCurveCounter(1===u?1:-1))}setAttributeImpl(t,e,s){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,i.t)("");const t=new a.T,n=0===e?s:0,r=0===e?0:1;t.setShiftCoords(n,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,s)}}Bi.st_totalCurveCount=0;class Hi{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o.J(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.J.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 zi extends Bi{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Mr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Mr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Mr):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Mr,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Mr,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,i.c)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Mr)}getBoundary(){return Wi(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return zi.type}getDimension(){return 1}createInstance(){return new zi({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}zi.type=i.G.enumPolyline;var Ui=i.G;function Oi(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===Ui.enumPolygon)return 0!==t.calculateArea2D();if(s===Ui.enumPolyline)return ji(t.getImpl(),0,!0).bNotEmpty;if(s===Ui.enumEnvelope)return!0;if((0,i.f)(s))return!!t.isClosed();if((0,i.j)(s))return!1;if(s===Ui.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(Oi(s.getGeometry(t),e))return!0;return!1}(0,i.b)("")}function Wi(t,e){const s=t.getGeometryType();if(s===Ui.enumPolygon){const e=new zi({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===Ui.enumPolyline)return ji(t.getImpl(),0,!1).boundary;if(s===Ui.enumEnvelope){const e=new zi({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,i.f)(s)){const e=new d({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new n.P;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===Ui.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=Wi(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if((0,i.j)(s))return new n.P({vd:t.getDescription()});(0,i.b)("")}function ji(t,e,s){const i=!1,o=t;let a=null;if(s||(a=new d({vd:o.getDescription()})),!o.isEmpty()){const t=new n.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 i=o.getPathEnd(e)-1;t.add(i)}if(t.size()>0){const e=new n.B,i=o.getAttributeStreamRef(0),h={userSort(t,e,s){const n=r.P.getNAN(),o=r.P.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,o),n.compare(o))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),h);let m=i.readPoint2D(2*t.read(0)),l=0,u=1;const c=new n.P;for(let e=1,n=t.size();e<n;e++){const n=i.readPoint2D(2*t.read(e));if(n.isEqualPoint2D(m))t.read(l)>t.read(e)?(t.write(l,(0,r.n)()),l=e):t.write(e,(0,r.n)()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new d({})}}else t.write(l,(0,r.n)());m=n,l=e,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new d({})}}else t.write(l,(0,r.n)());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==(0,r.n)();e++)o.getPointByVal(t.read(e),c),a.add(c)}}}return s?{bNotEmpty:i,boundary:new d({})}:{bNotEmpty:i,boundary:a}}const Ji=r.a7/180,Zi=180/r.a7;function Qi(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.u)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function Ki(t){return t*Ji}function $i(t){return t*Zi}function tn(t){const e=(0,r.ab)();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=(0,r.u)(s,e),s<0&&(s+=e),s)}function en(t){const e=(0,r.a8)();let s=t;return s>-e&&s<=e||(s=tn(s),s>e&&(s-=(0,r.ab)())),s}function sn(t,e){return Qi(e-t)}var nn=n.V;class rn extends W{constructor(t){if(void 0===t||(0,r.T)(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 Wi(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=r.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=r.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return Dn(this,t,e,1),this}constructLineCircularArc(t,e){return Dn(this,t,e,0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=new r.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(i),h=Math.sin(i);return o.rotateDirect(a,h),o.addThis(s),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,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,n){0===s&&(0,i.t)("construct_enclosing_circle");const o=[0,0,0],a=function(t,e,s){const i=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&u(t,e)}(e,i),function(t,e,s,i){let n=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===n?u=r.P.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===n?u=r.P.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===n&&s.equals(t.at(i[0]))&&(u=0),u<=0){if(u<0&&m+1<3){e[a]=(0,r.b)(e[h],e[h]=e[a]);for(let t=0;t<n;t++)if(i[t]===e[h]){o[t]=h;break}a++}h++;continue}l=!0;let c=0;for(let t=0;t<n;t++)o[t]>h&&(i[c]=i[t],o[c]=o[t],c++);n=c,i[n]=e[h],o[n]=h,n++,n<3?h=a:(1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.b)(i[0],i[0]=i[2]),o[2]=(0,r.b)(o[0],o[0]=o[2])),h++)}if(!l)break;if(m+1<3){a=0;let s=!1;for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)o[t]>o[e]&&(o[e]=(0,r.b)(o[t],o[t]=o[e]),i[e]=(0,r.b)(i[t],i[t]=i[e]),s=!0);for(let t=0;t<n;t++)e[o[t]]=(0,r.b)(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===n&&1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.b)(i[0],i[0]=i[2]),o[2]=(0,r.b)(o[0],o[0]=o[2]))}h=n}return n}(t,i,e,s)}(e,s,o);if(1===a)t.constructCircleRadius(0,e[o[0]],n);else if(2===a){const s=r.P.lerp(e[o[0]],e[o[1]],.5),i=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s);t.constructCircleRadius(Math.max(i,a),s,n)}else if(3===a){const s=r.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),i=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(i,a,h),s,n)}else(0,i.c)("unexpected")}(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const n=r.P.calculateCircleCenterFromThreePoints(t,e,s);if(!n.isFinite()||!Number.isFinite(r.P.distance(t,n))){const i=r.P.distance(t,e),n=r.P.distance(t,s);this.constructLineCircularArc(t,i>=n?e:s)}return this.constructCircleCenterAndPoint(n,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new r.I(t.x),n=new r.I(e.x),o=new r.I(s.x),a=new r.I(t.y),h=new r.I(e.y),m=new r.I(s.y),l=new r.I(.5),u=n.subE(i),c=h.subE(a),g=o.subE(i),_=m.subE(a),d=u.mulE(_).subThisE(c.mulE(g));if(d.scaleError(10),d.isZero()){if(!u.isZero()||!c.isZero())return Dn(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const p=u.sqr().addThisE(c.sqr()).mulThisE(l),f=g.sqr().addThisE(_.sqr()).mulThisE(l),x=p.mulE(_).subThisE(f.mulE(c)),P=u.mulE(f).subThisE(g.mulE(p));x.divThisE(d),P.divThisE(d);const y=x.sqr().addThisE(P.sqr());y.sqrtThis();const E=x.addE(i),C=P.addE(a);let S=t.x-E.value(),v=t.y-C.value();const b=Math.atan2(v,S);S=e.x-E.value(),v=e.y-C.value();const I=Math.atan2(v,S);S=s.x-E.value(),v=s.y-C.value();const w=Math.atan2(v,S);let D=w-2*(0,r.a8)();for(;D<b;)D+=2*(0,r.a8)();let T=I-2*(0,r.a8)();for(;T<D;)T+=2*(0,r.a8)();let N=w+2*(0,r.a8)();for(;N>b;)N-=2*(0,r.a8)();let A,G=I+2*(0,r.a8)();for(;G>N;)G-=2*(0,r.a8)();A=T-b<b-G?T-b:G-b;const M=new r.P(E.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(A)>(0,r.a8)(),A>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return wn(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return wn(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,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=en(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=en(i);u.x=l.x*Math.cos(c),u.y=l.y*Math.sin(c),u.rotateDirect(h,m),u.addThis(s);const g=(0,r.ak)(n,(0,r.ab)());let _=g;Math.abs(_)===(0,r.ab)()&&(_=0);const d=r.P.getNAN();return d.x=l.x*Math.cos(c+_),d.y=l.y*Math.sin(c+_),d.rotateDirect(h,m),d.addThis(s),this.constructEllipticArcEndPointsCenter(u,d,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,r.a8)(),g>0,s)}constructEllipticArcAsNURB(t,e,s,n){return(n>=1||n<0)&&(0,i.t)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,i.t)("construct_elliptic_arc_as_NURB: control_point"),zn([t,e,s],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,jn(this),this.afterCompletedModification(),t!==this&&k(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!w(this,[t])&&Tn(this)}isDegenerateToLine(){return Tn(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!Yn(this)}isMajor(){return Rn(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.J.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=nn.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?Kn(this,r.E.unit(),t):(0,i.b)("3d not impl")}applyTransformation(t){Gn(this,t,!1)}createInstance(){return new rn}calculateLength2D(){return function(t){if(Tn(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=Nn(t,0);return Nn(t,1)-e}(this)}queryCoord2D(t,e){if(Tn(this))Z(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=Cn(this,t),i=new r.P(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){!function(t,e,s){if(Tn(t))$(new Gr({start:t.getStartXY(),end:t.getEndXY()}),e,s);else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new r.I;Sn(t,e,i);const n=new r.I,o=new r.I;r.I.st_cosAndSin(i,n,o);const a=C.constructCoordsE(new r.I(t.m_semiMajorAxis).mulThisE(n),new r.I(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),h=new r.I(t.m_rotation);r.I.st_cosAndSin(h,n,o),a.rotateDirect(n,o),a.addThisE(C.constructPoint2D(t.m_center)),s.setE(a)}}(this,t,e)}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 i=new Mr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();let o=0===t&&1===e;if(o&&!i)return void this.copyTo(n);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&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,A(n,a.x,a.y),M(n,h.x,h.y),o)return void qn(n,vn(this));n.m_startAngle=Cn(this,t),n.m_sweepAngle=Cn(this,e)-n.m_startAngle,n.m_startAngle=fn(n.m_startAngle),Xn(n,Math.abs(n.m_sweepAngle)>(0,r.a8)()),n.assignVertexDescription(this.m_description),jn(n),yn(n);const m=this.m_description.getAttributeCount();if(m>1){for(let e=1;e<m;e++){const s=this.m_description.getSemantics(e),i=nn.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<m;t++){const s=this.m_description.getSemantics(t),i=nn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){!function(t,e,s){if(Tn(t))s.setE(C.constructPoint2D(t.getEndXY()).subE(C.constructPoint2D(t.getStartXY())));else{const i=new r.I;Sn(t,e,i);const n=new C;if(n.setCoordsE(new r.I(t.m_semiMajorAxis).negate().mulE((new r.I).setSin(i)),new r.I(t.getSemiMinorAxis()).mulE((new r.I).setCos(i))),t.m_rotation){const e=new r.I(t.m_rotation);n.rotateDirect((new r.I).setCos(e),(new r.I).setSin(e))}n.scaleThis(new r.I(t.getSweepAngle())),s.setE(n)}}(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new r.P;this.queryCoord2D(t,n);const o=new r.P;this.queryCoord2D(e,o),i||(n.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,A(s,n.x,n.y),M(s,o.x,o.y),i?qn(s,vn(this)):(s.m_startAngle=Cn(this,t),s.m_sweepAngle=Cn(this,e)-s.m_startAngle,s.m_startAngle=fn(s.m_startAngle),Xn(s,Math.abs(s.m_sweepAngle)>Math.PI),jn(s),s.afterCompletedModification())}changeEndPoints2D(t,e){In(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=nn.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.W)(o,a,h,n,nn.getDefaultValue(e))}getClosestCoordinate(t,e){return $n(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return $n(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,i.t)("");const s=this.getSemiAxes(),n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),o=n+(0,r.a8)(),a=new Array(3);let h=0;if(a[0]=En(this,n),a[0]>0&&a[0]<1&&h++,a[1]=En(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,(0,i.g)(t.length>=h);let m=0;for(let s=0;s<h;s++){const i=a[s];this.queryCut(m,i,t[s],e),m=i}return h}getMonotonicParts(t,e){if(t.length<4&&(0,i.t)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;const s=this.getSemiAxes(),n=new Array(4);n[0]=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),n[1]=n[0]+(0,r.a8)(),n[2]=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),n[3]=n[2]+(0,r.a8)();const o=new Array(5);let a=0;for(let t=0;t<4;t++)o[a]=En(this,n[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,r.X)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,i.g)(t.length>=a);let h=0;for(let s=0;s<a;s++){const i=o[s];this.queryCut(h,i,t[s],e),h=i}return a}intersectionWithAxis2D(t,e,s,i){if(Tn(this))return new Gr({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i);let n,o;const a=new r.I(e),h=this.getSemiAxes();if(t){if(e>this.m_center.y+h.x||e<this.m_center.y-h.x)return 0;n=new r.I(h.x).mulThis(this.m_sinr),o=new r.I(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;n=new r.I(h.x).mulThis(this.m_cosr),o=new r.I(h.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}const m=n.sqr(),l=o.sqr(),u=m.addE(l),c=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(m),_=c.sqr().subThisE(u.mulE(g).mulThis(4)),d=n.mulE(a).mulThis(-2),p=a.sqr().subThisE(l),f=d.sqr().subThisE(u.mulE(p).mulThis(4));let x=_.eps()*Math.abs(f.value())<=f.eps()*Math.abs(_.value());x?n.isZero()&&(x=!1):o.isZero()&&(x=!0),x||(c.setE(d),g.setE(p));const P=(0,r.m)(r.I,2);let y=vt(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.I,s=new r.I;x?(e.setE(P[t]),s.setE(a.subE(o.mulE(P[t])).divThisE(n))):(s.setE(P[t]),e.setE(a.subE(n.mulE(P[t])).divThisE(o)));const i=En(this,Math.atan2(e.value(),s.value()));i>=0&&i<=1&&(E[C]=i,C++)}return y=C,0===y?0:(2===y&&E[0]>E[1]&&(E[1]=(0,r.b)(E[0],E[0]=E[1])),i&&(0,r.a)(i,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]),!i&&s[0]>s[1]&&(s[1]=(0,r.b)(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 I(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new r.E(0,1),t):(0,i.b)("3d not impl")}clone(t){const e=new rn;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Tn(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 i=t+Math.PI,n=[0,0];n[0]=En(this,t),n[1]=En(this,i);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=n[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(Tn(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),n=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=r.t){let t=r.P.lerp(i,n,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*r.P.distance(i,n))),e.setCoords(i),e.mergeNe(n),void e.mergeNe(t)}Kn(this,s,e)}tToLength(t){return Tn(this)?t*r.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Nn(this,t)}parametricAngleToT(t){return En(this,t)}tToParametricAngle(t){return Cn(this,t)}lengthToT(t){if(Tn(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(Tn(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 i=bn(t),n=(0,r.aa)(),o=An(t);s<0&&(e=-e);const a=e/t.m_semiMajorAxis+o;let h=(0,r.ad)(a,i.e2,i.completeE);return h-=n,h-=t.getStartAngle(),h/s}(this,t)}calculateWeightedAreaCentroid2D(t){if(Tn(this)){const t=new r.P;return t.setCoords(0,0),t}const e=Wn(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),n=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,h=new r.P;h.x=n*o*(n*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=n*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+n*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const m=i.add(s).mul(i.crossProduct(s)/6);return h.x-=m.x,h.y-=m.y,h.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new r.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Tn(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),n=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*(n-i),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),_=Math.sqrt(c),d=.5*m*(Math.asinh(g*n)/g+n*Math.sqrt(1+u*n*n))-.5*m*(Math.asinh(g*i)/g+i*Math.sqrt(1+u*i*i)),p=-.5*m*(Math.asin(_*a)/_+a*Math.sqrt(1-c*a*a))- -.5*m*(Math.asin(_*o)/_+o*Math.sqrt(1-c*o*o));t.setCoords(d,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Tn(this)){const s=r.P.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),n=new r.P;return this.queryCoord2D(i,n),r.P.distance(n,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getTangent(t){if(Tn(this))return this.getEndXY().sub(this.getStartXY());{const e=Cn(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(Tn(this))return this.getEndXY().sub(this.getStartXY());{const e=Cn(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!!kn(this)&&(Tn(this)?(Ln(this),!1):Bn(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=Cn(this,t),s=new r.P,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const n=new r.P;n.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),n.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(n)/o}getMonotonicPartParams(t,e){const s=new Array(6);s[0]=0;let n=1;if(this.isDegenerateToLine())s[1]=1,n=2;else{const t=this.getSemiAxes(),e=new Array(4);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=(0,r.a9)());for(let t=0;t<4;t++){const i=En(this,e[t]);i>0&&i<1&&(s[n]=i,n++)}n>2&&(0,r.X)(s,n),s[n]=1,n++}if(e){t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s[t]}return n}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.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Tn(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,Fn(t)}calculateArea2DHelper(){return Wn(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)),Tn(this))return;const s=this.getSemiAxes(),i=new Array(8);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=En(this,t),i[1]=En(this,e),i[2]=En(this,n),i[3]=En(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=En(this,n),i[5]=En(this,r),i[6]=En(this,o),i[7]=En(this,a)}const n=r.P.getNAN();for(let s=0;s<8;s++){const r=i[s];t.containsExclusiveCoordinate(r)&&(this.queryCoord2D(r,n),e.mergeNe(n))}}setSegmentFromCoords(t,e){!function(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void Dn(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new r.P;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=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)(rn,4),g=new Array(4);let _=0;for(let t=0;t<4;t++){c[t].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,o,a,m[t],l[t],h),g[t]=0;let i=0;for(let n=u;n<s-1;n+=u){const s=c[t].getClosestCoordinate(e[n],!1);g[t]+=r.P.sqrDistance(c[t].getCoord2D(s),e[n]),i++}g[t]/=i,g[t]<g[_]&&(_=t)}t.assignCopy(c[_])}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,i.c)("should not1; be called"),0}ensureXYMonotone(){if(Tn(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Dn(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=(0,r.m)(r.P,3);let e=Hn(this,t);if(Le(t)){let s=!1;if(0===this.projectionBehavior()){const i=new o.J;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const n=new r.P;n.setSub(t[2],t[0]),n.leftPerpendicularThis(),n.normalize(),n.scale(r.P.distance(t[2],t[0]));const a=r.P.lerp(t[2],t[0],.5),h=a.sub(n),m=a.add(n);i.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),_=u.dotProduct(c);e=(0,r.aa)()-Math.abs(.5*Math.atan2(g,_)),s=!0}return zn(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){In(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,qn(e,vn(this))}reverseImpl(){Vn(this,!Yn(this)),yn(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&jn(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(Ki(Qi($i(this.m_rotation-s.m_rotation)))),n=Math.abs((0,r.a8)()-i),o=Math.min(i,n);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.b)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,r.b)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,r.b)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,r.b)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,r.b)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,r.b)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,r.b)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,r.b)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,r.b)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,r.b)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,r.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ln(this),Fn(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&(0,i.s)(""),Tn(this))return new Gr({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 n=this.getClosestCoordinate(t,!1),o=r.P.getNAN();return this.queryCoord2D(n,o),r.P.distance(o,t)<=s?(0,r.Y)(n,0,1)&&(this.queryCoord2D(0===n?1:0,o),r.P.distance(o,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Cr(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Fn(this)}clearEndPointModified(){Ln(this)}}rn.type=i.G.enumEllipticArc;class on extends Bi{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Mr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Mr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Mr):t.envelope?(0,i.b)("envelope constructor not impl"):(0,i.c)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Mr)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Wi(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return on.type}getDimension(){return 2}createInstance(){return new on({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function an(t,e,s,i,n,o){return new ln(0,0,0,null,!1,(0,r.q)()).densifyEx(t,e,s,i,!1,o)}function hn(t,e,s,n,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const l=t.getGeometryType();if(l===i.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(l===i.G.enumBezier){if(!n)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;const e=[];e.length=9;let i=t.getMonotonicPartParams(e.length,e);if(e.length=i,i=un(t,s,e),2===i&&o&&(e[1]=.5,e.push(1),i=3),h&&h.splice(0,0,...e.slice(0,i)),a){const s=new Mr;for(let n=1;n<i;n++){const i=e[n-1],r=e[n];t.queryCut(i,r,s,!0);const o=s.get();mi(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return i-1}if(l===i.G.enumEllipticArc){const m=t;if(m.isDegenerateToLine()||m.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(n&&(o||!m.isMonotoneQuickAndDirty())){const r=[];r.length=6;let l=m.getMonotonicPartParams(r.length,r);r.length=l,l=un(t,s,r),2===l&&o&&(r[1]=.5,r.push(1),l=3);let u=0;if(l>2){const t=new Mr,o=h||[];let c=0;for(let g=1;g<l;g++){const _=r[c],d=r[g];if(m.queryCut(_,d,t,!0),t.get().isDegenerate(0))continue;const p=o.length,f=cn(1===g,t.get(),e,s,n,a,h);(0,i.g)(f>0),u+=f;const x=g===l-1,P=r[c],y=t.get().getSweepAngle()/m.getSweepAngle();for(let t=p,e=o.length;t<e;t++)if(o[t]=!x||t+1<e?P+o[t]*y:1,a){const e=3*t,s=m.getCoord2D(o[t]);a[e].setCoordsPoint2D(s),e>0&&li(a.slice(e-3))}c=g}return u}}return cn(!0,m,e,s,n,a,h)}if(l===i.G.enumRationalBezier2){const i=t;if(n&&(o||!i.isMonotoneQuickAndDirty())){const n=[];n.length=6;let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=un(t,s,n),2===r&&o&&(n[1]=.5,n.push(1),r=3);let m=0;if(r>2){const t=new Mr,o=h||[];for(let l=1;l<r;l++){const u=n[l-1],c=n[l];i.queryCut(u,c,t,!0);const g=o.length;m+=gn(1===l,t.get(),e,s,!1,a,h);const _=l===r-1,d=n[l-1];for(let t=g,e=o.length;t<e;t++)if(o[t]=!_||t+1<e?d+o[t]:1,a){const e=3*t,s=i.getCoord2D(o[t]);a[e].setCoordsPoint2D(s),e>0&&Gs(a.slice(e-3))}}return m}}return gn(!0,i,e,s,n,a,h)}if(l===i.G.enumBezier2){const i=t,m=(0,r.m)(r.P,3);i.queryControlPoints(m);const l=new zs;return l.constructFromQuadratic(m),hn(l,e,s,n,o,a,h)}(0,i.b)("")}function mn(t,e,s,n,o,a,h,m,l){const u=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),u===i.G.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(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.f)(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=un(t,s,c);else{if(g=2,c[0]=0,c[1]=1,u===rn.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else(0,i.g)(u===Vt.type);c.length=g}if(2===g&&n&&(c[1]=.5,c.push(1),g=3),a){const e=new Mr;let s=1;for(;s<g;){const n=c[s-1],m=c[s];t.queryCut(n,m,e,!0);const l=(0,r.m)(r.P,3),_=[1,1,1];if(u===i.G.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(m-n)/3;c.splice(s,0,n+t),c.splice(s+1,0,n+2*t),g+=2;continue}_[1]=Hn(t,l)}else{const t=e.get();t.queryControlPoints(l),t.queryWeights(_)}o&&Le(l),1===s&&(a.push(l[0].clone()),h.push(_[0])),a.push(l[1].clone()),a.push(l[2].clone()),h.push(_[1]),h.push(_[2]),s++}}return m&&(m.length=g,(0,r.a)(m,c,0,0,g)),g-1}on.type=i.G.enumPolygon;class ln{static constructDefault(t){return new ln(0,0,0,t,!1,(0,r.q)())}constructor(t,e,s,o,a,h){this.m_segmentBuffer=null,this.m_dummyPoint=new n.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.aa)()?(0,r.aa)():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,i.A)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,n,o,a){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=n>(0,r.aa)()?(0,r.aa)():n,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,i.A)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return(0,i.u)(e)?t:(0,i.h)(e)?this.densifyMultiPath(t):(0,i.f)(e)?this.densifySegmentImpl(t):e===i.G.enumEnvelope?this.densifyEnvelope(t):void(0,i.c)("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.G.enumLine)&&(!n||s))return void(e?o===i.G.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.G.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.G.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new zi({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){const e=new on({vd:t.getDescription()});e.addEnvelope(t,!1);const s=o.J.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=e.getImpl(),n=t.getImpl(),o=n.getAttributeStreamRef(0),a=new Gr;for(let t=0,i=n.getPathCount();t<i;t++){const i=n.isClosedPath(t);if(0===n.getPathSize(t))continue;const h=n.getPathStart(t),m=o.readPoint2D(2*h),l=m.clone();s.startPath(m);for(let i=h+1,m=n.getPathEnd(t);i<m;i++){const t=o.readPoint2D(2*i),n=r.P.distance(l,t);if(n>this.m_maxLength){let e=Math.ceil(n/this.m_maxLength);e>(0,r.q)()&&(e=(0,r.q)());const i=1/e;let o,h,m;l.compare(t)<0?(a.setStartXY(l),a.setEndXY(t),o=0,h=1):(a.setStartXY(t),a.setEndXY(l),o=e-2,h=-1);for(let t=0,n=e-1;t<n;t++,o+=h){this.progress_(),m=i*(o+1);const t=new r.P;a.queryCoord2D(m,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),l.assign(t)}if(i){const t=r.P.distance(l,m);if(t>this.m_maxLength){const e=m;let i=Math.ceil(t/this.m_maxLength);i>(0,r.q)()&&(i=(0,r.q)());const n=1/i;let o,h;l.compare(e)<0?(a.setStartXY(l),a.setEndXY(e),o=0,h=1):(a.setStartXY(e),a.setEndXY(l),o=i-2,h=-1);const u=new r.P(0,0);let c;for(let t=0,e=i-1;t<e;t++,o+=h)this.progress_(),c=n*(o+1),a.queryCoord2D(c,u),s.lineTo(u),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,s,n,o,a){(0,i.g)(t.getGeometryType()!==i.G.enumBezier);let h=t.getStartXY().compare(t.getEndXY());0===h&&e<1&&(t.getGeometryType()===i.G.enumEllipticArc?h=t.getSweepAngle()<0?1:-1:(0,i.b)("densify segment by length"));let m=0;if(n&&(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 Mr);let i=Math.ceil(1/e);i>(0,r.q)()&&(i=(0,r.q)()),e=1/i,this.m_segmentBuffer.create(t.getGeometryType());let n,o,l,u=t;h<0?(n=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),n=i-2,o=-1,u=this.m_segmentBuffer.get());const c=i-1;for(let t=0;t<c;t++,n+=o)l=e*(n+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&&n&&m<2)&&(s?(t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,s,i,n){const o=new zs;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)):n.push(0),++l);const u=[],c=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let _=!0,d=0;if(m>0)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new 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(),_=!1);let e=.5*(h+m);Math.abs(d-e)<.4*(m-h)&&(e=d);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.mul(1-s).add(l.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[3];t[1]=i,t[2]=g,t[3]=f,t[4].setCoords(h,e);const P=[f,p,l,x,new r.P(e,m)];u.push(P),c[c.length-1]=o+1,c.push(o+1)}else u.pop(),c.pop(),(u.length>0||!i||i&&s&&l<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.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(),_=!1);let e=.5*(h+m);Math.abs(d-e)<.4*(m-h)&&(e=d);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.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,i,g,f,new r.P(h,e)];u.push(P),c[c.length-1]=o+1,c.push(o+1)}else u.pop(),c.pop(),(u.length>0||!i||i&&s&&l<2)&&(e?(a.queryCoord(m,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m),++l)}}densifyRationalBezier2(t,e,s,i,n){const o=new Vt;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)):n.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new Vt,g=[],_=[];for(g.push(new r.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++l}}}densifyBezier2(t,e,s,i,n){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)):n.push(0),++l);const u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),c=new qt,g=[],_=[];for(g.push(new r.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.bezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++l}}}densifyEllipticArc(t,e,s,i,n){const o=new rn;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)):n.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new rn,g=[],_=[];for(g.push(new r.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++l}}}calculateLengthSubdivisionStep(t,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.G.enumEllipticArc){const i=t;if(i.isCircular()||i.isDegenerate(0)||i.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*i.getSemiAxes().y/i.getSemiAxes().x}t.getGeometryType()===i.G.enumBezier&&(0,i.b)(""),(0,i.b)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const i=s.getSemiMajorAxis(),n=1-e/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(e/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(t,o)}}(0,i.b)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}(0,i.b)("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);e.queryControlPoints(o);const a=[0,0,0];return e.queryWeights(a),!n&&this.m_maxDeviation>0&&(n=!ln.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!ln.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),n}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);return e.queryControlPoints(o),!n&&this.m_maxDeviation>0&&(n=!ln.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!ln.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),n}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(n=!0,!0):(!n&&this.m_maxDeviation>0&&(n=!ln.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!ln.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n)}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=!ln.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!ln.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1])),o=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(n),Math.abs(o))<=e){const e=new r.P;_i(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),n=[0,0];if(1===function(t,e,s){(0,i.g)(!Tn(t));const n=new a.T;n.setRotateAngle(-t.getAxisXRotation());const o=new r.P;n.queryTransform(e,o);const h=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),m=h+(0,r.a8)();let l=En(t,h),u=En(t,m);u<l&&(u=(0,r.b)(l,l=u));let c=0;return l>=0&&l<=1&&(s[c++]=l),u>=0&&u<=1&&(s[c++]=u),c}(t,s,n)){const s=t.getCoord2D(n[0]),i=r.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),o=new r.P;return(0,r.D)(t.getStartXY(),t.getEndXY(),i,o),r.P.distance(s,o)<=e}}const s=t.getCoord2D(.5),n=new r.P;return(0,r.D)(t.getEndXY(),t.getStartXY(),.5,n),r.P.distance(s,n)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0||s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==i.G.enumEllipticArc||t.isCircular())}}function un(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const r=[];r.length=i-1;for(let e=1,o=i;e<o;e++){const i=t.tToLength(s[e]);r[e-1]=i-n,n=i}for(;r.length>1;){const t=r.findIndex((t=>t<=2*e));if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===r.length||r[e]>r[n])&&(n=e,i--)}r[n]+=r[t],r.splice(t,1),s.splice(i,1)}return s.length}function cn(t,e,s,i,n,h,m,l){const u=e.clone();u.dropAllAttributes();const c=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(r.P.getNAN()),e.push(r.P.getNAN()),e.push(i.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(),_=u.getEndXY(),d=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.J.constructEmpty();y.setCoords({center:f,width:2*d.x,height:2*d.x});const E=.05*y.calculateToleranceFromEnvelope(),C=Math.max(s/d.x,E/d.x);let S=4*Math.pow(C/.0741,1/6);S=Math.min(S,Math.PI/2);const v=tn(u.getStartAngle());let b=P>0?Math.floor(v/S):Math.ceil(v/S);b*=S;const I=P>0?S:-S;b+I===v&&(b+=I);let w=4/3*Math.tan(Math.abs(S)/4);P>0&&(w=-w),m&&t&&m.push(0);const D=S/Math.abs(P);let T=(b-v)/P;const N=g.clone(),A=new r.P;u.queryCoord2D(0,A);const G=A.clone(),M=1-.01*D;let q=0,F=0;for(;T<1;){let s;if(T+=D,F>0&&T<M)s=w;else{T>=M&&(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*i||r.P.distance(o,_)<=2*i))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(_),n&&li(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())),q++),F=T,G.setCoordsPoint2D(A)}return q}function gn(t,e,s,i,n,a,h,m){e.clone().dropAllAttributes();const l=new o.J;e.queryLooseEnvelope(l);const u=.05*l.calculateToleranceFromEnvelope(),c=Math.max(s,u);h&&t&&h.push(0);let g=0;const _=(0,r.m)(r.P,3);e.queryControlPoints(_);const d=[0,0,0];e.queryWeights(d);const p=[],f=(0,r.f)(9,Number.NaN);let x=0;n?(x=e.getMonotonicPartParams(f.length,f),f.length=x,x=un(e,i,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),i=[0,0,0];He(_,d,t,e,s,i);const n=(0,r.m)(r.P,4),o=ze(s,i,n),m=16,l=p.length>m;c>=o||l?(h.push(e),a&&(y&&(a.push(n[0]),y=!1),a.push(n[1]),a.push(n[2]),a.push(n[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class _n{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 dn(t,e){return t.convertToCanonic(e)}function pn(t,e,s,i){let n=t.m_startAngle,o=t.m_sweepAngle;const a=1e-12;for(;n>(0,r.a8)();)n-=2*(0,r.a8)();for(;n<=-(0,r.a8)();)n+=2*(0,r.a8)();if(!Number.isNaN(e)){for(;e>(0,r.a8)();)e-=2*(0,r.a8)();for(;e<=-(0,r.a8)();)e+=2*(0,r.a8)();!s&&e>n&&(e-=2*(0,r.a8)()),s&&e<n&&(e+=2*(0,r.a8)()),o=e-n,Math.abs(o)<a&&!i&&(o=s?2*(0,r.a8)():-2*(0,r.a8)()),Math.abs(o)>2*(0,r.a8)()-a&&i&&(o=0)}Math.abs(o)>2*(0,r.a8)()-a&&(o=o>=0?2*(0,r.a8)():-2*(0,r.a8)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),i=Math.abs(o)<=(0,r.a8)(),o&&(s=o>0),t.m_startAngle=fn(n),t.m_sweepAngle=o,Xn(t,!i),Vn(t,s)}function fn(t){let e=t,s=!1;return e<=-(0,r.a8)()?(e+=(0,r.ab)(),s=!0):e>(0,r.a8)()&&(e-=(0,r.ab)(),s=!0),e<=-(0,r.a8)()?(e=(0,r.u)(e,(0,r.ab)()),e<=-(0,r.a8)()&&(e+=(0,r.ab)()),s=!0):e>(0,r.a8)()&&(e=(0,r.u)(e,(0,r.ab)()),e>(0,r.a8)()&&(e-=(0,r.ab)()),s=!0),s&&(e>(0,r.a8)()||e<=-(0,r.a8)())&&(e=(0,r.a8)()),e}function xn(t,e,s){const i=s,n=i.getSemiAxes();let o=new r.P(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return o=i.convertFromCanonic(o),r.P.sqrDistance(o,i.getStartXY())}function Pn(t,e,s){const i=s,n=i.getSemiAxes(),o=t[0]+i.getStartAngle();let a=new r.P(n.x*Math.cos(o),n.y*Math.sin(o));return a=i.convertFromCanonic(a),r.P.sqrDistance(a,i.getEndXY())}function yn(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=Rn(t),o=Yn(t),a=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=fn(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?o?(0,r.ab)():-(0,r.ab)():0}else{const i=t.convertToCanonic(e),h=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=h.x,i.y/=h.y;const m=t.convertToCanonic(s);m.x/=h.x,m.y/=h.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=r.P.calculateAngle(i,m),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,r.ab)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,r.ab)()),t.m_startAngle=fn(t.m_startAngle);let l=xn([t.m_startAngle],0,t);if(l=Math.sqrt(l),l>.25*L(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Pt(xn,t,1,[t.m_startAngle],[e],[s],0,i),t.m_startAngle=fn(i[0])}if(l=Pn([t.m_sweepAngle],0,t),l=Math.sqrt(l),l>.25*L(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Pt(Pn,t,1,[t.m_sweepAngle],[e],[s],0,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>(0,r.a8)();if(Xn(t,u),n!==u&&!n&&Math.abs(t.m_sweepAngle)>1.5*(0,r.a8)())return void Dn(t,e,s,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void Dn(t,e,s,a)}}function En(t,e){return(function(t,e){const s=new r.E(t.getStartAngle(),t.getEndAngle());s.normalize();const i=(0,r.ab)(),n=(0,r.u)(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}(t,e)-t.getStartAngle())/t.getSweepAngle()}function Cn(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Sn(t,e,s){s.assign(new r.I(t.m_startAngle).addE(e.mulE(new r.I(t.m_sweepAngle))))}function vn(t){return t.m_cachedValues}function bn(t){if(t.m_cachedValues)return t.m_cachedValues;const e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,r.s)(t.m_minorMajorRatio)}(t),e.completeE=(0,r.al)(e.e2),t.m_cachedValues=e,e}function In(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Tn(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,jn(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*(0,r.aa)()){const i=(0,r.m)(r.P,3),n=Hn(t,i);if(Re(i)){if(i[0].assign(e),i[2].assign(s),Le(i),0===t.projectionBehavior()){let e=0,s=2;r.P.sqrDistance(i[1],i[0])<r.P.sqrDistance(i[1],i[2])&&(s=(0,r.b)(e,e=s));const n=i[s].sub(i[e]),o=n.length();n.divThis(o);const a=i[1].sub(i[e]),h=a.length(),m=a.dotProduct(n)/h,l=a.crossProduct(n)/h,u=new r.P;(0,r.D)(i[e],i[s],.5,u);const c=.5*o/l*(0,r.c)(1-m,0,1),g=i[1].side(i[e],i[s]),_=n.clone();g?_.leftPerpendicularThis():_.rightPerpendicularThis();const d=u.sub(_.mul(c));t.constructCircularArcThreePoint(i[0],i[2],d)}else zn(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?function(t,e,s){const i=t.getStartXY(),n=t.getEndXY(),o=i.equals(n),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(i,n),l=h/m;o.scale(l,l);const u=n.sub(i);u.divThis(m);const c=s.sub(e);c.divThis(h);const g=u.crossProduct(c),_=c.dotProduct(u);return o.rotate(_,g),o.shiftCoords(e.x,e.y),Gn(t,o,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,void(t.m_YEnd=s.y)}const m=new r.P;if(t.queryCoord2D(.5,m),h){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=m.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}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),_=new r.P;(0,r.D)(l,c,g,_);const d=r.P.distance(e,_);t.constructEllipticArcEndPointsCenter(e,s,d,1,0,!0,!t.isClockwise(),_),t.setProjectionBehavior(0)}(t,e,s):er(t,e,s)}}function wn(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,N(t,e),G(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),Xn(t,o),Vn(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,Bn(t,void 0===h)}function Dn(t,e,s,i){t.m_bits=0,t.m_rotation=0,N(t,e),G(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,Xn(t,!1),Vn(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function Tn(t){return t.m_center.isNAN()}function Nn(t,e){if(0===e)return 0;const s=bn(t),i=Cn(t,e),n=(0,r.aa)(),o=An(t),a=(0,r.ac)(i+n,s.e2,s.completeE),h=t.m_semiMajorAxis*(a-o);return Math.abs(h)}function An(t){const e=bn(t);return(0,r.ac)(t.getStartAngle()+(0,r.aa)(),e.e2,e.completeE)}function Gn(t,e,s){if(2===e.m_TransformationType)return void(0,i.g)(0);if((0,i.g)(!kn(t)),e.isIdentity())return;Fn(t);const n=r.P.getNAN();n.x=t.m_XStart,n.y=t.m_YStart,e.transformInPlace(n);const o=r.P.getNAN();if(o.x=t.m_XEnd,o.y=t.m_YEnd,e.transformInPlace(o),Tn(t))return t.m_XStart=n.x,t.m_YStart=n.y,t.m_XEnd=o.x,void(t.m_YEnd=o.y);const a=t.m_center.clone();if(e.transformInPlace(a),s||e.isUniformNoRotation()){let s=Yn(t);if(e.isReflective()&&(s=!s),0===t.projectionBehavior()){if(!n.equals(o)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(n,o,s)}return void Mn(t,n,o,a,s,!1)}const i=new r.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const h=Math.atan2(i.y,i.x),m=t.getSemiAxes();e.transformWithoutTranslateInPlace(m);const l=t.m_center.clone();return e.transformInPlace(l),void t.constructEllipticArcEndPointsCenter(n,o,m.x,m.y/m.x,h,t.isMajor(),s,l)}{{const s=new Array(4);!function(t,e){const s=new r.I(t.m_cosr).sqrThis(),i=new r.I(t.m_sinr).sqrThis(),n=new r.I(t.m_minorMajorRatio),o=new r.I(1/t.m_minorMajorRatio),a=n.mulE(s).addThisE(o.mulE(i)),h=n.subE(o).mulThis(2*t.m_cosr*t.m_sinr),m=n.mulE(i).addThisE(o.mulE(s));e[0]=a,e[1]=h,e[2]=m,e[3]=new r.I(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,s);const i=new S;if(i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]),!i.det().isZero()){const h=new S;if(h.a11.set(e.xx),h.a12.set(e.xy),h.a21.set(e.yx),h.a22.set(e.yy),h.invertThis()){const m=h.clone();m.transposeThis();const l=i.clone();if(l.mulThis(h),l.mulLeftThis(m),!l.det().isZero()){const i=(0,r.m)(r.I,4);i[0].setE(l.a11),i[1].setE(l.a12),i[1].mulThisByPower2(2),i[2].setE(l.a22),i[3].setE(s[3]);const h=r.P.getNAN(),m=function(t,e){const s=new S;s.a11.setE(t[0]),s.a12=r.I.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[r.P.getNAN(),r.P.getNAN()],n=[new r.I,new r.I];s.eigenSymmetric(n,i);const o=t[3].clone();return o.negateThis(),o.invThis(),n[0].mulThisE(o),n[1].mulThisE(o),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble(),Math.atan2(i[0].y,i[0].x)}(i,h);let u=Yn(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(n,o,h.x,h.y/h.x,m,t.isMajor(),u,a)}}}}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 i=t.isClockwise();i&&(s[2]=(0,r.b)(s[0],s[0]=s[2]));const h=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const m=new r.P(0,0),l=t.createInstance();zn(s,h,m,!1,l),t.constructEllipticArcEndPointsCenter(n,o,l.getSemiMajorAxis(),l.getMinorMajorRatio(),l.getAxisXRotation(),t.isMajor(),!i,a)}}function Mn(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),pn(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function qn(t,e){t.m_cachedValues=e}function Fn(t){t.m_cachedValues=null}function Vn(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function Yn(t){return!!(1&t.m_bits)}function Xn(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function Rn(t){return!!(2&t.m_bits)}function kn(t){return!!(8&t.m_bits)}function Ln(t){t.m_bits&=-9}function Bn(t,e){Ln(t);const s=t.getStartXY(),n=t.getEndXY();let o=!1;const a=Rn(t),h=Yn(t),m=t.projectionBehavior(),l=s.equals(n);let u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,i.p)("NAN minor major ratio and non-zero major axis")),u||=e?l:t.m_center.isNAN(),u)return Dn(t,s,n,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(l){const e=t.convertToCanonic(s);e.x/=c.x,e.y/=c.y;const i=Math.sqrt((0,r.s)(e.x)+(0,r.s)(e.y));if(o=1!==i,t.m_semiMajorAxis*=i,c.mulThis(i),t.m_startAngle=fn(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.ab)():-(0,r.ab)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;const e=new C;e.setWithEps(t.getStartXY(),8),e.subThisE((new C).setWithEps(t.m_center,8));const s=new r.I;s.setWithEps(t.m_rotation,8);const i=new r.I,n=new r.I;r.I.st_cosAndSin(s,i,n),e.rotateReverse(i,n);const o=new C;o.setWithEps(t.getEndXY()),o.subThisE(C.constructPoint2D(t.m_center)),o.rotateReverse(i,n);const a=new r.I;a.setWithEps(t.m_semiMajorAxis,8);const h=a.clone(),m=new r.I;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.ae),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(r.ae);return!l.isZero()||!u.isZero()}(t);if(!e){const i=t.convertToCanonic(s);i.x/=c.x,i.y/=c.y;const o=new r.P(1,0);t.m_startAngle=r.P.calculateAngle(o,i);const a=t.convertToCanonic(n);a.x/=c.x,a.y/=c.y,t.m_sweepAngle=r.P.calculateAngle(i,a),e=!On(t)}if(e){o=!0;const e=s.sub(n).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let i=(0,r.s)(e.x/c.x)+(0,r.s)(e.y/c.y);i>1&&(i=Math.sqrt(i),t.m_semiMajorAxis*=i,c.mulThis(i));const m=new r.P(0,0);{const t=c.x*c.x,s=c.y*c.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);m.setCoords(c.x*e.y/c.y,-c.y*e.x/c.x),m.mulThis(t),a===h&&m.negateThis()}}{const e=new r.P(m.x,m.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(n).mulThis(.5)),t.m_center.assign(e)}}if(yn(t),!On(t))return Dn(t,s,n,m),!0}return jn(t),t.afterCompletedModification(),o}function Hn(t,e){(0,i.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),n=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===n)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),n*Math.cos(h)),u=new r.P(-s*Math.sin(m),n*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 zn(t,e,s,n,o){if(n){const s=.5,i=Math.sqrt(e),n=(0,r.s)(1-s)+2*i*s*(1-s)+(0,r.s)(s),a=t[0].mul((0,r.s)(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul((0,r.s)(s))).divThis(n);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}const a=t[0].sub(t[1]),h=t[2].sub(t[1]),m=a.crossProduct(h),l=a.dotProduct(h),u=e;(0,i.g)(u<=1),(0,i.g)(u>0);const c=.5/(1-u),g=a.sqrLength(),_=l,d=h.sqrLength(),p=(0,r.s)(m),f=a.sub(h).sqrLength();if(0===p)return Dn(o,t[0],t[2],1),!1;if(l<=-Math.sqrt(g)*Math.sqrt(d))return Dn(o,t[0],t[2],1),!1;const x=[0,0],P=new r.E;P.setInfinite();const y=ft(2*p,-(f/u+4*_),2*(1-u)/u,P,!1,x);if(0===y)return Dn(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]),S=.5/u;let v=S-d*x[0],b=S-g*x[0];Math.abs(v)>Math.abs(b)?b=_*x[0]-S+1:v=_*x[0]-S+1;const I=a.mul(v).add(h.mul(b)),w=I.norm(1)<1e-15*E?0:Math.atan2(I.y,I.x)+Math.PI,D=a.add(h),T=s?s.clone():t[1].add(D.mul(c)),N=t[0].sub(T),A=t[2].sub(T),G=N.crossProduct(A)<0;return new rn,o.constructEllipticArcEndPointsCenter(t[0],t[2],E,C/E,w,!1,!G,T)}function Un(t,e,s,i,n){return zn(t,e,s,i,n)}function On(t){let e=!1;{const s=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),e=r.P.distance(t.getStartXY(),s)>L(t)}let s=!1;if(!e){const e=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center),s=r.P.distance(t.getEndXY(),e)>L(t)}return!e&&!s}function Wn(t){if(Tn(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,l=0;t.m_rotation&&(m=(a-h)*(a+h),l=2*a*h);const u=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;return t.m_rotation&&(c=-2*Math.sin(r+n)*Math.sin(r-n)*.125*l-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h),i*(u+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function jn(t){t.queryCoord2D(.5,t.m_interior)}function Jn(t,e,s,i,n){if(n){if(0!==vr(e,s))return 2}else if(b(e,s))return 1;return 0!==Zn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Zn(t,e,s,n,o,a,h,m,l,u){if(Tn(e))return it(new Gr({start:e.getStartXY(),end:e.getEndXY()}),s,n,o,a,h,m,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0);const c=B(e,s);if(H(e,s,h=Math.max(c,h)))return 0;const g=s.getStartXY();g.subThis(e.m_center);const _=s.getEndXY();_.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),_.rotateReverse(e.m_cosr,e.m_sinr);const d=_.clone();d.subThis(g);const p=e.m_semiMajorAxis,f=1/p,x=e.getSemiMinorAxis(),P=1/x,y=d.clone();y.leftPerpendicularThis();const E=Math.atan2(x*y.y,p*y.x),C=new Array(16),S=new Array(16);let v=0;const b=[E,E+Math.PI];for(let t=0;t<2;++t){const i=En(e,b[t]);if(i>=0&&i<=1){C[v]=i;const t=e.getCoord2D(C[v]);S[v]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(S[v]))<=h&&v++}}const I=g.x*f,w=g.y*P,D=d.x*f,T=d.y*P;let N=ft(D*D+T*T,2*(I*D+w*T),I*I+w*w-1,r.E.unit(),!1,S);(0,i.g)(N>=0);for(let t=0;t<N;t++){const i=d.mul(S[t]).add(g);i.x*=f,i.y*=P;const n=En(e,Math.atan2(i.y,i.x));if(n>=0&&n<=1){C[v]=n;const t=e.getCoord2D(n);S[v]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(S[v]))<=h&&v++}}(0,i.g)(v<C.length+4);const A=new Array(16);N=e.intersectPoint(s.getStartXY(),A,h);for(let t=0;t<N;t++,v++)C[v]=A[t],S[v]=0;N=e.intersectPoint(s.getEndXY(),A,h);for(let t=0;t<N;t++,v++)C[v]=A[t],S[v]=1;N=s.intersectPoint(e.getStartXY(),A,h);for(let t=0;t<N;t++,v++)C[v]=0,S[v]=A[t];N=s.intersectPoint(e.getEndXY(),A,h);for(let t=0;t<N;t++,v++)C[v]=1,S[v]=A[t];return 0===v?0:Dr(t,e,s,C,S,v,n,o,a,h,m,0,u)}function Qn(t,e,s,n,o,a,h,m,l,u){if(Tn(e)){const i=new Gr({start:e.getStartXY(),end:e.getEndXY()});return Zn(t,s,i,n,a,o,h,m,0,!0)}if(Tn(s)){const i=new Gr({start:s.getStartXY(),end:s.getEndXY()});return Zn(t,e,i,n,o,a,h,m,0,u)}const c=B(e,s);h=Math.max(h,c);let g=!1;{const t=e.getSemiAxes(),n=e.getCenter(),u=s.getSemiAxes(),c=s.getCenter(),_=r.P.distance(c,n),d=t.x+u.x;if(_>d+h)return 0;if(t.y>u.x){if(_+u.x+h<t.y)return 0}else if(u.y>t.x&&_+t.x+h<u.y)return 0;if(l&&!m){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),r=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(n&&r&&(g=!0,_<=d)&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+_)return(0,i.g)(!o&&!a),1}}if(!g&&H(e,s,h))return 0;const _=[],d=[],p=!1,f=!1,x=mn(e,0,0,p,f,_,d,null),P=[],y=[],E=mn(s,0,0,p,f,P,y,null);if(1===x&&1===E){const t=new Vt({points:_,weights:d}),i=new Vt({points:P,weights:y}),c=[],g=[],p=Ze(!1,t,i,n,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 n=0;n<p;++n){if(o)if((0,r.Y)(c[n],0,1))o.push(c[n]);else{const s=t.tToLength(c[n]),i=e.lengthToT(s);o.push(i)}if(a)if((0,r.Y)(g[n],0,1))a.push(g[n]);else{const t=i.tToLength(g[n]),e=s.lengthToT(t);a.push(e)}}}return p}let C=[];const S=[];let v=0;const b=l&&!m;for(let t=0;t<x;t++){const i=new Vt({points:_.slice(2*t,2*t+3),weights:d.slice(2*t,2*t+3)});let n=0;for(let o=0;o<E;o++){S.length<=o&&S.push(new Vt({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=Ze(!1,i,S[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=i.tToLength(a[h])+v,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=S[o].tToLength(m[h])+n,e=s.lengthToT(t);m[h]=e}C.push((0,r.h)(a[h],m[h]))}n+=S[o].calculateLength2D()}v+=i.calculateLength2D()}if(0===C.length)return 0;if(m&&(C=C.filter((t=>!(0,r.Y)(t.first,0,1)||!(0,r.Y)(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second))))),l)return C.length;const I=[],w=[];for(const t of C)I.push(t.first),w.push(t.second);return Dr(t,e,s,I,w,I.length,n,o,a,h,m,0,u)}function Kn(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Tn(t))return;const i=t.getSemiAxes(),n=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=r+Math.PI;n[0]=En(t,e),n[1]=En(t,s),n[2]=En(t,r),n[3]=En(t,o)}const o=new r.P;for(let i=0;i<4;i++){const r=n[i];e.containsExclusiveCoordinate(r)&&(t.queryCoord2D(r,o),s.mergeNe(o))}}function $n(t,e,s,n,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),Tn(t))return new Gr({start:a,end:h}).getClosestCoordinate(e,n);const m=dn(t,e);if(a=dn(t,a),h=dn(t,h),1===t.m_minorMajorRatio){if(m.isEqual(0,0))return s.vmin;const e=En(t,Math.atan2(m.y,m.x));return n||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.s)(c),_=m.x,d=m.y,p=(0,r.s)(u*d),f=u*c*d*2,x=[new r.I(p),new r.I(f),new r.I(g-(0,r.s)(l*_)-p),new r.I(-f),new r.I(-g)],P=(0,r.m)(r.I,4),y=It(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,i.g)(!n);let S=new Array(8);for(let e=0;e<y;++e){const s=P[e].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);S[2*e]=En(t,n),S[2*e+1]=En(t,r)}S=S.slice(0,2*y),(0,r.p)(S);for(let i=0,n=2*y;i<n;++i)if(S[i]>s.vmin&&S[i]<s.vmax){const s=r.P.sqrDistance(e,t.getCoord2D(S[i]));C>s&&(C=s,E=S[i])}return E}function tr(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 er(t,e,s,n){const o=t.getStartXY(),h=t.getEndXY(),m=o.equals(h),l=e.equals(s);if(!m&&!l){const i=new a.T;return i.initializeFromTwoPoints(o,h,e,s),Gn(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Dn(t,e,s,1);if(m&&l){const i=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),i)}if(!m){const i=.5*((0,r.ab)()-Math.abs(t.getSweepAngle())),n=(t.getSweepAngle()+i*(0,r.d)(t.getSweepAngle()))/t.getSweepAngle(),o=new r.P;t.queryCoord2D(n,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=pt(new _n(t,u),r.E.construct(0,.25),1,e);s>0&&((0,i.g)(1===s),c=e[0],g=1-e[0])}const _=t.getCoord2D(c),d=t.getCoord2D(g);(0,i.g)(!_.equals(d)),t.constructEllipticArcEndPointsCenter(_,d,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),er(t,e,s)}var sr=n.V;const ir=-1;class nr{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 rr{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!==ir;){for(;this.m_path!==ir;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!==ir)return this.m_vertex;if(this.m_bOneGeom)return ir;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===ir)break;this.m_bSkipMultiPoints&&!(0,i.h)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return ir}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==ir&&(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 ir}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==ir?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==ir&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):ir}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new rr({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class or{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class ar{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,s=this.m_indices.length;t<s;t++){if(t===this.m_selectionIndex)continue;const s=this.m_indices[t];null!==s&&s.size()>e&&s.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,1),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==ir?this.getPrevVertex(e):this.getLastVertex(t),r=n!==ir?this.getNextVertex(n):ir,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByVal(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==ir&&this.setPrevVertex(r,o),n!==ir&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===ir&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==ir||this.setFirstVertex(t,o)),h&&r===ir&&(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 n.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(i.G.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let e=0,n=s.getPathCount();e<n;e++){if(0===s.getPathSize(e))continue;const n=this.insertPath(t,ir);this.setClosedPath(n,s.isClosedPath(e));for(let t=s.getPathStart(e),r=s.getPathEnd(e);t<r;t++){const e=this.insertVertex_(n,ir,null,!1);if(i){const i=this.getVertexIndex(e);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{const e=new Mr;s.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}s.isStrongPathStart(e)&&this.setStrongPathStart(n,!0),s.isStrongPathEnd(e)&&this.setStrongPathEnd(n,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.G.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new o.J;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,l=0,u=-1,c=ir,g=!1,_=s.nextSegment();if(null!==_)for(;;_=s.nextSegment()){let r=null===_;const o=null!==_?s.getPathIndex():a,d=null!==_?s.getStartPointIndex():h;if(r||(a===o&&h+1===d?l++:r=!0),r){if(-1!==u){let t=-1,s=-1;if(l===m){this.setClosedPath(c,g);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-u),this.m_verticesMp.addPoints(e,u,n),s=i.getPathSize(a),t=n-1}else if(!g||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp.addPoints(e,u,h+2),s=h-u+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp?.addPoints(e,u,h+1),t=h,s=h-u+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=u;e<s;e++,r++){const e=this.insertVertex_(c,ir,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Mr;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===_)break;l=1,u=d,a!==o?(c=this.insertPath(t,ir),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),g=i.isClosedPath(o),a=o):c=this.insertPath(t,ir)}h=d}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const n=e.getImpl(),a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),h=o.J.constructEmpty();e.queryEnvelope(h),(0,i.g)(s.isIntersecting(h)&&!s.containsEnvelope(h));let m=o.J.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),l=o.J.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const u=n.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.b)(m,m=l))}else m.height()>l.width()&&(l=(0,r.b)(m,m=l));const c=[],g=n.queryLimitedSegmentIterator(m);let _=-1,d=-100,p=-1,f=0,x=-1,P=-1,y=ir,E=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let s=null===C;const h=null!==C?g.getPathIndex():_,m=null!==C?g.getStartPointIndex():d;if(s||(h===_?d+1===m?f++:s=!0:(s=_>=0,_<0&&(_=h,p=n.getSegmentCountPath(_),x=m,y=ir,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===ir&&(y=this.insertPath(t,ir),this.setClosedPath(y,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(y,ir,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,i.g)(1===c.length)}else if(m+1<n.getPathEnd(_)){const t=m+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m}else{const t=n.getPathStart(_),i=t!==P?1:0,r=m+1;h=r-s+i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+i),this.m_verticesMp.addPoints(e,s,r),o=m,i>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),y===ir&&(y=this.insertPath(t,ir),this.setClosedPath(y,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(y,ir,null,!1);if(a){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>o)this.setSegmentToIndex(s,null);else{const t=new Mr;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===c.length||c.at(-1).first+c.at(-1).second!==x+f){let t=x+f;t===e.getPathEnd(_)&&(t=e.getPathStart(_)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(y,ir,null,!1))}}c.length=0,E=!0,h!==_&&(_=h,p=n.getSegmentCountPath(_),y=ir,P=-1),x=m,f=1}if(!C)break;{const t=o.J.constructEmpty();C.queryLooseEnvelope(t),l.isIntersecting(t)?(E?c.push((0,r.h)(m,1)):c.at(-1).second++,E=!1):E=!0}d=m}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.G.enumPolygon,r=o.J.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,ir);this.insertVertex_(i,ir,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,ir);for(let t=0,i=e.getPointCount();t<i;t++)this.insertVertex_(s,ir,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let t=0,r=e.getPointCount();t<r;t++){const e=i.readPoint2D(2*t);s.contains(e)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let t=0,n=e.getPointCount();t<n;t++){const n=i.readPoint2D(2*t);s.contains(n)?(-1===r&&(r=t,o=t),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,ir);for(let t=0,n=e.getPointCount();t<n;t++){const e=i.readPoint2D(2*t);s.contains(e)&&this.insertVertex_(h,ir,null,!1)}}splitSegmentForward(t,e,s,n,r){const o=this.getNextVertex(t);o===ir&&(0,i.t)("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const u=this.getVertexIndex(m),c=this.getNextVertex(m),g=e.getResultSegment(s,t);let _=null;if(g.getGeometryType()!==i.G.enumLine&&(_=g.clone(),_.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),r)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),l){const i=e.getResultSegmentSegmentParentage(s,t),n=e.getResultSegmentStartPointIsBreak(s,t);this.setSegmentParentageAndBreak(m,i,n)}if(g.queryEnd(a),t<n-1){this.setSegmentToIndex(u,_);const i=this.insertVertex(h,c,a);this.setWeight(i,e.getResultSegmentEndPointWeight(s,t)),this.setRank(i,e.getResultSegmentEndPointRank(s,t)),this.select(i),m=i}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),r);const i=e.getResultSegmentEndPointIsBreak(s,t);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(u,_)}}}splitSegmentBackward(t,e,s,n,r){const o=this.getNextVertex(t);o===ir&&(0,i.t)("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const u=n-t-1,c=this.getVertexIndex(m),g=this.getNextVertex(m),_=e.getResultSegment(s,u);let d=null;if(_.getGeometryType()!==i.G.enumLine&&(d=_.clone(),d.reverse(),d.dropAllAttributes()),0===t&&(_.queryEnd(a),this.setSegmentToIndex(c,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,u),e.getResultSegmentEndPointWeight(s,u),r),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))),_.getGeometryType()===i.G.enumLine?this.setSegmentToIndex(c,null):this.setSegmentToIndex(c,d),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,u)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,u)),_.queryStart(a),t<n-1){const t=this.insertVertex(h,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(s,u)),this.setRank(t,e.getResultSegmentStartPointRank(s,u)),this.select(t),m=t,l&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,u),e.getResultSegmentStartPointWeight(s,u),r)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,n.Q)(0,-1):(0,n.Q)(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,n.Q)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=(0,r.b)(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,ir,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return ir}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,((t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s}))}sortVerticesSimpleByYHelper3D(t,e,s){(0,i.g)(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=n.b.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=ir,this.m_lastGeometry=ir,this.m_vertexIndexList=new n.S(5),this.m_pathIndexList=new n.S(8),this.m_geometryIndexList=new n.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new n.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.J(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=o.J.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let t=i.next();t!==ir;t=i.next()){if(n?s.merge(this.getXY(t)):s.mergeNe(this.getXY(t)),e){const e=this.getSegment(t);if(null!==e){const t=o.J.constructEmpty();e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}n=!1}return s}getEnvelope3D(t){return(0,i.g)(0),n.b.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,i.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if((0,i.h)(s))return this.addMultiPath(t,e);if(s===i.G.enumMultiPoint)return this.addMultiPoint(t,e);if(s===i.G.enumPoint)return this.addPoint_(t,e);if(s===i.G.enumEnvelope){const s=new on;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}(0,i.t)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());const s=e.getGeometryType();(0,i.h)(s)?this.appendMultiPath(t,e):s!==i.G.enumMultiPoint?(0,i.t)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);const s=this.queryVertexIterator();for(let t=s.next();t!==ir;t=s.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=ir,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==ir;)if(t!==i.G.enumUnknown&&this.getGeometryType(r)!==t)r=this.getNextGeometry(r);else{if(e===ir){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let t=this.getFirstPath(r);t!==ir;t=this.getNextPath(t))this.setPathGeometry(t,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==ir?this.setNextPath(t,i):this.setFirstPath(e,i),i!==ir&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,ir),this.setLastPath(r,ir);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==ir&&(this.setGeometryVertexCount(e,n),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let s=this.getFirstPath(t);s!==ir;s=this.getNextPath(s))this.setPathGeometry(s,e);for(let s=this.getFirstPath(e);s!==ir;s=this.getNextPath(s))this.setPathGeometry(s,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const l=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,l)}addPathFromMultiPath(t,e,s){const n=this.createGeometry(s?i.G.enumPolygon:i.G.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,ir);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,ir,null,!1);if(a){const s=this.getVertexIndex(e);if(1&r.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{const e=new Mr;r.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=function(t,e){let s=e,r=null;s||(r=(0,i.u)(t)?(0,n.W)():(0,n.x)(),s=r);let o=null;switch(t){case i.G.enumPoint:o=new n.P({vd:s});break;case i.G.enumLine:o=new Gr({vd:s});break;case i.G.enumBezier:o=new zs({vd:s});break;case i.G.enumEllipticArc:o=new rn({vd:s});break;case i.G.enumRationalBezier2:o=new Vt({vd:s});break;case i.G.enumBezier2:o=new qt({vd:s});break;case i.G.enumEnvelope:o=new n.E({vd:s});break;case i.G.enumMultiPoint:o=new d({vd:s});break;case i.G.enumPolyline:o=new zi({vd:s});break;case i.G.enumPolygon:o=new on({vd:s});break;case i.G.enumMultipatch:(0,i.b)("multipatch not impl");break;case i.G.enumGeometryCollection:o=new y({vd:s});break;default:(0,i.t)("Geometry.create")}return o}(e,this.m_verticesMp.getDescription()),r=this.getPointCount(t);if(0===r)return s;if((0,i.h)(e)){const e=s.getImpl(),i=this.getPathCount(t),o=(0,n.Q)(i+1),a=(0,n.R)(i+1,0),h=s.getDescription(),m=this.hasCurves();for(let s=0,m=h.getAttributeCount();s<m;s++){const m=h.getSemantics(s),l=sr.getComponentCount(m),u=(0,n.K)(m,r),c=this.m_vertices.getAttributeStreamRef(m);let g=0,_=0,d=0;for(let e=this.getFirstPath(t);e!==ir;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(_,t);const s=this.getPathSize(e);if(o.write(_++,d),d+=s,0===m){const t=c,s=u;let i;for(let n=this.getFirstVertex(e);g<d;n=this.getNextVertex(n),g++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*g,i)}}else for(let t=this.getFirstVertex(e);g<d;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(i,r)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),m){let s=0,i=0;for(let n=this.getFirstPath(t);n!==ir;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===i.G.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(r),e.resizeNoInit(r);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=sr.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(t),l=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<l;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(n,o)}e.notifyModifiedFlags(65535)}else(0,i.c)("getGeometry");return s}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==i.G.enumMultiPoint&&(0,i.t)("get_point_geometry_only");const s=this.getPointCount(t);if(s>1&&(0,i.t)("get_point_geometry_only"),0===s)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();const n=this.getFirstPath(t),r=this.getFirstVertex(n);this.queryPoint(r,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==ir;e=this.removePath(e));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==ir?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==ir?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=(0,n.x)());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new d({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===ir?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,n.Q)(0),t;this.m_geometryIndices.push((0,n.Q)(0));const t=this.m_geometryIndices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==ir;t=this.getNextGeometry(t))if(!(0,i.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,n,o){const a=t*t;let h=0;const m=this.hasCurves(),l=this.hasSegmentParentage();for(let t=o===ir?this.getFirstGeometry():o;t!==ir;t=o===ir?this.getNextGeometry(t):ir){const o=this.getGeometryType(t);if(!(0,i.h)(o))continue;if(s&&o!==i.G.enumPolygon)continue;const u=this.getGeometryType(t)===i.G.enumPolygon;let c=this.getGeometryModified(t);for(let s=this.getFirstPath(t);s!==ir;){let o=0;for(let e=this.getFirstVertex(s);o<Math.trunc(this.getPathSize(s)/2);){const u=this.getNextVertex(e);if(u===ir)break;const g=this.getXY(e),_=this.getXY(u);let d=r.P.sqrDistance(g,_),p=!0;do{if(d<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(d=e*e,d>a)break}}if(0===d?0===h&&(h=-1):h=1,u!==this.getLastVertex(s)){const s=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(u));if(this.transferAllDataToTheVertex(u,e),this.removeVertex(u,!1),n&&!c&&(this.setGeometryModified(t,!0),c=!0),l&&e!==u){this.setSegmentParentageBreakVertex(e,s);const t=this.getNextVertex(e);(0,i.g)(t!==ir),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),o++}let g=this.getFirstVertex(s);for(let e=this.isClosedPath(s)?g:this.getLastVertex(s);this.getPathSize(s)>0;){const i=this.getPrevVertex(e);if(i===ir)break;{const o=this.getXY(i),u=this.getXY(e);let _=r.P.sqrDistance(o,u),d=!0;do{if(_<=a){if(m){const t=this.getSegment(i);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}0===_?0===h&&(h=-1):h=1;const r=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(i));this.removeVertex(i,!0),n&&!c&&(this.setGeometryModified(t,!0),c=!0),l&&i!==e&&(r||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),g===i&&(g=this.getFirstVertex(s)),d=!1}}while(0);if(d&&(e=this.getPrevVertex(e),e===g))break}}const _=this.getPathSize(s);let d=e&&_<(u?3:2);d&&u&&2===_&&m&&(d=!this.pathHasCurves(s)),d?(s=this.removePath(s),0===h&&(h=-1),n&&!c&&(this.setGeometryModified(t,!0),c=!0)):s=this.getNextPath(s)}}return h}filterClosePoints3D(t,e,s,n,r,o){return(0,i.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==ir;e=this.getNextGeometry(e))if((0,i.h)(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==ir;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===ir)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return(0,i.g)(0),!1}transferAllDataToTheVertex(t,e){const s=this.getVertexIndex(t),i=this.getVertexIndex(e);if(this.m_weights){const t=this.getWeightWithIndex(s);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(s);this.setRankWithIndex(i,t)}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(i,t)}for(let s=0,i=this.m_indices.length;s<i;s++)if(s!==this.m_selectionIndex&&null!==this.m_indices[s]){const i=this.getUserIndex(t,s);-1!==i&&this.setUserIndex(e,s,i)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,n,r){let o=0;const a=this.getNextVertex(t);a===ir&&(0,i.t)("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),l=this.getSegmentFromIndex(h);let u=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&l&&(u=l.calculateLength2D());const _=this.getSegmentParentage(t),d=this.getHelperPoint();if(l){let t=0,i=0,r=ir;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=l.cut(t,s);if(null!==n&&(p>0&&e.setStartXY(n[p-1]),e.setEndXY(n[p]),e.normalizeAfterEndpointChange(),i=p),g){const t=u>0?l.calculateSubLengthFromStart(s)/u:0;this.m_vertices.interpolateTwoVertices(h,m,t,d)}d.setXY(e.getEndXY()),r=this.insertVertex(c,a,d),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==_&&this.setSegmentParentageAndBreak(r,_,!1),t=s}}if(r!==ir){const e=l.cut(t,1);null!==n&&(e.setStartXY(n[i]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(r);this.setSegmentToIndex(s,e)}}else{let t=0;for(let i=0;i<s;i++){const s=e[i];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(h,m,s,d);const t=this.insertVertex(c,a,d);o++,-1!==_&&this.setSegmentParentageAndBreak(t,_,!1)}t=s}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,e,s){this.getNextVertex(t)===ir&&(0,i.t)("");let n=t,r=!1;for(let t=0;t<e;++t){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(s);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==ir;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return(0,i.g)(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==ir){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByVal(s,e)}setPointOnlyEx(t,e,s,n){(0,i.g)(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==ir){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new r.P(e,s),t,!1),n.ensureXYMonotone()}const o=this.getPrevVertex(t);if(o!==ir){const t=this.getVertexIndex(o),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new r.P(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){(0,i.g)(0)}setXYZ(t,e,s){(0,i.g)(0)}setXYZCoords(t,e,s,n){(0,i.g)(0)}queryXYZ(t,e){(0,i.g)(0)}getXYZ(t){return(0,i.g)(0),n.v.getNAN()}getXYZWithIndex(t){return(0,i.g)(0),n.v.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,i.g)(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){(0,i.g)(0)}setAttributeInt(t,e,s,n){(0,i.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,i.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return(0,i.g)(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=(0,n.U)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=(0,n.U)(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,n.Q)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,1)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,n.Q)(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,n.U)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,n.U)(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 ar.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?ar.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,n.Q)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,1)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,n.Q)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];return s<i.size()?i.read(s):-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=(0,r.q)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let e=this.getFirstPath(t);e!==ir;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let r=0,o=this.getPathSize(e);r<o;r++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){(0,i.g)(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===ir)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new n.P({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return(0,i.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,i.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===ir)return!1;const s=this.getPathSize(t);let n=e;for(let t=0;t<s;t++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.G.enumLine)return!0}return!1}insertPath(t,e){let s=ir;e!==ir?(t!==this.getGeometryFromPath(e)&&(0,i.t)(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const n=this.newPath(t);return e!==ir&&this.setPrevPath(e,n),this.setNextPath(n,e),this.setPrevPath(n,s),s!==ir?this.setNextPath(s,n):this.setFirstPath(t,n),e===ir&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==ir?this.setNextPath(e,s):this.setFirstPath(i,s),s!==ir?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==ir){let s=e;for(let e=0,i=this.getPathSize(t);e<i;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,ir),this.setPrevVertex(s,ir);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){(0,i.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===ir)return 0;const s=this.getXY(e),n=new r.K(0),o=this.getPathSize(t);if(o>2){const t=s.clone(),i=t.x,a=t.y;let h=this.getNextVertex(e);const m=this.getXY(h);h=this.getNextVertex(h);const l=r.P.getNAN();for(let e=2;e<o;e++,h=this.getNextVertex(h))this.queryXY(h,l),n.pe((l.x-t.x)*(m.y-a)),t.setCoordsPoint2D(m),m.setCoordsPoint2D(l);n.pe((i-t.x)*(m.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.G.enumLine)continue;const s=2*e.calculateArea2DHelper();n.pe(s)}}this.setRingAreaValid(t,!0);const a=.5*n.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let e=this.getFirstPath(t);e!==ir;e=this.getNextPath(e)){const t=this.getPathIndex(e);t<n&&i.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===ir&&(0,i.t)(""),e===s)return;const n=this.getNextPath(s);let r=this.getPrevPath(s);const o=this.getGeometryFromPath(s);r===ir?this.setFirstPath(o,n):this.setNextPath(r,n),n===ir?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(s)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=e===ir?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,r),this.setNextPath(s,e),e===ir?this.setLastPath(t,s):this.setPrevPath(e,s),r===ir?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,ir,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==ir&&this.setNextVertex(i,n);const r=this.getPathSize(s);if(t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:ir),n!==ir&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:ir),this.hasCurves()&&i!==ir&&n!==ir){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(t,e){(0,i.g)(t!==e);const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==ir&&this.setNextVertex(n,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,ir),this.setNextVertex(r,ir);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:ir),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,ir,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,i.c)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==ir;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==ir;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=ir){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=ir){let s=ir,n=ir,r=ir,o=ir,a=0,h=!1;for(s=e!==ir?e:this.getFirstGeometry();s!==ir;s=this.getNextGeometry(s))if(!t||(0,i.h)(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==ir;n=this.getNextPath(n))if(r=this.getFirstVertex(n),o=r,a=0,r!==ir){h=!0;break}if(h||e!==ir)break}return h||(s=ir),rr.create_(this,s,n,r,o,a,t,!1,e!==ir)}queryVertexIteratorOnSelection(t=ir){return this.m_selection?rr.create_(this,t,ir,ir,ir,-1,!1,!0,t!==ir):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,i.g)(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=ir,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return(0,i.g)(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){return(0,i.g)(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===ir)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return(0,i.g)(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==ir?this.setNextPath(e,s):this.setFirstPath(i,s),s!==ir?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,ir),this.setLastVertex(t,ir),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,ir);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return(0,i.g)(0),0}findVertex3D(t,e,s){return(0,i.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);if(s!==ir&&this.setNextVertex(s,i),i!==ir&&this.setPrevVertex(i,s),this.hasCurves()&&s!==ir&&i!==ir){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,i.g)(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new nr(this))}sortVerticesSimpleByX(t,e,s){(0,i.g)(0)}sortVerticesSimpleByY3D(t,e,s){(0,i.g)(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==ir&&this.replaceCurveWithLine(s),this.getNextVertex(t)!==ir&&this.replaceCurveWithLine(t);const i=new r.P;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.n)()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,i.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.n)()>>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 or(e)}return new or(-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.n)()>>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!==ir&&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 hr(t){if(t.isEmpty())return new on({vd:t.getDescription()});const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new n.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new n.P,s=new zi({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const i=e.getAttributeStreamRef(0),o=new gr({stream:i,n:s});let a=1;const h=i.readPoint2D(0),m=new r.P;for(;a<s&&i.queryPoint2D(a<<1,m).equals(h);)a++;if(o.m_treeHull.addElement(0),a<s){o.m_treeHull.addBiggestElement(a);const t=new r.P;for(let s=a+1;s<e.getPointCount();s++){i.queryPoint2D(s<<1,t);const e=o.treeHull(t);-1!==e&&o.m_treeHull.setElement(e,s)}}const l=e.getDescription(),u=l.getAttributeCount()>1,c=o.m_treeHull.size();let g=null;if(c>=2){g=c>=3?new on({vd:l}):new zi({vd:l});const t=g.getImpl();t.reserve(o.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new r.P;for(let r=o.m_treeHull.getFirst();-1!==r;r=o.m_treeHull.getNext(r))if(u){const s=new n.P;e.getPointByVal(o.m_treeHull.getElement(r),s),t.insertPoint(0,-1,s)}else i.queryPoint2D(o.m_treeHull.getElement(r)<<1,s),t.insertPoint2D(0,-1,s)}else if(u){const t=new n.P({vd:l});e.getPointByVal(o.m_treeHull.getElement(o.m_treeHull.getFirst()),t),g=t}else{const t=i.readPoint2D(o.m_treeHull.getElement(o.m_treeHull.getFirst())<<1);g=new n.P(t)}return g}function mr(t,e,s){if(e<=262144)return function(t,e,s){const i=new n.A(0);for(let t=0;t<e;t++)i.add(t);const r={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};n.B.sortEx(i,0,e,r);let o=0;t:for(let n=0;n<e;++n){const e=i.read(n);for(;o>=2;){const r=s[o-2],a=s[o-1];if(t[a].equals(t[e])){i.write(n,-1);continue t}if(!(_r(t[r],t[a],t[e])>=0)){a===i.read(n-1)&&i.write(n-1,-1);break}o--}s[o++]=e,2===o&&t[e].equals(t[s[0]])&&(i.write(1,-1),o--)}const a=o+1;t:for(let n=e-2;n>=0;--n){const e=i.read(n);if(!(e<0)){for(;o>=a;){const i=s[o-2],n=s[o-1];if(t[n].equals(t[e]))continue t;if(!(dr(t[i],t[n],t[e])>=0))break;o--}if(0!==n){const i=s[o-1];s[o++]=e,t[e].equals(t[i])&&o--}}}return o>1&&t[s[0]].equals(t[s[o-1]])&&o--,o}(t,e,s);(0,i.g)(0);const r=new gr({points:t,n:e});let o=1;const a=t[0].clone();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],i=r.treeHull(e);-1!==i&&r.m_treeHull.setElement(i,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 lr(t,e,s){const i=t.getImpl(),n=i.getPathStart(e),o=i.getPathEnd(e),a=!i.isClosedPath(e)&&i.isClosedPathInXYPlane(e),h=i.getAttributeStreamRef(0),m=2*n;let l=2*o;if(a&&(l-=2),l-m<6)return!0;const u=h.readPoint2D(m),c=h.readPoint2D(m+2),g=h.readPoint2D(m+4);if(!pr(r.P.orientationRobust(c,g,u)))return!1;const _=c.clone(),d=new r.P;for(let t=m+6;t<l;t+=2){if(d.assign(c),c.assign(g),h.queryPoint2D(t,g),!pr(r.P.orientationRobust(c,g,u)))return!1;if(!pr(r.P.orientationRobust(_,g,u)))return!1;if(!pr(r.P.orientationRobust(c,g,d)))return!1}return!0}function ur(t,e,s,n,o){if(s.setNAN(),n.setCoords(1,0),o.setCoords(0,0),t.isEmpty())return;if(t.getGeometryType()===i.G.enumPoint)return void s.assign(t.getXY());const a=t,h=a.getPointCount();if(2===h){const t=a.getXY(0),e=a.getXY(1);s.assign(t.add(e).mul(.5));const i=e.sub(t);n=Pr(i),o.setCoords(.5*i.length(),0)}else{let t=Number.MAX_VALUE;const i=[0,1,0,0],m=new r.am(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);i[0]<h;++i[0],yr(m,0,h)){i[1]===i[0]&&(++i[1],yr(m,1,h));for(let t=1;;++t){for(;;){const e=Er(a.getXY(m.get(0,0)),a.getXY(m.get(0,1)),a.getXY(m.get(t,0)),a.getXY(m.get(t,1)),2^t);if(e>0)break;if(++i[t],yr(m,t,h),0===e)break}if(3===t)break;i[t+1]<i[t]&&(i[t+1]=i[t],m.set(t+1,0,m.get(t,0)),m.set(t+1,1,m.get(t,1)))}const l=a.getXY(m.get(0,0)).add(a.getXY(m.get(2,0))).mul(.5),u=Pr(a.getXY(m.get(0,1)).sub(a.getXY(m.get(0,0)))),c=new r.P;let g,_;if(c.x=Math.max(0,u.dotProduct(a.getXY(m.get(1,0)).sub(a.getXY(m.get(3,0))))),c.y=Math.max(0,u.crossProduct(a.getXY(m.get(0,0)).sub(a.getXY(m.get(2,0))))),e?(g=c.x*c.y,_=g<t):(g=c.y,_=g<t),_){t=g;const e=a.getXY(m.get(1,0)),i=a.getXY(m.get(3,0)),r=e.add(i).mul(.5).sub(l);s.assign(l.add(u.mul(u.dotProduct(r)))),n.assign(u),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,r.b)(o.x,o.x=o.y),n.leftPerpendicularThis())}n.y<0?n.negateThis():0===n.y&&(n.x=1)}ar.st_defaultRank=1;class cr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,i.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,i.g)(0),!1}get_vertex_handle_p(){return(0,i.g)(0),0}get_vertex_handle_q(){return(0,i.g)(0),0}get_current_support(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}intialize_(){return(0,i.g)(0),!1}increment_(){return(0,i.g)(0),!1}increment_q_(){return(0,i.g)(0),!1}increment_p_(){return(0,i.g)(0),!1}parallel_edge_with_q_support_(){return(0,i.g)(0),!1}parallel_edge_with_p_support_(){return(0,i.g)(0),!1}done_(){return(0,i.g)(0),!1}}class gr{nullGetXY(t){return(0,i.c)("m_getXY is null"),{}}nullDeleteNode(t){(0,i.c)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new n.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=ir,void(this.m_pathHandle=ir)):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=ir,void(this.m_pathHandle=ir)):void(0,i.r)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new ar,this.m_geometryHandle=this.m_shape.createGeometry(i.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,ir),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,i.g)(0),new 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,i.g)(0)}addGeometry(t){if(t.isEmpty())return;const e=t.getGeometryType();if(e===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else(0,i.i)(e)?this.addMultiVertexGeometry(t):(0,i.f)(e)?this.addSegment(t):e===i.G.enumEnvelope?this.addEnvelope(t):e===i.G.enumPoint?this.addPoint(t):(0,i.t)("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new n.P,e=this.m_treeHull.getFirst(),s=new on({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return(0,i.g)(0),new cr(this)}getXY(t){return(0,i.g)(0),new r.P}getXYWithIndex(t){return(0,i.g)(0),new r.P}getFirst(){return(0,i.g)(0),0}getLast(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}getVertexIndex(t){return(0,i.g)(0),0}getPointCount(){return(0,i.g)(0),0}addMultiVertexGeometry(t){const e=new n.P,s=t.getImpl(),i=new r.P;for(let n=0;n<t.getPointCount();n++){s.queryXY(n,i);const r=this.addPoint2D(i);if(-1!==r){t.getPointByVal(n,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}addEnvelope(t){const e=new n.P;for(let s=0;s<4;s++){const i=new r.P;t.queryCorner(s,i);const n=this.addPoint2D(i);if(-1!==n){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}addSegment(t){const e=new n.P,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const 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)}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),n=this.m_treeHull.getElement(s),o=this.m_treeHull.getElement(i),a=this.m_getXY(n),h=this.m_getXY(o),m=r.P.orientationRobust(h,t,a);if(pr(m)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(fr(m)){let n=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(n);const e=this.m_getXY(l);fr(r.P.orientationRobust(e,t,a))?(h=n,n=this.m_treeHull.getLeft(n)):(o=n,n=this.m_treeHull.getRight(n))}n=h,m=o,l=this.m_treeHull.getElement(n),u=this.m_treeHull.getElement(m);const c=this.m_getXY(l),g=this.m_getXY(u);if(m!==s&&!pr(r.P.orientationRobust(g,t,c)))break;e=this.m_treeHull.addElementAtPosition(m,n,-2,!0,!1),this.treeHullWalkForward(t,n,i),this.treeHullWalkBackward(t,m,s);break}{const n=xr(t,h,a);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getNext(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(pr(r.P.orientationRobust(s,t,a)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getNext(i),this.m_deleteNode(h)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getPrev(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(pr(r.P.orientationRobust(a,t,s)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getPrev(i),this.m_deleteNode(h)}return i}}function _r(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function dr(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function pr(t){return t<0}function fr(t){return t>0}function xr(t,e,s){let i=-1;i=e.y===s.y?0:e.x===s.x?1:Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1;let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Pr(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function yr(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Er(t,e,s,n,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,i.t)("")}return r.P.orientationRobustEx(t,e,s,n)}function Cr(t,e,s,i,n){return Sr(t,!1,e,s,i,n)}function Sr(t,e,s,n,r,o){const a=s.getGeometryType(),h=n.getGeometryType(),m=Math.max(r,B(s,n));if(a===i.G.enumLine&&h===i.G.enumLine)return st(s,n,m,o);let l=s,u=n,c=s.getStartXY(),g=s.getEndXY();if(c.compare(g)>0&&(l=s.clone().reverse()),c=n.getStartXY(),g=n.getEndXY(),c.compare(g)>0&&(u=n.clone().reverse()),e){if(s.equals(n))return 2;if(function(t,e,s){return(0,i.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&T(t,e,0,0,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&T(t,e,1,1,s,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&T(t,e,0,1,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&T(t,e,1,0,s,2,[0,0],[0,0]))}(s,n,m))return 4}switch(a){case i.G.enumLine:switch(h){case i.G.enumEllipticArc:return Jn(t,u,l,m,o);case i.G.enumBezier:return fi(t,u,l,m,o);case i.G.enumRationalBezier2:return Ue(t,u,l,m,o);case i.G.enumBezier2:return Fs(t,u,l,m,o);default:(0,i.c)("")}break;case i.G.enumEllipticArc:switch(h){case i.G.enumLine:return Jn(t,l,u,m,o);case i.G.enumEllipticArc:return function(t,e,s,i,n){if(n){if(0!==vr(e,s))return 2}else if(b(e,s))return 1;return 0!==Qn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumBezier:return xi(t,u,l,m,o);case i.G.enumRationalBezier2:return Oe(t,u,l,m,o);case i.G.enumBezier2:return Vs(t,u,l,m,o);default:(0,i.c)("")}break;case i.G.enumBezier:switch(h){case i.G.enumLine:return fi(t,l,u,m,o);case i.G.enumEllipticArc:return xi(t,l,u,m,o);case i.G.enumBezier:return function(t,e,s,i,n){if(n){if(0!==vr(e,s))return 2}else if(b(e,s))return 1;return 0!==Si(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumRationalBezier2:return Pi(t,l,u,m,o);case i.G.enumBezier2:return yi(t,l,u,m,o);default:(0,i.c)("")}break;case i.G.enumRationalBezier2:switch(h){case i.G.enumLine:return Ue(t,l,u,m,o);case i.G.enumEllipticArc:return Oe(t,l,u,m,o);case i.G.enumBezier:return Pi(t,u,l,m,o);case i.G.enumRationalBezier2:return function(t,e,s,i,n){if(n){const i=vr(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(b(e,s))return 1;return 0!==Ze(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumBezier2:return We(t,l,u,m,o);default:(0,i.c)("")}break;case i.G.enumBezier2:switch(h){case i.G.enumLine:return Fs(t,l,u,m,o);case i.G.enumEllipticArc:return Vs(t,l,u,m,o);case i.G.enumBezier:return yi(t,u,l,m,o);case i.G.enumRationalBezier2:return We(t,u,l,m,o);case i.G.enumBezier2:return function(t,e,s,i,n){if(n){if(0!==vr(e,s))return 2}else if(b(e,s))return 1;return 0!==Rs(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}(t,l,u,m,o);default:(0,i.c)("")}break;default:(0,i.c)("")}}function vr(t,e,s=!0){if(!s&&!br(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===i.G.enumEllipticArc)return tr(t,e,!1)?s:0;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===i.G.enumEllipticArc)return tr(t,e,!0)?s:-1;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function br(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function Ir(t,e,s,n,r,o,a){!r&&o&&(0,i.t)("");const h=e.getGeometryType(),m=s.getGeometryType(),l=Math.max(a,B(e,s));if(n&&(n.length=0),r&&(r.length=0),o&&(o.length=0),h===i.G.enumLine&&m===i.G.enumLine)return it(e,s,n,r,o,l,!1,!1);let u=e,c=s,g=e.getStartXY(),_=e.getEndXY(),d=!1,p=!1;g.compare(_)>0&&(u=e.clone(!0).reverse(),d=!0),g=s.getStartXY(),_=s.getEndXY(),g.compare(_)>0&&(c=s.clone(!0).reverse(),p=!0);let f=0;switch(h){case i.G.enumLine:switch(m){case i.G.enumEllipticArc:f=Zn(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier:f=Ei(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=je(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier2:f=Ys(t,c,u,n,o,r,l,!1,0,!0);break;default:(0,i.c)("")}break;case i.G.enumEllipticArc:switch(m){case i.G.enumLine:f=Zn(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=Qn(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumBezier:f=Ci(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Je(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier2:f=Xs(t,c,u,n,o,r,l,!1,0,!0);break;default:(0,i.c)("")}break;case i.G.enumRationalBezier2:switch(m){case i.G.enumLine:f=je(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=Je(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=vi(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Ze(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumBezier2:f=Qe(t,u,c,n,r,o,l,!1,!1,!1);break;default:(0,i.c)("")}break;case i.G.enumBezier2:switch(m){case i.G.enumLine:f=Ys(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=Xs(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=bi(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Qe(t,c,u,n,o,r,l,!1,!1,!0);break;case i.G.enumBezier2:f=Rs(t,u,c,n,r,o,l,!1,!1,!1);break;default:(0,i.c)("")}break;case i.G.enumBezier:switch(m){case i.G.enumLine:f=Ei(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=Ci(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=Si(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumRationalBezier2:f=vi(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier2:f=bi(t,u,c,n,r,o,l,!1,0,!1);break;default:(0,i.c)("")}break;default:(0,i.c)("")}if(d){if(r){for(let t=0;t<f;t++)r[t]=1-r[t];r.reverse()}n&&n.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function wr(t,e,s){return e===s?0:(e>s&&(s=(0,r.b)(e,e=s)),t.cut(e,s,!0).calculateUpperLength2D())}function Dr(t,e,s,i,n,o,a,h,m,l,u,c,g){if(!o)return 0;const _=(t,e)=>{for(let s=0;s<o;++s){let i=e[s];if((0,r.Y)(i,0,1)){i=(0,r.aq)(i);continue}const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&wr(t,0,i)<=L(t)&&(e[s]=0):n.equals(t.getEndXY())&&wr(t,i,1)<=L(t)&&(e[s]=1)}};_(e,i),_(s,n),function(t,e,s,i,n){const o=[],a=[],h=[];for(let m=0,l=n;m<l;m++)o.push(t.calculateSubLengthFromStart(s[m])),a.push(e.calculateSubLengthFromStart(i[m])),(0,r.Y)(s[m],0,1)&&(0,r.Y)(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&h.push(m);if(0===h.length||h.length===n)return;h.sort(((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0));let m=-1;for(const l of h){if(m>=0&&s[l]===s[m]&&s[l]===s[m]){m=l;continue}m=l;const h=[];h.length=n;for(let t=0;t<h.length;++t)h[t]=t;h.sort(((t,e)=>{const s=o[l],i=a[l],n=o[t]-s,r=a[t]-i,h=n*n+r*r,m=o[e]-s,u=a[e]-i,c=m*m+u*u;return h<c?-1:h>c?1:0}));for(let o=0;o<n;o++){const n=h[o];if(n===l||s[n]===s[l]&&i[n]===i[l]||(0,r.Y)(s[n],0,1)&&(0,r.Y)(i[n],0,1))continue;const a=(s,i,n,o)=>{const a=new C,h=new r.I;h.setWithEps(1);const m=new r.I;m.set(i,h.eps()),t.queryCoord2DE(m,a);const l=new C;t.queryCoord2DE(new r.I(s),l);let u=!1;return a.eq(l)&&(m.set(o,h.eps()),e.queryCoord2DE(m,a),e.queryCoord2DE(new r.I(n),l),u=a.eq(l)),!u},m=r.P.getNAN();t.queryCoord2D(s[n],m);const u=r.P.getNAN();if(e.queryCoord2D(i[n],u),0===r.P.distance(m,u)&&a(s[l],s[n],i[l],i[n]))break;const c=new r.E(i[n],i[l]);c.normalizeNoNAN();const g=new r.E(s[n],s[l]);g.normalizeNoNAN();let _=-1,d=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,f=s[n];m.assign(t.getCoord2D(f));for(let o=0;o<5;o++){const o=e.getClosestCoordinateOnInterval(m,c,-1);u.assign(e.getCoord2D(o));const h=r.P.distance(m,u);if(f=t.getClosestCoordinateOnInterval(u,g,-1),f===s[l]&&o===i[l]){_=1;break}m.assign(t.getCoord2D(f));const x=r.P.distance(u,m);if(!(x<p&&h<d)){_=0;break}if(0===x&&0===h){a(s[l],s[n],i[l],i[n])?(s[n]=f,i[n]=o,_=0):_=1;break}p=x,d=h}if(-1===_&&(_=(0,r.Y)(s[n],0,1)||(0,r.Y)(i[n],0,1)?0:1),1!==_)break;s[n]=s[l],i[n]=i[l]}}}(e,s,i,n,o);const d=[];for(let t=0,e=o;t<e;t++)d.push(t);const p=(t,e)=>g?(0,r.ar)(n[t],i[t],n[e],i[e]):(0,r.ar)(i[t],n[t],i[e],n[e]);if(d.length>1){d.sort(p);const t=Math.max(L(e),L(s));let o=0;for(let a=1,h=d.length;a<h;a++){const h=i[d[o]],m=i[d[a]],l=n[d[o]],u=n[d[a]];if(h!==m||l!==u)if(!(wr(e,h,m)<=t&&wr(s,l,u)<=t)||(0,r.Y)(h,0,1)&&(0,r.Y)(l,0,1)||(0,r.Y)(m,0,1)&&(0,r.Y)(u,0,1))o++,d[o]=d[a];else{const t=r.P.distance(e.getCoord2D(h),s.getCoord2D(l)),i=r.P.distance(e.getCoord2D(m),s.getCoord2D(u));if(t<=i)continue;if(i<t){d[o]=d[a];continue}}}if(d.length=o+1,1===d.length&&0!==d[0]&&(i[0]=i[d[0]],n[0]=n[d[0]],d[0]=0),d.length>2){const t=r.E.constructEmpty(),o=r.E.constructEmpty();t.setCoords(i[d[0]],i[d.at(-1)]),o.setCoords(n[d[0]],n[d.at(-1)]);let a=!0;for(let e=1,s=d.length-1;e<s;e++)if(!t.containsCoordinate(i[d[e]])||!o.containsCoordinate(n[d[e]])){a=!1;break}if(a){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let h=(0,r.w)(t.vmin,t.vmax,i[n]);const m=e.getCoord2D(h);if(!s.isCloserThanDistance(m,o,l)){a=!1;break}h=(0,r.w)(o.vmin,o.vmax,i[n]);const u=s.getCoord2D(h);if(!e.isCloserThanDistance(u,t,l)){a=!1;break}}}a&&(d[1]=d.at(-1),d.length=2)}}if(1===d.length&&t){const t=0,r=0;T(e,s,i[0],n[0],l,1,[t],[r])&&(d.push(1),i[1]=t,n[1]=r,d.sort(p))}if(u&&1===d.length){let t=!0;for(let o=0,a=d.length;o<a;o++)if(!(0,r.Y)(i[d[o]],0,1)||!(0,r.Y)(n[d[o]],0,1)||0!==r.P.distance(e.getCoord2D(i[d[o]]),s.getCoord2D(n[d[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,s=d.length;t<s;t++){if(h&&h.push(i[d[t]]),m&&m.push(n[d[t]]),a){const s=r.P.getNAN();e.queryCoord2D(i[d[t]],s),a.push(s)}f++}return f}function Tr(t,e,s,i,n,o,a,h,m){if((0,r.Y)(s,0,1)&&(0,r.Y)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const l=1e-12,u=new C,c=Number.EPSILON;if(t.queryDerivative(new r.I(s,c),u),u.isTrueZero()){const e=1===s?-1e-12:l;t.queryDerivative(new r.I(s,c).add(e),u)}1===s&&u.negateThis();const g=new C;if(e.queryDerivative(new r.I(i,c),g),g.isTrueZero()){const t=1===s?-1e-12:l;e.queryDerivative(new r.I(i,c).add(t),g)}1===i&&g.negateThis(),u.isZero()||u.normalize(),g.isZero()||g.normalize();const _=u.dotProduct(g),d=u.crossProduct(g);d.scaleError(3);const p=()=>{if(m)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(_.ge(r.F)&&(d.isZero()||Math.abs(d.value())<p()))return D(t,e,s,i,n,o,a,h)}return 0}function Nr(t,e,s,n,o){let a=-1,h=-1,m=-1,l=-1;{const i=[0,e],r=[e,0],o=[0,n],u=[n,0];for(let e=0;e<2&&-1===a;++e)for(let n=0;n<2;++n)if(t[i[e]].equals(s[o[n]])){a=i[e],h=r[e],m=o[n],l=u[n];break}}if(-1===a){const i=new p;i.setFromPoints(t,e+1);const r=new p;return r.setFromPoints(s,n+1),r.inflate(o),i.isIntersectingW(r)?-1:0}{const u=new Array(e+1),c=mr(t,e+1,u);(0,i.g)(c>1);let g=0,_=0;for(let t=0;t<c;++t)a===u[t]&&(_=t,g++),h===u[t]&&g++;if(2!==g)return-1;const d=new Array(n+1),p=mr(s,n+1,d);(0,i.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===d[t]&&(f=t,g++),l===d[t]&&g++;if(2!==g)return-1;const x=t[u[(_+c-1)%c]],P=t[u[(_+1)%c]],y=s[d[(f+p-1)%p]],E=s[d[(f+1)%p]],C=t[a],S=[x,P,y,E],v=[0,1,2,3];v.sort(((t,e)=>r.P.compareVectorsOrigin(C,S[t],S[e])));let b=v[0];for(let t=1;t<4;t++){if(v[t]!==(b+1)%4)return-1;b=v[t]}{const t=x.sub(C),e=E.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}return 1}}var Ar=n.V;class Gr extends j{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,i.g)(0),0}calculateUpperLength3D(){return(0,i.g)(0),0}changeEndPoints3D(t,e){(0,i.g)(0)}getClosestCoordinate3D(t,e,s){return(0,i.g)(0),0}getBoundary(){return Wi(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Q(this,t):K(this,t);const i=Ar.getInterpolation(e),n=this.getStartAttributeAsDbl(e,s),o=this.getEndAttributeAsDbl(e,s);return(0,r.W)(i,n,o,t,Ar.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,i.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Gr.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.J.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Ar.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,X(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,X(this,1,1,0))):(0,i.b)("env type not impl")}applyTransformation(t){(0,i.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 Gr({vd:this.m_description})}calculateLength2D(){return Math.sqrt(ht(this))}calculateLength3D(t){return(0,i.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryCoord2D(t,e){return J(this,t,e)}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return function(t,e){const s=t.getStartZ(),i=t.getEndZ();return(0,r.w)(s,i,e)}(this,t)}queryCoord2DE(t,e){$(this,t,e)}getCoordX(t){return Q(this,t)}getCoordY(t){return K(this,t)}cut(t,e,s){const i=new Mr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const o=r.P.getNAN();if(J(this,t,o),n.setStartXYCoords(o.x,o.y),J(this,e,o),n.setEndXYCoords(o.x,o.y),!i)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=Ar.getComponentCount(i);for(let s=0;s<r;s++){const r=this.getAttributeAsDbl(t,i,s);n.setStartAttribute(i,s,r);const o=this.getAttributeAsDbl(e,i,s);n.setEndAttribute(i,s,o)}}}queryDerivative(t,e){!function(t,e,s){const i=C.constructPoint2D(t.getStartXY()),n=C.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}(this,0,e)}getClosestCoordinate(t,e){return r.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new r.P;this.queryCoord2D(e.vmin,i);const n=new r.P;this.queryCoord2D(e.vmax,n);const o=r.P.getClosestCoordinate(i,n,t,!1);return O.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=Q(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new Gr;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 nt(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,i.t)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=Q(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=K(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=(0,r.c)(t.vmin,0,1);const i=new r.P;return this.queryCoord2D(s,i),e.setCoords({pt:i}),s=(0,r.c)(t.vmax,0,1),this.queryCoord2D(s,i),void e.mergeNe(i)}(0,i.b)("3d dst not impl")}orientBottomUp(){et(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return function(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(t,e){tt(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,i.g)(0),0}readFromBufferStream(t,e){(0,i.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){tt(this,t,e)}static isIntersectingLineLine(t,e,s,i){return st(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return st(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&(0,i.s)("");const n=nt(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Cr(!1,this,t,e,s)}}Gr.type=i.G.enumLine;class Mr{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new Gr,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,i.c)("bad constructor params"))}assignCopy(t){return t instanceof Mr?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Mr){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,i.c)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,i.g)(0)}createImpl(t){switch(t){case i.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Gr,this.m_mask|=1,this.m_active=1);break;case i.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new rn,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.G.enumBezier:4&this.m_mask||(this.m_curves=new zs,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.G.enumBezier2:8&this.m_mask||(this.m_curves=new qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Vt,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,i.t)("")}}create(t){t===i.G.enumLine?this.createLine():t===i.G.enumEllipticArc?this.createEllipticArc():t===i.G.enumBezier?this.createCubicBezier():t===i.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.G.enumBezier2?this.createQuadraticBezier():(0,i.t)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,i.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(i.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,i.c)("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,i.c)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Mr?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,i.b)("seg comparison not yet impl"),!1)}}}}]);
|