@arcgis/core 5.2.0-next.136 → 5.2.0-next.138
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/analysis/LineOfSightAnalysisObserver.d.ts +12 -0
- package/analysis/LineOfSightAnalysisObserver.js +1 -1
- package/analysis/LineOfSightAnalysisTarget.d.ts +12 -0
- package/analysis/LineOfSightAnalysisTarget.js +1 -1
- package/arcade/featureset/sources/FeatureLayerParquet.js +1 -1
- package/arcgisGlobal.d.ts +4 -0
- package/assets/components/assets/icon/blockHeightMedium16.json +1 -0
- package/assets/components/assets/icon/blockHeightMedium24.json +1 -0
- package/assets/components/assets/icon/blockHeightMedium32.json +1 -0
- package/assets/components/assets/icon/blockHeightShort16.json +1 -0
- package/assets/components/assets/icon/blockHeightShort24.json +1 -0
- package/assets/components/assets/icon/blockHeightShort32.json +1 -0
- package/assets/components/assets/icon/blockHeightTall16.json +1 -0
- package/assets/components/assets/icon/blockHeightTall24.json +1 -0
- package/assets/components/assets/icon/blockHeightTall32.json +1 -0
- package/assets/components/assets/icon/cursorCircle16.json +1 -0
- package/assets/components/assets/icon/cursorCircle24.json +1 -0
- package/assets/components/assets/icon/cursorCircle32.json +1 -0
- package/assets/components/assets/icon/dictionary16.json +1 -0
- package/assets/components/assets/icon/dictionary24.json +1 -0
- package/assets/components/assets/icon/dictionary32.json +1 -0
- package/assets/components/assets/icon/jobDependency16.json +1 -0
- package/assets/components/assets/icon/jobDependency24.json +1 -0
- package/assets/components/assets/icon/jobDependency32.json +1 -0
- package/assets/components/assets/icon/referenceChip16.json +1 -0
- package/assets/components/assets/icon/referenceChip24.json +1 -0
- package/assets/components/assets/icon/referenceChip32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4e6f95d8c624d513849a.js → 05963f57cbe5a5249496.js} +1 -1
- package/assets/esri/core/workers/chunks/{0b8681ca4a83e97f1f71.js → 067de1910190da228291.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c0fd1c6cda44e9f40ab.js → 070684943698fa43c2b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc1cb4b9a02e6c78deb7.js → 076e8d2e08ff2a013736.js} +1 -1
- package/assets/esri/core/workers/chunks/{c10e040368065411506a.js → 10445313d0d57b34511b.js} +1 -1
- package/assets/esri/core/workers/chunks/{d537c59b46cdaaf66034.js → 1188d0a136fffc009643.js} +1 -1
- package/assets/esri/core/workers/chunks/{20af3f085f60c32c6c53.js → 178083d8ed7707b45ca2.js} +1 -1
- package/assets/esri/core/workers/chunks/{f5efe3e800c6e23efcf3.js → 1819c45655c836b9a8d7.js} +1 -1
- package/assets/esri/core/workers/chunks/1b946714ca4a1a7359d4.js +2 -0
- package/assets/esri/core/workers/chunks/{d8d8b38ac8a91d9e45fc.js → 1cc744ab5eee5ee3bed8.js} +1 -1
- package/assets/esri/core/workers/chunks/{05e39b4de7f62c5b22cc.js → 20f75cc777af13fa249b.js} +1 -1
- package/assets/esri/core/workers/chunks/2a1ec30f9ad305763f81.js +2 -0
- package/assets/esri/core/workers/chunks/34570e6bbf559f18c1a5.js +1 -0
- package/assets/esri/core/workers/chunks/{60f6d5da9480dd36e877.js → 3dddae78286d05eb10fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{9efd30bbd02ec0d1031b.js → 3ec3589f6e74d7cb87cf.js} +1 -1
- package/assets/esri/core/workers/chunks/{0bec054fca104f3bf141.js → 3f776d9fd2ab68b21fca.js} +1 -1
- package/assets/esri/core/workers/chunks/402a82c77420254831bc.js +1 -0
- package/assets/esri/core/workers/chunks/{e2ebf0ea3af2e6907987.js → 406f24ec13eb30d43405.js} +1 -1
- package/assets/esri/core/workers/chunks/43fc42405167a5537039.js +1 -0
- package/assets/esri/core/workers/chunks/{ddedc414bb478b376221.js → 46b2d4addfc73f9183a4.js} +1 -1
- package/assets/esri/core/workers/chunks/498d6dfd3bb0d3490548.js +1 -0
- package/assets/esri/core/workers/chunks/{36ef86701883a20dd6f6.js → 4a640548032355e57acd.js} +1 -1
- package/assets/esri/core/workers/chunks/5566f14afb63065e438f.js +1 -0
- package/assets/esri/core/workers/chunks/{c3b96d1d43afccd23e45.js → 590e6c70206122e4cc3c.js} +2 -2
- package/assets/esri/core/workers/chunks/{54860dd53a46cf4c47f3.js → 59295b99bdff4045a0e7.js} +1 -1
- package/assets/esri/core/workers/chunks/5aeb5e18514644fe2cf9.js +1 -0
- package/assets/esri/core/workers/chunks/{5da86409d70098fc6a10.js → 5b3cfe95314a75a735c1.js} +1 -1
- package/assets/esri/core/workers/chunks/{a54678bfa0f1807b61cd.js → 5c855af73ee3c3e764fb.js} +1 -1
- package/assets/esri/core/workers/chunks/{06da3409992bb1fa85b0.js → 5e90c1b49f2b7e21d05a.js} +39 -31
- package/assets/esri/core/workers/chunks/5fd099ca1024707387b2.js +1 -0
- package/assets/esri/core/workers/chunks/{30f808cac8a34f95ea6e.js → 6079d27f4ab319fb8f0c.js} +1 -1
- package/assets/esri/core/workers/chunks/66c2a28a851130b87c04.js +1 -0
- package/assets/esri/core/workers/chunks/{dac90b3631f7f7158f68.js → 67f15538c51838201fc7.js} +1 -1
- package/assets/esri/core/workers/chunks/{cfaba0470619786e1ef8.js → 68d8ae42ab71d01a70a5.js} +2 -2
- package/assets/esri/core/workers/chunks/6aebf7cfd294e88bf926.js +1 -0
- package/assets/esri/core/workers/chunks/{864e7030c4ddbfcf0114.js → 6ccf9535013fe672c93b.js} +1 -1
- package/assets/esri/core/workers/chunks/{ba7f0cf7e495d3ec2d55.js → 6e62581d933e7298d1f6.js} +1 -1
- package/assets/esri/core/workers/chunks/{83b5dd4029e00abd80bf.js → 700b1d5bc67b7e1b3ff3.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9fea72cc222a30ef2f9.js → 72399062767abdfb0bee.js} +1 -1
- package/assets/esri/core/workers/chunks/{2a7fbfd77002a24bf737.js → 747461bb6a1bc2f0a64d.js} +1 -1
- package/assets/esri/core/workers/chunks/{c333f6ed42985bb2b11f.js → 7851aef196eea5d6c94e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f0b6bd6fab5320c3082f.js → 7a05b18f655c1167ce0a.js} +1 -1
- package/assets/esri/core/workers/chunks/{04296b75d0f81fbd1bb5.js → 864194927d05ebc4cc31.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c4a13a9f0b305394a26.js → 876f7633c15f1e31078d.js} +1 -1
- package/assets/esri/core/workers/chunks/{62298dba3f6cbdc3f4ae.js → 879b2f0ff1977bca9376.js} +1 -1
- package/assets/esri/core/workers/chunks/{b547b3bce729c9dac90d.js → 898359be6996fd9763b8.js} +1 -1
- package/assets/esri/core/workers/chunks/8cb716f110d164030309.js +1 -0
- package/assets/esri/core/workers/chunks/8dc1c3042267618fd710.js +2 -0
- package/assets/esri/core/workers/chunks/{625f02db93d7fbf175ca.js → 9001e9a1e81bce175ddd.js} +1 -1
- package/assets/esri/core/workers/chunks/{9ffa6c8d93d3443834c6.js → 912080c90b5cc2e817cf.js} +1 -1
- package/assets/esri/core/workers/chunks/96c50a0dda0f1503ef92.js +2 -0
- package/assets/esri/core/workers/chunks/{13e4379441499599c3b5.js → 9cbde13e536676767900.js} +1 -1
- package/assets/esri/core/workers/chunks/{408db4f32850b77264ae.js → 9cd3fcb5fca6f9dbbcd8.js} +1 -1
- package/assets/esri/core/workers/chunks/a054da6cbd8ee4774a57.js +1 -0
- package/assets/esri/core/workers/chunks/a05790444115e4cf1bcc.js +1 -0
- package/assets/esri/core/workers/chunks/{d1f2685782b423ef87a6.js → a556dd4e9e6d35e33a2c.js} +1 -1
- package/assets/esri/core/workers/chunks/{00d576d355599c88931e.js → bc38def1983089514e4b.js} +1 -1
- package/assets/esri/core/workers/chunks/{0725e515f3004bdd5c56.js → ca2adcbcf44454484fd5.js} +1 -1
- package/assets/esri/core/workers/chunks/{f3507b9e831ffd7a6bf8.js → cca8bd07bcd1d267a2e8.js} +1 -1
- package/assets/esri/core/workers/chunks/cfae60b9d2f2939e9c16.js +1 -0
- package/assets/esri/core/workers/chunks/{1d6b2a64f4e40e5cc13d.js → d201fbf3ceff946d2bd6.js} +1 -1
- package/assets/esri/core/workers/chunks/{4439078780d9ba49fd26.js → d51bb11baadc741c46bc.js} +1 -1
- package/assets/esri/core/workers/chunks/db1ab9b9c8bf5c7635d3.js +1 -0
- package/assets/esri/core/workers/chunks/de02a6a1f4810f99e9bb.js +1 -0
- package/assets/esri/core/workers/chunks/e630f3c56c077cb2bd8e.js +1 -0
- package/assets/esri/core/workers/chunks/e81173724e8de8c1e65b.js +1 -0
- package/assets/esri/core/workers/chunks/{2025288bed125594ceda.js → f6e62d2d279a328cbed7.js} +1 -1
- package/assets/esri/core/workers/chunks/{47c19778fcee7154ca38.js → f8bc474434fd365ab174.js} +1 -1
- package/assets/esri/core/workers/chunks/{9a20dc26cb9c7b2087cf.js → f95a1f878c9c1146180e.js} +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ar.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bg.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ca.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.cs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.da.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.el.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.en.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hu.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ja.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ko.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.nl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.no.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ru.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.th.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.tr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.vi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-TW.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ar.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.bg.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ca.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.cs.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.da.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.el.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.fr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.hu.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ja.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ko.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.nl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.no.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.pl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.ru.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.sk.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.sr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.sv.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.th.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.tr.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.vi.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/widgets/FeatureForm/t9n/messages.zh-TW.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ar.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.bg.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.bs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ca.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.cs.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.da.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.de.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.el.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.en.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.es.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.et.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.fi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.fr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.he.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.hr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.hu.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.id.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.it.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ja.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ko.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.lt.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.lv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.nl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.no.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pt-BR.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pt-PT.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ro.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ru.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sl.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sv.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.th.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.tr.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.uk.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.vi.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-CN.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-HK.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-TW.json +1 -1
- package/chunks/Bufferer-CclWhXVb.js +1 -1
- package/chunks/Component.glsl.js +3 -3
- package/chunks/DefaultMaterial.glsl.js +2 -2
- package/chunks/Distance2DCalculator-DjIp2uQi.js +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/Envelope2D.js +1 -1
- package/chunks/FocusArea.glsl.js +8 -10
- package/chunks/GaussianSplat.glsl.js +2 -2
- package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
- package/chunks/GeodeticUtils.js +1 -1
- package/chunks/Geometry.js +1 -1
- package/chunks/GeometryCleaner-CIE8Wfmb.js +1 -1
- package/chunks/GlobalIllumination.glsl.js +3 -3
- package/chunks/LineMarker.glsl.js +35 -42
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorAffineTransform.js +1 -1
- package/chunks/OperatorClip.js +1 -1
- package/chunks/OperatorDensify.js +1 -1
- package/chunks/OperatorDistance.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/OperatorGraphicBuffer.js +1 -1
- package/chunks/OperatorIntegrate.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/OperatorSimplifyOGC.js +1 -1
- package/chunks/Path.glsl.js +2 -2
- package/chunks/Point2D.js +1 -1
- package/chunks/RealisticTree.glsl.js +2 -2
- package/chunks/RibbonLine.glsl.js +51 -57
- package/chunks/SideCalculator2D-DX0718xq.js +1 -1
- package/chunks/Terrain.glsl.js +2 -2
- package/chunks/Transformation2D.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/config.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/editing/fieldUtils.d.ts +12 -0
- package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.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/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/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/ellipseUtils.js +2 -0
- package/interfaces.d.ts +15 -18
- package/kernel.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/list/LayerItemCollection.d.ts +1 -0
- package/layers/list/types.d.ts +5 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/queries.js +1 -1
- package/layers/support/TimeSeriesCalculation.d.ts +1 -1
- package/layers/support/TimeSeriesCalculation.js +1 -1
- package/layers/support/dataSeriesUtils.d.ts +10 -0
- package/layers/support/timeSeriesUtils.js +17 -6
- package/libs/lyr3d/Lyr3DModule.js +1 -1
- package/networks/UtilityNetwork.d.ts +15 -0
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +4 -4
- package/popup/FeatureContent.d.ts +14 -1
- package/popup/FeatureContent.js +1 -1
- package/popup/FeatureContentCollection.d.ts +4 -10
- package/popup/FeatureContentCollection.js +1 -1
- package/popup/actions.js +1 -1
- package/popup/support/featureUtils.js +1 -1
- package/renderers/support/RenderingInfo.js +1 -1
- package/renderers/support/renderingInfoUtils.js +1 -1
- package/renderers/visualVariables/SizeVariable.d.ts +16 -20
- package/renderers/visualVariables/support/SizeStop.d.ts +6 -2
- package/rest/networks/support/TraceLocation.js +1 -1
- package/rest/networks/support/TraceResult.d.ts +7 -0
- package/rest/networks/support/TraceResult.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/opacity.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/timeSeriesUtils.js +1 -1
- package/smartMapping/statistics/histogramForTimeSeries.d.ts +11 -0
- package/smartMapping/statistics/histogramForTimeSeries.js +2 -0
- package/smartMapping/statistics/summaryStatisticsForTimeSeries.d.ts +11 -0
- package/smartMapping/statistics/summaryStatisticsForTimeSeries.js +2 -0
- package/smartMapping/statistics/support/timeSeriesUtils.js +24 -0
- package/smartMapping/statistics/types.d.ts +50 -0
- package/support/tests/serviceMockDependencies.js +1 -1
- package/support/tests/setupServiceMocksMesh.js +1 -1
- package/symbols/cim/CIMPlacements.js +1 -1
- package/symbols/cim/callouts/calloutAnalysisUtils.js +1 -1
- package/symbols/cim/callouts/effects/BackgroundCallout.js +1 -1
- package/symbols/cim/callouts/effects/BalloonCallout.js +1 -1
- package/symbols/cim/callouts/effects/PointSymbolCallout.js +1 -1
- package/symbols/cim/callouts/effects/calloutUtils.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/jobsUtil.js +1 -1
- package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
- package/views/2d/engine/webgl/definitions.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/ComputedAnimatedParams.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/ComputedMarkerParams.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/CalloutMeshWriterPolicy.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextParams.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/layers/SketchLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.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/layerAdapters/labelingUtils.js +1 -1
- package/views/2d/layers/features/schema/ExceedsLimitCache.js +1 -1
- package/views/2d/layers/features/schema/TimeSchema.js +2 -0
- package/views/2d/layers/features/schema/processor/LabelMatcherSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/MatcherSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
- package/views/2d/layers/support/vectorTileDebugUtils.js +1 -1
- package/views/2d/layers/support/visualVariableSimpleUtils.js +1 -1
- package/views/2d/types.d.ts +2 -1
- package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +24 -0
- package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/input/handlers/ground/GroundDoubleClickMove.js +1 -1
- package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
- package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
- package/views/3d/interactive/placementTools/GroundNavigationPlacementTool3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
- package/views/3d/state/controllers/GroundNavigationController.js +1 -1
- package/views/3d/state/controllers/momentum/GroundNavigationMomentumController.js +1 -1
- package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +16 -8
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +5 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/evaluateSceneLightingFragment.glsl.js +12 -0
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +2 -2
- package/views/3d/webgl-engine/effects/focusArea/FocusArea.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/SelectionManager.d.ts +3 -3
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/options/bindViewToolOptions.js +1 -1
- package/views/interactive/sketch/SketchLabelOptions.d.ts +3 -0
- package/views/interactive/sketch/SketchLabelOptions.js +1 -1
- package/views/interactive/sketch/SketchTooltipOptions.d.ts +3 -0
- package/views/interactive/sketch/SketchTooltipOptions.js +1 -1
- package/views/interactive/sketch/SketchValueOptions.d.ts +3 -0
- package/views/interactive/sketch/SketchValueOptions.js +1 -1
- package/views/interactive/snapping/SnappingOptions.d.ts +3 -0
- package/views/interactive/snapping/SnappingOptions.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/views/interactive/tooltip/fields/parsingAndFormattingUtils.js +1 -1
- package/views/layers/SketchLayerView.d.ts +34 -0
- package/views/layers/SketchLayerView.js +2 -0
- package/views/layers/types.d.ts +3 -2
- package/views/selection/types.d.ts +15 -4
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.d.ts +4 -0
- package/widgets/Bookmarks/BookmarksVisibleElements.d.ts +5 -1
- package/widgets/Bookmarks/types.d.ts +2 -0
- package/widgets/Editor/EditorViewModel.d.ts +31 -30
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/Editor/types.d.ts +44 -0
- package/widgets/Editor.d.ts +30 -27
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.d.ts +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.d.ts +6 -0
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Histogram/types.d.ts +10 -2
- package/widgets/HistogramRangeSlider/types.d.ts +4 -1
- package/widgets/LayerList/LayerListViewModel.d.ts +2 -1
- package/widgets/Legend/LegendViewModel.d.ts +2 -0
- package/widgets/Legend/styles/card/CardView.d.ts +2 -0
- package/widgets/Legend/styles/classic/ClassicView.d.ts +4 -1
- package/widgets/Legend.d.ts +3 -0
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +7 -0
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/support/VideoFeatureCache.js +2 -0
- package/widgets/OrientedImageryViewer/types.d.ts +9 -0
- package/widgets/OrientedImageryViewer.d.ts +7 -0
- package/widgets/OrientedImageryViewer.js +2 -2
- package/widgets/PanoramicVideoViewer.js +1 -1
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/ScaleRangeSlider/types.d.ts +9 -2
- package/widgets/Sketch/SketchViewModel.d.ts +32 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.d.ts +27 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/types.d.ts +58 -13
- package/widgets/Slider.d.ts +6 -0
- package/widgets/smartMapping/BinaryColorSizeSlider/BinaryColorSizeSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/ClassedColorSlider/ClassedColorSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/ClassedSizeSlider/ClassedSizeSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/ColorSizeSlider/ColorSizeSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.d.ts +3 -0
- package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/SmartMappingSliderViewModel.d.ts +2 -0
- package/widgets/smartMapping/types.d.ts +30 -7
- package/widgets/support/FilterBuilder/FilterBuilderViewModel.d.ts +21 -11
- package/widgets/support/FilterBuilder/FilterBuilderViewModel.js +1 -1
- package/widgets/support/FilterBuilder/types.d.ts +28 -0
- package/widgets/support/FilterBuilder.js +1 -1
- package/widgets/support/FilterCondition/FilterConditionViewModel.d.ts +24 -0
- package/widgets/support/FilterCondition/FilterConditionViewModel.js +1 -1
- package/widgets/support/FilterCondition/types.d.ts +16 -1
- package/widgets/support/FilterCondition.js +1 -1
- package/widgets/support/SnappingControls/snappingLayerListUtils.js +1 -1
- package/widgets/support/iconUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0606ab6fdfc1dfea3856.js +0 -1
- package/assets/esri/core/workers/chunks/078dcd17f46403d44b24.js +0 -1
- package/assets/esri/core/workers/chunks/1289204f8ca96032c17a.js +0 -1
- package/assets/esri/core/workers/chunks/12b5a645c0987a0efe54.js +0 -2
- package/assets/esri/core/workers/chunks/152fe3d6ad7aebbd23d1.js +0 -1
- package/assets/esri/core/workers/chunks/17b938ba49fb1e7ab8c4.js +0 -1
- package/assets/esri/core/workers/chunks/1dbb3e25e005a8220779.js +0 -2
- package/assets/esri/core/workers/chunks/3d6fef25af7e1a51e1bd.js +0 -1
- package/assets/esri/core/workers/chunks/3ef367c9b7bf1588307d.js +0 -1
- package/assets/esri/core/workers/chunks/5f4feca26102088ea565.js +0 -1
- package/assets/esri/core/workers/chunks/74211d096cc3296e0968.js +0 -1
- package/assets/esri/core/workers/chunks/7926faab76a721a2e1c4.js +0 -1
- package/assets/esri/core/workers/chunks/ad28486bc6afaa346de5.js +0 -1
- package/assets/esri/core/workers/chunks/ad29c729e90b5866713c.js +0 -1
- package/assets/esri/core/workers/chunks/b72a2514aa4cc4ae7d1b.js +0 -1
- package/assets/esri/core/workers/chunks/bb51cf52b8ea8283f4f8.js +0 -1
- package/assets/esri/core/workers/chunks/be761749f8d77fbd9df5.js +0 -1
- package/assets/esri/core/workers/chunks/dbfd25aa0d19aed5890c.js +0 -1
- package/assets/esri/core/workers/chunks/de28a86775235bd5d3c4.js +0 -2
- package/assets/esri/core/workers/chunks/f6cfc901267a229de7a1.js +0 -2
- package/assets/esri/core/workers/chunks/fb147097149a89e671ff.js +0 -1
- package/support/revision.js +0 -2
- /package/assets/esri/core/workers/chunks/{1dbb3e25e005a8220779.js.LICENSE.txt → 1b946714ca4a1a7359d4.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{f6cfc901267a229de7a1.js.LICENSE.txt → 2a1ec30f9ad305763f81.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{c3b96d1d43afccd23e45.js.LICENSE.txt → 590e6c70206122e4cc3c.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{cfaba0470619786e1ef8.js.LICENSE.txt → 68d8ae42ab71d01a70a5.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{de28a86775235bd5d3c4.js.LICENSE.txt → 8dc1c3042267618fd710.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{12b5a645c0987a0efe54.js.LICENSE.txt → 96c50a0dda0f1503ef92.js.LICENSE.txt} +0 -0
package/chunks/UnitFactory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{a as n,c as r,G as i,h as a,d as o,j as s,s as c,g as l,u,w as d,i as f,t as p,v as m,x as h,y as g,z as _,e as v,q as y,f as b,r as x,p as S,m as C,A as w}from"./Geometry.js";import{Envelope2D as T}from"./Envelope2D.js";import{a as E,y as D,z as O,P as k,M as A,g as j,A as M,E as N,c as P,S as F,L as I,B as L,F as R,H as ee,n as z,I as te,Q as ne,D as re,l as ie,J as ae,K as oe,N as se,O as ce,R as le,V as ue,T as de,U as fe,W as pe,X as me,Y as he,Z as ge,_ as _e,b as ve,$ as ye,a0 as be,a1 as xe,a2 as Se,a3 as Ce,a4 as we}from"./MultiPathImpl.js";import{e as Te,l as Ee,i as De,d as Oe,m as ke,g as Ae,c as je,E as Me,P as B,C as Ne,f as Pe,I as Fe,T as Ie,n as Le,a as Re,B as ze,o as Be,b as Ve,p as He,V as Ue,q as We,r as Ge,t as Ke,u as qe,v as Je,w as Ye,x as Xe,y as Ze,z as Qe,j as $e,D as et,F as tt,G as nt,S as rt,A as it,k as V,H as at,J as ot,h as st}from"./Envelope.js";import{B as ct,C as lt,D as ut,d as H,P as U,w as dt,F as ft,p as pt,G as mt,H as ht,c as gt,e as _t,E as W,I as vt,o as yt,m as bt,t as xt,K as St,r as Ct,g as wt,J as Tt,h as Et,a as Dt,L as Ot,N as kt,s as At,S as jt,f as Mt,O as Nt,Q as Pt,R as Ft,j as It,M as Lt,T as Rt,l as G,b as zt,U as Bt,V as Vt,W as Ht,i as Ut,q as Wt,X as Gt,Y as Kt,Z as qt,_ as Jt,$ as Yt,a0 as Xt,a1 as Zt,a2 as Qt,z as $t,a3 as en,n as tn}from"./Point2D.js";import{T as K}from"./Transformation2D.js";import{c as q,O as nn,a as rn}from"./OperatorClip.js";import{O as an}from"./OperatorDensify.js";import{G as on}from"./GeometryCursor.js";import{S as sn}from"./SimpleGeometryCursor.js";class cn{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move){this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,e.move.m_sr=null;return}if(e.copy){this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,this.m_sr=e.copy.m_sr;return}e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){let n=e;return!(!this.m_sr&&n.m_sr||this.m_sr&&!n.m_sr||!this.m_geom&&n.m_geom||this.m_geom&&!n.m_geom||this.m_sr&&n.m_sr&&!this.m_sr.equals(n.m_sr)||this.m_geom&&n.m_geom&&!this.m_geom.equals(n.m_geom,t))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new cn({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}m_geom;m_sr}class ln{m_factor=1;m_wkid=0;m_peUnit=null;constructor(e){e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():``}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&n(`unit type mismatch`),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return ct(lt(this.getUnitType()),lt(this.getUnitToBaseFactor()))}equals(e){return e?this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName():!1}static isValidWkid(e){return!1}}class J{m_reason;m_vertexIndex1;m_vertexIndex2;assign(e){this.m_reason=e.m_reason,this.m_vertexIndex1=e.m_vertexIndex1,this.m_vertexIndex2=e.m_vertexIndex2}constructor(e,t,n){e===void 0?(this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-2):(this.m_reason=e,this.m_vertexIndex1=t,this.m_vertexIndex2=n)}clear(){this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-1}}const un={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,10992,10993,11030,11033,11042,11043,11225,11226,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104220,104221,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,10635,10636,10735,10736,10758,37e3,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,"6377397.155":[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,10898,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],"6377563.396":[4001,4188,4277,4278,4279],"6377340.189":[4002,4299,4300],"6377492.018":[4005,4273,4817],"6377483.865280418":[4006,4293],"6378293.645208759":[4007,4157,4302,4738,5464],"6378206.4":[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],"6378450.047":[4009,4268],"6378300.789":[4010,4281],"6378249.2":[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],"6378249.145":[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104032,104103,104305],"6377276.345":[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],"6377298.556":[4016,4298],"6377304.063":[4018,4245],"6378298.3":[4028,4903],"6378136.2":4032,"6378136.3":4033,"6378249.144808011":[4034,4241],"20922931.8":[4042,4243],"6377301.243":[4044,4145,37203],"6377299.151":[4045,4146],"6377019.27":[4657,10256,10260,10265],"6378306.3696":[4748,4752],"6377295.664":[4751,37006],"6378136.5":[7682,7683],"6371008.7714":104047,"6378418.941":[104700,104726,104760],"6378586.581":[104701,104743],"6378505.809":104702,"6378544.823":104703,"6378490.569":104704,"6378470.757":[104705,104776],"6378403.701":[104706,104750],"6378434.181":[104707,104724,104739,104764],"6378454.907":104708,"6378400.653":104709,"6378567.378":104710,"6378546.957":[104711,104717,104780],"6378476.853":[104712,104736],"6378411.321":[104713,104728],"6378647.541":[104714,104715],"6378514.953":[104716,104782],"6378421.989":[104718,104770],"6378481.425":[104719,104753,104774,104781],"6378518.001":[104720,104725],"6378521.049":[104721,104723,104731,104745,104748],"6378464.661":104722,"6378436.619":104727,"6378574.389":[104729,104730],"6378472.281":[104732,104756],"6378498.189":[104733,104746],"6378449.421":[104734,104766],"6378525.621":[104735,104754],"6378466.185":104737,"6378496.665":104738,"6378643.579":104740,"6378559.758":104741,"6378414.369":[104742,104763,104772],"6378441.801":104744,"6378502.761":[104747,104759,104773,104775],"6378617.061":104749,"6378624.681":[104751,104765],"6378468.623":104752,"6378445.763":[104755,104758,104761],"6378670.401":104757,"6378438.753":104762,"6378543.909":104767,"6378605.783":104768,"6378540.861":104769,"6378443.325":[104771,104784],"6378548.481":104777,"6378463.746":104778,"6378426.561":104779,"6378453.688":104783,"6378530.193":104785,"6378376.271":[104800,104828],"6378471.92":104801,"6378472.931":104802,"6378411.351":104803,"6378380.991":104805,"6378414.96":104806,"6378345.09":[104807,104819,104844,104870],"6378412.542":104808,"6378470.401":104809,"6378376.331":104810,"6378379.031":104811,"6378407.621":104812,"6378376.811":[104813,104827],"6378313.92":104814,"6378414.93":104815,"6378413.021":104816,"6378380.381":104817,"6378530.851":104818,"6378591.521":104820,"6378378.881":104821,"6378408.481":[104822,104832],"6378375.601":[104823,104838],"6378408.041":104824,"6378655.071":104825,"6378409.151":104826,"6378315.7":[104829,104840,104845,104851],"6378285.86":[104830,104835,104859],"6378379.301":104831,"6378560.121":104833,"6378531.821":104834,"6378500.6":104836,"6378376.041":104837,"6378406.601":104839,"6378438.991":104841,"6378345.42":104842,"6378593.86":104843,"6378381.271":[104846,104847],"6378413.671":104848,"6378344.377":104849,"6378563.891":104850,"6378408.091":104852,"6378377.671":104853,"6378472.751":104854,"6378412.511":104855,"6378407.281":104856,"6378534.451":104857,"6378406.051":104858,"6378532.921":104860,"6378380.091":104861,"6378408.941":104862,"6378624.171":104863,"6378377.411":104864,"6378474.591":104865,"6378407.141":104866,"6378376.871":104867,"6378375.251":104868,"6378405.971":104869,"6378437.651":104871};function dn(){for(let e in un)delete un[e]}class fn extends ln{constructor(e){if(typeof e==`number`){super(),this.m_factor=e,this.m_wkid=0;return}super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function pn(e){return new Tf}function mn(e){if(e.getType()===$.PE_TYPE_LINUNIT)return new Tf(e);if(e.getType()===$.PE_TYPE_ANGUNIT)return new fn(e);n(`peUnit`)}function hn(e){let t=Cp(null);return e.getType()===$.PE_TYPE_PROJCS||e.getType()===$.PE_TYPE_GEOGCS?t.reset(e.getUnit()):n(`PE_coord_sys`),t.get()||o(`cannot create units from coord sys`),mn(t.get())}class gn{x;y;z;constructor(e,t,r){e===void 0?(this.x=new qt,this.y=new qt,this.z=new qt):e instanceof V?(this.x=new qt(e.x),this.y=new qt(e.y),this.z=new qt(e.z)):e instanceof qt?(this.x=e.clone(),this.y=t.clone(),this.z=r.clone()):n(`EPoint3D constructor`)}dotProduct(e){return this.x.mulE(e.x).addE(this.y.mulE(e.y)).addE(this.z.mulE(e.z))}crossProduct(e){return new gn(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){let t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),n=e.x.mulE(this.z).subE(this.x.mulE(e.z)),r=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new gn(t,n,r)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(e,t){return e.sub(t).length()}negate(){return new gn(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new gn(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new gn(this.x.subE(e.x),this.y.subE(e.y),this.z.subE(e.z))}subThis(e){return this.x.subThisE(e.x),this.y.subThisE(e.y),this.z.subThisE(e.z),this}addThis(e){return this.x.addThisE(e.x),this.y.addThisE(e.y),this.z.addThisE(e.z),this}mul(e){return new gn(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new gn(this.x.divE(e),this.y.divE(e),this.z.divE(e))}eq(e){return this.x.eq(e.x)&&this.y.eq(e.y)&&this.z.eq(e.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return V.construct(this.x.value(),this.y.value(),this.z.value())}}class _n{m_origin=new V;m_normal=new V;m_axisX=new V;m_axisY=new V;constructor(e){if(!e){this.m_origin=new V,this.m_normal=new V(0,0,1),this.m_axisX=new V(1,0,0),this.m_axisY=new V(0,1,0);return}if(e.pt0&&e.pt1&&e.pt2){this.setFromPoints(e.pt0,e.pt1,e.pt2);return}l(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return l(0),this}set(e,t,n,r){l(0)}setFromPoints(e,t,n){let r=t.sub(e),i=n.sub(e);this.m_normal=r.crossProductVector(i);let a=!0;if(!this.m_normal.isZero())this.m_normal.normalizeThis(),this.m_axisX=r.getUnitVector();else{if(a=!1,r.isZero()&&(r=i),r.isZero())return this.m_normal.setCoords(0,0,1),this.m_axisX.setCoords(1,0,0),this.m_axisY.setCoords(0,1,0),this.m_origin=e,!1;this.m_axisX=r.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,a}getCoord(e,t){return l(0),{}}getCoord2D(e){return l(0),{}}getCoordX(e,t){return l(0),0}getCoordY(e,t){return l(0),0}getCoordZ(e,t){return l(0),0}setPreferredAxisX(e){l(0)}getOrigin(){return l(0),{}}getNormal(){return l(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){l(0)}setAxisY(e,t=!1){l(0)}recalculateAxisY(){l(0)}setOrigin(e){l(0)}setNormal(e,t){l(0)}intersect(e,t){return l(0),!1}intersectLine(e){return l(0),0}intersectLineEx(e,t){return l(0),0}closestCoordinate(e){let t=e.sub(this.m_origin),n=new U;return n.x=t.dotProduct(this.m_axisX),n.y=t.dotProduct(this.m_axisY),n}projectVector(e){return l(0),{}}signedDistance(e){return l(0),0}distance(e){return l(0),0}}function vn(e,t){return!1}function yn(e,t,n,r,i=100,a=vn){l(r>0);let o,s,c,u,d,f,p,m,h,g=0,_=0,v,y,b,x=Qt();t>n&&(n=gt(t,t=n));let S=e(t),C=e(n);S<C?(o=s=c=t,u=d=f=S):(o=s=c=n,u=d=f=C);let w=0;for(;w<i&&(b=(n-t)*.5,h=t+b,v=r*(Math.abs(o)+.25),y=v*2,!(a(o,u)||Math.abs(o-h)<=y-b));++w){if(Math.abs(_)>v){let e=(o-s)*(u-f),r=(o-c)*(u-d),i=(o-c)*r-(o-s)*e;r=2*(r-e),r>0&&(i=-i),r=Math.abs(r);let a=_;_=g,Math.abs(i)>=Math.abs(r*a*.5)||i<=r*(t-o)||i>=r*(n-o)?(_=o>=h?t-o:n-o,g=Qt()*_):(g=i/r,m=o+g,(m-t<y||n-m<y)&&(g=h-o<0?-Math.abs(v):Math.abs(v)))}else _=o>=h?t-o:n-o,g=_*x;m=o+g,p=e(m),p<u?(m>=o?t=o:n=o,c=s,s=o,o=m,f=d,d=u,u=p):(m<o?t=m:n=m,p<=d||s===o?(c=s,s=m,f=d,d=p):(p<=f||c===o||c===s)&&(c=m,f=p))}return yt(o,u)}function bn(e,t,n){if(e>n){let t=Math.ceil((e-n)/tn);e-=t*tn}else if(e<t){let n=Math.ceil((t-e)/tn);e+=n*tn}return e}function xn(e,t,n){return Sn(e,t,n,0)}function Sn(e,t,n,r){let i=n.x,a=n.y;return wn(e,t,Math.cos(i),Math.sin(i),Math.cos(a),Math.sin(a),r)}function Cn(e,t,n,r,i,a){return wn(e,t,n,r,i,a,0)}function wn(e,t,n,r,i,a,o){let s=e/Math.sqrt(1-t*a*a),c=s+o,l=c*i*n,u=c*i*r,d=(s*(1-t)+o)*a;return V.construct(l,u,d)}function Tn(e,t,n){let r=new qt,i=new qt,a=new qt,o=new qt;r.setCos(n.x),i.setSin(n.x),a.setCos(n.y),o.setSin(n.y);let s=o.negate().mulE(o.mul(t)).add(1).sqrt(),c=new qt(e).divE(s),l=c.mulE(a).mulE(r),u=c.mulE(a).mulE(i),d=c.mul(1-t).mulE(o);return new gn(l,u,d)}function En(e,t,n){let r=n.x,i=n.y,a=n.z,o=Math.atan2(i,r),s=Math.sqrt(r*r+i*i),c=Math.atan2(a,(1-t)*s);return U.construct(o,c)}function Dn(e,t,n){let r=1-t,i=e/Math.sqrt(Dt(n.x)+Dt(n.y)+Dt(n.z)/r);return n.mul(i)}function On(e,t,n,r,i){let a=xn(e,t,n),o=xn(e,t,r);return En(e,t,V.lerp(a,o,i))}function kn(e,t,n){let r=new V;return r.setCrossProductVector(t,n),Math.abs(Math.atan2(r.length(),t.dotProduct(n)))*e}function An(e,t,n,r,i){let a=n.getUnitVector(),o=r.getUnitVector(),s=t.getUnitVector(),c=new V;if(c.setCrossProductVector(a,o),!c.isZero()){c.normalizeThis();let t=s.sub(c.mul(c.dotProduct(s)));if(!t.isZero()){t.normalizeThis();let n=a.add(o).mul(.5);if(n.dotProduct(t)>n.dotProduct(a)){let n=Math.abs(c.dotProduct(s)),r=Math.asin(n);return i.assign(t.getUnitVector().mul(e)),r*e}}}let l=kn(1,a,s),u=kn(1,o,s);return l<=u?(i.assign(n),l*e):(i.assign(r),u*e)}function jn(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=e(o,new Sp,!1);return kp.geodeticDistance(n,r,i.x,i.y,a.x,a.y,t,null,null,$.PE_LINETYPE_GEODESIC),t.val}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function Mn(e,t,n,r,i){switch(l(n.isFinite()&&r.isFinite()),i){case 0:return jn(e,t,n,r);case 1:return Fn(e,t,n);case 2:case 3:{let i=xn(e,t,n),a=xn(e,t,r);return V.distance(i,a)}default:p(``)}}function Nn(e,t,n,r,i,a=0,o){if(a===2||a===3)return Pn(e,t,n,r,i,a===3,o);let s=En(e,t,n),c=n=>{let o=En(e,t,V.lerp(r,i,n));return Mn(e,t,s,o,a)},l=V.distance(r,i);if(l>0){let{first:n,second:a}=yn(c,0,1,qn(e,l));return o&&o.assign(Dn(e,t,V.lerp(r,i,n))),yt(n,a)}{let e=c(0);return o&&o.assign(r),yt(.5,e)}}function Pn(e,t,n,r,i,a=!1,o){let s=Dn(e,t,n);if(a){let a=new _n({pt0:new V(0,0,0),pt1:r,pt2:i}),c=a.closestCoordinate(n),l=a.closestCoordinate(r),u=a.closestCoordinate(i),d=U.getClosestCoordinate(l,u,c),f=Dn(e,t,V.lerp(r,i,d)),p=V.distance(f,s);return o&&o.assign(f),yt(d,p)}let c=n=>{let a=Dn(e,t,V.lerp(r,i,n));return V.distance(a,s)},l=V.distance(r,i);if(l>0){let{first:n,second:a}=yn(c,0,1,qn(e,l));return o&&o.assign(Dn(e,t,V.lerp(r,i,n))),yt(n,a)}{let e=V.distance(n,r);return o&&o.assign(n),yt(.5,e)}}function Fn(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=e(o,new Sp,!1);return kp.greatEllipticDistance(n,r,i.x,i.y,i.x,i.y,t,null,null),t.val}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function In(e,t,n,r,i){if(Math.abs(n.x-r.x)>Math.PI||Math.abs(n.y)>G||Math.abs(r.y)>G||(Math.abs(n.y)===G||Math.abs(r.y)===G)&&n.x!==r.x)return NaN;let{first:a,second:o}=Yt(n.x,r.x),s=i;if(s=bn(s,a,o),!W.construct(n.x,r.x).containsCoordinate(s))return NaN;let c=ge.constructPoint2D(n),l=ge.constructPoint2D(r),u=Tn(1,t,c),d=Tn(1,t,l),f=u.crossProductVector(d);if(f.z.isZero())return n.y;let p=f.x.divE(f.z.negate()),m=f.y.divE(f.z.negate()),h=p.mulE(p).addE(m.mulE(m)).sqrt();if(h.isZero()||p.isZero()&&m.isZero())return n.y;let g=Math.atan2(m.value(),p.value()),_=Math.atan2(h.value()*Math.cos(g-s),1-t),v=xn(1,t,U.construct(s,_)),y=V.construct(v.x,v.y,-v.z),b=f.value().dotProduct(v),x=f.value().dotProduct(y);return Math.abs(x)<Math.abs(b)&&(_=-_),_}function Ln(e,t,n,r,i,a){if(a[0]=NaN,a[1]=NaN,Math.abs(n.x-r.x)>Math.PI||Math.abs(n.y)>G||Math.abs(r.y)>G||(Math.abs(n.y)===G||Math.abs(r.y)===G)&&n.x!==r.x||Math.abs(i)>=G||n.y>0&&r.y>0&&n.y>i&&r.y>i||n.y<0&&r.y<0&&n.y<i&&r.y<i)return 0;let o=ge.constructPoint2D(n),s=ge.constructPoint2D(r),c=Tn(1,t,o),l=Tn(1,t,s),u=c.crossProductVector(l);if(u.z.isZero())return W.construct(n.y,r.y).containsCoordinate(i)?(a[0]=n.x,1):0;let d=u.x.divE(u.z.negate()),f=u.y.divE(u.z.negate()),p=d.mulE(d).addE(f.mulE(f)).sqrt();if(p.isZero()||d.isZero()&&f.isZero())return i===0?(a[0]=n.x,a[1]=r.x,2):0;let m=(1-t)*Math.tan(i)/p.value();if(Math.abs(m)>1)return 0;let h=Math.acos(m),g=Math.atan2(f.value(),d.value()),_=g-h,v=g+h,y=Math.min(n.x,r.x),b=Math.max(n.x,r.x);bn(_,y,b),i===0?v=_:bn(v,y,b);let x=0;return y<=_&&_<=b&&(a[x]=_,x++),v!==_&&y<=v&&v<=b&&(a[x]=v,x++),x}function Rn(e,t){t[0]>Math.PI*.5?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<-Math.PI*.5&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),l(t[0]>=-Math.PI*.5&&t[0]<=Math.PI*.5)}function zn(e,t){return e*Math.sqrt(1-t)}function Bn(e){return 1-e}function Vn(e,t,n,r,i){r=At(r,-G,G),i=At(i,-G,G);let a=G-.03,o;o=r>a&&i>a||r<-a&&i<-a?Hn(e,r,i):Un(e,i)-Un(e,r);let s=Bn(e);return .5*(n-t)*o*s}function Hn(e,t,n){let r=1;if(t<0&&(r=-1,t=-t,n=-n),e!==0){let i=e*e,a=i*e,o=a*e,s=[1,(1+11*e)/12,(1+118*e+241*i)/360,(1+1089*e+10419*i+8651*a)/20160,(1+9836*e+318246*i+1027436*a+458881*o)/1814400],c=t=>{let n=0,r=Dt(t)/(e-1);for(let e=s.length-1;e>=0;--e)n=s[e]+n*r;return n*=-Dt(t/(1-e)),n},l=c(G-t);return(c(G-n)-l)*r}{let e=G-t,i=G-n,a=-4*Dt(Math.sin(e/2));return(-4*Dt(Math.sin(i/2))-a)*r}}function Un(e,t){if(t===0)return 0;let n=Math.sin(t),r=n,i=n;return e!==0&&(r/=1-e*n*n,i=n*$t(Math.sqrt(e)*n)),r+i}function Wn(e,t){return e/Math.sqrt(1-t)}function Gn(e,t){return(1-t)*e}function Kn(e,t,n){let r=n/(2*Gn(e,t)),i=r*r;return n*(1-i*(.16666666666666666-.008333333333333333*i))}function qn(e,t){if(t!==0){let n=e*Zt()/t;return Math.min(n,1e-10)}return 0}class Jn{m_parent;m_currentShift=63n;m_currentElt=0n;m_iCurrentElt=-1;m_aiSetElts;constructor(e){this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,this.m_currentShift===64n){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return Jn.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 2**53-1}}function Yn(e){return 1n<<(BigInt(e)&63n)}function Xn(e){return e>>6}class Zn{m_bits=[];constructor(e){if(e!==void 0&&e.copy){this.m_bits=e.copy.m_bits.slice();return}}assignMove(){return this}assignCopy(){return this}hasBit(e){let t=Yn(e),n=Xn(e);return this.m_bits[n]!==void 0&&!!(this.m_bits[n]&t)}setBit(e){let t=Yn(e),n=Xn(e);this.m_bits[n]===void 0&&(this.m_bits[n]=0n),this.m_bits[n]|=t}clearBit(e){}flipBit(e){let t=Yn(e),n=Xn(e);return this.m_bits[n]===void 0&&(this.m_bits[n]=0n),this.m_bits[n]^=t,(this.m_bits[n]&t)!==0n}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(e&2)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((n,r)=>{t|=n===e.m_bits[r]?2:1}),t&1?!1:(e.m_bits.forEach((e,n)=>{t|=e===this.m_bits[n]?2:1}),!(t&1))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]===void 0?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]!==void 0&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]!==void 0&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]===void 0?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>Nt(e,t),lt(0))}getUnorderedBitIterator(){return new Jn(this)}}class Qn{m_map=new Map;m_hf;m_ef;constructor(e,t){this.m_hf=e,this.m_ef=t}add(e){let t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;let n=this.m_map.get(t);return n instanceof Array?n.find(t=>this.m_ef(t,e))||n.push(e):this.m_ef(n,e)||this.m_map.set(t,[n,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){let t=this.m_hf(e);if(!this.m_map.has(t))return!1;let n=this.m_map.get(t);return n instanceof Array?n.find(t=>this.m_ef(t,e))!==void 0:this.m_ef(n,e)}get(e){let t=this.m_hf(e),n=this.m_map.get(t);if(n!==void 0)return n instanceof Array?n.find(t=>this.m_ef(t,e)):n}get size(){let e=0;for(let t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[Symbol.iterator](){return new Set()[Symbol.iterator]()}entries(){return new Set().entries()}keys(){return new Set().keys()}values(){return new Set().values()}get[Symbol.toStringTag](){return`ValueSet`}}class $n extends tt{m_helper;m_bufferLeft=new F;m_bufferRight=new F;m_intervalLeft=W.constructEmpty();m_intervalRight=W.constructEmpty();m_yScanline=NaN;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=t,i=e.getElement(n);this.m_helper.querySegmentXY(r,this.m_bufferLeft),this.m_helper.querySegmentXY(i,this.m_bufferRight);let a=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(a.getStartX(),a.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;let s=a.getStartY()===a.getEndY(),c=o.getStartY()===o.getEndY();if(s||c){if(s&&c)return 0;if(a.getStartY()===o.getStartY()&&a.getStartX()===o.getStartX())return s?1:-1;if(a.getEndY()===o.getEndY()&&a.getEndX()===o.getEndX())return s?-1:1}let l=a.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),u=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(l===u){let e=a.getEndY(),t=o.getEndY(),n=Math.min(e,t),r=(n+this.m_yScanline)*.5;r===this.m_yScanline&&(r=n),l=a.intersectionOfYMonotonicWithAxisX(r,this.m_intervalLeft.vmin),u=o.intersectionOfYMonotonicWithAxisX(r,this.m_intervalRight.vmin)}return l<u?-1:+(l>u)}setY(e){this.m_yScanline=e}}class er{m_parent;m_segmentBuffer=new F;m_point=U.getNAN();constructor(e){this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){let n=e.getElement(t);this.m_parent.querySegmentXY(n,this.m_segmentBuffer);let r=this.m_segmentBuffer.get(),i=new W;if(i.setCoords(r.getStartX(),r.getEndX()),this.m_point.x<i.vmin)return-1;if(this.m_point.x>i.vmax)return 1;let a=r.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<a?-1:+(this.m_point.x>a)}}var tr;(function(e){e[e.enumInputModeBuildGraph=0]=`enumInputModeBuildGraph`,e[e.enumInputModeSimplifyAlternate=1]=`enumInputModeSimplifyAlternate`,e[e.enumInputModeSimplifyWinding=2]=`enumInputModeSimplifyWinding`})(tr||={});var nr;(function(e){e[e.enumSegmentParentageBreakNode=1]=`enumSegmentParentageBreakNode`,e[e.enumPathBreakNode=2]=`enumPathBreakNode`})(nr||={});function rr(e,t){return{parentage:e,rank:t}}function ir(e,t){let n=e.length;if(n!==t.length)return!1;let r=e[0].parentage;if(r!==t[0].parentage)return!1;if(r===-1)return!0;for(let r=1;r<n;++r)if(e[r].parentage!==t[r].parentage)return!1;return!0}function ar(e,t,n){n.length=0;let r=!1;{let i=e.getHalfEdgeVertexIterator(t);for(;i!==z;){let t=e.getVertexFromVertexIterator(i),a=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);r||=o>=0,n.push(rr(o,a)),i=e.incrementVertexIterator(i)}}{let i=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;i!==z;){let t=e.getVertexFromVertexIterator(i),a=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);r||=o>=0,n.push(rr(o,a)),i=e.incrementVertexIterator(i)}}r&&n.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:+(e.parentage>t.parentage)),n[0].parentage===-1&&(n.length=1)}function or(){return new Qn(e=>e.getHashCode(),(e,t)=>e.equals(t))}class sr{m_shape=null;m_clusterData=new rt(8);m_clusterVertices=new rt(2);m_firstCluster=z;m_lastCluster=z;m_halfEdgeData=new rt(8);m_chainData=new rt(8);m_chainAreas=null;m_chainPerimeters=null;static c_EdgeParentageMask=2147483647;static c_EdgeBitMask=1<<31;m_universeChain=-1;m_simplifiedGeometry=-1;m_edgeIndices=[];m_clusterIndices=[];m_chainIndices=[];m_bBuildGeometryParentageSets=!1;m_chainBitSetIndex=-1;m_edgeBitSetIndex=-1;m_edgeBitSetIndexLeft=-1;m_emptyBitSet=null;m_geometryMapID=null;m_uniqueBitSets=null;m_chainBitSets=[];m_edgeBitSets=[];m_checkDirtyPlanesweepTolerance=NaN;m_geometryIDIndex=-1;m_clusterIndex=-1;m_halfEdgeIndex=-1;m_tmpHalfEdgeParentageIndex=-1;m_tmpHalfEdgeParentageIndexLeft=-1;m_tmpHalfEdgeWindingNumberIndex=-1;m_tmpHalfEdgeOddEvenNumberIndex=-1;m_segmentParentageIndex=-1;m_segmentIndexHe=-1;m_clusterBreakNodeIndex=-1;m_universeGeomID=-1;m_pointCount=0;m_progressCounter=0;m_bBuildChains=!0;m_bDirtyCheckFailed=!1;constructor(){}setCheckDirtyPlanesweepTolerance(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,n=!0,r=!1){r?this.setEditShapeImpl3D_(e,tr.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,tr.enumInputModeBuildGraph,null,t,n)}setAndSimplifyEditShapeAlternate(e,t,n=null,r=!1){let a=[];a.push(t),this.m_simplifiedGeometry=t,r?this.setEditShapeImpl3D_(e,tr.enumInputModeSimplifyAlternate,a,n,!1):this.setEditShapeImpl_(e,tr.enumInputModeSimplifyAlternate,a,n,e.getGeometryType(t)===i.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,n=null){let r=[];r.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,tr.enumInputModeSimplifyWinding,r,n,!0)}removeShape(){this.m_shape!==null&&(this.m_geometryIDIndex!==-1&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),this.m_clusterIndex!==-1&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),this.m_halfEdgeIndex!==-1&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.m_tmpHalfEdgeWindingNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),this.m_tmpHalfEdgeOddEvenNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),this.m_segmentParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_segmentIndexHe!==-1&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),this.m_clusterBreakNodeIndex!==-1&&(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=z,this.m_lastCluster=z,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=z,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){let n=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(n))}queryXYZ(e,t){l(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){let n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];return r.size()<=n?-1:r.read(n)}setClusterUserIndex(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1),i.write(r,n)}hasClusterUserIndexFlags(e,t,n){if(t===-1)return!1;let r=this.getClusterUserIndex(e,t);return r!==-1&&(n&r)!==0}setClusterUserIndexFlags(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1);let a=i.read(r);a===-1&&(a=0),i.write(r,n|a)}clearClusterUserIndexFlags(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1);let a=i.read(r);a===-1&&(a=0),i.write(r,~n&a)}createUserIndexForClusters(e=-1){let t=new Re(this.m_clusterData.capacity(),e);for(let e=0,n=this.m_clusterIndices.length;e<n;e++)if(this.m_clusterIndices[e]===null)return this.m_clusterIndices[e]=t,e;return this.m_clusterIndices.push(t),this.m_clusterIndices.length-1}deleteUserIndexForClusters(e){this.m_clusterIndices[e]=null}getHalfEdgeOrigin(e){return this.m_halfEdgeData.getField(e,1)}getHalfEdgeTo(e){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(e))}getHalfEdgeTwin(e){return this.m_halfEdgeData.getField(e,4)}getHalfEdgePrev(e){return this.m_halfEdgeData.getField(e,5)}getHalfEdgeNext(e){return this.m_halfEdgeData.getField(e,6)}getHalfEdgeChain(e){return this.m_halfEdgeData.getField(e,2)}getHalfEdgeFaceParentage(e){return this.getChainParentage(this.getHalfEdgeChain(e))}getHalfEdgeVertexIterator(e){return this.m_halfEdgeData.getField(e,7)}getHalfEdgeFromXY(e,t){this.queryXY(this.getHalfEdgeOrigin(e),t)}getHalfEdgeToXY(e,t){this.queryXY(this.getHalfEdgeTo(e),t)}isHalfEdgeCurve(e){return this.m_segmentIndexHe!==-1&&this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)!==-1}getHalfEdgeFromXYZ(e,t){l(0)}getHalfEdgeToXYZ(e,t){l(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&sr.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){let n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];return r.size()<=n?-1:r.read(n)}setHalfEdgeUserIndex(e,t,n){let r=this.getHalfEdgeIndex_(e),i=this.m_edgeIndices[t];i.size()<=r&&i.resize(this.m_halfEdgeData.size(),-1),i.write(r,n)}createUserIndexForHalfEdges(e){e===void 0&&(e=-1);let t=new Re(this.m_halfEdgeData.capacity(),e);for(let e=0,n=this.m_edgeIndices.length;e<n;e++)if(this.m_edgeIndices[e]===null)return this.m_edgeIndices[e]=t,e;this.m_edgeIndices.push(t);let n=this.m_edgeIndices.length-1;return l(n>=0&&n<=2**53-1),n}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.getHalfEdgeChain(n),i=this.getHalfEdgeTwin(n),a=this.getHalfEdgeChain(i);this.setChainHalfEdge_(r,z),this.setChainHalfEdge_(a,z),this.updateVertexToHalfEdgeConnection_(n,!0),this.deleteEdgeImpl_(n)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonInterior(e,t){return l(0),!1}doesClusterBelongToAPolygonExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return l(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){let t=this.getChainIndex_(e),n=this.m_chainAreas.read(t);return Number.isNaN(n)&&(this.updateChainAreaAndPerimeter_(e),n=this.m_chainAreas.read(t)),n}getChainPerimeter(e){return l(0),0}getChainUserIndex(e,t){let n=this.getChainIndex_(e),r=this.m_chainIndices[t];return r.size()<=n?-1:r.read(n)}setChainUserIndex(e,t,n){let r=this.getChainIndex_(e),i=this.m_chainIndices[t];i.size()<=r&&i.resize(this.m_chainData.size(),-1),i.write(r,n)}createUserIndexForChains(){let e=new Re(this.m_chainData.capacity(),-1);for(let t=0,n=this.m_chainIndices.length;t<n;t++)if(this.m_chainIndices[t]===null)return this.m_chainIndices[t]=e,t;return this.m_chainIndices.push(e),this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,n,r){let a=t===z?e.createGeometry(i.enumPolygon):t,o=new F;this.extractPolygonPathFromChain_(e,a,n,r,o);for(let t=this.getChainFirstIsland(n);t!==z;t=this.getChainNextInParent(t))this.extractPolygonPathFromChain_(e,a,t,r,o);return a}getGeometryID(e){let t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return l(t>=0),1<<Math.min(t,31)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_clusterIndex)}getHalfEdgeFromVertex(e){return this.m_shape.getUserIndex(e,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(e){if(l(this.m_bBuildGeometryParentageSets),this.m_chainBitSetIndex===-1)return this.getEmptySet();let t=this.getChainUserIndex(e,this.m_chainBitSetIndex);l(t>=0);let n=this.m_chainBitSets.at(t);return n||=this.getEmptySet(),n}getChainBoundaryBitSet(e){l(this.m_bBuildGeometryParentageSets);let t=new Zn,n=e=>{let n=this.getChainHalfEdge(e),r=n;do{let e=this.getEdgeBitSet_(r);e!==null&&t.assignOr(e);let n=this.getEdgeBitSet_(this.getHalfEdgeTwin(r));n!==null&&t.assignOr(n),r=this.getHalfEdgeNext(r)}while(r!==n)};n(e);for(let t=this.getChainFirstIsland(e);t!==z;t=this.getChainNextInParent(t))n(e);return t}getChainPolygons(e){return l(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||e===null)return[];if(this.m_geometryMapID===null){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==z;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}let t=[],n=e.getUnorderedBitIterator();for(let e=n.next();e!==Jn.npos();e=n.next())l(this.m_geometryMapID.has(e)),t.push(this.m_geometryMapID.get(e));return t}getVertexDominant(e,t){if(t===z)return e;let n=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(n,t)}getVertexDominantFromCluster(e,t){if(t!==z){let n=z;for(let r=this.getClusterVertexIterator(e);r!==z;r=this.incrementVertexIterator(r)){let e=this.getVertexFromVertexIterator(r);n===z&&(n=e);let i=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(i)===t){n=e;break}}return n}{let t=this.getClusterVertexIterator(e);return t===z?z:this.getVertexFromVertexIterator(t)}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode)}setBreakNode(e,t){l(this.m_clusterBreakNodeIndex!==-1),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode)}setStrongPathNode(e,t){if(this.m_clusterBreakNodeIndex===-1){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode)}getSegmentParentage(e){if(this.m_segmentParentageIndex===-1)return-1;let t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){let t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;let n=this.getHalfEdgeTwin(t),r=this.getHalfEdgeNext(n);return e!==this.getHalfEdgeTwin(r)}isCrossroadBehind(e){return l(0),!1}getHalfEdgeConnector(e,t){let n=this.getClusterHalfEdge(e);if(n===z)return z;let r=n,i=z,a=z;do{if(this.getHalfEdgeTo(r)===t)return r;if(i===z){if(i=this.getClusterHalfEdge(t),i===z)return z;a=i}if(this.getHalfEdgeTo(a)===e)return r=this.getHalfEdgeTwin(a),r;r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r)),a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(r!==n&&a!==i);return z}querySegmentXY(e,t){if(this.m_segmentIndexHe!==-1){let n=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(n!==-1){if(n!==-2){let e=this.m_shape.getSegmentFromIndex(n);t.copyFrom(e,!0)}else{n=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);let r=this.m_shape.getSegmentFromIndex(n);t.copyFrom(r,!0),t.get().reverse()}return}}t.createLine();let n=t.get(),r=U.getNAN();this.getHalfEdgeFromXY(e,r),n.setStartXY(r),this.getHalfEdgeToXY(e,r),n.setEndXY(r)}isCurveEdge(e){return this.m_segmentIndexHe!==-1&&this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)!==-1}compareEdgeAnglesCurveHelper_(e,t,n){let r=new F,i=new F;this.querySegmentXY(e,r),this.querySegmentXY(t,i);let a=r.get(),o=i.get();if(a.equals(o))return 0;let s=new U;this.getHalfEdgeFromXY(e,s);let c=new U;this.getHalfEdgeToXY(e,c);let u=new U;return this.getHalfEdgeToXY(t,u),l(!c.isEqualPoint2D(u)),ce(a,o)}compareEdgeAnglesHelper_(e,t,n){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,n);let r=U.getNAN();this.getHalfEdgeToXY(e,r);let i=U.getNAN();if(this.getHalfEdgeToXY(t,i),r.isEqualPoint2D(i))return 0;let a=U.getNAN();this.getHalfEdgeFromXY(e,a);let o=U.getNAN();o.setSub(r,a);let s=U.getNAN();return s.setSub(i,a),!n||s.y>=0&&o.y>0?U.compareVectors(o,s):0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return l(0),0}compareEdgeAnglesForPair3D_(e,t){return l(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){let t=this.getHalfEdgeChain(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeChain(n);l(r===t),l(e===this.getHalfEdgeNext(n)||n===this.getHalfEdgeNext(e));let i=this.getHalfEdgeNext(e);i===n&&(i=this.getHalfEdgeNext(i),i===e&&(i=z));let a=this.getChainIndex_(t),o=this.m_chainAreas.read(a);Number.isNaN(o)||(this.setChainArea_(t,NaN),this.setChainPerimeter_(t,NaN));let s=this.getChainHalfEdge(t);(s===e||s===n)&&this.setChainHalfEdge_(t,i),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,n){let r=t===z?this.getClusterHalfEdge(e):t;if(r===z)return z;let i=r;for(;;){if(this.getHalfEdgeUserIndex(r,n)!==1)return r;let e=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));if(e===i)return z;r=e}}removeSpikes_(){let e=!1,t=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==z;n=this.getNextCluster(n)){let r=z;for(;;){let i=this.getFirstUnvisitedHalfEdgeOnCluster_(n,r,t);if(i===z)break;r=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));let a=i;for(;;){let n=this.getHalfEdgeNext(a),o=this.getHalfEdgePrev(a),s=this.getHalfEdgeTwin(a);if(o===s){if(this.deleteEdgeInternal_(a),e=!0,(r===a||r===s)&&(r=z),a===i||o===i){if(i=n,a===i||o===i)break;a=n;continue}}else this.setHalfEdgeUserIndex(a,t,1);if(a=n,a===i)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){let e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){let e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);let t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){let e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return l(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){let n=t?z:e;for(let t=this.getHalfEdgeVertexIterator(e);t!==z;t=this.incrementVertexIterator(t)){let e=this.getVertexFromVertexIterator(t);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,n)}}updateVertexToHalfEdgeConnection_(e,t){e!==z&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);let n=this.getChainFirstIsland(t);this.setChainNextInParent_(e,n),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){let n=this.getChainIndex_(e);this.m_chainAreas.write(n,t)}setChainPerimeter_(e,t){let n=this.getChainIndex_(e);this.m_chainPerimeters.write(n,t)}updateChainAreaAndPerimeter_(e){let t=this.m_shape.hasCurves(),n=new St(0),r=new St(0),i=this.getChainHalfEdge(e),a=U.getNAN(),o=U.getNAN(),s=U.getNAN();this.getHalfEdgeFromXY(i,a),o.setCoordsPoint2D(a);let c=i;do this.getHalfEdgeToXY(c,s),(!t||!this.isCurveEdge(c))&&r.pe(U.distance(o,s)),this.getHalfEdgeChain(this.getHalfEdgeTwin(c))!==e&&n.pe((s.x-a.x-(o.x-a.x))*(s.y-a.y+(o.y-a.y))*.5),o.setCoordsPoint2D(s),c=this.getHalfEdgeNext(c);while(c!==i);if(t){let t=new F;c=i;do{this.getHalfEdgeToXY(c,s);let i=this.isCurveEdge(c);if(i&&(this.querySegmentXY(c,t),r.pe(t.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(c))!==e&&i){let e=t.get().calculateArea2DHelper();n.pe(e)}c=this.getHalfEdgeNext(c)}while(c!==i)}let l=this.getChainIndex_(e);this.m_chainAreas.write(l,n.getResult()),this.m_chainPerimeters.write(l,r.getResult())}getChainTopmostEdge_(e){return l(0),0}planeSweepParentage_(e,t){let n=new $n(this),r=new Ie;r.setCapacity(Math.trunc(this.m_pointCount/2)),r.setComparator(n);let i=[],a=this.createUserIndexForHalfEdges(),o=null,s=U.getNAN();for(let c=this.getFirstCluster();c!==z;c=this.getNextCluster(c)){this.progress_(t);let l=this.getClusterHalfEdge(c);if(l!==z){if(i.length=0,!this.tryOptimizedInsertion_(r,a,i,c,l)){this.queryXY(c,s),n.setY(s.y);let e=l;do{let t=this.getHalfEdgeUserIndex(e,a);t!==-1&&(r.deleteNode(t),this.setHalfEdgeUserIndex(e,a,rt.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(l!==e);e=l;do{if(this.getHalfEdgeUserIndex(e,a)===-1){let t=r.addElement(e);i.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(l!==e)}for(let t=i.length-1;t>=0;t--){let n=i[t],o=r.getElement(n),s=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(s,a,n),this.planeSweepParentagePropagateParentage_(r,n,e)}}else if(this.getClusterChain(c)===z){o===null&&(o=new er(this)),this.queryXY(c,s),o.setPointXY(s);let e=r.searchLowerBound(o),t=this.m_universeChain;if(e!==-1){let n=r.getElement(e);this.getHalfEdgeChain(n)===this.getHalfEdgeChain(this.getHalfEdgeTwin(n))&&(n=this.getLeftSkipPolylines_(r,e)),n!==z&&(t=this.getHalfEdgeChain(n))}this.addClusterToExteriorChain_(t,c)}}this.deleteUserIndexForHalfEdges(a)}planeSweepParentagePropagateParentage_(e,t,n){let r=e.getElement(t),i=this.getHalfEdgeChain(r);if(this.getChainParent(i)!==z)return;let a=this.getLeftSkipPolylines_(e,t),o=this.getHalfEdgeTwin(r),s=this.getHalfEdgeChain(o),c=this.getChainParent(i),u=this.getChainParent(s);if(a===z)c===z&&(s===i?(this.setChainParent_(s,this.m_universeChain),u=this.m_universeChain,c=u):(u===z&&(this.setChainParent_(s,this.m_universeChain),u=this.m_universeChain),this.setChainParent_(i,s),c=s));else{let e=this.getHalfEdgeChain(a);if(u===z){if(this.getChainArea(e)<=0){let t=this.getChainParent(e);this.setChainParent_(s,t),u=t}else this.setChainParent_(s,e),u=e;s===i&&(c=u)}}c===z&&(this.trySetChainParentFromTwin_(i,s),c=this.getChainParent(i)),l(c!==z),n===tr.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,r,a):n===tr.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,r,a,o,i,s):n===tr.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,r,a,o,i,s)}propagateParentageBuildGraph_(e,t,n,r){let i=t,a;r===z?(i=e.getNext(i),a=this.getHalfEdgeChain(n)):a=this.getHalfEdgeChain(r);let o=null,s=this.getChainParentage(a);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(a));i!==-1;i=e.getNext(i)){let t=e.getElement(i),n=this.getHalfEdgeTwin(t);a=this.getHalfEdgeChain(t);let r=this.getHalfEdgeChain(n);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(r);e=new Zn({copy:e}),e.assignOr(o),this.setChainBitSet_(r,e);let n=this.getChainBitSet(a),i=this.getLeftEdgeBitSet_(t),s=new Zn({copy:o});if(s.assignSubtract(i),s.isZero())break;n=new Zn({copy:n}),n.assignOr(s),this.setChainBitSet_(a,n),o=n}let c=this.getChainParentage(r),l=c|s;l!==c&&this.setChainParentage_(r,l);let u=this.getChainParentage(a),d=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft),f=s&~d;if(f&&(u|=f,this.setChainParentage_(a,u)),f===0)break;s=u}}propagateParentageWinding_(e,t,n,r,i,a,o){if(a===o)return;let s=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex);s+=this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex);let c=0,u=[],d=[];d.push(0);for(let n=e.getFirst();n!==t;n=e.getNext(n)){let t=e.getElement(n),r=this.getHalfEdgeTwin(t),i=this.getHalfEdgeChain(t),a=this.getHalfEdgeChain(r);if(i!==a){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex),c+=e;let n=!1;u.length!==0&&u.at(-1)===a&&(d.pop(),u.pop(),n=!0),l(this.getChainParent(a)!==z),(!n||this.getChainParent(a)!==i)&&(d.push(c),u.push(i))}}if(c+=s,u.length!==0&&u.at(-1)===o&&(d.pop(),u.pop()),c!==0){if(d.at(-1)===0){let e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}else if(d.at(-1)!==0){let e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}propagateParentageAlternate_(e,t,n,r,i,a,o){let s=this.m_simplifiedGeometry,c=this.getGeometryID(s);if(r===z)this.setChainParentage_(o,this.m_universeGeomID),this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,c):this.setChainParentage_(a,this.m_universeGeomID);else{let e=this.getChainParentage(o);if(e===0){let e=this.getHalfEdgeChain(r),t=this.getChainParentage(e);this.setChainParentage_(o,t),this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,t===c?this.m_universeGeomID:c):this.setChainParentage_(a,t)}else this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,e===c?this.m_universeGeomID:c):this.setChainParentage_(a,e)}}tryOptimizedInsertion_(e,t,n,r,i){let a=i,o=-1,s=z,c=0;do{if(c===2)return!1;let e=this.getHalfEdgeUserIndex(a,t);if(e!==-1){if(o!==-1)return!1;o=e}else{if(s!==z)return!1;s=a}c++,a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(i!==a);return s===z||o===-1?!1:(this.setHalfEdgeUserIndex(e.getElement(o),t,rt.impossibleIndex2()),e.setElement(o,s),n.push(o),!0)}trySetChainParentFromTwin_(e,t){let n=this.getChainArea(e);if(n===0)return!1;let r=this.getChainArea(t);if(n>0&&r<0||n<0&&r>0)return this.setChainParent_(e,t),!0;{let n=this.getChainParent(t);if(n!==z)return this.setChainParent_(e,n),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let n=0,r=t.size();n<r;n++){let r=t.read(n),a=this.m_shape.getUserIndex(r,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(r),c=this.m_shape.getGeometryFromPath(o),l=this.m_shape.getGeometryType(c);if(s(l)){let t=this.m_shape.getNextVertex(r);if(t===z)continue;let n=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(a===n)continue;let o=this.newHalfEdgePair_(),s=this.getHalfEdgeTwin(o),u=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(u,0,r),this.m_clusterVertices.setField(u,1,-1),this.setHalfEdgeVertexIterator_(o,u),this.m_shape.setUserIndex(r,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,a);let d=this.getClusterHalfEdge(a);if(d===z)this.setClusterHalfEdge_(a,o),this.setHalfEdgePrev_(o,s),this.setHalfEdgeNext_(s,o);else{let e=this.getHalfEdgePrev(d);this.setHalfEdgePrev_(d,s),this.setHalfEdgeNext_(s,d),this.setHalfEdgeNext_(e,o),this.setHalfEdgePrev_(o,e)}this.setHalfEdgeOrigin_(s,n);let f=this.getClusterHalfEdge(n);if(f===z)this.setClusterHalfEdge_(n,s),this.setHalfEdgeNext_(o,s),this.setHalfEdgePrev_(s,o);else{let e=this.getHalfEdgePrev(f);this.setHalfEdgePrev_(f,o),this.setHalfEdgeNext_(o,f),this.setHalfEdgeNext_(e,s),this.setHalfEdgePrev_(s,e)}let p=this.getGeometryID(c);if(e===tr.enumInputModeBuildGraph){let e=l===i.enumPolygon?p:0;if(this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){let e=new Zn,t=this.m_shape.getGeometryUserIndex(c,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(o,e),this.setEdgeBitSet_(s,null),this.setLeftEdgeBitSet_(s,e),this.setLeftEdgeBitSet_(o,null)}}else if(e===tr.enumInputModeSimplifyWinding){let e=this.m_shape.getXY(r),n=this.m_shape.getXY(t),i=0,a=0;e.compare(n)<0?i=1:a=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,i),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex,a)}else e===tr.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex,1));let m=l===i.enumPolygon?sr.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,p|m),this.setHalfEdgeParentage_(s,p|m)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,n=t.size();e<n;e++){let n=t.read(e);if(this.m_shape.getSegment(n)){let e=this.m_shape.getUserIndex(n,this.m_halfEdgeIndex);e!==z&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(n)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{let n=this.getHalfEdgeVertexIterator(t);if(n!==z){let r=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(n,1,r),this.setHalfEdgeVertexIterator_(e,n),this.setHalfEdgeVertexIterator_(t,z)}}let n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeTwin(t);{let e=this.getHalfEdgeVertexIterator(r);if(e!==z){let t=this.getHalfEdgeVertexIterator(n);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(n,e),this.setHalfEdgeVertexIterator_(r,z)}}if(this.m_segmentIndexHe!==-1){let i=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(i!==-1){if(i===-2){let n=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,n)}if(i=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe),i===-2){let e=this.getHalfEdgeUserIndex(r,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(n,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){let t=[];for(let n=this.getFirstCluster();n!==z;n=this.getNextCluster(n)){t.length=0;let r=this.getClusterHalfEdge(n);if(r!==z){let i=r;do t.push(i),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));while(i!==r);if(t.length>1){let i=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=gt(t[0],t[0]=t[1]):i=!1;let a=t[0],o=a,s=this.getHalfEdgeTo(o),c=this.getHalfEdgeTwin(o),l=z;for(let n=1,r=t.length;n<r;n++){let r=t[n],i=this.getHalfEdgeTwin(r),u=this.getHalfEdgeOrigin(i);if(u===s&&r!==o){if(e===tr.enumInputModeBuildGraph){let e=this.getHalfEdgeParentageMask_(o)|this.getHalfEdgeParentageMask_(r);if(this.setHalfEdgeParentage_(o,e),this.setHalfEdgeParentage_(c,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,n;e=this.getEdgeBitSet_(o),t=this.getEdgeBitSet_(r),n=new Zn({copy:e}),n.assignOr(t),this.setEdgeBitSet_(o,n),e=this.getEdgeBitSet_(c),t=this.getEdgeBitSet_(i),n=new Zn({copy:e}),n.assignOr(t),this.setEdgeBitSet_(c,n),e=this.getLeftEdgeBitSet_(o),t=this.getLeftEdgeBitSet_(r),n=new Zn({copy:e}),n.assignOr(t),this.setLeftEdgeBitSet_(o,n),e=this.getLeftEdgeBitSet_(c),t=this.getLeftEdgeBitSet_(i),n=new Zn({copy:e}),n.assignOr(t),this.setLeftEdgeBitSet_(c,n)}}else if(this.m_tmpHalfEdgeWindingNumberIndex!==-1){let e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(this.m_tmpHalfEdgeOddEvenNumberIndex!==-1){let e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(o,r),this.deleteEdgeImpl_(r),l=o,t[n]=z,r===a&&(t[0]=z,a=z);continue}this.updateVertexToHalfEdgeConnection_(l,!1),l=z,o=r,s=u,c=i}if(this.updateVertexToHalfEdgeConnection_(l,!1),l=z,!i){a=z;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n!==z){a=n;break}}r!==a&&this.setClusterHalfEdge_(n,a);continue}a=z;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n===z)continue;if(a===z){a=n,o=a,s=this.getHalfEdgeTo(o),c=this.getHalfEdgeTwin(o);continue}if(n===o)continue;let r=this.getHalfEdgeTwin(n),i=this.getHalfEdgeOrigin(r);this.setHalfEdgeNext_(c,n),this.setHalfEdgePrev_(n,c),o=n,s=i,c=r}this.setClusterHalfEdge_(n,a)}}}}sortHalfEdgesByAngle3D_(e){l(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,z);let t=this.m_universeChain,n=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let r=this.getClusterHalfEdge(e);if(r!==z){let e=r;do{if(this.getHalfEdgeUserIndex(e,n)!==1){let r=this.newChain_();this.setChainHalfEdge_(r,e),this.setChainPrev_(r,t),this.setChainNext_(t,r);let i=null;this.m_bBuildGeometryParentageSets&&(i=new Zn),t=r;let a=0,o=e;do this.m_tmpHalfEdgeParentageIndex!==-1&&(a|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&i.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,r),this.setHalfEdgeUserIndex(o,n,1),o=this.getHalfEdgeNext(o);while(o!==e);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(r,i),this.setChainParentage_(r,a)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==r)}}this.m_chainAreas=new it(this.m_chainData.size(),NaN),this.m_chainPerimeters=new it(this.m_chainData.size(),NaN),this.setChainArea_(this.m_universeChain,1/0),this.setChainPerimeter_(this.m_universeChain,1/0),this.deleteUserIndexForHalfEdges(n)}simplify_(e){l(0)}simplifyAlternate_(){l(0)}simplifyWinding_(){l(0)}setEditShapeImpl_(e,t,n,r,i){this.removeShape(),this.m_bBuildChains=i,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let a=this.m_shape.getTotalPointCount();if(n){a=0;for(let e=0,t=n.length;e<t;e++)a+=this.m_shape.getPointCount(n[e])}let o=new Re(0),s=0,c=0;{let e=n==null?this.m_shape.getFirstGeometry():n[0],t=1;for(;e!==z;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,c++);for(let t=this.m_shape.getFirstPath(e);t!==z;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let n=0,r=this.m_shape.getPathSize(t);n<r;n++)o.add(e),e=this.m_shape.getNextVertex(e)}b(this.m_shape.getGeometryType(e))||(s+=this.m_shape.getPathCount(e)),n==null?e=this.m_shape.getNextGeometry(e):(e=t<n.length?n[t]:z,t++)}}this.m_universeGeomID=1<<Math.min(c,31),this.m_pointCount=o.size(),this.m_shape.sortVerticesSimpleByY(o,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(r,!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,s)),this.m_clusterIndex=this.m_shape.createUserIndex();let l=U.getNAN(),u=0,d=U.getNAN();for(let e=0;e<=this.m_pointCount;e++){if(e<this.m_pointCount){let t=o.read(e);this.m_shape.queryXY(t,d)}else d.setNAN();if(!l.isEqualPoint2D(d)){if(u<e){let t=this.newCluster_(),n=z,r=-1;for(let i=u;i<e;i++){r=o.read(i),this.m_shape.setUserIndex(r,this.m_clusterIndex,t);let e=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(e,0,r),this.m_clusterVertices.setField(e,1,n),n=e;let a=this.m_shape.getPathFromVertex(r),s=this.m_shape.getGeometryFromPath(a),c=this.getGeometryID(s);this.setClusterParentage_(t,this.getClusterParentage(t)|c)}this.setClusterVertexIterator_(t,n),this.setClusterVertexIndex_(t,this.m_shape.getVertexIndex(r)),this.m_lastCluster!==z&&this.setNextCluster_(this.m_lastCluster,t),this.setPrevCluster_(t,this.m_lastCluster),this.m_lastCluster=t,this.m_firstCluster===z&&(this.m_firstCluster=t)}u=e,l.setCoordsPoint2D(d)}}if(this.m_shape.hasSegmentParentage()){this.m_clusterBreakNodeIndex===-1&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){let t=o.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){let e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(r,!0);{let e=n==null?this.m_shape.getFirstGeometry():n[0],t=1;for(;e!==z;){for(let t=this.m_shape.getFirstPath(e);t!==z;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){let e=this.m_shape.getFirstVertex(t),n=this.getClusterFromVertex(e);this.setStrongPathNode(n,!0)}if(this.m_shape.isStrongPathEnd(t)){let e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),n=this.getClusterFromVertex(e);this.setStrongPathNode(n,!0)}}n==null?e=this.m_shape.getNextGeometry(e):(e=t<n.length?n[t]:z,t++)}}if(t===tr.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===tr.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===tr.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,o),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_()){this.m_bDirtyCheckFailed=!0,this.cleanSetEditShapeImpl_();return}this.buildChains_(t),this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,r),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(e,t,n,r,i){l(0)}cleanSetEditShapeImpl_(){this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.m_tmpHalfEdgeWindingNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),this.m_tmpHalfEdgeOddEvenNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){l(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){let t=this.getHalfEdgeNext(e),n=this.getHalfEdgePrev(e),r=this.getHalfEdgeTwin(e),i=this.getHalfEdgeNext(r),a=this.getHalfEdgePrev(r);t!==r&&(this.setHalfEdgeNext_(a,t),this.setHalfEdgePrev_(t,a)),n!==r&&(this.setHalfEdgeNext_(n,i),this.setHalfEdgePrev_(i,n));let o=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(o)===e&&(i===e?this.setClusterHalfEdge_(o,z):this.setClusterHalfEdge_(o,i));let s=this.getHalfEdgeOrigin(r);this.getClusterHalfEdge(s)===r&&(t===r?this.setClusterHalfEdge_(s,z):this.setClusterHalfEdge_(s,t)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(r)}getLeftSkipPolylines_(e,t){let n=t;for(;;)if(n=e.getPrev(n),n!==-1){let t=e.getElement(n);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}else return z}checkStructureAfterDirtySweep_(){let e=Dt(this.m_checkDirtyPlanesweepTolerance),t=new U,n=new U,r=new U,i=new U,a=new U;for(let o=this.getFirstCluster();o!==z;o=this.getNextCluster(o)){let s=this.getClusterHalfEdge(o);if(s!==z){let o=s;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,n),r.setSub(n,t);let c=r.sqrLength();do{let s=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==s){this.getHalfEdgeToXY(o,i),a.setSub(i,t);let s=a.sqrLength(),l=a.crossProduct(r),u=l*l/(s*c);if(Math.min(s,c)*u<=e&&a.dotProduct(r)>=0)return!1;r.assign(a),c=s,n.assign(i)}}while(o!==s)}}return!0}extractPolygonPathFromChain_(e,t,n,r,i){let a=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(n),s=o,c=z,l=new B;do{let o=this.getHalfEdgeTwin(s);if(this.getHalfEdgeChain(o)!==n){let n=z,o=this.getHalfEdgeOrigin(s);if(r===z){let e=this.getClusterVertexIterator(o);n=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==z;e=this.incrementVertexIterator(e)){let t=this.getVertexFromVertexIterator(e);n===z&&(n=t);let i=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(i)===r){n=t;break}}c===z&&(c=e.insertPath(t,z),e.setClosedPath(c,!0));let u;if(this.m_shape===e?u=e.addVertex(c,n):(this.m_shape.queryPoint(n,l),u=e.addPoint(c,l)),this.isHalfEdgeCurve(s)&&(this.querySegmentXY(s,i),e.setSegmentToIndex(e.getVertexIndex(u),i.get().clone())),a){let t=this.getSegmentParentage(s);e.setSegmentParentageAndBreak(u,t,this.isBreakNode(o))}}s=this.getHalfEdgeNext(s)}while(s!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;l(this.m_clusterBreakNodeIndex!==-1),l(this.m_segmentParentageIndex===-1);for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let t=0,n=this.getClusterHalfEdge(e);if(n!==z){let e=n;do t++,e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e));while(e!==n&&t<3)}t!==2&&this.setBreakNode(e,!0)}let e=[],t=[],n=e,r=t;this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();let i=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let t=this.getClusterHalfEdge(e);if(t!==z){let e=!1,a=t;do{let t=a;for(;this.getHalfEdgeUserIndex(t,i)===-1;){let a=this.getHalfEdgeNext(t),o=this.getHalfEdgeTwin(t);ar(this,t,r);let s=r.at(-1).parentage;if(!e){let r=this.getHalfEdgeOrigin(t);if(!this.isBreakNode(r)){let r=this.getHalfEdgePrev(t);t!==r&&(ar(this,r,n),e=!0)}}if(e&&!ir(r,n)){let e=this.getHalfEdgeOrigin(t);this.setBreakNode(e,!0)}n=gt(r,r=n),e=!0;let c=this.getHalfEdgeOrigin(a);this.isBreakNode(c)&&(e=!1),this.setHalfEdgeUserIndex(t,this.m_segmentParentageIndex,s),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,s),this.setHalfEdgeUserIndex(t,i,1),this.setHalfEdgeUserIndex(o,i,1),t=a}a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(a!==t)}}this.deleteUserIndexForHalfEdges(i)}registerNewBitSet(e){return this.m_uniqueBitSets===null&&(this.m_uniqueBitSets=or(),this.m_uniqueBitSets.add(this.getEmptySet())),e===null?this.getEmptySet():this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){let t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return l(t>=0),l(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){let t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return l(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_edgeBitSetIndex===-1&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());let n=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);n===-1?(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t)):this.m_edgeBitSets[n]=t}setLeftEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_edgeBitSetIndexLeft===-1&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());let n=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);n===-1?(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t)):this.m_edgeBitSets[n]=t}setChainBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_chainBitSetIndex===-1&&(this.m_chainBitSetIndex=this.createUserIndexForChains());let n=this.getChainUserIndex(e,this.m_chainBitSetIndex);n===-1?(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t)):this.m_chainBitSets[n]=t}getEmptySet(){return this.m_emptyBitSet||=new Zn,this.m_emptyBitSet}deleteEdgeBitSets_(){this.m_edgeBitSetIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),this.m_edgeBitSetIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){this.m_chainBitSetIndex!==-1&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(e){}dbgVerifyEdgeSegment(e){}}class Y{m_listNodes=new rt(2);m_lists;m_listOfLists=Y.st_nullNode();m_bAllowNavigationBetweenLists=!0;freeNode_(e){this.m_listNodes.deleteElement(e)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){this.m_lists.deleteElement(e)}newList_(){return this.m_lists.newElement()}Init_(e){l(0)}constructor(e){e===void 0&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new rt(this.m_bAllowNavigationBetweenLists?4:2)}createList(){let e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==Y.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,e),this.m_listOfLists=e),e}deleteList(e){let t=this.getFirst(e);for(;t!==Y.st_nullNode();){let e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){let t=this.m_lists.getField(e,2),n=this.m_lists.getField(e,3);t===Y.st_nullNode()?this.m_listOfLists=n:this.m_lists.setField(t,3,n),n!==Y.st_nullNode()&&this.m_lists.setField(n,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);let n=this.m_lists.getField(e,1),r=this.newNode_();return n===Y.st_nullNode()?(this.m_lists.setField(e,0,r),this.m_lists.setField(e,1,r)):(this.m_listNodes.setField(n,1,r),this.m_lists.setField(e,1,r)),this.m_listNodes.setField(r,0,t),r}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,n){t===Y.st_nullNode()?(this.m_lists.setField(e,0,this.m_listNodes.getField(n,1)),this.m_lists.getField(e,1)===n&&this.m_lists.setField(e,1,Y.st_nullNode())):(this.m_listNodes.setField(t,1,this.m_listNodes.getField(n,1)),this.m_lists.getField(e,1)===n&&this.m_lists.setField(e,1,t)),this.freeNode_(n)}deleteElementSearch(e,t){let n=-1,r=this.getFirst(e);for(;r!==t;)n=r,r=this.getNext(r);this.deleteElementDirect(e,n,t)}concatenateLists(e,t){let n=this.m_lists.getField(e,1),r=this.m_lists.getField(t,0);if(r!==Y.st_nullNode()&&(n===Y.st_nullNode()?(this.m_lists.setField(e,0,r),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_listNodes.setField(n,1,r),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){let e=this.m_lists.getField(t,2),n=this.m_lists.getField(t,3);e===Y.st_nullNode()?this.m_listOfLists=n:this.m_lists.setField(e,3,n),n!==Y.st_nullNode()&&this.m_lists.setField(n,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){l(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){let t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=Y.st_nullNode()}isEmpty(e){return l(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(e){return this.m_lists.getField(e,3)}}function cr(e=-1){return{m_value:e,m_line:new I,m_segment:null,m_segmentInfo:new Se(-1),m_env:new W(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class lr extends tt{m_shape;m_bIntersectionDetected=!1;m_nonSimpleResult=new J;m_tempSimpleEdge1=cr();m_tempSimpleEdge2=cr();m_prev1=z;m_prev2=z;m_vertex1=z;m_vertex2=z;m_currentNode=-1;m_prevX1=NaN;m_prevX2=NaN;m_prevY=NaN;m_prevX=0;m_sweepY=NaN;m_sweepX=0;m_ptSweep=new U;m_tolerance;m_tolerance10;m_bIsSimple;m_bShapeHasSegments;m_simpleEdgesCache=[];m_simpleEdgesRecycle=[];m_cOutstandingConstructedEdges=0;constructor(e,t,n){super(!0),this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=n;let r=Math.trunc(Math.min(e.getTotalPointCount()*3/2,67)),i=Math.min(7,r);this.m_simpleEdgesCache.length=i}tryGetCachedEdge_(e){let t=this.m_simpleEdgesCache[(e&It())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){let t=(e&It())%this.m_simpleEdgesCache.length,n=this.m_simpleEdgesCache[t];n&&n.m_value===e&&(this.m_simpleEdgesRecycle.push(n),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){let t=(e&It())%this.m_simpleEdgesCache.length,n=this.m_simpleEdgesCache[t];return n?null:(this.m_simpleEdgesRecycle.length===0?(n=cr(),this.m_cOutstandingConstructedEdges++):n=this.m_simpleEdgesRecycle.pop(),n.m_value=e,this.m_simpleEdgesCache[t]=n,n)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=e.m_segment!==null,e.m_bCurve){let t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){let n=e.getStartXY(),r=e.getEndXY(),i=t.getStartXY(),a=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),n.isEqualPoint2D(i)&&this.m_sweepY===n.y){this.m_ptSweep.assign(r.compare(a)<0?r:a);let n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(n-i)>this.m_tolerance)return n<i?-1:1}let o=n.compare(i)<0?i:n,s=r.compare(a)<0?r:a,c=0,l=0;for(let n=1;n<5;n++){Tt(o,s,n/5,this.m_ptSweep);let r=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),a=Math.abs(r-i);a>c&&(c=a,l=r<i?-1:1)}return l===0?this.errorCracking():l}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);let n=this.compareNonHorizontalLowerEnd_(e,t),r=this.compareNonHorizontalUpperEnd_(e,t);return n<0&&r<0?-1:n>0&&r>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(e,t){let n=U.getNAN();n.setSub(t.getEndXY(),t.getStartXY()),n.rightPerpendicularThis(),n.normalize();let r=U.getNAN();r.setSub(e.getStartXY(),t.getStartXY());let i=U.getNAN();i.setSub(e.getEndXY(),t.getStartXY());let a=r.dotProduct(n),o=i.dotProduct(n),s=Math.abs(a),c=Math.abs(o);if(s<c){if(s<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(c<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return a<0&&o<0?-1:a>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let n=1;if(e.m_line.getStartY()<t.m_line.getStartY()){n=-1;let r=e;e=t,t=r}let r=e.m_line,i=t.m_line,a=r.getStartX()-i.getStartX(),o=t.m_dxdy*(r.getStartY()-i.getStartY()),s=this.m_tolerance10;return a<o-s?-n:a>o+s?n:i.isIntersectingPoint(r.getStartXY(),this.m_tolerance,!0)?this.errorCracking():a<o?-n:n}compareNonHorizontalUpperEnd_(e,t){let n=1;if(t.m_line.getEndY()<e.m_line.getEndY()){n=-1;let r=e;e=t,t=r}let r=e.m_line,i=t.m_line,a=r.getEndX()-i.getStartX(),o=t.m_dxdy*(r.getEndY()-i.getStartY()),s=this.m_tolerance10;return a<o-s?-n:a>o+s?n:i.isIntersectingPoint(r.getEndXY(),this.m_tolerance,!0)?this.errorCracking():a<o?-n:n}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new J(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){return this.m_bIntersectionDetected=!0,this.m_bIsSimple?this.m_nonSimpleResult=new J(6,this.m_vertex1,this.m_vertex2):(this.m_prev1=z,this.m_prev2=z,this.m_vertex1=z,this.m_vertex2=z),-1}compareSegments_(e,t,n,r){if(n.m_env.vmax<r.m_env.vmin)return-1;if(r.m_env.vmax<n.m_env.vmin)return 1;if(!n.m_bCurve&&!r.m_bCurve){let e=+!!n.m_bHorizontal;return e|=r.m_bHorizontal?2:0,e===0?this.compareNonHorizontal_(n,r):e===1?this.compareHorizontal1_(n.m_line,r.m_line):e===2?this.compareHorizontal1_(r.m_line,n.m_line)*-1:this.compareHorizontal2_(n.m_line,r.m_line)}if(this.m_bIntersectionDetected)return-1;let i=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX,a;i&&e===this.m_prev1?a=this.m_prevX1:(a=NaN,this.m_prev1=z);let o;if(i&&t===this.m_prev2?o=this.m_prevX2:(o=NaN,this.m_prev2=z),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(a)){this.m_prev1=e;let t=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=t,this.m_prevX1=t}if(Number.isNaN(o)){this.m_prev2=t;let e=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX2=e}let s=de(!0,!0,n.m_segment,r.m_segment,this.m_tolerance,!0);return s===0?Math.abs(a-o)<=this.m_tolerance?this.compareTwoSegments_(n.m_segment,r.m_segment):a<o?-1:+(a>o):s===2?this.m_bIsSimple?this.errorCoincident():n.m_segmentInfo.equals(r.m_segmentInfo)?0:this.errorCracking():this.errorCracking()}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=z,this.m_prev2=z,this.m_vertex1=z,this.m_vertex2=z}compare(e,t,n){if(this.m_bIntersectionDetected)return-1;let r=e.getElement(n),i=t;return this.m_currentNode=n,this.compareSegments(i,i,r,r)}compareSegments(e,t,n,r){let i=this.tryGetCachedEdge_(e);i===null?this.m_vertex1===t?i=this.m_tempSimpleEdge1:(this.m_vertex1=t,i=this.tryCreateCachedEdge_(e),i===null&&(i=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(i,t)):this.m_vertex1=t;let a=this.tryGetCachedEdge_(n);return a===null?this.m_vertex2===r?a=this.m_tempSimpleEdge2:(this.m_vertex2=r,a=this.tryCreateCachedEdge_(n),a===null&&(a=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=n),this.initSimpleEdge_(a,r)):this.m_vertex2=r,this.compareSegments_(t,r,i,a)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class ur{m_shape;m_bIntersectionDetected=!1;m_pointOfInterest=U.getNAN();m_line1=new I;m_seg1=null;m_env=W.constructEmpty();m_vertex1=-1;m_currentNode=-1;m_minDist=Number.MAX_VALUE;m_tolerance;constructor(e,t){this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){let n=e.getElement(t);return this.compareVertex(e,t,n)}compareVertex(e,t,n){let r=this.m_shape.getSegment(n),i,a=!0;if(r==null)this.m_shape.queryLineConnector(n,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),r=this.m_line1,i=this.m_line1.getStartY()===this.m_line1.getEndY();else{let e=T.constructEmpty();r.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),i=e.height()===0,a=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(i)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let o=0;if(a){me(this.m_line1);let e=this.m_line1.getStartXY(),t=new U;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();let n=new U;n.setSub(this.m_pointOfInterest,e),o=t.dotProduct(n),o/=t.length()}else o=r.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x;return o<-this.m_tolerance*10?-1:o>this.m_tolerance*10?1:(r.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(o)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=o),this.m_bIntersectionDetected=!0),o<0?-1:+(o>0))}}class dr{m_bitFilter;m_hashBuckets;m_lists=new Y(!1);m_hash;constructor(e,t){this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(dr.st_nullNode()),this.m_bitFilter=new Int32Array(e*10+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){t===void 0&&(t=this.m_hash.getHash(e));let n=t%(this.m_bitFilter.length<<5);this.m_bitFilter[n>>5]|=1<<(n&31);let r=t%this.m_hashBuckets.length,i=this.m_hashBuckets[r];return i===Y.st_nullNode()&&(i=this.m_lists.createList(),this.m_hashBuckets[r]=i),this.m_lists.addElement(i,e)}deleteElement(e,t){t===void 0&&(t=this.m_hash.getHash(e));let r=t%this.m_hashBuckets.length,i=this.m_hashBuckets[r];i===Y.st_nullNode()&&n(``);let a=this.m_lists.getFirst(i),o=Y.st_nullNode();for(;a!==Y.st_nullNode();){let t=this.m_lists.getData(a),n=this.m_lists.getNext(a);t===e?(this.m_lists.deleteElementDirect(i,o,a),this.m_lists.getFirst(i)===Y.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[r]=Y.st_nullNode())):o=a,a=n}}getFirstInBucket(e){let t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(t&31)))return Y.st_nullNode();let n=e%this.m_hashBuckets.length,r=this.m_hashBuckets[n];return r===Y.st_nullNode()?Y.st_nullNode():this.m_lists.getFirst(r)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){let t=this.m_hash.getHash(e),n=this.getFirstInBucket(t);for(;n!==Y.st_nullNode();){let t=this.m_lists.getData(n);if(this.m_hash.equal(t,e))return n;n=this.m_lists.getNext(n)}return Y.st_nullNode()}deleteNode(e){let t=this.getElement(e),r=this.m_hash.getHash(t)%this.m_hashBuckets.length,i=this.m_hashBuckets[r];i===Y.st_nullNode()&&n(``),this.m_lists.deleteElementSearch(i,e),this.m_lists.getFirst(i)===Y.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[r]=Y.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return Y.st_nullNode()}clear(){l(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function fr(e,t,n,r,i){let a=new br(i);return a.m_shape=e,a.m_sqrTolerance=t*t,a.m_cellSize=2*t,a.m_invCellSize=1/a.m_cellSize,a.m_geometry=n,a.m_bTrackChanges=r,a.m_bHasSegmentParentage=e.hasSegmentParentage(),a.clusterNonReciprocal()}function pr(e,t,n,r,i){let a=e-n,o=t-r;return a*a+o*o<=i}function mr(){return{pt:new U,weight:0,rank:0,bMerged:!1}}function hr(e,t,n,r,i,a){let o=mr(),s=n+i,c=!1,l=e.x;e.x!==t.x&&(r===a&&(l=(e.x*n+t.x*i)/s),c=!0);let u=e.y;return e.y!==t.y&&(r===a&&(u=(e.y*n+t.y*i)/s),c=!0),r===a?(o.pt.setCoords(l,u),o.weight=s,o.rank=r):r>a?(o.rank=r,o.weight=n,o.pt=e):(o.rank=a,o.weight=i,o.pt=t),o.bMerged=c,o}function gr(e,t,n,r,i,a,o,s,c){let l=e.equals(t);if(r>a)return o.assignCopy(e),c[0]=r,s[0]=n,l;if(a>r)return o=t,c[0]=a,s[0]=i,l;o.assignCopy(e);let u=hr(e.getXY(),t.getXY(),n,r,i,a);return o.setXY(u.pt),s[0]=u.weight,c[0]=u.rank,l}function _r(e,t,n,r,i){let a=new br(i);return a.m_shape=e,a.m_sqrTolerance=t*t,a.m_cellSize=2*t,a.m_invCellSize=1/a.m_cellSize,a.m_geometry=n,a.m_bTrackChanges=!1,a.needsClustering()}function vr(e,t){let n=en(e);return Xt(n,t)}class yr{m_shape;m_sqrTolerance;m_invCellSize;m_origin;m_hashValues;m_workPt=new U;constructor(e,t,n,r,i){this.m_shape=e,this.m_sqrTolerance=n,this.m_invCellSize=r,this.m_origin=t.clone(),this.m_hashValues=i}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);let t=this.m_workPt.x-this.m_origin.x,n=Math.trunc(t*this.m_invCellSize+.5),r=this.m_workPt.y-this.m_origin.y;return vr(n,Math.trunc(r*this.m_invCellSize+.5))}equal(e,t){return l(0),!1}}class br{m_origin=U.getNAN();m_sqrTolerance=0;m_cellSize=0;m_invCellSize=0;m_geometry=z;m_bucketArray=H(4,NaN);m_bucketHash=H(4,NaN);m_dbgCandidateCheckCount=0;m_progressTracker;m_nsr=new J;m_hashValues=-1;m_newClusters=-1;m_bTrackChanges=!1;m_bHasSegmentParentage=!1;m_shape=null;m_clusters=new Y;m_hashFunction=null;m_hashTable=null;m_progressCounter=0;constructor(e){this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){let n=U.getNAN();this.m_shape.queryXY(e,n);let r=(n.x-this.m_origin.x)*this.m_invCellSize,i=(n.y-this.m_origin.y)*this.m_invCellSize,a=Math.trunc(r),o=Math.trunc(i),s=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1){let n=vr(a+e,o+t),r=this.m_hashTable.getFirstInBucket(n);r!==dr.st_nullNode()&&(this.m_bucketArray[s]=r,this.m_bucketHash[s]=n,s++)}for(let e=s-1;e>=1;e--){let t=this.m_bucketArray[e];for(let n=e-1;n>=0;n--)if(t===this.m_bucketArray[n]){this.m_bucketHash[n]=-1,s--,e!==s&&(this.m_bucketHash[e]=this.m_bucketHash[s],this.m_bucketArray[e]=this.m_bucketArray[s]);break}}for(let r=0;r<s;r++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[r],n,this.m_bucketArray[r],t)}collectNearestNeighbourCandidates(e,t,n,r,i){let a=U.getNAN();for(let o=r;o!==dr.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){let r=this.m_hashTable.getElement(o);e===r||t!==-1&&this.m_shape.getUserIndex(r,this.m_hashValues)!==t||(this.m_shape.queryXY(r,a),pr(n.x,n.y,a.x,a.y,this.m_sqrTolerance)&&i.push(o))}}mergeClusters(e,t,n){let r=this.m_shape.getUserIndex(e,this.m_newClusters),i=this.m_shape.getUserIndex(t,this.m_newClusters);r===-1&&(r=this.m_clusters.createList(),this.m_clusters.addElement(r,e),this.m_shape.setUserIndex(e,this.m_newClusters,r)),i===-1?this.m_clusters.addElement(r,t):this.m_clusters.concatenateLists(r,i),this.m_shape.setUserIndex(t,this.m_newClusters,rt.impossibleIndex2());let a=this.mergeVertices(e,t);if(n){let t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return a}mergeVertices(e,t){let n=U.getNAN();this.m_shape.queryXY(e,n);let r=U.getNAN();this.m_shape.queryXY(t,r);let i=this.m_shape.getRank(e),a=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),s=this.m_shape.getWeight(t),c,l,u,d,f=!1;if(i===a?(c=i,l=o+s,u=n.x,n.x!==r.x&&(u=(n.x*o+r.x*s)/l,f=!0),d=n.y,n.y!==r.y&&(d=(n.y*o+r.y*s)/l,f=!0)):(i>a?(u=n.x,d=n.y,l=o,c=i):(u=r.x,d=r.y,l=s,c=a),f=!n.equals(r)),f&&(this.m_shape.setXYMonotonic(e,u,d),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){let n=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,n),this.m_shape.setSegmentParentageBreakVertex(t,n)}return this.m_shape.setWeight(e,l),this.m_shape.setRank(e,c),f}needsClustering(){let n={stack:[],error:void 0,hasError:!1};try{e(n,Et(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);let t=this.m_shape.getSelectedCount(),r=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(r.getLowerLeft());let i=Math.max(r.height(),r.width())/(Ut()-1);this.m_cellSize<i&&(this.m_cellSize=i,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 yr(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new dr(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let a=!1;for(let e=0;e<2;e++){let t=[],n=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let r=n.next();r!==z;r=n.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(r,this.m_newClusters)===rt.impossibleIndex2())continue;let n;if(e===0?(n=this.m_hashFunction.calculateHashFromVertex(r),this.m_shape.setUserIndex(r,this.m_hashValues,n)):n=this.m_shape.getUserIndex(r,this.m_hashValues),this.collectClusterCandidates(r,t),t.length!==0){for(let e=0,n=t.length;e<n;e++){this.progress_();let n=t[e],i=this.m_hashTable.getElement(n);if(this.m_hashTable.deleteNode(n),!this.m_shape.isEqualXY(r,i))return this.m_nsr=new J(5,this.m_shape.getVertexIndex(r),this.m_shape.getVertexIndex(i)),a=!0,a;this.mergeClusters(r,i,!1)}t.length=0}e===0&&this.m_hashTable.addElement(r,n)}}return a}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}clusterNonReciprocal(){let e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();let n=Math.max(t.height(),t.width())/(Ut()-1);this.m_cellSize<n&&(this.m_cellSize=n,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 yr(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new dr(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let r=!1;{let e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==z;t=e.next()){this.progress_();let e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{let e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=t.next();n!==z;n=t.next()){if(this.m_shape.getUserIndex(n,this.m_newClusters)===rt.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(n,this.m_hashValues);this.m_hashTable.deleteElement(n,t);let i=!1;for(;this.collectClusterCandidates(n,e),e.length!==0;){let t=0;for(let r=0,i=e.length;r<i;r++){this.progress_();let a=e[r],o=this.m_hashTable.getElement(a);this.m_hashTable.deleteNode(a);let s=r+1===i;t|=+!!this.mergeClusters(n,o,s)}if(i||=t!==0,r||=t!==0,e.length=0,!t)break}i&&(t=this.m_shape.getUserIndex(n,this.m_hashValues)),this.m_hashTable.addElement(n,t)}e.length=0}return r&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),r}applyClusterPositions_(){let e=U.getNAN();for(let t=this.m_clusters.getFirstList();t!==Y.st_nullNode();t=this.m_clusters.getNextList(t)){let n=this.m_clusters.getFirst(t),r=this.m_clusters.getElement(n);this.m_shape.queryXY(r,e);let i=this.m_shape.getRank(r),a=this.m_shape.getWeight(r);for(n=this.m_clusters.getNext(n);n!==Y.st_nullNode();n=this.m_clusters.getNext(n)){let t=this.m_clusters.getElement(n);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentageBreakVertex(r)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(r,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,a),this.m_shape.setRank(t,i)}}}}class xr{static maxWeight=Number.MAX_VALUE*.1;static c_smallToleranceFactor=.01;static c_maxGeometryTypeToRankDelta=8;m_inputParts=[];m_resultParts1=[];m_resultParts2=[];m_resultSegments=[];m_freeSegments=[];m_inputSegments=[];m_param1=[];m_param2=[];m_tolerance=0;m_toleranceZ=0;m_point=new B;m_pointWeight=1;m_maxDensifyLimit=0;m_pointRank=0;m_changed1=!1;m_changed2=!1;m_adaptiveDensify=!1;clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(e,t,n,r,i,a,o,s,c,l){return Cr(e,t,n,r,i,a,o,s,c,l)}pushSegment(e,t,n,r,i,a,o,s,c,l){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,n,r,i,a,o,s,c,l)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?e===0?this.m_param1.length-1:this.m_param2.length-1:e===0?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return e===0?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return e===0?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){this.m_inputSegments.length!==2&&o(``),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;let n=Dt(e*xr.c_smallToleranceFactor),r=!1,i=this.m_inputParts[0],a=this.m_inputParts[1],s=this.m_inputSegments[i.segmentIndex],c=this.m_inputSegments[a.segmentIndex];if(t||L(!0,s,c,e,!0)&5){let t=pe(!0,s,c,null,this.m_param1,this.m_param2,e);t===0&&o(``);let l=Array(t);for(let e=0;e<t;++e)l[e]=U.getNAN();let u=new Float64Array(t),d=new Int32Array(t),f=Array(t),p=Array(t);for(let e=0;e<t;++e)f[e]=wr(),p[e]=wr();for(let e=0;e<t;e++){let t=this.m_param1[e],o=this.m_param2[e],m=i.rankInterior,h=i.weightInterior,g;t===0?(m=i.rankStart,h=i.weightStart,g=i.u.bBreakStart):t===1?(m=i.rankEnd,h=i.weightEnd,g=i.u.bBreakEnd):(this.m_changed1=!0,g=!1);let _=a.rankInterior,v=a.weightInterior,y;o===0?(_=a.rankStart,v=a.weightStart,y=a.u.bBreakStart):o===1?(_=a.rankEnd,v=a.weightEnd,y=a.u.bBreakEnd):(this.m_changed2=!0,y=!1);let b=m,x=_,S=1,C=0,w=U.getNAN();if(b===x){let r=s.getCoord2D(t),i=c.getCoord2D(o);S=h+v;let a=v/S;C=m,Tt(r,i,a,w);let l=U.sqrDistance(w,r),u=U.sqrDistance(w,i);f[e].bBigMove=l>n,p[e].bBigMove=u>n,!this.m_changed1&&!r.equals(w)&&(this.m_changed1=!0),!this.m_changed2&&!i.equals(w)&&(this.m_changed2=!0)}else if(b>x){w=s.getCoord2D(t);let r=c.getCoord2D(o);S=h,C=m;let i=U.sqrDistance(w,r);f[e].bBigMove=!1,p[e].bBigMove=i>n,!this.m_changed2&&!r.equals(w)&&(this.m_changed2=!0)}else{w=c.getCoord2D(o),S=v,C=_;let r=s.getCoord2D(t),i=U.sqrDistance(w,r);f[e].bBigMove=i>n,p[e].bBigMove=!1,!this.m_changed1&&!r.equals(w)&&(this.m_changed1=!0)}l[e].assign(w),u[e]=S,d[e]=C,f[e].bIsBreak=g||y,p[e].bIsBreak=g||y,r||=f[e].bBigMove||p[e].bBigMove}let m=i.rankInterior,h=i.weightInterior,g=0,_=-1;for(let n=0;n<=t;n++){let r=n<t?this.m_param1[n]:1;if(r!==g){let a=this.allocResultSegment(),o=this.m_resultSegments[a];s.queryCut(g,r,o,!1),o.get().snapControlPoints(e*e);let c,p,v,y,b=!1,x=!1,S=!1,C=!1,w=!1,T=U.getNAN(),E=U.getNAN();_===-1?(c=i.weightStart,p=i.rankStart,T=o.get().getStartXY(),S=i.u.bBreakStart):(p=d[_],c=u[_],b=f[_].bBigMove,T.assign(l[_]),S=f[_].bIsBreak,w=!0),n<t?(y=d[n],v=u[n],x=f[n].bBigMove,E.assign(l[n]),C=f[n].bIsBreak,w=!0):(v=i.weightEnd,y=i.rankEnd,E=o.get().getEndXY(),C=i.u.bBreakEnd),w&&o.get().setCoordsForIntersector(T,E,!0),this.m_resultParts1.push(this.newIntersectionPart_(a,c,p,v,y,h,m,S,C,i.segmentParentage));let D=this.m_resultParts1.at(-1);D.u.bBigMoveStart=b,D.u.bBigMoveEnd=x,g=r,_=n}else _===-1&&(_=n)}let v=H(t,0);for(let e=0;e<t;e++)v[e]=e;t>2?(v.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:+(this.m_param2[e]>this.m_param2[t])),dt(this.m_param2)):t===2&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=gt(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),v[1]=gt(v[0],v[0]=v[1]));let y=a.rankInterior,b=a.weightInterior;g=0,_=-1;for(let n=0;n<=t;n++){let r=n<t?this.m_param2[n]:1;if(r!==g){let i=this.allocResultSegment(),o=this.m_resultSegments[i];c.queryCut(g,r,o,!1),o.get().snapControlPoints(e*e);let s,f,m,h,x=U.getNAN(),S=U.getNAN(),C=!1,w=!1,T=!1,E=!1,D=!1;if(_!==-1){let e=v[_];s=u[e],f=d[e],x.assign(l[e]),T=p[e].bBigMove,C=p[e].bIsBreak,D=!0}else s=a.weightStart,f=a.rankStart,x=o.get().getStartXY(),C=a.u.bBreakStart;if(n!==t){let e=v[n];m=u[e],h=d[e],S.assign(l[e]),E=p[e].bBigMove,w=p[e].bIsBreak,D=!0}else m=a.weightEnd,h=a.rankEnd,S=o.get().getEndXY(),w=a.u.bBreakEnd;D&&o.get().setCoordsForIntersector(x,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(i,s,f,m,h,b,y,C,w,a.segmentParentage));let O=this.m_resultParts2.at(-1);O.u.bBigMoveStart=T,O.u.bBigMoveEnd=E,g=r,_=n}else _===-1&&(_=n)}return r?3:2}return 0}intersectLines3D(e,t,n,r){return l(0),1}intersect2D(e,t){let n=this.m_inputParts[0],r=this.m_inputParts[1],a=this.m_inputSegments[n.segmentIndex].getGeometryType(),o=this.m_inputSegments[r.segmentIndex].getGeometryType();return a!==i.enumLine||o!==i.enumLine?new Or(this).intersectCurves(e,t):this.intersectLines(e,t)}intersect2DEx(e,t,n,r,i){this.m_point.assignCopy(t),this.m_inputSegments.length!==1&&o(``),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;let a=Dt(e*xr.c_smallToleranceFactor),s=!1,c=this.m_inputParts[0],l=this.m_inputSegments[c.segmentIndex];if(i||l.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=H(16,NaN);let i=l.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=i;let o=c.rankInterior,u=c.weightInterior;i===0?(o=c.rankStart,u=c.weightStart):i===1?(o=c.rankEnd,u=c.weightEnd):this.m_changed1=!0;let d=o,f=n,p=r;d===f&&l.isCurve()&&(d=f+1);let m=1,h=0,g=new U;if(d===f){let e=l.getCoord2D(i),n=t.getXY();m=u+p,h=o;let r=p/m;Tt(e,n,r,g),!this.m_changed1&&!e.equals(g)&&(this.m_changed1=!0),!this.m_changed2&&!n.equals(g)&&(this.m_changed2=!0),s=U.sqrDistance(g,e)>a}else d>f?(g.assign(l.getCoord2D(i)),m=u,h=o,!this.m_changed2&&!g.equals(t.getXY())&&(this.m_changed2=!0)):(g.assign(l.getCoord2D(i)),m=p,h=f,!this.m_changed1&&!g.equals(t.getXY())&&(this.m_changed1=!0),s=U.sqrDistance(g,t.getXY())>a);let _=0,v=-1;for(let t=0;t<=1;t++){let n=t<1?this.m_param1[0]:1;if(n!==_){let r=this.allocResultSegment(),i=this.m_resultSegments[r];l.queryCut(_,n,i),i.get().snapControlPoints(e*e);let a=c.weightStart,o=c.weightEnd,s=c.rankStart,u=c.rankEnd,d=c.rankInterior,f=c.weightInterior,p=c.u.bBreakStart,y=c.u.bBreakEnd;v!==-1&&(a=m,s=h,p=!0,i.get().setCoordsForIntersector(g,i.get().getEndXY(),!0)),t!==1&&(o=m,u=h,y=!0,i.get().setCoordsForIntersector(i.get().getStartXY(),g,!0)),_=n,this.m_resultParts1.push(this.newIntersectionPart_(r,a,s,o,u,f,d,p,y,c.segmentParentage))}v=t}return this.m_point.setXY(g),this.m_pointWeight=m,this.m_pointRank=h,s?3:2}return 0}intersect3D(e,t,n,r){return l(0),1}intersect3DEx(e,t,n,r,i,a,o){return l(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let e=new F,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let t=new F({copy:e}),n=this.m_resultSegments.length;return this.m_resultSegments.push(t),n}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let t=new F({segment:e}),n=this.m_resultSegments.length;return this.m_resultSegments.push(t),n}}function Sr(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function Cr(e,t,n,r,i,a,o,s,c,l){return{segmentIndex:e,weightStart:t,rankStart:n,weightEnd:r,rankEnd:i,weightInterior:a,rankInterior:o,segmentParentage:l,u:Sr(s,c)}}function wr(){return{bBigMove:!1,bIsBreak:!1}}let Tr=class{start=null;end=null;equalEdge=null;segmentIndex=-1;segmentParentage=-1;weight=0;rank=0;hasSegment(){return this.segmentIndex>=0}transferAttributes(e,t,n){if(t.getDescription().getAttributeCount()===1)return;let r=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),i=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),a=new B;t.queryStart(a),n?(a.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setStart(a)):(a.setXY(i),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(a)),t.queryEnd(a),n?(a.setXY(i),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(a)):(a.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setStart(a))}copyFromWhenOverlap(e,t,n){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,n?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class Er{hash=0;pt=new U;prevInChain=null;nextInChain=null;prevInHash=null;nextInHash=null;prevEqual=null;nextEqual=null;weight=0;rank=0;bBigMove=!1;bIsBreak=!1;copyFrom(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;e.prevEqual!==null;e=e.prevEqual);return e}}function Dr(e,t,n,r){return{edge1:e,edge2:t,recursion:n,bIsIntersecting:r}}class Or{parent;m_pairs=[];m_chainOrigin1=null;m_chainOrigin2=null;m_newNodes=[];m_hashTableOfEquals=[];m_hashTableOfEqualsSize=0;m_origin=new U;m_cell=new U;constructor(e){this.parent=e}addSegment(e,t,n,r,i,a,o,s,c,u,d){let f=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),n,r,c),p=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),i,a,u);this.newEdge(f,p,e,o,s,d),this.m_chainOrigin1===null?this.m_chainOrigin1=f:this.m_chainOrigin2===null?this.m_chainOrigin2=f:l(0)}intersectCurvesHelper(e,t,n,r,a){let s=this.getSegment(e).get(),c=this.getSegment(t).get();if(s.isDegenerate(0)||c.isDegenerate(0))return 0;let u=this.tryOverlapIntersectCurves(e,t,n,r);if(u!==0)return u;let d=Dt(n*.01),f=!1,p=this.processSharpCorners(s,c,n,a>4),m=p>0;if(!m){if(!r&&!(de(!0,!1,s,c,n,!0)&5))return 0;p=pe(!0,s,c,null,this.parent.m_param1,this.parent.m_param2,n)}p===0&&o(``);let h=s.getGeometryType(),g=c.getGeometryType(),_=bt(U,p),v=bt(U,p),y=H(p,NaN),b=H(p,NaN),x=H(p,NaN),S=H(p,NaN),C=Wt(wr,p),w=Wt(wr,p),T=!1,E=!1;for(let r=0;r<p;r++){let i=this.parent.m_param1[r],a=this.parent.m_param2[r],o=e.rank,l=e.weight,u=!0,p=!1;i===0?(o=e.start.rank,l=e.start.weight,p=e.start.bIsBreak):i===1?(o=e.end.rank,l=e.end.weight,p=e.end.bIsBreak):(T=!0,u=!1);let D=t.rank,O=t.weight,k=!1,A=!0;a===0?(D=t.start.rank,O=t.start.weight,k=t.start.bIsBreak):a===1?(D=t.end.rank,O=t.end.weight,k=t.end.bIsBreak):(E=!0,A=!1);let j=o,M=D;if(j===M&&(j*=xr.c_maxGeometryTypeToRankDelta,M*=xr.c_maxGeometryTypeToRankDelta,j+=kr(h,s,!1),M+=kr(g,c,!1)),u&&A&&M===j){let e=s.getCoord2D(i),t=c.getCoord2D(a);e.equals(t)&&(M=j-1)}let N=1,P=0,F=1,I=0,L=new U,R=new U,ee=s.getCoord2D(i),z=c.getCoord2D(a);if(m&&U.distance(ee,z)>n)L.setCoordsPoint2D(ee),R.setCoordsPoint2D(z),N=l,F=O,P=o,I=D,C[r].bBigMove=!1,w[r].bBigMove=!1,p=!0,k=!0;else if(j===M){F=N=l+O,I=P=o;let e=O/N;Tt(ee,z,e,L),R.setCoordsPoint2D(L);let t=U.sqrDistance(L,ee),n=U.sqrDistance(L,z);C[r].bBigMove=t>d,w[r].bBigMove=n>d,!T&&!ee.equals(L)&&(T=!0),!E&&!z.equals(R)&&(E=!0)}else if(j>M){L.setCoordsPoint2D(ee),R.setCoordsPoint2D(L),F=N=l,I=P=o;let e=U.sqrDistance(L,z);C[r].bBigMove=!1,w[r].bBigMove=e>d,!E&&!z.equals(R)&&(E=!0)}else{R.setCoordsPoint2D(z),L.setCoordsPoint2D(R),F=N=O,I=P=D;let e=U.sqrDistance(L,ee);C[r].bBigMove=e>d,w[r].bBigMove=!1,!T&&!ee.equals(L)&&(T=!0)}_[r].assign(L),v[r].assign(R),y[r]=N,b[r]=F,x[r]=P,S[r]=I,C[r].bIsBreak=p||k,w[r].bIsBreak=p||k,f||=C[r].bBigMove||w[r].bBigMove,r>0&&(i===this.parent.m_param1[r-1]||a===this.parent.m_param2[r-1])&&(x[r]<=x[r-1]?(_[r].assign(v[r-1]),y[r]=b[r-1],x[r]=S[r-1],v[r].assign(v[r-1]),b[r]=b[r-1],S[r]=S[r-1],C[r].bBigMove||=C[r-1].bBigMove,w[r].bBigMove||=w[r-1].bBigMove,C[r].bIsBreak||=C[r-1].bIsBreak,w[r].bIsBreak||=w[r-1].bIsBreak):(_[r-1].assign(_[r]),y[r-1]=y[r],x[r-1]=x[r],v[r-1].assign(v[r]),b[r-1]=b[r],S[r-1]=S[r],C[r-1].bBigMove||=C[r].bBigMove,w[r-1].bBigMove||=w[r].bBigMove,C[r-1].bIsBreak||=C[r].bIsBreak,w[r-1].bIsBreak||=w[r].bIsBreak))}if(!T&&!E&&p===2&&(h!==i.enumLine||g!==i.enumLine)){if(this.processDoublyConnectedEdges(e,t,a+1,n))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;l(0)}this.parent.m_changed1||=T,this.parent.m_changed2||=E;let D=e,O=e.end.weight,k=e.end.rank,A=e.end.bBigMove,j=e.end.bIsBreak,M=0,N=-1;for(let t=0;t<=p;t++){let r=t<p?this.parent.m_param1[t]:1;if(r!==M){let i=this.parent.allocResultSegment(),a=this.parent.m_resultSegments[i];s.queryCut(M,r,a,!1),a.get().snapControlPoints(n*n);let o,c,l,u,d=!1,f=!1,m=!1,h=!1,g=new U,v=new U;N===-1?(o=e.start.weight,c=e.start.rank,m=e.start.bBigMove,d=e.start.bIsBreak,g.assign(a.get().getStartXY())):(c=x[N],o=y[N],m=C[N].bBigMove,d=C[N].bIsBreak,g.assign(_[N])),t<p?(u=x[t],l=y[t],h=C[t].bBigMove,f=C[t].bIsBreak,v.assign(_[t])):(l=O,u=k,h=A,f=j,v.assign(a.get().getEndXY()));let b=D;r<1&&(this.splitEdgeInPlace(D),b=D.getNextInChain()),this.updateSegmentOnly(D,i),D.start.hash!==0&&!D.start.pt.equals(g)&&(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),D.end.hash!==0&&!D.end.pt.equals(v)&&(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(g),D.end.pt.assign(v),D.start.bBigMove||=m,D.end.bBigMove||=h,D.start.bIsBreak||=d,D.end.bIsBreak||=f,D.start.weight=o,D.start.rank=c,D.end.weight=l,D.end.rank=u,D=b,M=r,N=t}else N===-1&&(N=t)}let P=D.getNextInChain(),F=[];F.length=p;for(let e=0;e<p;e++)F[e]=e;p>2?(F.sort((e,t)=>Gt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Gt)):p===2&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=gt(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),F[1]=gt(F[0],F[0]=F[1])),D=t,O=t.end.weight,k=t.end.rank,A=t.end.bBigMove,j=t.end.bIsBreak,M=0,N=-1;for(let e=0;e<=p;e++){let r=e<p?this.parent.m_param2[e]:1;if(r!==M){let i=this.parent.allocResultSegment(),a=this.parent.m_resultSegments[i];c.queryCut(M,r,a,!1),a.get().snapControlPoints(n*n);let o,s,l,u,d=new U,f=new U,m=!1,h=!1,g=!1,_=!1;if(N!==-1){let e=F[N];o=b[e],s=S[e],d.assign(v[e]),g=w[e].bBigMove,m=w[e].bIsBreak}else o=t.start.weight,s=t.start.rank,g=t.start.bBigMove,m=t.start.bIsBreak,d.assign(a.get().getStartXY());if(e!==p){let t=F[e];l=b[t],u=S[t],f.assign(v[t]),_=w[t].bBigMove,h=w[t].bIsBreak}else l=O,u=k,_=A,h=j,f.assign(a.get().getEndXY());let y=D;r<1&&(this.splitEdgeInPlace(D),y=D.getNextInChain()),this.updateSegmentOnly(D,i),D.start.hash!==0&&!D.start.pt.equals(d)&&(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),D.end.hash!==0&&!D.end.pt.equals(f)&&(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(d),D.end.pt.assign(f),D.start.bBigMove||=g,D.end.bBigMove||=_,D.start.bIsBreak||=m,D.end.bIsBreak||=h,D.start.weight=o,D.start.rank=s,D.end.weight=l,D.end.rank=u,D=y,M=r,N=e}else N===-1&&(N=e)}let I=D.getNextInChain();return this.postProcessResultPartsForCurves(e,P,t,I,a+1),f?3:2}intersectCurves(e,t){this.parent.m_inputSegments.length!==2&&o(``),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=ut(16);let n=T.constructEmpty();for(let e=0;e<2;e++){let t=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex]),r=T.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex].queryLooseEnvelope(r),n.mergeEnvelope2D(r);let i=this.parent.m_inputParts[e];this.addSegment(t,0,i.weightStart,i.rankStart,i.weightEnd,i.rankEnd,i.weightInterior,i.rankInterior,i.u.bBreakStart,i.u.bBreakEnd,i.segmentParentage)}n.inflateCoords(100*e,100*e),this.m_origin.assign(n.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(Dr(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let r=0,i=!0;for(;this.m_pairs.length;){let t=this.m_pairs.at(-1);this.m_pairs.pop(),l(t.recursion>=0),l(t.recursion<=256),this.clusterNodes(e);let n=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,r=n)}for(let e=0;e<2;e++){let t=e===0?this.parent.m_resultParts1:this.parent.m_resultParts2,n=e===0?this.m_chainOrigin1:this.m_chainOrigin2;for(let e=n.nextInChain;e!=null;e=e.getNextInChain())t.push(this.parent.newIntersectionPart_(e.segmentIndex,e.start.weight,e.start.rank,e.end.weight,e.end.rank,e.weight,e.rank,e.start.bIsBreak,e.end.bIsBreak,e.segmentParentage)),t.at(-1).u.bBigMoveStart=e.start.bBigMove,t.at(-1).u.bBigMoveEnd=e.end.bBigMove}return r}tryOverlapIntersectCurves(e,t,n,r){let i=this.parent.m_resultSegments[e.segmentIndex].get(),a=this.parent.m_resultSegments[t.segmentIndex].get(),o=i.getStartXY().equals(a.getStartXY())&&i.getEndXY().equals(a.getEndXY()),s=i.getStartXY().equals(a.getEndXY())&&i.getEndXY().equals(a.getStartXY());if(!o&&!s)return 0;let c=ye(i,a,!0);if(c!==0&&be(i,a)&&e.segmentParentage===t.segmentParentage){let e=!1;if(c>0)e=i.equals(a);else{l(c===-1);let t=new F({segment:a});t.get().reverse(),e=i.equals(t.get())}if(e)return 1}let u=n*xr.c_smallToleranceFactor,d=!1;if(c===0){let e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,r=e.length;t<r;++t){let r=e[t],o=new U;i.queryCoord2D(r,o);let s=a.getClosestCoordinate(o,!1),c=new U;a.queryCoord2D(s,c);let l=U.distance(o,c);if(l>n)return 0;d||=l>u}for(let t=0,r=e.length;t<r;++t){let r=e[t],o=new U;a.queryCoord2D(r,o);let s=i.getClosestCoordinate(o,!1),c=new U;i.queryCoord2D(s,c);let l=U.distance(o,c);if(l>n)return 0;d||=l>u}}let f=e.rank,p=t.rank,m=f,h=p;return m===h&&(m*=xr.c_maxGeometryTypeToRankDelta,h*=xr.c_maxGeometryTypeToRankDelta,m+=kr(i.getGeometryType(),i,!0),h+=kr(a.getGeometryType(),a,!0)),m>h?(t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,i,o)):h>m?(e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,a,o)):e.segmentParentage<=t.segmentParentage?(e.weight+=t.weight,t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,i,o)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,a,o)),d?3:2}postProcessResultPartsForCurves(e,t,n,r,i){i===Kt()&&o(`curve_helper`);for(let n=e;n!==t;n=n.getNextInChain())this.updateSegmentToNodes(n);for(let e=n;e!==r;e=e.getNextInChain())this.updateSegmentToNodes(e);for(let a=e;a!==t;a=a.getNextInChain()){let e=a.end.pt.sub(a.start.pt);for(let t=n;t!==r;t=t.getNextInChain()){let n=0;if(a.start.pt.equals(t.start.pt)&&a.end.pt.equals(t.end.pt)?n=1:a.start.pt.equals(t.end.pt)&&a.end.pt.equals(t.start.pt)&&(n=-1),!n){let n=+!!a.start.pt.equals(t.start.pt);if(n||(n=a.end.pt.equals(t.end.pt)?2:0,n||(n=a.end.pt.equals(t.start.pt)?3:0,n||=a.start.pt.equals(t.end.pt)?4:0)),n){let r=t.end.pt.sub(t.start.pt),s=e.dotProduct(r),c;switch(n){case 1:case 2:c=s>0;break;case 3:case 4:c=s<0;break;default:o(`post_process_result_parts_for_curves_`)}c&&this.m_pairs.push(Dr(a,t,i,!1))}continue}let r=this.parent.m_resultSegments[a.segmentIndex],s=this.parent.m_resultSegments[t.segmentIndex],c=[.5,.25,.75];for(let e=0,t=c.length;e<t;++e){let t=c[e],i=new U;r.get().queryCoord2D(t,i);let a=s.get().getClosestCoordinate(i,!1),o=new U;if(s.get().queryCoord2D(a,o),U.distance(i,o)>this.parent.m_tolerance){n=0;break}}if(!n){this.m_pairs.push(Dr(a,t,i,!1));continue}for(let e=0,t=c.length;e<t;++e){let t=c[e],i=new U;s.get().queryCoord2D(t,i);let a=r.get().getClosestCoordinate(i,!1),o=new U;if(r.get().queryCoord2D(a,o),U.distance(i,o)>this.parent.m_tolerance){n=0;break}}if(!n){this.m_pairs.push(Dr(a,t,i,!1));continue}a.equalEdge=t,t.equalEdge=a;let l=a.rank,u=t.rank;l===u&&(l*=xr.c_maxGeometryTypeToRankDelta,u*=xr.c_maxGeometryTypeToRankDelta,l+=kr(r.get().getGeometryType(),r.get(),!0),u+=kr(s.get().getGeometryType(),s.get(),!0)),l>u||l===u&&a.segmentParentage<=t.segmentParentage?(r.copyTo(s,!1),t.segmentParentage=a.segmentParentage,n===-1&&s.get().reverse()):(s.copyTo(r,!1),a.segmentParentage=t.segmentParentage,n===-1&&r.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(n.start),r&&this.updateAttachedEdgesAfterNodeChange(r.start)}processDoublyConnectedEdges(e,t,n,r){n===Kt()&&o(`curve_helper`);let i=this.getSegment(e).get(),a=this.getSegment(t).get(),s=i.getStartXY().equals(a.getStartXY())&&i.getEndXY().equals(a.getEndXY())?1:i.getEndXY().equals(a.getStartXY())&&i.getStartXY().equals(a.getEndXY())?-1:0;if(s!==0){let o=new F;i.queryCut(0,.5,o),o.get().snapControlPoints(r*r);let c=new F;i.queryCut(.5,1,c),c.get().snapControlPoints(r*r),this.splitEdgeInPlace(e),e.end.pt=o.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(c);let l=a.getClosestCoordinate(e.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),a.queryCut(0,l,o),o.get().snapControlPoints(r*r),a.queryCut(l,1,c),c.get().snapControlPoints(r*r),this.splitEdgeInPlace(t),t.end.pt=o.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(c),s>0?(this.m_pairs.push(Dr(e,t,n,!1)),this.m_pairs.push(Dr(e.getNextInChain(),t.getNextInChain(),n,!1))):(this.m_pairs.push(Dr(e,t.getNextInChain(),n,!1)),this.m_pairs.push(Dr(e.getNextInChain(),t,n,!1))),!0}return!1}newNode(e,t,n,r){let i=new Er;return this.m_newNodes.push(i),i.pt=e,i.rank=n,i.weight=t,i.bIsBreak=r,i}newEdge(e,t,n,r,i,a){let o=new Tr;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=n,o.segmentParentage=a,o.rank=i,o.weight=r,o}splitEdgeInPlace(e){e.segmentIndex=-1;let t=new Tr,n=new Er;this.m_newNodes.push(n),n.pt.setNAN(),n.nextInChain=t,n.prevInChain=e,n.prevInHash=null,n.nextInHash=null,n.prevEqual=null,n.nextEqual=null,n.weight=e.weight,n.rank=e.rank,n.bIsBreak=!1,n.bBigMove=!1,t.start=n,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=n,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();t!==null;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){let t=e.prevInChain;if(t&&t.hasSegment()){let n=this.getSegment(t).get();e.pt.equals(n.getEndXY())||(n.setCoordsForIntersector(t.start.pt,t.end.pt,!1),n.ensureXYMonotone())}let n=e.nextInChain;if(n&&n.hasSegment()){let t=this.getSegment(n).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(n.start.pt,n.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){let t=this.getSegment(e).get();(!e.start.pt.equals(t.getStartXY())||!e.end.pt.equals(t.getEndXY()))&&(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1,n=[],r=[],i=[];for(let e=0,t=this.m_newNodes.length;e<t;e++){let n=this.m_newNodes[e];if(n===null)continue;let r=n;for(let i=e+1;i<t;i++){let e=this.m_newNodes[i];e!==null&&n.pt.equals(e.pt)&&(r.nextInHash=e,e.prevInHash=r,r=e,this.m_newNodes[i]=null)}}for(let a=0,o=this.m_newNodes.length;a<o;a++){let o=this.m_newNodes[a];if(o==null)continue;for(o.hash=this.calculateHash(o.pt);;){let a=ut(4),s=this.hashTableBinsToCheck(o,a);for(let t=0;t<s;t++)if(a[t]!==null)for(let s=a[t];s!==null;){let t=s.nextInHash;U.distance(o.pt,s.pt)<=e&&(n.push(s),this.removeNodeFromHash(s),s.hash=0,i.push(s),r.push(s)),s=t}let c=!1;for(let e of n)if(!o.pt.equals(e.pt)){let n=hr(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(n.pt),o.weight=n.weight,o.rank=n.rank,c=!0,t=!0}if(n.length=0,c){o.hash=this.calculateHash(o.pt);continue}break}i.push(o),r.push(o);for(let e=o.nextInHash;e!==null;){e.prevInHash=null;let t=e.nextInHash;e.nextInHash=null,i.push(e),r.push(e),e=t}let s=o.hash,c=null,l=null;for(let e of r)o!==e&&(e.hash=s,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=c,c&&(c.nextInHash=e),e.prevEqual=l,e.nextEqual=null,l&&(l.nextEqual=e),l=e,c=e;let u=s%this.m_hashTableOfEquals.length;c.nextInHash=this.m_hashTableOfEquals[u],this.m_hashTableOfEquals[u]!==null&&(this.m_hashTableOfEquals[u].prevInHash=c),this.m_hashTableOfEquals[u]=r[0],this.m_hashTableOfEqualsSize+=r.length,r.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(let e of i)this.updateAttachedEdgesAfterNodeChange(e)}rehashIfNeeded(){if(this.m_hashTableOfEqualsSize*2>this.m_hashTableOfEquals.length){let e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=ut(e.length*2),this.m_hashTableOfEqualsSize=0;for(let t of e){let e=t;for(;e;){let t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){let t=e.hash%this.m_hashTableOfEquals.length,n=this.m_hashTableOfEquals[t];e.nextInHash=n,n!==null&&(n.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){let t=e.hash%this.m_hashTableOfEquals.length,n=e.prevInHash,r=e.nextInHash;n?n.nextInHash=r:this.m_hashTableOfEquals[t]=r,r&&(r.prevInHash=n),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){let n=(e.pt.x-this.m_origin.x)/this.m_cell.x,r=(e.pt.y-this.m_origin.y)/this.m_cell.y,i=Ut()-1,a=Math.round(At(n,-i,i)),o=Math.round(At(r,-i,i)),s=a|o<<32;s=lt(s),t[0]=this.m_hashTableOfEquals[s%this.m_hashTableOfEquals.length];let c=a+1|o<<32;c=lt(c);let l=1;t[1]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(l=2);let u=a+1|o+1<<32;u=lt(u),t[l]=this.m_hashTableOfEquals[u%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}l++;let d=a|o+1<<32;d=lt(d),t[l]=this.m_hashTableOfEquals[d%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}return l++,l}calculateHash(e){let t=(e.x-this.m_origin.x)/this.m_cell.x,n=(e.y-this.m_origin.y)/this.m_cell.y,r=Ut()-1,i=Math.round(At(t,-r,r))|Math.round(At(n,-r,r))<<32;return i=lt(i),i===0&&(i=1),i}processSharpCorners(e,t,n,r){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){let i=[0,0],a=[0,0],o=xe(e,t,0,0,n,2,i,a,r);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return o+1}}if(e.getEndXY().equals(t.getEndXY())){let i=[0,0],a=[0,0],o=xe(e,t,1,1,n,2,i,a,r);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),o+1}}if(e.getStartXY().equals(t.getEndXY())){let i=[0,0],a=[0,0],o=xe(e,t,0,1,n,2,i,a,r);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return o+1}}if(e.getEndXY().equals(t.getStartXY())){let i=[0,0],a=[0,0],o=xe(e,t,1,0,n,2,i,a,r);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),o+1}}return 0}}function kr(e,t,n){let r=0;switch(e){case i.enumLine:r=0;break;case i.enumBezier:r=2;break;case i.enumRationalBezier2:r=3;break;case i.enumBezier2:r=1;break;case i.enumEllipticArc:r=t.projectionBehavior()===0?5:4;break;default:o(``)}return n?5-r:r}class Ar extends lr{m_parent;constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,n){if(this.m_bIntersectionDetected)return-1;let r=e.getElement(n),i=this.m_parent.getEdgeOriginVertices(t),a=this.m_parent.m_edgeVertices.getFirstElement(i),o=this.m_parent.getEdgeOriginVertices(r),s=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=n,this.compareSegments(t,a,r,s)}}class jr extends ur{m_parent;constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;let n=e.getElement(t),r=this.m_parent.getEdgeOriginVertices(n),i=this.m_parent.m_edgeVertices.getFirstElement(r);return this.m_currentNode=t,this.compareVertex(e,t,i)}}class Mr extends tt{m_shape;pt1=U.getNAN();pt2=U.getNAN();constructor(e){super(),this.m_shape=e}compare(e,t,n){this.m_shape.queryXY(t,this.pt1);let r=e.getElement(n);return this.m_shape.queryXY(r,this.pt2),this.pt1.compare(this.pt2)}}class Nr{m_shape;m_point=U.getNAN();m_pt=U.getNAN();constructor(e){this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){let n=e.getElement(t);return this.m_shape.queryXY(n,this.m_pt),this.m_point.compare(this.m_pt)}}class Pr{m_shape=null;m_progressTracker=null;m_edges=new rt(8);m_clusters=new rt(5);m_clusterVertices=new Y(!1);m_edgeVertices=new Y(!1);m_helperPoint=new B;m_eventQ=new Ie;m_sweepStructure=new Ie;m_bComplications=!1;m_bTrackChanges;m_sweepComparator=null;m_tempEdgeBuffer=[];m_modifiedClusters=[];m_edgesToInsertInSweepStructure=[];m_prevNeighbour=-1;m_nextNeighbour=-1;m_bContinuingSegmentChainOptimization=!1;m_progressCounter=0;m_segmentIntersector=new xr;m_segBuf1=new F;m_segBuf2=new F;m_sweepPoint=new U(0,0);m_tolerance=0;m_toleranceSqr=0;m_sweepPointCluster=-1;m_vertexClusterIndex=-1;m_bCracked=!1;m_bSweepPointClusterWasModified=!1;constructor(e,t){this.m_progressTracker=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){let n=new K;n.setSwapCoordinates(),e.applyTransformation(n),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let r=this.sweepImpl_();return e.applyTransformation(n),r||=(this.fillEventQueuePass2(),this.sweepImpl_()||r),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let n=this.sweepImpl_();if(!this.m_bComplications){let r=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,z);this.m_bComplications=r===1,n||=r===1}return this.m_vertexClusterIndex!==-1&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,n}getEdgeCluster(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,n){this.m_edges.setField(e,0+t,n)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,n){this.m_edges.setField(e,3+t,n)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){let n=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+n)}setNextEdge_(e,t,n){let r=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+r,n)}getPrevEdge(e,t){let n=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+n)}setPrevEdge_(e,t,n){let r=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+r,n)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){let t=this.m_clusters.newElement(),n=this.m_clusterVertices.createList();return this.setClusterVertices_(t,n),e!==z&&(this.m_clusterVertices.addElement(n,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){let n=this.getClusterVertices(e);this.m_clusterVertices.addElement(n,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){let t=this.m_edges.newElement(),n=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,n),e!==-1&&this.m_edgeVertices.addElement(n,e),t}addVertexToEdge_(e,t){let n=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(n,t)}deleteEdge_(e){this.m_edges.deleteElement(e);let t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&kt(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){this.getEdgeCluster(e,0)===-1?this.setEdgeCluster_(e,0,t):this.getEdgeCluster(e,1)===-1?this.setEdgeCluster_(e,1,t):o(``),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){let n=this.getClusterFirstEdge(t);if(n!==-1){let r=this.getNextEdge(n,t);this.setPrevEdge_(r,t,e),this.setNextEdge_(e,t,r),this.setNextEdge_(n,t,e),this.setPrevEdge_(e,t,n)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);let n=this.getClusterEventQNode(t);n!==-1&&(this.m_eventQ.deleteNode(n),this.setClusterEventQNode_(t,-1));let r=this.getClusterFirstEdge(e),i=this.getClusterFirstEdge(t);if(i!==-1){let n=i,a=i,o=!1;do{this.dbgCheckEdge_(n),o=!1;let r=this.getEdgeEnd(n,t),s=this.getNextEdgeEx(n,r);if(this.getEdgeCluster(n,r+1&1)===e){this.disconnectEdge_(n);let e=this.getEdgeOriginVertices(n);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(n),n===s){i=-1;break}i===n&&(i=this.getClusterFirstEdge(t),a=s,o=!0)}n=s}while(n!==a||o);if(i!==-1){do{let r=this.getEdgeEnd(n,t),i=this.getNextEdgeEx(n,r);this.setEdgeCluster_(n,r,e),n=i}while(n!==a);if(r=this.getClusterFirstEdge(e),r!==-1){let t=this.getNextEdge(r,e),n=this.getNextEdge(i,e);t===r?(this.setClusterFirstEdge_(e,i),this.addEdgeToClusterImpl_(r,e),this.setClusterFirstEdge_(e,r)):n===i&&this.addEdgeToClusterImpl_(i,e),this.setNextEdge_(i,e,t),this.setPrevEdge_(t,e,i),this.setNextEdge_(r,e,n),this.setPrevEdge_(n,e,r)}else this.setClusterFirstEdge_(e,i)}}let a=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(o);t!==-1;t=this.m_clusterVertices.getNext(t)){let n=this.m_clusterVertices.getElement(t);this.m_shape.setUserIndex(n,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(a,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);let n=this.getEdgeCluster(e,0),r=this.getEdgeCluster(e,1),i=this.getEdgeCluster(t,0),a=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),s=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,s),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),t===this.getClusterFirstEdge(r)&&this.setClusterFirstEdge_(r,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(n===i&&r===a||r===i&&n===a)){let e=this.getClusterXY(n),t=this.getClusterXY(i);e.isEqualPoint2D(t)?(n!==i&&this.mergeClusters_(n,i),r!==a&&this.mergeClusters_(r,a)):(r!==i&&this.mergeClusters_(r,i),n!==a&&this.mergeClusters_(n,a))}this.dbgCheckEdge_(e)}disconnectEdge_(e){let t=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,n)}disconnectEdgeFromCluster_(e,t){let n=this.getNextEdge(e,t),r=this.getPrevEdge(e,t),i=this.getClusterFirstEdge(t);n===e?this.setClusterFirstEdge_(t,-1):(this.setNextEdge_(r,t,n),this.setPrevEdge_(n,t,r),i===e&&this.setClusterFirstEdge_(t,n))}applyIntersectorToEditShape_(e,t,n){let r=this.m_edgeVertices.getFirst(e),i=this.m_edgeVertices.getElement(r),a=this.getClusterFromVertex(i),o=this.m_shape.getNextVertex(i),s=this.getClusterFromVertex(o),c=this.m_shape.getXY(i),l=this.m_shape.getXY(o),u=!1,d=!1,f=t.getResultSegment(n,0).getStartXY(),p=t.getResultSegment(n,t.getResultSegmentCount(n)-1).getEndXY();c.equals(f)||(u=!0),l.equals(p)||(d=!0),this.m_shape.splitSegmentWithIntersector(i,t,n,!0,!0);let m=this.m_bTrackChanges&&t.getSegmentChanged(n);for(m&&this.m_shape.setGeometryModifiedWithVertex(i,!0),r=this.m_edgeVertices.getNext(r);r!==-1;r=this.m_edgeVertices.getNext(r)){let e=this.m_edgeVertices.getElement(r),i=this.getClusterFromVertex(e)===a;this.m_shape.splitSegmentWithIntersector(e,t,n,i,!0),m&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(u&&this.updateClusterXY(!0,a,f,t.getResultSegmentStartPointWeight(n,0),t.getResultSegmentStartPointRank(n,0)),d){let e=t.getResultSegmentCount(n)-1;this.updateClusterXY(!0,s,p,t.getResultSegmentEndPointWeight(n,e),t.getResultSegmentEndPointRank(n,e))}}createEdgesAndClustersFromSplitEdge_(e,t,n){this.dbgCheckNewEdgesArray_();let r=this.getEdgeOriginVertices(e),i=this.getEdgeCluster(e,0),a=this.getEdgeCluster(e,1),o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);let s=rt.impossibleIndex3();this.setEdgeSweepNode_(o,s),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,i);let c=t.getResultSegmentCount(n);for(let e=1;e<c;e++){let e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);let t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,s),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,a);for(let e=this.m_edgeVertices.getFirst(r);e!==-1;e=this.m_edgeVertices.getNext(e)){let t=this.m_edgeVertices.getElement(e);if(this.getClusterFromVertex(t)===i){let e=0,n=this.m_tempEdgeBuffer.length;do{if(e>0){let n=this.m_tempEdgeBuffer[e-1];this.addVertexToCluster_(n,t)}let n=this.m_tempEdgeBuffer[e];e+=2,this.addVertexToEdge_(n,t),t=this.m_shape.getNextVertex(t)}while(e<n)}else{let e=this.m_tempEdgeBuffer.length-1;do{if(e<this.m_tempEdgeBuffer.length-2){let n=this.m_tempEdgeBuffer[e+1];this.addVertexToCluster_(n,t)}let n=this.m_tempEdgeBuffer[e];e-=2,this.addVertexToEdge_(n,t),t=this.m_shape.getNextVertex(t)}while(e>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){let t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,n){let r=this.getEdgeCluster(t,0),i=this.getClusterXY(r),a=this.getEdgeCluster(t,1),o=this.getClusterXY(a),s=n.getResultSegmentCount(e),c=n.getResultSegment(e,0),l=c.getStartXY();if(i.isEqualPoint2D(l)||(this.m_bComplications||i.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(r,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(r)),!this.m_bComplications&&s>1){let e=i.compare(o),t=c.getEndXY();(i.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}c=n.getResultSegment(e,s-1);let u=c.getEndXY();o.isEqualPoint2D(u)||(this.m_bComplications||o.compare(this.m_sweepPoint)*u.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(a,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(a)),this.m_tempEdgeBuffer.push(t);for(let e=0,n=this.m_tempEdgeBuffer.length;e<n;e++){let n=this.m_tempEdgeBuffer[e],r=this.getEdgeSweepNode(n);rt.isValidElement(r)&&(this.m_sweepStructure.deleteNode(r),this.setEdgeSweepNode_(n,-1));let i=rt.impossibleIndex3();n!==t&&this.getEdgeSweepNode(n)!==i&&(this.m_edgesToInsertInSweepStructure.push(n),this.setEdgeSweepNode_(n,i))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){let n=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,n,t),this.m_sweepComparator.intersectionDetected()?(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0):!1}fixIntersection_(e,t){this.m_bCracked=!0;let n=this.m_sweepStructure.getElement(e),r=this.m_sweepStructure.getElement(t),i=null,a=null,o=this.getEdgeOriginVertices(n),s=this.m_edgeVertices.getFirstElement(o),c=this.getEdgeOriginVertices(r),l=this.m_edgeVertices.getFirstElement(c);this.m_shape.querySegment(s,this.m_segBuf1,!1,!1),i=this.m_segBuf1.get();let u=this.m_shape.getNextVertex(s),d=this.m_shape.getWeight(s),f=this.m_shape.getSegmentParentageBreakVertex(s),p=this.m_shape.getWeight(u),m=this.m_shape.getSegmentParentageBreakVertex(u),h=this.m_shape.getSegmentWeight(s),g=this.m_shape.getRank(s),_=this.m_shape.getRank(u),v=this.m_shape.getSegmentRank(s),y=this.m_shape.getSegmentParentage(s);this.m_shape.querySegment(l,this.m_segBuf2,!1,!1),a=this.m_segBuf2.get();let b=this.m_shape.getNextVertex(l),x=this.m_shape.getWeight(l),S=this.m_shape.getSegmentParentageBreakVertex(l),C=this.m_shape.getWeight(b),w=this.m_shape.getSegmentParentageBreakVertex(b),T=this.m_shape.getSegmentWeight(l),E=this.m_shape.getRank(l),D=this.m_shape.getRank(b),O=this.m_shape.getSegmentRank(l),k=this.m_shape.getSegmentParentage(l);this.m_segmentIntersector.pushSegment(i,d,g,p,_,h,v,f,m,y),this.m_segmentIntersector.pushSegment(a,x,E,C,D,T,O,S,w,k),this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)===3&&(this.m_bComplications=!0),this.splitEdge_(n,r,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;let n=this.m_sweepStructure.getElement(t),r=null,i=this.getEdgeOriginVertices(n),a=this.m_edgeVertices.getFirstElement(i);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();let o=this.m_shape.getNextVertex(a),s=this.m_shape.getWeight(a),c=this.m_shape.getSegmentParentageBreakVertex(a),l=this.m_shape.getWeight(o),u=this.m_shape.getSegmentParentageBreakVertex(o),d=this.m_shape.getSegmentWeight(a),f=this.m_shape.getRank(a),p=this.m_shape.getRank(o),m=this.m_shape.getSegmentRank(a),h=this.m_shape.getSegmentParentage(a),g=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(r,s,f,l,p,d,m,c,u,h),this.m_shape.queryPoint(g,this.m_helperPoint);let _=this.m_shape.getWeight(g),v=this.m_shape.getRank(g);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,v,_,!0),this.splitEdge_(n,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(this.m_edgesToInsertInSweepStructure.length===0)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=0,n=this.m_edgesToInsertInSweepStructure.length,r=Math.max(2*n+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||t>r){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}let n=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(n,-1);let i=this.isEdgeOnSweepLine_(n);rt.isValidElement(i)?(this.insertNewEdgeToSweepStructure_(n,i),t++):i!==rt.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let n;if(this.m_bContinuingSegmentChainOptimization?(n=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):n=this.m_sweepStructure.addUniqueElement(e),n===-1){let t=this.m_sweepStructure.getDuplicateElement(),n=this.m_sweepStructure.getElement(t);return this.mergeEdges_(n,e),!1}if(this.setEdgeSweepNode_(e,n),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();let e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,n),!0}return!1}isEdgeOnSweepLine_(e){let t=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getClusterXY(t),i=this.getClusterXY(n);if(U.sqrDistance(r,i)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;let a=r.compare(this.m_sweepPoint),o=i.compare(this.m_sweepPoint);return a<=0&&o>0?n:o<=0&&a>0?t:a>0&&o>0?rt.impossibleIndex2():-1}fillEventQueue(){let e=new Re(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let n=t.next();n!==z;n=t.next())this.m_shape.getUserIndex(n,this.m_vertexClusterIndex)!==-1&&e.add(n);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(e.size()),this.m_eventQ.setComparator(new Mr(this.m_shape));let n=U.getNAN();n.setNAN();let r=-1;for(let t=0,i=e.size();t<i;t++){let i=e.read(t);if(this.m_shape.getXY(i).isEqualPoint2D(n)){let e=this.m_shape.getUserIndex(i,this.m_vertexClusterIndex);this.mergeClusters_(r,e);continue}r=this.getClusterFromVertex(i),this.m_shape.queryXY(i,n);let a=this.m_eventQ.addBiggestElement(i);this.setClusterEventQNode_(r,a)}}fillEventQueuePass2(){let e=new Re(0);for(let t=this.m_eventQ.getFirst();t!==-1;t=this.m_eventQ.getNext(t)){let n=this.m_eventQ.getElement(t);e.add(n)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,n=e.size();t<n;t++){let n=e.read(t),r=this.getClusterFromVertex(n),i=this.m_eventQ.addBiggestElement(n);this.setClusterEventQNode_(r,i)}}getAffectedEdges(e,t){let n=this.getClusterFirstEdge(e);if(n===-1)return;let r=n;do{let n=this.getEdgeSweepNode(r);rt.isValidElement(n)&&t.push(r),r=this.getNextEdge(r,e)}while(r!==n)}updateClusterXY(e,t,n,r,i){let a=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(a);t!==-1;t=this.m_clusterVertices.getNext(t)){let a=this.m_clusterVertices.getElement(t);this.m_shape.setXYMonotonicPoint2D(a,n),this.m_shape.setWeight(a,r),this.m_shape.setRank(a,i),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(a,!0),this.m_shape.setSegmentParentageBreakVertex(a,!0)}}splitEdge_(e,t,n,r){this.dbgCheckEdge_(e),t!==-1&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),t!==-1&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,r),t!==-1&&this.processSplitHelper1_(1,t,r),n!==-1&&r.getResultPointChanged()&&this.m_modifiedClusters.push(n);for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){let t=this.m_modifiedClusters[e],n=this.getClusterEventQNode(t);n!==-1&&(this.m_eventQ.deleteNode(n),this.setClusterEventQNode_(t,-1))}let i=this.getEdgeOriginVertices(e),a=t===-1?-1:this.getEdgeOriginVertices(t);if(this.applyIntersectorToEditShape_(i,r,0),a!==-1)this.applyIntersectorToEditShape_(a,r,1);else{let e=r.getResultPoint().getXY();this.updateClusterXY(r.getResultPointChanged(),n,e,r.getResultPointWeight(),r.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,r,0),t!==-1&&this.createEdgesAndClustersFromSplitEdge_(t,r,1),this.m_edgeVertices.deleteList(i),this.deleteEdge_(e),t!==-1&&(this.m_edgeVertices.deleteList(a),this.deleteEdge_(t));for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){let t=this.m_modifiedClusters[e];t===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let n=this.getClusterEventQNode(t);if(n===-1){let e=this.getClusterFirstVertex(t);if(n=this.m_eventQ.addUniqueElement(e),n===-1){let e=this.m_eventQ.getDuplicateElement(),n=this.m_eventQ.getElement(e),r=this.getClusterFromVertex(n);this.mergeClusters_(r,t)}else this.setClusterEventQNode_(t,n)}}this.m_modifiedClusters.length=0}getClusterXY(e){let t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){let t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,this.m_sweepComparator===null&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new Ar(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));let e=[],t=null,n=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;let r=rt.impossibleIndex2(),i=rt.impossibleIndex3();for(let a=this.m_eventQ.getFirst();a!==-1;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;let o=this.m_eventQ.getElement(a);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 s=!1;{let t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(s=t===-1,!s){let n=t;do{let t=this.getEdgeSweepNode(n);t===-1?(this.m_edgesToInsertInSweepStructure.push(n),this.setEdgeSweepNode_(n,i)):t!==i&&e.push(t),n=this.getNextEdge(n,this.m_sweepPointCluster)}while(n!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=e.length===1&&this.m_edgesToInsertInSweepStructure.length===1;for(let t=0,n=e.length;t<n;t++){let n=this.m_sweepStructure.getElement(e[t]);this.setEdgeSweepNode_(n,r)}let t=r,n=r;for(let i=0,a=e.length;i<a;i++){let a=e[i];if(t===r){let e=this.m_sweepStructure.getPrev(a);if(e!==-1){let n=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(n)!==r&&(t=e)}else t=-1}if(n===r){let e=this.m_sweepStructure.getNext(a);if(e!==-1){let t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==r&&(n=e)}else n=-1}if(t!==r&&n!==r)break}for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_sweepStructure.getElement(n);this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(r,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=n,t!==-1&&n!==-1?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,n):t===-1&&n===-1&&(this.m_bContinuingSegmentChainOptimization=!1)}else s&&(t===null&&(t=new jr(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.getCurrentNode())));let c=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&c&&this.m_prevNeighbour!==-1&&this.m_nextNeighbour!==-1&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,n===null&&(n=new Nr(this.m_shape)),n.setPoint(this.m_sweepPoint),a=this.m_eventQ.searchUpperBound(n)):a=this.m_eventQ.getNext(a)}return this.m_bCracked}setEditShape_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==z;t=this.m_shape.getNextGeometry(t)){if(!s(this.m_shape.getGeometryType(t))){for(let e=this.m_shape.getFirstPath(t);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}continue}for(let n=this.m_shape.getFirstPath(t);n!==z;n=this.m_shape.getNextPath(n)){let t=this.m_shape.getPathSize(n),r=this.m_shape.getFirstVertex(n);if(r===z)continue;let i=this.m_shape.getNextVertex(r);if(i===z||i===r)continue;let a=-1;e.selected(r)&&(a=this.newCluster_(r));let o=-1;a!==-1&&e.selected(i)&&(o=this.newEdge_(r),this.addEdgeToCluster(o,a));let s=o;for(let e=0,n=t-2;e<n;e++){let e=this.m_shape.getNextVertex(i),t=-1;if(this.m_shape.selected(i)){let n=this.newCluster_(i);s!==-1&&this.addEdgeToCluster(s,n),this.m_shape.selected(e)&&(t=this.newEdge_(i),this.addEdgeToCluster(t,n))}s=t,i=e}if(this.m_shape.isClosedPath(n)){let e=this.m_shape.getNextVertex(i);if(this.m_shape.selected(i)){let t=this.newCluster_(i);if(s!==-1&&this.addEdgeToCluster(s,t),this.m_shape.selected(e)){let e=this.newEdge_(i);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,a)}}}else{let e=-1;this.m_shape.selected(i)&&(e=this.newCluster_(i),s!==-1&&this.addEdgeToCluster(s,e))}}}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function Fr(e,t,n,r){n>0&&fr(e,n,t,!1,r),new Lr(r).executeImpl_(e,t)}function Ir(e,t,n){return{vertex0:e,vertex1:t,dir:n}}class Lr{m_shape=null;m_progressTracker;m_spikes=[];m_points=new Re(0);m_pointsIndex=-1;m_dissolvedEdges=0;constructor(e){this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let n=e.getFirstPath(t);n!==z;n=e.getNextPath(n)){let t=e.getFirstVertex(n);for(let r=0,i=e.getPathSize(n);r<i;r++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let t=0,n=this.m_points.size();t<n;++t)e.setUserIndex(this.m_points.read(t),this.m_pointsIndex,t);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let n=this.m_points.read(0),r=e.getXY(n),i=1,a=0,o=[];for(let t=1;t<this.m_points.size();t++){let s=this.m_points.read(t);if(s===z||e.getUserIndex(s,this.m_pointsIndex)===-1)continue;let c=e.getXY(s);if(c.isEqualPoint2D(r))i++;else{if(i>1){for(let n=a;n<t;n++){let t=this.m_points.read(n);if(e.getUserIndex(t,this.m_pointsIndex)===-1)continue;let i=e.getNextVertex(t),a=e.getPrevVertex(t);if(t!==i&&!e.isEqualXYPoint2D(i,r)){let e=Ir(t,i,1);o.push(e)}if(t!==a&&a!==i&&!e.isEqualXYPoint2D(a,r)){let e=Ir(t,a,-1);o.push(e)}}o.length>0&&this.processBunch_(o,r)}n=s,r.assign(c),i=1,a=t}}if(this.m_dissolvedEdges===0){e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1;return}let s=e.getPointCount(t);for(let t=0;t<this.m_points.size();t++){let n=this.m_points.read(t);if(n===z)continue;if(e.getUserIndex(n,this.m_pointsIndex)!==-1){e.setUserIndex(n,this.m_pointsIndex,-1);continue}let r=e.getPathFromVertex(n);e.getFirstVertex(r)===n&&e.setFirstVertex(r,z),e.freeVertex(n),this.m_points.write(t,z),s--}let c=e.createPathUserIndex(),u=e.getPathCount(t);for(let n=0,r=this.m_points.size();n<r;++n){if(this.m_points.read(n)===z)continue;let r=this.m_points.read(n);if(e.getUserIndex(r,this.m_pointsIndex)!==-1)continue;let i=e.getPathFromVertex(r),a=-1;if(e.getPathUserIndex(i,c)===2){i=z;for(let t=e.getNextVertex(r);t!==r;t=e.getNextVertex(t)){let n=e.getPathFromVertex(t);if(e.getPathUserIndex(n,c)!==2){i=n,r=t;break}}i===z&&(i=e.insertPath(t,z),e.setClosedPath(i,!0),u++),l(i!==z)}e.setPathUserIndex(i,c,2),a=e.getFirstVertex(i);let o=0,s=!1,d=r;do{a===d&&(s=!0),e.setUserIndex(d,this.m_pointsIndex,1);let t=e.getPathFromVertex(d);t!==i&&(e.getPathUserIndex(t,c)!==2&&(e.setPathUserIndex(t,c,1),e.setFirstVertex(t,z)),e.setPathToVertex(d,i)),o++,d=e.getNextVertex(d)}while(d!==r);s||e.setFirstVertex(i,r),e.setPathSize(i,o)}for(let n=e.getFirstPath(t);n!==z;){let t=e.getNextPath(n);(e.getPathUserIndex(n,c)===1||e.getFirstVertex(n)===z)&&(e.removePathOnly(n),u--),n=t}e.setGeometryVertexCount(t,s),e.setGeometryPathCount(t,u),e.removePathUserIndex(c),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,n)=>{let r=this.m_shape.getXY(e.vertex1).sub(t),i=this.m_shape.getXY(n.vertex1).sub(t),a=U.compareVectors(r,i);return a===0?e.dir<n.dir?-1:1:a});let n=0,r=this.m_shape.getXY(e[0].vertex1),i=1,a=this.m_shape.hasCurves();for(let t=1,o=e.length;t<o;t++){let s=this.m_shape.getXY(e[t].vertex1);if(!(s.isEqualPoint2D(r)&&(i++,t+1<o))){if(i===2){let t=e[n],r=e[n+1],i=t.dir;if(i!==r.dir){let e=!0;if(a&&(e=!this.m_shape.isCurve(t.dir===1?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(r.dir===1?r.vertex0:r.vertex1)),e){if(i===1){let e=t.vertex0,n=r.vertex0;this.m_shape.setNextVertex(e,n),this.m_shape.setPrevVertex(n,e),this.m_shape.getPrevVertex(e)===n&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(n,this.m_pointsIndex,-1));let i=t.vertex1,a=r.vertex1;this.m_shape.setPrevVertex(i,a),this.m_shape.setNextVertex(a,i),this.m_shape.getNextVertex(i)===a&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(a,this.m_pointsIndex,-1))}else{let e=t.vertex0,n=r.vertex0;this.m_shape.setPrevVertex(e,n),this.m_shape.setNextVertex(n,e),this.m_shape.getNextVertex(e)===n&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(n,this.m_pointsIndex,-1));let i=t.vertex1,a=r.vertex1;this.m_shape.setNextVertex(i,a),this.m_shape.setPrevVertex(a,i),this.m_shape.getPrevVertex(i)===a&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(a,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}r.assign(s),n=t,i=1}}e.length=0}}function Rr(e){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))if(s(e.getGeometryType(t)))return!0;return!1}function zr(e,t,n,r){if(!Rr(e))return!1;let i=new Ur(r);i.m_shape=e,i.m_tolerance=t,i.m_bTrackChanges=n;let a=!1,o=e.hasCurves()?5:15;return a=e.getTotalPointCount()<o?i.crackBruteForce_():i.crackerPlaneSweep_(),a}function Br(e,t,n,r,i){if(!Rr(t))return!1;let a=new Ur(i);if(a.m_shape=t,a.m_tolerance=n,a.m_bAllowCoincident=e,a.m_bNeedsNonSimpleResult=r!==null,a.needsCrackingImpl_())return r&&r.assign(a.m_nonSimpleResult),!0;let o=new K;o.setSwapCoordinates(),t.applyTransformation(o),a=new Ur(i),a.m_shape=t,a.m_tolerance=n,a.m_bAllowCoincident=e,a.m_bNeedsNonSimpleResult=r!==null;let s=a.needsCrackingImpl_();return t.applyTransformation(o),s?(r&&r.assign(a.m_nonSimpleResult),!0):!1}function Vr(e,t,n,r){let i=t.getGeometryType();if(s(i))return new Ur(r).crackAWithBMultiPath_(e,t,n);p(`crack_A_with_B`)}function Hr(e,t){return{t:e,index:t}}class Ur{static s_bForceBruteForce=!0;m_shape=null;m_progressTracker=null;m_nonSimpleResult=new J;m_tolerance=0;m_sweepComparator=null;m_progressCounter=0;m_bTrackChanges=!1;m_bNeedsNonSimpleResult=!1;m_bAllowCoincident=!0;crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){let t=new K;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1,t=new F,n=new F,r=T.constructEmpty(),i=T.constructEmpty(),a=new B,o=new xr,s=this.m_shape.getTotalPointCount(),c=s*s*2,u=this.m_shape.queryVertexIteratorOnSelection();for(let s=u.next();s!==z;s=u.next()){let d=this.m_shape.getGeometryType(u.currentGeometry()),f=1,p=1,m=1,h=0,g=0,_=0,v=this.m_shape.getSegmentParentage(s),y=!1,x=!1,S=null,C=!1;if(b(d))f=this.m_shape.getWeight(s),h=this.m_shape.getRank(s);else{if(S=this.getSegment_(s,t),S===null)continue;let e=this.m_shape.getVertexIndex(s);f=this.m_shape.getWeightWithIndex(e),h=this.m_shape.getRankWithIndex(e),m=this.m_shape.getSegmentWeightWithIndex(e),_=this.m_shape.getSegmentRankWithIndex(e),y=this.m_shape.getSegmentParentageBreakVertex(s);{let e=this.m_shape.getNextVertex(s);p=this.m_shape.getWeight(e),g=this.m_shape.getRank(e),x=this.m_shape.getSegmentParentageBreakVertex(e)}if(S.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),S.isDegenerate(this.m_tolerance)){if(S.isDegenerate(0))C=!0,S=null;else continue}}let w=new ue({copy:u}),T=w.next();T!==z&&(T=w.next());let E=0;for(;T!==z;T=w.next()){if(E!==0){E--;continue}if(this.m_shape.getTotalPointCount()>c)return e;this.progress_();let d=this.m_shape.getGeometryType(w.currentGeometry()),D=null,O=!1,k=0,A=0,j=0,M=0,N=0,P=0,F=!1,I=!1,L=this.m_shape.getSegmentParentage(T);if(b(d))k=this.m_shape.getWeight(T),M=this.m_shape.getRank(T);else{if(D=this.getSegment_(T,n),D===null)continue;let e=this.m_shape.getVertexIndex(T);k=this.m_shape.getWeightWithIndex(e),M=this.m_shape.getRankWithIndex(e),j=this.m_shape.getSegmentWeightWithIndex(e),P=this.m_shape.getSegmentRankWithIndex(e),F=this.m_shape.getSegmentParentageBreakVertex(T);{let e=this.m_shape.getNextVertex(T);A=this.m_shape.getWeight(e),N=this.m_shape.getRank(e),I=this.m_shape.getSegmentParentageBreakVertex(e)}if(D.queryLooseEnvelope(i),D.isDegenerate(this.m_tolerance)){if(D.isDegenerate(0))O=!0,D=null;else continue}}let R=0,ee=0;if(S!==null&&D!==null)r.isIntersectingNe(i)&&de(!0,!0,S,D,this.m_tolerance,!0)!==0&&(o.pushSegment(S,f,h,p,g,m,_,y,x,v),o.pushSegment(D,k,M,A,N,j,P,F,I,L),o.intersect2D(this.m_tolerance,!0),e||=o.getSegmentChanged(0)||o.getSegmentChanged(1),R=o.getResultSegmentCount(0),ee=o.getResultSegmentCount(1),R+ee>0&&(this.m_shape.splitSegmentWithIntersector(s,o,0,!0,!0),this.m_shape.splitSegmentWithIntersector(T,o,1,!0,!0),this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(T,!0))),ee>1&&(E+=ee-1),o.clear());else if(S!==null){let t=this.m_shape.getXY(T);if(r.contains(t)){if(o.pushSegment(S,f,h,p,g,m,_,y,x,v),this.m_shape.queryPoint(T,a),o.intersect2DEx(this.m_tolerance,a,M,k,!1),e||=o.getSegmentChanged(0)||o.getResultPointChanged(),R=o.getResultSegmentCount(0),R>0){if(this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(T,!0)),this.m_shape.splitSegmentWithIntersector(s,o,0,!0,!0),O){let e=z;for(let t=this.m_shape.getNextVertex(T);t!==z&&t!==T&&(D=this.getSegment_(t,n),e=t,D!=null&&D.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=T;t!==z&&(this.m_shape.setPoint(t,o.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(T,o.getResultPoint(),!0)}o.clear()}}else if(D!==null){let t=this.m_shape.getXY(s);if(i.inflateCoords(this.m_tolerance,this.m_tolerance),i.contains(t)){if(o.pushSegment(D,k,M,A,N,j,P,F,I,L),this.m_shape.queryPoint(s,a),o.intersect2DEx(this.m_tolerance,a,h,f,!1),e||=o.getSegmentChanged(0)||o.getResultPointChanged(),ee=o.getResultSegmentCount(0),ee>0){if(this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(T,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(s,!0)),this.m_shape.splitSegmentWithIntersector(T,o,0,!0,!0),E+=ee-1,C){let e=z;for(let t=this.m_shape.getNextVertex(s);t!==z&&t!==s&&(D=this.getSegment_(t,n),e=t,D!=null&&D.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=s;t!==z&&(this.m_shape.setPoint(t,o.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(s,o.getResultPoint(),!0)}o.clear()}}else continue;if(R+ee!==0&&R!==0){let e=!1;for(;S=this.getSegment_(s,t),S!=null&&(S.queryEnvelope(r),S.isDegenerate(this.m_tolerance));)if(R>1)s=u.next(),R--,l(s!==z);else{e=!0;break}if(e)break}}}return e}m_sweepStructure=new Ie;crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Pr(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1,t=new Re(0);t.resize(this.m_shape.getSelectedCount());let n=this.m_shape.queryVertexIteratorOnSelection();for(let e=0,r=n.next();r!==z;++e,r=n.next())t.write(e,r);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(z);let r=this.m_shape.createUserIndex(),i=this.m_shape.createUserIndex();this.m_sweepComparator=new lr(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let a=null,s=[],c=[],l=0,u=new U;for(let n=t.read(l++);n!==z;){this.m_shape.queryXY(n,u);let d=!1;do{let e=this.m_shape.getNextVertex(n),a=this.m_shape.getPrevVertex(n);d||=e!==z||a!==z,e!==z&&!this.m_shape.selected(e)&&(e=z),a!==z&&!this.m_shape.selected(a)&&(a=z),e!==z&&this.m_shape.compareVerticesSimpleY(n,e)<0&&(c.push(n),c.push(e)),a!==z&&this.m_shape.compareVerticesSimpleY(n,a)<0&&(c.push(a),c.push(a));let o=this.m_shape.getUserIndex(n,r);o!==-1&&(s.push(o),this.m_shape.setUserIndex(n,r,-1));let u=this.m_shape.getUserIndex(n,i);u!==-1&&(s.push(u),this.m_shape.setUserIndex(n,i,-1)),n=t.read(l++)}while(n!==z&&this.m_shape.isEqualXYPoint2D(n,u));if(!d&&(a===null&&(a=new ur(this.m_shape,this.m_tolerance)),a.setPoint(u),this.m_sweepStructure.searchUpperBound(a),a.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(o(`needsCrackingIMpl_`),this.m_nonSimpleResult=new J(6,-1,-1));break}let f=s.length===1&&c.length===2;s.length>32&&dt(s);let p=-1,m=-1;if(!f)for(let t=0,n=s.length;t<n;t++){let n=s[t],r=this.m_sweepStructure.getPrev(n);if(r!==-1&&s.indexOf(r)===-1){if(p===-1)p=r;else if(e=!0,this.m_bNeedsNonSimpleResult)this.m_nonSimpleResult=new J(6,-1,-1);else break}let i=this.m_sweepStructure.getNext(n);if(i!==-1&&s.indexOf(i)===-1){if(m===-1)m=i;else if(e=!0,this.m_bNeedsNonSimpleResult)this.m_nonSimpleResult=new J(6,-1,-1);else break}if(p!==-1&&m!==-1)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(u.y,u.x),!f){for(let e=0,t=s.length;e<t;e++){let t=s[e];this.m_sweepStructure.deleteNode(t)}s.length=0}if(!f&&p!==-1&&m!==-1&&this.checkForIntersections_(p,m)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,n=c.length;t<n;t+=2){let n=c[t],a=c[t+1],o;if(f?(o=this.m_sweepStructure.replaceElementAtPosition(s[0],n,!0,!0),s.length=0,f=!1):o=this.m_sweepStructure.addElement(n),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}this.m_shape.getUserIndex(a,r)===-1?this.m_shape.setUserIndex(a,r,o):this.m_shape.setUserIndex(a,i,o)}if(e)break;c.length=0}return this.m_shape.removeUserIndex(r),this.m_shape.removeUserIndex(i),e}checkForIntersections_(e,t){let n=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,n,t);let r=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),r}getSegment_(e,t){return Ur.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,n){return e.querySegment(t,n,!1,!1)?n.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,n){let r=T.constructEmpty();e.queryLooseEnvelope(r);let a=T.constructEmpty();if(t.queryLooseEnvelope(a),a.inflateCoords(n,n),!a.isIntersecting(r))return e;let o=e.getImpl(),s=o.getAccelerators(),c=null,u=null;s&&(u=s.getQuadTree()),Wr(e,m(t))&&(c=qe(o,a),u=c);let d=u?u.getIteratorForQT():null,f=t.querySegmentIterator(),p=e.querySegmentIterator(),h=H(15,NaN),g=[];for(;f.nextPath();)for(;f.hasNextSegment();){let e=f.nextSegment();if(u){d.resetIterator(e,n);for(let t=d.next();t!==-1;t=d.next()){this.progress_();let r=u.getElement(t);if(p.resetToVertex(r,-1),p.hasNextSegment()){let t=p.nextSegment().intersect(e,null,h,null,n);for(let e=0;e<t;e++){let t=h[e];if(t===0||t===1)continue;let n=Hr(t,p.getStartPointIndex());g.push(n)}}}}else{let t=T.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(p.resetToFirstPath();p.nextPath();)for(;p.hasNextSegment();){let r=p.nextSegment(),i=T.constructEmpty();if(r.queryLooseEnvelope(i),!i.isIntersecting(t))continue;let a=r.intersect(e,null,h,null,n);for(let e=0;e<a;e++){let t=h[e];if(t===0||t===1)continue;let n=Hr(t,p.getStartPointIndex());g.push(n)}}}}if(g.length===0)return e;g.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:+(e.t>t.t));let _=e.createInstance();for(_.getGeometryType()===i.enumPolygon&&_.setFillRule(e.getFillRule()),p.resetToFirstPath();p.nextPath()&&!p.hasNextSegment(););l(p.hasNextSegment());let v=p.nextSegment(),y=new F,b=-1;for(let e=0,t=g.length;e<t;){let n=g[e].index,r=e+1;for(;r<t&&g[r].index===n;)++r;for(;p.getStartPointIndex()<n;){this.progress_();let e=p.hasNextSegment(),t=p.getPathIndex();if((e||!p.isClosingSegment()||p.isCurve())&&(l(v!==null),_.addSegment(v,b!==t)),b=t,!e){for(p.isPathClosed();p.nextPath()&&!p.hasNextSegment(););l(p.hasNextSegment())}v=p.nextSegment()}let i=0;for(let t=e;t<r;t++){let e=g[t].t;if(e===i)continue;l(v!==null),v.queryCut(i,e,y),i=e;let n=p.getPathIndex();_.addSegment(y.get(),b!==n),b=n}let a=p.hasNextSegment();if((a||!p.isClosingSegment()||p.isCurve())&&(l(v!=null),v.queryCut(i,1,y),_.addSegment(y.get(),!1)),a)v=p.nextSegment();else{for(;p.nextPath()&&!p.hasNextSegment(););v=p.hasNextSegment()?p.nextSegment():null}e=r}if(v!==null){let e=p.getPathIndex();(p.hasNextSegment()||!p.isClosingSegment()||p.isCurve())&&_.addSegment(v,b!==e),b=e}let x=p.hasNextSegment();for(;;){if(!x){for(;p.nextPath()&&(x=p.hasNextSegment(),!x););if(!x)break}v=p.nextSegment();let e=p.getPathIndex();x=p.hasNextSegment(),(x||!p.isClosingSegment()||p.isCurve())&&_.addSegment(v,b!==e),b=e}return _}constructor(e){this.m_progressTracker=e}}function Wr(e,t){let n=e.getPointCount();return n<16?!1:2*n+Math.log(n)/Math.log(2)*1*t<1*n*t}class Gr{m_inputPoint;m_windnum;m_monotoneParts=bt(F,16);m_xOrds=H(16,NaN);m_tolerance;m_toleranceSqr;m_miny;m_maxy;m_bAlternate;m_bTestBorder;m_bBreak;constructor(e,t){this.m_inputPoint=U.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY()))){this.m_bBreak=!0;return}if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){let t=Math.min(e.getStartX(),e.getEndX()),n=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<n&&(this.m_bBreak=!0)}return}let t=!1,n=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>n)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){let r=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,n);t=!Number.isNaN(r)&&r<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){let t=e.getClosestCoordinate(this.m_inputPoint,!1),n=e.getCoord2D(t);return U.sqrDistance(n,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){let t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let n=0;if(e.isCurve()&&(this.m_monotoneParts.length===0&&(this.m_monotoneParts.length=128),n=e.getMonotonicParts(this.m_monotoneParts,!0),l(this.m_monotoneParts.length>=n)),n>0)for(let e=0;e<n;e++){let t=this.m_monotoneParts[e].get(),n=W.construct(t.getStartY(),t.getEndY());if(!(n.vmin>this.m_inputPoint.y||n.vmax<this.m_inputPoint.y)&&(this._DoOne(t),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return l(0),2}}function Kr(e,t,n,r){let i=new T;e.queryLooseEnvelope(i),i.inflateCoords(r,r);let a=e.getFillRule()===0,o=new Gr(a,r);o.setInputPoint(n);let s=i.clone();s.xmax=n.x+r,s.ymin=n.y-r,s.ymax=n.y+r;let c=e.getImpl().querySegmentIterator(),l=t.getIterator(s,r);for(let e=l.next();e!==-1;e=l.next())if(c.resetToVertex(t.getElement(e),-1),c.hasNextSegment()){let e=c.nextSegment();if(o.processSegment(e))return-1}return+!!o._Result()}function qr(e,t,n){let r=e.getFillRule()===0,i=new Gr(r,n);i.setInputPoint(t);let a=e.getImpl().querySegmentIterator();for(;a.nextPath();)for(;a.hasNextSegment();){let e=a.nextSegment();if(i.processSegment(e))return-1}return+!!i._Result()}function Jr(e,t,n){return t.isEmpty()?0:Yr(e,t.getXY(),n)}function Yr(e,t,n){if(e.isEmpty())return 0;let r=T.constructEmpty();if(e.queryLooseEnvelope(r),r.inflateCoords(n,n),!r.contains(t))return 0;let i=e.getImpl().getAccelerators();if(i){i.getRasterizedGeometry()&&l(0);let r=i.getQuadTree();if(r)return Kr(e,r,t,n)}return qr(e,t,n)}function Xr(e,t){let n=e.getPointCount();return n<16?!1:2*n+Math.log(n)/Math.log(2)*1*t<1*n*t}function Zr(e,t,n,r,i){let a=new ni(i);return a.m_shape=e,a.m_geometry=t,a.m_sortedVertices=n,a.m_bFixSelfTangency=r,a.fixRingOrientation_()}function Qr(e,t,n){let r=new ni(n);return r.m_shape=e,r.m_geometry=t,r.m_sortedVertices=null,r.m_bFixSelfTangency=!1,r.fixRingOrientationForMp2sp_()}class $r{m_shape;m_end1Nodes=[];m_end2Nodes=[];m_directions=[];m_firstFree;getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){let t=this.getEnd1(e),n=this.getEnd2(e);return this.m_shape.getNextVertex(t)===n?n:t}constructor(e){this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),n=this.getEnd2(e);this.m_shape.getPrevVertex(t)===n&&(n=gt(t,t=n));let r=U.getNAN(),i=U.getNAN();return this.m_shape.queryXY(t,r),this.m_shape.queryXY(n,i),l(!r.equals(i)),r.y<i.y}getStart(e){let t=this.getEnd1(e),n=this.getEnd2(e);return this.m_shape.getNextVertex(t)===n?t:n}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(this.m_firstFree!==-1){let t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}let t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let ei=class extends tt{m_helper;m_line1=new I;m_line2=new I;m_leftElm=-1;m_leftx=0;m_seg1=null;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_edges,a;this.m_leftElm===t?a=this.m_leftx:(this.m_seg1=i.getSegment(t),this.m_seg1?a=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(i.getShape().queryLineConnector(i.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,a=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=a,this.m_leftElm=t);let o=i.getSegment(r),s;if(o?s=o.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(i.getShape().queryLineConnector(i.getStart(r),this.m_line2,!0),o=this.m_line2,s=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),a===s){let e=i.isBottomUp(t),n=i.isBottomUp(r),c=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=n?o.getEndY():o.getStartY(),u=Math.min(c,l),d=(u+this.m_helper.m_yScanline)*.5;d===this.m_helper.m_yScanline&&(d=u),a=this.m_seg1.intersectionOfYMonotonicWithAxisX(d,0),s=o.intersectionOfYMonotonicWithAxisX(d,0),a===s&&w(``)}return a<s?-1:+(a>s)}reset(){this.m_leftElm=-1}};class ti{m_sortedVertices;m_sortedVerticesArray;m_node=-1;m_index=0;constructor(e){this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){let e=this.m_node;if(e===-1)return z;let t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){let e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return z}}class ni{m_edges=null;m_sweepComparator;m_shape=null;m_AET=new Ie;m_yScanline=0;m_geometry=z;m_unknownRingOrientationCount=-1;m_sortedVertices=null;m_sortedVerticesArray=null;m_unknownNodes=[];m_progressTracker;m_node1UserIndex=-1;m_node2UserIndex=-1;m_pathOrientationIndex=-1;m_pathParentageIndex=-1;m_pathParentsIndex=-1;m_progressCounter=0;m_bFixSelfTangency=!1;constructor(e){this.m_progressTracker=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new ei(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){let e=this.fixRingOrientationImplMain_();return this.m_pathOrientationIndex===-1||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),this.m_pathOrientationIndex===-1?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||=new $r(this.m_shape),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let n=0,r=e.length;n<r;n++)e[n]!==-1&&t++;(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let t=0,n=e.length;t<n;t++){let n=e[t];n!==z&&this.insertEdge_(n,-1)}for(let e=0;e<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;e++){let n=this.m_unknownNodes[e],r=this.m_AET.getElement(n),i=this.m_edges.getPath(r),a=this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex),o=z;if(a===0){let e=this.m_AET.getPrev(n),r=n,i=!1;for(;e!==Ie.st_nullNode();){let t=this.m_AET.getElement(e),n=this.m_edges.getPath(t);if(this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)!==0){o=n;break}r=e,e=this.m_AET.getPrev(e)}if(e===Ie.st_nullNode())i=!0,e=r;else{let t=this.m_AET.getElement(e);i=this.m_edges.isBottomUp(t),e=this.m_AET.getNext(e),i=!i}do{let n=this.m_AET.getElement(e),a=this.m_edges.getPath(n);if(this.m_shape.getPathUserIndex(a,this.m_pathOrientationIndex)===0){if(i!==this.m_edges.isBottomUp(n)){let e=this.m_shape.getFirstVertex(a);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(a,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(a,this.m_pathOrientationIndex,i?3:2),!i){let e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);e===2?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),l(e===3)):l(e===3);let t=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,a),this.m_shape.setPathUserIndex(a,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(a,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}o=a,r=e,e=this.m_AET.getNext(e),i=!i}while(r!==n)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_shape.getUserIndex(n,this.m_node1UserIndex),i=this.m_shape.getUserIndex(n,this.m_node2UserIndex);if(r!==-1){let e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(n,this.m_node1UserIndex,-1)}if(i!==-1){let e=this.m_AET.getElement(i);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(n,this.m_node2UserIndex,-1)}let a=-1;r!==-1&&i!==-1?(this.m_AET.deleteNode(r),this.m_AET.deleteNode(i),e[t]=z):a=r===-1?i:r,a!==-1&&(this.insertEdge_(n,a)||this.m_AET.deleteNode(a),e[t]=z)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){let n=U.getNAN(),r=U.getNAN();this.m_shape.queryXY(e,n);let i=this.m_shape.getNextVertex(e);this.m_shape.queryXY(i,r);let a=!1;if(n.y<r.y){a=!0;let n=this.m_edges.newEdge(e),r;t===-1?r=this.m_AET.addElement(n):(r=t,this.m_AET.setElement(r,n)),this.m_shape.getUserIndex(i,this.m_node1UserIndex)===-1?this.m_shape.setUserIndex(i,this.m_node1UserIndex,r):this.m_shape.setUserIndex(i,this.m_node2UserIndex,r);let o=this.m_shape.getPathFromVertex(e);this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)===0&&this.m_unknownNodes.push(r)}let o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,r),n.y<r.y){a=!0;let n=this.m_edges.newEdge(o),r;t===-1?r=this.m_AET.addElement(n):(r=t,this.m_AET.setElement(r,n)),this.m_shape.getUserIndex(o,this.m_node1UserIndex)===-1?this.m_shape.setUserIndex(o,this.m_node1UserIndex,r):this.m_shape.setUserIndex(o,this.m_node2UserIndex,r);let i=this.m_shape.getPathFromVertex(e);this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)===0&&this.m_unknownNodes.push(r)}return a}fixRingSelfTangency_(){let e=[],t=[],n=-1,r=-1,i=new U,a=z,o=z,s=-1,c=new ti(this);for(let l=c.next();l!==z;l=c.next()){let c=new U;this.m_shape.queryXY(l,c);let u=this.m_shape.getPathFromVertex(l);i.equals(c)&&o===u?(r===-1&&(n=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,n,-1),r=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,r,-1)),s===-1&&(s=t.length,this.m_shape.setUserIndex(a,r,s),t.push(1),this.m_shape.getPathUserIndex(u,n)===-1&&(this.m_shape.setPathUserIndex(u,n,a),e.push(u))),this.m_shape.setUserIndex(l,r,s),t[t.length-1]++):(s=-1,i.assign(c)),a=l,o=u}if(e.length===0)return!1;l(n!==-1);for(let i=0,a=e.length;i<a;i++){let a=e[i],o=this.m_shape.getPathUserIndex(a,n),s=this.m_shape.getUserIndex(o,r),c=[],l=[];c.push(o),l.push(s);for(let e=this.m_shape.getNextVertex(o);e!==o;e=this.m_shape.getNextVertex(e)){let n=e,i=this.m_shape.getUserIndex(n,r);if(i!==-1){if(l.length===0){l.push(i),c.push(n);continue}if(l.at(-1)===i){let a=c.at(-1);this.m_shape.peelALoopIntoAPath(a,n),this.m_shape.setUserIndex(e,r,-1),t[i]--,t[i]===1&&(t[i]=0,l.pop(),c.pop()),o=a,e=a}else c.push(e),l.push(i)}}}return this.m_shape.removePathUserIndex(n),this.m_shape.removeUserIndex(r),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){let n={stack:[],error:void 0,hasError:!1};try{let t=!1,r,i=e(n,Et(()=>{this.m_sortedVerticesArray=null}),!1);if(this.m_sortedVertices===null){let e=this.m_shape.getPointCount(this.m_geometry);r=new Re(0);for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,i=this.m_shape.getPathSize(e);n<i;n++)r.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(r,0,e),this.progress_(!0),this.m_sortedVerticesArray=r}else i.bForget=!0;if(this.m_bFixSelfTangency&&(t=this.fixRingSelfTangency_()),this.m_shape.getPathCount(this.m_geometry)===1){let e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){let t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);let a=[];this.m_yScanline=NaN;let o=U.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);let s=new ti(this);for(let e=s.next();e!==z&&(this.progress_(),this.m_shape.queryXY(e,o),o.y!==this.m_yScanline&&a.length&&(t=this.processBunchForRingOrientationTest_(a)||t,this.m_sweepComparator.reset(),a.length=0),a.push(e),this.m_yScanline=o.y,this.m_unknownRingOrientationCount!==0);e=s.next());return this.m_unknownRingOrientationCount>0&&(t=this.processBunchForRingOrientationTest_(a)||t,a.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),t}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}fixRingOrientationImplSimplify_(){let e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==z;)if(this.progress_(),this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)===3){this.m_shape.setExterior(t,!0);for(let n=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);n!==z;){let r=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e.push(n),this.m_shape.setExterior(n,!1),this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,t),n=r}let n=t,r=e.length;for(let e=this.m_shape.getNextPath(t);r>0&&e!==z;e=this.m_shape.getNextPath(e),--r){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)===t){n=e;continue}n=z;break}if(r!==0){n=t;for(let t=0,r=e.length;t<r;t++){let r=e[t];this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,nt),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(n),r),n=r}}e.length=0,t=this.m_shape.getNextPath(n)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){let e=this.m_shape.createPathUserIndex(),t=0,n=[];for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==z;)if(this.progress_(),this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)===3){this.m_shape.setExterior(r,!0),this.m_shape.setPathUserIndex(r,e,t),t++;for(let e=this.m_shape.getPathUserIndex(r,this.m_pathParentageIndex);e!==z;){let t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);n.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,r),e=t}let i=r,a=n.length,o=t;for(let t=this.m_shape.getNextPath(r);a>0&&t!==z;t=this.m_shape.getNextPath(t),--a){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)===r){i=t,this.m_shape.setPathUserIndex(t,e,-o),o++;continue}i=z;break}if(a!==0){i=r,o=t;for(let t=0,r=n.length;t<r;t++){let r=n[t];this.m_shape.setPathUserIndex(r,e,-o),o++,this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,nt)}i=r}t=o,n.length=0,r=this.m_shape.getNextPath(i)}else r=this.m_shape.getNextPath(r);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function ri(e,t,n,r,i,a){let o=new ii(a);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=n,o.m_bFixSelfTangency=r,o.m_polylineDegeneracies=i,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class ii{m_shape=null;m_progressTracker;m_geometry=z;m_sortedVertices=new Fe;m_bunchEdgeEndPoints=[];m_bunchEdgeCenterPoints=[];m_bunchEdgeIndices=[];m_sorterSegmentBuffer1=null;m_sorterSegmentBuffer2=null;m_knownSimpleResult=-1;m_sortedVerticesListIndex=-1;m_polylineDegeneracies=z;m_userIndexSortedIndexToVertex=-1;m_userIndexSortedAngleIndexToVertex=-1;m_nextVertexToProcess=-1;m_firstCoincidentVertex=-1;m_progressCounter=0;m_bFixSelfTangency=!1;m_bHasSegmentParentage=!1;m_bHasSegments=!1;constructor(e){this.m_progressTracker=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){let n=this.m_bunchEdgeEndPoints[e],r=new U;this.m_shape.queryXY(n,r);let i=new U,a=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(a,i),r.equals(i))return 0;let o=this.m_bunchEdgeCenterPoints[e],s=new U;this.m_shape.queryXY(o,s);let c=this.m_bunchEdgeCenterPoints[t],l=new U;this.m_shape.queryXY(c,l);let u=new U;u.setSub(r,s);let d=new U;return d.setSub(i,l),(u.isZero()||d.isZero())&&w(``),U.compareVectors(u,d)}compareAnglesCurves_(e,t){let n=this.m_bunchEdgeEndPoints[e],r=this.m_bunchEdgeEndPoints[t],i=this.m_bunchEdgeCenterPoints[e],a=this.m_bunchEdgeCenterPoints[t],o=this.m_shape.getNextVertex(i)===n,s=this.m_shape.getNextVertex(a)===r,c=o?this.m_shape.isCurve(i):this.m_shape.isCurve(n),l=s?this.m_shape.isCurve(a):this.m_shape.isCurve(r);return!c&&!l?this.compareAnglesLines_(e,t):(this.m_sorterSegmentBuffer1||=new F,this.m_sorterSegmentBuffer2||=new F,o?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),s?this.m_shape.querySegment(a,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(r,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse()),ce(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get()))}beforeRemoveVertex_(e,t){let n=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===n&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===n&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,n),this.removeAngleSortInfo_(e),t){let t=this.m_shape.getPathFromVertex(e);if(t!==z&&this.m_shape.getFirstVertex(t)===e){let n=this.m_shape.getNextVertex(e);if(n!==e){if(this.m_shape.getPathFromVertex(n)===t){this.m_shape.setFirstVertex(t,n);return}{let n=this.m_shape.getPrevVertex(e);if(n!==e&&this.m_shape.getPathFromVertex(n)===t){this.m_shape.setFirstVertex(t,n);return}}}this.m_shape.setFirstVertex(t,z),this.m_shape.setLastVertex(t,z)}}}processBunch_(){let e=!1,t=new U(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let n=this.m_firstCoincidentVertex,r=0,i=!0;for(;n!==this.m_nextVertexToProcess;){let e=this.m_sortedVertices.getData(n);i&&=(this.m_shape.queryXY(e,t),!1);let a=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex)!==nt&&(this.m_bunchEdgeEndPoints.push(a),this.m_shape.setUserIndex(a,this.m_userIndexSortedAngleIndexToVertex,nt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(r++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==nt&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,nt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(r++)),n=this.m_sortedVertices.getNext(n)}if(this.m_bunchEdgeEndPoints.length<2){this.m_bunchEdgeEndPoints.length===1&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){let t=this.m_bunchEdgeIndices[e],n=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(n,this.m_userIndexSortedAngleIndexToVertex,e)}let a=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){let t=this.m_bunchEdgeIndices[e];if(t===-1)continue;let n=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(n,this.m_userIndexSortedAngleIndexToVertex,-1)}if(a){e=!0;continue}break}return e}processCrossOvers_(e){let t=!1,n=!0;for(;n;){n=!1;let r=0;this.m_bunchEdgeIndices[r]===-1&&(r=this.getNextEdgeIndex_(r));let i=this.getNextEdgeIndex_(r);for(let a=0,o=this.m_bunchEdgeIndices.length;a<o&&r!==-1&&i!==-1&&r!==i;a++){let a=this.m_bunchEdgeIndices[r],o=this.m_bunchEdgeIndices[i],s=this.m_bunchEdgeEndPoints[a],c=this.m_bunchEdgeEndPoints[o],l=this.m_shape.getNextVertex(s),u=!1;this.m_shape.isEqualXYPoint2D(l,e)||(l=this.m_shape.getPrevVertex(s),u=!0);let d=this.m_shape.getNextVertex(c),f=!1;this.m_shape.isEqualXYPoint2D(d,e)||(d=this.m_shape.getPrevVertex(c),f=!0);let p=u?this.m_shape.getPrevVertex(l):this.m_shape.getNextVertex(l),m=f?this.m_shape.getPrevVertex(d):this.m_shape.getNextVertex(d),h=!1;(this.removeSpike_(l)||this.removeSpike_(d)||this.removeSpike_(s)||this.removeSpike_(c)||this.removeSpike_(p)||this.removeSpike_(m))&&(h=!0),l!==d&&(!h&&this.m_shape.isEqualXY(s,c)&&(h=this.resolveOverlap_(u,f,l,s,d,c)),!h&&this.m_shape.isEqualXY(p,m)&&(h=this.resolveOverlap_(!u,!f,l,p,d,m)),!h&&this.m_shape.isEqualXY(s,m)&&(h=this.resolveOverlap_(u,!f,l,s,d,m)),!h&&this.m_shape.isEqualXY(p,c)&&(h=this.resolveOverlap_(!u,f,l,p,d,c))),h&&(t=!0),n||=h,r=h?this.getNextEdgeIndex_(r):i,i=this.getNextEdgeIndex_(r)}}if(!t){let n=0;this.m_bunchEdgeIndices[n]===-1&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,a=this.m_bunchEdgeIndices.length;i<a&&n!==-1&&r!==-1&&n!==r;i++){let i=this.m_bunchEdgeIndices[n],a=this.m_bunchEdgeIndices[r],o=this.m_bunchEdgeEndPoints[i],s=this.m_bunchEdgeEndPoints[a],c=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(c,e)||(c=this.m_shape.getPrevVertex(o));let l=this.m_shape.getNextVertex(s);this.m_shape.isEqualXYPoint2D(l,e)||(l=this.m_shape.getPrevVertex(s));let u=this.getDirection_(c,o),d=this.getDirection_(l,s),f=u?this.m_shape.getPrevVertex(c):this.m_shape.getNextVertex(c),p=d?this.m_shape.getPrevVertex(l):this.m_shape.getNextVertex(l),m=this.detectAndResolveCrossOver_(u,d,o,c,f,s,l,p);if(m===1){t=!0;continue}m===0?(n=this.getNextEdgeIndex_(n),r=this.getNextEdgeIndex_(n)):(n=this.getPrevEdgeIndex_(n),r=this.getNextEdgeIndex_(n))}}return t}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===i.enumPolygon&&this.m_shape.getFillRule(this.m_geometry)===1&&new Xs(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();let t=this.m_shape.getPointCount(this.m_geometry),n=new Re(0);this.m_shape.dbgVerifyMonotone();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let r=0,i=this.m_shape.getPathSize(e);r<i;r++)this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1),n.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(n,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let e=0;e<t;e++){let t=n.read(e),r=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,t);this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,r)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let r=0,a=!1;do{a=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);let t=new U(0,0);this.m_firstCoincidentVertex!==Fe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let n=0,i=this.m_firstCoincidentVertex;for(;i!==Fe.st_nullNode()&&(i=this.m_sortedVertices.getNext(i),i!==Fe.st_nullNode());){this.progress_();let e=this.m_sortedVertices.getData(i),r=U.getNAN();if(this.m_shape.queryXY(e,r),t.equals(r)){n++;continue}if(n>0){this.m_nextVertexToProcess=i;let e=this.processBunch_();i=this.m_nextVertexToProcess,i!==Fe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(i),r),e&&(a=!0)}t.setCoordsPoint2D(r),this.m_firstCoincidentVertex=i,n=0}this.m_nextVertexToProcess=-1,n>0&&this.processBunch_()&&(a=!0),r++>10&&o(``),a&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(a=!0),e||=a}while(a);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=Zr(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,n,r,i,a,o,s){if(r===o)return this.removeAngleSortInfo_(n),this.removeAngleSortInfo_(a),-1;let c=this.m_shape.getUserIndex(n,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),u=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),d=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),f=H(8,NaN),p=H(4,NaN);f[0]=0,p[0]=c,f[1]=0,p[1]=l,f[2]=1,p[2]=u,f[3]=1,p[3]=d;for(let e=1;e<4;e++){let t=p[e],n=f[e],r=e-1;for(;r>=0&&p[r]>t;)p[r+1]=p[r],f[r+1]=f[r],r--;p[r+1]=t,f[r+1]=n}let m=0;if(f[0]&&(m|=1),f[1]&&(m|=2),f[2]&&(m|=4),f[3]&&(m|=8),m!==5&&m!==10)return 0;if(e!==t&&(s=gt(a,a=s)),e)this.m_shape.setNextVertex(s,r),this.m_shape.setPrevVertex(r,s),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(s,r),this.m_shape.setNextVertex(r,s),this.m_shape.setPrevVertex(i,o),this.m_shape.setNextVertex(o,i),this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(r),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(r,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){let e=this.m_shape.getVertexIndex(r),t=this.m_shape.getVertexIndex(o),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);let i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}}return 1}resolveOverlap_(e,t,n,r,i,a){return this.resolveOverlapOddEven_(e,t,n,r,i,a)}resolveOverlapOddEven_(e,t,n,r,i,a){if(e!==t){e||(i=gt(n,n=i),a=gt(r,r=a));let t=this.m_shape.getNextVertex(i),o=this.m_shape.getNextVertex(n);if(this.m_shape.setNextVertex(n,t),this.m_shape.setPrevVertex(t,n),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegments){let e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(i),r=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);let a=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,a),this.m_shape.setSegmentToIndex(t,r)}if(this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(i);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(i,e,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(a,!0)}this.removeSpike_(i)}else{let o=e?n:r,s=t?i:a,c=e?r:n,l=t?a:i,u=null;if(this.m_bHasSegments){let e=this.m_shape.getVertexIndex(l);u=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);let t=this.m_shape.getVertexIndex(s);this.m_shape.setSegmentToIndex(t,null);let n=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(n,null)}let d=-1;this.m_bHasSegmentParentage&&(d=this.m_shape.getSegmentParentage(l));let f=!1;this.m_shape.setNextVertex(o,s),this.m_shape.setNextVertex(s,o),this.m_shape.setPrevVertex(c,l),this.m_shape.setPrevVertex(l,c);let p=l;for(;p!==s;){let e=this.m_shape.getPrevVertex(p),t=this.m_shape.getNextVertex(p);if(this.m_shape.setPrevVertex(p,t),this.m_shape.setNextVertex(p,e),f||=p===o,this.m_bHasSegments&&p!==o){let e=this.m_shape.getVertexIndex(t),n=u;u=this.m_shape.getSegmentFromIndex(e),n!==null&&n.reverse(),this.m_shape.setSegmentToIndex(e,n)}if(this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,d),d=e}p=t}let m=null;if(!f){let e=this.m_shape.getPrevVertex(s),t=this.m_shape.getNextVertex(s);if(this.m_shape.setPrevVertex(s,t),this.m_shape.setNextVertex(s,e),this.m_bHasSegments){let e=this.m_shape.getVertexIndex(s);m=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let h=-1,g=-1;if(this.m_bHasSegmentParentage&&(h=f?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(s),g=this.m_shape.getSegmentParentage(c)),this.transferVertexData_(s,o),this.beforeRemoveVertex_(s,!0),this.m_shape.removeVertexInternal(s,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(l,c),this.beforeRemoveVertex_(l,!0),this.m_shape.removeVertexInternal(l,!0),this.removeAngleSortInfo_(c),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,h,!0),this.m_shape.setSegmentParentageAndBreak(c,g,!0)),m){let e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,m)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==z;){let n=this.m_shape.getNextPath(t),r=this.m_shape.getFirstVertex(t);for(let n=0,i=this.m_shape.getPathSize(t);n<i&&i>1;){this.progress_();let{v:a,bModified:o}=this.checkAndCleanupSpike_(t,r);if(a===z)break;o?(e=!0,r=a,n=0,i=this.m_shape.getPathSize(t)):(r=a,n++)}t=n}return e}checkAndCleanupSpike_(e,t){let n={v:z,bModified:!1},r=this.m_shape.getPrevVertex(t),i=this.m_shape.getNextVertex(t),a=z,o=z;for(;this.m_shape.isEqualXY(r,i)&&(a=r,o=i,i!==t);)r=this.m_shape.getPrevVertex(r),i=this.m_shape.getNextVertex(i);if(a===z)return n.v=i,n;n.bModified=!0;for(let e=this.m_shape.getNextVertex(a);this.beforeRemoveVertex_(e,!1),e!==o;e=this.m_shape.getNextVertex(e));if(a!==t){let e=this.m_shape.peelALoopIntoAPath(a,o);this.m_polylineDegeneracies===z?this.m_shape.removePath(e):this.m_shape.movePath(this.m_polylineDegeneracies,z,e)}else return this.m_polylineDegeneracies===z?this.m_shape.removePath(e):this.m_shape.movePath(this.m_polylineDegeneracies,z,e),n.v=z,n;return n.v=a,n}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),n=this.m_shape.getNextVertex(e),r=z,i=z;for(;this.m_shape.isEqualXY(t,n)&&(r=t,i=n,n!==e);)t=this.m_shape.getPrevVertex(t),n=this.m_shape.getNextVertex(n);if(r===z)return!1;if(this.m_shape.peelALoop(r,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)),this.removeAngleSortInfo_(r),this.m_polylineDegeneracies===z)for(let e=this.m_shape.getNextVertex(i);;){let t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(e),null),this.m_shape.removeVertexInternal(e,!1),e===i)break;e=t}else{for(let e=i;;){let t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!1),e=t,e===i)break}this.m_shape.insertClosedPath(this.m_polylineDegeneracies,z,i,i,[!1])}return!0}fixOrphanVertices_(){let e=0;for(let e=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());e!==-1;e=this.m_sortedVertices.getNext(e)){let t=this.m_sortedVertices.getData(e);this.m_shape.setPathToVertex(t,z)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==z;){let r=this.m_shape.getFirstVertex(n);if(r===z||this.m_shape.getPathFromVertex(r)!==z){let e=n;n=this.m_shape.getNextPath(n),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(r,n);let i=1;for(let e=this.m_shape.getNextVertex(r);e!==r;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,n),i++;this.m_shape.setRingAreaValid(n,!1),this.m_shape.setPathSize(n,i),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(r)),t+=i,e++,n=this.m_shape.getNextPath(n)}for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());n!==-1;n=this.m_sortedVertices.getNext(n)){let r=this.m_sortedVertices.getData(n);if(this.m_shape.getPathFromVertex(r)!==z)continue;let i=this.m_shape.insertClosedPath(this.m_geometry,z,r,r,[!1]);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let n=0;for(let e=this.m_shape.getFirstGeometry();e!==z;e=this.m_shape.getNextGeometry(e))n+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(n)}getNextEdgeIndex_(e){if(e===-1)return-1;for(let t=0,n=this.m_bunchEdgeIndices.length-1;t<n;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,this.m_bunchEdgeIndices[e]!==-1)return e;return-1}getPrevEdgeIndex_(e){if(e===-1)return-1;for(let t=0,n=this.m_bunchEdgeIndices.length-1;t<n;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,this.m_bunchEdgeIndices[e]!==-1)return e;return-1}transferVertexData_(e,t){let n=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),r=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,n),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,r)}removeAngleSortInfo_(e){let t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);t!==-1&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function ai(e,t,r,a,o,s=!0){switch(ci(a)){case 0:break;case 1:n(`relation string length has to be 9 characters`);break;default:n(`relation string`)}if(s){let n=xi(a,e.getDimension(),t.getDimension());if(n!==0)return Ri(e,t,r,n,o)}let c=0;if(typeof r==`number`)c=r;else{let n=T.constructEmpty();e.queryEnvelope(n);let i=T.constructEmpty();t.queryEnvelope(i);let a=T.constructEmpty();a.setCoords({env2D:n}),a.mergeEnvelope2D(i),c=Oe(r,a,!1)}let l=Mi(e,c),u=Mi(t,c);if(l.isEmpty()||u.isEmpty())return bi(l,u,a);let d=l.getGeometryType(),f=u.getGeometryType(),p=!1;switch(d){case i.enumPolygon:switch(f){case i.enumPolygon:p=li(l,u,c,a,o);break;case i.enumPolyline:p=ui(l,u,c,a,o);break;case i.enumPoint:p=hi(l,u,c,a);break;case i.enumMultiPoint:p=di(l,u,c,a,o)}break;case i.enumPolyline:switch(f){case i.enumPolygon:p=ui(u,l,c,Ni(a),o);break;case i.enumPolyline:p=fi(l,u,c,a,o);break;case i.enumPoint:p=gi(l,u,c,a,o);break;case i.enumMultiPoint:p=pi(l,u,c,a,o)}break;case i.enumPoint:switch(f){case i.enumPolygon:p=hi(u,l,c,Ni(a));break;case i.enumPolyline:p=gi(u,l,c,Ni(a),o);break;case i.enumPoint:p=vi(l,u,c,a);break;case i.enumMultiPoint:p=_i(u,l,c,Ni(a))}break;case i.enumMultiPoint:switch(f){case i.enumPolygon:p=di(u,l,c,Ni(a),o);break;case i.enumPolyline:p=pi(u,l,c,Ni(a),o);break;case i.enumMultiPoint:p=mi(l,u,c,a,o);break;case i.enumPoint:p=_i(l,u,c,a)}break;default:p=!1}return p}function oi(e,t,n,r){let i=new Ai;i.resetMatrix_(),i.setPredicates_(`T*****F**`),i.setAreaAreaPredicates_();let a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(o);let s=!1;if(Hi(a,o,n)&&(i.areaAreaDisjointPredicates_(e,t),s=!0),s||X(e,t),s)return yi(i.m_matrix,i.m_scl);let c=new N,l=c.addGeometry(e),u=c.addGeometry(t),d=null,f=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){d=new _s;let e=ms(n,c.getEnvelope2D(r));f=gs(e,0),ss(c,e,n,12e3,d,null,r)}ys(c,new Ne(n,0).add(f),r,!1,!1);let p=c.getGeometry(u).getBoundary();if(c.filterClosePoints(0,!0,!0,!1,z),ri(c,l,-1,!1,z,r),c.getPointCount(l)===0)return!1;ri(c,u,-1,!1,z,r),i.setEditShape_(c,r);let m=c.getPointCount(u)===0;if(!m){i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape();let e=yi(i.m_matrix,i.m_scl);if(!e)return e}let h=c.getGeometry(l);return c=new N,l=c.addGeometry(h),u=c.addGeometry(p),i.setEditShape_(c,r),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(m?`T*****F**`:`******F**`),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape(),yi(i.m_matrix,i.m_scl)}function si(e,t,n,r){let i=new Ai;i.resetMatrix_(),i.setPredicates_(`T*****F**`),i.setAreaLinePredicates_();let a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(o);let s=!1;if(Hi(a,o,n)&&(i.areaLineDisjointPredicates_(e,t),s=!0),s||X(e,t),s)return yi(i.m_matrix,i.m_scl);let c=new N,l=c.addGeometry(e),u=c.addGeometry(t);return i.setEditShapeCrackAndCluster_(c,new Ne(n,0),r),c.getPointCount(l)!==0&&(i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape(),yi(i.m_matrix,i.m_scl))}function ci(e){if(e.length!==9)return 1;for(let t=0;t<9;t++){let n=e[t];if(n!==`*`&&n!==`T`&&n!==`F`&&n!==`0`&&n!==`1`&&n!==`2`)return 2}return 0}function li(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaAreaPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaAreaDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function ui(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaLinePredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaLineDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexB=a.m_topoGraph.createUserIndexForClusters(),ki(s,a.m_topoGraph,a.m_clusterIndexB),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexB),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function di(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaPointPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaPointDisjointPredicates_(e),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function fi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLineLinePredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.lineLineDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexA=a.m_topoGraph.createUserIndexForClusters(),a.m_clusterIndexB=a.m_topoGraph.createUserIndexForClusters(),ki(o,a.m_topoGraph,a.m_clusterIndexA),ki(s,a.m_topoGraph,a.m_clusterIndexB),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexA),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexB),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function pi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLinePointPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.linePointDisjointPredicates_(e),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexA=a.m_topoGraph.createUserIndexForClusters(),ki(o,a.m_topoGraph,a.m_clusterIndexA),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexA),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function mi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setPointPointPredicates_();let o=new T,s=new T;e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.pointPointDisjointPredicates_(),c=!0),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function hi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaPointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=!1;if(Ui(s,o,n)&&(a.areaPointDisjointPredicates_(e),c=!0),!c){let t=qo(e,s,n);if(t===1)a.m_matrix[0]=0,a.m_matrix[2]=2,a.m_matrix[3]=-1,a.m_matrix[5]=1,a.m_matrix[6]=-1;else if(t===2){if(a.m_matrix[6]=-1,e.calculateArea2D()!==0)a.m_matrix[0]=-1,a.m_matrix[3]=0,a.m_matrix[2]=2,a.m_matrix[5]=1;else{a.m_matrix[0]=0,a.m_matrix[3]=-1,a.m_matrix[5]=-1;let t=T.constructEmpty();e.queryEnvelope(t),a.m_matrix[2]=!t.height()&&!t.width()?-1:1}}else a.areaPointDisjointPredicates_(e)}return yi(a.m_matrix,r)}function gi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLinePointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=!1;if(Ui(s,o,n)&&(a.linePointDisjointPredicates_(e),c=!0),!c){let r=null,o=!1,s=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&(Ri(e,t,n,4,i)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(r=P(e),s=!Ri(r,t,n,4,i),o=!0,s?a.m_matrix[0]=-1:a.m_matrix[0]=0),a.m_matrix[6]=-1)),a.m_performPredicates[3]&&(r!==null&&r.isEmpty()?a.m_matrix[3]=-1:(o||=(r??=P(e),s=!Ri(r,t,n,4,i),!0),a.m_matrix[3]=s?0:-1)),a.m_performPredicates[5]){if(r!==null&&r.isEmpty())a.m_matrix[5]=-1;else if(o&&!s)a.m_matrix[5]=0;else{r===null&&(r=P(e));let o=Ri(r,t,n,3,i);a.m_matrix[5]=o?-1:0}}if(a.m_performPredicates[2]){if(e.calculateLength2D()!==0)a.m_matrix[2]=1;else{let r=new A({vd:e.getDescription()});r.addPoints(e,0,e.getPointCount());let o=Ri(r,t,n,3,i);a.m_matrix[2]=o?-1:0}}}return yi(a.m_matrix,a.m_scl)}function _i(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setPointPointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=new U,l=!1;if(Ui(s,o,n)&&(a.pointPointDisjointPredicates_(),l=!0),!l){let t=!1,r=!0,i=n*n;for(let n=0;n<e.getPointCount()&&(e.queryXY(n,c),U.sqrDistance(c,s)<=i?t=!0:r=!1,!t||r);n++);t?(a.m_matrix[0]=0,r?a.m_matrix[2]=-1:a.m_matrix[2]=0,a.m_matrix[6]=-1):(a.m_matrix[0]=-1,a.m_matrix[2]=0,a.m_matrix[6]=0)}return yi(a.m_matrix,r)}function vi(e,t,n,r,i){let a=e.getXY(),o=t.getXY(),s=H(9,-1);return U.sqrDistance(a,o)<=n*n?s[0]=0:(s[2]=0,s[6]=0),s[8]=2,yi(s,r)}function yi(e,t){for(let n=0;n<9;n++)switch(t[n]){case`T`:if(e[n]===-1)return!1;break;case`F`:if(e[n]!==-1)return!1;break;case`0`:if(e[n]!==0)return!1;break;case`1`:if(e[n]!==1)return!1;break;case`2`:if(e[n]!==2)return!1}return!0}function bi(e,t,n){let r=H(9,-1);if(e.isEmpty()&&t.isEmpty())return yi(r,n);let a=!1,o;e.isEmpty()?(o=t,a=!0):o=e,r[0]=-1,r[1]=-1,r[3]=-1,r[4]=-1,r[6]=-1,r[7]=-1,r[8]=2;let c=o.getGeometryType();if(s(c)){if(c===i.enumPolygon){if(o.calculateArea2D()!==0)r[2]=2,r[5]=1;else{r[5]=-1;let e=T.constructEmpty();o.queryEnvelope(e),r[2]=!e.height()&&!e.width()?0:1}}else r[2]=+(o.calculateLength2D()!==0),r[5]=M(o)?0:-1}else r[2]=0,r[5]=-1;return a&&ji(r),yi(r,n)}function xi(e,t,n){return Si(e)?3:Ci(e)?4:wi(e,t,n)?8:Ti(e,t,n)?16:Di(e)?64:Ei(e)?1:Oi(e,t,n)?32:0}function Si(e){return e===`T*F**FFF*`}function Ci(e){return e===`FF*FF****`}function wi(e,t,n){return t===0&&n===0?!1:t===2&&n===2?e===`F***T****`:(t===2||t===1)&&n===0&&e===`F**T*****`}function Ti(e,t,n){return t>n?e===`T*****T**`:t===1&&n===1&&e===`0********`}function Ei(e){return e===`T*****FF*`}function Di(e){return e===`T**FF*FF*`}function Oi(e,t,n){return t===n?t===1?e===`1*T***T**`:e===`T*T***T**`:!1}function ki(e,t,n){let r=t.getGeometryID(e);for(let e=t.getFirstCluster();e!==z;e=t.getNextCluster(e)){if((t.getClusterParentage(e)&r)===0)continue;let i=t.getClusterHalfEdge(e);if(i===z){t.setClusterUserIndex(e,n,0);continue}let a=i,o=0;do{let e=a;(t.getHalfEdgeParentage(e)&r)!==0&&o++,a=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(a!==i);t.setClusterUserIndex(e,n,o)}}class Ai{m_clusterIndexA=-1;m_clusterIndexB=-1;m_visitedIndex=-1;m_topoGraph=new sr;m_matrix=H(9,0);m_maxDim=H(9,0);m_performPredicates=H(9,!1);m_scl=``;m_predicateCount=0;nullFunc(){return o(`should not be called`),!1}m_predicatesHalfEdge=this.nullFunc;m_predicatesCluster=this.nullFunc;constructor(){}resetMatrix_(){this.m_matrix.fill(-2),this.m_maxDim.fill(-2)}setPredicates_(e){this.m_scl=e;for(let e=0;e<9;e++)this.m_scl[e]===`*`?this.m_performPredicates[e]=!1:(this.m_performPredicates[e]=!0,this.m_predicateCount++)}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&this.m_matrix[e]===-2&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return this.m_matrix[e]===-2?!1:this.m_matrix[e]===-1?(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):this.m_scl[e]!==`T`&&this.m_scl[e]!==`F`&&this.m_matrix[e]<this.m_maxDim[e]?!1:(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0)}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,n,r,i){let a=t!==-1,o=r!==-1;if(a||o){if(!(n!==`T`&&n!==`F`&&a||i!==`T`&&i!==`F`&&o)||e.calculateArea2D()!==0)a&&(this.m_matrix[t]=2),o&&(this.m_matrix[r]=1);else if(o&&(this.m_matrix[r]=-1),a){let n=T.constructEmpty();e.queryEnvelope(n),this.m_matrix[t]=!n.height()&&!n.width()?0:1}}}areaAreaContainsPredicates_(e){this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(e){this.areaAreaContainsPredicates_(e),ji(this.m_matrix)}areaLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){let e=this.m_scl[6],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[6]=+!!n}this.m_performPredicates[7]&&(M(t)?this.m_matrix[7]=0:this.m_matrix[7]=-1),this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){let e=this.m_scl[0],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[0]=+!!n}this.m_performPredicates[1]&&(M(t)?this.m_matrix[1]=0:this.m_matrix[1]=-1),this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){let t=this.m_scl[2],n=t!==`T`&&t!==`F`?e.calculateLength2D()!==0:!0;this.m_matrix[2]=+!!n}if(this.m_performPredicates[5]&&(M(e)?this.m_matrix[5]=0:this.m_matrix[5]=-1),this.m_performPredicates[6]){let e=this.m_scl[6],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[6]=+!!n}this.m_performPredicates[7]&&(M(t)?this.m_matrix[7]=0:this.m_matrix[7]=-1)}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){let t=this.m_scl[2],n=t!==`T`&&t!==`F`?e.calculateLength2D()!==0:!0;this.m_matrix[2]=+!!n}if(this.m_performPredicates[5]){let t=M(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);let n=this.isPredicateKnown_(1);r&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,n,3);let t=this.isPredicateKnown_(3);r&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,n);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,n,5);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,n,t,7);let i=this.isPredicateKnown_(7);r&&=i}return r}areaLinePredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(1);r&&=i}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,n);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,n);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);let n=this.isPredicateKnown_(6);r&&=n}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(7);r&&=i}return r}lineLinePredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB,1);let i=this.isPredicateKnown_(1);r&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,n,t,this.m_clusterIndexB,this.m_clusterIndexA,3);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,n,this.m_clusterIndexA,5);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,n,t,this.m_clusterIndexB,7);let i=this.isPredicateKnown_(7);r&&=i}return r}areaPointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);let n=this.isPredicateKnown_(0);r&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);let n=this.isPredicateKnown_(2);r&&=n}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);let n=this.isPredicateKnown_(5);r&&=n}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);let n=this.isPredicateKnown_(6);r&&=n}return r}linePointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(6);r&&=i}return r}pointPointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}return r}interiorAreaInteriorArea_(e,t,n){if(this.m_matrix[0]===2)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e);(r&t)!==0&&(r&n)!==0&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,n){if(this.m_matrix[n]===1)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(r&t)!==0&&(i&t)!==0&&(this.m_matrix[n]=1)}interiorAreaExteriorArea_(e,t,n,r){if(this.m_matrix[r]===2)return;let i=this.m_topoGraph.getHalfEdgeFaceParentage(e);(i&t)!==0&&(i&n)===0&&(this.m_matrix[r]=2)}boundaryAreaBoundaryArea_(e,t,n){if(this.m_matrix[4]===1)return;let r=this.m_topoGraph.getHalfEdgeParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[4]=1;return}if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if((i&t)!==0&&(i&n)!==0){this.m_matrix[4]=0;return}}}boundaryAreaExteriorArea_(e,t,n,r){if(this.m_matrix[r]===1)return;let i=this.m_topoGraph.getHalfEdgeFaceParentage(e),a=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(i&n)===0&&(a&n)===0&&(this.m_matrix[r]=1)}interiorAreaInteriorLine_(e,t,n){if(this.m_matrix[0]===1)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(r&t)!==0&&(i&t)!==0&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[1]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)===0&&(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[1]=0;return}}}}interiorAreaExteriorLine_(e,t,n){this.m_matrix[2]!==2&&(this.m_topoGraph.getHalfEdgeParentage(e)&t)!==0&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,n,r){if(this.m_matrix[3]===1)return;let i=this.m_topoGraph.getHalfEdgeParentage(e);if((i&t)!==0&&(i&n)!==0){this.m_matrix[3]=1;return}if(this.m_matrix[3]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2==0){this.m_matrix[3]=0;return}}}}boundaryAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[4]=0;return}}}}boundaryAreaExteriorLine_(e,t,n){if(this.m_matrix[5]===1)return;let r=this.m_topoGraph.getHalfEdgeParentage(e);(r&t)!==0&&(r&n)===0&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(this.m_matrix[6]===1)return;let n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(n&t)===0&&(r&t)===0&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[7]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)===0&&(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)===0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[7]=0;return}}}}interiorLineInteriorLine_(e,t,n,r,i){if(this.m_matrix[0]===1)return;let a=this.m_topoGraph.getHalfEdgeParentage(e);if((a&t)!==0&&(a&n)!==0){this.m_matrix[0]=1;return}if(this.m_matrix[0]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let a=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(a);if((o&t)!==0&&(o&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(a,r),t=this.m_topoGraph.getClusterUserIndex(a,i);if(e%2==0&&t%2==0){this.m_matrix[0]=0;return}}}}interiorLineBoundaryLine_(e,t,n,r,i,a){if(this.m_matrix[a]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let o=this.m_topoGraph.getHalfEdgeTo(e),s=this.m_topoGraph.getClusterParentage(o);if((s&t)!==0&&(s&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(o,r),t=this.m_topoGraph.getClusterUserIndex(o,i);if(e%2==0&&t%2!=0){this.m_matrix[a]=0;return}}}}interiorLineExteriorLine_(e,t,n,r){if(this.m_matrix[r]===1)return;let i=this.m_topoGraph.getHalfEdgeParentage(e);(i&t)!==0&&(i&n)===0&&(this.m_matrix[r]=1)}boundaryLineBoundaryLine_(e,t,n,r,i){if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let a=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(a);if((o&t)!==0&&(o&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(a,r),t=this.m_topoGraph.getClusterUserIndex(a,i);if(e%2!=0&&t%2!=0){this.m_matrix[4]=0;return}}}}boundaryLineExteriorLine_(e,t,n,r,i){if(this.m_matrix[i]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let t=this.m_topoGraph.getHalfEdgeTo(e);if((this.m_topoGraph.getClusterParentage(t)&n)===0&&this.m_topoGraph.getClusterUserIndex(t,r)%2!=0){this.m_matrix[i]=0;return}}}interiorAreaInteriorPoint_(e,t){if(this.m_matrix[0]!==0&&(this.m_topoGraph.getClusterParentage(e)&t)===0){let n=this.m_topoGraph.getClusterChain(e);if((this.m_topoGraph.getChainParentage(n)&t)!==0){this.m_matrix[0]=0;return}}}interiorAreaExteriorPoint_(e,t){this.m_matrix[2]!==2&&(this.m_topoGraph.getClusterParentage(e)&t)!==0&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,n){if(this.m_matrix[3]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[3]=0;return}}boundaryAreaExteriorPoint_(e,t){this.m_matrix[5]!==1&&(this.m_topoGraph.getClusterParentage(e)&t)!==0&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(this.m_matrix[6]!==0&&(this.m_topoGraph.getClusterParentage(e)&t)===0){let n=this.m_topoGraph.getClusterChain(e);if((this.m_topoGraph.getChainParentage(n)&t)===0){this.m_matrix[6]=0;return}}}interiorLineInteriorPoint_(e,t,n,r){if(this.m_matrix[0]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)!==0&&this.m_topoGraph.getClusterUserIndex(e,r)%2==0){this.m_matrix[0]=0;return}}interiorLineExteriorPoint_(e,t,n,r){if(this.m_matrix[2]!==1){if(this.m_topoGraph.getClusterHalfEdge(e)!==-1){this.m_matrix[2]=1;return}if(this.m_matrix[2]!==0&&(this.m_topoGraph.getClusterParentage(e)&n)===0){this.m_matrix[2]=0;return}}}boundaryLineInteriorPoint_(e,t,n,r){if(this.m_matrix[3]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)!==0&&this.m_topoGraph.getClusterUserIndex(e,r)%2!=0){this.m_matrix[3]=0;return}}boundaryLineExteriorPoint_(e,t,n,r){if(this.m_matrix[5]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)===0&&this.m_topoGraph.getClusterUserIndex(e,r)%2!=0){this.m_matrix[5]=0;return}}exteriorLineInteriorPoint_(e,t,n){if(this.m_matrix[6]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)===0&&(r&n)!==0){this.m_matrix[6]=0;return}}interiorPointInteriorPoint_(e,t,n){if(this.m_matrix[0]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[0]=0;return}}interiorPointExteriorPoint_(e,t,n,r){if(this.m_matrix[r]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)===0){this.m_matrix[r]=0;return}}computeMatrixTopoGraphHalfEdges_(e,t){let n=!1,r=this.m_topoGraph.getGeometryID(e),i=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z){if(this.m_predicatesCluster!==null&&(n=this.m_predicatesCluster(e,r,i),n))break;continue}let a=t;do{let e=a;if(this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex)!==1)do{if(n=this.m_predicatesHalfEdge(e,r,i),n)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==a&&!n);if(n)break;a=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(a!==t);if(n)break}n||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let n=!1,r=this.m_topoGraph.getGeometryID(e),i=this.m_topoGraph.getGeometryID(t);for(let e=this.m_topoGraph.getFirstCluster();e!==z&&(n=this.m_predicatesCluster(e,r,i),!n);e=this.m_topoGraph.getNextCluster(e));n||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,n){let r=0;if(e.hasCurves()){let i=new _s,a=e.getEnvelope2D(n),o=ms(t.total(),a);r=gs(o,0),ss(e,o,t.total(),12e3,i,null,n),i.clearStitcher(e)}ys(e,t.add(r),n,!1,!1),e.filterClosePoints(0,!0,!0,!1,z);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,!1,z,n);this.setEditShape_(e,n)}}function ji(e){let t=e[1],n=e[2],r=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=n,e[7]=r}function Mi(e,t,n){let r=e.getGeometryType();if(a(r)){let t=new E({vd:e.getDescription()});return t.addSegment(e,!0),t}if(r===i.enumEnvelope){let n=e,r=T.constructEmpty();if(e.queryEnvelope(r),r.height()<=t&&r.width()<=t){let t=new B({vd:e.getDescription()});return n.getCenter(t),t}if(r.height()<=t||r.width()<=t){let t=new E({vd:e.getDescription()}),r=new B;return n.queryCornerByVal(0,r),t.startPathPoint(r),n.queryCornerByVal(2,r),t.lineToPoint(r),t}let i=new k({vd:e.getDescription()});return i.addEnvelope(n,!1),i}return e}function Ni(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Pi{m_multiVertexImplA;m_multiVertexImplB;m_queryType;m_bPaths;m_bQuadTree;m_bDone=!1;m_bSwapElements;m_tolerance=0;m_pathIndex;m_pointIndex;m_elementHandle=-1;m_query=T.constructEmpty();m_envInter=T.constructEmpty();m_quadTree=null;m_qtIter;m_segIter;m_function;m_intersector=null;nullFunc(){return o(`should not be called`),!1}constructor(e,t,n,r=!1){this.m_function=this.nullFunc;let i=e.getAccelerators(),a=null;i!=null&&(a=r?i.getQuadTreeForPaths():i.getQuadTree());let o=t.getAccelerators(),c=null;if(o!=null&&(c=r?o.getQuadTreeForPaths():o.getQuadTree()),a===null&&c===null&&!r){let r=e.getPointCount(),i=t.getPointCount();if(r>10&&i>10){let o=T.constructEmpty(),l=T.constructEmpty(),u=T.constructEmpty();e.queryLooseEnvelope(o),t.queryLooseEnvelope(l),o.inflateCoords(n,n),l.inflateCoords(n,n),u.setCoords({env2D:o}),u.intersect(l),r>=i?a=s(e.getGeometryType())?qe(e,u):Je(e,u):c=s(t.getGeometryType())?qe(t,u):Je(t,u)}}this.construct_(e,a,t,c,n,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():!1}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):s(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?s(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||y(``),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||y(``),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(e,t,n,r,a,o){let c=T.constructEmpty(),l=T.constructEmpty();e.queryLooseEnvelope(c),n.queryLooseEnvelope(l),c.inflateCoords(a,a),l.inflateCoords(a,a),this.m_envInter.setCoords({env2D:c}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;let u=e.getGeometryType(),d=n.getGeometryType();this.m_bPaths=o,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.enumUnknown,this.m_bQuadTree=!1,t!==null&&(this.m_bDone=!1,this.m_tolerance=a,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,s(d)?(this.m_queryType=d,this.m_function=this.nextPath_,o?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=d,this.m_function=this.nextPoint_,this.m_pointIndex=n.getPointCount())),this.m_bQuadTree||r!==null&&(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,s(u)?(this.m_queryType=u,this.m_function=this.nextPath_,o?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(!o||!s(u)||!s(d)?s(u)&&s(d)?(this.m_intersector=Ye(e,n,a),this.m_bSwapElements=!1):s(u)&&!s(d)?(this.m_intersector=Xe(e,n,a),this.m_bSwapElements=!1):!s(u)&&s(d)?(this.m_intersector=Xe(n,e,a),this.m_bSwapElements=!0):(this.m_intersector=Ze(e,n,a),this.m_bSwapElements=!1):this.m_intersector=Qe(e,n,a))}nextPath_(){return this.m_bPaths?--this.m_pathIndex===-1?(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;let e=this.m_segIter.nextSegment(),t=new T;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(--this.m_pointIndex===-1)return this.m_bDone=!0,!1;let e=new U;if(this.m_bSwapElements){let t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{let t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(T.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),this.m_elementHandle===-1?s(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0):!1}}function Fi(e){return e===2?1:e===1?2:e===128?64:e===64?128:e}function Ii(e,t,n){let r;if(e instanceof rp||e===null){let i=T.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(n),r=Oe(e,i,!1)}else r=e;return r}function Li(e,t,n){let r;if(e instanceof rp||e===null){let i=T.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(n),r=Oe(e,i,!1)}else r=e;return r}function Ri(e,t,n,o,s){if(e.isEmpty()||t.isEmpty())return o===4;r(e),r(t);let c=e.getGeometryType(),l=t.getGeometryType();if(c===i.enumEnvelope){if(l===i.enumEnvelope)return zi(e,t,n,o);if(l===i.enumPoint)return Bi(t,e,n,Fi(o))}else if(c===i.enumPoint){if(l===i.enumEnvelope)return Bi(e,t,n,o);if(l===i.enumPoint)return Vi(e,t,n,o)}let u=T.constructEmpty();e.queryEnvelope(u);let d=T.constructEmpty();t.queryEnvelope(d);let f=Li(n,u,d);if(Hi(u,d,f))return o===4;let p=!1,m=null,h=null,g=null,_=null;switch(a(c)?(m=new E({vd:e.getDescription()}),m.addSegment(e,!0),g=m,c=i.enumPolyline):g=e,a(l)?(h=new E({vd:t.getDescription()}),h.addSegment(t,!0),_=h,l=i.enumPolyline):_=t,c!==i.enumEnvelope&&l!==i.enumEnvelope?(g.getDimension()<_.getDimension()||c===i.enumPoint&&l===i.enumMultiPoint)&&(o=Fi(o)):c!==i.enumPolygon&&l!==i.enumEnvelope&&(o=Fi(o)),c){case i.enumPolygon:switch(l){case i.enumPolygon:p=Wi(g,_,f,o,s);break;case i.enumPolyline:p=Gi(g,_,f,o,s);break;case i.enumPoint:p=Ki(g,_,f,o);break;case i.enumMultiPoint:p=qi(g,_,f,o);break;case i.enumEnvelope:p=Ji(g,_,f,o,s)}break;case i.enumPolyline:switch(l){case i.enumPolygon:p=Gi(_,g,f,o,s);break;case i.enumPolyline:p=Yi(g,_,f,o,s);break;case i.enumPoint:p=Xi(g,_,f,o);break;case i.enumMultiPoint:p=Zi(g,_,f,o);break;case i.enumEnvelope:p=Qi(g,_,f,o,s)}break;case i.enumPoint:switch(l){case i.enumPolygon:p=Ki(_,g,f,o);break;case i.enumPolyline:p=Xi(_,g,f,o);break;case i.enumMultiPoint:p=ea(_,g,f,o)}break;case i.enumMultiPoint:switch(l){case i.enumPolygon:p=qi(_,g,f,o);break;case i.enumPolyline:p=Zi(_,g,f,o);break;case i.enumMultiPoint:p=$i(g,_,f,o);break;case i.enumPoint:p=ea(g,_,f,o);break;case i.enumEnvelope:p=ta(g,_,f,o)}break;case i.enumEnvelope:switch(l){case i.enumPolygon:p=Ji(_,g,f,o,s);break;case i.enumPolyline:p=Qi(_,g,f,o,s);break;case i.enumMultiPoint:p=ta(_,g,f,o)}}return p}function zi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=T.constructEmpty();e.queryEnvelope(a);let o=T.constructEmpty();t.queryEnvelope(o);let s=Li(n,a,o);switch(r){case 4:return Hi(a,o,s);case 2:return mo(o,a,s,!1);case 128:return mo(o,a,s,!0);case 1:return mo(a,o,s,!1);case 64:return mo(a,o,s,!0);case 3:return uo(a,o,s);case 8:return fo(a,o,s);case 32:return po(a,o,s);case 16:return!1}return!1}function Bi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=e.getXY(),o=T.constructEmpty();t.queryEnvelope(o);let s=Ii(n,a,o);switch(r){case 4:return Ui(a,o,s);case 2:case 128:return lo(a,o,s);case 1:case 64:return!1;case 3:return so(a,o,s);case 8:return co(a,o,s)}return!1}function Vi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=e.getXY(),o=t.getXY(),s;if(n instanceof rp||n===null){let e=T.constructEmpty();e.setCoords({pt:a}),e.merge(o),s=Oe(n,e,!1)}else s=n;switch(r){case 4:return ao(a,o,s);case 2:case 128:return oo(o,a,s);case 1:case 64:return oo(a,o,s);case 3:return io(a,o,s)}return!1}function Hi(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!e.isIntersecting(r)}function X(e,t,n,r=!1){let i=e.getGeometryType(),a=t.getGeometryType();do if(f(i)){let t=e.getImpl().getAccelerators();if(t!==null){let e=t.getRasterizedGeometry();l(e===null)}}while(0);do if(f(a)){let e=t.getImpl().getAccelerators();if(e!==null){let t=e.getRasterizedGeometry();l(t===null)}}while(0);return 0}function Ui(e,t,n,r){let i=T.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(n,n),!i.contains(e)}function Wi(e,t,n,r,i){switch(r){case 4:return ra(e,t,n);case 2:return oa(t,e,n,i);case 128:return sa(t,e,n);case 1:return oa(e,t,n,i);case 64:return sa(e,t,n);case 3:return na(e,t,n,i);case 8:return ia(e,t,n);case 32:return aa(e,t,n,i)}return!1}function Gi(e,t,n,r,i){switch(r){case 4:return ca(e,t,n);case 1:return da(e,t,n,i);case 64:return fa(e,t,n);case 8:return la(e,t,n,i);case 16:return ua(e,t,n)}return!1}function Ki(e,t,n,r,i){switch(r){case 4:return pa(e,t,n);case 1:case 64:return ha(e,t,n);case 8:return ma(e,t,n)}return!1}function qi(e,t,n,r,i){switch(r){case 4:return ga(e,t,n);case 1:return ya(e,t,n,!1);case 64:return ya(e,t,n,!0);case 8:return _a(e,t,n);case 16:return va(e,t,n)}return!1}function Ji(e,t,n,r,i){if(xa(e,t,n))return r===4;if(r===4)return!1;switch(r){case 2:return wa(e,t,n,!1);case 128:return wa(e,t,n,!0);case 1:return Ta(e,t,n,!1,i);case 64:return Ta(e,t,n,!0,i);case 3:return ba(e,t,n,i);case 8:return Sa(e,t,n,i);case 32:return Ca(e,t,n,i);case 16:return!1}return!1}function Yi(e,t,n,r,i){switch(r){case 4:return Da(e,t,n);case 2:return ja(t,e,n,i);case 128:return Ma(t,e,n,i);case 1:return ja(e,t,n,i);case 64:return Ma(e,t,n,i);case 3:return Ea(e,t,n,i);case 8:return Oa(e,t,n,i);case 32:return Aa(e,t,n,i);case 16:return ka(e,t,n,i)}return!1}function Xi(e,t,n,r,i){switch(r){case 4:return Na(e,t,n);case 1:case 64:return Fa(e,t,n);case 8:return Pa(e,t,n)}return!1}function Zi(e,t,n,r,i){switch(r){case 4:return Ia(e,t,n);case 1:case 64:return za(e,t,n);case 8:return La(e,t,n);case 16:return Ra(e,t,n)}return!1}function Qi(e,t,n,r,i){if(Va(e,t,n))return r===4;if(r===4)return!1;switch(r){case 2:return Ua(e,t,n,!1);case 128:return Ua(e,t,n,!0);case 1:case 64:return!1;case 3:return Ba(e,t,n);case 8:return Ha(e,t,n,i);case 32:return!1;case 16:return Wa(e,t,n)}return!1}function $i(e,t,n,r,i){switch(r){case 4:return Ka(e,t,n);case 2:case 128:return Ja(t,e,n);case 1:case 64:return Ja(e,t,n);case 3:return Ga(e,t,n);case 32:return qa(e,t,n)}return!1}function ea(e,t,n,r,i){switch(r){case 4:return Xa(e,t,n);case 2:case 128:return Za(e,t,n);case 1:case 64:return Qa(e,t,n);case 3:return Ya(e,t,n)}return!1}function ta(e,t,n,r,i){switch(r){case 4:return eo(e,t,n);case 2:return no(e,t,n,!1);case 128:return no(e,t,n,!0);case 1:case 64:return!1;case 3:return $a(e,t,n);case 8:return to(e,t,n);case 16:return ro(e,t,n)}return!1}function na(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(a),!uo(i,a,n))return!1;if(X(e,t),xo(e,t,n))return!0;let o=e.calculateLength2D(),s=t.calculateLength2D(),c=Math.max(e.getPointCount(),t.getPointCount());return Math.abs(o-s)>c*4*n?!1:e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`**F**FFF*`,r,!1):wo(e,t,n,!0)}function ra(e,t,n,r){return X(e,t,n,!0),ho(e,t,n,!0)===1}function ia(e,t,n,r){return X(e,t),Mo(e,t,n,null)}function aa(e,t,n,r){return X(e,t),No(e,t,n,r)}function oa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),Po(e,t,n,r)):!1}function sa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ho(e,t,n,!1)===2):!1}function ca(e,t,n,r){return X(e,t,n,!0),ho(e,t,n,!0)===1}function la(e,t,n,r){return X(e,t),Fo(e,t,n,r)}function ua(e,t,n,r){return X(e,t),Io(e,t,n,null)}function da(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),Lo(e,t,n,r)):!1}function fa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ho(e,t,n,!1)===2):!1}function pa(e,t,n,r){return Ko(e,t,n)===0}function ma(e,t,n,r){return zo(e,t.getXY(),n)}function ha(e,t,n,r){return Ro(e,t.getXY(),n)}function ga(e,t,n,r,i){return X(e,t),go(e,t,n)===1}function _a(e,t,n,r){X(e,t);let i=T.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);let a=new U,o=!1,s=e.getImpl(),c=new k,l=e,u=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,a),i.contains(a)){let e=qo(l,a,n);if(e===2)o=!0;else if(e===1)return!1}u||=(Xr(e,t.getPointCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()===null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),l=c):l=e,!0)}return!!o}function va(e,t,n,r){X(e,t);let i=new T,a=new T,o=new T;e.queryEnvelope(i),t.queryEnvelope(o),a.setCoords({env2D:i}),a.inflateCoords(n,n);let s=!1,c=!1,l=new U,u=e.getImpl(),d=new k,f=e,p=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,l),!a.contains(l))c=!0;else{let e=qo(f,l,n);e===0?c=!0:e===1&&(s=!0)}if(s&&c)return!0;p||=(Xr(e,t.getPointCount()-1)&&(u.getAccelerators()===null||u.getAccelerators().getQuadTree()===null)?(e.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),f=d):f=e,!0)}return!1}function ya(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=!1,c=new U,l=e.getImpl(),u=new k,d=e,f=!1;for(let i=0;i<t.getPointCount();i++){if(t.queryXY(i,c),!a.contains(c))return!1;let o=qo(d,c,n);if(o===1)s=!0;else if(o===0)return!1;if(r&&o===2)return!1;f||=(Xr(e,t.getPointCount()-1)&&(l.getAccelerators()===null||l.getAccelerators().getQuadTree()===null)?(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),d=u):d=e,!0)}return s}function ba(e,t,n,r){let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),!uo(i,a,n))return!1;let o=new k;return o.addEnvelope(t,!1),na(e,o,n,r)}function xa(e,t,n,r){X(e,t);let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||qo(e,a.getLowerLeft(),0)!==0||a.contains(e.getXY(0))?!1:!jo(e,a,n)}function Sa(e,t,n,r){X(e,t);let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new k;return o.addEnvelope(t,!1),Mo(e,o,n,r)}function Ca(e,t,n,r){X(e,t);let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new k;return o.addEnvelope(t,!1),No(e,o,n,r)}function wa(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();return e.queryEnvelope(a),t.queryEnvelope(o),r?yo(o,a,n):vo(o,a,n)}function Ta(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=new k;return s.addEnvelope(t,!1),r?ho(e,s,n,!1)===2:Po(e,s,n,i)}function Ea(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)?(X(e,t),xo(e,t,n)?!0:e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`**F**FFF*`,r,!1):wo(e,t,n,!1)):!1}function Da(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl();return!new Pi(i,a,n,!0).next()||!Eo(e,t,n)}function Oa(e,t,n,r){X(e,t);let i=[],a=Do(e,t,n,i);if(a===-2){let i=T.constructEmpty(),a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a),i.inflateCoords(1e3*n,1e3*n),a.inflateCoords(1e3*n,1e3*n),o.setCoords({env2D:i}),o.intersect(a);let s,c;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(c=q(t,o,n,0,r),c.isEmpty())return!1}else c=t;return ai(s,c,n,`F********`,r,!1)}if(a!==0)return!1;let o=new A;for(let e=0;e<i.length;e+=2){let t=i[e],n=i[e+1];o.addXY(t,n)}let s=e.getBoundary(),c=t.getBoundary();return s.addPoints(c,0,c.getPointCount()),!s.isEmpty()&&Ja(s,o,n)}function ka(e,t,n,r){X(e,t);let i=[],a=Do(e,t,n,i);if(a===-2){let i=T.constructEmpty(),a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a),i.inflateCoords(1e3*n,1e3*n),a.inflateCoords(1e3*n,1e3*n),o.setCoords({env2D:i}),o.intersect(a);let s,c;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(c=q(t,o,n,0,r),c.isEmpty())return!1}else c=t;return ai(s,c,n,`0********`,r,!1)}if(a!==0)return!1;let o=new A;for(let e=0;e<i.length;e+=2){let t=i[e],n=i[e+1];o.addXY(t,n)}let s=e.getBoundary(),c=t.getBoundary();return s.addPoints(c,0,c.getPointCount()),s.isEmpty()?!0:!Ja(s,o,n)}function Aa(e,t,n,r){X(e,t);let i=T.constructEmpty(),a=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a);let o=bo(i,a,n),s=bo(a,i,n),c=e.hasNonLinearSegments(),l=t.hasNonLinearSegments(),u=Do(e,t,n,null);if(u===-1)return!1;if(u===1){if(o&&s)return!0;if(!c&&!l)return o&&!s?!To(t,e,n,!1):s&&!o?!To(e,t,n,!1):!To(e,t,n,!1)&&!To(t,e,n,!1)}let d=T.constructEmpty(),f=T.constructEmpty(),p=T.constructEmpty();d.setCoords({env2D:i}),d.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:a}),f.inflateCoords(1e3*n,1e3*n),p.setCoords({env2D:d}),p.intersect(f);let m,h,g=``;if(g+=`1*`,o){if(t.getPointCount()>10){if(h=q(t,p,n,0,r),h.isEmpty())return!1}else h=t;g+=`****`}else h=t,g+=`T***`;if(s){if(e.getPointCount()>10){if(m=q(e,p,n,0,r),m.isEmpty())return!1}else m=e;g+=`***`}else m=e,g+=`T**`;return ai(m,h,n,g,r,!1)}function ja(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`******FF*`,r,!1):To(t,e,n,!1)):!1}function Ma(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ai(e,t,n,`T**FF*FF*`,r,!1)):!1}function Na(e,t,n,r){return X(e,t),!ko(e,t.getXY(),n)}function Pa(e,t,n,r){return X(e,t),Vo(e,t.getXY(),n)}function Fa(e,t,n,r){return X(e,t),Ao(e,t.getXY(),n)}function Ia(e,t,n,r){return X(e,t),!Oo(e,t,n,!1)}function La(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl(),o=new A,s=new Pi(i,a,n,!1),c=i.querySegmentIterator(),l=!1;for(;s.next();){let e=s.getRedElement(),t=s.getBlueElement();c.resetToVertex(e,-1);let r=c.nextSegment(),i=a.getXY(t);r.isIntersectingPoint(i,n)&&(l=!0,o.addPoint2D(i))}if(!l)return!1;let u=e.getBoundary();return!u.isEmpty()&&Ja(u,o,n)}function Ra(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl(),o=a.getPointCount(),s=H(o,!1),c=new Pi(i,a,n,!1),l=i.querySegmentIterator(),u=!1;for(;c.next();){let e=c.getRedElement(),t=c.getBlueElement();l.resetToVertex(e,-1);let r=l.nextSegment(),i=a.getXY(t);r.isIntersectingPoint(i,n)&&(u=!0,s[t]=!0)}if(!u)return!1;let d=!1;for(let e=0;e<o;e++)if(!s[e]){d=!0;break}if(!d)return!1;let f=e.getBoundary();if(f.isEmpty())return!0;let p=new A;for(let e=0;e<o;e++)s[e]&&p.addPoint2D(a.getXY(e));return!Ja(f,p,n)}function za(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=Oo(e,t,n,!0);if(!s)return s;let c=e.getBoundary();return c.isEmpty()?s:!Ja(c,t,n)}function Ba(e,t,n,r){let i=new T,a=new T;return e.queryEnvelope(i),t.queryEnvelope(a),a.height()>n&&a.width()>n?!1:uo(i,a,n)}function Va(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a);let o=Ho(a,i,n);return o===0?!jo(e,a,n):o===4}function Ha(e,t,n,r){let a=new T,s=new T;if(e.queryEnvelope(a),t.queryEnvelope(s),s.height()<=n||s.width()<=n)return!1;let c=new T,l=new T;if(c.setCoords({env2D:s}),l.setCoords({env2D:s}),c.inflateCoords(n,n),l.inflateCoords(-n,-n),l.containsEnvelope(a)||!a.isIntersecting(c))return!1;let u=e.getImpl().querySegmentIterator();u.stripAttributes();let d=e.getImpl().getAccelerators(),f=null,p=null;d!==null&&(f=d.getQuadTree(),f!==null&&(p=f.getIterator(s,n))),p||u.nextPath()||o(`relational_operations`);let m=!1,h=null,g=new U,_=new U,v=e.hasNonLinearSegments(),y=!1;for(;;){if(p!==null){let e=p.next();if(e===-1)break;u.resetToVertex(f.getElement(e),-1),h=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;h=u.nextSegment()}if(!v||h.getGeometryType()===i.enumLine){g.assign(h.getStartXY()),_.assign(h.getEndXY());let e=l.clipLine(g,_);if(e!==0)return!1;m||(e=c.clipLine(g,_),e!==0&&(m=!0))}else{let e=new T;if(h.queryEnvelope(e),l.containsEnvelope(e))return!1;if(c.isIntersecting(e)){y=!0;break}}}if(!y)return m;let b=new k;return b.addEnvelope(s,!1),la(b,e,n,r)}function Ua(e,t,n,r,a){let s=T.constructEmpty(),c=T.constructEmpty();if(e.queryEnvelope(s),t.queryEnvelope(c),c.height()<=n||c.width()<=n)return!1;if(r)return yo(c,s,n);if(!vo(c,s,n))return!1;let l=T.constructEmpty();l.setCoords({env2D:c}),l.inflateCoords(-n,-n);let u=T.constructEmpty();if(u.setCoords({env2D:c}),u.inflateCoords(n,n),l.containsEnvelope(s))return!0;let d=e.getImpl().querySegmentIterator();d.stripAttributes(),d.nextPath()||o(`relational_operations`);let f=!1,p,m,h,g,_,v,y=e.hasNonLinearSegments();for(y&&(h=new I,g=new I,_=new I,v=new I,l.querySide(0,h),l.querySide(1,g),l.querySide(2,_),l.querySide(3,v));;){for(;!d.hasNextSegment()&&d.nextPath(););if(!d.hasNextSegment())break;let e=d.nextSegment();if(!y||e.getGeometryType()===i.enumLine){if(p=e.getStartXY(),m=e.getEndXY(),l.clipLine(p,m)!==0){f=!0;break}}else{if(e.isIntersecting(h,n)){f=!0;break}if(e.isIntersecting(g,n)){f=!0;break}if(e.isIntersecting(_,n)){f=!0;break}if(e.isIntersecting(v,n)){f=!0;break}}}return f}function Wa(e,t,n,r){let a=new T,o=new T;if(e.queryEnvelope(a),t.queryEnvelope(o),o.height()<=n||o.width()<=n)return!1;let s=new T;if(s.setCoords({env2D:o}),s.inflateCoords(n,n),s.containsEnvelope(a))return!1;let c=new T;if(c.setCoords({env2D:o}),c.inflateCoords(-n,-n),!c.isIntersecting(a))return!1;let u=e.getImpl().querySegmentIterator();u.stripAttributes();let d=e.getImpl().getAccelerators(),f=null,p=null;if(d!==null&&(f=d.getQuadTree(),f!==null&&(p=f.getIterator(o,n))),!p){let e=u.nextPath();l(e)}let m=!1,h=null,g=new U,_=new U,v=e.hasNonLinearSegments(),y=null,b=null,x=null,S=null;for(v&&(y=new I,b=new I,x=new I,S=new I,c.querySide(0,y),c.querySide(1,b),c.querySide(2,x),c.querySide(3,S));;){if(p!==null){let e=p.next();if(e===-1)break;u.resetToVertex(f.getElement(e),-1),h=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;h=u.nextSegment()}if(h.getGeometryType()===i.enumLine){if(g.assign(h.getStartXY()),_.assign(h.getEndXY()),c.clipLine(g,_)!==0){m=!0;break}}else{if(y.isIntersecting(h,n)){m=!0;break}if(b.isIntersecting(h,n)){m=!0;break}if(x.isIntersecting(h,n)){m=!0;break}if(S.isIntersecting(h,n)){m=!0;break}}}return m&&!0}function Ga(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)?So(e,t,n)?!0:Co(e,t,n,!1,!0,!1):!1}function Ka(e,t,n,r){let i=e,a=t,o=new Pi(i,a,n,!1),s=n*n,c=new U,l=new U;for(;o.next();){let e=o.getRedElement(),t=o.getBlueElement();if(i.queryXY(e,c),a.queryXY(t,l),U.sqrDistance(c,l)<=s)return!1}return!0}function qa(e,t,n,r){return Co(e,t,n,!1,!1,!0)}function Ja(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?Co(t,e,n,!0,!1,!1):!1}function Ya(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)}function Xa(e,t,n,r){return Bo(e,t.getXY(),n)}function Za(e,t,n,r){return Ya(e,t,n)}function Qa(e,t,n,r){return!Xa(e,t,n)}function $a(e,t,n,r){let i=new T,a=new T;return e.queryEnvelope(i),t.queryEnvelope(a),a.height()>n||a.width()>n?!1:uo(i,a,n)}function eo(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n))return!1;let o=T.constructEmpty();o.setCoords({env2D:a}),o.inflateCoords(n,n);let s=new U;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,s),o.contains(s))return!1;return!0}function to(e,t,n,r){let i=new T,a=new T,o=new T;if(t.queryEnvelope(i),i.height()<=n||i.width()<=n)return!1;a.setCoords({env2D:i}),o.setCoords({env2D:i}),a.inflateCoords(n,n),o.inflateCoords(-n,-n);let s=new U,c=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,s),a.contains(s)){if(o.containsExclusive(s))return!1;c=!0}return c}function no(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),o.height()<=n||o.width()<=n)return!1;if(r)return yo(o,a,n);if(!vo(o,a,n))return!1;let s=!1,c=T.constructEmpty(),l=T.constructEmpty();c.setCoords({env2D:o}),l.setCoords({env2D:o}),c.inflateCoords(-n,-n),l.inflateCoords(n,n);let u=new U;for(let t=0;t<e.getPointCount();t++){if(e.queryXY(t,u),!l.contains(u))return!1;c.containsExclusive(u)&&(s=!0)}return s}function ro(e,t,n,r){let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new T,s=new T;o.setCoords({env2D:a}),o.inflateCoords(-n,-n),s.setCoords({env2D:a}),s.inflateCoords(n,n);let c=new U,l=!1,u=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,c),!l&&o.containsExclusive(c)&&(l=!0),!u&&!s.contains(c)&&(u=!0),l&&u)return!0;return!1}function io(e,t,n,r){return U.sqrDistance(e,t)<=n*n}function ao(e,t,n,r){return U.sqrDistance(e,t)>n*n}function oo(e,t,n,r){return io(e,t,n)}function so(e,t,n,r){let i=new T;return i.setCoords({pt:e}),uo(i,t,n)}function co(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;let i=new T,a=new T;return i.setCoords({env2D:t}),i.inflateCoords(n,n),!(!i.contains(e)||(a.setCoords({env2D:t}),a.inflateCoords(-n,-n),a.containsExclusive(e)))}function lo(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;let i=T.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(-n,-n),i.containsExclusive(e)}function uo(e,t,n,r){return vo(e,t,n)&&vo(t,e,n)}function fo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;let i=new T;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&i.height()>n&&i.width()>n?!1:(i.setCoords({env2D:e}),i.inflateCoords(n,n),i.intersect(t),!i.isEmpty())}function po(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n||vo(e,t,n)||vo(t,e,n))return!1;let i=new T;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&(i.height()>n||i.width()>n)}function mo(e,t,n,r,i){if(e.height()<=n||e.width()<=n)return!1;if(r)return yo(e,t,n);if(!vo(e,t,n))return!1;let a=T.constructEmpty();return a.setCoords({env2D:e}),a.inflateCoords(-n,-n),a.intersect(t),!a.isEmpty()}function ho(e,t,n,r,a){let o=new U,s=new U,c=T.constructEmpty(),l=T.constructEmpty(),u=e.getImpl(),d=t.getImpl(),f=d.getGeometryType(),p=new Pi(u,d,n,!0);if(!p.next())return 1;if(Eo(e,t,n))return r?4:0;let m=new k,h=e,g=new k,_=null;f===i.enumPolygon&&(_=t);let v=f===i.enumPolygon?H(u.getPathCount(),!1):[],y=H(d.getPathCount(),!1),b=!1,x=!1,S=!1,C=!1,w=!1,E=!1;do{if(S&&w||C&&E||S&&C)break;let a=p.getRedElement(),T=p.getBlueElement();if(!y[T]&&(s.assign(t.getXY(t.getPathStart(T))),c.setCoords({env2D:p.getRedEnvelope()}),c.inflateCoords(n,n),c.contains(s))){if(qo(h,s,0)!==0){if(C=!0,r)return 4}else E=!0;y[T]=!0}if(f===i.enumPolygon&&!v[a]&&(o.assign(e.getXY(e.getPathStart(a))),l.setCoords({env2D:p.getBlueEnvelope()}),l.inflateCoords(n,n),l.contains(o))){if(qo(_,o,0)!==0){if(S=!0,r)return 4}else w=!0;v[a]=!0}if(b||=(Xr(e,t.getPathCount()-1)&&(u.getAccelerators()===null||u.getAccelerators().getQuadTree()===null)?(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m):h=e,!0),f===i.enumPolygon&&!x){let n=t;Xr(n,e.getPathCount()-1)&&(d.getAccelerators()===null||d.getAccelerators().getQuadTree()===null)?(n.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),_=g):_=t,x=!0}}while(p.next());if(!S&&!C)return 1;if(!w||!E){if(f===i.enumPolygon){for(let e=0,t=u.getPathCount();e<t;e++)if(!v[e]){w=!0;break}}for(let e=0,t=d.getPathCount();e<t;e++)if(!y[e]){E=!0;break}}return S&&w||C&&E||S&&C?4:C?2:3}function go(e,t,n,r,i){let a=T.constructEmpty();e.queryEnvelope(a),a.inflateCoords(n,n);let o=new U,s=e.getImpl(),c=new k,l=e,u=!1,d=!1,f=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,o),a.contains(o)){let e=qo(l,o,n);if(e===1)return d=!0,4;if(e===2)return 4;f=!0}else f=!0;u||=(Xr(e,t.getPointCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()==null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),l=c):l=e,!0)}return d?f?4:2:1}function _o(e,t,n,r,a){r[0]=!1;let o=e.getImpl(),s=t.getImpl(),c=o.querySegmentIterator(),u=s.querySegmentIterator(),d=[0,0],f=[0,0],p=new Pi(o,s,n),m=!1;for(;p.next();){let e=p.getRedElement(),t=p.getBlueElement();c.resetToVertex(e,-1),u.resetToVertex(t,-1);let i=c.nextSegment(),a=u.nextSegment(),o=0;if(Uo(i,a)?!m&&a.isIntersecting(i,n)&&(m=!0):o=a.intersect(i,null,f,d,n),o!==0&&(m=!0,o===1)){let e=d[0],t=f[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!m){r[0]=!0;let a=T.constructEmpty();e.queryEnvelope(a),a.inflateCoords(n,n);let c=new k,u=e,d=!1;for(let n=0,r=t.getPathCount();n<r;n++)if(t.getPathSize(n)>0){let r=T.constructEmpty();if(t.queryPathEnvelope(n,r),a.isIntersecting(r)){let e=t.getXY(t.getPathStart(n)),r=Yr(u,e,0);if(l(r!==-1),r===0)return!1}else return!1;d||=(Xr(e,t.getPathCount()-1)&&(o.getAccelerators()===null||o.getAccelerators().getQuadTree()===null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),u=c):u=e,!0)}if(e.getPathCount()===1||t.getGeometryType()===i.enumPolyline)return!0;let f=t,p=T.constructEmpty();f.queryEnvelope(p),p.inflateCoords(n,n);let m=new k,h=f,g=!1;for(let t=0,n=e.getPathCount();t<n;t++)if(e.getPathSize(t)>0){let n=T.constructEmpty();if(e.queryPathEnvelope(t,n),p.isIntersecting(n)){let n=e.getXY(e.getPathStart(t)),r=Yr(h,n,0);if(l(r!==-1),r===1)return!1}g||=(Xr(f,e.getPathCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()===null)?(f.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m):h=f,!0)}return!0}return!1}function vo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)}function yo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),e.containsExclusiveEnvelope(r)}function bo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!r.contains(e.getLowerLeft())||!r.contains(e.getLowerRight())||!r.contains(e.getUpperLeft())||!r.contains(e.getUpperRight())}function xo(e,t,n,r){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);let i=new U,a=new U,o=!0,s=n*n;for(let n=0;n<e.getPathCount();n++){if(e.getPathEnd(n)!==t.getPathEnd(n)){o=!1;break}for(let r=e.getPathStart(n);r<t.getPathEnd(n);r++)if(e.queryXY(r,i),t.queryXY(r,a),U.sqrDistance(i,a)>s){o=!1;break}if(!o)break}return!!o}function So(e,t,n,r){if(e.getPointCount()!==t.getPointCount())return!1;let i=new U,a=new U,o=!0,s=n*n;for(let n=0;n<e.getPointCount();n++)if(e.queryXY(n,i),t.queryXY(n,a),U.sqrDistance(i,a)>s){o=!1;break}return!!o}function Co(e,t,n,r,i,a,o){let s=e.getImpl(),c=t.getImpl(),l=s.getPointCount(),u=c.getPointCount(),d=H(l,!1),f=i||a?H(u,!1):[],p=n*n,m=new Pi(s,c,n);for(;m.next();){let e=m.getRedElement(),t=m.getBlueElement(),n=s.getXY(e),r=c.getXY(t);U.sqrDistance(n,r)<=p&&(d[e]=!0,(i||a)&&(f[t]=!0))}let h=!1,g=!1;for(let e=0;e<l;e++){let t=d[e];if(h||=!t,g||=t,(i||r)&&h)return!1}if(r)return!0;let _=!1,v=!1;for(let e=0;e<u;e++){let t=f[e];if(_||=!t,v||=t,i&&_)return!1}return i?!0:h&&g&&_&&v}function wo(e,t,n,r){return To(e,t,n,r)&&To(t,e,n,r)}function To(e,t,n,r){if(S(e),S(t),t.isEmpty())return!1;let i=!0,a=H(2,NaN),s=H(2,NaN),c=[],l=new Go,u,d=T.constructEmpty(),f=T.constructEmpty(),p=T.constructEmpty();e.queryEnvelope(d),t.queryEnvelope(f),d.inflateCoords(n,n),f.inflateCoords(n,n),p.setCoords({env2D:d}),p.intersect(f);let m=e.getImpl().querySegmentIterator(),h=t.getImpl().querySegmentIterator(),g=t.getImpl().getAccelerators(),_=null,v=null,y=null,b=null;if(g!==null&&(_=g.getQuadTree(),v=g.getQuadTreeForPaths(),v!==null&&(b=v.getIteratorForQT())),_===null){let n=e.getPointCount(),r=t.getPointCount();n>10&&r>10&&(_=qe(t.getImpl(),p))}for(_!==null&&(y=_.getIteratorForQT());m.nextPath();)for(;m.hasNextSegment();){let e=m.nextSegment();if(e.queryEnvelope(d),!d.isIntersecting(p))return i=!1,!1;if(b!==null&&(b.resetIterator(d,n),b.next()===-1))continue;let t=0,g=null;if(y!=null)y.resetIterator(e,n);else if(h.resetToFirstPath(),!h.nextPath())return i=!1,!1;do if(t=0,y!==null){let r=y.next();if(r===-1)return i=!1,!1;h.resetToVertex(_.getElement(r),-1),g=h.nextSegment(),t=e.intersect(g,null,a,s,n)}else{for(;!h.hasNextSegment();)if(!h.nextPath())return i=!1,!1;g=h.nextSegment(),g.queryEnvelope(f),f.inflateCoords(n,n),d.isIntersecting(f)&&(t=e.intersect(g,null,a,s,n))}while(!(t===2&&a[0]===0&&(!r||s[0]<=s[1])));let v=NaN,x=!1;do{let r=!1;if(a[1]===1){if(!m.hasNextSegment()){x=!0;break}e=m.nextSegment(),r=!0}if(s[1]===1&&s[0]<=s[1]){if(v===-1||(v=1,!h.hasNextSegment()))break;g=h.nextSegment(),r=!0}if(s[1]===0&&s[0]>s[1]){if(v===1)break;if(Number.isNaN(v)){if(!h.hasPreviousSegment())break;h.previousSegment(),v=-1}if(!h.hasPreviousSegment())break;g=h.previousSegment(),r=!0}if(!r)break;t=e.intersect(g,null,a,s,n)}while(t===2&&(!r||s[0]<=s[1]));if(x)continue;let S=e.calculateLength2D();e.queryEnvelope(d),c.length=0,l.m_overlapEvents.length=0;let C=!1,w=!1,T=0,E=Oe(null,d,!0);for(y===null?(h.resetToFirstPath(),h.nextPath()||o(`relational_operations`)):y.resetIterator(e,n);;){if(t=0,y!==null){let r=y.next();if(r===-1)break;h.resetToVertex(_.getElement(r),-1),g=h.nextSegment(),t=e.intersect(g,null,a,s,n)}else{for(;!h.hasNextSegment()&&h.nextPath(););if(!h.hasNextSegment())break;g=h.nextSegment(),g.queryEnvelope(f),f.inflateCoords(n,n),d.isIntersecting(f)&&(t=e.intersect(g,null,a,s,n))}if(t===2&&(!r||s[0]<=s[1])){let e=m.getStartPointIndex(),t=m.getPathIndex(),r=h.getStartPointIndex(),i=h.getPathIndex();if(u=Wo(e,t,a[0],a[1],r,i,s[0],s[1]),l.m_overlapEvents.push(u),c.push(c.length),!C&&!(u.m_scalarA0<T&&u.m_scalarA1<T)){if(T===0&&S*(u.m_scalarA0-T)>n)C=!0;else if(T!==0&&S*(u.m_scalarA0-T)>E)C=!0;else if(T=u.m_scalarA1,S*(1-T)<=n||T===1){w=!0;break}}}}if(!w){if(!C)return i=!1,!1;c.length>1&&c.sort((e,t)=>l.compareOverlapEvents(e,t)),T=0;for(let e=0;e<l.m_overlapEvents.length;e++)if(u=l.m_overlapEvents[c[e]],!(u.m_scalarA0<T&&u.m_scalarA1<T)){if(T===0&&S*(u.m_scalarA0-T)>n||T!==0&&S*(u.m_scalarA0-T)>E)return i=!1,!1;if(T=u.m_scalarA1,S*(1-T)<=n||T===1)break}if(S*(1-T)>n)return i=!1,!1;c.length=0,l.m_overlapEvents.length=0}}return i}function Eo(e,t,n){let r=e.getImpl(),i=t.getImpl(),a=r.querySegmentIterator(),o=i.querySegmentIterator(),s=new Pi(r,i,n);for(;s.next();){let e=s.getRedElement(),t=s.getBlueElement();a.resetToVertex(e,-1),o.resetToVertex(t,-1);let r=a.nextSegment();if(o.nextSegment().isIntersecting(r,n))return!0}return!1}function Do(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=new Pi(i,a,n),u=!1,d=-1;for(;l.next();){let e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let i=o.nextSegment(),a=s.nextSegment(),f=0;if(Uo(i,a)){if(a.isIntersecting(i,n))return-2}else f=i.intersect(a,null,c,null,n);if(f){if(f===2){let e=i.calculateLength2D(),t=c[0];if(e*(c[1]-t)>n)return d=1,d;u=!0}else if(d=0,r){let e=c[0],t=new U;i.queryCoord2D(e,t),r.push(t.x),r.push(t.y)}}}return u?-2:d}function Oo(e,t,n,r){let i=e.getImpl(),a=t,o=a.getPointCount(),s=r?H(o,!1):[],c=new Pi(i,a,n,!1),l=i.querySegmentIterator();for(;c.next();){let e=c.getRedElement(),t=c.getBlueElement();l.resetToVertex(e,-1);let i=l.nextSegment(),o=a.getXY(t);if(i.isIntersectingPoint(o,n)){if(!r)return!0;s[t]=!0}}if(!r)return!1;for(let e=0;e<o;e++)if(!s[e])return!1;return!0}function ko(e,t,n){let r=new U,i=n*n,a=e.querySegmentIterator(),o=e.getImpl().getAccelerators();if(o!==null){let e=o.getQuadTree();if(e!==null){let o=T.constructEmpty();o.setCoords({pt:t});let s=e.getIterator(o,n);for(let n=s.next();n!==-1;n=s.next())if(a.resetToVertex(e.getElement(n),-1),a.hasNextSegment()){let e=a.nextSegment(),n=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(n,r),U.sqrDistance(t,r)<=i)return!0}return!1}}let s=T.constructEmpty();for(;a.nextPath();)for(;a.hasNextSegment();){let e=a.nextSegment();if(e.queryEnvelope(s),s.inflateCoords(n,n),!s.contains(t))continue;let o=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(o,r),U.sqrDistance(t,r)<=i)return!0}return!1}function Ao(e,t,n){return ko(e,t,n)&&!Vo(e,t,n)}function jo(e,t,n,r){let a=e.querySegmentIterator(),o=e.getImpl().getAccelerators(),s=e.hasNonLinearSegments(),c=null,l=null,u=null,d=null;if(o!==null){let e=o.getQuadTree();if(e!==null){let r=e.getIterator(t,n);s&&(c=new I,l=new I,u=new I,d=new I,t.querySide(0,c),t.querySide(1,l),t.querySide(2,u),t.querySide(3,d));let o=T.constructEmpty();o.setCoords({env2D:t}),o.inflateCoords(n,n);for(let s=r.next();s!==-1;s=r.next())if(a.resetToVertex(e.getElement(s),-1),a.hasNextSegment()){let e=a.nextSegment();if(e.getGeometryType()===i.enumLine){let t=e.getStartXY(),n=e.getEndXY();if(o.clipLine(t,n))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY())||e.isIntersecting(c,n)||e.isIntersecting(l,n)||e.isIntersecting(u,n)||e.isIntersecting(d,n))return!0}return!1}}if(s){c=new I,l=new I,u=new I,d=new I,t.querySide(0,c),t.querySide(1,l),t.querySide(2,u),t.querySide(3,d);let r=e.querySegmentIterator();for(;r.nextPath();)for(;r.hasNextSegment();){let e=r.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY())||e.isIntersecting(c,n)||e.isIntersecting(l,n)||e.isIntersecting(u,n)||e.isIntersecting(d,n))return!0}}else{let r=T.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(n,n);let i=e.getImpl(),a=i.getAttributeStreamRef(0),o=new U;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0,n=new U,s=new U,c=new U,l=i.getPathStart(e),u=new U;for(let d=l,f=i.getPathEnd(e);d<f;d++){if(t){a.queryPoint2D(2*d,n),u.assign(n),t=!1;continue}if(a.queryPoint2D(2*d,o),s.setCoordsPoint2D(n),c.setCoordsPoint2D(o),r.clipLine(s,c))return!0;n.assign(o)}if(i.isClosedPath(e)&&!t&&(s.setCoordsPoint2D(n),c.setCoordsPoint2D(u),r.clipLine(s,c)))return!0}}return!1}function Mo(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=[0],s=We(i.getIsSimple(0,o))&&We(a.getIsSimple(0,o)),c=i.querySegmentIterator(),l=a.querySegmentIterator(),u=H(2,0),d=H(2,0),f=new Pi(i,a,n),p=!1;for(;f.next();){let e=f.getRedElement(),t=f.getBlueElement();c.resetToVertex(e,-1),l.resetToVertex(t,-1);let r=c.nextSegment(),i=l.nextSegment(),a=0;if(Uo(r,i)){if(i.isIntersecting(r,n)){p=!0;break}}else a=i.intersect(r,null,d,u,n);if(a===2){let e=u[0],t=u[1],i=r.calculateLength2D();if(s&&(t-e)*i>n)return!1;p=!0}else if(a){let e=u[0],t=d[0];if(e>0&&e<1&&t>0&&t<1)return!1;p=!0}}if(!p)return!1;let m=T.constructEmpty(),h=T.constructEmpty(),g=T.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(h),m.inflateCoords(1e3*n,1e3*n),h.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:m}),g.intersect(h);let _,v;if(e.getPointCount()>10){if(_=q(e,g,n,0,r),_.isEmpty())return!1}else _=e;if(t.getPointCount()>10){if(v=q(t,g,n,0,r),v.isEmpty())return!1}else v=t;return ai(_,v,n,`F********`,r,!1)}function No(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=[0],s=We(i.getIsSimple(0,o))&&We(a.getIsSimple(0,o)),c=T.constructEmpty(),l=T.constructEmpty(),u=T.constructEmpty();e.queryEnvelope(c),t.queryEnvelope(l);let d=!1,f=bo(c,l,n),p=bo(l,c,n),m=i.querySegmentIterator(),h=a.querySegmentIterator(),g=H(2,NaN),_=H(2,NaN),v=new Pi(i,a,n);for(;v.next();){let e=v.getRedElement(),t=v.getBlueElement();m.resetToVertex(e,-1),h.resetToVertex(t,-1);let r=m.nextSegment(),i=h.nextSegment(),a=0;if(Uo(r,i)){if(i.isIntersecting(r,n))break}else a=i.intersect(r,null,_,g,n);if(a===2){let e=g[0],t=g[1],i=r.calculateLength2D();if(s&&(t-e)*i>n&&(d=!0,f&&p))return!0}else if(a){let e=g[0],t=_[0];if(e>0&&e<1&&t>0&&t<1)return!0}}let y=T.constructEmpty(),b=T.constructEmpty();y.setCoords({env2D:c}),y.inflateCoords(1e3*n,1e3*n),b.setCoords({env2D:l}),b.inflateCoords(1e3*n,1e3*n),u.setCoords({env2D:y}),u.intersect(b);let x,S,C=``;if(C+=d?`**`:`T*`,f){if(t.getPointCount()>10){if(S=q(t,u,n,0,r),S.isEmpty())return!1}else S=t;C+=`****`}else S=t,C+=`T***`;if(p){if(e.getPointCount()>10){if(x=q(e,u,n,0,r),x.isEmpty())return!1}else x=e;C+=`***`}else x=e,C+=`T**`;return ai(x,S,n,C,r,!1)}function Po(e,t,n,r){let i=[!1],a=_o(e,t,n,i);if(i[0])return a;let o=T.constructEmpty();t.queryEnvelope(o),o.inflateCoords(1e3*n,1e3*n);let s;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;return oi(s,t,n,r)}function Fo(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=H(2,NaN),u=new Pi(i,a,n),d=!1;for(;u.next();){let e=u.getRedElement(),t=u.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let r=o.nextSegment(),i=s.nextSegment(),a=0;if(Uo(r,i)?!d&&i.isIntersecting(r,n)&&(d=!0):a=i.intersect(r,null,l,c,n),a===2)d=!0;else if(a){let e=c[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!1;d=!0}}if(!d)return!1;let f=T.constructEmpty(),p=T.constructEmpty(),m=T.constructEmpty();e.queryEnvelope(f),t.queryEnvelope(p),f.inflateCoords(1e3*n,1e3*n),p.inflateCoords(1e3*n,1e3*n),m.setCoords({env2D:f}),m.intersect(p);let h,g;if(e.getPointCount()>10){if(h=q(e,m,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(g=q(t,m,n,0,r),g.isEmpty())return!1}else g=t;return ai(h,g,n,`F********`,r,!1)}function Io(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=H(2,NaN),u=new Pi(i,a,n),d=!1;for(;u.next();){let e=u.getRedElement(),t=u.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let r=o.nextSegment(),i=s.nextSegment(),a=0;if(Uo(r,i)?!d&&i.isIntersecting(r,n)&&(d=!0):a=i.intersect(r,null,l,c,n),a===2)d=!0;else if(a){let e=c[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!0;d=!0}}if(!d)return!1;let f=T.constructEmpty(),p=T.constructEmpty(),m=T.constructEmpty(),h=T.constructEmpty(),g=T.constructEmpty();if(e.queryEnvelope(f),t.queryEnvelope(p),bo(p,f,n)){m.setCoords({env2D:f}),m.inflateCoords(1e3*n,1e3*n),h.setCoords({env2D:p}),h.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:m}),g.intersect(h);let i,a;if(e.getPointCount()>10){if(i=q(e,g,n,0,r),i.isEmpty())return!1}else i=e;if(t.getPointCount()>10){if(a=q(t,g,n,0,r),a.isEmpty())return!1}else a=t;return ai(i,a,n,`T********`,r,!1)}return ai(e,t,n,`T*****T**`,r,!1)}function Lo(e,t,n,r){let i=[!1],a=_o(e,t,n,i);if(i[0])return a;let o=T.constructEmpty();t.queryEnvelope(o),o.inflateCoords(1e3*n,1e3*n);let s;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;return si(s,t,n,r)}function Ro(e,t,n,r){return qo(e,t,n)===1}function zo(e,t,n,r){return qo(e,t,n)===2}function Bo(e,t,n,r){let i=new U,a=n*n;for(let n=0;n<e.getPointCount();n++)if(e.queryXY(n,i),U.sqrDistance(i,t)<=a)return!1;return!0}function Vo(e,t,n){let r=e.getBoundary();return!r.isEmpty()&&!Bo(r,t,n)}function Ho(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)?1073741824:r.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}function Uo(e,t){return e.getGeometryType()!==i.enumLine||t.getGeometryType()!==i.enumLine}function Wo(e,t,n,r,i,a,o,s){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:n,m_scalarA1:r,m_ivertexB:i,m_ipathB:a,m_scalarB0:o,m_scalarB1:s}}class Go{m_overlapEvents=[];compareOverlapEvents(e,t){let n=this.m_overlapEvents[e],r=this.m_overlapEvents[t];return n.m_ipathA<r.m_ipathA||n.m_ipathA===r.m_ipathA&&(n.m_ivertexA<r.m_ivertexA||n.m_ivertexA===r.m_ivertexA&&(n.m_scalarA0<r.m_scalarA0||n.m_scalarA0===r.m_scalarA0&&(n.m_scalarA1<r.m_scalarA1||n.m_scalarA1===r.m_scalarA1&&n.m_ivertexB<r.m_ivertexB)))?-1:1}}function Ko(e,t,n){let r=Jr(e,t,n);return r?r===1?1:2:0}function qo(e,t,n){let r=Yr(e,t,n);return r?r===1?1:2:0}function Jo(e,t,n,r,i){for(let a=0;a<n;a++)i[a]=qo(e,t[a],r)}function Yo(e,t,n,r,a){if(e.getGeometryType()===i.enumPolygon)Jo(e,t,n,r,a);else if(e.getGeometryType()===i.enumEnvelope){let i=T.constructEmpty();e.queryEnvelope(i),Zo(i,t,n,r,a)}else y(``)}function Xo(e,t,n,r,o){let s=e.getGeometryType();s===i.enumPolyline?ts(e,t,n,r,o):a(s)?es():y(``)}function Zo(e,t,n,r,i){if(e.isEmpty()){for(let e=0;e<n;e++)i[e]=0;return}let a=e.clone();a.inflateCoords(-r*.5,-r*.5);let o=e.clone();o.inflateCoords(r*.5,r*.5);for(let e=0;e<n;e++)a.contains(t[e])?i[e]=1:o.contains(t[e])?i[e]=2:i[e]=0}function Qo(e){if(e.isEmpty())return 0;switch(e.getGeometryType()){case i.enumMultiPoint:return e.getImpl().getPointCount();case i.enumPolyline:return e.getImpl().getPathCount();case i.enumPolygon:return e.getImpl().getOGCPolygonCount();case i.enumGeometryCollection:return e.getGeometryCount()}return 1}function $o(e,t,n){if(n.reset(),t<3)return;let r=e[0].clone(),i=r.x,a=r.y,o=e[1].clone(),s=new U;for(let i=2;i<t;i++)s.assign(e[i]),n.pe((s.x-r.x)*(o.y-a)),r.assign(o),o.assign(s);n.pe((i-r.x)*(o.y-a))}function es(e,t,n,r,i){l(0)}function ts(e,t,n,r,i){let a=e.getImpl(),o=a.getAccelerators(),s=null;o&&(s=o.getRasterizedGeometry());let c=n;for(let e=0;e<n;e++)i[e]=1,s&&l(0);if(c){if(o){let e=null;o!==null&&o.getQuadTree()!==null&&(e=o.getQuadTree());let s=a.getPointCount();if(e===null&&s>20&&s*n>4*s+Math.log(s)*n&&(e=qe(a)),e){let o=null,s=a.querySegmentIterator(),l=new T;for(let a=0;a<n&&c;a++)if(i[a]===1){l.setCoords(t[a]),o===null?o=e.getIterator(l,r):o.resetIterator(l,r);let n=-1;for(let l=o.next();l!==-1;l=o.next()){if(s.resetToVertex(e.getElement(l),n),n=s.getPathIndex(),s.nextSegment().isIntersectingPoint(t[a],r)){i[a]=2,c--;break}i[a]=0}}return}}let e=a.querySegmentIterator();for(;e.nextPath()&&c;)for(;e.hasNextSegment()&&c;){let a=e.nextSegment();for(let e=0;e<n&&c;e++)i[e]===1&&a.isIntersectingPoint(t[e],r)&&(i[e]=2,c--)}}for(let e=0;e<n;e++)i[e]===1&&(i[e]=0)}function ns(e,t,n,r,i){let a=fe(t),o=Math.max(4*a,n);return new os(t,null,o,NaN,i).approximateWithCirclesImpl(e,r)}function rs(){return Number.isNaN(this.radius.value())}function is(){return{ptStart:new U,ptEnd:new U,center:new ge,radius:new qt,fcenter:new he,fradius2:new Lt,maxError:NaN,isLine:rs}}function as(e,t,n,r){return{pt:e.clone(),t,err:n,checkCount:r}}class os{m_left;m_eps;m_tolerance;m_circleCheckCounter;m_bReversedLeft;m_leftArc;m_tracker;m_trackerCounter;constructor(e,t,n,r,i){this.m_left=e,this.m_tracker=i,this.m_eps=n,this.m_trackerCounter=0,this.m_tolerance=r,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc=is()}closeToCircularArc(e,t,n,r,i,a){if(this.m_circleCheckCounter++,a.maxError=0,!os.checkSweepAngle(e,t))return!1;if(a.ptStart.setCoordsPoint2D(n),a.ptEnd.setCoordsPoint2D(i),e.isCircular()){let t=e;return a.fradius2=Lt.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),a.radius.set(t.getSemiMajorAxis()),a.fcenter.assignPoint2D(t.getCenter()),a.center.set(t.getCenter()),!0}let o=a.ptEnd.sub(a.ptStart).clone();if(o.leftPerpendicularThis(),o.normalize(),Math.abs(o.dotProduct(r.sub(a.ptStart)))<=this.m_eps)return this.confirmIsLine(a,o)?(a.radius.set(NaN),a.center.setCoords(0,0),!0):!1;{let n=a.ptEnd.sub(a.ptStart),i=r.sub(a.ptStart),o=n.crossProduct(i);if(o===0)return!1;let s=n.sqrLength()*.5,c=i.sqrLength()*.5,l=s*i.y-c*n.y;l/=o;let u=n.x*c-i.x*s;u/=o;let d=Math.sqrt(l*l+u*u);if(2**-52*4*d>this.m_eps)return!1;let f=l+a.ptStart.x,p=u+a.ptStart.y;a.radius.set(d),a.center.setCoords(f,p);let m=this.maxCircleApproximationError(e,t,a);if(m>this.m_eps)return a.maxError=m,!1}let s=new he().assignPoint2D(a.ptStart),c=new he().assignPoint2D(a.ptEnd).sub(s),l=new he().assignPoint2D(r).sub(s),u=c.crossProduct(l);if(u.isZero())return!1;let d=c.sqrLength().mulDouble(.5),f=l.sqrLength().mulDouble(.5),p=d.mul(l.y).sub(f.mul(c.y)),m=c.x.mul(f).sub(l.x.mul(d)),h=p.mul(p).add(m.mul(m)),g=u.clone();g.invertThis(),a.fradius2=h.mul(g).mul(g),a.fcenter.setCoords(p.mul(g).add(s.x),m.mul(g).add(s.y)),a.center.setWithEps(a.fcenter.asPoint2D()),a.radius.setWithEps(Math.sqrt(a.fradius2.toDouble()));let _=ge.constructPoint2D(a.ptStart).subE(a.center),v=ge.constructPoint2D(a.ptEnd).subE(a.center);if(!_.dotProduct(v).gt(Rt))return!1;let y=this.maxCircleApproximationError(e,t,a);return a.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.enumEllipticArc){let n=e,r=_e(n,t.vmin),i=_e(n,t.vmax);return!(Math.abs(i-r)>G*.5)}return!0}confirmIsLine(e,t){let n=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(n.mul(.25)))>this.m_eps||Math.abs(t.dotProduct(n.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,n){let r=[.25,.75],a=[.1,.25,.75,.9],o,s;e.getGeometryType()===i.enumEllipticArc?(o=r,s=r.length):(o=a,s=a.length);let c=0;for(let r=0;r<s;++r){let i=new U;e.queryCoord2D(Ct(t.vmin,t.vmax,o[r]),i);let a=i.sub(n.center.value()).length(),s=Math.abs(a-n.radius.value());s>c&&(c=s)}return c}approximateWithCirclesImpl(e,t){let n=1;t&&t.push(0);let r=H(9,NaN),i;e?i=this.m_left.getMonotonicPartParams(r.length,r):(r[0]=0,r[1]=1,i=2);let a=[],o=[],s=new U(0,0);for(let e=1;e<i;e++){let i=new W(r[e-1],r[e]);for(this.m_bReversedLeft=!os.goodOrientation(this.m_left,i),this.m_bReversedLeft?(a.push(as(s,i.vmin,0,0)),a.push(as(s,i.vmax,0,0))):(a.push(as(s,i.vmax,0,0)),a.push(as(s,i.vmin,0,0))),a[0].pt=this.m_left.getCoord2D(a[0].t),a[1].pt=this.m_left.getCoord2D(a[1].t);a.length>1;){this.progress_();let e=a.at(-1),r=e.checkCount,i=e.err,s=e.pt.clone(),c=e.t,l=a[a.length-2].t,u=(c+l)*.5,d=this.m_left.getCoord2D(u);if(i<=this.m_eps||r>=5){let e=new W;if(e.setCoords(c,l),this.closeToCircularArc(this.m_left,e,s,d,a[a.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(c):t.push(l)),n++,a.pop();continue}r=0,i=this.m_leftArc.maxError}e.t=u,e.pt.setCoordsPoint2D(d),i*=.125,r++,e.err=i,e.checkCount=r,a.push(as(s,c,i,r))}this.m_bReversedLeft&&t&&(t.length+=o.length,zt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),a.length=0}return n}approximateWithCirclesImplPolyline(e){let t=new E,n=[];if(!this.approximateWithCirclesImpl(!0,n))return t;let r=0,i=this.m_left.getStartXY();t.startPath(i);for(let a=1;a<n.length;++a)if(e)t.lineTo(this.m_left.getCoord2D(n[a]));else{let e=new U;this.m_left.queryCoord2D(n[a],e);let o=new U;this.m_left.queryCoord2D((n[a]+r)*.5,o);let s=new ie;s.constructCircularArcThreePoint(i,e,o),t.addSegment(s,!1),i.assign(e),r=n[a]}return t}static goodOrientation(e,t){let n=e.getCoord2D(t.vmin),r=e.getCoord2D(t.vmax);return n.compare(r)<0}progress_(e=!1){}}function ss(e,t,n,r,i,a,o){ls(e,t,n,i,a,o),Cs(e,n,o)}function cs(e,t,n,r){if(!s(e.getGeometryType()))return e;let a=e.getImpl();if(!a.hasNonLinearSegments())return e;let o=e.createInstance();o.getGeometryType()===i.enumPolygon&&o.setFillRule(e.getFillRule()),new N;let c=new B,l=new F,u=[],d=[],f=[],p=e.getDescription().getAttributeCount()>1,m=a.querySegmentIterator();for(;m.nextPath();){let e=!0;for(;m.hasNextSegment();){let r=m.isClosingSegment(),a=m.nextSegment();if(!a.isCurve()){o.addSegment(a,e,r),e=!1;continue}let s,h=!1;switch(a.getGeometryType()){case i.enumEllipticArc:s=ee(a,t,n,!0,!0,d,f,u),h=!0;break;case i.enumRationalBezier2:s=ee(a,t,n,!0,!0,d,f,u),h=!0;break;default:s=R(a,t,n,!0,!0,d,u)}let g=h?2:3;d[1].isNAN()?(l.createLine(),l.get().construct(d[0],d[g])):h?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(d,f)):(l.createCubicBezier(),l.get().constructPoints(d)),p&&e&&(a.queryCoord(u[0],c),l.get().setStart(c)),p&&(a.queryCoord(u[1],c),l.get().setEnd(c)),o.addSegment(l.get(),e,r&&s===1),e=!1;for(let e=1,t=s,n=g;e<t;++e,n+=g)d[n+1].isNAN()?(l.createLine(),l.get().construct(d[n],d[n+g])):h?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(d.slice(n),f.slice(n))):(l.createCubicBezier(),l.get().constructPoints(d.slice(n))),p&&(a.queryCoord(u[e+1],c),l.get().setEnd(c)),o.addSegment(l.get(),!1,r&&e+1===t)}}return o}function ls(e,t,n,r,i,a){if(!e.hasCurves()){r.m_impl=null;return}e.setCurveStitcherPointer(r),r.m_impl=new vs(a,!1,null),r.m_impl.buildMonotonicCurveParentage(e,t,n,i)}function us(e,t,n,r,i,a,o,s){if(!e.hasCurves()){a.m_impl=null;return}e.setCurveStitcherPointer(a),a.m_impl=new vs(s,!0,i),a.m_impl.buildMonotonicCurveParentage(e,t,n,o),Cs(e,n,s)}function ds(e){if(!e.hasSegmentParentage())return;let t=e.queryVertexIteratorOnSelection();for(let n=t.next();n!==z;n=t.next())if(!e.getSegmentParentageBreakVertex(n)){e.getPathFromVertex(n);let t=e.getPrevVertex(n),r=t===z?-1:e.getSegmentParentage(t),i=e.getSegmentParentage(n);i!==-1&&r!==-1&&i!==r&&e.setSegmentParentageBreakVertex(n,!0)}}function fs(e){if(!e.hasSegmentParentage())return;ds(e);let t=new Re(0),n=e.queryVertexIteratorOnSelection();for(let e=n.next();e!==z;e=n.next())t.add(e);if(t.size()===0)return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(z);let r=U.getNAN();e.queryXY(t.read(0),r);let i=0,a=U.getNAN();for(let n=1,o=t.size();n<o;n++){{let r=t.read(n);r===z?a.setNAN():e.queryXY(r,a)}if(!a.isEqualPoint2D(r)){if(n-i>1){let r=!1;for(let a=i;a<n;++a){let n=t.read(a);if(e.getSegmentParentageBreakVertex(n)){r=!0;break}}if(!r){let a=(t,n,r)=>{let i=e.getPrevVertex(t),a=e.getNextVertex(t);i===z?n.setNAN():n.assign(e.getXY(i)),a===z?r.setNAN():r.assign(e.getXY(a))},o=new U,s=new U;a(t.read(i),o,s);for(let e=i+1;e<n;++e){let n=t.read(e);if(n===z)continue;let i=new U,c=new U;a(n,i,c);let l=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if((!l(i,o)||!l(c,s))&&(!l(c,o)||!l(i,s))){r=!0;break}}}if(r)for(let r=i;r<n;++r)e.setSegmentParentageBreakVertex(t.read(r),!0)}r.setCoordsPoint2D(a),i=n}}}function ps(e,t){let n=t.isEmpty()?e:je(null,t,!0).total();return n>e&&(n=e),n*.125}function ms(e,t){return t||=T.constructEmpty(),ps(e,t)}function hs(e,t){return e*.125}function gs(e,t){return 3*e+3*t}class _s{m_impl=null;stitchCurves(e,t,n,r){this.m_impl&&(this.m_impl.stitchCurves(e,t,n),r&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&=(this.m_impl.clearStitcher(e),null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class vs{constructor(e,t,n){this.m_progressTracker=e,this.m_nsr=n,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,n,r){if(!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=n;let a=new B,o=new F,s=[],c=[],u=[];for(let r=e.getFirstGeometry();r!==z;r=e.getNextGeometry(r))for(let d=e.getFirstPath(r);d!==z;d=e.getNextPath(d)){let r=e.getPathSize(d),f=e.getFirstVertex(d),p=0,m=-1;for(let h=0;h<r;h++){let g=e.getNextVertex(f);if(!e.querySegment(f,o,!0,!1)){f=g;continue}if(p===0){m=e.getVertexIndex(f);let t=vs.regularizeCurve(e,o.get(),f,n);if(t>=0){this.m_nsr&&this.m_nsr.m_reason===0&&this.m_nsr.assign(new J(13,m,-1)),p=t,r=e.getPathSize(d),g=e.getNextVertex(f);let n=e.querySegment(f,o,!0,!1);l(n)}}else p--;let _=e.getVertexIndex(f);this.m_originalVertexIndex!==-1&&e.setUserIndex(f,this.m_originalVertexIndex,m),e.setSegmentToIndex(_,null);let v,y=!1;switch(o.get().getGeometryType()){case i.enumEllipticArc:v=ee(o.get(),t,n,!1,!0,c,u,s),y=!0;break;case i.enumRationalBezier2:v=ee(o.get(),t,n,!1,!0,c,u,s),y=!0;break;default:{let e=!this.m_bIsSimple||!o.get().isMonotoneQuickAndDirty();v=R(o.get(),t,n,e,!1,c,s)}}let b=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(f,b,!0),!c[1].isNAN()){let t=null;t=y?new ne({points:c,weights:u}):new te({cp:c}),t.snapControlPoints(n*n),e.setSegmentToIndex(_,t)}let x=y?2:3;for(let t=1,r=v,i=x;t<r;++t,i+=x){o.get().queryCoord(s[t],a);let r=e.insertVertex(d,g,a);if(this.m_originalVertexIndex!==-1&&e.setUserIndex(r,this.m_originalVertexIndex,m),!c[i+1].isNAN()){if(y){let t=new ne({points:c.slice(i),weights:u.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(r),t)}else{let t=new te({cp:c.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(r),t)}}e.setSegmentParentageAndBreak(r,b,!1)}v>1&&(h+=v-1,r=e.getPathSize(d)),this.m_originalPlanarSegments.push(o.releaseSegment()),f=g}}}buildLinearSegmentParentage(e,t,n,r,i){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=r,!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_tolerance=n,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());let a=new B,o=new F,s=new re(0,t,0,this.m_progressTracker,!1,r),c=[];for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))for(let r=e.getFirstPath(t);r!==z;r=e.getNextPath(r)){let t=e.getPathSize(r),i=e.getFirstVertex(r);for(let u=0;u<t;u++){let u=e.getNextVertex(i);if(!e.querySegment(i,o,!0,!1)){i=u;continue}if(vs.regularizeCurve(e,o.get(),i,n)>=0){t=e.getPathSize(r),u=e.getNextVertex(i);let n=e.querySegment(i,o,!0,!1);l(n)}let d=e.getVertexIndex(i);this.m_originalVertexIndex!==-1&&e.setUserIndex(i,this.m_originalVertexIndex,d),e.setSegmentToIndex(d,null),c.length=0,s.densifySegment(o.get(),c),this.progress_();let f=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(i,f,!0);for(let t=1,n=c.length-1;t<n;++t){o.get().queryCoord(c[t],a);let n=e.insertVertex(r,u,a);e.setSegmentParentageAndBreak(n,f,!1),this.m_originalVertexIndex!==-1&&e.setUserIndex(n,this.m_originalVertexIndex,d)}this.m_originalPlanarSegments.push(o.releaseSegment()),i=u}}e.clearSegments()}stitchCurves(e,t,n){vs.st_stitchCurvesImpl(this,e,t,n,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,this.m_originalVertexIndex!==-1&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){vs.st_stitchCurvesImpl(null,e,z,0,!0)}getOriginalVertexIndex(e,t){return this.m_originalVertexIndex===-1||t===z?-1:e.getUserIndex(t,this.m_originalVertexIndex)}getOriginalSegmentTypeInfo(e){if(e!==-1){let t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.enumEllipticArc:return t.projectionBehavior()===0?0:1;case i.enumBezier:return 2;case i.enumBezier2:return 3;case i.enumLine:return-1;case i.enumRationalBezier2:return 4;default:p(``)}}return-1}m_originalPlanarSegments=[];m_progressTracker=null;m_nsr=null;m_tolerance;m_densificationDeviation;m_maxSegmentsPerCurve;m_originalVertexIndex;m_type;m_progressCounter;m_bIsSimple;progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,n,r,i,a,o){if(t===n&&r===0){l(e.getNextVertex(t)===z),e.setSegmentToIndex(e.getVertexIndex(t),null),e.setSegmentParentageAndBreak(t,-1);return}let s=e.getNextVertex(t),c=e.getXY(t),u=e.getXY(n),d=0;{let t=2,i=c;for(let r=s;r!==n;r=e.getNextVertex(r)){let n=e.getXY(r);d+=U.distance(n,i),i=n,t++}d+=U.distance(u,i),l(t===r)}if(i===null){e.setSegmentToIndex(e.getVertexIndex(t),null),e.removeVertices(s,n);return}let f,p=o,m=i.getClosestCoordinate(c,!1),h=i.getClosestCoordinate(u,!1),g=i.calculateLength2D(),_=i.tToLength(m),v=i.tToLength(h),y=Math.abs(_)>10*p&&Math.abs(_-g)>10*p,b=Math.abs(v)>10*p&&Math.abs(v-g)>10*p,x=e=>{let t=e.calculateLength2D();return Math.abs(t-d)>Math.max(d*.2,4*p)?null:e},S=i.isClosed();if(!S){let e=U.distance(i.getStartXY(),i.getEndXY());e<=p&&g>5*e&&(S=!0)}if(S){let a=new U,o,s;if(r===2)a=U.lerp(c,u,.5),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o);else{let n=e.getNextNthVertex(t,(r-1)/2);a=e.getXY(n),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o);let c=Math.abs(s)>10*p&&Math.abs(s-g)>10*p;if(!c&&(r-1>=4&&(n=e.getNextNthVertex(t,(r-1)/4),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o),c=Math.abs(s)>10*p&&Math.abs(s-g)>10*p),!c))return}let d=!1,S=_===v;if(S){let n=2,a=4;r-1<=4&&(n=1,a=2);let o=c,s=e.getXY(e.getNextNthVertex(t,n)),l=e.getXY(e.getNextNthVertex(t,a));d=-U.orientationNonRobust(o,s,l)*_t(i.calculateArea2DHelper())>0}else b?y?d=s>_:s<v?(_=0,m=0):(_=g,m=1):s>_?(v=g,h=1):(v=0,h=0);if(S)f=i.clone(),f.dropAllAttributes(),d||f.reverse(),l(c.equals(u));else{let e=!1;m>h&&(e=!0,[m,h]=[h,m]),f=i.cut(m,h,!0),f.getDescription().getAttributeCount(),e&&f.reverse()}f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}else if(y||b){if((!y||!b)&&U.distance(i.getStartXY(),i.getEndXY())<10*p){let r=[yt(m,h),yt(m,h),yt(m,h)];y?(r[1].second=0,r[2].second=1):(r[1].first=1,r[2].first=0);let a=[null,null,null],o=[0,0,0],s=Number.MAX_VALUE,l=0;for(let e=0;e<3;e++){let t=!1;if(r[e].first>r[e].second){t=!0;let n=r[e].first;r[e].first=r[e].second,r[e].second=n}a[e]=i.cut(r[e].first,r[e].second,!0),a[e].dropAllAttributes(),t&&a[e].reverse(),a[e].setCoordsForIntersector(c,u,!1),o[e]=a[e].calculateLength2D();let n=Math.abs(d-o[e]);n<s&&(s=n,l=e)}f=a[l],f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f));return}let r=!1;m>h&&(r=!0,[m,h]=[h,m]),f=i.cut(m,h,!0),f.dropAllAttributes(),r&&f.reverse(),f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}else{if(f=i.clone(),f.dropAllAttributes(),_>v&&f.reverse(),d<Math.max(g*.75,g-this.m_densificationDeviation*(r-1))){let e=m>h?h:m,t=f.tToLength(e)+d,n=f.lengthToT(t);n=At(n,e,1),f=f.cut(e,n,!0)}f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}}processSpanCurves_(e,t,n,r,i,a,o){if(t===n&&r===0){l(e.getNextVertex(t)===z),e.setSegmentToIndex(e.getVertexIndex(t),null),e.setSegmentParentageAndBreak(t,-1);return}let s=e.getNextVertex(t);{let t=2;for(let r=s;r!==n;r=e.getNextVertex(r))t++;l(t===r)}if(i===null){e.setSegmentToIndex(e.getVertexIndex(t),null),e.removeVertices(s,n);return}let c=e.getXY(t),u=e.getXY(n);if(i.isClosed()){if(c.isEqualPoint2D(u)&&c.isEqualPoint2D(i.getStartXY())){let s;if(s=this.verifySegmentFitnessCurves(e,t,n,r,i,a,o)){let r=i.clone();r.dropAllAttributes(),s<0&&r.reverse(),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),r);return}}}else if(c.isEqualPoint2D(i.getStartXY())){if(u.isEqualPoint2D(i.getEndXY())){let s=i.clone();s.dropAllAttributes();let c=this.verifySegmentFitnessCurves(e,t,n,r,s,a,o);if(c){l(c>0),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),s);return}}}else if(u.isEqualPoint2D(i.getStartXY())&&c.isEqualPoint2D(i.getEndXY())){let s=i.getReversed();s.dropAllAttributes();let c=this.verifySegmentFitnessCurves(e,t,n,r,s,a,o);if(c){l(c>0),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),s);return}}this.processSpanSplitSegmentCurves(e,t,n,r,i,a,o)}processSpan_(e,t,n,r,i,a,o){if(this.m_type===0){this.processSpanSmartTe_(e,t,n,r,i,a,o);return}this.processSpanCurves_(e,t,n,r,i,a,o)}processSpanSplitSegmentCurves(e,t,n,r,i,a,o){if(i.isLine()||this.fitSegmentToSpanCurves(e,t,n,r,i,a,o))return;let s=o*o,c=r,l=t,u=e.getXY(t),d=i.getClosestCoordinate(u,!1),f=i.getCoord2D(d),p=!1,m=U.sqrDistance(u,f);if(m>s){let r=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,i,a,o),r===n)return;l=r,p=!0,--c}let h=n,g=e.getXY(n);d=i.getClosestCoordinate(g,!1);let _=i.getCoord2D(d),v=!1,y=U.sqrDistance(g,_);if(y>s){let t=e.getPrevVertex(n);if(this.approximateSpanSectionCurves(e,t,i,a,o),t===l)return;h=t,v=!0,--c}if((p||v)&&this.fitSegmentToSpanCurves(e,l,h,c,i,a,o))return;let b=!1;if(!p&&m>0){let n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,i,a,o),n===h)return;l=n,p=!0,b=!0,--c}if(!v&&y>0){let t=e.getPrevVertex(n);if(this.approximateSpanSectionCurves(e,t,i,a,o),t===l)return;h=t,v=!0,b=!0,--c}if(b&&this.fitSegmentToSpanCurves(e,l,h,c,i,a,o))return;let x=l;for(;;){let t=e.getNextVertex(x);if(this.approximateSpanSectionCurves(e,x,i,a,o),x=t,x===h)return}}fitSegmentToSpanCurves(e,t,n,r,i,a,o){let s=[];s.push(e.getXY(t));let c=t,l=new F;for(;;){e.querySegment(c,l,!1,!0);let t=[.1,.25,.4,.5,.6,.75,.9,1],i=0;for(let e of t)(r===2||i&1)&&s.push(l.get().getCoord2D(e)),i++;if(c=e.getNextVertex(c),c===n)break}let u=(()=>{let e=s[0].compare(s.at(-1));if(e===0){let t=new St(0);$o(s,s.length,t),e=t.getResult()>=0?-1:1}return e>0})();u&&s.reverse();let d=i.clone();if(d.dropAllAttributes(),u&&d.reverse(),d.setSegmentFromCoordsForStitcher(s,s.length),u&&d.reverse(),d.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,n,r,d,a,o)){this.removeSpanBetween(e,t,n);let r=e.getVertexIndex(t);return e.setSegmentToIndex(r,d),!0}return!1}approximateSpanSectionCurves(e,t,n,r,a){let s=new F;if(!e.querySegment(t,s,!0,!1))return;let c=n.getGeometryType();if(c!==s.get().getGeometryType()){if(c===i.enumEllipticArc){if(s.get().getGeometryType()!==i.enumRationalBezier2)return;if(n.projectionBehavior()===0){let n=[];ns(!1,s.get(),a,n,this.m_progressTracker);let r=e.getNextVertex(t),i=e.getPathFromVertex(t),o=new B,c=t;for(let t=1,a=n.length;t<a;t++){let a=n[t],l=s.get().getCoord2D(n[t-1]),u=s.get().getCoord2D(Ct(n[t-1],a,.5));s.get().queryCoord(a,o);let d=o.getXY(),f=new ie;f.constructCircularArcThreePoint(l,d,u);let p=z;a<1&&(p=e.insertVertex(i,r,o)),e.setSegmentToIndex(e.getVertexIndex(c),f),c=p}return}{let n=bt(U,3);s.get().queryControlPoints(n);let r=[0,0,0];s.get().queryWeights(r);let i=ae(r),a=new ie;oe(n,i*i,null,!1,a),e.setSegmentToIndex(e.getVertexIndex(t),a);return}}o(`approximate_span_section_`)}}verifySegmentFitnessCurves(e,t,n,r,i,a,o){let s=e.getXY(t),c=e.getXY(n);if(!s.isEqualPoint2D(i.getStartXY())||!c.isEqualPoint2D(i.getEndXY()))return 0;let l=0;if(i.isClosed()){let e=i.getCoord2D(.1).sub(s);l=i.getCoord2D(.7).sub(s).crossProduct(e)>=0?1:-1}let u=H(se.s_maxMonotonicPartParams,NaN),d=i.getMonotonicPartParams(u.length,u);d--;let f=new I,p=[1,.5,.75,.25],m=0,h=t,g=s.clone();for(;;){let t=e.getNextVertex(h),r=e.getSegment(h);r===null&&(e.queryLineConnector(h,f,!0),r=f);for(let e=+(t===n);e<p.length;e++){let t=r.getCoord2D(p[e]);if(!i.isCloserThanDistance(t,W.unit(),o))return 0}if(d>1)for(let e=1;e<d;){let t=i.getCoord2D(u[e]);r.isCloserThanDistance(t,W.unit(),o)?(u[d-1]=gt(u[e],u[e]=u[d-1]),d--):e++}if(l){let e=r.getCoord2D(.25);m+=e.sub(s).crossProduct(g.sub(s)),g.assign(e),e.assign(r.getCoord2D(.75)),m+=e.sub(s).crossProduct(g.sub(s)),g.assign(e)}if(h=t,h===n)return d>1?0:l?m<0?-l:l:1}}removeSpanBetween(e,t,n){e.setSegmentToIndex(e.getVertexIndex(t),null);let r=e.getNextVertex(t);r!==n&&e.removeVertices(r,n)}static st_stitchCurvesImpl(e,t,n,r,i){if(!t.hasSegmentParentage())return;ds(t);let a=n===z?t.getFirstGeometry():n;for(;a!==z;){if(!C(t.getGeometryType(a))){a=n===z?t.getNextGeometry(a):z;continue}for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n),o=t.isClosedPath(n);o&&(a+=1);let s=t.getFirstVertex(n),c=t.getSegmentParentage(s);if(o){if(c!==-1&&!t.getSegmentParentageBreakVertex(s)){let e=t.getPrevVertex(s),n=s;for(let r=0;;r++){let i=t.getSegmentParentage(e);if(c!==i){l(i===-1);break}if(s=e,t.getSegmentParentageBreakVertex(e))break;if(e===n){s=n,t.setSegmentParentageBreakVertex(s,!0);break}e=t.getPrevVertex(e),l(r<a)}}}else l(c===-1||t.getSegmentParentageBreakVertex(s));let u=s;for(let n=0;n<a&&u!==z;){let o=t.getSegmentParentage(u);if(o===-1){if(n++,u=t.getNextVertex(u),u===s)break;continue}let c=0,d=z,f=u;c=1;let p=t.getNextVertex(f);for(;n<a&&p!==z;){n++,d=p,c++;let e=t.getSegmentParentage(p);if(e===-1||t.getSegmentParentageBreakVertex(p))break;l(e===o),p=t.getNextVertex(p)}if(d===z){l(0);break}if(!i){let n=e.m_originalPlanarSegments[o];e.processSpan_(t,f,d,c,n,o,r)}if(u=d,u===s)break}}if(n!==z)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromLinesImpl(e,t,n,r,i){let a=n===z?t.getFirstGeometry():n;for(;a!==z;){for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n);t.isClosedPath(n)&&(a+=1);let o=!0,s=!1,c=t.getFirstVertex(n),u=c;for(let n=0;n<a&&u!==z;){let d=t.getSegmentParentage(u);if(d===-1||o){o=!1,n++,u=t.getNextVertex(u),s=!0;continue}let f=0,p,m;if(s?(p=t.getPrevVertex(u),m=u,l(p!==z),l(m!==p),l(t.getSegmentParentage(p)===-1||c===p)):(p=u,m=t.getNextVertex(p),n++,l(m!==z),l(m!==p),d=t.getSegmentParentage(m)),f=2,s=!1,d===-1||t.getSegmentParentageBreakVertex(m)){u=m;continue}let h=t.getNextVertex(m);for(n++;n<a&&h!==z;){m=h,f++;let e=t.getSegmentParentage(h);if(e===-1||t.getSegmentParentageBreakVertex(h))break;l(e===d),n++,h=t.getNextVertex(h)}if(!i){let n=e.m_originalPlanarSegments[d];e.processSpan_(t,p,m,f,n,d,r)}u=m}}if(n!==z)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(e,t,n,r,i){let a=n===z?t.getFirstGeometry():n;for(;a!==z;){if(!C(t.getGeometryType(a))){a=n===z?t.getNextGeometry(a):z;continue}for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n),o=t.isClosedPath(n);o&&(a+=1);let s=t.getFirstVertex(n);if(o){if(t.getSegmentParentage(s)!==-1){let e=s;for(let r=0;!t.getSegmentParentageBreakVertex(e);r++){if(r===a){s=t.getFirstVertex(n),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else l(t.getSegmentParentage(s)===-1||t.getSegmentParentageBreakVertex(s));let c=s;for(let n=0;n<a&&c!==z;){let o=t.getSegmentParentage(c);if(o===-1){n++,c=t.getNextVertex(c);continue}let s=0,u=z,d=c;s=1;let f=t.getNextVertex(d);for(;n<a&&f!==z;){n++,u=f,s++;let e=t.getSegmentParentage(f);if(e===-1||t.getSegmentParentageBreakVertex(f))break;l(e===o),f=t.getNextVertex(f)}if(u===z)break;if(!i){let n=e.m_originalPlanarSegments[o];e.processSpan_(t,d,u,s,n,o,r)}c=u}}if(n!==z)break;a=t.getNextGeometry(a)}}static regularizeCurve(e,t,n,r){let i=t.snapControlPoints(r*r);if(i){let r=e.getVertexIndex(n),i=t.clone();e.setSegmentToIndex(r,i)}if(t.getGeometryType()===te.type){let a=[],o=t.calculateSpecialPointsForCracking(r,a);if(o>0){let s=[];if(o>1){for(let e=0;e<o;e++)if(s.push(t.getCoord2D(a[e])),e>0){let t=(Math.abs(s[e].x)+Math.abs(s[e].y))*wt(),n=U.distance(s[e-1],s[e]);if(n<t&&n>0){let t=new U;Tt(s[e-1],s[e],.5,t),s[e-1]=t,s[e]=t}}}e.splitSegment(n,a,o),i=e.snapControlPoints(n,o+1,r*r)||i;for(let t=0;t<o;t++)n=e.getNextVertex(n),e.setSegmentParentageBreakVertex(n,!0);return o}}return i?0:-1}}function ys(e,t,n,r,i){return new Ts(e,n,t,r,i).do_()}function bs(e,t,n){let r=Pe(e);return pr(t.getX(),t.getY(),n.getX(),n.getY(),Dt(r))}function xs(e,t,n=1,r=1,i=1,a=1){if(r>a)return e;if(a>r)return t;let o=[0],s=[0],c=new B;return gr(e,t,n,r,i,a,c,s,o),c}function Ss(e,t,n){let r=Pe(t),i=Le(t);return _r(e,r,z,null,n)?!0:Br(!0,e,i,null,n)}function Cs(e,t,n){return Ts.fixCurveTwoPointLoops(e,t,n)}function ws(e){return Pe(e)}class Ts{m_shape;m_progressTracker;m_tolerance;m_bFilterDegenerateSegments;m_bTrackChanges;m_progressCounter;constructor(e,t,n,r,i){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=n,this.m_bFilterDegenerateSegments=r,this.m_bTrackChanges=i,this.m_progressCounter=0}do_(){let e=new Ne(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=ws(e),n=Le(e),r=n*(1+1e-5);n*=1+1e-6;let i=!1,a=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),s=this.m_shape.hasPointFeatures();for(let e=0;;e++){this.m_shape.dbgCheckSelection(),e>a&&o(`crack_and_cluster_iteration_exceeded`),this.m_shape.dbgVerifyMonotone();let c=-1;e===0&&(c=this.firstCrack_(),i||=c>0);let l=this.cluster_(t);if(this.m_shape.dbgVerifyMonotone(),i||=l,this.m_bFilterDegenerateSegments){let e=this.m_shape.filterClosePoints(t,!0,!1,this.m_bTrackChanges,z)!==0;i||=e,this.m_shape.dbgVerifyMonotone()}let u=this.m_shape.snapControlPointsOnSelection(r*r);i||=u,this.m_shape.dbgCheckSelection();let d=!1;if((e===0&&c===-1||s||Br(!0,this.m_shape,n,null,this.m_progressTracker))&&(d=this.crack_(r),i||=d,this.m_shape.dbgVerifyMonotone()),!d&&!Ts.fixCurveTwoPointLoops(this.m_shape,t,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return i&&fs(this.m_shape),i}cluster_(e){return fr(this.m_shape,e,z,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return zr(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,n){if(!e.hasCurves())return!1;e.dbgVerifyCurves();let r=e.createUserIndexUninitialized(),i=new Re(0),a=e.queryVertexIteratorOnSelection();for(let t=a.next();t!==z;t=a.next())i.add(t),e.setUserIndex(t,r,-1);if(i.size()===0)return!1;i.add(z),e.sortVerticesSimpleByY(i,0,i.size()-1);let o=0,s=e.getXY(i.read(o)),c=new U(NaN,NaN),u=[];for(let t=1,n=i.size();t<n;++t){let n=i.read(t),a=n===z?c:e.getXY(n);if(a.equals(s))continue;let l=[];for(let n=o;n<t;n++){let t=i.read(n),a=e.getPrevVertex(t);if(a!==z&&e.getUserIndex(a,r)===-1){let t=Es(e.getXY(a),e.getSegment(a));U.sqrDistance(s,t.otherPt)!==0&&(t.vert=a,t.dir=-1,l.push(t)),e.setUserIndex(a,r,1)}let o=e.getNextVertex(t);if(o!==z&&e.getUserIndex(t,r)===-1){let n=Es(e.getXY(o),e.getSegment(t));U.sqrDistance(s,n.otherPt)!==0&&(n.vert=t,n.dir=1,l.push(n)),e.setUserIndex(t,r,1)}}if(l.length>1){l.sort((e,t)=>ks(e,t));let e=Es(c.clone(),null);l.push(e);let t=0;for(let e=1,n=l.length;e<n;e++)if(!l[e].otherPt.equals(l[e-1].otherPt)){if(e-t>1&&l[t].seg!==null){let n=!1,r=t;for(let i=t+1;i<e;i++)if(!Ds(l[r],l[i])){n=!0;break}if(n)for(let n=t;n<e&&l[n].seg!==null;n++)u.push(l[n].vert)}t=e}}o=t,s.setCoordsPoint2D(a)}for(let n of u){let r=e.getSegment(n);l(r!==null);let i=e.getXY(n),a=e.getXY(e.getNextVertex(n));if(U.distance(i,a)<t*3)e.setSegmentToIndex(e.getVertexIndex(n),null);else{let t=r.lengthToT(r.calculateLength2D()*.5);e.splitSegment(n,[t],1)}}return e.removeUserIndex(r),u.length>0}firstCrack_(){let e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=je(null,e,!0).total();if(t*4<this.m_tolerance.total()){let e=!1,n=t*1.1,r=t,i=this.cluster_(n);e||=i;let a=0;this.m_bFilterDegenerateSegments&&(a=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,z));let o=this.crack_(r);return e||=o,e?1:a?2:0}return-1}progress_(e=!1){this.m_progressCounter++,(e||!(this.m_progressCounter&4095))&&(this.m_progressCounter=0)}}function Es(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function Ds(e,t){if(l(e.otherPt.equals(t.otherPt)),e.seg===null)return t.seg===null;if(t.seg===null)return!1;let n=e.seg.getGeometryType();if(n!==t.seg.getGeometryType())return!1;if(n===i.enumBezier){let n=e.seg,r=t.seg,i=n.getControlPoint1(),a=n.getControlPoint2();e.dir===-1&&(a=gt(i,i=a));let o=r.getControlPoint1(),s=r.getControlPoint2();return t.dir===-1&&(s=gt(o,o=s)),i.equals(o)&&a.equals(s)}if(n===i.enumRationalBezier2){let n=e.seg,r=t.seg,i=n.getControlPoint1(),a=r.getControlPoint1();if(!i.equals(a))return!1;let o=[0,0,0];n.queryWeights(o),e.dir===-1&&(o[2]=gt(o[0],o[0]=o[2]));let s=[0,0,0];return r.queryWeights(s),t.dir===-1&&(s[2]=gt(s[0],s[0]=s[2])),o[0]===s[0]&&o[1]===s[1]&&o[2]===s[2]}o(``)}function Os(e,t){if(e.seg===null||t.seg===null)return e.seg===null?t.seg===null?0:1:-1;let n=e.seg.getGeometryType(),r=t.seg.getGeometryType();return n<r?-1:+(n>r)}function ks(e,t){let n=e.otherPt.compare(t.otherPt);return n===0?Os(e,t):n}var As=s,js=a,Ms=u;function Ns(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:l(0,`unrecognized cut side`)}return 3}function Ps(){return{unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1}}function Fs(e,t,n,r){return new Xs(r).autoCompleteImpl(e,t,n)}function Is(e,t,n,r,a,o,s){let c=new Xs(a);c.m_bOGCOutput=!0;let l=e.getGeometryType()===i.enumPolygon&&e.getFillRule()===1&&!We(r);return c.planarSimplifyImpl_(e,t,l,n,r,a,o,s)}function Ls(e,t,n,r,i,a,o,s){return new Xs(a).planarSimplifyImpl_(e,t,n,r,i,a,o,s)}function Rs(e,t,n,r){let i=new Xs(r),a=new N,o=a.addGeometry(t),s=i.planarSimplifyNoCrackingAndCluster(e,a,o,n);return l(s,`planar_simplify_no_cracking_and_cluster`),a.getGeometry(o)}function zs(e,t,n,r,i,a,o){return l(0),{}}function Bs(e,t,n,r){return l(0),{}}function Vs(e,t,n){return Qs(e,t,n)}function Hs(e,t,n,r){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return $s(ec(e),e,t,`-`);let a=new T;e.queryEnvelope(a);let o=new T;t.queryEnvelope(o);let s=new T;s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=o.clone(),u=Pe(c);if(l.inflateCoords(u,u),!a.isIntersecting(l))return $s(ec(e),e,t,`-`);let d=new Xs(r),f=new N,p=f.addGeometry(ec(e)),m=f.addGeometry(ec(t)),h=0,g=0,_=null;if(f.hasCurves()){_=new _s;let e=f.getEnvelope2D(r);g=hs(c.total());let t=ms(c.total(),e);h=gs(t,g),ss(f,t,c.total(),12e3,_,null,r)}d.setEditShapeCrackAndCluster(f,c.add(h));let v=d.difference(p,m);_!==null&&_.stitchCurves(f,v,g,!0);let y=$s(f.getGeometry(v),e,t,`-`);return As(y.getGeometryType())&&(y.getImpl().setIsSimple(4,c.total()),y.getGeometryType()===i.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Us(e,t,n,r){if(e.getDimension()>t.getDimension())return $s(ec(e),e,t,`^`);if(e.getDimension()<t.getDimension()||e.isEmpty())return $s(ec(t),e,t,`^`);if(t.isEmpty())return $s(ec(e),e,t,`^`);let a=new T;e.queryEnvelope(a);let o=new T;t.queryEnvelope(o);let s=new T;s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=new Xs(r),u=new N,d=u.addGeometry(ec(e)),f=u.addGeometry(ec(t)),p=0,m=null;if(u.hasCurves()){m=new _s;let e=u.getEnvelope2D(r);p=hs(c.total()),ss(u,ms(c.total(),e),c.total(),12e3,m,null,r)}l.setEditShapeCrackAndCluster(u,c);let h=l.symmetricDifference(d,f);m!==null&&m.stitchCurves(u,h,p,!0);let g=$s(u.getGeometry(h),e,t,`^`);return As(g.getGeometryType())&&(g.getImpl().setIsSimple(4,c.total()),g.getGeometryType()===i.enumPolygon&&g.getImpl().updateOGCFlagsProtected()),g}function Ws(e,t,n){return Zs(e,t,n,!0)}function Gs(e,t,n){return e.isEmpty()||t.isEmpty()?e.createInstance():bs(n,e,t)?new B({copy:xs(e,t)}):e.createInstance()}function Ks(e,t,n,r){let a=T.constructEmpty();e.queryEnvelope(a);let o=T.constructEmpty();t.queryEnvelope(o);let s=T.constructEmpty();s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=new T(o),u=Pe(c);if(l.inflateCoords(u,u),!a.isIntersecting(l)){if(e.getDimension()<=t.getDimension())return $s(ec(e.createInstance()),e,t,`&`);if(e.getDimension()>t.getDimension())return $s(ec(t.createInstance()),e,t,`&`)}let d=new Xs(r),f=new N,p=f.addGeometry(ec(e)),m=f.addGeometry(ec(t)),h=0,g=0,_=null;if(f.hasCurves()){_=new _s;let e=f.getEnvelope2D(r);g=hs(c.total());let t=ms(c.total(),e);h=gs(t,g),ss(f,t,c.total(),12e3,_,null,r)}d.setEditShapeCrackAndCluster(f,c.add(h));let v=d.intersection(p,m);_!==null&&_.stitchCurves(f,v,g,!0);let y=$s(f.getGeometry(v),e,t,`&`);return As(y.getGeometryType())&&(y.getImpl().setIsSimple(4,c.total()),y.getGeometryType()===i.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function qs(e,t,n,r){let a=[,,,],o=T.constructEmpty();e.queryEnvelope(o);let s=T.constructEmpty();t.queryEnvelope(s);let c=T.constructEmpty();c.setCoords({env2D:o}),c.mergeEnvelope2D(s);let l=je(n,c,!0),u=new T(s),d=Pe(l);if(u.inflateCoords(d,d),!o.isIntersecting(u)){if(e.getDimension()<=t.getDimension()){let n=$s(ec(e.createInstance()),e,t,`&`);return a[n.getDimension()]=n,a}if(e.getDimension()>t.getDimension()){let n=$s(ec(t.createInstance()),e,t,`&`);return a[n.getDimension()]=n,a}}let f=new Xs(r),p=new N,m=p.addGeometry(ec(e)),h=p.addGeometry(ec(t)),g=0,_=0,v=null;if(p.hasCurves()){v=new _s;let e=p.getEnvelope2D(r);_=hs(l.total());let t=ms(l.total(),e);g=gs(t,_),ss(p,t,l.total(),12e3,v,null,r)}f.setEditShapeCrackAndCluster(p,l.add(g)),p.dbgVerifyCurves();let y=f.intersectionEx(m,h);for(let n of y){v!==null&&v.stitchCurves(p,n,_,!1);let r=$s(p.getGeometry(n),e,t,`&`);As(r.getGeometryType())&&(r.getImpl().setIsSimple(4,l.total()),r.getGeometryType()===i.enumPolygon&&r.getImpl().updateOGCFlagsProtected()),a[r.getDimension()]=r}return v!==null&&v.clearStitcher(p),a}function Js(e,t,r,i,a,o=!1){t===0&&n(`not enough geometries to dissolve`);let s=0;for(let n=0,r=t;n<r;n++)s=Math.max(e[n].getDimension(),s);if(s===2||s===1)return new Xs(i).dissolveMultiPaths_(s,!1,e,t,r,a,o);let c=0,l=-1;for(let n=0,r=t;n<r;n++)e[n].getDimension()===s&&(l===-1&&(l=n),e[n].isEmpty()||(l=n,c++));if(c<2)return ec(e[l]);let u=Ge.constructEmpty(),d=new N,f=z;for(let n=0,r=t;n<r;n++)if(e[n].getDimension()===s&&!e[n].isEmpty()){f===z?f=d.addGeometry(ec(e[n])):d.appendGeometry(f,ec(e[n]));let t=Ge.constructEmpty();e[n].queryLooseEnvelope(t),u.mergeEnv3D(t)}let p=je(r,u.getEnvelope2D(),!0),m=new Xs(i);if(o){let e=Ke(r,u.getEnvelopeZs(),!0);return m.planarSimplify3DImpl_(d,p,e,0,!0)}return m.m_bOGCOutput=!0,m.planarSimplifyMultiPoints(d,p,!1,-1)}function Ys(e,t,r,i,a,o=!1){t<2&&n(`not enough geometries to dissolve`);let s=0;for(let n=0,r=t;n<r;n++)s=Math.max(e[n].getDimension(),s);if(s===2||s===1)return new Xs(i).dissolveMultiPaths_(s,!0,e,t,r,a,o);let c=Ge.constructEmpty(),l=new N,u=z,d=0,f=-1;for(let n=0,r=t;n<r;n++)if(e[n].getDimension()===s&&(f===-1&&(f=n),!e[n].isEmpty())){f=n,u===z?u=l.addGeometry(ec(e[n])):l.appendGeometry(u,ec(e[n]));let t=Ge.constructEmpty();e[n].queryLooseEnvelope(t),c.mergeEnv3D(t),d++}if(d<2)return ec(e[f]);let p=s===0?r:null,m=je(p,c.getEnvelope2D(),!0),h=new Xs(i);if(o){let e=Ke(p,c.getEnvelopeZs(),!0);return h.m_bOGCOutput=!0,h.planarSimplify3DImpl_(l,m,e,0,!0)}return h.planarSimplifyMultiPoints(l,m,!0,-1)}class Xs{m_progressTracker;m_topoGraph=null;m_maskLookup=[];m_dummyPt1=U.getNAN();m_dummyPt2=U.getNAN();m_fromEdgeForPolylines=z;m_progressCounter=0;m_bOGCOutput=!1;constructor(e){this.m_progressTracker=e}linesToPolygonsImpl(e,t){let n=0,r=0,i=null;if(e.hasCurves()){i=new _s;let a=e.getEnvelope2D(this.m_progressTracker);r=hs(t.total());let o=ms(t.total(),a);n=gs(o,r),ss(e,o,t.total(),12e3,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(n));let a=this.m_topoGraph.createUserIndexForChains(),o=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(o,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(o);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);let s=[];for(let t=this.m_topoGraph.getFirstChain();t!==z;t=this.m_topoGraph.getChainNext(t)){if(this.m_topoGraph.getChainUserIndex(t,a)===1)continue;this.m_topoGraph.setChainUserIndex(t,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);if(this.m_topoGraph.getChainArea(t)===0)continue;let n=this.m_topoGraph.extractPolygonFromChainAndIslands(e,z,t,z);i?.stitchCurves(e,n,r,!1);let o=e.getGeometry(n);s.push(o)}return new sn(s)}autoCompleteImpl(e,t,n){let r=0,i=0,a=null;if(e.hasCurves()){a=new _s;let t=e.getEnvelope2D(this.m_progressTracker);i=hs(n.total());let o=ms(n.total(),t);r=gs(o,i),ss(e,o,n.total(),12e3,a,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,n.add(r));let o=this.m_topoGraph.getGeometryID(t),s=this.m_topoGraph.createUserIndexForChains(),c=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(c,s,1);for(let e=this.m_topoGraph.getChainFirstIsland(c);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,s,1);let l=[];for(let t=this.m_topoGraph.getFirstChain();t!==z;t=this.m_topoGraph.getChainNext(t)){if(this.m_topoGraph.getChainUserIndex(t,s)===1)continue;this.m_topoGraph.setChainUserIndex(t,s,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,s,1);if(this.m_topoGraph.getChainParentage(t)!==0)continue;let n=this.m_topoGraph.getChainHalfEdge(t),r=n,c=!1;do{let e=this.m_topoGraph.getHalfEdgeTwin(r);if(this.m_topoGraph.getHalfEdgeChain(e)!==t&&(this.m_topoGraph.getHalfEdgeParentage(r)&o)!==0){c=!0;break}r=this.m_topoGraph.getHalfEdgeNext(r)}while(r!==n);if(!c||this.m_topoGraph.getChainArea(t)===0)continue;let u=this.m_topoGraph.extractPolygonFromChainAndIslands(e,z,t,z);a!==null&&a.stitchCurves(e,u,i,!1);let d=e.getGeometry(u);l.push(d)}return new sn(l)}setEditShape(e,t=!1){this.m_topoGraph===null&&(this.m_topoGraph=new sr),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){ys(e,t,this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,this.m_bOGCOutput,z,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){let n=this.m_topoGraph.getShape();for(let r=n.getFirstGeometry();r!==z;r=n.getNextGeometry(r))if(r===t)for(let t=n.getFirstPath(r);t!==z;t=n.getNextPath(t)){let r=n.getFirstVertex(t);if(r===z)continue;let i=n.getNextVertex(r);for(;i!==z;){let t=this.m_topoGraph.getClusterFromVertex(r),a=this.m_topoGraph.getClusterFromVertex(i),o=this.m_topoGraph.getHalfEdgeConnector(t,a);if(o!==z){let t=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}r=i,i=n.getNextVertex(r)}}}flushVertices_(e,t){let n=this.m_topoGraph.getShape(),r=n.hasSegmentParentage(),i=new F,a=n.insertPath(e,z);t.push(t[0]);let o=t.length,s=z;for(let e=0;e<o;e++){let c=t[e];if(s=n.addVertex(a,c),!r)continue;let l=this.m_topoGraph.getClusterFromVertex(c);if(e>0&&this.m_topoGraph.isBreakNode(l)&&n.setSegmentParentageBreakVertex(s,!0),e<o-1){let r=this.m_topoGraph.getHalfEdgeConnector(l,this.m_topoGraph.getClusterFromVertex(t[e+1])),a=this.m_topoGraph.getSegmentParentage(r);n.setSegmentParentageAndBreak(s,a,e>0||this.m_topoGraph.isBreakNode(l)),this.m_topoGraph.isHalfEdgeCurve(r)&&(this.m_topoGraph.querySegmentXY(r,i),n.setSegmentToIndex(n.getVertexIndex(s),i.get().clone()))}}if(r){let e=this.m_topoGraph.getClusterFromVertex(t[o-1]);this.m_topoGraph.isBreakNode(e)&&n.setSegmentParentageBreakVertex(s,!0)}n.setClosedPath(a,!0)}processPolygonCuts_(e,t,n,r){let a=this.m_topoGraph.getGeometryID(n),o=this.m_topoGraph.getGeometryID(r),s=[],c=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n)){let r=this.m_topoGraph.getClusterHalfEdge(n);if(r===z)continue;let u=r;do{if(this.m_topoGraph.getHalfEdgeUserIndex(u,l)!==1){let n=u,r=u,d=!1,f=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(n,l,1),d||(this.m_topoGraph.getHalfEdgeParentage(n)&o)!==0&&(this.m_topoGraph.getHalfEdgeFaceParentage(n)&a)!==0&&(r=n,d=!0),d){let t=this.m_topoGraph.getHalfEdgeOrigin(n),r=this.m_topoGraph.getClusterVertexIterator(t),i=this.m_topoGraph.getVertexFromVertexIterator(r);if(s.push(i),e!==-1&&(this.m_topoGraph.getHalfEdgeParentage(n)&o)!==0){let t=this.m_topoGraph.getHalfEdgeUserIndex(n,e);f|=t}}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==r);if(d&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(r))>0){let e=c.createGeometry(i.enumPolygon);this.flushVertices_(e,s),t!==-1&&c.setGeometryUserIndex(e,t,f)}s.length=0}u=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(u))}while(u!==r)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(e,t,n,r){this.m_topoGraph.removeSpikes_();let i=-1;e!==-1&&(i=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(i,n)),this.processPolygonCuts_(i,e,t,n),i!==-1&&(this.m_topoGraph.deleteUserIndexForHalfEdges(i),i=-1);let a=this.m_topoGraph.getShape();for(let e=a.getFirstGeometry();e!==z;e=a.getNextGeometry(e))e!==t&&e!==n&&r.push(e);r.sort((e,t)=>{let n=a.getFirstPath(e),r=a.getRingArea(n),i=a.getFirstPath(t),o=a.getRingArea(i);return r<o?-1:+(r>o)})}cut(e,t,n,r,i){let a=this.m_topoGraph.getShape().getGeometryType(n),s=this.m_topoGraph.getShape().getGeometryType(r),c=u(a),l=u(s);if(c===2&&l===1){this.cutPolygonPolyline_(t,n,r,i);return}if(c===1&&l===1){new nc(this,e,t,n,r,i).Do();return}o(``)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){let t=e.getGeometryType();if(t===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(a(t)){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n(`Unexpected geometry type`),e}dissolveNonSimplePolygons(e,t,n,r){l(t>0);let i=new N,a=0,o=-1;for(let n=0,r=t;n<r;n++)e[n].getDimension()===2&&(o===-1&&(o=n),e[n].isEmpty()||(a++,i.addGeometry(e[n])));return a===0?(l(o>=0),this.normalizeInputGeometry(e[o])):this.planarSimplifyPolygons(i,n,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,n,r,o,c,u){l(e>=1&&e<=2),l(r>0);let d=8&c?1:2,f=Ge.constructEmpty(),p=0,h=-1,g=!0;for(let t=0,a=r;t<a;t++)if(n[t].getDimension()===e&&(h===-1&&(h=t),!n[t].isEmpty())){h=t,p++;let r=Ge.constructEmpty();if(n[t].queryLooseEnvelope(r),f.mergeEnv3D(r),e===2&&g&&n[t].getGeometryType()===i.enumPolygon){if(c&16){let e=n[t].getImpl().getIsSimple(0,[0]),r=this.m_bOGCOutput?e===5:De(e);g&&=r}else{let e=$e(n[t],0);g&&=e}}}if(p<2&&(l(h>=0),p===0||!(c&16)))return this.normalizeInputGeometry(n[h]);if(!g){let e=je(t?null:o,f.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(n,r,e,c)}let _=n.slice(0,r),v=je(o,f.getEnvelope2D(),!0),y=Pe(v)*10,b=new Ne(0,0);if(u&&(b=Ke(o,f.getEnvelopeZs(),!0)),p===1&&e===1&&d===2&&!t)return u?zs():this.m_bOGCOutput?Is(_[h],v,!1,-1,this.m_progressTracker,d,!1):Ls(_[h],v,!1,!1,-1,this.m_progressTracker,d,!1);let x=new et;x.startConstruction();let S=e===2?3:4,C=0;for(let n=0,o=r;n<o;n++){if(_[n].getDimension()!==e||_[n].isEmpty())continue;let r=_[n].getGeometryType();if(r!==i.enumEnvelope){if(a(r)?(_[n]=this.normalizeInputGeometry(_[n]),r=i.enumPolyline):l(s(r)),e===1){l(r===i.enumPolyline);let e=-1;u?l(0,`3d not implemented yet`):e=_[n].getImpl().getIsSimple(v.total(),[0]),(this.m_bOGCOutput?e!==5:!De(e))&&(t?S=-1:(u?l(0,`3d not implemented yet`):this.m_bOGCOutput?_[n]=Is(_[n],v,!1,-1,this.m_progressTracker,d,!1):_[n]=Ls(_[n],v,!1,!1,-1,this.m_progressTracker,d,!1),l(De(_[n].getImpl().getIsSimple(v.total(),[0])))))}else{l(r===i.enumPolygon);let e=_[n].getImpl().getIsSimple(0,[0]);l(We(e))}let o=_[n].getImpl();for(let e=0,t=o.getPathCount();e<t;e++){let t=T.constructEmpty();o.queryLoosePathEnvelope(e,t),t.inflateCoords(y,y),x.addEnvelope(C,t),C++}}else{l(r===i.enumEnvelope);let e=T.constructEmpty();_[n].queryLooseEnvelope(e),e.inflateCoords(y,y),x.addEnvelope(C,e),C++,S=-1}}x.endConstruction();let w=C,D=H(w,-2147483647),O=H(w,-1),A=0;h=-1,C=0;for(let t=0,n=r;t<n;t++){if(_[t].getDimension()!==e||(h===-1&&(h=t),_[t].isEmpty()))continue;h=t,A++;let n=_[t].getGeometryType();if(s(n)){let e=_[t];for(let n=0,r=e.getPathCount();n<r;n++)O[C]=t,D[C]=-n-1,C++}else l(n===i.enumEnvelope),O[C]=t,D[C]=-1,C++}if(A<2&&e===2)return l(h>=0),this.normalizeInputGeometry(_[h]);let j=w;for(;x.next()&&j>0;){this.progress_();let e=x.getHandleA(),t=x.getHandleB(),n=x.getElement(e),r=x.getElement(t);O[n]!==O[r]&&(D[n]<0&&(j--,D[n]=-(D[n]+1)),D[r]<0&&(j--,D[r]=-(D[r]+1)))}let M=new N,P=!1,F=0;for(let t=0,n=r;t<n;t++){if(_[t].getDimension()!==e||_[t].isEmpty())continue;let n=_[t].getGeometryType(),r=F,a=0,o=0,c=s(n)?_[t]:null;for(let e=r,n=D.length;e<n&&O[e]===t;e++)D[e]>=0&&(a++,o+=c?c.getPathSize(D[e]):m(_[t])),F++;let u=m(_[t]);if(o>.95*u){M.addGeometry(this.normalizeInputGeometry(_[t]));for(let e=r;e<F;e++)D[e]<0&&(D[e]=-(D[e]+1))}else if(a===0){P=!0;continue}else{P=!0,l(s(n)),l(c!=null);let e=new k({vd:_[t].getDescription()}),a=new E({vd:_[t].getDescription()}),o=n===i.enumPolygon?e:a;for(let e=r;e<F;e++)D[e]>=0&&o.addPath(c,D[e],!0);M.addGeometry(o)}}let I=M.getFirstGeometry(),L;if(I!==z){let n=e===2,r=t?je(null,f.getEnvelope2D(),!0):v,i=new Ne(0,0);if(u&&(i=t?Ke(null,f.getEnvelopeZs(),!0):b),e===2&&!(c&2)){M.collapseAllGeometriesToFirst();let e=0,t=null;if(M.hasCurves()&&!M.hasSegmentParentage()){t=new _s;let n=M.getEnvelope2D(this.m_progressTracker);e=hs(r.total()),ss(M,ms(r.total(),n),r.total(),12e3,t,null,this.m_progressTracker)}Fr(M,M.getFirstGeometry(),r.total(),this.m_progressTracker),t!==null&&t.stitchCurves(M,z,e,!0)}if(u)L=this.planarSimplify3DImpl_(M,r,i,d,!0);else if(e===2)L=this.planarSimplifyPolygons(M,r,n,t,-1,!1);else{let e=Ps();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=d,L=this.planarSimplifyPolylines(M,r,t,e,-1)}P||(S=L.getImpl().getIsSimple(r.total(),[0]))}else l(P),l(h>=0),L=e===2?new k({vd:_[h].getDescription()}):new E({vd:_[h].getDescription()});if(P){let e=0;for(let t=0,n=D.length;t<n;t++){let n=O[t];if(!(n<0)&&D[t]<0){let r=_[n].getGeometryType(),i=s(r)?_[n]:null;if(i){let n=-(D[t]+1);e+=i.getPathSize(n)}else e+=4}}L.reserve(L.getPointCount()+e);for(let e=0,t=D.length;e<t;e++){let t=O[e];if(!(t<0)&&D[e]<0){let n=_[t].getGeometryType(),r=s(n)?_[t]:null;if(r){let t=-(D[e]+1);L.addPath(r,t,!0)}else n===i.enumEnvelope?L.addEnvelope(_[t],!1):(l(a(n)),L.addSegment(_[t],!0))}}}let R=0;if(e===2?S!==-1&&(S=3,R=t?0:v.total()):(l(e===1),!t&&S!==-1&&(R=v.total())),u||L.getImpl().setIsSimple(S,R),!t&&P){if(e===2){if(u)l(0,`3d not yet implemented`);else return new xc().execute(L,o,!1,this.m_progressTracker)}else e===1&&d!==1&&(L=u?Bs():Rs(this.m_bOGCOutput,L,d,this.m_progressTracker),L.getImpl().setIsSimple(S,R))}return L}dissolveTopoGraphCommonEdges_(){let e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n)){let r=this.m_topoGraph.getClusterHalfEdge(n),i=r;if(r!==z)do{if(this.progress_(),this.m_topoGraph.getHalfEdgeUserIndex(i,e)!==1){let n=this.m_topoGraph.getHalfEdgeTwin(i);this.m_topoGraph.setHalfEdgeUserIndex(n,e,1),this.m_topoGraph.setHalfEdgeUserIndex(i,e,1);let r=this.m_topoGraph.getHalfEdgeFaceParentage(i);if(this.isGoodParentage(r)){let e=this.m_topoGraph.getHalfEdgeFaceParentage(n);this.isGoodParentage(e)&&t.push(i)}}i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(i))}while(i!==r)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,n,r){let i=It(),a=z;for(let r=this.m_topoGraph.getClusterVertexIterator(e);r!==z;r=this.m_topoGraph.incrementVertexIterator(r)){let e=this.m_topoGraph.getVertexFromVertexIterator(r),o=t.getUserIndex(e,n);o>=0&&o<i&&(i=o,a=e)}l(a!==z);let o=t.getUserIndex(a,r);return o>0&&(t.setUserIndex(a,r,--o),o===0&&t.setUserIndex(a,n,-1)),a}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,n,r,a){let o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==i.enumPolygon)return;let s=o.hasSegmentParentage(),c=new F;for(let i=o.getFirstPath(e);i!==z;i=o.getNextPath(i)){let e=o.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);let l=this.m_topoGraph.getHalfEdgeFromVertex(e);if(l===z)continue;let u=this.m_topoGraph.getHalfEdgeUserIndex(l,n);if(u===1||u===2)continue;let d=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(!this.isGoodParentage(d)){this.m_topoGraph.setHalfEdgeUserIndex(l,n,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(l,n,1);let f=o.insertPath(t,z);o.setClosedPath(f,!0);let p=l,m=e,h=this.m_topoGraph.getClusterFromVertex(m),g=1;do{this.progress_();let e=this.chooseVertexFromVertexCluster_(m,a),t=o.addVertex(f,e);if(this.m_topoGraph.isHalfEdgeCurve(p)&&(this.m_topoGraph.querySegmentXY(p,c),o.setSegmentToIndex(o.getVertexIndex(t),c.get().clone())),s){let e=this.m_topoGraph.getSegmentParentage(p);o.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(h))}r!==-1&&this.m_topoGraph.setClusterUserIndex(h,r,1),this.m_topoGraph.setHalfEdgeUserIndex(p,n,1),p=this.m_topoGraph.getHalfEdgeNext(p);let i,l;do i=g===1?o.getNextVertex(m):o.getPrevVertex(m),l=i===z?z:this.m_topoGraph.getClusterFromVertex(i);while(l===h);let u=this.m_topoGraph.getHalfEdgeOrigin(p);if(u!==l){do i=g===1?o.getPrevVertex(m):o.getNextVertex(m),l=i===z?z:this.m_topoGraph.getClusterFromVertex(i);while(l===h);if(u!==l){l=u;let e=this.m_topoGraph.getClusterVertexIterator(l);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else g=-g}h=l,m=i}while(p!==l)}}topoOperationPolygonPolygonHelper_(e,t,n,r,i,a){this.progress_(!0),e!==z&&this.collectPolygonPathsPreservingFrom_(e,n,i,a,r),t!==z&&this.collectPolygonPathsPreservingFrom_(t,n,i,a,r);let o=new F,s=this.m_topoGraph.getShape();s.dbgVerifyCurves();let c=s.hasSegmentParentage();for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z)continue;let l=t;do{this.progress_();let e=this.m_topoGraph.getHalfEdgeUserIndex(l,i);if(e!==1&&e!==2){let e=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(e)){let e=s.insertPath(n,z);s.setClosedPath(e,!0);let t=l;do{let n=this.m_topoGraph.getHalfEdgeVertexIterator(t),l=z;if(n!==z)l=this.m_topoGraph.getVertexFromVertexIterator(n);else{let e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(t));l=this.m_topoGraph.getVertexFromVertexIterator(e),l=s.getNextVertex(l)}let u=this.chooseVertexFromVertexCluster_(l,r),d=s.addVertex(e,u);if(c){let e=this.m_topoGraph.getSegmentParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t);s.setSegmentParentageAndBreak(d,e,this.m_topoGraph.isBreakNode(n))}if(this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,o),s.setSegmentToIndex(s.getVertexIndex(d),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(t,i,1),a!==-1){let e=this.m_topoGraph.getClusterFromVertex(u);this.m_topoGraph.setClusterUserIndex(e,a,1)}t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,i,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==t)}}topoOperationPolygonPolygon_(e,t,n,r=!1){this.dissolveTopoGraphCommonEdges_();let a=this.m_topoGraph.getShape(),o=a.createGeometry(i.enumPolygon),s=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,n,s,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(s),r||ri(a,o,3,this.m_bOGCOutput,z,this.m_progressTracker),o}topoOperationPolyline_(e,t){let n=Ps();return n.allCrossRoadsImpassable=!1,n.ogcRule=t,n.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(z,e,!1,n).first}topoOperationMultiPoint_(){let e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),n=e.insertPath(t,z);for(let t=this.m_topoGraph.getFirstCluster();t!==z;t=this.m_topoGraph.getNextCluster(t)){let r=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(r)){let r=z;for(let n=this.m_topoGraph.getClusterVertexIterator(t);n!==z;n=this.m_topoGraph.incrementVertexIterator(n)){let t=this.m_topoGraph.getVertexFromVertexIterator(n);r===z&&(r=t);let i=e.getGeometryFromPath(e.getPathFromVertex(t)),a=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(a)){r=t;break}}e.addVertex(n,r)}}return t}intersection(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=u(n),a=u(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s|c]=!0;let d=z;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(d=e),i===2&&a===2)return this.topoOperationPolygonPolygon_(e,t,d);if(i===1&&a>0||a===1&&i>0)return this.topoOperationPolyline_(d,this.m_bOGCOutput);if(i===0||a===0)return this.topoOperationMultiPoint_();o(``)}topoOperationPolygonPolygonEx(e,t,n){let r=this.m_topoGraph.getShape(),a=r.createGeometry(i.enumPolygon),o=r.createGeometry(i.enumPolyline),s=r.createGeometry(i.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let c=z,l=this.m_topoGraph.createUserIndexForHalfEdges(),u=this.m_topoGraph.createUserIndexForClusters();r.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,a,n,l,u),r.dbgVerifyCurves();let d=r.hasSegmentParentage(),f=new F;for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z)continue;let i=t;do{let t=this.m_topoGraph.getHalfEdgeUserIndex(i,l),a=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(i),l),s=t|a;if(s===2){let c=this.m_topoGraph.getHalfEdgeParentage(i);if(this.isGoodParentage(c)){let p=r.insertPath(o,z),m=i,h=this.chooseVertexFromCluster_(e,n),g=r.addVertex(p,h);if(d){let e=this.m_topoGraph.getSegmentParentage(i),t=this.m_topoGraph.getHalfEdgeOrigin(i);r.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}this.m_topoGraph.isHalfEdgeCurve(i)&&(this.m_topoGraph.querySegmentXY(i,f),r.setSegmentToIndex(r.getVertexIndex(g),f.get().clone())),this.m_topoGraph.setClusterUserIndex(e,u,1);do{this.progress_();let e=this.m_topoGraph.getHalfEdgeTo(m),o=this.chooseVertexFromCluster_(e,n);if(g=r.addVertex(p,o),d){let e=this.m_topoGraph.getSegmentParentage(i),t=this.m_topoGraph.getHalfEdgeOrigin(i);r.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.setHalfEdgeUserIndex(m,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l,1),this.m_topoGraph.setClusterUserIndex(e,u,1),m=this.m_topoGraph.getHalfEdgeNext(m),t=this.m_topoGraph.getHalfEdgeUserIndex(m,l),a=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l),s=t|a,s!==2)break;if(c=this.m_topoGraph.getHalfEdgeParentage(m),!this.isGoodParentage(c)){this.m_topoGraph.setHalfEdgeUserIndex(m,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l,1);break}this.m_topoGraph.isHalfEdgeCurve(i)&&m!==i&&(this.m_topoGraph.querySegmentXY(i,f),r.setSegmentToIndex(r.getVertexIndex(g),f.get().clone()))}while(m!==i)}else this.m_topoGraph.setHalfEdgeUserIndex(i,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(i),l,1)}i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(i))}while(i!==t)}for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){if(this.progress_(),this.m_topoGraph.getClusterUserIndex(e,u)===1)continue;let t=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(t)){c===z&&(c=r.insertPath(s,z));let t=this.m_topoGraph.getClusterVertexIterator(e),i=z;if(t!==z){i=this.m_topoGraph.getVertexFromVertexIterator(t);let e=this.chooseVertexFromVertexCluster_(i,n);r.addVertex(c,e)}}}this.m_topoGraph.deleteUserIndexForClusters(u),this.m_topoGraph.deleteUserIndexForHalfEdges(l),r.dbgVerifyCurves(),ri(r,a,3,this.m_bOGCOutput,z,this.m_progressTracker);let p=[z,z,z];return p[0]=s,p[1]=o,p[2]=a,p}topoOperationPolylinePolylineOrPolygonEx(e,t){let n=Ps();return n.allCrossRoadsImpassable=!1,n.ogcRule=t,n.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(z,e,!0,n)}topoOperationMultiPoint(){let e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),n=e.insertPath(t,z);for(let t=this.m_topoGraph.getFirstCluster();t!==z;t=this.m_topoGraph.getNextCluster(t)){let r=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(r)){let r=z;for(let n=this.m_topoGraph.getClusterVertexIterator(t);n!==z;n=this.m_topoGraph.incrementVertexIterator(n)){let t=this.m_topoGraph.getVertexFromVertexIterator(n);r===z&&(r=t);let i=e.getGeometryFromPath(e.getPathFromVertex(t)),a=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(a)){r=t;break}}e.addVertex(n,r)}}return t}intersectionEx(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=Ms(n),a=Ms(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s|c]=!0;let u=z;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(u=e),i===2&&a===2)return this.topoOperationPolygonPolygonEx(e,t,u);if(i===1&&a>0||a===1&&i>0){let{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(u,this.m_bOGCOutput);return[t,e]}if(i===0||a===0){let e=[];return e.push(this.topoOperationMultiPoint()),e}o(``)}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){let n=this.getCombinedHalfEdgeParentage(t),r=this.m_topoGraph.getHalfEdgeOrigin(t),i=this.m_topoGraph.getHalfEdgeTo(t),a=0,o=0;for(let s=this.m_topoGraph.getClusterVertexIterator(r);s!==z;s=this.m_topoGraph.incrementVertexIterator(s)){let r=this.m_topoGraph.getVertexFromVertexIterator(s),c=e.getPathFromVertex(r),l=e.getGeometryFromPath(c),u=this.m_topoGraph.getGeometryID(l),d=e.getFirstVertex(c),f=(u&n)!==0;f&&d===r&&(this.m_fromEdgeForPolylines=t);let p=e.getNextVertex(r);if(p!==z&&this.m_topoGraph.getClusterFromVertex(p)===i){if(a++,f){if(this.m_fromEdgeForPolylines===z&&d===p){let e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o++}}else{let n=e.getPrevVertex(r);if(n!==z&&this.m_topoGraph.getClusterFromVertex(n)===i&&(a--,f)){if(this.m_fromEdgeForPolylines===z&&d===n){let e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o--}}}this.m_topoGraph.queryXY(r,this.m_dummyPt1),this.m_topoGraph.queryXY(i,this.m_dummyPt2);let s=U.distance(this.m_dummyPt1,this.m_dummyPt2);return(o===0?a:o)*s}tryMoveThroughCrossroadBackwards(e,t){let n=this.m_topoGraph.getHalfEdgePrev(e),r=this.m_topoGraph.getHalfEdgeTwin(n);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return z;let t=this.m_topoGraph.getHalfEdgeTwin(e);if(r===this.m_topoGraph.getHalfEdgeNext(t))return n}let i=r,a=z;for(;i!==e;){let e=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(e)){if(a!==z)return z;a=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(i))}return a}tryMoveThroughCrossroadForward(e,t){let n=this.m_topoGraph.getHalfEdgeNext(e),r=this.m_topoGraph.getHalfEdgeTwin(n);if(!t){let t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return z;if(r===this.m_topoGraph.getHalfEdgePrev(t))return n}let i=r,a=z;for(;i!==e;){let e=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(e)){if(a!==z)return z;a=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(i))}return a}isOnALoop(e,t){let n=e,r=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let i=0;i<r;i++){if(this.m_topoGraph.getHalfEdgeUserIndex(n,t)===1)return!1;let r=this.m_topoGraph.getHalfEdgeNext(n);if(r===this.m_topoGraph.getHalfEdgeTwin(n))return!1;if(n=r,n===e)return!0}o(`is_on_a_loop_`)}restorePolylineParts(e,t,n,r,i,a,o,s,c,u){l(i===z&&a>=0&&o>=0||a===-1&&o===-1),l(s===-1&&u.unsplitBehavior!==1||s!==-1&&u.unsplitBehavior===1);let d=u.ogcRule,f=u.allCrossRoadsImpassable,p=u.unsplitBehavior===1,m=u.unsplitBehavior===0,h=this.m_topoGraph.getShape(),g=h.hasSegmentParentage(),_=e,v=this.m_topoGraph.getHalfEdgeTwin(_),y=new F;this.m_fromEdgeForPolylines=z;let b=this.prevailingDirection(h,_),x=_,S=z,C=!1,w=!1,T=!1;if(!p)do{let t=this.m_topoGraph.getHalfEdgePrev(_);if(t===v){T=!0;break}let r=this.m_topoGraph.getHalfEdgeNext(v);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(r))){C=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==r){if(f){C=!0;break}if(_=this.tryMoveThroughCrossroadBackwards(_,!0),_===z){C=!0;break}v=this.m_topoGraph.getHalfEdgeTwin(_)}else _=t,v=r;if(this.m_topoGraph.getHalfEdgeUserIndex(_,n)===1){T=!0;break}if(_===e){S=e,w=!0;break}let i=this.getCombinedHalfEdgeParentage(_);if(!this.isGoodParentage(i))break;x=_,b+=this.prevailingDirection(h,_)}while(1);if(S===z){for(_=e,v=this.m_topoGraph.getHalfEdgeTwin(_),S=_;;){let e=this.m_topoGraph.getHalfEdgeNext(_),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){C=!0;break}if(e===v){T=!0;break}if(s!==-1){let e=this.m_topoGraph.getHalfEdgeOrigin(v);if(this.m_topoGraph.getClusterUserIndex(e,s)===1){C=!0;break}}let r=this.m_topoGraph.getHalfEdgePrev(v);if(this.m_topoGraph.getHalfEdgeTwin(e)!==r){if(t||f){C=!0;break}if(_=this.tryMoveThroughCrossroadForward(_,!0),_===z){C=!0;break}v=this.m_topoGraph.getHalfEdgeTwin(_)}else _=e,v=r;if(this.m_topoGraph.getHalfEdgeUserIndex(_,n)===1){T=!0;break}let i=this.getCombinedHalfEdgeParentage(_);if(!this.isGoodParentage(i))break;S=_,b+=this.prevailingDirection(h,_)}let t=this.m_topoGraph.getHalfEdgeOrigin(x);w=this.m_topoGraph.getHalfEdgeTo(S)===t}else if(this.m_fromEdgeForPolylines!==z){x=e,S=this.tryMoveThroughCrossroadBackwards(x,!1),l(S!==z);let t=this.m_topoGraph.getHalfEdgeTwin(x);this.m_topoGraph.getHalfEdgeNext(t)}let E=w;!w&&!T&&c&&(E=this.isOnALoop(e,n),E||=this.isOnALoop(v,n));let D=b>=0,O=!1;E&&C&&(w?(O=d,D&&(O||p||m)&&x!==e&&(l(!p),x=e,O=!1)):(p||D&&m)&&(x=e));let k=0;for(_=x;v=this.m_topoGraph.getHalfEdgeTwin(_),this.m_topoGraph.setHalfEdgeUserIndex(_,n,1),this.m_topoGraph.setHalfEdgeUserIndex(v,n,1),k++,_!==S;)_=f?this.m_topoGraph.getHalfEdgeNext(_):this.tryMoveThroughCrossroadForward(_,!1);D||(S=gt(x,x=S),S=this.m_topoGraph.getHalfEdgeTwin(S),x=this.m_topoGraph.getHalfEdgeTwin(x));let A=h.insertPath(t,z);_=x;let j=this.m_topoGraph.getHalfEdgeOrigin(x),M;M=a===-1?this.chooseVertexFromCluster_(j,i):this.chooseVertexByOrder(j,h,a,o),this.m_topoGraph.isStrongPathNode(j)&&h.setStrongPathStart(A,!0);let N=h.addVertex(A,M),P=N;r!==-1&&this.m_topoGraph.setClusterUserIndex(j,r,1);let I=0,L=O?Math.trunc((k+1)/2):-1,R=z,ee=!0,te=z;for(;;){if(g){let e=this.m_topoGraph.getSegmentParentage(_),t=this.m_topoGraph.getHalfEdgeOrigin(_);h.setSegmentParentageAndBreak(P,e,ee||this.m_topoGraph.isBreakNode(t))}ee=!1,this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,y),h.setSegmentToIndex(h.getVertexIndex(P),y.get().clone())),R!==z&&o!==-1&&h.addToUserIndex(R,o,-1);let e=f?this.m_topoGraph.getHalfEdgeNext(_):this.tryMoveThroughCrossroadForward(_,!1),n=this.m_topoGraph.getHalfEdgeTo(_),s;if(s=a===-1?this.chooseVertexFromCluster_(n,i):this.chooseVertexByOrder(n,h,a,o),N=h.addVertex(A,s),te=n,r!==-1&&this.m_topoGraph.setClusterUserIndex(n,r,1),g&&this.m_topoGraph.isBreakNode(n)&&h.setSegmentParentageBreakVertex(N,!0),R=s,I++,O&&I===L&&(A=h.insertPath(t,z),N=h.addVertex(A,s),ee=!0,o!==-1&&h.addToUserIndex(s,o,-1),R=z),_===S)break;_=e,P=N}te!==z&&this.m_topoGraph.isStrongPathNode(te)&&h.setStrongPathEnd(A,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,n,r){l(t===z||e===z);let a=this.m_topoGraph.getShape(),o=t=>(t=e===z?t===z?a.getFirstGeometry():a.getNextGeometry(t):t===z?e:z,t),s=a.createGeometry(i.enumPolyline),c=-1;n&&(c=this.m_topoGraph.createUserIndexForClusters());let u=this.m_topoGraph.createUserIndexForHalfEdges(),d=t===z?a.createUserIndex():-1,f=t===z?a.createUserIndex():-1,p=-1;if(r.unsplitBehavior===1){p=this.m_topoGraph.createUserIndexForClusters();for(let e=o(z);e!==z;e=o(e))for(let t=a.getFirstPath(e);t!==z;t=a.getNextPath(t)){{let e=a.getFirstVertex(t),n=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(n,p,1)}if(!a.isClosedPath(t)){let e=a.getLastVertex(t),n=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(n,p,1)}}}if(t===z){let e=0;for(let t=o(z);t!==z;t=o(t))for(let n=a.getFirstPath(t);n!==z;n=a.getNextPath(n))if(a.isClosedPath(n)){let t=a.getFirstVertex(n);for(let r=0,i=a.getPathSize(n);r<i;r++,t=a.getNextVertex(t))a.setUserIndex(t,d,e++),a.setUserIndex(t,f,2)}else{let t=a.getFirstVertex(n);a.setUserIndex(t,d,e++),a.setUserIndex(t,f,1);let r=a.getNextVertex(t);for(let t=1,i=a.getPathSize(n)-1;t<i;++t)a.setUserIndex(r,d,e++),a.setUserIndex(r,f,2),r=a.getNextVertex(r);a.setUserIndex(r,d,e++),a.setUserIndex(r,f,1)}}for(let e=o(z);e!==z;e=o(e))for(let n=a.getFirstPath(e);n!==z;n=a.getNextPath(n)){let e=a.getFirstVertex(n);for(let i=0,o=a.getPathSize(n);i<o;i++,e=a.getNextVertex(e)){let n=this.m_topoGraph.getHalfEdgeFromVertex(e);if(n===z||this.m_topoGraph.getHalfEdgeUserIndex(n,u)===1)continue;let a=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(a)){let e=i===0;this.restorePolylineParts(n,s,u,c,t,d,f,p,e,r)}}}let m=z;if(n){m=a.createGeometry(i.enumMultiPoint);let e=z;for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n))if(this.progress_(),this.m_topoGraph.getClusterUserIndex(n,c)!==1){let r=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(r)){e===z&&(e=a.insertPath(m,z));let r=this.m_topoGraph.getClusterVertexIterator(n);if(r!==z){this.m_topoGraph.getVertexFromVertexIterator(r);let i;i=d===-1?this.chooseVertexFromCluster_(n,t):this.chooseVertexByOrder(n,a,d,f),a.addVertex(e,i)}}}}return f!==-1&&a.removeUserIndex(f),d!==-1&&a.removeUserIndex(d),c!==-1&&a.removeUserIndex(c),this.m_topoGraph.deleteUserIndexForHalfEdges(u),yt(s,m)}difference(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=u(n),a=u(r);if(i>a)return e;let s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s]=!0,i===2&&a===2){let n=z;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(n=e),this.topoOperationPolygonPolygon_(e,t,n)}if(i===1&&a===2){let t=Ps();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}if(i===1&&a===1){let t=Ps();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}if(i===0)return this.topoOperationMultiPoint_();o(``)}symmetricDifference(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=Ms(n),a=Ms(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);if(l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s]=!0,this.m_maskLookup[s]=!0,this.m_maskLookup[c]=!0,i===2&&a===2)return this.topoOperationPolygonPolygon_(e,t,z);if(i===1&&a===1)return this.topoOperationPolyline_(z,this.m_bOGCOutput);if(i===0&&a===0)return this.topoOperationMultiPoint();o(``)}planarSimplifyNoCrackingAndCluster(e,t,n,r){this.m_bOGCOutput=e,this.m_topoGraph=new sr;let a=t.getFillRule(n),s=t.getGeometryType(n);if(a!==1||s===i.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let c=this.m_topoGraph.getGeometryID(n);if(l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0,t.getGeometryType(n)===i.enumPolygon||a===1&&t.getGeometryType(n)!==i.enumMultiPoint){t.setFillRule(n,0);let i=this.topoOperationPolygonPolygon_(n,z,z);if(t.swapGeometry(i,n),t.removeGeometry(i),a===1&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,n,r)}else if(t.getGeometryType(n)===i.enumPolyline){let e=Ps();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=r;let i=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(i,n),t.removeGeometry(i)}else if(t.getGeometryType(n)===i.enumMultiPoint){let e=this.topoOperationMultiPoint_();t.swapGeometry(e,n),t.removeGeometry(e)}else o(``);return!0}unsplitPolylineExact(e){return l(0),new E}planarSimplifyPolylines(e,t,n,r,a){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let n=e.getGeometryType(t);l(n===i.enumPolyline)}let o=0,s=0,c=null;if(e.hasCurves()&&!e.hasSegmentParentage()){c=new _s;let n=e.getEnvelope2D(this.m_progressTracker);s=hs(t.total());let r=ms(t.total(),n);o=gs(r,s),ss(e,r,t.total(),12e3,c,null,this.m_progressTracker)}{let n=ws(t.add(o));e.filterClosePoints(n,!1,!1,!1,z)}if(this.m_topoGraph=new sr,a!==4&&a!==5){if(c===null&&n){let r=new Pr(this.m_progressTracker,!1);r.sweepVertical(e,t.total()),r.hadComplications()?(ys(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ys(e,t.add(o),this.m_progressTracker,!0,!1),n=!1}else n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();let u=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,u,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n&&c===null),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,r,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let d=this.m_topoGraph.getGeometryID(u);l(d>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=d+1,this.m_maskLookup[d]=!0;let f=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),r);c!==null&&c.stitchCurves(e,f,s,!0);let p=e.getGeometry(f);return n||p.getImpl().setIsSimple(4,t.total()),p}planarSimplifyMultiPoints(e,t,n,r){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let n=e.getGeometryType(t);l(n===i.enumMultiPoint)}this.m_topoGraph=new sr,r!==4&&r!==5&&ys(e,t,this.m_progressTracker,!0,!1),n=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();let a=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,a,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let o=this.m_topoGraph.getGeometryID(a);l(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0;let s=this.topoOperationMultiPoint(),c=e.getGeometry(s);return n||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyPolygons(e,t,n,r,a,o){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let r=e.getGeometryType(t);l(r===i.enumPolygon||r===i.enumPolyline&&n)}let s=0,c=0,u=null;if(e.hasCurves()&&!e.hasSegmentParentage()){u=new _s;let n=e.getEnvelope2D(this.m_progressTracker);c=hs(t.total());let r=ms(t.total(),n);s=gs(r,c),ss(e,r,t.total(),12e3,u,null,this.m_progressTracker)}if(o){ys(e,t.add(s),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,!1,z,this.m_progressTracker)}if(this.m_topoGraph=new sr,!o&&a!==4&&a!==5){if(u===null&&r){let n=new Pr(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(ys(e,t,this.m_progressTracker,!0,!1),r=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ys(e,t.add(s),this.m_progressTracker,!0,!1),r=!1}else r=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();let d=e.getFirstGeometry();if(n?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,d,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,d,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(r&&u===null),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,n,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let f=this.m_topoGraph.getGeometryID(d);l(f>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=f+1,this.m_maskLookup[f]=!0,e.setFillRule(d,0);let p=this.m_bOGCOutput&&n,m=p,h=this.topoOperationPolygonPolygon_(d,z,z,m);p&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(d),this.m_topoGraph=new sr,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,h,this.m_progressTracker),h=this.topoOperationPolygonPolygon_(h,z,z,!1)),u!==null&&u.stitchCurves(e,h,c,!0);let g=e.getGeometry(h);return g.setFillRule(0),r?g.getImpl().setIsSimple(3,0):(g.getImpl().setIsSimple(4,t.total()),g.getImpl().updateOGCFlagsProtected()),g}planarSimplify3DImpl_(e,t,n,r,i){return l(0),{}}planarSimplifyImpl_(e,t,n,r,a,s,c,l){if(e.isEmpty())return e.clone();let u=e.getGeometryType(),d=new N,f=d.addGeometry(e);if(We(a)&&u===i.enumPolygon&&(n=!1,d.setFillRule(f,0)),l&&(e.hasAttribute(1)&&d.replaceNaNs(1,0),d.removeNaNVertices()),u===i.enumPolygon||u===i.enumPolyline&&n)return this.planarSimplifyPolygons(d,t,n,r,a,!1);if(u===E.type){let e=Ps();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=c,this.planarSimplifyPolylines(d,t,r,e,a)}if(u===i.enumMultiPoint)return this.planarSimplifyMultiPoints(d,t,r,a);o(`what else?`)}}function Zs(e,t,n,r){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return r?e.createInstance():new B({copy:e});let i=[new U],a=[0],s=t.getDimension()===2;return t.getDimension()!==1&&t.getDimension()!==2&&o(``),i[0]=e.getXY(),s?Yo(t,i,1,n.total(),a):Xo(t,i,1,n.total(),a),a[0]===0?e.createInstance():e}function Qs(e,t,n,r){let i=e.createInstance(),a=bt(U,100),s=Array(100),c=e.getPointCount(),l=!0,u=t.getDimension()===2;t.getDimension()!==1&&t.getDimension()!==2&&o(``);for(let r=0;r<c;){let o=e.queryCoordinates(a,a.length,r,-1)-r;u?Yo(t,a,o,n.total(),s):Xo(t,a,o,n.total(),s);let c=0;for(let t=0;t<o;t++)s[t]===0&&(l&&(l=!1,i.addPoints(e,0,r)),c!==t&&i.addPoints(e,r+c,r+t),c=t+1);!l&&c!==o&&i.addPoints(e,r+c,r+o),r+=o}return l?e:i}function $s(e,t,n,r){let a=e.getGeometryType();if(a===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(a===i.enumPoint&&(r===`|`||r===`^`)){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(a===i.enumLine){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(a===i.enumMultiPoint&&r===`-`&&t.getGeometryType()===i.enumPoint){let t=new B({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(a===i.enumMultiPoint&&r===`&`&&t.getGeometryType()===i.enumPoint){let t=new B({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function ec(e){let t=e.getGeometryType();if(t===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(js(t)){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n(`Unexpected geometry type`),e}function tc(e,t,n,r){let i=n===z?e.getClusterHalfEdge(t):n,a=i;l(e.getHalfEdgeOrigin(i)===t);do r(a),a=e.getHalfEdgeNext(e.getHalfEdgeTwin(a));while(a!==i)}class nc{m_rParent;m_rTopoGraph;m_rShape;m_rCutHandles;m_IDCuttee;m_IDCutter;m_IDBoth;m_sideIndex;m_cutteeBreadcrumbsIndex;m_clusterParentageIndex;m_cuttee;m_cutter;m_bConsiderTouch;constructor(e,t,n,r,i,a){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(r),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(i),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=n,this.m_cuttee=r,this.m_cutter=i,this.m_rCutHandles=a,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let t=0,n=this.m_rShape.getPathSize(e);for(let r=this.m_rShape.getFirstVertex(e);t<n;t++,r=this.m_rShape.getNextVertex(r))this.m_rShape.setUserIndex(r,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(r)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return e|8}classifyStandardCut(e,t,n,r){let i=this.m_rShape.getPrevVertex(e),a=this.m_rShape.getNextVertex(e),o=i===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),s=a===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(a)),c=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n)),l=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),u=1,d=32,f=32;if(tc(this.m_rTopoGraph,t,l,e=>{e===c&&(u=2),e===o&&(d=u),e===s&&(f=u)}),this.m_bConsiderTouch)d!==32&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|d),f!==32&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|f);else{if(d===32||f===32||d===f&&o!==c&&o!==l&&s!==c&&s!==l)return 1;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|d),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|f)}return 0}classifyTouchCut(e,t,n,r){let i=this.m_rShape.getPrevVertex(e),a=this.m_rShape.getNextVertex(e),o=i===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),s=a===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(a)),c=n===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n)),l=r===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r));if(!this.m_bConsiderTouch){let t;return(t=c===o||l===o)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=c===s||l===s)&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),+!t}if(o===z)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===z)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;if(o===s)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(l!==z){if(o===l)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===l)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let n=1;tc(this.m_rTopoGraph,t,l,t=>{if(t===o){let e=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,e),n=2}else if(t===s){let t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),n=2}})}else{if(o===c)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===c)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let n=2;tc(this.m_rTopoGraph,t,c,t=>{if(t===o){let e=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,e),n=1}else if(t===s){let t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),n=1}})}return 0}classifyCutVertex(e,t){let n=0,r=0;for(let i=this.m_rTopoGraph.getClusterVertexIterator(t);i!==z;i=this.m_rTopoGraph.incrementVertexIterator(i)){let a=this.m_rTopoGraph.getVertexFromVertexIterator(i);if(this.m_rShape.getGeometryFromVertex(a)===this.m_cutter){r++;let i=this.m_rShape.getPrevVertex(a),o=this.m_rShape.getNextVertex(a);n+=i===z||o===z?this.classifyTouchCut(e,t,i,o):this.classifyStandardCut(e,t,i,o)}}r&&n===r&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let t=this.m_rShape.getPathSize(e),n=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,n=this.m_rShape.getNextVertex(n))this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,0);n=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,n=this.m_rShape.getNextVertex(n)){let e=this.m_rTopoGraph.getClusterFromVertex(n);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(n,e)}}let e=(e,t)=>{let n=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex),r=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(r)&this.m_IDBoth)===this.m_IDBoth&&(n|=4),n};for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==z;t=this.m_rShape.getNextPath(t)){let n=this.m_rShape.getFirstVertex(t),r=this.m_rShape.isClosedPath(t),i=this.m_rShape.getPathSize(t)+ +!!r,a=1,o=32;for(let t=this.m_rShape.getNextVertex(n);a<i;++a,n=t,t=this.m_rShape.getNextVertex(t)){let r=e(n,t);this.m_rShape.getUserIndex(n,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=r),o!==32&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,o|r)}n=this.m_rShape.getLastVertex(t);let s=32;a=1;for(let t=this.m_rShape.getPrevVertex(n);a<i;++a,n=t,t=this.m_rShape.getPrevVertex(t)){let r=e(t,n);this.m_rShape.getUserIndex(n,this.m_clusterParentageIndex)===this.m_IDBoth&&(s=r),s!==32&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,s|r)}}let t=z,n=z,r=32,a=this.m_rShape.hasSegmentParentage(),o=new F;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let s=this.m_rShape.isClosedPath(e),c=this.m_rShape.getPathSize(e)+ +!!s,l=1,u=this.m_rShape.getFirstVertex(e),d=z,f=!0;for(let e=this.m_rShape.getNextVertex(u);l<c;++l,e=this.m_rShape.getNextVertex(e)){let s=this.m_rShape.getUserIndex(u,this.m_cutteeBreadcrumbsIndex);s===8?s=3:(s&=-9,s&4?s=4:(s&3)==3&&(s=3)),s===r?this.m_rShape.getUserIndex(u,this.m_clusterParentageIndex)===this.m_IDBoth&&s!==4&&(d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),n=this.m_rShape.insertPath(t,z),f=!0):(t!==z&&(d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,r)),t=this.m_rShape.createGeometry(i.enumPolyline),n=this.m_rShape.insertPath(t,z),r=s,f=!0),d=this.m_rShape.addVertex(n,u);let c=this.m_rTopoGraph.getClusterFromVertex(u);!f&&a&&this.m_rTopoGraph.isBreakNode(c)&&this.m_rShape.setSegmentParentageBreakVertex(d,!0);let l=this.m_rTopoGraph.getHalfEdgeFromVertex(u);if(a){let e=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(d,e,f||this.m_rTopoGraph.isBreakNode(c))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,o),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(d),o.get().clone())),u=e,f=!1}d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,r),t=z,n=z,r=32}}}function rc(e,t,n){return new Xs(n).linesToPolygonsImpl(e,t)}function ic(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=new T;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),oc(a,t,n,r,s)}let u=e.getImpl().getIsSimple(l,[0]),d=n?-1:u;if(De(d)||d===0)return d;let f=new bc(e,t,d,s,!1);return c===i.enumMultiPoint||c===i.enumPolyline||c===i.enumPolygon?d=f.isSimplePlanarImpl():o(``),e.getImpl().setIsSimple(d,l),r&&r.assign(f.m_nonSimpleResult),d}function ac(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=new T;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),ac(a,t,n,r,s)}d(c),f(c)||p(`OGC simplify is not implemented for this geometry type`);let u=e.getImpl().getIsSimple(l,[0]),m=n?-1:u;if(m===5||m===0)return m;let h=new bc(e,t,m,s,!0);return c===i.enumMultiPoint||c===i.enumPolyline||c===i.enumPolygon?(m=h.isSimplePlanarImpl(),De(m)&&(m=5)):o(``),e.getImpl().setIsSimple(m,l),r&&r.assign(h.m_nonSimpleResult),m}function oc(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=T.constructEmpty();return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),oc(a,t,n,r,s)}let u=e.getImpl().getIsSimple(l,[0]),d=n?-1:u;if(d!==-1)return d;let f=new bc(e,t,d,s,!1);return c===i.enumMultiPoint?d=f.multipointIsSimpleAsFeature():c===i.enumPolyline?d=f.polylineIsSimpleAsFeature():c===i.enumPolygon?d=f.polygonIsSimpleAsFeature():o(``),e.getImpl().setIsSimple(d,l),r&&r.assign(f.m_nonSimpleResult),d}function sc(e,t,n,r){if(e.isEmpty())return e;let s=e.getGeometryType();if(s===i.enumPoint){let t=new J;if(lc(e,t),t.m_reason===3){let t=e.clone();return t.replaceNaNs(1,0),t}return t.m_reason===2?e.createInstance():e}if(s===i.enumEnvelope){let n=Te(t,e,!0).total(),r=e,i=T.constructEmpty();return r.queryEnvelope(i),i.isDegenerate(n)?r.createInstance():e}if(a(s)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),sc(a,t,n,r)}d(s);let c=Te(t,e,!1).total(),l=e.getImpl().getIsSimple(c,[0]),u=n?-1:l;if(De(u)){if(s===i.enumPolygon&&e.getFillRule()!==0){let t=e.clone();return t.setFillRule(0),t}return e}if((s===i.enumMultiPoint||s===i.enumPolyline)&&u>=1)return e;let f=new bc(e,t,u,r,!1),p;return s===i.enumMultiPoint?p=f.multipointSimplifyAsFeature():s===i.enumPolyline?p=f.polylineSimplifyAsFeature():s===i.enumPolygon?p=f.polygonSimplifyAsFeature():o(``),p}function cc(e,t,n,r){if(e.isEmpty())return e;let o=e.getGeometryType();if(o===i.enumPoint){let t=new J;if(lc(e,t),t.m_reason===3){let t=e.clone();return t.replaceNaNs(1,0),t}return t.m_reason===2?e.createInstance():e}if(o===i.enumEnvelope){let n=e,r=new T;n.queryEnvelope(r);let i=Te(t,e,!0).total();return r.isDegenerate(i)?n.createInstance():e}if(a(o)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),cc(a,t,n,r)}d(o),f(o)||p(`OGC simplify is not implemented for this geometry type`);let s=Te(t,e,!1).total(),c=e.getImpl().getIsSimple(s,[0]),l=n?-1:c;if(l===5){if(o===i.enumPolygon&&e.getFillRule()!==0){let t=e.clone();return t.setFillRule(0),t}return e}return Is(e,Te(t,e,!0),!1,l,r,0,!0)}function lc(e,t){let n=e.getX(),r=e.getY();if(!Number.isFinite(n)||!Number.isFinite(r))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){let n=e.getZ();if(!Number.isFinite(n))return t&&(t.m_reason=Number.isNaN(n)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class uc{m_segment=null;m_vertexIndex=-1;m_pathIndex=-1;m_flags=0;setReversed(e){this.m_flags&=-2,this.m_flags|=+!!e}getReversed(){return!!(this.m_flags&1)}getRightSide(){return+!this.getReversed()}}function dc(){return{x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1}}function fc(e,t,n,r,i){return{x:e,y:t,ipath:n,ivertex:r,ipolygon:i}}function pc(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function mc(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function hc(){return{x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1}}function gc(e,t,n,r,i,a){return{x:e,y:t,ipath:n,ivertex:r,bBoundary:i,bEndPoint:a}}function _c(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.bBoundary=t.bBoundary,e.bEndPoint=t.bEndPoint}class vc extends tt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*r);return i<0?-1:+(i>0)}}class yc extends tt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_edges[t],a=this.m_helper.m_edges[r],o=i.getReversed(),s=a.getReversed(),c=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),l=a.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(c===l){let e=o?i.m_segment.getStartY():i.m_segment.getEndY(),t=s?a.m_segment.getStartY():a.m_segment.getEndY(),n=Math.min(e,t),r=(n-this.m_helper.m_yScanline)*.5+this.m_helper.m_yScanline;r===this.m_helper.m_yScanline&&(r=n),c=i.m_segment.intersectionOfYMonotonicWithAxisX(r,0),l=a.m_segment.intersectionOfYMonotonicWithAxisX(r,0)}return c<l?-1:+(c>l)}}class bc{m_description;m_geometry;m_multiVertexGeom=null;m_sr;m_toleranceIsSimpleClustering;m_toleranceIsSimpleCracking;m_toleranceIsSimple;m_toleranceSimplify;m_knownSimpleResult;m_attributeCount;m_edges=[];m_freeEdges=[];m_lineEdgesRecycle=[];m_newEdges=[];m_recycledSegIter=null;m_crossOverHelperList=new Fe;m_progressTracker=null;m_progressCounter=0;m_AET=new Ie;m_xyToNode1=null;m_xyToNode2=null;m_pathOrientations=null;m_pathParentage=null;m_unknownOrientationPathCount;m_yScanline;m_xy=null;m_pairs=[];m_pairIndices=null;m_pathsForOGCTests=[];m_curveStitcher=null;m_editShape=null;m_multiPathStitcher=null;m_bOGCRestrictions;m_bPlanarSimplify;m_nonSimpleResult=new J;constructor(e,t,n,r,i){this.m_progressCounter=0,this.m_progressTracker=r,this.m_geometry=e,this.m_knownSimpleResult=n,this.m_sr=t;let a=Te(t,e,!1);this.m_toleranceIsSimple=a,this.m_toleranceIsSimpleClustering=Pe(a),this.m_toleranceIsSimpleCracking=Le(a),this.m_toleranceSimplify=Te(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=i,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;let e=this.m_geometry.getGeometryType();return s(e)&&!this.checkDegenerateSegments(!1)||!this._CheckClustering()?0:s(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5}isSimplePlanarImpl3D(){return l(0),7}generateSortedPairs(e){let t=null;s(e.getGeometryType())&&(t=e);let n=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&t!==null,r=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new Re(0),n&&(this.m_pathsForOGCTests.length=0);let i=0;for(let e=0;e<r;e++)if(this.m_pairs.push(2*e),this.m_pairs.push(2*e+1),this.m_pairIndices.add(2*e),this.m_pairIndices.add(2*e+1),n){for(;e>=t.getPathEnd(i);)i++;this.m_pathsForOGCTests.push(i)}let a=new ze,o={parent:this,workPt:new U,userSort(e,t,r){r.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,n))},getValue(e){let t=this.parent.m_pairs[e],n=t>>1;return this.parent.m_xy.queryPoint2D(2*n,this.workPt),this.workPt.y+(t&1?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};a.sort(this.m_pairIndices,0,2*r,o)}_TestToleranceDistancePlanar(e,t){let n=this.m_xy.read(2*e),r=this.m_xy.read(2*e+1),i=this.m_xy.read(2*t),a=this.m_xy.read(2*t+1);return!pr(n,r,i,a,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||this.m_geometry.getDimension()!==0&&n===i&&r===a}checkStructure(){let e=this.m_geometry.getGeometryType();if(s(e)){let e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.enumPolygon?3:2;for(let n=0,r=e.getPathCount();n<r;n++)if(e.getPathSize(n)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(n)&&e.getPathSize(n)>0)continue;return this.m_nonSimpleResult=new J(1,n,0),!1}}if(f(e)){let e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let n=0,r=e.getPointCount();n<r;n++)if(!t.readPoint2D(n*2).isFinite())return this.m_nonSimpleResult=new J(2,n,0),!1;if(this.m_geometry.hasAttribute(1)){let t=e.getAttributeStreamRef(1);for(let n=0,r=e.getPointCount();n<r;n++){let e=t.read(n);if(!Number.isFinite(e))return this.m_nonSimpleResult=Number.isNaN(e)?new J(3,n,0):new J(2,n,0),!1}}}return!0}checkDegenerateSegments(e){let t=this.m_geometry.getImpl(),n=t.querySegmentIterator(),r=t.hasAttribute(1),i=r?Be(this.m_sr,t,!1).total():0,a=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;n.nextPath();)for(;n.hasNextSegment();){let t=n.nextSegment(),s=t.calculateLowerLength2D();if(!(s>o)&&!(a&&t.isCurve()&&(s=t.calculateLength2D(),s>o))){if(e&&r){let e=t.getStartAttributeAsDbl(1,0),n=t.getEndAttributeAsDbl(1,0);if(Math.abs(n-e)>i)continue}return this.m_nonSimpleResult=new J(4,n.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return l(0),!1}_CheckClustering(){let e=this.m_geometry.getImpl();this.generateSortedPairs(e);let t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new vc(this)),this.m_AET.setCapacity(t);for(let e=0,n=t*2;e<n;e++){this.progress_();let t=this.m_pairIndices.read(e),n=this.m_pairs[t],r=n>>1;if(n&1){let e=this.m_AET.search(r),t=this.m_AET.getPrev(e),n=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==Ie.st_nullNode()&&n!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(n)))return this.m_nonSimpleResult=new J(5,this.m_AET.getElement(t),this.m_AET.getElement(n)),!1}else{let e=this.m_AET.addElement(r),t=this.m_AET.getPrev(e);if(t!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),r))return this.m_nonSimpleResult=new J(5,r,this.m_AET.getElement(t)),!1;let n=this.m_AET.getNext(e);if(n!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(n),r))return this.m_nonSimpleResult=new J(5,r,this.m_AET.getElement(n)),!1}}return!0}_CheckCracking(){let e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new N,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new _s;let e=T.constructEmpty();this.m_geometry.queryEnvelope(e);let t=ms(this.m_toleranceSimplify.total(),e),n=new J;if(us(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,n,this.m_curveStitcher,null,this.m_progressTracker),n.m_reason!==0)return this.m_editShape=null,this.m_nonSimpleResult.assign(n),!1}let e=new J;return Br(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(this.m_curveStitcher==null?(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)):(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(this.m_curveStitcher??(this.m_editShape=null),!0)}_CheckCrackingBrute(){let e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),n=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){let e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){n.resetTo(t);do for(;n.hasNextSegment();){let r=n.nextSegment(),i=L(!0,e,r,this.m_toleranceIsSimpleCracking,!0);if(i){let e=i===2?7:6;return this.m_nonSimpleResult=new J(e,t.getStartPointIndex(),n.getStartPointIndex()),!1}}while(n.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();this.m_curveStitcher!==null&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);let t=[],n=e.getPointCount(),r=NaN,i=0;for(let e=0,a=n*2;e<a;e++){this.progress_();let n=this.m_pairIndices.read(e),a=this.m_pairs[n];if(a&1)continue;let o=a>>1,s=this.m_xy.read(2*o),c=this.m_xy.read(2*o+1);if(t.length&&(s!==r||c!==i)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),r=s,i=c}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){let e=this.m_geometry.getImpl(),t=[];for(let n=0,r=e.getPathCount();n<r;n++)t.push(e.isClosedPathInXYPlane(n));let n=hc(),r,i,a;{let o=this.m_pairIndices.read(0),s=this.m_pairs[o]>>1,c=this.m_xy.readPoint2D(2*s),l=this.m_pathsForOGCTests[s];r=t[l],i=e.getPathStart(l),a=e.getPathEnd(l)-1,n.bEndPoint=s===i||s===a,n.bBoundary=this.m_bOGCRestrictions?!r&&n.bEndPoint:n.bEndPoint,n.ipath=l,n.x=c.x,n.y=c.y,n.ivertex=s}for(let o=1,s=this.m_pairIndices.size();o<s;o++){let s=this.m_pairIndices.read(o),c=this.m_pairs[s];if(c&1)continue;let l=c>>1,u=this.m_xy.readPoint2D(2*l),d=this.m_pathsForOGCTests[l];d!==n.ipath&&(r=t[d],i=e.getPathStart(d),a=e.getPathEnd(d)-1);let f,p=l===i||l===a;f=this.m_bOGCRestrictions?!r&&p:p;let m=gc(u.x,u.y,d,l,f,p);if(m.x===n.x&&m.y===n.y){if(this.m_bOGCRestrictions){if((!m.bBoundary||!n.bBoundary)&&(m.ipath!==n.ipath||!m.bEndPoint||!n.bEndPoint))return this.m_nonSimpleResult=new J(10,m.ivertex,n.ivertex),!1}else if(!m.bEndPoint||!n.bEndPoint)return this.m_nonSimpleResult=new J(7,m.ivertex,n.ivertex),!1}_c(n,m)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return l(0),!1}checkSelfIntersectionsPolygonsOGC(){let e=this.m_geometry.getImpl(),t=[],n=-1,r=!1;for(let i=0,a=e.getPathCount();i<a;i++)e.isExteriorRingOGC(i)&&(r=!1,n++,i<a-1&&(e.isExteriorRingOGC(i+1)||(r=!0))),t.push(r?n:-1);let i=dc();{let e=this.m_pairIndices.read(0),n=this.m_pairs[e]>>1,r=this.m_xy.readPoint2D(2*n),a=this.m_pathsForOGCTests[n];i.ipath=a,i.x=r.x,i.y=r.y,i.ivertex=n,i.ipolygon=t[a]}let a=[];for(let e=1,n=this.m_pairIndices.size();e<n;e++){let n=this.m_pairIndices.read(e),r=this.m_pairs[n];if(r&1)continue;let o=r>>1,s=this.m_xy.readPoint2D(2*o),c=this.m_pathsForOGCTests[o],l=fc(s.x,s.y,c,o,t[c]);if(l.x===i.x&&l.y===i.y){if(l.ipath===i.ipath)return this.m_nonSimpleResult=new J(11,l.ivertex,i.ivertex),!1;t[l.ipath]>=0&&t[l.ipath]===t[i.ipath]&&((a.length===0||!pc(a.at(-1),i))&&a.push({...i}),a.push(l))}mc(i,l)}if(a.length===0)return!0;let o=new Fe(!0);t.fill(-1);let s=-1,c=new U;for(let e=0,n=a.length;e<n;e++){let n=a[e];(n.x!==c.x||n.y!==c.y)&&(s=o.createList(0),c.x=n.x,c.y=n.y);let r=t[n.ipath];r===-1&&(r=o.createList(2),t[n.ipath]=r),o.addElement(r,s),o.addElement(s,r)}let l=[];for(let e=o.getFirstList();e!==-1;e=o.getNextList(e)){let n=o.getListData(e);if(n&1||!(n&2))continue;let r=-1;for(l.push(e),l.push(-1);l.length;){let e=l.at(-1);l.pop();let t=l.at(-1);l.pop();let n=o.getListData(t);if(n&1){r=n&2?t:e;break}o.setListData(t,n|1);for(let n=o.getFirst(t);n!==-1;n=o.getNext(n)){let r=o.getData(n);r!==e&&(l.push(r),l.push(t))}}if(r!==-1){let e=t.indexOf(r);return this.m_nonSimpleResult=new J(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){let e=this.m_multiPathStitcher===null?this.m_geometry.getImpl():this.m_multiPathStitcher.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new J(8,e.getPathCount()===1?1:-1,-1),0;if(e.getPathCount()===1)return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new Ve(e.getPathCount(),0),this.m_pathParentage=new Re(e.getPathCount(),-1);let t=-1,n=0;for(let r=0,i=e.getPathCount();r<i;r++){let i=e.calculateRingArea2D(r);if(this.m_pathOrientations.write(r,i<0?0:8),i>0)t=r,n=i;else if(i===0)return this.m_nonSimpleResult=new J(8,r,-1),0;else{if((t<0||n<Math.abs(i))&&(this.m_nonSimpleResult=new J(9,r,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(r,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;let r=e.getPointCount();this.m_yScanline=NaN;let i=[];this.m_xyToNode1=new Re(r,Ie.st_nullNode()),this.m_xyToNode2=new Re(r,Ie.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new yc(this));for(let e=0,t=r*2;this.m_unknownOrientationPathCount>0&&e<t;e++){let t=this.m_pairIndices.read(e),n=this.m_pairs[t];if(n&1)continue;let r=n>>1,a=this.m_xy.read(2*r+1);if(a!==this.m_yScanline&&i.length){if(!this.processBunchForRingOrientationTest(i))return 0;i.length=0}i.push(r),this.m_yScanline=a}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(i)?0:this.m_bOGCRestrictions?this.m_nonSimpleResult.m_reason!==0||!this.checkSelfIntersectionsPolygonsOGC()?0:5:this.m_nonSimpleResult.m_reason===0?4:3}processBunchForSelfIntersectionTest(e){if(e.length===1)return!0;for(let t=0,n=e.length;t<n;t++){let n=e[t];this.m_recycledSegIter.resetToVertex(n,-1);let r=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(r,n,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();let i=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(i,n,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();t===-1&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let e=0,n=this.m_edges.length;e<n;e++)this.m_crossOverHelperList.addElement(t,e);let n=!0,r=-1,i=-1;for(;n;){n=!1;let e=this.m_crossOverHelperList.getFirst(t);if(e===-1)break;let a=this.m_crossOverHelperList.getNext(e);for(;a!==-1;){let o=this.m_crossOverHelperList.getData(e),s=this.m_crossOverHelperList.getData(a);if(r=this.m_edges[o].m_vertexIndex,i=this.m_edges[s].m_vertexIndex,r===i){if(n=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(a),a=this.m_crossOverHelperList.deleteElement(t,a),a===-1||e===-1)break;continue}e=a,a=this.m_crossOverHelperList.getNext(e)}}let a=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),a>0)return this.m_nonSimpleResult=new J(7,r,i),!1;for(let t=0,n=e.length;t<n;t++)this.recycleEdge(this.m_edges[t]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_xyToNode1.read(n);if(r!==Ie.st_nullNode()){let e=this.m_AET.getElement(r);this.m_freeEdges.push(e),this.m_AET.deleteNode(r),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(n,Ie.st_nullNode())}if(r=this.m_xyToNode2.read(n),r!==Ie.st_nullNode()){let e=this.m_AET.getElement(r);this.m_freeEdges.push(e),this.m_AET.deleteNode(r),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(n,Ie.st_nullNode())}}for(let t=0,n=e.length;t<n;t++){let n=e[t];this.m_recycledSegIter.resetToVertex(n,-1);let r=this.m_recycledSegIter.previousSegment();if(r.getStartY()>r.getEndY()){let e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(r,n,this.m_recycledSegIter.getPathIndex(),!0),i;this.m_freeEdges.length>0?(i=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[i]=t):(i=this.m_edges.length,this.m_edges.push(t));let a=this.m_AET.addElement(i);this.m_xyToNode1.read(e)===Ie.st_nullNode()?this.m_xyToNode1.write(e,a):this.m_xyToNode2.write(e,a),this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())&3||this.m_newEdges.push(a)}this.m_recycledSegIter.nextSegment();let i=this.m_recycledSegIter.nextSegment();if(i.getStartY()<i.getEndY()){let e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(i,n,this.m_recycledSegIter.getPathIndex(),!1),r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));let a=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===Ie.st_nullNode()?this.m_xyToNode1.write(e,a):this.m_xyToNode2.write(e,a),this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())&3||this.m_newEdges.push(a)}}for(let e=0,t=this.m_newEdges.length;e<t&&this.m_unknownOrientationPathCount>0;e++){let t=this.m_newEdges[e],n=this.m_AET.getElement(t),r=this.m_edges[n].m_pathIndex;if(!(this.m_pathOrientations.read(r)&3)){let e=-1,n=this.m_AET.getPrev(t),r=t,i=0;{let t=-1,a=null,o=-1,s=0;for(;n!==Ie.st_nullNode()&&(t=this.m_AET.getElement(n),a=this.m_edges[t],o=a.m_pathIndex,s=this.m_pathOrientations.read(o),!(s&3));)r=n,n=this.m_AET.getPrev(n);n===Ie.st_nullNode()?(i=1,n=r):(e=(s&3)==1?o:this.m_pathParentage.read(o),i=+!a.getRightSide(),n=this.m_AET.getNext(n))}do{let t=this.m_AET.getElement(n),a=this.m_edges[t],o=a.m_pathIndex,s=this.m_pathOrientations.read(o);if(!(s&3)){if(i!==a.getRightSide())return this.m_nonSimpleResult=new J(8,o,-1),!1;let t=i&&!a.getReversed()?1:2;if(s=s&-4|t,this.m_pathOrientations.write(o,s),t===2&&this.m_nonSimpleResult.m_reason===0){let t=this.m_pathParentage.read(o);if(t!==e&&(this.m_nonSimpleResult=new J(9,o,t),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}e=(s&3)==1?o:this.m_pathParentage.read(o),r=n,n=this.m_AET.getNext(n),i=+!i}while(r!==t)}}return this.m_newEdges.length=0,!0}createEdge(e,t,n,r){let a;return e.getGeometryType()===i.enumLine?a=this.createEdgeLine(e):(a=new uc,a.m_segment=e.clone()),a.m_vertexIndex=t,a.m_pathIndex=n,a.m_flags=0,a.setReversed(r),a}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new uc,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,n,r){let i=e.calculateLowerLength2D();if(i<=n){let a=!0;if(e.isCurve()&&(i=e.calculateLength2D(),a=i<=n),a){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let n=e.getStartAttributeAsDbl(1,0);return Number.isNaN(n)&&(n=0),Math.abs(n-t)<=r}return!0}return!1}return!1}static isShortSegmentPoints(e,t,n,r,i){if(n){let n=e.getXYZ(),a=t.getXYZ();return He(n,a,r,i)}{let n=e.getXY(),i=t.getXY();return U.sqrDistance(n,i)<=r*r}}removeDegenerateSegmentsFromCurvedPath(e,t,n,r){let i=e.hasAttribute(1),a=e.querySegmentIterator();a.resetToPath(t),l(a.nextPath());let o=this.m_toleranceSimplify.total(),s=!1,c=!0,u=new B,d=new B,f=new U;for(;a.hasNextSegment();){this.progress_();let e=a.nextSegment();if(bc.isShortSegment(e,i,o,n)){if(s){if(e.queryEnd(d),bc.isShortSegmentPoints(u,d,i,o,n))continue;c&&=(r.startPathPoint(u),!1),e.queryEnd(u),r.lineToPoint(u),s=!1}else f.assign(e.getStartXY()),e.queryStart(u),s=!0;continue}if(!s)r.addSegment(e,c),c=!1;else if(e.isCurve()){let t=e.clone();if(t.setCoordsForIntersector(f,e.getEndXY(),!1),t.setStart(u),!bc.isShortSegment(t,i,o,n))r.addSegment(t,c),c=!1,s=!1;else continue}else if(e.queryEnd(d),!bc.isShortSegmentPoints(u,d,i,o,n))c&&=(r.startPathPoint(u),!1),r.lineToPoint(d),s=!1;else continue}if(c||!s)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),u):e.getPointByVal(e.getPathEnd(t)-1,u);let p=r.querySegmentIterator();p.resetToLastPath(),p.resetToLastSegment();let m=r.getDescription().getAttributeCount()>1;for(l(p.previousPath());p.hasPreviousSegment();){let e=p.previousSegment();if(e.isCurve()){let t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),u.getXY(),!1),!bc.isShortSegment(t,i,o,n)){m&&t.setEnd(u);let e=p.getEndPointIndex();for(let t=r.getPointCount()-1;t>=e;t--)r.removePoint(t);r.addSegment(t,!1);return}}else if(e.queryStart(d),!bc.isShortSegmentPoints(d,u,i,o,n)){let e=p.getEndPointIndex();for(let t=r.getPointCount()-1;t>=e;t--)r.removePoint(t);r.lineToPoint(u);return}}r.removePath(r.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;let e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;let t=e.getPointCount(),n=H(t,0);for(let e=0;e<t;e++)n[e]=e;n.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let e=1;e<t;e++)if(this.compareVerticesMultiPoint(n[e-1],n[e])===0)return this.m_nonSimpleResult=new J(5,n[e-1],n[e]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()?+!!this.checkDegenerateSegments(!0):0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl(),t=bc.hasNanZs(e),n=this.m_geometry,r;t&&(r=this.m_geometry.clone(),e=r.getImpl(),r.replaceNaNs(1,Ue.getDefaultValue(1)),n=r),this.m_multiVertexGeom=e;let i=e.getPointCount(),a=H(i,0);for(let e=0;e<i;e++)a[e]=e;a.sort((e,t)=>this.compareVerticesMultiPoint(e,t));let o=Array(i);o.fill(!1);let s=-1;for(let t=0;t<i;t++){let n=a[t];e.getXY(n).isFinite()&&((s<0||this.compareVerticesMultiPoint(s,n)!==0)&&(o[n]=!0),s=n)}let c=this.m_geometry.createInstance(),l=0,u=0;for(let e=0;e<i;e++)o[e]?u=e+1:(l<u&&c.addPoints(n,l,u),l=e+1);return l<u&&c.addPoints(n,l,u),c.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),c}polylineSimplifyAsFeature(){let e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),n=e.querySegmentIterator(),r=this.m_geometry.createInstance(),i=this.m_geometry,a=e.hasAttribute(1),o=a?Be(this.m_sr,e,!0).total():0,s=[],c=[],l=null;a&&(l=e.getAttributeStreamRef(1));let u=new B,d=e.hasNonLinearSegments(),f=this.m_toleranceSimplify.total();for(;t.nextPath();){if(n.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(d&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,r);continue}n.resetToLastSegment();let p=0,m=0,h=!0,g=!0;for(;t.hasNextSegment();){this.progress_();let r=t.nextSegment(),i=n.previousSegment();if(t.getStartPointIndex()>n.getStartPointIndex())break;if(h){let n=t.getStartPointIndex();e.getXY(n).isNAN()||(h=!1,s.push(n))}if(g){let t=n.getEndPointIndex();e.getXY(t).isNAN()||(c.push(t),g=!1)}if(!h){let n=s.at(-1),i=t.getEndPointIndex();if(i-n>1){let t=new U;t.setSub(e.getXY(n),e.getXY(i)),p=t.length()}else p=r.calculateLength2D();if(p>f)s.push(i),p=0;else if(a){let e=l.read(n);Number.isNaN(e)&&(e=0);let t=l.read(i);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(s.push(i),p=0)}}if(!g){let t=c.at(-1),r=n.getStartPointIndex();if(r-t>1){let n=new U;n.setSub(e.getXY(t),e.getXY(r)),m=n.length()}else m=i.calculateLength2D();if(m>f)c.push(r),m=0;else if(a){let e=l.read(t);Number.isNaN(e)&&(e=0);let n=l.read(r);Number.isNaN(n)&&(n=0),Math.abs(n-e)>o&&(c.push(r),m=0)}}}if(s.length>0&&c.length>0&&(s.at(-1)<c.at(-1)?s.length>c.length?s.pop():c.pop():(s.at(-1)===c.at(-1)||c.pop(),c.pop())),c.length+s.length>=2){let e=!1;for(let t=0,n=s.length;t<n;t++)i.getPointByVal(s[t],u),e?r.lineToPoint(u):(r.startPathPoint(u),e=!0);for(let t=c.length-1;t>0;t--)i.getPointByVal(c[t],u),e?r.lineToPoint(u):(r.startPathPoint(u),e=!0);i.isClosedPath(t.getPathIndex())?r.closePathWithLine():c.length>0&&(i.getPointByVal(c[0],u),r.lineToPoint(u))}s.length=0,c.length=0}return a&&r.replaceNaNs(1,0),r.getImpl().setIsSimple(1,f),r}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(this.m_geometry.getFillRule()===1&&!We(this.m_knownSimpleResult))return Ls(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);let e=new N;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),e.getTotalPointCount()!==0){let t=null,n=0,r=0;if(e.hasCurves()){t=new _s;let i=T.constructEmpty();this.m_geometry.queryEnvelope(i);let a=ms(this.m_toleranceSimplify.total(),i);n=hs(this.m_toleranceSimplify.total()),r=gs(a,n),ss(e,a,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}We(this.m_knownSimpleResult)||ys(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1),this.m_geometry.getGeometryType()===i.enumPolygon&&ri(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),t!==null&&t.stitchCurves(e,e.getFirstGeometry(),n,!0)}let t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===i.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){let t=e.getAttributeStreamRef(1);for(let n=0,r=e.getPointCount();n<r;n++){let e=t.read(n);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,n){if(e===t)return 0;let r=this.m_pairs[e],i=this.m_pairs[t],a=r>>1,o=i>>1,s=this.m_xy.readPoint2D(2*a);s.y+=r&1?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;let c=this.m_xy.readPoint2D(2*o);c.y+=i&1?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;let l=s.compare(c);if(l===0&&n){let e=this.m_pathsForOGCTests[a]-this.m_pathsForOGCTests[o];return _t(e)}return l}compareVerticesMultiPoint(e,t){if(e===t)return 0;let n=this.m_multiVertexGeom.getXY(e),r=this.m_multiVertexGeom.getXY(t),i=!n.isFinite(),a=!r.isFinite();if(i||a)return i<a?-1:+(i>a);if(n.y<r.y)return-1;if(n.y>r.y)return 1;if(n.x<r.x)return-1;if(n.x>r.x)return 1;for(let n=1;n<this.m_attributeCount;n++){let r=this.m_description.getSemantics(n),i=Ue.getComponentCount(r);for(let n=0;n<i;n++){let i=this.m_multiVertexGeom.getAttributeAsDbl(r,e,n),a=this.m_multiVertexGeom.getAttributeAsDbl(r,t,n),o=xt(i,a);if(o!==0)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;let n=e.m_segment.getTangent(+!!e.getReversed());e.getReversed()&&n.negateThis();let r=t.m_segment.getTangent(+!!t.getReversed());t.getReversed()&&r.negateThis();let i=n.getQuarter(),a=r.getQuarter();if(a===i){let e=n.crossProduct(r);return e<0?1:e>0?-1:0}return i<a?-1:1}}class xc{getOperatorType(){return 10103}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,n,r,i){let a=oc(e,t,n,r,i);return Ee(e.getGeometryType(),a)}isSimplePlanarDONOTUSE(e,t,n,r,i){let a=ic(e,t,n,r,i);return De(a)}executeMany(e,t,n,r){return new Sc(e,t,n,r)}execute(e,t,n,r){let i=new sn([e]),a=this.executeMany(i,t,n,r).next();return a||o(`null geometry`),a}}class Sc extends on{m_inputGeometryCursor;m_spatialReference;m_progressTracker;m_index;m_bForceSimplify;constructor(e,t,n,r){super(),this.m_progressTracker=r,this.m_bForceSimplify=n,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){let e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||n(``),e.getGeometryType()===i.enumGeometryCollection){let t=j(e,-1),n=new xc().executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),r=e.createInstance();for(let e=n.next();e!=null;e=n.next())r.addGeometry(e);return r}return sc(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Cc(e,t,n){let r=new T;e.queryEnvelope(r);let a=new T;t.queryEnvelope(a);let o=new T(a);if(o.inflate(2*n),!o.isIntersecting(r))return 4;let s=e.getGeometryType(),c=t.getGeometryType();do{if(s===i.enumEnvelope&&r.containsEnvelope(o))return 1;if(c===i.enumEnvelope){let e=new T(r);if(e.inflate(2*n),a.containsEnvelope(e))return 2}}while(0);return 0}class wc{m_intersectorGeom=null;m_sr=null;m_dimensionMask=-1;m_progressTracker=null;m_intersectorGeomType=i.enumUnknown;m_geomIntersectorEmptyGeom=null;constructor(e,t,n,r){this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=n,this.m_progressTracker=r,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){let t=this.tryFastImplementation(e);if(t!==null)return t;let n=Ae(this.m_intersectorGeom,e),r=je(this.m_sr,n,!0).total(),i=T.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);let a=T.constructEmpty();e.queryEnvelope(a),i.inflateCoords(2*r,2*r),i.intersect(a),i.inflateCoords(100*r,100*r);let o=q(this.m_intersectorGeom,i,0,0,this.m_progressTracker),s=q(e,i,0,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(o=gt(s,s=o)),Ks(s,o,this.m_sr,this.m_progressTracker)}intersectEx(e){let t=this.tryFastImplementation(e);if(t!==null){let n=[];return n.length=3,n[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,n)}let n=Ae(this.m_intersectorGeom,e),r=je(this.m_sr,n,!0).total(),i=T.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);let a=T.constructEmpty();e.queryEnvelope(a),i.inflateCoords(2*r,2*r),i.intersect(a),i.inflateCoords(100*r,100*r);let o=q(this.m_intersectorGeom,i,0,0,this.m_progressTracker),s=q(e,i,0,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(o=gt(s,s=o));let c=qs(s,o,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,c)}init(e,t,n,r=null){l(0)}static intersectPoints(e,t,n){let r=Ae(e,t);return Gs(e,t,je(n,r,!0))}tryFastImplementation(e){let t=e.getGeometryType();if(this.m_intersectorGeomType===i.enumPoint&&t===i.enumPoint){let t=wc.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(this.m_dimensionMask!==-1){let e=new A({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.enumEnvelope&&this.m_intersectorGeomType===i.enumEnvelope&&(this.m_dimensionMask===-1||this.m_dimensionMask===4)){let t=e,n=this.m_intersectorGeom,r=new Me({copy:t});return r.intersect(n),r}let n=Ae(e,this.m_intersectorGeom),r=je(this.m_sr,n,!0),a=e.isEmpty(),s=this.m_intersectorGeom.isEmpty(),c=a||s;if(!c){let t=Cc(this.m_intersectorGeom,e,r.total());if(t===4)c=!0;else if(t&2)return this.m_intersectorGeom;else if(t&1)return e}if(c){let n=u(t),r=u(this.m_intersectorGeomType);return n<r?wc.ReturnEmpty(e,a):n>r||n===0&&t===i.enumMultiPoint&&this.m_intersectorGeomType===i.enumPoint?this.ReturnEmptyIntersector():wc.ReturnEmpty(e,a)}if(t===i.enumEnvelope&&u(this.m_intersectorGeomType)===0||this.m_intersectorGeomType===i.enumEnvelope&&u(t)===0){let n=t===i.enumEnvelope?e:this.m_intersectorGeom,a=t===i.enumEnvelope?this.m_intersectorGeom:e,o=T.constructEmpty();return n.queryEnvelope(o),q(a,o,r.total(),0,this.m_progressTracker)}if(u(t)===0&&u(this.m_intersectorGeomType)>0||u(t)>0&&u(this.m_intersectorGeomType)===0){if(t===i.enumMultiPoint)return Vs(e,this.m_intersectorGeom,r);if(t===i.enumPoint)return Ws(e,this.m_intersectorGeom,r);if(this.m_intersectorGeomType===i.enumMultiPoint)return Vs(this.m_intersectorGeom,e,r);if(this.m_intersectorGeomType===i.enumPoint)return Ws(this.m_intersectorGeom,e,r);o(``)}return null}ReturnEmptyIntersector(){return this.m_geomIntersectorEmptyGeom===null&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,n){let r=0;return t&1?(n[0]||=new A({vd:e}),r++):n.shift(),t&2?(n[r]||(n[r]=new E({vd:e})),r++):n.splice(r,1),t&4?n[r]||(n[r]=new k({vd:e})):n.splice(r,1),new sn(n)}}class Tc extends on{m_inputGeoms;m_smallCursor=null;m_progressTracker;m_geomIntersector;m_index;m_dimensionMask;m_intersector;constructor(e,t,r,i,a){super(),this.m_progressTracker=i,this.m_geomIntersector=t.next(),this.m_intersector=new wc(this.m_geomIntersector,r,a,i),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=a,this.m_dimensionMask!==-1&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&n(`bad dimension mask`)}next(){if(!this.m_geomIntersector)return null;let e;if(this.m_smallCursor!==null){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();)return r(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dimensionMask===-1?this.m_intersector.intersect(e):(this.m_smallCursor=this.m_intersector.intersectEx(e),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Ec{getOperatorType(){return 1e4}accelerateGeometry(e,t,n){if(!this.canAccelerateGeometry(e))return!1;Te(t,e,!0);let r=0;return(e.getGeometryType()===i.enumPolygon||e.getGeometryType()===i.enumPolyline)&&D(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeAccelerator(n)),!!r}canAccelerateGeometry(e){return D(e)}supportsCurves(){return!0}executeMany(e,t,n,r,i=-1){return new Tc(e,t,n,r,i)}execute(e,t,n,r){if(e.getGeometryType()===i.enumPoint&&t.getGeometryType()===i.enumPoint)return wc.intersectPoints(e,t,n);let a=new sn([e]),s=new sn([t]),c=this.executeMany(a,s,n,r,-1).next();return c||o(`null output`),c}}function Dc(e,t,n){return t.m_projector.project(e,n)}function Oc(e,t,n,r,i){e.m_projector.transformInPlaceZ(t,null,n,r,null,i);let a=r.slice(0,n).filter(e=>!e.isNAN());for(let e=0,t=a.length;e<t;++e)r[e].assign(a[e]);return a.length}function kc(e,t,n,r,i){return e.m_projector.transformInPlaceZ(t,null,n,r,null,i)}function Ac(e,t,r,o){if((!e||!t||!t.isPannable())&&n(`fold_into_360_range_geodetic`),e.isEmpty())return e;if(r===4)return jc(e,t,o);let c=e,l=c.getGeometryType();if(s(l)){c=Fu(e,t);let n=new T;c.queryEnvelope(n);let i=je(t,n,!1).total(),a=t.getPannableExtent(),o=Math.floor((n.xmin-a.xmin)/a.width())*a.width()+a.xmin,s=c;for(;o<n.xmax;)o>n.xmin+i&&o<n.xmax-i&&(s=Nu(s,t,r,!0,o)),o+=a.width();c=s}else{if(l===i.enumEnvelope){let e=new k({vd:c.getDescription()});return e.addEnvelope(c,!1),Ac(e,t,r,o)}if(a(l)){let e=new E({vd:c.getDescription()});return e.addSegment(c,!0),Ac(e,t,r,o)}}return jc(c,t,o)}function jc(e,t,r){if((!e||!t||!t.isPannable())&&n(``),e.isEmpty())return e;let o,s=e.getGeometryType();if(s===i.enumEnvelope){let t=new k({vd:e.getDescription()});t.addEnvelope(e,!1),o=t}else if(a(s)){let t=new E({vd:e.getDescription()});t.addSegment(e,!0),o=t}else o=e;let c=Fu(o,t);return c.isEmpty()?c:Eu(c,t,0,c!==e,0,r)}function Mc(e,t,n){if(!t.isPannable()||e.isEmpty())return e;let r=t.getPannableExtent().width(),i=r*.5,a=e.queryInterval(0,0);if(a.width()<i||!f(e.getGeometryType())){if(Number.isNaN(n))return e;let t=a.getCenter();if(Math.abs(t-n)<=i)return e;{let i=new K,a=n-t,o=ht(a/r)*r;i.setShiftCoords(o,0);let s=e.clone();return s.applyTransformation(i),s}}let o=e.getGeometryType(),c=e,l=c.getAttributeStreamRef(0),u=e.clone(),d=u.getAttributeStreamRef(0),p=0,m=0,h=0,g=s(o)?0:-1,_=W.constructEmpty(),v=!1;for(let e=0,t=c.getPointCount();e<t;e++){let t=l.read(e*2);e===m&&(s(o)?(g===0&&Number.isNaN(n)&&(v=!0),g>0&&Number.isNaN(n)&&(n=_.getCenter(),v=!1),m=c.getPathEnd(g),g++):m=c.getPointCount(),Number.isNaN(n)?h=t:(h=n,p=0));let a=t-h;Math.abs(a)>i&&(a=ht(a/r)*r,p-=a,Math.abs(p)<.1*r&&(p=0));let u=t+p;d.write(e*2,u),v&&_.mergeCoordinate(u),h=t}return u.notifyModified(),u}function Nc(e,t,n,r){let i=t.getCoordinateSystemType();if(i===0){let r=new ip;return t.queryPrecisionDescriptor(r),Pc(e,r,t,n)}let a=e;(r===2||r===3)&&t.isPannable()&&(a=jc(a,t,n));let s=new ip;if(t.queryPrecisionDescriptor(s),a=Pc(a,s,t,n),r===0||a.isEmpty())return a;if(i===1){if(r===1){let e=new T;a.queryLooseEnvelope(e);let r=t.getPannableExtent(),i=.01*r.width();return r.xmin=e.xmin-i,r.xmax=e.xmax+i,new nn().execute(a,r,t,n)}return a}if(i===2){let e=t.getPCSHorizon();if(r===1||r===2){let r=new Ec().execute(a,e,t,n);return r===e?r.clone():r}return a}if(i===3)return a;o(`missing implementation`)}function Pc(e,t,n,r){let i=t.getXYGridRange(),a=e.hasAttribute(1),o=e.hasAttribute(2),s=new W,c=new W;a&&(s=t.getZGridRange()),o&&(c=t.getMGridRange());let l=new nn().execute(e,i,n,r);if(a){let t=l.queryInterval(1,0);s.contains(t)||(e===l&&(l=l.clone()),ot(l,s,1,0))}if(o){let t=l.queryInterval(2,0);c.contains(t)||(e===l&&(l=l.clone()),ot(l,c,2,0))}return l}class Fc{m_projTransform;m_inputPCSHorizonClipOption=0;m_outputPCSHorizonClipOption=0;m_bDontGeonormalizePolygon=!1;m_bClipOutCurvedPoles=!1;m_bNormalizeOutputGeometry=!1;m_bDontHackPolesInGeogToGeog=!1;m_centralMeridianOfOutputGCS=0;m_densificationStepInput=0;constructor(e){e||n(``),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;let t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.densificationStep;let r=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=r.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=r.hasFlag(1073741824),this.m_bClipOutCurvedPoles=r.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;let n=e.getGeometryType();if(n===i.enumPoint)return this.projectPoint(e,t);let r=this.m_projTransform.getInputSR().getCoordinateSystemType(),a=this.m_projTransform.getOutputSR().getCoordinateSystemType(),s=this.m_projTransform.getInputSR(),c=this.m_projTransform.getOutputSR();if(r===0&&r===a){let t=Lc(s,c),n=e.clone();return n.applyTransformation(t),n}switch(n){case i.enumPolyline:case i.enumPolygon:return this.projectMultiPath(e,t);case i.enumMultiPoint:return this.projectMultiPoint(e,t);case i.enumEnvelope:return this.projectEnvelope(e,t);case i.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:o(``)}}projectPoint(e,t){let n=[e.getXY()],r=null,i;(i=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(n,r,1,n,r,null);let a=e.clone();return a.setXY(n[0]),i&&a.setZ(r[0]),a}projectMultiPoint(e,t){let n=new A({copy:e}),r=this.m_projTransform.getInputSR(),i=this.m_projTransform.getOutputSR(),a=r.getCoordinateSystemType(),o=i.getCoordinateSystemType();if(a===3&&l(0),n=Uu(n,r,this.m_inputPCSHorizonClipOption,t),n.isEmpty())return n;a===2&&Qu(r,0,n),ud(this.m_projTransform,n,!1);let s=0;o===3&&l(0);let c=o===2;return c?s=i.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS),(!c||this.m_outputPCSHorizonClipOption===0)&&(n=Eu(n,Yf(i),s,!1,0,t)),c&&(n=xu(n,i,this.m_outputPCSHorizonClipOption,t),Yu(i,n,this.m_bNormalizeOutputGeometry),n.isEmpty()),n}projectMultiPath(e,t){let n=e.getGeometryType();if(n===i.enumPolygon)return this.projectPolygon(e,t);if(n===i.enumPolyline)return this.projectPolyline(e,t);o(`project_multi_path_`)}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();let n=this.m_projTransform.isVertical()&&e.hasAttribute(1),r=W.constructEmpty();if(n&&(r=e.queryInterval(1,0)),r.width()>0){let n=e.clone();n.setInterval(1,0,r.vmin,r.vmin);let i=this.projectEnvelopeHelper(n,t);n.setInterval(1,0,r.vmax,r.vmax);let a=this.projectEnvelopeHelper(n,t);return i.merge(a),i}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){l(e.getGeometryType()===i.enumPolygon),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());let n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),o=r.getCoordinateSystemType(),s=new k({copy:e});a===3&&l(0),o===3&&l(0);let c=a===2,u=o===2,d=c?n.getGCS():n,f=u?r.getGCS():r,p=!u&&!this.m_bDontHackPolesInGeogToGeog,m=!1,h=Uu(s,n,this.m_inputPCSHorizonClipOption,t);if(h.isEmpty())return h;let g=this.m_densificationStepInput,_=!Number.isNaN(g);_&&(h=new an().execute(h,g,0,0,t));let v,y=u?r.getPCSInfo():null,b=NaN;c&&(b=n.getCentralMeridian());let x=r.getGCSSplitLines()!==null;if(this.m_bDontGeonormalizePolygon){let e=h;if(c&&(sd(n,b,e),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,e,p),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}v=e}else{let e=new E({vd:h.getDescription()});if(e.addAndExplicitlyOpenAllPaths(h,!1),c){if(sd(n,b,e),_){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(this.m_bClipOutCurvedPoles){let r=n.getPCSInfo(),i=r.getSouthPoleGeometry()===Ep.PE_POLE_LINE_CURVED,a=r.getNorthPoleGeometry()===Ep.PE_POLE_LINE_CURVED;if(i||a){let n=T.constructEmpty();e.queryLooseEnvelope(n),n.inflateCoords(1,1);let r=89.9999*d.getOneDegreeGCSUnit();i&&(n.ymin=-r),a&&(n.ymax=r),e=rn(e,n,d,0,0,t)}}}if(fd(this.m_projTransform,e,p),_){let e=Yf(n).getUnitsPerMillimeter(),t=Yf(r).getUnitsPerMillimeter();g*=t/e}let i=NaN;u?(y=r.getPCSInfo(),i=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=Ic(n)|Ic(r),o=f.getTolerance(0)*10;this.m_bDontHackPolesInGeogToGeog&&(a=3,o=f.getTolerance(0)*10),v=ju(h,n,e,f,i,t,a,o,this.m_bNormalizeOutputGeometry),a=0}if(x&&(l(!r.isPannable()),v=fu(v,r,t)),u){if(!m){let e=f.getPannableExtent().width();if(v.queryInterval(0,0).width()>=e-f.getTolerance(0)*10){let e=y.getNorthPoleLocation(),t=y.getSouthPoleLocation(),n=y.getNorthPoleGeometry(),r=y.getSouthPoleGeometry(),i=0;n===Ep.PE_POLE_POINT&&e!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(i=1),r===Ep.PE_POLE_POINT&&t!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(i|=2),m||=i!==0}}v=xu(v,r,this.m_outputPCSHorizonClipOption,t),_&&(v=new an().execute(v,g,0,0,t)),Zu(r,v,this.m_bNormalizeOutputGeometry)}return v.isEmpty()||m&&(v=new xc().execute(v,r,!1,t)),v}projectPolyline(e,t){l(e.getGeometryType()===i.enumPolyline),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());let n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),o=r.getCoordinateSystemType(),s=new E({copy:e});a===3&&l(0),o===3&&l(0);let c=a===2,u=o===2;c&&n.getGCS();let d=u?r.getGCS():r,f=!u&&!this.m_bDontHackPolesInGeogToGeog,p=Uu(s,n,this.m_inputPCSHorizonClipOption,t);if(p.isEmpty())return p;let m=NaN;c&&(m=n.getCentralMeridian());let h=r.getGCSSplitLines()!==null,g=this.m_densificationStepInput,_=!Number.isNaN(g);_&&(p=new an().execute(p,g,0,0,t));let v;if(this.m_bDontGeonormalizePolygon){if(c&&(sd(n,m,p),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,p,f),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}v=p}else{let e=new E({vd:p.getDescription()});if(e.addAndExplicitlyOpenAllPaths(p,!1),c&&(sd(n,m,e),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,e,f),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}let i=NaN;u?i=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=Ic(n)|Ic(r),o=d.getTolerance(0)*10;this.m_bDontHackPolesInGeogToGeog&&(a=3,o=0),v=Mu(p,n,e,d,i,t,a,o,this.m_bNormalizeOutputGeometry),a=0}return h&&(l(!r.isPannable()),v=fu(v,r,t)),u&&(v=xu(v,r,this.m_outputPCSHorizonClipOption,t),_&&(v=new an().execute(v,g,0,0,t)),Zu(r,v,this.m_bNormalizeOutputGeometry)),v.isEmpty(),v}projectGeometryCollection(e,t){return l(0),{}}projectEnvelopeHelper(e,t){let n=(e.height()+e.width())/400;if(n!==0){let r=new an().execute(e,n,0,0,t),i=this.projectMultiPath(r,t),a=new Me({vd:e.getDescription()});if(i.isEmpty()){let n=Math.min(e.height(),e.width()),i=Te(this.m_projTransform.getInputSR(),e,!0).total();if(n>100*i){let e=T.constructEmpty(),t=je(this.m_projTransform.getOutputSR(),e,!0).total(),r=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(n>100*Math.max(i,t*r))return a}let o=new E;o.addAndExplicitlyOpenAllPaths(r,!1),this.projectMultiPath(o,t).queryEnvelope(a);let s=new A({vd:e.getDescription()});s.reserve(4);let c=new B;for(let t=0;t<4;t++)e.queryCornerByVal(t,c),s.add(c);let l=this.projectMultiPoint(s,t),u=new Me;return l.queryEnvelope(u),a.merge(u),a}return i.queryEnvelope(a),a}{let n=e.getCenterXY(),r=new B(n),i=this.projectPoint(r,t),a=new Me({vd:e.getDescription()});if(i.isEmpty())a.setEmpty();else{e.copyTo(a);let t=i.getXY();a.setCoords(t.x,t.y,t.x,t.y)}return a}}transformInPlace(e,t,n,r){return l(0),0}transformInPlaceZ(e,t,n,r,i,a){if(this.m_projTransform.isIdentity())return e!==r&&ft(r,e,n),t!==i&&zt(i,t,0,0,n),n;let o=this.m_projTransform,s=o.getInputSR(),c=o.getOutputSR(),u=s.getCoordinateSystemType(),d=c.getCoordinateSystemType();if(u===0&&u===d)return Lc(s,c).transformPoints2D(e,n,r),o.isVertical()&&l(0),n;u===3&&p(`image: transform_in_place_`),d===3&&p(`image: transform_in_place_`),Wu(e,n,r,s,this.m_inputPCSHorizonClipOption),i!==t&&zt(i,t,0,0,n),u===2&&cd(s,0,r,n),gd(this.m_projTransform,r,i,n,!1);let f=0,m=d===2;m?f=c.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(f=this.m_centralMeridianOfOutputGCS),(!m||this.m_outputPCSHorizonClipOption===0)&&Du(r,n,c.getGCS(),f),m&&(Tu(r,n,c,this.m_outputPCSHorizonClipOption),Ku(c,r,n,!1));let h=n;for(let e=0;e<n;++e)r[e].isNAN()&&(i&&(i[e]=NaN),h--);return h}}function Ic(e){if(e.getCoordinateSystemType()!==2)return 0;let t=0,n=e.getPCSInfo(),r=n.getNorthPoleLocation(),i=n.getSouthPoleLocation(),a=n.getNorthPoleGeometry(),o=n.getSouthPoleGeometry();return a===Ep.PE_POLE_POINT&&r!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===Ep.PE_POLE_POINT&&i!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function Lc(e,t){let n=e.getHorzUnitFactor(),r=t.getHorzUnitFactor(),i=1,a=1,o=20015077/180;e.getUnit().getUnitType()===1&&(i=o),t.getUnit().getUnitType()===1&&(a=o);let s=i===a?1:i/a,c=n/r*s,l=new K;return l.setScaleCoords(c,c),l}class Rc{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n){return!t||t.isIdentity()?e:new zc(e,t,n)}execute(e,t,n){return t.isIdentity()?e:Dc(e,t,n)}transform(e,t,n,r,i=!0){return i?Oc(e,t,n,r,null):kc(e,t,n,r,null)}transform3D(e,t,n,r,i=!0){return l(0),0}foldInto360Range(e,t){return jc(e,t,null)}foldInto360RangeGeodetic(e,t,n){return Ac(e,t,n,null)}normalizeGeometryEx(e,t,n,r,i=0){return Ol(e,t,n,r,i)}normalizeGeometry(e,t,n){return Mc(e,t,n)}clipToSpatialReference(e,t,n,r=0){return Nc(e,t,n,r)}}class zc extends on{m_inputGeoms;m_projTrans;m_index;m_progressTracker;constructor(e,t,r){super(),this.m_projTrans=t,this.m_progressTracker=r,this.m_index=-1,e||n(``),this.m_inputGeoms=e}next(){let e=this.m_inputGeoms.next();return e==null?null:(S(e),r(e),this.m_index=this.m_inputGeoms.getGeometryID(),Dc(e,this.m_projTrans,this.m_progressTracker))}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Bc(e,t,o,c,u,d,f=!1){e||n(`Geometry.Geodetic_densify.densify`);let p=e.getGeometryType();if(r(e),e.isEmpty()||b(p))return e;let m=new Kc;m.m_sr=t,m.m_gcs=t.getGCS(),m.m_transform=m.m_gcs===t?null:t.getSRToGCSTransform(),m.m_progressTracker=d;let h=Pf();m.m_gcs.querySpheroidData(h),m.m_a=h.majorSemiAxis,m.m_eSquared=h.e2,m.m_rpu=m.m_gcs.getUnit().getUnitToBaseFactor(),m.m_gcsTolerance=m.m_gcs.getTolerance(0),m.m_radTolerance=m.m_gcsTolerance*m.m_rpu,m.m_maxLength=c,m.m_maxDeviation=u,m.m_curveType=o;let g,_,v;if(p===i.enumEnvelope){let t=new k({vd:e.getDescription()});t.addEnvelope(e,!1),g=t,p=i.enumPolygon}else if(a(p)){let t=new E({vd:e.getDescription()});t.addSegment(e,!0),g=t,p=i.enumPolyline}else g=e;if(m.m_curveType!==4){if(l(s(p)),_=m.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(g),_.isEmpty())return _;_=Vc(m.m_rpu,_);let e=m.geodeticDensify(_);f||(e=new Rc().foldInto360RangeGeodetic(e,m.m_gcs,m.m_curveType)),v=m.m_transform&&!m.m_transform.isIdentity()?new Rc().execute(e,m.m_transform.getInverse(),d):e}else{l(s(p));let e;if(t.isPannable())e=Fu(g,t);else{let n=t.getPCSHorizon();e=new Ec().execute(g,n,t,d),e===n&&(e=n.clone())}if(_=e,_.isEmpty())return _;v=m.shapePreservingDensify(_)}return v}function Vc(e,t){let n=new T;if(t.queryLooseEnvelope(n),n.width()*e<Math.PI)return t;let r=!1,i=t.querySegmentIterator(),a=new U,o=new U;for(;i.nextPath();)for(;i.hasNextSegment();){let t=i.nextSegment();if(a.setCoordsPoint2D(t.getStartXY()),o.setCoordsPoint2D(t.getEndXY()),a.scale(e),o.scale(e),Math.abs(a.x-o.x)>Math.PI){if(!Uc(a,o)){r=!0;break}if(Math.abs(a.x-o.x)>Math.PI*2){r=!0;break}}}if(!r)return t;let s=t.createInstance();s.reserve(t.getPointCount());let c=t.getDescription().getAttributeCount()>1,l=new U,u=new U,d=new U(0,0),f=new U(0,0),p=new B;for(i.resetToFirstPath();i.nextPath();){let t=NaN,n=0;for(;i.hasNextSegment();){let r=i.nextSegment();if(a.setCoordsPoint2D(r.getStartXY()),o.setCoordsPoint2D(r.getEndXY()),a.scale(e),o.scale(e),Number.isNaN(t)?(n=il(a.x,NaN,n),d.setCoordsPoint2D(a)):d.setCoordsPoint2D(f),t=d.x,!Uc(a,o))l.setCoordsPoint2D(o),ul(l),n=il(l.x,t,n),f.setCoords(n+l.x,l.y);else{if(o.x-a.x>Math.PI*2)for(;o.x-a.x>Math.PI*2;)o.x-=Math.PI*2;else if(o.x-a.x<-Math.PI*2)for(;o.x-a.x<-Math.PI*2;)o.x+=Math.PI*2;n=il(o.x,NaN,n),f.setCoordsPoint2D(o)}if(Math.abs(f.x-o.x)<.5&&f.setCoordsPoint2D(o),c)r.queryCoord(0,p),u.setCoordsPoint2D(d),u.scale(1/e),p.setXY(u),i.isFirstSegmentInPath()?s.startPathPoint(p):s.lineToPoint(p),i.isLastSegmentInPath()&&!i.isPathClosed()&&(r.queryCoord(1,p),u.setCoordsPoint2D(f),u.scale(1/e),p.setXY(u),s.lineToPoint(p));else{i.isFirstSegmentInPath()&&s.insertPath2D(-1,null,0,0,!0);let t=s.getPathCount()-1;u.setCoordsPoint2D(d),u.scale(1/e),s.insertPoint2D(t,-1,u),i.isLastSegmentInPath()&&!i.isPathClosed()&&(u.setCoordsPoint2D(f),u.scale(1/e),s.insertPoint2D(t,-1,u))}}}return s}function Hc(e,t,n,r,i,a,o,s,c,l,u,d){let f=new U,p=new U,m=r.compare(i)>0;nl(m,r,i,f,p);let h=Yc(e,t,n,f,p,a,o,s,c,l,null,u,d);return m&&tl(c,l,null,u),h}function Uc(e,t){return!!(Z(e.y,G)&&Z(t.y,G)||Z(e.y,-G)&&Z(t.y,-G))}function Wc(e,t){return!!(Z(e.y,G)&&!Z(t.y,G)||Z(e.y,-G)&&!Z(t.y,-G))}function Gc(e,t){return!!(Z(t.y,G)&&!Z(e.y,G)||Z(t.y,-G)&&!Z(e.y,-G))}class Kc{m_sr=null;m_gcs=null;m_transform=null;m_progressTracker=null;m_a=0;m_eSquared=0;m_rpu=0;m_gcsTolerance=0;m_radTolerance=0;m_maxLength=0;m_maxDeviation=0;m_curveType=0;geodeticDensify(e){let t=e.createInstance(),n=e.querySegmentIterator(),r=[],i=[],a=new F,o=e.getDescription().getAttributeCount()>1;for(;n.nextPath();){let e=[0];for(;n.hasNextSegment();){let s=n.nextSegment(),c=s.getStartXY(),l=s.getEndXY();c.scale(this.m_rpu),l.scale(this.m_rpu);let u=new U,d=new U,f=c.compare(l)>0;nl(f,c,l,u,d),r.length=0,i.length=0,this.m_maxLength>0?Yc(this.m_a,this.m_eSquared,this.m_curveType,u,d,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,o?i:null,r,e):Xc(),f&&tl(null,null,o?i:null,r),r[0].setCoordsPoint2D(s.getStartXY()),r.at(-1).setCoordsPoint2D(s.getEndXY());let p=1/this.m_rpu;for(let e=1,t=r.length-1;e<t;e++)r[e].scale(p);if(!o)qc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),r,t);else{let e=rl(f,s,a);Jc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),s,e,i,r,t)}}}return t}shapePreservingDensify(e){let t=e.createInstance(),n=e.querySegmentIterator(),r=[],i=[],a=new F,o=e.getDescription().getAttributeCount()>1;for(;n.nextPath();)for(;n.hasNextSegment();){let e=n.nextSegment(),s=e.getStartXY(),c=e.getEndXY(),l=s.compare(c)>0,u=rl(l,e,a);r.length=0,i.length=0,el(this.m_a,this.m_eSquared,this.m_rpu,u,this.m_sr,this.m_maxLength,this.m_maxDeviation,o?i:null,r),l&&tl(null,null,o?i:null,r),o?Jc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),e,u,i,r,t):qc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),r,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){let t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Fu(e,this.m_gcs),!t))return e;let n=e.createInstance();n.reserveParts(e.getPointCount(),e.getPathCount());for(let t=0,r=e.getPathCount();t<r;++t){let r=new A,i=e.getPathStart(t),a=e.getPathEnd(t);r.addPoints(e,i,a);let o=e.isClosedPath(t),s=!1;if(o&&a-i===1&&e.hasNonLinearSegmentsPath(t)){let t=new B;e.getPointByVal(i,t),r.add(t),s=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!s){let t=new B;e.getPointByVal(i,t),r.add(t)}if(r=new Rc().execute(r,this.m_transform,this.m_progressTracker),o&&r.getPointCount()>1){let e=r.getXY(0),t=r.getXY(r.getPointCount()-1);e.equals(t)&&r.removePoint(r.getPointCount()-1)}}r.getPointCount()>1&&(n.addPathMultiPoint(r,0,-1,!0),o&&n.closePathWithLine())}return n}}function qc(e,t,n,r){e&&r.insertPath2D(-1,null,0,0,!0);let i=r.getPathCount()-1;r.insertPointsFromPoints(i,-1,n,0,n.length-1,!0),t&&r.insertPoint2D(i,-1,n.at(-1))}function Jc(e,t,n,r,i,a,o){o.reserve(o.getPointCount()+a.length-1);let s=new B;if(n.queryStart(s),e?o.startPathPoint(s):o.lineToPoint(s),a.length>2){let e=r.calculateLength2D();for(let t=1;t<a.length-1;t++){let n=r.lengthToT(i[t]*e);r.queryCoord(n,s),s.setXY(a[t]),o.lineToPoint(s)}}t&&(n.queryEnd(s),o.lineToPoint(s))}function Yc(n,r,i,a,o,s,c,l,u,d,f,p,m){let h={stack:[],error:void 0,hasError:!1};try{let t=e(h,new Sp,!1),g=e(h,new Sp,!1),_=e(h,new Sp,!1);kp.geodeticDistance(n,r,a.x,a.y,o.x,o.y,_,t,g,i);let v=_.val,y=t.val,b=g.val,x=y,S=b;x<0&&(x+=Math.PI*2),S<0&&(S+=Math.PI*2),u&&(u[0]=x),d&&(d[0]=S);let C=NaN,w=NaN;if(f!==null){let e=Ap.q90(n,r),t=Ap.q(n,r,a.y);C=(e-t)/v,w=(e+t)/v}let T=Wc(a,o),E=Gc(a,o),D=T||E,O=cl(a,o,l),k=e(h,new jt(new Sp,new Sp),!1),A=new U,j=new U,M=new U;m[0]=il(a.x,NaN,m[0]);let N=m[0];if(v<=s)return p.push(a.clone()),m[0]=il(o.x,NaN,m[0]),f?.push(0),D?(T&&al(a,o,f,p),E&&ol(a,o,f,p)):O?sl(a,o,y,C,w,f,p):c>0&&(j.setCoords(a.x-N,a.y),A.setCoords(o.x-m[0],o.y),N=Zc()),p.push(o.clone()),v;let P=1+Math.ceil(v/s),F=v/(P-1),I=new U;p.push(a.clone()),I.setCoordsPoint2D(a),j.setCoords(a.x-m[0],a.y),f!==null&&f.push(0);for(let e=1;e<P;e++){let t;if(e<P-1){let o=e*F;kp.geodeticCoordinate(n,r,a.x,a.y,o,y,k.at(0),k.at(1),i),A.setCoords(k.at(0).val,k.at(1).val),m[0]=il(A.x,I.x,m[0]),M.setCoords(m[0]+A.x,A.y),t=e/(P-1)}else m[0]=il(o.x,NaN,m[0]),A.setCoords(o.x-m[0],o.y),M.setCoordsPoint2D(o),t=1;D?(e===1&&T&&al(a,M,f,p),e===P-1&&E&&ol(I,o,f,p)):O?ll(I,M,l)&&(a.x<o.x?I.x>M.x&&(m[0]+=Math.PI*2,M.setCoords(m[0]+A.x,A.y)):I.x<M.x&&(m[0]-=Math.PI*2,M.setCoords(m[0]+A.x,A.y)),sl(I,M,y,C,w,f,p)):c>0&&Zc(),p.push(M.clone()),f?.push(t),I.setCoordsPoint2D(M),j.setCoordsPoint2D(A),N=m[0]}return v}catch(e){h.error=e,h.hasError=!0}finally{t(h)}}function Xc(e,t,n,r,i,a,o,s,c,u){l(0)}function Zc(e,t,n,r,i,a,o,s,c,u,d,f,p,m,h){return l(0),0}function Qc(e,t,n,r){let i=xn(e,t,n),a=xn(e,t,r);return V.distance(i,a)}function $c(e,t,n,r,i,a,o,s){let c=[],u=bt(Array,8),d=2,f=i.getCoord2D(a);u[0][0]=f.x,u[0][1]=f.y,f=i.getCoord2D(o),u[1][0]=f.x,u[1][1]=f.y;let p=e=>{if(n!==null){let t=wp.projToGeog(n,e,u);l(t===e)}for(let e of u)e[0]*=r,e[1]*=r};p(2),c.push(xn(e,t,new U(u[0][0],u[0][1]))),c.push(xn(e,t,new U(u[1][0],u[1][1])));let m=V.distance(c[0],c[1]);if(m>s)return m;let h=0;for(d=3;d<=17;){let n=1/(d-1),r=0;for(let e=1;e<d;++e)if(e&1){let t=Ct(a,o,e*n);i.queryCoord2D(t,f),u[r][0]=f.x,u[r][1]=f.y,r++}p(r);let g=1;for(let n=0;n<r;++n)c.splice(g,0,xn(e,t,new U(u[n][0],u[n][1]))),g++;g=0;let _=c[g];g++;let v=0;for(;g!==c.length;++g){let e=c[g],t=V.distance(_,e);v+=t,_=e}if(v>s)return v;if(h=v-m,l(h>=0||Math.abs(h)<v*1e-14),h<0&&(h=0),m=v,v+h<=s)return v+h;d=2*d-1}return m+h}function el(e,t,n,r,i,a,o,s,c){let u=r.isCurve(),d=zn(e,t)*Math.PI*179/180,f=a;(!(a>0)||a>d)&&(f=d);let p=o,m=p>0,h=NaN;m&&(h=Kn(e,t,p));let g=i.getCoordinateSystemType()===1,_=null;g||(_=i.getPECoordSys());let v=i.getTolerance(0),y=r.getStartXY(),b=r.getEndXY(),x=new U,S=new U;if(g)x.setCoordsPoint2D(y),x.scale(n),S.setCoordsPoint2D(b),S.scale(n);else{let e=[y.x,y.y,b.x,b.y];wp.projToGeog(_,2,e),x.setCoords(e[0],e[1]),x.scale(n),S.setCoords(e[2],e[3]),S.scale(n)}let C=0,w=0,T=[],E=[],D=[];T.push(b.clone()),E.push(S.clone()),D.push(1),c.push(y.clone()),s!==null&&s.push(w);let O=i.isPannable(),k=y.clone(),A=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333],j=5;u||(m?(A[0]=.5,A[1]=.25,A[2]=.75,j=3):j=1),l(f>0);let M=e=>{if(e=e.clone(),_!==null){let t=[e.x,e.y];wp.projToGeog(_,1,t),e.setCoords(t[0],t[1])}return e.scale(n),e};for(;E.length>0;){let a=T.at(-1).clone();S.assign(E.at(-1));let o=D.at(-1),d=!1,p=NaN,y=$c(e,t,_,n,r,w,o,f),b=f>=y&&Math.abs(x.y-S.y)<Math.PI*.9;g&&b&&(b=Math.abs(x.x-S.x)<Math.PI*.9);let N=new U,P=new U,F=!1;if(!m&&b&&b&&(F=!0),r.calculateSubLength(w,o)<=v&&(F=!0),!F)for(let s=0;s<j;s++){let c=Ct(w,o,A[s]),f=new U;r.queryCoord2D(c,f);let _=M(f);if(s===0&&(p=c,N.setCoordsPoint2D(f),P.setCoordsPoint2D(_),!b)){d=!0;break}if(l(m),g&&Math.abs(x.x-_.x)>=Math.PI){d=!0;break}let v=new U,y=new U;u?(v=U.lerp(k,a,A[s]),y=M(v)):(v=f.clone(),y=_.clone());let C=On(e,t,x,S,A[s]),T=C.clone();if(g?(T.x/=n,T.y/=n):(T.x/=n,T.y/=n,kc(i.getGCSToSRTransform(),[T],1,[T],null)),T.isNAN()){let{second:n}=Nn(e,t,xn(e,t,_),xn(e,t,x),xn(e,t,S),2,null);if(n>h){d=!0;break}}else{if(O){let e=i.getPannableExtent().width(),t=Ct(r.getStartX(),r.getEndX(),.5);for(;T.x<t-e*.5;)T.x+=e;for(;T.x>=t+e*.5;)T.x-=e}let n=r.getClosestCoordinateOnInterval(T,new W(w,o),-1),a=r.getCoord2D(n);a=M(a);let s=Qc(e,t,a,C);if(s>h){if(s<4*h){let{second:n}=Nn(e,t,xn(e,t,a),xn(e,t,x),xn(e,t,S),2,null);s=n}if(s>h){d=!0;break}}else if(u){let n=xn(e,t,_),r=xn(e,t,x),i=xn(e,t,S),{second:a}=Nn(e,t,n,r,i,3,null);if(a<=h){n=xn(e,t,y);let{second:o}=Nn(e,t,n,r,i,3,null);a=o}if(a>h){d=!0;break}}}}d?(T.push(N.clone()),E.push(P.clone()),D.push(p)):(T.pop(),E.pop(),D.pop(),c.push(a.clone()),C+=y,s!==null&&s.push(C),k.setCoordsPoint2D(a),x.setCoordsPoint2D(S),w=o)}if(s!==null){let e=1/C;for(let t=0;t<s.length;t++)s[t]*=e}}function tl(e,t,n,r){if(r.reverse(),n!==null&&n.reverse(),e){let n=e[0];e[0]=t[0],t[0]=n}}function nl(e,t,n,r,i){e?(r.setCoordsPoint2D(n),i.setCoordsPoint2D(t)):(r.setCoordsPoint2D(t),i.setCoordsPoint2D(n))}function rl(e,t,n){return e?(n.create(t.getGeometryType()),t.copyTo(n.get()),n.get().reverse(),n.get()):t}function il(e,t,n){if(Number.isNaN(t)){for(;n-e>Math.PI;)n-=Math.PI*2;for(;e-n>Math.PI;)n+=Math.PI*2;return n}return n+e-t>Math.PI?n-=Math.PI*2:t-(n+e)>Math.PI&&(n+=Math.PI*2),n}function al(e,t,n,r){if(e.y>0){let i=new U;i.setCoords(t.x,G),!Z(e.x,i.x)&&!Z(t.y,i.y)&&(r.push(i),n!==null&&n.push(0))}else{let i=new U;i.setCoords(t.x,-G),!Z(e.x,i.x)&&!Z(t.y,i.y)&&(r.push(i),n!==null&&n.push(0))}}function ol(e,t,n,r){if(t.y>0){let i=new U;i.setCoords(e.x,G),!Z(t.x,i.x)&&!Z(e.y,i.y)&&(r.push(i),n!==null&&n.push(1))}else{let i=new U;i.setCoords(e.x,-G),!Z(t.x,i.x)&&!Z(e.y,i.y)&&(r.push(i),n!==null&&n.push(1))}}function sl(e,t,n,r,i,a,o){if(xp(n)){if(G-e.y>0){let t=new U;t.setCoords(e.x,G),o.push(t),a!==null&&a.push(r)}if(G-t.y>0){let e=new U;e.setCoords(t.x,G),o.push(e),a!==null&&a.push(r)}}else{if(G+e.y>0){let t=new U;t.setCoords(e.x,-G),o.push(t),a!==null&&a.push(i)}if(G+t.y>0){let e=new U;e.setCoords(t.x,-G),o.push(e),a!==null&&a.push(i)}}}function cl(e,t,n){return!(!ll(e,t,n)||Z(e.y,G)||Z(e.y,-G)||Z(t.y,G)||Z(t.y,-G))}function ll(e,t,n){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=n}function ul(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=Math.PI*2;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=Math.PI*2}function dl(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=[i.x],s=[i.y-a],c=[i.x],l=[i.y+a];Rn(t,s),Rn(c,l);let u=e(o,new Sp,!1),d=e(o,new Sp,!1);return kp.greatEllipticDistance(n,r,i.x,i.y,t[0],s[0],u,null,null),kp.greatEllipticDistance(n,r,i.x,i.y,c[0],l[0],d,null,null),Math.min(u.val,d.val)}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function fl(e,t,n,r,i){let a=new T;n.queryEnvelope(a);let o=Te(null,n,!0).total();if(t.xmin-a.xmin<=o&&a.xmax-t.xmax<=o)return n;let s=t.width(),c=0;for(;t.xmin+c*s<a.xmin;)c++;for(;t.xmin+c*s>a.xmin;)c--;let l=c*s,u=new K;u.setShiftCoords(-l,0);let d=n;d.applyTransformation(u);let f=new T;d.queryEnvelope(f);let p=null;if(f.xmax>t.xmax){let n=0,r=new T;r.setCoords({env2D:t}),--r.ymin,r.ymax+=1;let a=d;for(;r.xmin<f.xmax;){f.xmax>r.xmax&&(a=Nu(a,e,2,!0,r.xmax));let o=st(a,r),c=je(null,o,!0).total(),l=q(a,r,c,NaN,i);p===null?p=l===a?l.clone():l:(u.setShiftCoords(-n*s,0),l.applyTransformation(u),p.add(l,!1)),n++,r.xmin=r.xmax,r.xmax=t.xmax+n*s}}else p=d;return p}class pl{m_gcs;m_a;m_e2;m_rpu;m_curvCenterRad;m_cartCenter3D;m_basisX=new V;m_basisY=new V;m_normal=new V;m_d;m_northPolePcs;m_southPolePcs;constructor(e,t){l(e.getCoordinateSystemType()===1),this.m_gcs=e;let n=Pf();e.querySpheroidData(n),this.m_a=n.majorSemiAxis,this.m_e2=n.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);let r=this.m_curvCenterRad.x,i=this.m_curvCenterRad.y,a=Math.cos(r),o=Math.sin(r),s=Math.cos(i),c=Math.sin(i);this.m_cartCenter3D=Cn(this.m_a,this.m_e2,a,o,s,c),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),V.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(U.construct(0,Math.PI*.5/this.m_rpu)),this.m_southPolePcs=this.projectPoint(U.construct(0,-Math.PI*.5/this.m_rpu))}project(e){let t=e.getGeometryType();if(f(t)){S(e);let t=e;return this.projectMultiVertex(t)}n(`Gnomonic.project`)}unproject(e,t,r){let a=e.getGeometryType();if(f(a)){S(e);let n=e,o=[];if(a===i.enumPolygon){let e=n.getPathCount();for(let t=0;t<e;t++){let e=n.calculateRingArea2D(t);o.push(e)}}return this.unprojectMultiVertex(t,n),s(a)?(Sl(this.m_gcs,0,n),ml(o,this.m_gcs,0,n,r)):n=Eu(n,this.m_gcs,0,!0,0,r),n}n(`Gnomonic.unproject`)}projectPoint(e){let t=e.mul(this.m_rpu),n=xn(this.m_a,this.m_e2,t),r=this.m_normal.dotProduct(n);if(r<=0)return U.construct(NaN,NaN);let i=this.m_d/r,a=n.mul(i).sub(this.m_cartCenter3D),o=new U;return o.x=this.m_basisX.dotProduct(a),o.y=this.m_basisY.dotProduct(a),o}unprojectPoint(e){let t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return En(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){let t=e.getImpl(),n=!0,r=new U,i=new U;for(let e=0,a=t.getPointCount();e<a;e++)t.queryXY(e,r),r.y*this.m_rpu>Math.PI*.5?i.assign(this.m_northPolePcs):r.y*this.m_rpu<-Math.PI*.5?i.assign(this.m_southPolePcs):i.assign(this.projectPoint(r)),t.setXYNoCurves(e,i),i.isNAN()&&(n=!1);return t.notifyModifiedFlags(2001),n}unprojectMultiVertex(e,t){let n=t.getImpl(),r=e*e,i=!this.m_northPolePcs.isNAN(),a=!this.m_southPolePcs.isNAN();for(let e=0,t=n.getPointCount();e<t;e++){let t=n.getXY(e),o=new U;i&&U.sqrDistance(t,this.m_northPolePcs)<=r?(o.setCoords(this.m_curvCenterRad.x,Math.PI*.5),o.scale(1/this.m_rpu)):a&&U.sqrDistance(t,this.m_southPolePcs)<=r?(o.setCoords(this.m_curvCenterRad.x,-Math.PI*.5),o.scale(1/this.m_rpu)):o=this.unprojectPoint(t),n.setXYNoCurves(e,o)}n.notifyModifiedFlags(2001)}}function ml(e,t,n,r,a){let o=r.getGeometryType(),s=t.getPannableExtent(),c=r,l=!1,u=!1;if(o===i.enumPolygon){let r=new T,i=U.construct(n,0);r.setCoords({env2D:s}),r.centerAt(i),l=hl(e,t,r,c,a);let o=xl(t,r,c,a);o!==c&&(u=!0),c=o}else c=new Rc().foldInto360RangeGeodetic(c,t,2);o===i.enumPolygon&&(l||u)&&(c=new xc().execute(c,t,!1,a)),c!==r&&(r.setEmpty(),r.add(c,!1))}function hl(e,t,n,r,i){let a=gl(n,r),o=_l(e,t,n,r,i);return a||o}function gl(e,t){let n=new T;t.queryEnvelope(n);let r=Z(e.ymax,n.ymax),i=Z(e.ymin,n.ymin),a=r||i;return a?(vl(e,t),a):!1}function _l(e,t,n,r,i){let a=[],o=[],s=.5*n.width();for(let c=0;c<r.getPathCount();c++){let l=r.getXY(r.getPathStart(c)),u=r.getXY(r.getPathEnd(c)-1),d=e[c]<0;if(Math.abs(l.x-u.x)>s){let e=yl(d,t,n,c,r,i);a.push(e),o.push(c)}else if(!d&&r.calculateRingArea2D(c)<0){let e=bl(t,n,c,r,i);a.push(e),o.push(c)}}if(a.length===0)return!1;let c=new k({vd:r.getDescription()}),l=0,u=o[l];for(let e=0;e<r.getPathCount();e++)e===u?(c.add(a[l],!1),l++,l<o.length&&(u=o[l])):c.addPath(r,e,!0);return r.setEmpty(),r.add(c,!1),!0}function vl(e,t){let n=new k,r=new T;for(let i=0;i<t.getPathCount();i++){t.queryPathEnvelope(i,r);let a=Z(e.ymax,r.ymax),o=Z(e.ymin,r.ymin);if(!(a||o)){n.addPath(t,i,!0);continue}n.insertPath2D(-1,null,0,0,!0);let s=t.getPathStart(i),c=t.getPathEnd(i),l=c-s,u=-1;for(u=s;u<c;u++){let n=t.getXY(u);if(a=Z(e.ymax,n.y),o=Z(e.ymin,n.y),!a&&!o)break}let d=u,f=!1,p=NaN;do{let r=t.getXY(d);a=Z(e.ymax,r.y),o=Z(e.ymin,r.y);let c=s+(d+1-s)%l;if(!a&&!o)n.insertPoint2D(i,-1,r),p=r.x,f=!1;else{let a=U.construct(p,r.y);n.insertPoint2D(i,-1,a);let o=t.getXY(c),s=Z(e.ymax,o.y),l=Z(e.ymin,o.y);!s&&!l&&(a=U.construct(o.x,r.y),f?n.setXYNoCurves(n.getPointCount()-1,a):n.insertPoint2D(i,-1,a)),f=!0}d=c}while(d!==u)}t.setEmpty(),t.add(n,!1)}function yl(e,t,n,r,i,a){let o=new k,s=new k,c=new K,l=i.getXY(i.getPathStart(r)),u=i.getXY(i.getPathEnd(r)-1),d=n.width(),f=.5*d,p=new T;i.queryEnvelope(p);let m=Math.ceil(p.width()/d)+1,h,g;l.x>u.x?(h=-d,g=e?n.ymin:n.ymax):(h=d,g=e?n.ymax:n.ymin),c.setShiftCoords(h,0),o.addPath(i,r,!0),s.add(o,!1);let _=new B;for(let e=0;e<m;e++)s.applyTransformation(c),s.getPointByVal(0,_),o.lineToPoint(_),o.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);let v=o.getXY(0),y=o.getXY(o.getPointCount()-1);v.y=g,y.y=g,o.lineTo(y);let b=new U;for(b.setCoordsPoint2D(y),b.x-=.5*h;Math.abs(b.x-v.x)>f;)o.lineTo(b),b.x-=.5*h;o.lineTo(v);let x=n.getCenter().x,S=new T;o.queryEnvelope(S);let C=0,w=S.getCenter().x;w-x>f?C=-Math.ceil((w-x-f)/d):x-w>f&&(C=Math.ceil((x-w-f)/d)),C!==0&&(c.setShiftCoords(C*d,0),o.applyTransformation(c));let E=new N,D=E.addGeometry(o);Pu(E,D,t,0,2,!0,n.xmin),Pu(E,D,t,0,2,!0,n.xmax);let O=E.getGeometry(D),A=st(O,n);A.inflateCoords(0,1);let j=je(null,A,!0);return q(O,n,j.total(),NaN,a)}function bl(e,t,n,r,i){let a=t.width(),o=.5*a,s=t.getCenter().x,c=new T;r.queryPathEnvelope(n,c);let l=0,u=c.getCenter().x;if(u-s>o?l=-Math.ceil((u-s-o)/a):s-u>o&&(l=Math.ceil((s-u-o)/a)),l!==0){let e=new K;e.setShiftCoords(l*a,0),r.getImpl().applyTransformationToPath(e,n),r.queryPathEnvelope(n,c),u=c.getCenter().x}let d,f=new T;t.containsExclusiveEnvelope(c)?(d=!1,f.setCoords({env2D:t})):(d=!0,f.setCoords({env2D:t}),f.xmin-=a,f.xmax+=a);let p=r.createInstance();p.addPathPoint2D(null,0,!0);let m=new U;if(m.setCoords(f.xmin,f.ymin),p.insertPoint2D(0,-1,m),m.setCoords(f.xmin,f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(.5*(f.xmin+f.xmax),f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(f.xmax,f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(f.xmax,f.ymin),p.insertPoint2D(0,-1,m),m.setCoords(.5*(f.xmin+f.xmax),f.ymin),p.insertPoint2D(0,-1,m),!d)p.addPath(r,n,!0);else{p.addPath(r,n,!0);let o=new K;u<s?o.setShiftCoords(a,0):o.setShiftCoords(-a,0),r.getImpl().applyTransformationToPath(o,n),p.addPath(r,n,!0);let c=new N,l=c.addGeometry(p);Pu(c,l,e,0,2,!0,t.xmin),Pu(c,l,e,0,2,!0,t.xmax),p=c.getGeometry(l);let d=st(p,t);d.inflateCoords(0,1);let f=je(null,d,!0).total();p=q(p,t,f,NaN,i)}return p}function xl(e,t,n,r){let i=new T;n.queryEnvelope(i);let a=Te(null,n,!0).total();if(t.xmin-i.xmin<=a&&i.xmax-t.xmax<=a)return n;let o=n.createInstance(),s=n.createInstance(),c=new T,l=n.getPathCount();for(let i=0;i<l;i++){if(n.queryPathEnvelope(i,c),t.xmin-c.xmin<=a&&c.xmax-t.xmax<=a){o.addPath(n,i,!0);continue}s.setEmpty(),s.addPath(n,i,!0),s=fl(e,t,s,!0,r),o.add(s,!0)}return o}function Sl(e,t,n){let r=e.getPannableExtent(),i=U.construct(t,0);r.centerAt(i);let a=r.width(),o=.5*a,s=new U;s.setNAN();let c=NaN;for(let e=0;e<n.getPathCount();e++)for(let t=n.getPathStart(e);t<n.getPathEnd(e);t++){let i=n.getXY(t),l=Z(i.y,r.ymax)||Z(r.ymin,i.y);t===n.getPathStart(e)?(s.setNAN(),c=0):!s.isNAN()&&!l&&(c=Cl(i.x,s.x,o,a,c)),i.x+=c,n.setXYNoCurves(t,i),l||s.setCoordsPoint2D(i)}n.getImpl().notifyModifiedFlags(2001)}function Cl(e,t,n,r,i){return i+e-t>n?i-=r:t-(i+e)>n&&(i+=r),i}function wl(e,t,n,r,i,a){let o=t.getAttributeStreamRef(0),s=t.getPointCount(),c=!1,l=new U;for(let e=0;e<s;++e){if(o.queryPoint2D(2*e,l),a&1&&l.y>=n){c=!0;break}if(a&2&&l.y<=-n){c=!0;break}}if(!c)return!1;let u=!1;e&&(u=t.getImpl().isClosedPathInXYPlane(0));let d=new N,f=d.addGeometry(t),p=d.getFirstPath(f),m=-1,h=!0,g=new U,_=new B,v=z,y=kl*i/360;for(let e=d.getFirstVertex(p);e!==z;e=d.getNextVertex(e)){d.queryXY(e,l);let t=a&1&&l.y>=n?1:0;if(t|=a&2&&l.y<=-n?2:0,m>0&&m!==t){if(g.x!==l.x){let t=d.getPrevVertex(e);d.queryPoint(t,_);let n=d.insertVertex(p,e,_);g.x=l.x,d.setXY(n,g)}if(u){let t=v===z?d.getFirstVertex(p):d.getNextVertex(v),n=d.getPrevVertex(e);for(;t!==n;)t=d.removeVertex(t,!1);if(v!==z){let e=d.getXY(v),t=d.getXY(n);if(Math.abs(e.x-t.x)>y){d.queryPoint(v,_);let r=d.insertVertex(p,n,_);e.x=Ct(e.x,t.x,.5),d.setXY(r,e)}}}v=z}if(t&&(l.y=Mt(r,l.y),d.setXY(e,l),!h&&m!==t)){if(l.x!==g.x){d.queryPoint(e,_);let t=d.insertVertex(p,e,_);d.setXYCoords(t,g.x,l.y),v=t}else v=e}m=t,g.assign(l),h=!1}if(u){if(v!==z){let e=d.getNextVertex(v);for(;e!==z;)e=d.removeVertex(e,!1)}let e=d.getFirstVertex(p),t=d.getLastVertex(p),n=d.getXY(e),r=d.getXY(t);if(!n.equals(r)&&(d.queryPoint(e,_),t=d.insertVertex(p,z,_),Math.abs(n.x-r.x)>y)){let e=d.insertVertex(p,t,_);n.x=Ct(n.x,r.x,.5),d.setXY(e,n)}}return t.assignCopy(d.getGeometry(f)),!0}function Tl(e,t){let n=new k({vd:e});n.addEnvelope(t,!1);let r=t.width()/180;return n=new an().execute(n,r,0,0,null),n}function El(e,t){let n=e.getPannableExtent();return Number.isNaN(t)||n.centerAtCoords(t,0),n}function Dl(e,t,n){let r=Pf();t.querySpheroidData(r);let i=t.getGCS()===t?null:t.getSRToGCSTransform(),a=bt(U,100),o=new V(0,0,0),s=e.getPointCount(),c=t.getGCS().getUnit().getUnitToBaseFactor();for(let t=0,n=s;t<n;){let s=Math.min(100,n-t);e.queryCoordinates(a,s,t,t+s),i&&new Rc().transform(i,a,s,a,!1);for(let e=0;e<s;e++){if(a[e].isNAN())continue;a[e].scale(c);let t=xn(r.majorSemiAxis,r.e2,a[e]);o.addThis(t)}t+=s}let l=En(r.majorSemiAxis,r.e2,o);l.scale(1/c);let u=new pl(t.getGCS(),l),d=e;if(!u.project(d))return 0;n.length=e.getPathCount();let f=d.calculateArea2D()<0;for(let t=0,r=e.getPathCount();t<r;t++){let e=d.calculateRingArea2D(t);n[t]=f?e<0:e>0}return f?-1:1}function Ol(e,t,n,r,a){if(!t.isPannable()||e.isEmpty())return e;let s=e.getGeometryType();s===i.enumGeometryCollection&&p(`not yet impl for geometry collection`);let c=t.getPannableExtent();Number.isNaN(n)&&(n=c.getCenterX());let l=c.width(),u=l*.5,d=a>0,m=e.queryInterval(0,0);if(!d&&m.width()<u||!f(e.getGeometryType())){let t=m.getCenter();if(Math.abs(t-n)<=u)return e;{let r=new K,i=n-t,a=ht(i/l)*l;r.setShiftCoords(a,0);let o=e.clone();return o.applyTransformation(r),o}}if(s===i.enumPolygon){let i=new E({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),d&&(i=Bc(i,t,2,a,NaN,null,!0));let o=[];if(!r){{let n=e;d&&(n=new k,n.add(i,!1));let r=Dl(e,t,o);if(r)r<0&&i.reverseAllPaths();else{let e=n.getPathCount();for(let t=0;t<e;t++)o.push(n.calculateRingArea2D(t)>0)}}r=o}return new Al(null,r,i,null,t,n,3,0,null).geoNormalizePolygonGeometry(!0)}if(s===i.enumPolyline){let r=new E({vd:e.getDescription()});return r.addAndExplicitlyOpenAllPaths(e,!1),d&&(r=Bc(r,t,2,a,NaN,null,!0)),new Al(null,null,r,null,t,n,3,0,null).geoNormalizePolylineGeometry(!0)}if(s===i.enumMultiPoint){let t=e,r=t.getAttributeStreamRef(0),i,a=null,o=n,s=0,c=.1*l;for(let n=0,d=t.getPointCount();n<d;n++){let t=r.read(n*2),d=t-o;if(Math.abs(d)>u&&(d=ht(d/l)*l,s-=d,Math.abs(s)<c&&(s=0)),s!==0){a||=(i=e.clone(),i.getAttributeStreamRef(0));let r=t+s;a.write(n*2,r)}o=t}return a?(i.notifyModified(),i):e}o(``)}const kl=210;class Al{m_inputPoly;m_originalGeometry;m_polygonRingFlags;m_originalSR;m_pannableSR;m_pannableExtent;m_progressTracker;m_centralLongitude;m_poleSnappingTolerance;m_width360;m_degree;m_GCSLargeDelta;m_poleFlags;m_bAdjustedAtPoles=0;constructor(e,t,n,r,i,a,o,s,c){this.m_inputPoly=n,this.m_progressTracker=c,this.m_originalGeometry=e,this.m_originalSR=r,this.m_polygonRingFlags=t,this.m_pannableSR=i,this.m_poleSnappingTolerance=s,this.m_poleFlags=o,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=El(this.m_pannableSR,a),this.m_centralLongitude=Number.isNaN(a)?this.m_pannableExtent.getCenterX():a,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=210*this.m_degree,l(this.m_originalGeometry===null&&this.m_originalSR===null||this.m_originalGeometry!==null&&this.m_originalSR!==null)}geonormalizeRing(e,t,n,r,i,a,s){let c=n,u=new E({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,e,!0),this.m_poleFlags!==0&&(this.m_bAdjustedAtPoles|=+!!wl(!0,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags),this.m_bAdjustedAtPoles&&(c=!1));let d=-1;c&&(d=this.m_originalGeometry.getPathStart(e));let f=u.getAttributeStreamRef(0),p=u.getPointCount(),m=0,h=f.read(0),g=0,_=3*this.m_pannableSR.getTolerance(0),v=!1,y=new U,b=new U,x=!1,S=u.hasNonLinearSegments(),C=new U;for(let e=1;e<p;++e){f.queryPoint2D(2*e,C);let t=C.x,n=t+m,i=n-h;if(C.x=n,Math.abs(i)>this.m_GCSLargeDelta){if(c){let t=d+e-1,n=d+(e+1<p?e:0),o=a.read(t*2),s=(a.read(n*2)-o)*r;Math.abs(i-s)>1*this.m_degree&&(c=!1)}if(!c){let e=Mt(this.m_width360,n-h);m-=e,n=t+m,++g,x=m!==0,C.x=n}}else v||at(y,b,C,_)&&(v=!0);x&&(S&&o(`error in geonormalize_ring_ for curves`),f.write(2*e,n)),h=n,y.setCoordsPoint2D(b),b.setCoordsPoint2D(C)}g&&u.notifyModified();let w=u.getXY(0),T=u.getXY(p-1);if(U.distance(w,T)<_){let e=this.finalizeGeoNormalizeClosedRing(u,v,i);s.add(e,!1)}else{t<0&&(this.m_originalGeometry===null?t=1:(l(this.m_originalGeometry!==null),t=+(this.m_originalGeometry.calculateRingArea2D(e)>0)));let n=this.finalizeGeoNormalizeOpenedRing(t>0,u);s.add(n,!1)}}geoNormalizePolygonGeometry(e){l(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),l(this.m_pannableSR.isPannable());let t=null,n=NaN,r=!!this.m_originalSR&&this.m_originalSR.isPannable();r&&(t=this.m_originalGeometry.getAttributeStreamRef(0),n=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;let i=new k({vd:this.m_inputPoly.getDescription()});for(let a=0,o=this.m_inputPoly.getPathCount();a<o;++a){let o=this.m_polygonRingFlags?+!!this.m_polygonRingFlags[a]:-1;this.geonormalizeRing(a,o,r,n,e,t,i)}let a=this.m_pannableSR.getTolerance(0),o=this.m_pannableExtent.width()/180;Bu(i,this.m_pannableExtent,a*.1,!1);let s=T.constructEmpty();if(s.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;let t=T.constructEmpty();for(let n=0,r=i.getPathCount();n<r;n++)if(i.queryPathEnvelope(n,t),!(s.xmin<=t.xmin&&s.xmax>=t.xmax)&&!(t.xmin>=s.xmax||t.xmax<=s.xmin)){e=!1;break}if(e)break;s.move(this.m_width360*.5,0)}e||s.setCoords({env2D:this.m_pannableExtent})}let c=q(i,s,a,o,this.m_progressTracker),u=i!==c,d=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,f=c.calculateArea2D(),p=0;if(f>0&&d<0)p=1;else if(f<=0&&d>0){if(f===0){if(this.m_originalSR){let e=NaN;this.m_originalSR.getCoordinateSystemType()===2?e=this.m_originalSR.getPCSHorizon().calculateArea2D():this.m_originalSR.getCoordinateSystemType()===1&&(e=this.m_originalSR.getPannableExtent().getArea()),d>e*.99&&(p=-1)}}else p=-1}if(p!==0){let e=Tl(c.getDescription(),s);e.add(c,!1),u=!0,c=e}return u&&(c=new xc().execute(c,this.m_pannableSR,!1,this.m_progressTracker)),c}geoNormalizePolylineGeometry(e){l(this.m_pannableSR.isPannable());let t=null,n=this.m_originalSR&&this.m_originalSR.isPannable(),r=1;n&&(l(this.m_originalGeometry),r=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));let i=this.m_pannableExtent.width(),a=i*vt()*4,s=e,c=NaN,u=W.constructEmpty();this.m_bAdjustedAtPoles=0;let d=new E({vd:this.m_inputPoly.getDescription()});for(let e=0,f=this.m_inputPoly.getPathCount();e<f;++e){let f=n,p=new E({vd:this.m_inputPoly.getDescription()});p.addPath(this.m_inputPoly,e,!0);let m=this.m_inputPoly.isClosedPath(e);this.m_poleFlags!==0&&(this.m_bAdjustedAtPoles|=+!!wl(m,p,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags),this.m_bAdjustedAtPoles&&(f=!1));let h=-1,g=p.getPointCount(),_=!1;f&&(h=this.m_originalGeometry.getPathStart(e),_=this.m_originalGeometry.isClosedPath(e));let v=p.getAttributeStreamRef(0),y=0,b=v.read(0),x=0,S=new U,C=new U,w=!1,D=p.hasNonLinearSegments(),O=new U;for(let e=1;e<g;++e){v.queryPoint2D(2*e,O);let n=O.x,i=n+y,a=i-b;if(O.x=i,Math.abs(a)>this.m_GCSLargeDelta){if(f){let n=h+e-1,i=h;(!_||e+1<g)&&(i+=e);let o=t.read(n*2),s=(t.read(i*2)-o)*r;Math.abs(a-s)>1*this.m_degree&&(f=!1)}if(!f){let e=Mt(this.m_width360,i-b);y-=e,i=n+y,++x,w=y!==0,O.x=i}}w&&(D&&o(`error in geonormalize_ring_ for curves`),v.write(2*e,i)),b=i,S.setCoordsPoint2D(C),C.setCoordsPoint2D(O)}if(x&&p.notifyModified(),s){let e=!1;if(!p.isEmpty()){let t=T.constructEmpty();if(p.queryEnvelope(t),t.width()>=i||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(c)){let e=this.m_centralLongitude-i*.5;c=t.xmin,c+=Math.round((e-t.xmin)/i)*i,c>e&&(c-=i),l(c<=e),c<e&&(c+=i),l(c>=e)}let n=Math.round((c-t.xmin)/i)*i;if(t.xmin+n>c+a&&(n-=i),t.xmin+n<c-a&&(n+=i),u.mergeCoordinate(t.xmin+n),u.mergeCoordinate(t.xmax+n),e=u.width()>=i,!e){let e=new K;e.setShiftCoords(n,0),p.applyTransformation(e)}}}d.add(p,!1),e&&(d=(()=>{let e=new E({vd:d.getDescription()});for(let t=0,n=d.getPathCount();t<n;++t){let n=new E({vd:d.getDescription()});n.addPath(d,t,!0);let r=Eu(n,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(r,!1)}return e})(),s=!1)}else{let e=Eu(p,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);d.add(e,!1)}}if(s)return d;let f=this.m_pannableSR.getTolerance(0),p=this.m_pannableExtent.width()/180;return Bu(d,this.m_pannableExtent,f*.1,!1),q(d,this.m_pannableExtent,f,p,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){let n=t.getPointCount(),r=t.getXY(0),i=t.getXY(n-1);{let e=Math.abs(i.x-r.x),t=Math.round(e/this.m_width360)*this.m_width360;l(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}let a=_t(i.x-r.x),o=T.constructEmpty();t.queryLooseEnvelope(o);let s=this.m_pannableExtent.getCenterX(),c=0,u=s-this.m_width360,d=s+this.m_width360;if(a>=0){let e=Math.ceil((u-o.xmin)/this.m_width360);for(e*=this.m_width360;u>o.xmin+e;)e+=this.m_width360;for(;u<o.xmax+e;)e-=this.m_width360;for(c=e,o.width()>720&&(d=u+Math.ceil(o.width()/360)*360);d<o.xmax;)d+=this.m_width360}else{let e=Math.ceil((d-o.xmax)/this.m_width360);for(e*=this.m_width360;d<o.xmax+e;)e-=this.m_width360;for(;d>o.xmin+e;)e+=this.m_width360;for(c=e,o.width()>720&&(u=d-Math.ceil(o.width()/360)*360);u>o.xmin;)u-=this.m_width360}let f=Math.round(Math.abs(i.x-r.x)/this.m_width360)*this.m_width360,p=a*f,m=o.clone();m.move(c,0);let h=new U(0,0),g=new K;g.setShiftCoords(c,0),t.applyTransformation(g);let _=new E({vd:t.getDescription()});_.add(t,!1),h.assign(t.getXY(n-1));let v=0,y=_.getXY(0).x;for(;a>0?m.xmax<d:m.xmin>u;)m.move(p,0),g.xd=p,t.applyTransformation(g),y+=p,this.m_pannableExtent.xmin<=y&&this.m_pannableExtent.xmax>=y&&(v=_.getPointCount()-1),t.setXY(0,h),h.assign(t.getXY(n-1)),_.addSegmentsFromPath(t,0,0,n-1,!1);let b=new k({vd:_.getDescription()});b.add(_,!1);let x=_.getXY(0),S=_.getXY(_.getPointCount()-1),C=a<0?e:!e,w=b.getPointCount()-1;if(C){let e=new U(S.x,this.m_pannableExtent.ymax);b.lineTo(e);let t=new U(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);b.lineTo(t);let n=new U(x.x,this.m_pannableExtent.ymax);b.lineTo(n)}else{let e=new U(S.x,this.m_pannableExtent.ymin);b.lineTo(e);let t=new U(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);b.lineTo(t);let n=new U(x.x,this.m_pannableExtent.ymin);b.lineTo(n)}if(b.interpolateAttributesPath(0,w,0),b.getImpl().changeRingStartPoint(v),f>this.m_width360){let e=new k({copy:b});g.setShiftCoords(this.m_width360,0),e.applyTransformation(g),b.add(e,!1)}return b}finalizeGeoNormalizeClosedRing(e,t,n){let r=new k({vd:e.getDescription()});if(r.add(e,!1),!r.hasNonLinearSegments()||!(()=>{let e=r.getPointCount()-2;return r.getSegmentType(e)!==i.enumLine})())r.removePointFromPath(0,r.getPointCount()-1);else{let e=new F,t=r.getPointCount()-2;r.getSegmentBuffer(t,e,!1),r.removePointFromPath(0,t+1),r.closeLastPathWithSegment(e.get())}let a=T.constructEmpty();r.queryLooseEnvelope(a);let o=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(o*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+o;)o+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+o;)o-=this.m_width360;if(o+=this.m_width360,o!==0){a.move(o,0);let e=new K;e.setShiftCoords(o,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){let e=r.calculateArea2D(),t=new xc().execute(r,this.m_pannableSR,!0,this.m_progressTracker);if(t!==r){let n=t.calculateArea2D();_t(e)!==_t(n)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=n?new k({copy:r}):new k({move:r}),n)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);let t=new K;t.setShiftCoords(this.m_width360,0),r.applyTransformation(t),e.add(r,!1)}return e}let s=new k({vd:e.getDescription()});s.add(r,!1);let c=t||a.width()>this.m_width360-this.m_pannableSR.getTolerance(0)*10;for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);let e=new K;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),s.add(r,!1)}if(c){let e=s.calculateArea2D();s.setFillRule(1),s=new xc().execute(s,this.m_pannableSR,!0,this.m_progressTracker);let t=s.calculateArea2D();_t(e)!==_t(t)&&s.reverseAllPaths()}return s}geonormalize_ring_(e,t,n,r,i,a,o){l(0)}}function jl(e){l(0);let t=of(e),n=new Pl;return n.setVertProj_(t),n}function Ml(e,t=!0){return l(0),{}}function Nl(e){return Sf()}class Pl{m_hashCode=0;m_peVertSysVal=null;m_verticalUnit=new Tf;m_verticalShift=0;m_userVerticalWKID=0;m_bIsDepth=!1;getType(){return l(0),0}getID(){return l(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return l(0),``}getTextExtended(e){return l(0),``}getText2(e){return l(0),``}getUnit(){return l(0),{}}equals(e){return l(0),!1}equalForProjection(e){return l(0),!1}getPeVertcsCopy(){return l(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return l(0),0}isDepth(){return l(0),!1}getVerticalShift(){return l(0),0}isCustomWkid(){return this.m_peVertSysVal?this.m_peVertSysVal.isCustomWkid():!1}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Fl(e,t,n,r,i){if(e.equals(t))return!1;if(r){let n=1,a=0,o=1,s=1,c=0,l=1;Number.isNaN(e.m_heightMetersPerUnit)||(n=e.m_heightMetersPerUnit,a=e.m_heightZ0,o=e.m_heightSign,s=t.m_heightMetersPerUnit,c=t.m_heightZ0,l=t.m_heightSign);let u=o*l*n/s;for(let e=0;e<i;e++)r[e]=(r[e]-a)*u+c}let a=1,o=0;if(Number.isNaN(e.m_XYToRadians)||(a=e.m_XYToRadians/t.m_XYToRadians,o=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,o!==0&&(o=ve(o),o/=t.m_XYToRadians)),Array.isArray(n)){let e=n;for(let t=0;t<i;t++)e[t][0]=e[t][0]*a+o,e[t][1]=e[t][1]*a}else{let e=n;for(let t=0;t<i;t++){let n=t<<1;e[n]=e[n]*a+o,e[n+1]=e[n+1]*a}}return!0}function Il(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(e){this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0,this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees},equals(e){return mt(this.m_heightSign,e.m_heightSign)&&mt(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&mt(this.m_heightZ0,e.m_heightZ0)&&mt(this.m_XYToRadians,e.m_XYToRadians)&&mt(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=NaN,this.m_heightZ0=0,this.m_XYToRadians=NaN,this.m_PrimeMeridianDegrees=NaN,t&&l(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){let n=e?e.getPECoordSys():null,r=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(n,r)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Ll{m_inputUnitParams;m_outputUnitParams;m_constantsLoaded=-1;m_isUsable=-1;m_latestID;m_inputSR=null;m_outputSR=null;m_inputSRHorz=null;m_outputSRHorz=null;m_inputVCS=null;m_outputVCS=null;m_geogTran;m_vertTran;m_hashCode=0;m_areaOfUse=new Me;constructor(e){this.m_inputUnitParams=Il(),this.m_outputUnitParams=Il(),l(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=Q.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);let t=this.m_geogTran.getGeogcs1();Q.getCode(t);let n=this.m_geogTran.getGeogcs2();Q.getCode(n),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():(l(0),``)}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(t===-1){if(!e){this.m_geogTran||o(`vcs not impl`);let t=this.m_geogTran.getParameters();t[$.PE_PARM_ND]!==null&&(e=t[$.PE_PARM_ND].getValue()===0)}t=+!!this.m_geogTran.loadConstants(),this.m_constantsLoaded=t}return t!==0}isUsable(){let e=this.m_isUsable;return e===-1&&(this.m_isUsable=e=this.m_geogTran?+!!this.m_geogTran.usable():+!!this.m_vertTran),e===1}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return e===0&&(e=this.m_latestID>0?lt(this.m_latestID):Ot(this.getText()),e===0&&(e=345),this.m_hashCode=e),e}isGeogtran(){return this.m_geogTran!==null}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():(p(`vcs not impl`),``)}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,n,r,i,a;if(this.m_geogTran){let o=this.m_geogTran.getGeogcs1(),s=rf(o),c=this.m_geogTran.getGeogcs2(),l=rf(c),u=-1,d=-1;u=s.getVcsCode(),d=l.getVcsCode(),n=Uf(o,null,null,1),r=Uf(c,null,null,1),u>0&&d>0?(i=jl(u),a=jl(d),e=Kf(),t=Kf()):(e=n,t=r)}else l(0);!this.m_inputSR&&!this.m_inputVCS&&(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=n,this.m_outputSRHorz=r,this.m_inputVCS=i,this.m_outputVCS=a)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=NaN,this.m_outputUnitParams.m_XYToRadians=NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=NaN,this.m_vertTran)l(0);else if(this.m_geogTran){let e=this.m_geogTran,t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function Rl(e,t,n,r,i,a,o){let s=null;t&&(s=t.getPEVerticalCoordSys());let c=null;e&&(c=e.getPECoordSys());let l=null;r&&(l=r.getPEVerticalCoordSys());let u=null;if(n&&(u=n.getPECoordSys()),!c&&!s&&!u&&!l)return!1;let d=Il();d.initFromGcsAndVcsPe(c,s);let f=Il();return f.initFromGcsAndVcsPe(u,l),Fl(d,f,i,a,o)}function zl(e,t,n,r,i,a,o,s){let c=t,l=e,u=Il();u.initFromGcsAndVcsPe(l,c),s.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),s.processUnitParams(u),u.processUnitParams(s),o>0&&Fl(u,s,i,a,o)}function Bl(e,t,n,r,i,a,o,s){let c=Il();c.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),c.processUnitParams(e);let l=null;r&&(l=r.getPECoordSys());let u=Il();u.initFromGcsAndVcsPe(l,null),u.processUnitParams(c),c.processUnitParams(u),s>0&&Fl(c,u,a,o,s)}function Vl(e,t,n,r,i,a,o,s,c){let l=Il(),u=Il();l.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),u.assign(i?r.m_outputUnitParams:r.m_inputUnitParams),l.processUnitParams(e),u.processUnitParams(l),l.processUnitParams(u),s>0&&Fl(l,u,a,o,s),c.assign(u)}function Hl(e,t,n,r,i,a,o){let s=t.getVerttran(),c=t.getGeogtran();if(o.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),a>0){t.prepareOrThrow();let e=n?$.PE_TRANSFORM_2_TO_1:$.PE_TRANSFORM_1_TO_2;s?md():hd(c,a,r,i,e)}}function Ul(e,t,n,r,i){let a=e.getVerttran(),o=e.getGeogtran();if(i>0){e.prepareOrThrow();let s=t?$.PE_TRANSFORM_2_TO_1:$.PE_TRANSFORM_1_TO_2;a?md():hd(o,i,n,r,s)}}class Wl{supportsCurves(){return!0}accelerateGeometry(e,t,n){return Gl(e,t,n)}canAccelerateGeometry(e){return Kl(e)}}function Gl(e,t,n){if(!Kl(e))return!1;ke(t,e,!1);let r=0,i=e.getGeometryType();return s(i)&&D(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeAccelerator(n)),s(i)&&O(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeForPathsAccelerator(n)),r>0}function Kl(e){return D(e)||O(e)}class ql extends Wl{getOperatorType(){return 8}execute(e,t,n,r){return Ri(e,t,n,1,r)}}function Jl(e,t,r,o){if(e.isEmpty()||t.isEmpty())return e;let s=e.getDimension(),c=t.getDimension();if(s>c)return e;let l=e.getGeometryType(),u=t.getGeometryType(),d=new T,f=new T,p=new T;e.queryEnvelope(d),t.queryEnvelope(f),p.setCoords({env2D:d}),p.mergeEnvelope2D(f);let m=je(r,p,!0),h=Pe(m),g=new T;if(g.setCoords({env2D:d}),g.inflateCoords(h,h),!g.isIntersecting(f))return e;if(s===1&&c===2){let n=au(e,t,u,r,o);if(n)return n}if(l===i.enumPoint){let r;switch(a(u)?(r=new E({vd:t.getDescription()}),r.addSegment(t,!0)):r=t,u){case i.enumPolygon:return Zl(e,r,m);case i.enumPolyline:return Ql(e,r,m);case i.enumMultiPoint:return $l(e,r,m);case i.enumEnvelope:return eu(e,r,m);case i.enumPoint:return tu(e,r,m);default:n(`invalid shape type`)}}else if(l===i.enumMultiPoint)switch(u){case i.enumPolygon:return nu(e,t,m);case i.enumEnvelope:return ru(e,t,m);case i.enumPoint:return iu(e,t,m)}let _=new T(d);return _.inflate(100*m.total()),Hs(e,q(t,_,0,0,o),r,o)}class Yl{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n,r){return new Xl(e,t,n,r)}execute(e,t,n,r){return this.executeMany(new sn([e]),new sn([t]),n,r).next()}}class Xl extends on{m_inputGeoms;m_progressTracker;m_spatialReference;m_geomSubtractor;m_index;constructor(e,t,n,r){super(),this.m_progressTracker=r,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=n;let i=t.next();this.m_geomSubtractor=i||new k}next(){let e=this.m_inputGeoms.next();return e?(r(e),c(e),this.m_index=this.m_inputGeoms.getGeometryID(),Jl(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Zl(e,t,n,r){return Ko(t,e,n.total())===0?e:e.createInstance()}function Ql(e,t,n,r){let i=e.getXY(),a=t.querySegmentIterator(),o=Pe(n),s=o*o;for(;a.nextPath();)for(;a.hasNextSegment();){let t=a.nextSegment(),r=new T;if(t.queryEnvelope(r),r.inflateCoords(o,o),!r.contains(i))continue;if(t.isIntersectingPoint(i,n.total()))return e.createInstance();let c=t.getStartXY();if(U.sqrDistance(i,c)<=s||(c=t.getEndXY(),U.sqrDistance(i,c)<=s))return e.createInstance()}return e}function $l(e,t,n,r){let i=t.getImpl().getAttributeStreamRef(0),a=t.getPointCount(),o=e.getXY(),s=Pe(n),c=s*s,l=new U;for(let t=0;t<a;t++)if(i.queryPoint2D(2*t,l),U.sqrDistance(l,o)<=c)return e.createInstance();return e}function eu(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getXY();return i.contains(a)?e.createInstance():e}function tu(e,t,n,r){let i=Pe(n),a=i*i,o=e.getXY(),s=t.getXY();return U.sqrDistance(o,s)<=a?e.createInstance():e}function nu(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getPointCount(),o=!1,s=H(a,!1),c=new U;for(let r=0;r<a;r++)e.queryXY(r,c),i.contains(c)&&qo(t,c,n.total())!==0&&(o=!0,s[r]=!0);if(!o)return e;let l=e.createInstance();for(let t=0;t<a;t++)s[t]||l.addPoints(e,t,t+1);return l}function ru(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getPointCount(),o=!1,s=H(a,!1),c=new U;for(let t=0;t<a;t++)e.queryXY(t,c),i.contains(c)&&(o=!0,s[t]=!0);if(!o)return e;let l=e.createInstance();for(let t=0;t<a;t++)s[t]||l.addPoints(e,t,t+1);return l}function iu(e,t,n,r){let i=e.getImpl().getAttributeStreamRef(0),a=e.getPointCount(),o=t.getXY(),s=!1,c=H(a,!1),l=Pe(n),u=l*l,d=new U;for(let e=0;e<a;e++)i.queryPoint2D(2*e,d),U.sqrDistance(d,o)<=u&&(s=!0,c[e]=!0);if(!s)return e;let f=e.createInstance();for(let t=0;t<a;t++)c[t]||f.addPoints(e,t,t+1);return f}function au(e,t,n,r,a){let o=new Me;e.queryEnvelope(o);let s=new T;t.queryEnvelope(s),o.merge(s);let c=.1*o.width(),l=.1*o.height();o.inflateCoords(c,l);let u=new k;u.addEnvelope(o,!1);let d=u.getImpl();if(n===i.enumPolygon){let e=t.getImpl();d.add(e,!0)}else d.addEnvelope(t,!0);return new wc(u,r,-1,a).tryFastImplementation(e)}class ou{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n,r=0){return new uu(e,t,n,r)}execute(e,t,n,r){let i=new sn([e,t]),a=new uu(i,n,r,0).next();return a||o(`null output`),a}}function su(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new U}}function cu(e,t){return U.compareZorder(e.location,t.location)?-1:+!e.location.equals(t.location)}class lu{binVertexCount;geometries;constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>cu(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class uu extends on{m_inputGeoms;m_progressTracker;m_spatialReference;m_bUnionAllDimensions;m_bPreserveAllPathEnds;m_index=-1;m_currentDim=-1;m_bDone=!1;m_unionBins=[];m_readyGeoms=ut(4);m_dimGeomCounts=H(4,0);m_addedGeoms=0;m_options;m_maxDimension=-1;m_bHadGeometry=H(4,!1);m_bIs3D;m_complexUnionGeoms=ut(4);m_totalNonEmptyGeomCounters=H(4,0);constructor(e,t,n,r,i=!1){super(),this.m_progressTracker=n,this.m_bUnionAllDimensions=!!(r&4),this.m_bPreserveAllPathEnds=!!(r&8),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=r,this.m_bIs3D=i}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(this.m_maxDimension===-1)return null;if(this.m_bUnionAllDimensions){if(this.m_currentDim===-1){for(let e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?l(0):this.m_complexUnionGeoms[e]=new Yl().execute(this.m_complexUnionGeoms[e],this.m_complexUnionGeoms[t],this.m_spatialReference,this.m_progressTracker))}}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&o(``),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,this.m_currentDim===0&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.enumPoint){let e=new A({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(e){return this.m_readyGeoms[e]}finishDim(e,t,n){let r=t;if(n){if(this.m_options&1)return r;if(e===1){if(!(this.m_options&8)&&(this.m_options&16||this.m_totalNonEmptyGeomCounters[e]>1)){r=Js([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options|16,this.m_bIs3D);let e=r.getImpl().getIsSimple(0,[0]);l(this.m_bIs3D||De(e))}else this.m_totalNonEmptyGeomCounters[e]===1&&(this.m_bIs3D?l(0):r=new xc().execute(r,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?l(0):r=new xc().execute(r,this.m_spatialReference,!1,this.m_progressTracker);if(e===0&&r.getGeometryType()===i.enumPoint){let e=new A({vd:r.getDescription()});r.isEmpty()||e.add(r),r=e}}else return this.m_options&16&&(r=Js([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D)),r;return r}static getLevel(e){let t=m(e),n=t>0?(Math.log(t)-Math.log(32))/Math.log(4):0;return n<0&&(n=0),Math.floor(n)}step_(){if(this.m_bDone)return!0;let e;if(this.m_inputGeoms?(e=this.m_inputGeoms.next(),e===null?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,e!==null){let t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let e=0;e<=this.m_maxDimension;e++){for(;this.m_dimGeomCounts[e]>1;){let t=this.collectGeometriesToUnion(e);if(t!==null){let n;n=this.m_options&1?Js(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Ys(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options|8,this.m_bIs3D),this.addGeom(e,!0,n)}else break}if(this.m_bDone&&(l(this.m_dimGeomCounts[e]<=1),this.m_dimGeomCounts[e]!==0)){let t=this.m_unionBins[e].entries().next().value,n=t[1].geomPairs()[0].geom,r=t[1].geomPairs()[0].bUnioned;this.m_unionBins[e].clear(),this.m_readyGeoms[e]=this.finishDim(e,n,r)}}return this.m_bDone}addGeom(e,t,n){let r=su();r.geom=n;let i=m(n);r.vertexCount=i;let a=T.constructEmpty();n.queryEnvelope(a),r.location=i>0?a.getCenter():new U(0,0);let o=uu.getLevel(n);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let s=null,c=this.m_unionBins[e].get(o);c&&(s=c),s===null&&(s=new lu,this.m_unionBins[e].set(o,s)),r.bUnioned=t,s.addPair(r),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(this.m_options&1&&!this.m_bDone)return null;let t=null,n=[];for(let t of this.m_unionBins[e].keys())n.push(t);dt(n);for(let r=0;r<n.length;r++){if(n[r]===-1)continue;let i=this.m_unionBins[e].get(n[r]);{let a=i.getBinVertexCount()>5e3&&i.geomCount()>=4;if(this.m_bDone||a){for(let i=0;i<r;i++){if(n[i]===-1)continue;let r=this.m_unionBins[e].get(n[i]);r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(let e of r.geomPairs())t||=[],t.push(e.geom);r.clear(),this.m_unionBins[e].delete(n[i]),n[i]=-1}i.sort(),this.m_dimGeomCounts[e]-=i.geomCount(),this.m_addedGeoms-=i.geomCount();for(let e of i.geomPairs())t||=[],t.push(e.geom);if(i.clear(),this.m_unionBins[e].delete(n[r]),n[r]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&h(),e.hasAttribute(1)||n(`Geometry must have Zs`)),r(e)}}class du extends Wl{getOperatorType(){return 3}execute(e,t,n,r=null){return Ri(e,t,n,4,r)}}function fu(e,t,n){let r=t.getGCSSplitLines();if(r===null)return e;let i=t.getGCS(),a=i.getPannableExtent().width(),o=T.constructEmpty();e.queryLooseEnvelope(o);let s=W.constructEmpty();o.queryIntervalX(s);let c=r.querySegmentIterator(),l=null,u=new K;for(;c.nextPath();)for(;c.hasNextSegment();){let e=c.nextSegment(),t=e.queryInterval(0,0),n=W.constructEmpty();n.setCoordsFromEnvelope(t);let r=0;for(;n.vmax>s.vmin;)n.move(-a),r--;for(;n.vmin<=s.vmax;){if(n.isIntersecting(s)){l===null&&(l=new E);let t=new I({start:e.getStartXY(),end:e.getEndXY()});r!==0&&(u.setShiftCoords(r*a,0),t.applyTransformation(u)),l.addSegment(t,!0)}n.move(a),++r}}if(l!==null){let t=Te(i,l,!0),r=Pe(t);return Vr(e,l,r,n)}return e}function pu(e,t,n){let r=e.getName();return np(r)||(n||t>0?(r=e.toString($.PE_STR_NAME_CANON|$.PE_STR_AUTH_NONE),r=vu(r)):r=e.toString($.PE_STR_AUTH_TOP)),r}function mu(e,t,n,r){return l(0),``}function hu(e,t=-1){if((t>1||t<-1)&&n(`verbosity`),t===-1)return e.toString();{let n=t===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL;return e.toString(n)}}function gu(e,t){(t>1||t<-1)&&n(`verbosity`);let r=$.PE_STR_FMT_WKT2;return t!==-1&&(r|=t===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL),e.toString(r)}function _u(e){return l(0),``}function vu(e){return e.toLocaleUpperCase(`en-US`)}function yu(e,t,r){let a=e.getPCSHorizon();if(a.getGeometryType()===i.enumPolygon){let n=e.getDefaultPrecisionSR().getTolerance(0),i=a;for(let e=0;e<r;e++)qo(i,t[e],n)!==1&&t[e].setNAN();return}if(a.getGeometryType()===i.enumEnvelope){let e=a;for(let n=0;n<r;n++)e.contains(t[n])||t[n].setNAN();return}n(``)}function bu(e,t,n,r){for(let i=0;i<t;i++){if(e[i].y<n.ymin||e[i].y>n.ymax){e[i].setNAN();continue}let t=e[i].x;e[i].x=ku(t,n,r)}}function xu(e,t,n,r){if(e.isEmpty()||n===1)return e;let a=e.getGeometryType();if(a===i.enumPoint){let r=e,i=r.getXY();return Tu([i],1,t,n)===0||i.isNAN()?r.setEmpty():r.setXY(i),e}if(a===i.enumMultiPoint){let r=e,i=e.createInstance(),a=r.getPointCount();i.reserve(a);let o=r.getAttributeStreamRef(0),s=r.getDescription().getAttributeCount()>1,c=new B,l=Float64Array.from(o.getArray());if(Tu(l,a,t,n)>0)for(let e=0,t=a*2;e<t;e+=2)Number.isNaN(l[e])||(s?(r.getPointByVal(e>>1,c),c.setXYCoords(l[e],l[e+1]),i.add(c)):i.addXY(l[e],l[e+1]));return i}let c=e,l=t.getOneDegreeGCSUnit(),u=l*90,d=l*180,f=l*360,p=t.getCentralMeridian(),m=.5*l,h=T.constructEmpty();c.queryEnvelope(h);let g=t.getGCSHorizon(),_=t.getGCSHorisonIsInclusive(),v=g.getGeometryType()===i.enumEnvelope,y=T.constructEmpty();g.queryEnvelope(y);let b=t.getGCS();if((n===2||n===4)&&(y.xmin=p-d,y.xmax=y.xmin+f),n===4){if(h.width()>f-l)n=2;else{let e=T.constructEmpty();e.setCoords({xmin:h.xmin-l,ymin:y.ymin,xmax:h.xmax+l,ymax:y.ymax}),c=new nn().execute(c,e,b,r);let t=Math.floor((p-h.getCenterX())/f);for(h.move(t*f,0);h.xmin>y.xmax;)--t,h.move(-f,0);for(;h.xmin<y.xmin;)t+=1,h.move(f,0);if(t!==0){let e=new K;e.setShiftCoords(t*f,0),c.applyTransformation(e)}return c}}if(n===2&&(y.xmin=p-d,y.xmax=y.xmin+f),h.ymin<-u||h.ymax>u){let e=T.constructEmpty();if(e.setCoords({xmin:h.xmin-l,ymin:-u,xmax:h.xmax+l,ymax:u}),c=new nn().execute(c,e,b,r),c.isEmpty())return c;c.queryEnvelope(h)}if(_&&(y.ymax<h.ymin||y.ymin>h.ymax))return c.createInstance();h.width()>f&&(c=Ru(c,p-d,f,b,!0,0,!0,r),c.queryEnvelope(h));let x=Lu(h.xmin,h.xmax,y.xmin,y.xmax,f);if(x!==0&&h.move(x,0),h.xmax>y.xmax||h.xmin<y.xmin){if(h.xmax>y.xmax)for(;h.xmin>=y.xmax;)h.move(-f,0),x-=f;for(;h.xmin<y.xmax-f;)h.move(f,0),x+=f}let S=ke(b,g,!1);if(x!==0){let e=new K;e.setShiftCoords(x,0),c.applyTransformation(e),x=0}if(_){if(v&&y.containsEnvelope(h))return c;let e=[,,];for(let t=0;t<2;t++){let n;if(v?n=s(a)?q(c,y,S,m,r):q(c,y,S,0,r):(n=new Ec().execute(c,g,b,r),n===g&&(n=n.clone())),y.xmin<=h.xmin&&y.xmax>=h.xmax||y.xmin>=h.xmin&&y.xmax<=h.xmax)return n;if(e[t]=n,t===0){h.move(-f,0);let e=new K;e.setShiftCoords(-f,0),c.applyTransformation(e)}}return s(a)?e[0].add(e[1],!1):o(`intersect_with_GCS_horizon: unexpected geometry type`),e[0]}{if(y.ymax<h.ymin||y.ymin>h.ymax)return c;let e=0;for(;!c.isEmpty()&&h.xmax>y.xmin;){if(e!==0){let t=new K;t.setShiftCoords(e,0),c.applyTransformation(t)}if(new du().execute(c,g,b,r)||(c=new Yl().execute(c,g,b,r),g===c&&(c=c.clone())),e!==0){let t=new K;t.setShiftCoords(-e,0),c.applyTransformation(t)}e-=f,h.move(-f,0)}return c}}function Su(n,r,i,a,o,s){let c={stack:[],error:void 0,hasError:!1};try{if(s===2)return In(n,r,i,a,o);if(Math.abs(i.x-a.x)>=Math.PI||!Md(i.x,a.x,o))return NaN;i.x>a.x&&(a=gt(i,i=a));let t=e(c,new Sp,!1),l=e(c,new Sp,!1),u=e(c,new Sp,!1),d=i.clone();kp.geodeticDistance(n,r,i.x,i.y,a.x,a.y,l,t,null,s);let f=l.val,p=0,m=1;for(;f*(m-p)>n*1e-12;){let e=.5*(p+m);if(kp.geodeticCoordinate(n,r,i.x,i.y,f*e,t.val,l,u,s),d.x=l.val,d.y=u.val,d.x===o)return d.y;if(Md(i.x,d.x,o))m=e;else if(Md(a.x,d.x,o))p=e;else return NaN}return d.y}catch(e){c.error=e,c.hasError=!0}finally{t(c)}}function Cu(e,t){let n;if(Array.isArray(e)){let r=e;n=new Float64Array(t*2);for(let e=0,i=0;e<t;e++,i+=2)n[i]=r[e].x,n[i+1]=r[e].y}else n=e;return n}function wu(e,t,n,r){for(let i=0,a=0;i<r;i++,a+=2)t[n+i].x=e[a],t[n+i].y=e[a+1]}function Tu(e,t,n,r){if(t===0||r===1)return t;let a=Cu(e,t);if(r===2){let r=n.getPannableExtentInGCS(),i=t;for(let e=0,n=t*2;e<n;e+=2)(a[e+1]>r.ymax||a[e+1]<r.ymin)&&(a[e]=NaN,i--);return i?(zu(a,t,r.xmin,r.width(),!0),e!==a&&wu(a,e,0,t),i):(e!==a&&wu(a,e,0,t),0)}let o=n.getOneDegreeGCSUnit(),s=o*90,c=o*180,l=o*360,u=t;for(let e=0,n=t*2;e<n;e+=2)(a[e+1]>s||a[e+1]<-s)&&(a[e]=NaN,u--);if(!u)return e!==a&&wu(a,e,0,t),0;let d=T.constructEmpty();d.setFromPoints(a,t);let f=n.getGCSHorizon(),p=n.getGCSHorisonIsInclusive(),m=f.getGeometryType()===i.enumEnvelope,h=T.constructEmpty();if(f.queryEnvelope(h),p&&(h.ymax<d.ymin||h.ymin>d.ymax))return e!==a&&wu(a,e,0,t),0;if(p){if(zu(a,t,h.getCenterX()-c,l,!0),u=t,m)for(let e=0,n=t*2;e<n;e+=2)h.containsCoords(a[e],a[e+1])||(a[e]=NaN,u--);else{let e=ke(n.getGCS(),f,!1),r=new U;for(let n=0,i=t*2;n<i;n+=2)r.setCoords(a[n],a[n+1]),qo(f,r,e)!==0||(a[n]=NaN,u--)}}else{zu(a,t,-c,l,!0),u=t;let e=ke(n.getGCS(),f,!1),r=new U;for(let n=0,i=t*2;n<i;n+=2){r.setCoords(a[n],a[n+1]),r.isNAN()&&u--;let t=Iu(r.x,h.xmin,h.xmax,l);r.x+=t,qo(f,r,e)!==0&&(a[n]=NaN,u--)}}return e!==a&&wu(a,e,0,t),u}function Eu(e,t,r,i,a,o){if(t.isPannable()||n(`fold_into_360_degree_range`),e.isEmpty())return e;let s,c;if(t.getCoordinateSystemType()===2){let e=t.getPannableExtent();c=e.xmin,s=e.width()}else{let e=t.getOneDegreeGCSUnit(),n=e*180;s=e*360,c=r-n}return Ru(e,c,s,t,i,a,!0,o)}function Du(e,t,n,r){let i,a;if(n.getCoordinateSystemType()===2){let e=n.getPannableExtent();i=e.xmin,a=e.width()}else{let e=n.getOneDegreeGCSUnit(),t=e*180;a=e*360,i=r-t}zu(e,t,i,a)}function Ou(e,t){let n=t.width(),r=pt(e-t.vmin,n);return r<0&&(r+=n),t.snapClip(r+t.vmin)}function ku(e,t,n){return e>t.xmax&&e-t.xmax<n?t.xmax:e<t.xmin&&t.xmin-e<n?t.xmin:e}function Au(e,t,n){if(e[0]<t.vmin||e[0]>t.vmax||n&&e[0]===t.vmax){let n=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/n)*n,e[0]=t.snapClip(e[0]),!0}return!1}function ju(e,t,n,r,i,a,o,s,c){return new Al(e,null,n,t,r,i,o,s,a).geoNormalizePolygonGeometry(c)}function Mu(e,t,n,r,i,a,o,s,c){return new Al(e,null,n,t,r,i,o,s,a).geoNormalizePolylineGeometry(c)}function Nu(e,t,n,r,i){let a=new N,o=a.addGeometry(e);return Pu(a,o,t,ke(t,e,!1),n,r,i),a.getGeometry(o)}function Pu(n,r,i,a,o,s,c){let u={stack:[],error:void 0,hasError:!1};try{l(Rf()),i.isPannable()||y(`insert_geodetic_points`);let t=i.getPannableExtent(),d=i.getGCS(),f=Pf();d.querySpheroidData(f);let p=d.getUnit().getUnitToBaseFactor(),m=f.majorSemiAxis,h=f.e2,g=0,_=new W;t.queryIntervalX(_);let v=null,b=H(4,NaN);i.getCoordinateSystemType()===2?(v=i.getPECoordSys(),s?(b[0]=Ou(c,_),b[1]=t.getCenterY(),wp.projToGeog(v,1,b),g=b[0]*p):(b[0]=t.getCenterX(),b[1]=c,wp.projToGeog(v,1,b),g=b[1]*p)):g=c*p,!s&&g!==0&&o!==2&&y(`insert_geodetic_points: 1`);let x=e(u,new Sp,!1),S=new U,C=new U,w=new U,T=new U,E=new U,D=new U;for(let e=n.getFirstPath(r);e!==z;e=n.getNextPath(e)){let t=n.getFirstVertex(e);n.queryXY(t,w);let r=!1,l=n.getNextVertex(t);for(let e=l;e!==z;e=n.getNextVertex(e)){if(e===l){if(r)break;r=!0}if(n.queryXY(e,T),s&&(a<c-w.x&&T.x-c>a||a<c-T.x&&w.x-c>a)||!s&&(c!==0||a<-w.y&&T.y>a||a<-T.y&&w.y>a))do{if(Math.abs(w.x-T.x)>=_.width()*.5)break;i.getCoordinateSystemType()===2?(b[0]=Ou(w.x,_),b[1]=w.y,b[2]=Ou(T.x,_),b[3]=T.y,od(v,2,b,0),E.x=b[0]*p,E.y=b[1]*p,D.y=b[3]*p):(E.x=w.x*p,E.y=w.y*p,D.y=T.y*p),D.x=(T.x-w.x)*Math.PI*2/_.width()+E.x;let t=0,r=bt(U,2);if(s){if(C.x=g,C.y=Su(m,h,E,D,g,o),Number.isNaN(C.y))break;r[0]=C,t=1}else if(o===2){let e=[0,0];if(t=Ln(m,h,E,D,g,e),!t)break;r[0].x=e[0],r[0].y=g,t===2&&(r[1].x=e[1],r[1].y=g)}else{if(C.x=Nd(m,h,E,D,o),Number.isNaN(C.x))break;C.y=0,r[0]=C,t=1}let a=-1;for(let l=0;l<t;l++){kp.geodeticDistance(m,h,E.x,E.y,D.x,D.y,x,null,null,o);let t=x.val;kp.geodeticDistance(m,h,E.x,E.y,r[l].x,r[l].y,x,null,null,o);let u=x.val;i.getCoordinateSystemType()===2?(b[0]=r[l].x/p,b[1]=r[l].y/p,wp.geogToProj(v,1,b),s?(S.y=b[1],S.x=c):(S.x=Pd(b[0],w.x,T.x,_),S.y=c)):s?(S.x=c,S.y=r[l].y/p):(S.x=Pd(r[l].x/p,w.x,T.x,_),S.y=c);let d=t>0?At(u/t,0,1):.5;if(d===0||d===1||a>d)continue;let f=n.getPrevVertex(e);n.splitSegment(f,[d],1);let g=n.getNextVertex(f);n.setXYCoords(g,S.x,S.y),a=d}}while(0);w.setCoordsPoint2D(T)}}}catch(e){u.error=e,u.hasError=!0}finally{t(u)}}function Fu(e,t){l(t.isPannable());let n=t.getPannableExtent();if(e.getGeometryType()===i.enumPoint){let t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}let r=T.constructEmpty();e.queryEnvelope(r);let a=T.constructEmpty();a.setCoords({env2D:n}),a.xmin=r.xmin,a.xmax=r.xmax,a.inflateCoords(a.height()*.01,0);let o=Oe(t,r,!1),s;return s=a.containsEnvelope(r)?e:q(e,a,o,0,null),s}function Iu(e,t,n,r){let i=(n+t)*.5;return ht((i-e)/r)*r}function Lu(e,t,n,r,i){return e>=n&&t<=r?0:Iu((t+e)*.5,n,r,i)}function Ru(e,t,n,r,a,o,s,c){let l=e.getGeometryType(),u=W.constructEmpty();u.setCoords(t,t+n);let d=[0];if(l===i.enumPoint){if(d[0]=e.getX(),Au(d,u,s)){let t=a?e:e.clone();return t.setX(d[0]),t}return e}let f=T.constructEmpty();if(e.queryEnvelope(f),f.isEmpty())return e;if(l===i.enumMultiPoint){let t=a?e:e.clone(),n=t.getImpl(),r=n.getAttributeStreamRef(0),i=n.getPointCount()*2,o=!1;for(let e=0;e<i;e+=2)d[0]=r.read(e),Au(d,u,s)&&(r.write(e,d[0]),o=!0);return o&&n.notifyModifiedFlags(2001),t}let p=W.constructEmpty();if(f.queryIntervalX(p),u.contains(p))return u.vmax,p.vmax,e;let m=T.constructEmpty();if(m.setCoords({env2D:f}),p.width()===0){let t=p.vmin;t+=Math.ceil((u.vmin-t)/n)*n,t=u.snapClip(t);let r=a?e:e.clone();return r.setAttributeBasic(0,0,t),r}if(l===i.enumEnvelope){let t=a?e:e.clone();return f.intersect(m),t.setEnvelope(f),t}let h=Math.max(f.height(),f.width())*.1*1;m.inflateCoords(0,h);let g=e,_=r.getTolerance(0),v=new K;for(;;){let e=Math.floor((p.vmin-t)/n),a=Math.ceil((p.vmax-t)/n);if(a-e>3){let s=Math.floor((a+e)*.5);m.xmin=f.xmin-h,m.xmax=t+n*s;let u=q(g,m,_,o,c);m.xmin=m.xmax,m.xmax=f.xmax+h;let d=q(g,m,_,o,c);v.setShiftCoords((s-a)*n,0),d.applyTransformation(v),l===i.enumPolygon?g=new ou().execute(u,d,r,c):(g=u,g.add(d,!1)),g.queryEnvelope(f),f.queryIntervalX(p)}else break}m.xmin=t,m.xmax=t+n;let y=T.constructEmpty();y.setCoords({env2D:m}),y.inflateCoords(_,0);let b=Math.floor((f.xmin-m.xmin)/n)*n;b?(m.move(b,0),v.setShiftCoords(-b,0)):v.setIdentity();let x;x=l===i.enumPolyline?new E({vd:g.getDescription()}):new k({vd:g.getDescription()});let S=T.constructEmpty(),C=T.constructEmpty();for(;f.xmax>m.xmin;){let e=q(g,m,_,0,c);e.queryEnvelope(C);let t=!1;t=l===i.enumPolyline?!e.isEmpty()&&(C.width()>_||C.height()>_):!e.isEmpty()&&(l!==i.enumPolygon||C.width()>_),t&&(e.applyTransformation(v),e.queryEnvelope(C),x.queryEnvelope(S),S.inflateCoords(_,_),S.isIntersecting(C)&&l===i.enumPolygon?x=new ou().execute(x,e,r,c):x.add(e,!1)),m.move(n,0),v.shiftCoords(-n,0)}return x}function zu(e,t,n,r,i=!0){let a=new W;a.setCoords(n,n+r);let o=[0];if(Array.isArray(e)){let n=e;for(let e=0;e<t;e++)a.containsRightExclusive(n[e].x)||(o[0]=n[e].x,Au(o,a,i),n[e].x=o[0])}else{let n=e;for(let e=0;e<t;e++){let t=e<<1;a.containsRightExclusive(n[t])||(o[0]=n[t],Au(o,a,i),n[t]=o[0])}}}function Bu(e,t,n,r=!0){if(e.isEmpty())return;let a=e.getGeometryType();if(!(r&&a===i.enumPolygon)){if(f(a)){let r=s(a)&&e.hasNonLinearSegments(),i=!1;if(r){let r=e.getImpl(),a=r.getAttributeStreamRef(0),o=r.getSegmentFlagsStreamRef();l(o!==null);for(let e=0,s=r.getPathCount();e<s;e++){let s=!0,c=r.isClosedPath(e),l=r.getPathEnd(e);c&&r.getPathSize(e)>0&&(s=(o.read(l-1)&31)==1);for(let c=r.getPathStart(e);c<l;c++)if((o.read(c)&31)==1){if(s){let e=a.read(2*c),r=ku(e,t,n);r!==e&&(i=!0,a.write(2*c,r))}s=!0}else s=!1}}else{let r=e.getImpl(),a=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){let r=a.read(2*e),o=ku(r,t,n);o!==r&&(i=!0,a.write(2*e,o))}}i&&e.getImpl().notifyModifiedFlags(2001)}else if(a===i.enumEnvelope){let r=e,i=T.constructEmpty();r.queryEnvelope(i),i.xmin=ku(i.xmin,t,n),i.xmax=ku(i.xmax,t,n),r.setEnvelope(i)}else if(a===i.enumPoint){let r=e;r.setX(ku(r.getX(),t,n))}else o(``)}}function Vu(e,t,n){let r=new U;return r.x=ku(e.x,t,n),r.y=e.y,r}function Hu(e,t){if(t.isEmpty())return 0;let n=e.getPECoordSys();if(n.getProjection().getCode()===$.PE_PRJ_AZIMUTHAL_EQUIDISTANT){let r=Pf();e.querySpheroidData(r);let i=n.getParameters();if(i[$.PE_PARM_LAM0]===null||i[$.PE_PARM_PHI0]===null)return 0;let a=[i[$.PE_PARM_LAM0].getValue(),i[$.PE_PARM_PHI0].getValue()];wp.geogToProj(n,1,a);let o=new U(a[0],a[1]),s=T.constructEmpty();t.queryEnvelope(s);let c=bt(U,4);s.queryCorners(c);let l=0,u=e.getOneMeter(),d=Math.max(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,f=Math.min(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,p=d/180;f-=p,d*=u,f*=u;for(let e=0;e<4;e++){let t=U.distance(c[e],o);if(t>d)l++;else if(t>f)return-1}if(l===0)return 1;if(l===4){let e=T.constructEmpty();return e.setCoords({center:o,width:d,height:d}),s.isIntersectingNe(e)?-1:0}return-1}return-1}function Uu(e,t,n,r){let a=e.getGeometryType();l(a===i.enumPolygon||a===i.enumPolyline||a===i.enumMultiPoint);let o=t.getCoordinateSystemType();if(o===2){let o=e;if(n===0){let n=Hu(t,e);if(n===0)return e.createInstance();if(n===1)return e;let a=t.getPCSHorizon(),s=a.getGeometryType(),c=t.getDefaultPrecisionSR();if(s===i.enumEnvelope){let n=T.constructEmpty();a.queryEnvelope(n);let i=Oe(c,n,!1);o=q(e,n,i,t.getOneMeterPCSUnit()*5e4,r)}else new ql().execute(a,e,c,r)||(o=new Ec().execute(o,a,c,r),o===a&&(o=o.clone()))}else if(t.isPannable()){let e=T.constructEmpty();o.queryEnvelope(e);let s=t.getPannableExtent();s.containsEnvelope(e)||(Bu(o,s,t.getTolerance(0)),(n===2||n===4)&&(o=Fu(o,t)),n===4?a===i.enumPolygon&&e.width()>s.width()*2&&(o=Ru(o,-2*s.width(),2*s.width(),t,!0,0,!0,r)):o=Eu(o,t,0,!0,t.getOneMeterPCSUnit()*1e5,r))}return o}if(l(o===1),a===i.enumMultiPoint)return Bu(e,t.getPannableExtent(),t.getTolerance(0)),e;{let n=T.constructEmpty();e.queryEnvelope(n);let o=e,s=t.getPannableExtent();if(n.ymin<s.ymin||n.ymax>s.ymax){let e=Math.max(1,n.calculateToleranceFromEnvelope()),i=new T(n.xmin-e,s.ymin,n.xmax+e,s.ymax);if(o=new nn().execute(o,i,t,r),o.isEmpty())return o}return a===i.enumPolygon&&n.width()>s.width()*2&&(o=Ru(o,-2*s.width(),2*s.width(),t,!0,0,!0,r)),o}}function Wu(e,t,n,r,i,a){let o=r.getCoordinateSystemType();if(o===2){if(i===0)n!==e&&ft(n,e,t),yu(r,n,t);else if(n!==e&&ft(n,e,t),r.isPannable()){let e=r.getTolerance(0);bu(n,t,r.getPannableExtent(),e),Du(n,t,r,0)}}else{l(o===1);let i=r.getTolerance(0),a=r.getPannableExtent();for(let r=0;r<t;r++)n[r].assign(Vu(e[r],a,i))}}function Gu(e,t){let n=t.getPointCount();if(!n)return;let r=t.getImpl(),i=r.getAttributeStreamRef(0),a=e;wp.geogToProj(a,n,i.getArray()),r.notifyModifiedFlags(2001)}function Ku(e,t,n,r){if(!n)return;let i=e.getPECoordSys();if(n===1){if(t[0].isNAN())return;let n=[t[0].x,t[0].y];if(wp.geogToProj(i,1,n),r){let{first:r,second:i}=e.m_peCoordSysVal.getGeogToProjFactors();n[0]=r*(t[0].x-e.getCentralMeridian())+i}t[0].setCoords(n[0],n[1]);return}let a=e.isPannable(),o=a?e.getPannableExtent().width():0,s=o*179/360,c=0;a&&(c=e.getCentralMeridian());let l=new Float64Array(512);for(let u=0;u<n;){for(let e=u;e<n&&t[e].isNAN();++e)u++;let d=Math.min(256,n-u);if(d>0){for(let e=1,n=u+1;e<d;++e,++n)if(t[n].isNAN()){d=e;break}for(let e=0;e<d;++e){let n=e<<1;l[n]=t[u+e].x,l[n+1]=t[u+e].y}if(wp.geogToProj(i,d,l),r){let{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<d;++e){let i=e<<1;l[i]=n*(t[u+e].x-c)+r}}if(a)for(let e=0,n=u;e<d;e++,n++){let r=e<<1,i=l[r],a=_t(i),u=t[n].x-c;a*_t(u)<0&&Math.abs(i)>s&&(l[r]-=a*o)}wu(l,t,u,d),u+=d}}}function qu(e,t,n,r){let i=e.getSRToGCSTransform();return new Rc().transform(i,t,n,r,!1)}function Ju(e,t,n,r){let i=new A({vd:t.getDescription()});i.addPoints(t,0,-1);let a;a=new Rc().execute(i,e,r);let o=t.getPointCount();if(n.setEmpty(),e.getInputSR().isPannable()){if(o!==a.getPointCount())return!1;let r=new T;t.queryEnvelope(r);let i=new T;a.queryEnvelope(i);let s=r.width(),c=i.width();if(s!==0&&c!==0){let t=c/s,n=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/n-1)>1e-10)return!1}else if(s!==0||c!==0)return!1;n.add(t,!1);for(let e=0;e<o;e++){let t=a.getXY(e);n.setXY(e,t)}return!0}return!1}function Yu(e,t,n){l(!n||e.isPannable());let r=t.getPointCount();if(!r)return;let i=t.getImpl(),a=i.getAttributeStreamRef(0),o=e.getPECoordSys(),s=0,c=a.readRange(0,r*2),u=()=>{wp.geogToProj(o,r,c)},d=e.isPannable()&&!n,f=d?e.getPannableExtent().width():0,p=f*179/360;if(e.isPannable()&&(s=e.getCentralMeridian(),n)){let t=e.m_peCoordSysVal.getGeogToProjFactors(),n=t.first,i=t.second;u=()=>{wp.geogToProj(o,r,c);for(let e=0;e<r;e++){let t=e<<1,r=a.read(t),o=n*(r-s)+i;c[t]=o}}}if(u(),d)for(let e=0;e<r;e++){let t=e<<1,n=c[t],r=_t(n),i=a.read(t)-s;r*_t(i)<0&&Math.abs(n)>p&&(c[t]+=-r*f)}a.writeRangeFromArray(0,r*2,c,!0,1),i.notifyModifiedFlags(2001)}function Xu(e,t,n){switch(t.getGeometryType()){case i.enumLine:Cd(e,t,n);return;case i.enumBezier:kd(e,t,n);return;case i.enumEllipticArc:Td(e,t,n);return;case i.enumBezier2:Ad();return;case i.enumRationalBezier2:jd();return;default:o(``)}}function Zu(e,t,n){if(!t.hasNonLinearSegments()){Yu(e,t,n);return}if(l(!n||e.isPannable()),t.isEmpty())return;let r=e.getPECoordSys(),i=e.isPannable(),a=i?e.getPannableExtent().width():0,o=a*179/360,s=0;i&&(s=e.getCentralMeridian());let c=t.createInstance();c.reserveParts(t.getPointCount(),t.getPathCount());let u=t.getImpl(),d=new F;for(let l=0,f=t.getPathCount();l<f;++l)if(u.hasNonLinearSegmentsPath(l)){let t=!0,r=-1,i=u.getPathStart(l),a=i+u.getSegmentCountPath(l);u.isClosedPath(l)&&(r=a-1);let o=new U;for(let s=i;s<a;++s){if(u.getSegmentBuffer(s,d,!1),Xu(e,d.get(),n),t||d.get().getStartXY().equals(o)||d.get().moveTo(o),s!==r)c.addSegment(d.get(),t);else{if(t){let e=new B;d.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(d.get())}o.assign(d.get().getEndXY()),t=!1}}else{let e=1024,n=u.getPathSize(l),d=Math.min(n,e),f;c.insertPath(-1,t,l,!0);let p=u.getAttributeStreamRef(0),m=c.getAttributeStreamRef(0);for(let t=u.getPathStart(l),c=u.getPathEnd(l);t<c;){if(f=p.readRange(t,d),wp.geogToProj(r,d,f),i)for(let e=0;e<d;e++){let t=e<<1,n=f[t],r=_t(n),i=p.read(2*(0+e))-s;r*_t(i)<0&&Math.abs(n)>o&&(f[t]+=-r*a)}m.writeRangeFromArray(t,d,f,!0,1),t+=d,n-=d,d=Math.min(n,e)}}t.assignMove(c)}function Qu(e,t,n){let r=1e3,i=n.getPointCount();if(!i)return;let a=n.getImpl(),o=a.getAttributeStreamRef(0),s=Math.min(i,r),c=0,l=e.getPECoordSys();Number.isNaN(t)&&(t=0);let u=e.isPannable(),d=e.getOneDegreeGCSUnit(),f=d*360,p=d*179,m;for(;i;){if(m=o.readRange(c*2,s*2),od(l,s,m,t),u)for(let e=0;e<s;e++){let n=e<<1,r=m[n]-t,i=_t(r),a=o.read(2*(c+e));i*_t(a)<0&&Math.abs(r)>p&&(m[n]+=-i*f)}o.writeRangeFromArray(c*2,s*2,m,!0,1),c+=s,i-=s,s=Math.min(i,r)}a.notifyModifiedFlags(2001)}function $u(e,t,n){switch(n.getGeometryType()){case i.enumLine:ed(e,t,n);return;case i.enumBezier:rd(e,t,n);return;case i.enumEllipticArc:td(e,t,n);return;case i.enumBezier2:id();return;case i.enumRationalBezier2:ad();return;default:o(``)}}function ed(e,t,n){let r=[n.getStartXY(),n.getEndXY()];cd(e,t,r,2),n.setStartXY(r[0]),n.setEndXY(r[1]),n.normalizeAfterEndpointChange()}function td(e,t,n){if(n.projectionBehavior()===0)nd(e,t,n);else{let r=n.isClosed()&&n.isMajor(),i=[n.getStartXY(),r?n.getCenter():n.getEndXY()],a=[i[0].clone(),i[1].clone()];Ed(e,t,a,2);let o=new K;o.initializeFromTwoPointsArray(i,a),n.applyTransformation(o);let s=+!r;n.setCoordsForIntersector(a[0],a[s],!1)}}function nd(e,t,n){Dd(!1,e,t,n,!1)}function rd(e,t,n){let r=bt(U,4);n.queryControlPoints(r),Ed(e,t,r,4),n.setControlPoints(r)}function id(e,t,n){l(0)}function ad(e,t,n){l(0)}function od(e,t,n,r){let i=wp.projToGeogCenter(e,t,n,r);for(let e=0;e<t;++e){let t=e<<1;l(Number.isFinite(n[t]+n[t+1]))}return i}function sd(e,t,n){if(!n.hasNonLinearSegments()){Qu(e,t,n);return}if(n.isEmpty())return;let r=e.getPECoordSys();Number.isNaN(t)&&(t=0);let i=e.isPannable(),a=e.getOneDegreeGCSUnit(),o=a*360,s=a*179,c=n.createInstance();c.reserveParts(n.getPointCount(),n.getPathCount());let l=n.getImpl(),u=new F;for(let a=0,d=n.getPathCount();a<d;++a)if(l.hasNonLinearSegmentsPath(a)){let n=!0,r=-1,i=l.getPathStart(a),o=i+l.getSegmentCountPath(a);l.isClosedPath(a)&&(r=o-1);let s=new U;for(let a=i;a<o;++a){if(l.getSegmentBuffer(a,u,!1),$u(e,t,u.get()),n||u.get().getStartXY().equals(s)||u.get().moveTo(s),a!==r)c.addSegment(u.get(),n);else{if(n){let e=new B;u.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(u.get())}s.assign(u.get().getEndXY()),n=!1}}else{let e=1e3,u=l.getPathSize(a),d=Math.min(u,e),f;c.insertPath(-1,n,a,!0);let p=l.getAttributeStreamRef(0),m=c.getAttributeStreamRef(0);for(let n=l.getPathStart(a),c=l.getPathEnd(a);n<c;){if(f=p.readRange(2*n,2*d),od(r,d,f,t),i)for(let e=0;e<d;e++){let r=e<<1,i=f[r]-t,a=_t(i),c=p.read(2*n);a*_t(c)<0&&Math.abs(i)>s&&(f[r]+=-a*o)}m.writeRangeFromArray(2*n,2*d,f,!0,1),n+=d,u-=d,d=Math.min(u,e)}}n.assignMove(c)}function cd(e,t,n,r){let i=e.getPECoordSys();Number.isNaN(t)&&(t=0);let a=e.isPannable(),o=e.getOneDegreeGCSUnit(),s=o*360,c=o*179,l=new Float64Array(512);for(let e=0;e<r;){for(let t=e;t<r&&n[t].isNAN();++t)e++;let o=Math.min(256,r-e);if(o>0){for(let t=1,r=e+1;t<o;++t,++r)if(n[r].isNAN()){o=t;break}for(let t=0;t<o;t++){let r=t<<1;l[r]=n[e+t].x,l[r+1]=n[e+t].y}if(od(i,o,l,t),a)for(let r=0,i=e;r<o;++r,++i){let e=r<<1,a=n[i].x,o=l[e]-t,u=_t(o);u*_t(a)<0&&Math.abs(o)>c&&(l[e]-=u*s)}for(let t=0;t<o;t++){let r=t<<1;n[e+t].x=l[r],n[e+t].y=l[r+1]}e+=o}}}function ld(e,t,n,r){l(0)}function ud(e,t,n){let r=t.getPointCount();if(!r)return!1;let i=t.getImpl(),a=i.getAttributeStreamRef(0),o=null,s=e.getInputSR(),c=e.getOutputSR();s.getVCS(),c.getVCS();let l=s.getOneDegreeGCSUnit(),u=c.getOneDegreeGCSUnit(),d=e.isVertical();d&&t.hasAttribute(1)&&(o=i.getAttributeStreamRef(1));let f=e.getDatumTransformation(),p=f?f.getType()===1:!1;if(!p&&o!==null&&(ld(o.getArray()),o=null),!f||f.count()===0){let e=s.getGcsUnitFactor()/c.getGcsUnitFactor(),t=(s.getPrimeMeridian()-c.getPrimeMeridian())*u,n=l*-90,o=l*90,d=0,f=a.getArray(),p=[0];for(let e=1,t=r*2;e<t;)p[0]=f[e],d|=+!!Jt(p,n,o),f[e]=p[0],e+=2;if(t!==0||e!==1){d=1;let n=a.getArray();for(let i=0,a=r*2;i<a;){let r=n[i];r*=e,r+=t,n[i]=r,n[i+1]*=e,i+=2}}return d!==0&&i.notifyModifiedFlags(2001),!!d}let m=1e3,h=Math.min(r,m),g=H(h,NaN),_=H(h,NaN),v=null;o!==null&&(v=new Float64Array(h));let y=0,b=NaN,x=NaN,S=u*360,C=u/l;n&&(x=u*90,b=l*89.9,_.fill(0));let w=!0,T=0;for(;r;){let e=!1,t=a.readRange(y*2,h*2);for(let e=0;e<h;e++)g[e]=t[e<<1];if(n)for(let n=0;n<h;n++){let r=(n<<1)+1,i=Math.abs(t[r])-b;if(i>0){let a=t[r];t[r]=Mt(b,a),_[n]=Mt(i,a),e=!0}}let i=t[0];if(p){let e=f;v&&o.queryRange(y,h,v,!0,1),e.transform(!1,t,v,h),v&&o.writeRangeFromArray(y,h,v,!0,1)}else f.transform(!1,t,h);w&&=(T=t[0]-C*i,!1);for(let e=0;e<h;e++){let n=e<<1,r=t[n]-g[e]*C-T;Math.abs(r)>200&&(r>0?t[n]+=-S:t[n]+=S)}if(e){for(let e=0;e<h;e++)if(_[e]){let n=(e<<1)+1;t[n]+=C*_[e],t[n]>x?t[n]=x:t[n]<-x&&(t[n]=-x)}_.fill(0)}a.writeRangeFromArray(y*2,h*2,t,!0,1),d&&o&&o.writeRangeFromArray(y,h,v,!0,1),y+=h,r-=h,h=Math.min(r,m)}return i.notifyModifiedFlags(2001),!0}function dd(e,t,n){switch(t.getGeometryType()){case i.enumLine:return _d(e,t,n);case i.enumBezier:return bd(e,t,n);case i.enumEllipticArc:return vd(e,t,n);case i.enumBezier2:return xd();case i.enumRationalBezier2:return Sd();default:o(``)}}function fd(e,t,n){if(!t.hasNonLinearSegments())return ud(e,t,n);if(t.isEmpty())return!1;let r=t.createInstance();r.reserveParts(t.getPointCount(),t.getPathCount());let i=t.getImpl(),a=new F;for(let o=0,s=t.getPathCount();o<s;++o){let t=!0,s=-1,c=i.getPathStart(o),l=c+i.getSegmentCountPath(o);i.isClosedPath(o)&&(s=l-1);let u=new U;for(let o=c;o<l;++o){if(i.getSegmentBuffer(o,a,!1),dd(e,a.get(),n),t||a.get().getStartXY().equals(u)||a.get().moveTo(u),o!==s)r.addSegment(a.get(),t);else{if(t){let e=new B;a.get().queryStart(e),r.startPathPoint(e)}r.closeLastPathWithSegment(a.get())}u.assign(a.get().getEndXY()),t=!1}}return t.assignMove(r),!0}function pd(e,t,n,r,i,a){if(e.isIdentityGeogToGeog()){let n=e.getInputSR().getOneDegreeGCSUnit()*90,i=0,a=[0];for(let e=0;e<r;e++)a[0]=t[e].y,i|=+!!Jt(a,-n,n),t[e].y=a[0];return i}let o=e.getInputSR(),s=e.getOutputSR(),c=o.getVCS(),l=s.getVCS(),u=o.getOneDegreeGCSUnit(),d=u*90,f=s.getOneDegreeGCSUnit(),p=e.isVertical(),m=e.getDatumTransformation(),h=m?m.getType()===1:!1;if(p||(n=null),!m||m.count()===0){let e=0,i=[0];for(let n=0;n<r;n++)i[0]=t[n].y,e|=+!!Jt(i,-d,d),t[n].y=i[0];return e|=+!!Rl(o.getGCS(),c,s.getGCS(),l,t,n,r),e}!h&&n!==null&&ld();let g=1024,_=Math.min(r,g),v=H(_,NaN),y=H(_,NaN),b=0,x=NaN,S=NaN,C=f*360,w=f/u;i&&(S=f*90,x=u*89.9);let T=!0,E=0,D=r;for(;D;){let e=!1;for(let e=0;e<_;e++)v[e]=t[e+b].x;if(i)for(let n=0;n<_;n++){let r=Math.abs(t[n+b].y)-x;if(r>0){let i=t[n+b].y;t[n+b].y=Mt(x,i),y[n]=Mt(r,i),e=!0}}let r=t[0].x;h?m.transform(!1,t,n,_):m.transform(!1,t,_),T&&=(E=t[0].x-w*r,!1);for(let e=0;e<_;e++){let n=t[b+e].x-v[e]*w-E;Math.abs(n)>200&&(n>0?t[b+e].x-=C:t[b+e].x+=C)}if(e){for(let e=0;e<_;e++)y[e]&&(t[b+e].y+=w*y[e],t[b+e].y>S?t[b+e].y=S:t[b+e].y<-S&&(t[b+e].y=-S));y.fill(0,0,_)}b+=_,D-=_,_=Math.min(D,g)}return 1}function md(e,t,n,r,i){return l(0),0}function hd(e,t,n,r,i){l(r===null),l(t<2147483647);let a=Array.isArray(n),o;o=a?Bt(n):n;let s=Tp.geogToGeog(e,t,o,null,i);return a&&Vt(o,n),s}function gd(e,t,n,r,i,a){let o=0,s=!0,c=0;for(let a=0;a<r;++a)t[a].isNAN()?s||=(o|=pd(e,t.slice(c,a-c),n?n.slice(c,a-c):null,a-c,i),c=a,!0):s&&=(c=a,!1);return s||(o|=pd(e,c===0?t:t.slice(c),n?c===0?n:n.slice(c):null,r-c,i)),o!==0}function _d(e,t,n){let r=[t.getStartXY(),t.getEndXY()],i=[0,0],a=null;t.hasAttribute(1)&&(a=i,a[0]=t.getAttributeAsDbl(0,1,0),a[1]=t.getAttributeAsDbl(1,1,0));let o=gd(e,r,a,2,n);return t.setStartXY(r[0]),t.setEndXY(r[1]),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,a[1])),t.normalizeAfterEndpointChange(),o}function vd(e,t,n){if(t.projectionBehavior()===0)return yd(e,t,n);let r=t.getStartXY().equals(t.getEndXY()),i=bt(U,3),a=bt(U,3),o=[0,0,0],s=null;i[0].assign(t.getStartXY()),i[1].assign(r?t.getCenter():t.getEndXY());let c=!1;t.hasAttribute(1)&&(s=o,s[0]=t.getAttributeAsDbl(0,1,0),s[1]=t.getAttributeAsDbl(1,1,0),s[2]=Ct(s[0],s[1],.5),r&&(s[1]=s[2])),a[0].setCoordsPoint2D(i[0]),a[1].setCoordsPoint2D(i[1]);let l=new K;if(r||t.isDegenerateToLine())c=gd(e,a,s,2,n),l.initializeFromTwoPoints(i[0],i[1],a[0],a[1]);else{let r=new U;t.queryCoord2D(.5,r),i[2].setCoordsPoint2D(r),a[2].setCoordsPoint2D(r),c=gd(e,a,s,3,n),l.setFromTwoTriangles(i,a)}return l.isIdentity()||(t.applyTransformation(l),t.setStartXY(a[0]),t.setEndXY(r?a[0]:a[1]),t.normalizeAfterEndpointChange()),s&&(t.setStartAttribute(1,0,s[0]),t.setEndAttribute(1,0,r?s[0]:s[1])),c}function yd(e,t,n){let r=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()],i=4;t.isDegenerateToLine()&&(i=2);let a=[0,0,0,0],o=null;if(t.hasAttribute(1)){o=a,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);let e=Ct(o[0],o[1],.5);o[2]=e,o[3]=e}let s=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),c=gd(e,r,o,i,n);return s?t.constructCircleCenterAndPoint(r[3],r[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(r[0],r[1]):t.constructCircularArcThreePoint(r[0],r[1],r[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),c}function bd(e,t,n){let r=bt(U,4);t.queryControlPoints(r);let i=[0,0,0,0],a=null;t.hasAttribute(1)&&(a=i,a[0]=t.getAttributeAsDbl(0,1,0),a[3]=t.getAttributeAsDbl(1,1,0),a[1]=Ct(a[0],a[3],.5),a[2]=a[1]);let o=gd(e,r,a||null,r.length,n);return t.setControlPoints(r),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,a[3])),t.normalizeAfterEndpointChange(),o}function xd(e,t,n){return l(0),!1}function Sd(e,t,n){return l(0),!1}function Cd(e,t,n){let r=[t.getStartXY(),t.getEndXY()];Ku(e,r,2,n),t.setStartXY(r[0]),t.setEndXY(r[1]),t.normalizeAfterEndpointChange()}function wd(e,t,n,r){Ku(e,t,n,r)}function Td(e,t,n){if(t.projectionBehavior()===0)Od(e,t,n);else{let r=t.isClosed()&&t.isMajor(),i=[t.getStartXY(),r?t.getCenter():t.getEndXY()],a=[i[0].clone(),i[1].clone()];wd(e,a,2,n);let o=new K;o.initializeFromTwoPointsArray(i,a),t.applyTransformation(o);let s=+!r;t.setCoordsForIntersector(a[0],a[s],!1)}}function Ed(e,t,n,r){cd(e,t,n,r);let i=new T;i.setFromPoints(n,r);let a=e.getOneDegreeGCSUnit(),o=a*360,s=a*180;if(i.width()>s){for(let e=0;e<r;e++)for(;n[e].x<t;)n[e].x+=o;if(i.setFromPoints(n,r),i.xmax>s+t)for(let e=0;e<r;e++)n[e].x-=o}}function Dd(e,t,n,r,i){let a=bt(U,3),o=0,s=!1,c=!1,l=r.isDegenerateToLine();if(l?(a[0].assign(r.getStartXY()),a[1].assign(r.getEndXY()),a[2].setCoords(0,0),o=2):r.isClosed()&&r.isMajor()?(s=!0,c=!r.isClockwise(),a[0].assign(r.getStartXY()),a[1].assign(r.getCenter()),a[2].setCoords(0,0),o=2):(a[0].assign(r.getStartXY()),a[1].assign(r.getEndXY()),a[2].assign(r.getInteriorPoint()),o=3),e?wd(t,a,o,i):Ed(t,n,a,o),l){r.constructLineCircularArc(a[0],a[1]);return}if(s){r.constructCircleCenterAndPoint(a[1],a[0],c);return}r.constructCircularArcThreePoint(a[0],a[1],a[2])}function Od(e,t,n){Dd(!0,e,0,t,n)}function kd(e,t,n){let r=bt(U,4);t.queryControlPoints(r),wd(e,r,4,n),t.setControlPoints(r)}function Ad(e,t,n){l(0)}function jd(e,t,n){l(0)}function Md(e,t,n){let r=we(e),i=we(t),a=Ce(r,i),o=Ce(r,we(n));return o===0||a>0&&o>0&&o<=a||a<0&&o<0&&o>=a}function Nd(n,r,i,a,o){let s={stack:[],error:void 0,hasError:!1};try{let t=i.clone(),c=a.clone();if(o===2){let e=[0,0];return Ln(n,r,t,c,0,e),e[0]}if(t.y>c.y){let e=new U;e.assign(t),t.assign(c),c.assign(e)}let u=e(s,new Sp,!1),d=e(s,new Sp,!1),f=e(s,new Sp,!1),p=new W;if(p.setCoords(t.y,c.y),!p.containsCoordinate(0)||Math.abs(t.x-c.x)>=Math.PI)return NaN;if(t.x===c.x)return t.x;kp.geodeticDistance(n,r,t.x,t.y,c.x,c.y,d,u,null,o);let m=d.val,h=0,g=1,_=t.clone();for(;m*(g-h)>n*1e-12;){let e=.5*(h+g);if(kp.geodeticCoordinate(n,r,t.x,t.y,m*e,u.val,d,f,o),_.x=d.val,_.y=f.val,p.setCoords(t.y,_.y),_.y===0)return _.x;if(p.containsCoordinate(0))g=e;else if(p.setCoords(c.y,_.y),p.containsCoordinate(0))h=e;else return l(!1),NaN}return _.x}catch(e){s.error=e,s.hasError=!0}finally{t(s)}}function Pd(e,t,n,r){let i=new W;i.setCoords(t,n);let a=r.width(),o=Math.floor((e-t)/a)*a+e,s=i.getCenter();for(;Math.abs(o-s)>Math.abs(o+a-s);)o+=a;return o}class Fd extends on{m_geometryDeque=[];m_index=-1;constructor(){super()}next(){if(this.m_geometryDeque.length>0){this.m_index++;let e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}function Id(e,t){return e===t?!0:e===null||t===null||e.m_csType!==t.m_csType?!1:e.m_WKID===0&&t.m_WKID===0?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID}function Ld(e,t){return e===t?!0:e===null||t===null||e.m_csType!==t.m_csType?!1:e.m_WKID===0&&t.m_WKID===0?e.m_csType===1?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID}class Rd{m_csType;m_PCSHorizon=null;m_GCSHorizon=null;m_GCSSplitLines=null;m_bGCSHorisonIsInclusive=!1;m_oneMeterPCS=0;m_oneDegreeGCS=0;m_gcsUnitFactor=0;m_northPole=U.getNAN();m_southPole=U.getNAN();m_polesUpdated=0;m_domain=T.constructEmpty();m_primeMeridian=NaN;m_geogToProjFactor=1;m_geogToProjOffset=0;m_geogToProjFactorsUpdated=0;m_oneMillimeter=0;m_centralMeridian=0;m_pPCSInfoNoDomain=null;m_WKID;m_oldWKID=-1973;m_vcsWKID=-1;m_bIsPannable=!1;m_bCached=!1;m_pannableExtent=T.constructEmpty();m_pannableExtentGCS=T.constructEmpty();m_unit;m_areaOfUse=null;m_canonicalWkt=``;m_hashCode;m_peCoordSys;constructor(e,t=!0){this.m_peCoordSys=e,this.m_WKID=Q.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=pu(e,0,!0),this.m_hashCode=Ot(this.m_canonicalWkt)):this.m_hashCode=Pt(this.m_WKID);let r=this.m_peCoordSys.getType();this.m_csType=r===$.PE_TYPE_PROJCS?2:1,l(r===$.PE_TYPE_PROJCS||r===$.PE_TYPE_GEOGCS),r===$.PE_TYPE_PROJCS&&(e.loadConstants()||n(`PeProjcs.loadConstants failed`));let i=r===$.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();r!==$.PE_TYPE_GEOGCS&&Q.getCode(i),this.m_unit=hn(e),this.m_primeMeridian=i.getPrimem().getLongitude();{let e=i.getUnit().getUnitFactor();this.m_gcsUnitFactor=e;let t=Math.PI/(180*e);Math.abs(t-1)<1e-10&&(t=1),this.m_oneDegreeGCS=t}if(r===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=Ep.generate(e,Ep.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||o(`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;let e=1/i.getUnit().getUnitFactor(),t=i.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/t*e,this.m_centralMeridian=0}this.m_bIsPannable&&(this.updateGCSHorizon(),this.updatePCSHorizon(),this.updatePoles(),this.updateDomain(),this.updatePannableExtent(),this.updatePannableExtentGCS())}[Symbol.dispose](){}getHashCode(){return this.m_hashCode}getPCSHorizonPannable(){return this.m_PCSHorizon}getGCSHorizonPannable(){return this.m_GCSHorizon}getPCSInfo(){return l(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==$.PE_TYPE_PROJCS)return;let e=!0,t=this.m_peCoordSys,n=t.getGeogcs(),r=t.horizonGcsGenerate();if(!r)return;l(r.length>0);let i=r[0].getNump(),a=r[0].getKind(),o;e=r[0].getInclusive()>0;let s,c=this.getOneDegreeGCSUnit(),u=c*90,d=c*180,f=c*360,p=c*370,m=d*$.PE_HORIZON_DELTA/Math.PI,h=T.constructEmpty(),g=null;if(i>1){for(let e=1;e<i;e++)if(r[e].getKind()===$.PE_HORIZON_LINE){g||=new E;let t=r[e].getCoord();g.startPathCoords(t[0][0],t[0][1]),g.lineToCoords(t[1][0],t[1][1])}}if(a===$.PE_HORIZON_RECT){let t=r[0].getCoord();if(h.setFromPoints([new U(t[0][0],t[0][1]),new U(t[1][0],t[1][1])],2),Math.abs(h.ymax-u)<m*1e-7&&(h.ymax=u),Math.abs(h.ymin+u)<m*1e-7&&(h.ymin=-u),h.width()>p){let e=-400*c,t=e+5*f;h.setCoords({xmin:e,ymin:h.ymin,xmax:t,ymax:h.ymax})}let n=new Me({env2D:h});this.m_GCSHorizon||(this.m_GCSHorizon=n,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap(),a=Uf(n,null,null,1),d=[],p=new W;for(let e=0;e<i;e++){if(r[e].getKind()!==$.PE_HORIZON_POLY)continue;o=r[e].getSize();let t=r[e].getCoord(),n=T.constructEmpty();n.setFromPoints(Ft(t),o),d.push(new W(n.xmin,n.xmax)),n.width(),p.merge(d.at(-1))}let m=!1,h=new W;p.width()>f&&d.length>1?(h.vmin=this.getCentralMeridian()-f,h.vmax=h.vmin+f*2,m=!0,t=!0):(h.vmin=p.vmin,h.vmax=h.vmin+f);let _=e=>{let t=0;for(;d[e].vmin+t<h.vmin;)t+=f;for(;d[e].vmax+t-f>h.vmin;)t-=f;return t},v=new k;if(t){let e=new Fd,t=new ou().executeMany(e,a,null);for(let n=0;n<i;n++){if(r[n].getKind()!==$.PE_HORIZON_POLY)continue;o=r[n].getSize();let i=r[n].getCoord();s=r[n].getInclusive()>0;let a=new k;if(a.addPathPoint2D(Ft(i),o-1,!0),!m)e.tick(a),t.tock();else{let t=_(n),r=d[n].clone();r.move(t);let i=t,o=new K;do{o.setShiftCoords(i,0);let t=a.clone();t.applyTransformation(o),e.tick(t),e.tock(),i+=f,r.move(f)}while(r.vmin<h.vmax)}}v=t.next()}else{v=new k;for(let t=0;t<i;t++){if(r[t].getKind()!==$.PE_HORIZON_POLY)continue;o=r[t].getSize();let n=r[t].getCoord();if(s=r[t].getInclusive()>0,l(s===e),!m)v.addPathPoint2D(Ft(n),o-1,!0);else{let e=new k;e.addPathPoint2D(Ft(n),o-1,!0);let r=_(t),i=d[t].clone();i.move(r);let a=r,s=new K;do{if(a!==0){s.setShiftCoords(a,0);let t=new k({copy:e});t.applyTransformation(s),v.addPath(t,0,!0)}else v.addPath(e,0,!0);a+=f,i.move(f)}while(i.vmin<h.vmax)}}}m&&(v=new nn().execute(v,new T(h.vmin,-u-c,h.vmax,u+c),a,null)),e?new Ec().accelerateGeometry(v,a,1):new Yl().accelerateGeometry(v,a,1),new du().accelerateGeometry(v,a,1),this.m_GCSHorizon===null&&(this.m_GCSHorizon=v,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=g)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==$.PE_TYPE_PROJCS)return;let e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();let n=e[0].getKind();e[0].getInclusive();let r=T.constructEmpty(),i=e[0].getNump(),a=!1;if(n===$.PE_HORIZON_RECT){let n=e[0].getCoord();r.setFromPoints(Ft(n),2),t=new Me({env2D:r})}else{let n=-1;for(let t=0;t<i;t++)e[t].getKind()===$.PE_HORIZON_POLY&&(n=t);l(n>=0);let r=e[n].getSize()-1,o=e[n].getCoord(),s=new k;t=s,s.addPathPoint2D(Ft(o),r,!0),a=!0}if(this.getPCSInfo().isDensificationNeeded()){l(n!==$.PE_HORIZON_RECT);let e=1e5*this.getOneMeterPCSUnit();t=new an().execute(t,e,0,0,null)}if(a){{let e=new Me;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}new Ec().accelerateGeometry(t,null,1)}this.m_PCSHorizon===null&&(this.m_PCSHorizon=t)}updatePannableExtent(){let e=this.m_peCoordSys.getType();if(e===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),n=e.getGeogcs();n||o(``);let r=[t+1/n.getUnit().getUnitFactor()*Math.PI,0];wp.geogToProj(e,1,r);let i=r[0],a=e.getParameters()[$.PE_PARM_X0].getValue(),s=this.getPCSHorizon(),c=T.constructEmpty();s.queryEnvelope(c);let l=Math.abs(i-a),u=-1*l,d=l+a,f=u+a,p=c.ymax,m=c.ymin;this.m_pannableExtent.setCoords({xmin:f,ymin:m,xmax:d,ymax:p})}else if(e===$.PE_TYPE_GEOGCS){let e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o(``)}updatePannableExtentGCS(){let e=this.m_peCoordSys.getType();if(e===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=this.m_centralMeridian,n=e.getGeogcs();n||o(``);let r=1/n.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),a=T.constructEmpty();i.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:t-r,ymin:a.ymin,xmax:t+r,ymax:a.ymax})}else if(e===$.PE_TYPE_GEOGCS){let e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o(``)}updateDomain(){if(this.m_csType===1){let e=400*this.getOneDegreeGCSUnit();this.m_domain=T.construct(-e,-e,e,e)}else{l(this.m_csType===2);let e=Ep.generate(this.m_peCoordSys,Ep.PE_PCSINFO_OPTION_DOMAIN);e||o(`generate pcs info failed`);let t=new T(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===$.PE_TYPE_PROJCS){let e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];wp.geogToProj(this.m_peCoordSys,2,t);let n=this.getPCSInfo().getNorthPoleLocation()!==Ep.PE_POLE_OUTSIDE_BOUNDARY,r=this.getPCSInfo().getSouthPoleLocation()!==Ep.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||=(n&&this.m_northPole.setCoords(t[0][0],t[0][1]),r&&this.m_southPole.setCoords(t[1][0],t[1][1]),1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===$.PE_TYPE_PROJCS){let e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),n=[0,0,0,0];n[0]=t,n[1]=0,n[2]=t+e,n[3]=0;let r=wp.geogToProj(this.m_peCoordSys,2,n);l(r===2);let i=(n[2]-n[0])/e,a=n[0];this.m_geogToProjFactorsUpdated===0&&(this.m_geogToProjFactor=i,this.m_geogToProjOffset=a,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():(this.m_GCSHorizon===null&&this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(this.m_PCSHorizon===null&&this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(e){return this.m_bIsPannable||this.m_polesUpdated!==0||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return this.m_geogToProjFactorsUpdated===0&&this.updateGeogToProjFactors(),yt(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){let t=[0];Ip(this.m_peCoordSys.getType(),this.m_WKID,t,[0])||o(`query_code_change`),e=t[0]}this.m_oldWKID=e}return e}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return this.m_areaOfUse===null?this.updateAreaOfUse():this.m_areaOfUse}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}class zd{m_oneMeter=0;m_WKID=-1;m_oldWKID=-1;m_canonicalWkt=`not yet implemented`;m_model=0;m_unit=new Tf;m_cached=!1;m_peVertcs;static st_DeadWeedCount;constructor(e,t=!0){}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function Bd(e,t,n){return Vd(e,t,T.constructEmpty())}function Vd(e,t,n,r){return Ud(!0,e,t,n)}function Hd(e,t,n,r){return Wd(!0,e,t,n,r)}function Ud(e,t,n,r,i){return Rf()||v(`cannot create projection transformation`),t.hasVCS()&&n.hasVCS()?qd():Jd(t,n,r)}function Wd(e,t,n,r,i,a){return Rf()||v(`cannot create projection transformation`),new $d(e?2:1,t,n,r,i,a)}function Gd(e,t,r,i,a,o=!1){if((!t||!r)&&n(``),Rf()||v(`cannot obtain geotransformation list`),e===1&&t.hasVCS()&&r.hasVCS())return p(`hv xform not impl`),[];{let e=Jp(t,r,i,a,o),n=[];for(let t of e)n.push(t);return n}}function Kd(){return{centralMeridianOfOutputGCS:NaN,densificationStep:NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return mt(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&mt(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function qd(e,t,n,r){return l(0),{}}function Jd(e,t,r,i){(!e||!t)&&n(`!inputSR || !outputSR`);let a=e.getLatestID(),o=t.getLatestID();if(a===3857&&o===4326){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return mf()}else if(a===4326&&o===3857&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return gf();let s=T.constructEmpty();s.setCoords({env2D:r});let c=e.getCoordinateSystemType(),l=t.getCoordinateSystemType();if(c===0||l===0)return Yd(e,t);let u=e.getGCS().getLatestID(),d=t.getGCS().getLatestID();if(u>0&&u===d)return Yd(e,t);let f=new lf(e,t,r);{let e=df(f);if(e)return e}let p=Gd(0,e,t,s,1,!0);return ff(f,Yd(e,t,p.length?p[0]:void 0))}function Yd(e,t,n,r,i){return new $d(1,e,t,n,r,i)}function Xd(){return{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return(this.flagsMask&e)!==0}}}function Zd(){return{m_extendedParams:Kd(),m_extendedParamsInternal:Xd()}}function Qd(){return Zd()}class $d{m_inputSR;m_outputSR;m_datumTran=null;m_params;m_bIdentity=!0;m_bIdentityGeogToGeog=!0;m_bVertical=!1;m_bNormalize=!1;m_projector;constructor(e,t,r,i,a,o){(!t||!r)&&n(`!inputSR || !outputSR`),i&&i.getType()===0&&(i.m_bReadOnly=!0),this.m_bNormalize=!1;let s,c;e!==1&&(s=t.getVCS(),c=r.getVCS(),this.m_bVertical=s!=null&&c!=null),this.m_inputSR=t,this.m_outputSR=r,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,l(!this.m_params),a&&(this.m_params=Zd(),this.m_params.m_extendedParams=a),o&&(this.m_params||=Zd(),this.m_params.m_extendedParamsInternal=o);let u=!1,d=i!=null,f=t.getCoordinateSystemType(),p=r.getCoordinateSystemType();if(r.isPannable()&&f!==0&&a){let e=a.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&r.isPannable()){let t=r.getPannableExtent(),n=t.getCenterX();if(n!==e){let r=Math.ceil(t.width());e+r!==n+r&&(u=!0)}}}let m=a&&a.normalizeResultGeometry;if(t.equals(r)){this.m_bIdentity=!u,this.m_bIdentityGeogToGeog=!0,this.updateProjector();return}let h=!d&&t.equalForProjection(r,this.m_bVertical);this.m_bIdentity=h&&!u,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:f!==0&&p!==0&&(m&&this.m_outputSR.isPannable()&&(this.m_bNormalize=m),this.m_datumTran=i||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||this.m_datumTran.count()===0)&&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(){let e=new $d(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:Qd().m_extendedParams}equals(e){return l(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return l(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:Qd().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:Qd().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new Fc(this)}}const ef=new Map,tf=new Map,nf=new Map;function rf(e){let t=e.getCode();if(t>0)return wf(t)||Cf(Q.coordsys(t));let n=e.getName();if(tf.has(n)){let t=tf.get(n);if(t&&t.deref()){let n=t.deref();if(n.m_peCoordSys.isEqual(e))return n}}return t=Q.getCode(e),Cf(t>0?Q.coordsys(t):e)}function af(e){e<=0&&g(e);{let t=wf(e);if(t)return t}let t=Cp(Q.coordsys(e));t.get()||g(e);let n=Cf(t.release());return n.getLatestID()!==e&&ef.set(e,new WeakRef(n)),n}function of(e){let t=new zd({},!0);return t.m_WKID=e,t}function sf(e){let t=Cp(Q.fromString($.PE_TYPE_COORDSYS,e));return t.get()||_(e),rf(t.release())}function cf(e){tf.delete(e.m_peCoordSys.getName()),nf.delete(pu(e.m_peCoordSys,0,!1))}class lf{m_inputSR;m_outputSR;m_env;m_hashCode=-1;constructor(e,t,n){e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=n.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=ct(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.xmin)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.xmax)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.ymin)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR?!1:this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR)}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const uf=new Map;function df(e){if(uf.has(e.getHashCode()))return uf.get(e.getHashCode())}function ff(e,t){return uf.set(e.getHashCode(),t),t}let pf;function mf(){return pf||=Hd(op(),up()),pf}let hf;function gf(){return hf||=mf().getInverse(),hf}let _f;function vf(){return _f||=Q.unit(9001),_f}function yf(e){return Cp(Q.coordsys(e)).get()!==null}const bf=new Map;function xf(e){if(bf.has(e))return bf.get(e);{let t=yf(e);return bf.set(e,t),t}}function Sf(e){return!1}function Cf(e){let t=Cp(e),n=e.getCode();if(n>0){let e=wf(n);if(e)return e}let r=e.getName(),i=tf.get(r);if(i){let t=i.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}let a=new Rd(t.release());if(n>0)return a.setCached(),ef.set(n,new WeakRef(a)),tf.set(r,new WeakRef(a)),a;let o=pu(e,0,!1);if(i=nf.get(o),i){let e=i.deref();if(e)return e}return a.setCached(),nf.set(o,new WeakRef(a)),a}function wf(e){let t=ef.get(e);if(t)return t.deref()}class Tf extends ln{constructor(e){if(e===void 0){super(),this.m_wkid=9001,this.m_peUnit=null;return}if(typeof e==`number`){super(),this.m_factor=e,this.m_wkid=0;return}super(e),e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=vf())}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const Ef=`0123456789bcdefghjkmnpqrstuvwxyz`.split(``);function Df(e,t,n){let r=H(t,`R`),i=0,a=0;for(let n=0;n<t;n++){let o=e[i]>>a&31;if(a+=5,a>31){let t=37-a;o&=(1<<t)-1,a-=32,i++,o|=(e[i]&(1<<a)-1)<<t}let s=Ef[o];r[t-1-n]=s}return n>t?r.push(...`0`.repeat(n-t)):n<t&&(r.length=n),r.join(``)}function Of(e,t,n,r,i){l(r>>5<i.length);let a=t,o=n;for(let t=r;t>=0;t-=2){let n=t&31,r=t>>5,s=(o+a)*.5;e>=s?(i[r]|=1<<n,a=s):o=s}}let kf=new Set;const Af=2147483645n,jf=9007199254740990n,Mf=`operation is not supported for unknown coordinate systems`;var Nf;(function(e){e[e.utmDefault=0]=`utmDefault`,e[e.utmNorthSouth=1]=`utmNorthSouth`})(Nf||={});function Pf(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return this.e2===0}}}function Ff(e,t,n){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-n),e.e2=n*(2-n),e.flattening=n}function If(e){if(Q)return;Fp(e);let t=kf;kf=null,t.forEach(e=>{let t=e.deref();t&&t.attachToPe()})}function Lf(e){Pp(e)}function Rf(){return!!Q}function zf(){return!!Mp}function Bf(){return!!Q||!!Mp}function Vf(e,t,n){return l(Bf()),hp(e,t===void 0?0:t,null,!1)}function Hf(e,t){l(Bf());let n=new rp,r;return Rf()?(r=sf(e),n.setHorzProj_(r),n.m_vertcs=null,n.m_userWKID=r.getLatestID()):(r=Np(e),n.m_unit=r.isPCS?new Tf(r.metersOrRadiansPerUnit):new fn(r.metersOrRadiansPerUnit)),fp(n.m_precisionDescriptor,r,null,1),n.m_bDefaultDescriptor=!0,n.m_userWKT=e,n.calculateHashCode(),n.initDbgName(),n}function Uf(e,t,n,r,i=!0){let a=null;return t&&(a=Ml(t,i)),Wf(e,a,n,r,i)}function Wf(e,t,r,i,a){e||n(`!PE_coord_sys`);let o=new rp,s;return s=a?rf(e):new Rd(e,!1),fp(o.m_precisionDescriptor,s,t,i),o.m_bDefaultDescriptor=!0,o.setHorzProj_(s),o.m_vertcs=t,o.m_userWKID=s.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Gf(e,t,r=!1){e.getCoordinateSystemType()===3&&n(`image spatial reference cannot be altered`);let i=new rp,a=e;return i.m_peCoordSysVal=a.m_peCoordSysVal,i.m_vertcs=a.m_vertcs,i.m_unit=a.m_unit,i.m_precisionDescriptor.assign(t),i.m_localZToXYFactor=a.m_localZToXYFactor,(Number.isNaN(i.m_precisionDescriptor.m_falseX)||Number.isNaN(i.m_precisionDescriptor.m_falseY))&&(i.m_precisionDescriptor.m_falseX=a.m_precisionDescriptor.m_falseX,i.m_precisionDescriptor.m_falseY=a.m_precisionDescriptor.m_falseY),i.m_precisionDescriptor.snapPrecision(),i.m_precisionDescriptor.fixTolerance(),i.m_userWKID=a.m_userWKID,i.m_bDefaultDescriptor=i.m_precisionDescriptor.equals(a.m_precisionDescriptor)?a.m_bDefaultDescriptor:!1,r&&(i.m_bDefaultDescriptor=!0),i.calculateHashCode(),i.initDbgName(),i}function Kf(e,t,n){return{}}function qf(e,t,r){t===void 0&&(t=1),(t<=0||!Number.isFinite(t))&&n(``),!e&&t!==1&&n(`null Unit has to have z_to_xy_factor equal to 1`);let i=new rp;i.m_unit=e;let a=e||new Tf(9001);return mp(i.m_precisionDescriptor,a,null,1),i.m_bDefaultDescriptor=!0,Number.isNaN(i.m_precisionDescriptor.m_falseX)&&n(`NAN false X/Y are not allowed here`),i.m_localZToXYFactor=t,i.calculateHashCode(),i.initDbgName(),i}function Jf(e,t){return e.snapGeometry(t)}function Yf(e){let t=e.getCoordinateSystemType();return t===1?e:(t===3&&l(0),e.getGCS())}function Xf(e){return l(Bf()),zf()?Lp(e):xf(e)}function Zf(n){if(Rf()){let r={stack:[],error:void 0,hasError:!1};try{return e(r,Q.fromString($.PE_TYPE_COORDSYS,n,!0),!1)!==null}catch(e){r.error=e,r.hasError=!0}finally{t(r)}}try{return Np(n),!0}catch{}return!1}let Qf;function $f(){return Qf||=(()=>{let e=Math.trunc(Math.random()*Ut()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})(),Qf}let ep=0;function tp(e=``){let t=`${$f()}${ep++}`;return e!==``&&(t+=`|${e}`),t}function np(e){return e.startsWith($f())}class rp{m_vertcs=null;m_peCoordSysVal=null;m_unit;m_userWKID=0;m_userWKT=null;m_geogSpatialReference=null;m_srToGcs=null;m_gcsToSr=null;m_defaultPrecisionSR=null;m_localZToXYFactor=-1;m_precisionDescriptor=new ip;m_hashCode=0;m_bDefaultDescriptor=!1;destroy(){cf(this.m_peCoordSysVal),this.getCoordinateSystemType()===1||this.getCoordinateSystemType()===2?this.getPECoordSys().destroy():o(`SpatialReference.destroy`)}constructor(){dp(this.m_precisionDescriptor),kf&&kf.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Vf(this.m_userWKID):Hf(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(this.getCoordinateSystemType()===1)return Hd(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;let n=this.getGCS(),r=this;t=e?Hd(r,n,null):Hd(n,r,null);let i=t;return(e?this.m_srToGcs:this.m_gcsToSr)||(e?this.m_srToGcs=i:this.m_gcsToSr=i,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal(),t=this.getHashCodeVertical(),n=this.m_precisionDescriptor.getHashCode();e=ct(e,t),this.m_hashCode=ct(e,n)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),this.getCoordinateSystemType()===1?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){let e=this.getPECoordSys();if(e)switch(e.getType()){case $.PE_TYPE_GEOGCS:return 1;case $.PE_TYPE_PROJCS:return 2;default:return 0}else if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Tf)return 2;else if(this.m_unit instanceof fn)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 p(`vcs not implemented`),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return p(`vcs not implemented`),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){let e=this.getPECoordSys();return e?hu(e):this.m_userWKT??``}getTextExtended(e){let t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?mu(null,t,this.getPEVerticalCoordSys()):hu(t,e):this.m_userWKT??``}getText2(e=-1){let t=this.getPECoordSys();return t?gu(t,e):this.m_userWKT??``}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof Tf?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof fn?.001/(Np(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):(y(`sr object not in valid state`),0)}getAuthorityName(){return this.getPECoordSys()?_u():``}getVerticalUnit(){return p(`vcs not implemented`),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){let e=this.getCoordinateSystemType();if(e===0)y(Mf);else if(e===1)return this;else e===3&&y(`image cs not supported`);if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===op()||this===cp())t=up();else{l(this.m_peCoordSysVal);let e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||o(``),t=Uf(e,this.m_vertcs,null,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?t=this.m_geogSpatialReference:this.m_geogSpatialReference=t,t}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(e.length===0)return 0;e.length>t.length&&n(`coordsSrc.size() > coordsDst.size()`);let r=this.getCoordinateSystemType();if(r===0&&y(Mf),r===1)return ft(t,e,e.length),e.length;l(this.m_peCoordSysVal);let i=this.getSRToGCSTransform();return new Rc().transform(i,e,e.length,t)}toGeohash(e,t=8){let n=e.clone();n.scale(this.getGCS().getUnit().getID()===9102?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),n.x<-180?(n.x=pt(n.x,360),n.x<-180&&(n.x+=360)):n.x>180&&(n.x=pt(n.x,360),n.x>180&&(n.x-=360)),n.y>90&&(n.y=90),n.y<-90&&(n.y=-90);let r=t*5,i=new Uint32Array(4);return Of(n.x,-180,180,r-1,i),Of(n.y,-90,90,r-2,i),Df(i,t,t)}isPannable(){let e=this.getCoordinateSystemType();return e===0||e===3?!1:(l(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||n(`!is_pannable`),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||n(`!is_pannable`),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){let e=this.getCoordinateSystemType();e!==1&&e!==2&&n(`Not a GCS or PCS`)}getDomainXY(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX)){if(Rf()||v(`cannot query precision descriptor`),l(this.m_peCoordSysVal!==null),this.m_precisionDescriptor.m_precision!==2){let t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=NaN,e.m_falseY=NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{let t=this.getCoordinateSystemType();t===0?mp(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):t===3?p(`image cs`):fp(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=NaN,e.m_falseY=NaN}horizontalEqual(e){return Id(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return this.m_vertcs!==null==(e.m_vertcs!==null)?!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs):!1}equals(e){let t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t)||!t.m_peCoordSysVal&&(l(!this.m_peCoordSysVal),this.m_unit!==null!=(t.m_unit!==null)||this.m_unit&&!this.m_unit.equals(t.m_unit)||this.m_localZToXYFactor!==t.m_localZToXYFactor))return!1;if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;l(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,n=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){let t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,n=t.ymin}let r=t.m_precisionDescriptor.m_falseX,i=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(r)){let e=t.m_peCoordSysVal.getDomainXY();r=e.xmin,i=e.ymin}return e===r&&n===i}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;let n=this.getCoordinateSystemType(),r=e.getCoordinateSystemType();if(n===0||r===0)return n===0&&r===0?t&&this.getZToXYFactor()!==e.getZToXYFactor()?!1:this.getUnit()&&e.getUnit()?this.getUnit().equals(e.getUnit()):!0:n===3||r===3?!1:this.getUnit()===null||e.getUnit()===null?!0:t&&this.getZToXYFactor()!==e.getZToXYFactor()?!1:this.getUnit().equals(e.getUnit());if(n!==r)return!1;if(n===3)return this.equals(e);if(Ld(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(this.m_vertcs!==null==(e.m_vertcs!==null))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return l(0),!1}equalVerticalVCS(e){return l(0),!1}convergenceAngle(e){return l(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){let e=this.m_peCoordSysVal.m_peCoordSys;return e||o(`cannot clone coord sys`),e}return null}getPeVertcsCopy(){return l(0),0}throwIfLocal(){this.getCoordinateSystemType()===0&&n(Mf)}getPrimeMeridian(){return this.throwIfLocal(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return this.getUnitsPerMillimeter()*1e3}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(this.m_defaultPrecisionSR===null){let e=new ip;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=Gf(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal);let t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),n=t.getFlattening();Ff(e,t.getAxis(),n)}getAreaOfUse(){this.getCoordinateSystemType()===0&&y(``),l(this.m_peCoordSysVal);let e=this.m_peCoordSysVal.getAreaOfUse();return e===null?new cn:new cn({geom:e.clone(),sr:Vf(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty()||this.m_precisionDescriptor.getPrecision()===2)return!1;let t=e.getGeometryType();if(f(t))return this.snapMultiVertex_(e);if(t===i.enumPoint)return this.snapPoint_(e);if(t===i.enumEnvelope)return this.snapEnvelope_(e);if(a(t))return this.snapSegment_(e);if(t===i.enumGeometryCollection){let t=e,n=!1;for(let e=0,r=t.getGeometryCount();e<r;++e)n=this.snapGeometry(t.getGeometry(e))||n;return n}o(`what else?`)}snapMultiVertex_(e){if(l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2),s(e.getGeometryType())){let t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}let t=e.getImpl(),n=t.getDescription(),r=!1;for(let e=0,i=n.getAttributeCount();e<i;e++){let i=n.getSemantics(e),a=t.getAttributeStreamRef(i);r=this.snapAttributes(i,a,0,t.getPointCount())||r}return r&&t.notifyModifiedFlags(2001),r}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2);let t=new ip;this.queryPrecisionDescriptor(t);let n=e.getStartXY(),r=new U;r.x=gp(n.x,t.getFalseX(),t.getGridUnitsXY()),r.y=gp(n.y,t.getFalseY(),t.getGridUnitsXY());let i=!r.equals(n),a=e.getEndXY(),o=new U;o.x=gp(a.x,t.getFalseX(),t.getGridUnitsXY()),o.y=gp(a.y,t.getFalseY(),t.getGridUnitsXY()),i||=!o.equals(a),i&&e.changeEndPoints2D(r,o);let s=(t,n,r)=>{let i=!1;{let a=e.getStartAttributeAsDbl(t,0),o=gp(a,n,r),s=!mt(o,a);i||=s,s&&e.setStartAttribute(t,0,o)}{let a=e.getEndAttributeAsDbl(t,0),o=gp(a,n,r),s=!mt(o,a);i||=s,s&&e.setEndAttribute(t,0,o)}return i},c=+!!i;return e.hasAttribute(1)&&(c|=+!!s(1,t.getFalseZ(),t.getGridUnitsZ())),e.hasAttribute(2)&&(c|=+!!s(2,t.getFalseM(),t.getGridUnitsM())),!!c}snapGeometryWithCurves_(e){l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2);let t=e.createInstance(),n=new F,r=0;for(let i=0,a=e.getPathCount();i<a;++i){let a=e.getSegmentCountPath(i);if(a===0){if(t.addPath(e,i,!0),t.getPathSize(i)===1){let e=new B;t.getPointByVal(t.getPointCount()-1,e),r|=+!!this.snapGeometry(e),t.setPointByVal(t.getPointCount()-1,e)}continue}let o=e.isClosedPath(i);for(let s=0,c=o?a-1:a;s<c;++s)e.getSegmentFromPath(i,s,n,!1),r|=+!!this.snapGeometry(n.get()),t.addSegment(n.get(),s===0);o&&(e.getSegmentFromPath(i,a-1,n,!1),r|=+!!this.snapGeometry(n.get()),a===1?t.addPathFromClosedSegment(n.get(),!1):t.closeLastPathWithSegment(n.get()))}return r&&t.copyTo(e),!!r}snapAttributes(e,t,n,r){let i=!1,a=new ip;if(this.queryPrecisionDescriptor(a),e===0){let e=t;for(let t=n;t<r;t++){let n=e.read(2*t),r=rp.s_SnapValue(n,a.getFalseX(),a.getGridUnitsXY()),o=e.read(2*t+1),s=rp.s_SnapValue(o,a.getFalseY(),a.getGridUnitsXY());i=i||r!==n||s!==o,i&&(e.write(2*t,r),e.write(2*t+1,s))}}else if(e===1){let e=t;for(let t=n;t<r;t++){let n=e.read(t),r=rp.s_SnapValue(n,a.getFalseZ(),a.getGridUnitsZ());i||=!mt(r,n),i&&e.write(t,r)}}else if(e===2){let e=t;for(let t=n;t<r;t++){let n=e.read(t),r=rp.s_SnapValue(n,a.getFalseM(),a.getGridUnitsM());i||=!mt(r,n),i&&e.write(t,r)}}return i}static s_SnapValue(e,t,n){return ht((e-t)*n)/n+t}}class ip{m_falseX;m_falseY;m_unitsXY;m_falseZ;m_unitsZ;m_falseM;m_unitsM;m_toleranceXY;m_toleranceZ;m_toleranceM;m_precision;constructor(){let e=jf,t=1e-4,n=.001,r=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-r,this.m_falseY=-r,this.m_unitsXY=Number(e)/(2*r),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=n,this.m_toleranceM=n,this.m_toleranceZ=n}getHashCode(){let e=7777,t=7777;return t=ct(t,this.m_falseM),t=ct(t,this.m_unitsM),e=ct(e,this.m_unitsXY),t=ct(t,this.m_toleranceXY),e=ct(e,this.m_falseZ),t=ct(t,this.m_toleranceZ),e=ct(e,this.m_unitsZ),t=ct(t,this.m_toleranceM),e=ct(e,this.m_precision),ct(e,t)}clone(){let e=new ip;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(this.m_precision===2)return 0;switch(e){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){let e=new T;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 2:e.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:e.setEmpty(),o(``)}return e}getZGridRange(){let e=new W;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),o(``)}return e}getMGridRange(){let e=new W;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),o(``)}return e}setTolerance(e,t){switch(t<0&&n(`tol < 0`),Number.isFinite(t)||n(`tol is not finite`),e){case 0:this.m_toleranceXY=t;break;case 1:this.m_toleranceZ=t;break;case 2:this.m_toleranceM=t;break;default:n(`cannot set tolerance for this attribute`)}}setGridParams(e,t,r){(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&n(`grid params are not finite`),r<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=r}setZParams(e,t){(!Number.isFinite(e)||!Number.isFinite(t))&&n(`grid params are not finite`),t<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseZ=e,this.m_unitsZ=t}setMParams(e,t){(!Number.isFinite(e)||!Number.isFinite(t))&&n(`grid params are not finite`),t<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||mt(this.m_falseX,e.m_falseX)&&mt(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(this.m_precision===2)return;let e=(e,t,n,r)=>{if(!Number.isFinite(t)||!Number.isFinite(n))return n;if(n<1)return 1;if(!r)return n;let i=Number(e)/n;return Math.trunc((t+i-t)*n)>e&&(n=e/(t+i-t)),Math.max(1,n)},t=Number(this.m_precision===0?Af:jf);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(this.m_precision===2)return!0;let e=(e,t,n,r)=>{if(n<1||!Number.isFinite(t)||!Number.isFinite(n))return!1;if(!r)return!0;let i=Number(e)/n;return!(BigInt((t+i-t)*n)>e)},t=this.m_precision===0?Af:jf;return!(!e(t,this.m_falseX,this.m_unitsXY,!0)||!e(t,this.m_falseY,this.m_unitsXY,!0)||!e(t,this.m_falseZ,this.m_unitsZ,!1)||!e(t,this.m_falseM,this.m_unitsM,!1))}fixTolerance(){this.m_precision!==2&&(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=NaN))}equalsWithoutFalseXY(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,n){}setBestMDomainFromMRange(e,t,n){}}let ap;function op(){return(!ap||Rf()&&ap.getPECoordSys()===null)&&(ap=hp(3857,0,null,!0)),ap}let sp;function cp(){return(!sp||Rf()&&sp.getPECoordSys()===null)&&(sp=hp(102100,0,null,!0)),sp}let lp;function up(){return(!lp||Rf()&&lp.getPECoordSys()===null)&&(lp=hp(4326,0,null,!0)),lp}function dp(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=vt()*100,e.m_toleranceZ=vt()*100,e.m_toleranceM=vt()*100,e.m_precision=2}function fp(e,t,r,i){let a=t instanceof Rd;dp(e),e.m_precision=i,e.m_falseX=NaN,e.m_falseY=NaN;let o=1e-4,s=.001,c=a?t.m_csType:t.isPCS?2:1;c===1?e.m_unitsXY=1/((i===0?5.555555555555555e-7:1e-9)*(a?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180)):c===2?e.m_unitsXY=1/((i===0?s:o)*(a?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit)):n(`unrecognized cs type`),e.m_falseM=-1e5,e.m_unitsM=1/(i===0?s:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let l=0,u=0;(i===0||i===1)&&(l=2/e.m_unitsXY,u=2/e.m_unitsM),e.m_toleranceXY=Math.max(l,a?t.getUnitsPerMillimeter():c===2?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(s,u),pp(e,r)}function pp(e,t){let n=1e-4,r=.001;e.m_falseZ=-1e5,e.m_unitsZ=t?1/((e.m_precision===0?r:n)*t.getOneMeter()):1/(e.m_precision===0?r:n),e.m_unitsZ=Math.max(1,e.m_unitsZ);let i=0;(e.m_precision===0||e.m_precision===1)&&(i=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*r:r,i)}function mp(e,t,n,r){dp(e),e.m_precision=r;let i=r===0?Af:jf,a=1e-4,o=.001,s=1,c=1,l=.001;t&&(c=t.getUnitToBaseFactor()),t&&t.getUnitType()===1?(s=400*Math.PI/180,l=8.983152841195215e-9*Math.PI/180/c):(s=(r===0?o:a)*Number(i)*.5,l=o/c),s/=c,e.m_falseX=-s,e.m_falseY=-s,e.m_unitsXY=Number(i)/(2*s),e.m_falseM=-1e5,e.m_unitsM=1/(r===0?o:a),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let u=0,d=0;(e.m_precision===0||e.m_precision===1)&&(d=2/e.m_unitsM,u=2/e.m_unitsXY),e.m_toleranceXY=Math.max(u,l),e.m_toleranceM=Math.max(o,d),pp(e,n)}function hp(e,t,n,r){if(!r&&t<=0){if(e===3857)return op();if(e===102100)return cp();if(e===4326)return up()}let i=new rp,a,o=null;return Rf()?(a=af(e),t>0?o=null:t=0,i.setHorzProj_(a),i.m_vertcs=o):(a=Np(e),i.m_unit=a.isPCS?new Tf(a.metersOrRadiansPerUnit):new fn(a.metersOrRadiansPerUnit)),fp(i.m_precisionDescriptor,a,o,1),i.m_bDefaultDescriptor=!0,i.m_userWKID=e,i.calculateHashCode(),i.initDbgName(),i}function gp(e,t,n){return ht((e-t)*n)/n+t}let _p=null;const vp=3552713678800501e-30;function yp(e,t,n){return e===t||Math.abs(e-t)<=n*(1+(Math.abs(e)+Math.abs(t))/2)}function Z(e,t){return yp(e,t,vp)}function bp(e,t){return e===0||Math.abs(e)<=t}function xp(e){return bp(e,vp)}let Sp;function Cp(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){let e=this._this;return this._this=null,e}}}let Q,$,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp=null;function Np(e){l(Mp);let t=Mp(e);return t.semiMajor=t.isPCS?NaN:Bp(e),t}function Pp(e){Mp=e,l(Mp)}function Fp(e){let t=e;Q=t.PeFactory,l(Q),jp=t.PeGCSExtent,l(jp),kp=t.PeLineType,l(kp),Ap=t.PeMath,l(Ap),Sp=t.PeDouble,l(Sp),$=t.PeDefs,l($),wp=t.PeCSTransformations,l(wp),Tp=t.PeGTTransformations,l(Tp),Ep=t.PePCSInfo,l(Ep),Dp=t.PeGTlistExtended,l(Dp),Q.initialize(),Op=t.PeGTlistExtendedEntry,l(Op),$.PE_TYPE_ANGUNIT=512,$.PE_STR_AUTH_ALL=2,Ep.PE_POLE_LINE_STRAIGHT=2,Ep.PE_POLE_LINE_CURVED=3,$.PE_PARM_LAM0=2,$.PE_PARM_PHI0=6,$.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,$.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,$.PE_PRJ_ALBERS=43007,$.PE_PRJ_CYLINDRICAL_EQAREA=43034,$.PE_TYPE_VERTCS=8,$.PE_LINETYPE_GEODESIC=0,$.PE_LINETYPE_LOXODROME=1,$.PE_LINETYPE_GREAT_ELLIPTIC=2,$.PE_LINETYPE_NORMAL_SECTION=3,Dp.PE_GTLIST_OPTS_USABLE=1,Mp=null}function Ip(e,t,n,r){return t<=0?(n[0]=0,r[0]=0,!1):(n[0]=t,r[0]=t,!0)}function Lp(e){return l(zf()),Mp(e).isPCS?!0:Rp(e)}function Rp(e){return Q&&y(`pe has been loaded. no-pe methods should not be used at this point.`),_p||Vp(),_p.has(e)}const zp=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Bp(e){if(Q&&y(`pe has been loaded. no-pe methods should not be used at this point.`),typeof e==`string`){let t=e.match(zp);(!t||t.length!==2)&&n(`bad gcs wkt`);let r=Number.parseFloat(t[1]);return Number.isFinite(r)||n(`bad gcs wkt`),r}return _p||Vp(),_p.has(e)||y(`gcs wkid not found`),_p.get(e)}function Vp(){_p=new Map;for(let e in un){let t=Number.parseFloat(e),n=un[e];if(Array.isArray(n))for(let e of n)_p.set(e,t);else _p.set(n,t)}dn()}function Hp(e,t){let n=Q.geogtran(e);return n||g(e),new qp(n,t)}function Up(e,t){let n=Q.fromString($.PE_TYPE_GEOGTRAN,e);return n||_(e),new qp(n,t)}function Wp(e,t){return new qp(e,t)}const Gp=lt(0),Kp=lt(1);class qp{m_geogTranWrapper;m_hashCode;m_bInverted;constructor(e,t){if(e instanceof qp){this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,this.m_hashCode=ct(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Kp:Gp);return}this.m_geogTranWrapper=new Ll(e),this.m_bInverted=t,this.m_hashCode=ct(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Kp:Gp)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return``;if(e===-1)return this.m_geogTranWrapper.getGeogtran().toString();{let t=e===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=$.PE_STR_FMT_WKT2;return e!==-1&&(t|=e===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(t)}getName(){return!this.m_geogTranWrapper||!this.m_geogTranWrapper.getGeogtran()?``:this.m_geogTranWrapper.getGeogtran().getName()}getInputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getOutputSr(!1):this.m_geogTranWrapper.getInputSr(!1)}getOutputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getInputSr(!1):this.m_geogTranWrapper.getOutputSr(!1)}getInverse(){return new qp(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){let t=e;return t===this?!0:this.m_bInverted===t.m_bInverted?this.GetPeGeogtran()===t.GetPeGeogtran()||!(this.getID()!==t.getID()||this.getID()===0&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())):!1}referencesMissingData(){return this.m_geogTranWrapper?!this.m_geogTranWrapper.isUsable():!1}getWrapper(){return this.m_geogTranWrapper}}function Jp(n,r,i,a,o){let s=n.getGCS(),c=r.getGCS(),u=s,d=c,f=u.getPECoordSys(),p=d.getPECoordSys(),m=null;if(!i.isEmpty()){let e=i.clone();if(!e.isEmpty()&&n.getCoordinateSystemType()===2){let t=new Me({env2D:e}),r=Hd(n,s,null);t=new Rc().execute(t,r,null),t.queryEnvelope(e)}if(!e.isEmpty()){let t=f.getPrimem().getLongitude(),n=f.getUnit().getUnitFactor();m=new jp(e.xmin,e.ymin,e.xmax,e.ymax,t,n)}}let h=a;h>=Ut()&&(h=0);let g=[],_=Dp.PE_GTLIST_OPTS_COMMON;o||(_&=~Dp.PE_GTLIST_OPTS_USABLE);for(let n=0;n<2;n++){let n={stack:[],error:void 0,hasError:!1};try{g.length=0;let t=Dp.getGTlist(f,p,2,_,m,h);if(t==null||t.length===0)break;e(n,{[Symbol.dispose](){Op.destroy(t)}},!1);let r=!1;for(let e of t){let t=Xp(e);if(l(t),o&&t.referencesMissingData()){r=!0,h=0;continue}if(g.push(t),g.length===a)break}if(!r)break}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}return m&&m.destroy(),g}function Yp(){return new Zp([],null,null,null)}function Xp(e){let t=new Qp,n=e.getSteps();if(n){let r=e.getEntries();for(let e=0;e<n;e++){let n=r[e].getDirection()!==0,i,a=r[e].getGeogtran().getCode();if(a>=0)i=Q.geogtran(a);else{let t=r[e].getGeogtran().toString($.PE_STR_FMT_WKT);i=Q.fromString($.PE_TYPE_GEOGTRAN,t)}if(i==null)return null;let o=Wp(i,n);t.add(o)}return t.create()}return null}class Zp{m_bReadOnly=!0;m_transforms;m_inputSr;m_outputSr;m_name=``;m_fastTrack=-1;m_bNameIsSet=!1;constructor(e,t,n,r){this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=n,this.m_outputSr=r}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(this.m_transforms.length===0)return``;let e=``;for(let t of this.m_transforms)e.length>0&&(e+=` + `),t.isInverted()&&(e+=`~`),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=ct(e,this.m_transforms[t].getHashCode());return e}equals(e){return l(0),!1}referencesMissingData(){if(this.m_transforms.length===0)return!1;for(let e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return l(0),!1}validateTransformation(e,t){return l(0),!1}nameIsSet(){return l(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&x(``),this.m_transforms[e]}getInverse(){let e=new Qp;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,n){if(this.count()===0)return;let r=this.m_inputSr,i=this.m_outputSr;if(e&&(i=gt(r,r=i)),this.m_transforms.length===0){Rl(r,null,i,null,t,null,n);return}let a=this.m_fastTrack;if(a===1){le(e,this.m_transforms,r=>{Ul(r.getWrapper(),e!==r.isInverted(),t,null,n)});return}let o=Il();a===-1&&o.initFromGcsAndVcs(r,null);let s=Il(),c=e?this.m_transforms.length-1:0,l=e?-1:1;for(let i=0,u=this.m_transforms.length;i<u;i++,c+=l){if(i===0){let i=this.m_transforms[c];zl(r.getPECoordSys(),null,i.getWrapper(),e!==i.isInverted(),t,null,n,s),a===-1&&(o.equals(s)||(a=0)),o.assign(s)}else{let r=this.m_transforms[c-l],i=this.m_transforms[c];Vl(o,r.getWrapper(),e!==r.isInverted(),i.getWrapper(),e!==i.isInverted(),t,null,n,s),a===-1&&(o.equals(s)||(a=0)),o.assign(s)}let u=this.m_transforms[c];Hl(o,u.getWrapper(),e!==u.isInverted(),t,null,n,s),o.assign(s)}let u=this.m_transforms[c-l];Bl(o,u.getWrapper(),e!==u.isInverted(),i,null,t,null,n),a===-1&&(s.initFromGcsAndVcs(i,null),o.equals(s)||(a=0)),this.m_fastTrack=a===0?0:1}}class Qp{m_transforms=[];m_inputGCS=null;m_outputGCS=null;m_name=``;m_bNameIsSet=!1;getInputSpatialReference(){return this.m_inputGCS===null?this.count()>0?this.m_transforms[0].getInputSpatialReference():null:this.m_inputGCS}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return this.m_outputGCS===null?this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null:this.m_outputGCS}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(this.m_transforms.length===0)return``;let e=``;for(let t of this.m_transforms)e.length>0&&(e+=` + `),t.isInverted()&&(e+=`~`),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&x(``),this.m_transforms[e]}setStep(e,t){l(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let t=e.count()-1;t>=0;--t)this.add(e.getStep(t).getInverse());else for(let t=0;t<e.count();++t)this.add(e.getStep(t))}clear(){this.m_transforms=[],this.m_name=``,this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){l(0)}create(){let e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),n=new Zp(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return n.m_bReadOnly=!0,this.clear(),n}}export{ai as $,Wp as A,Gd as B,Bd as C,Hd as D,Vd as E,Wd as F,qp as G,Kd as H,Xd as I,xc as J,qo as K,ri as L,ms as M,hs as N,Rc as O,$d as P,ss as Q,Ss as R,rp as S,ys as T,_s as U,gs as V,J as W,ac as X,cc as Y,Wl as Z,Ri as _,ip as a,cn as a$,ci as a0,Gl as a1,Kl as a2,Yl as a3,Ec as a4,ou as a5,Xs as a6,Ns as a7,us as a8,Qr as a9,Ru as aA,Yo as aB,En as aC,wp as aD,Ou as aE,Ju as aF,Gn as aG,An as aH,Nn as aI,kc as aJ,Wn as aK,kn as aL,qu as aM,$ as aN,fu as aO,gd as aP,cs as aQ,Us as aR,Fs as aS,rc as aT,sr as aU,Y as aV,Jn as aW,Q as aX,Gu as aY,Vn as aZ,Nl as a_,Qo as aa,Ls as ab,Qp as ac,Yp as ad,Ap as ae,Bc as af,Fu as ag,Vc as ah,pn as ai,Fd as aj,fl as ak,Pu as al,Z as am,Sp as an,kp as ao,dl as ap,Wc as aq,Gc as ar,Hc as as,Uc as at,pl as au,xn as av,Ku as aw,cd as ax,yn as ay,Uu as az,Hf as b,Vf as c,Uf as d,qf as e,Gf as f,Kf as g,Yf as h,If as i,tp as j,zf as k,Rf as l,Lf as m,Bf as n,np as o,Xf as p,Zf as q,Pf as r,Jf as s,cp as t,up as u,du as v,op as w,ql as x,Hp as y,Up as z};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{b as n,t as r,G as i,h as a,d as o,j as s,s as c,g as l,u,w as d,i as f,a as p,v as m,x as h,y as g,z as _,e as v,q as y,f as b,r as x,p as S,m as C,A as w}from"./Geometry.js";import{Envelope2D as T}from"./Envelope2D.js";import{a as E,y as D,z as O,P as k,M as A,g as j,A as M,E as N,c as P,S as F,L as I,B as L,F as R,H as ee,n as z,I as te,Q as ne,D as re,l as ie,J as ae,K as oe,N as se,O as ce,R as le,V as ue,T as de,U as fe,W as pe,X as me,Y as he,Z as ge,_ as _e,b as ve,$ as ye,a0 as be,a1 as xe,a2 as Se,a3 as Ce,a4 as we}from"./MultiPathImpl.js";import{e as Te,l as Ee,i as De,d as Oe,m as ke,g as Ae,c as je,E as Me,P as B,C as Ne,f as Pe,I as Fe,T as Ie,n as Le,a as Re,B as ze,o as Be,b as Ve,p as He,V as Ue,q as We,r as Ge,t as Ke,u as qe,v as Je,w as Ye,x as Xe,y as Ze,z as Qe,j as $e,D as et,F as tt,G as nt,S as rt,A as it,k as V,H as at,J as ot,h as st}from"./Envelope.js";import{B as ct,C as lt,D as ut,c as H,P as U,w as dt,F as ft,p as pt,G as mt,H as ht,s as gt,h as _t,E as W,I as vt,o as yt,d as bt,t as xt,K as St,r as Ct,g as wt,J as Tt,m as Et,e as Dt,L as Ot,N as kt,a as At,S as jt,j as Mt,O as Nt,Q as Pt,R as Ft,b as It,M as Lt,T as Rt,l as G,f as zt,U as Bt,V as Vt,W as Ht,i as Ut,q as Wt,X as Gt,Y as Kt,Z as qt,_ as Jt,$ as Yt,a0 as Xt,a1 as Zt,a2 as Qt,z as $t,a3 as en,n as tn}from"./Point2D.js";import{T as K}from"./Transformation2D.js";import{c as q,O as nn,a as rn}from"./OperatorClip.js";import{O as an}from"./OperatorDensify.js";import{G as on}from"./GeometryCursor.js";import{S as sn}from"./SimpleGeometryCursor.js";class cn{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move){this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,e.move.m_sr=null;return}if(e.copy){this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,this.m_sr=e.copy.m_sr;return}e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){let n=e;return!(!this.m_sr&&n.m_sr||this.m_sr&&!n.m_sr||!this.m_geom&&n.m_geom||this.m_geom&&!n.m_geom||this.m_sr&&n.m_sr&&!this.m_sr.equals(n.m_sr)||this.m_geom&&n.m_geom&&!this.m_geom.equals(n.m_geom,t))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new cn({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}m_geom;m_sr}class ln{m_factor=1;m_wkid=0;m_peUnit=null;constructor(e){e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():``}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&n(`unit type mismatch`),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return ct(lt(this.getUnitType()),lt(this.getUnitToBaseFactor()))}equals(e){return e?this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName():!1}static isValidWkid(e){return!1}}class J{m_reason;m_vertexIndex1;m_vertexIndex2;assign(e){this.m_reason=e.m_reason,this.m_vertexIndex1=e.m_vertexIndex1,this.m_vertexIndex2=e.m_vertexIndex2}constructor(e,t,n){e===void 0?(this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-2):(this.m_reason=e,this.m_vertexIndex1=t,this.m_vertexIndex2=n)}clear(){this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-1}}const un={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,10992,10993,11030,11033,11042,11043,11225,11226,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104220,104221,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,10635,10636,10735,10736,10758,37e3,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,"6377397.155":[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,10898,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],"6377563.396":[4001,4188,4277,4278,4279],"6377340.189":[4002,4299,4300],"6377492.018":[4005,4273,4817],"6377483.865280418":[4006,4293],"6378293.645208759":[4007,4157,4302,4738,5464],"6378206.4":[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],"6378450.047":[4009,4268],"6378300.789":[4010,4281],"6378249.2":[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],"6378249.145":[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104032,104103,104305],"6377276.345":[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],"6377298.556":[4016,4298],"6377304.063":[4018,4245],"6378298.3":[4028,4903],"6378136.2":4032,"6378136.3":4033,"6378249.144808011":[4034,4241],"20922931.8":[4042,4243],"6377301.243":[4044,4145,37203],"6377299.151":[4045,4146],"6377019.27":[4657,10256,10260,10265],"6378306.3696":[4748,4752],"6377295.664":[4751,37006],"6378136.5":[7682,7683],"6371008.7714":104047,"6378418.941":[104700,104726,104760],"6378586.581":[104701,104743],"6378505.809":104702,"6378544.823":104703,"6378490.569":104704,"6378470.757":[104705,104776],"6378403.701":[104706,104750],"6378434.181":[104707,104724,104739,104764],"6378454.907":104708,"6378400.653":104709,"6378567.378":104710,"6378546.957":[104711,104717,104780],"6378476.853":[104712,104736],"6378411.321":[104713,104728],"6378647.541":[104714,104715],"6378514.953":[104716,104782],"6378421.989":[104718,104770],"6378481.425":[104719,104753,104774,104781],"6378518.001":[104720,104725],"6378521.049":[104721,104723,104731,104745,104748],"6378464.661":104722,"6378436.619":104727,"6378574.389":[104729,104730],"6378472.281":[104732,104756],"6378498.189":[104733,104746],"6378449.421":[104734,104766],"6378525.621":[104735,104754],"6378466.185":104737,"6378496.665":104738,"6378643.579":104740,"6378559.758":104741,"6378414.369":[104742,104763,104772],"6378441.801":104744,"6378502.761":[104747,104759,104773,104775],"6378617.061":104749,"6378624.681":[104751,104765],"6378468.623":104752,"6378445.763":[104755,104758,104761],"6378670.401":104757,"6378438.753":104762,"6378543.909":104767,"6378605.783":104768,"6378540.861":104769,"6378443.325":[104771,104784],"6378548.481":104777,"6378463.746":104778,"6378426.561":104779,"6378453.688":104783,"6378530.193":104785,"6378376.271":[104800,104828],"6378471.92":104801,"6378472.931":104802,"6378411.351":104803,"6378380.991":104805,"6378414.96":104806,"6378345.09":[104807,104819,104844,104870],"6378412.542":104808,"6378470.401":104809,"6378376.331":104810,"6378379.031":104811,"6378407.621":104812,"6378376.811":[104813,104827],"6378313.92":104814,"6378414.93":104815,"6378413.021":104816,"6378380.381":104817,"6378530.851":104818,"6378591.521":104820,"6378378.881":104821,"6378408.481":[104822,104832],"6378375.601":[104823,104838],"6378408.041":104824,"6378655.071":104825,"6378409.151":104826,"6378315.7":[104829,104840,104845,104851],"6378285.86":[104830,104835,104859],"6378379.301":104831,"6378560.121":104833,"6378531.821":104834,"6378500.6":104836,"6378376.041":104837,"6378406.601":104839,"6378438.991":104841,"6378345.42":104842,"6378593.86":104843,"6378381.271":[104846,104847],"6378413.671":104848,"6378344.377":104849,"6378563.891":104850,"6378408.091":104852,"6378377.671":104853,"6378472.751":104854,"6378412.511":104855,"6378407.281":104856,"6378534.451":104857,"6378406.051":104858,"6378532.921":104860,"6378380.091":104861,"6378408.941":104862,"6378624.171":104863,"6378377.411":104864,"6378474.591":104865,"6378407.141":104866,"6378376.871":104867,"6378375.251":104868,"6378405.971":104869,"6378437.651":104871};function dn(){for(let e in un)delete un[e]}class fn extends ln{constructor(e){if(typeof e==`number`){super(),this.m_factor=e,this.m_wkid=0;return}super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function pn(e){return new Tf}function mn(e){if(e.getType()===$.PE_TYPE_LINUNIT)return new Tf(e);if(e.getType()===$.PE_TYPE_ANGUNIT)return new fn(e);n(`peUnit`)}function hn(e){let t=Cp(null);return e.getType()===$.PE_TYPE_PROJCS||e.getType()===$.PE_TYPE_GEOGCS?t.reset(e.getUnit()):n(`PE_coord_sys`),t.get()||o(`cannot create units from coord sys`),mn(t.get())}class gn{x;y;z;constructor(e,t,r){e===void 0?(this.x=new qt,this.y=new qt,this.z=new qt):e instanceof V?(this.x=new qt(e.x),this.y=new qt(e.y),this.z=new qt(e.z)):e instanceof qt?(this.x=e.clone(),this.y=t.clone(),this.z=r.clone()):n(`EPoint3D constructor`)}dotProduct(e){return this.x.mulE(e.x).addE(this.y.mulE(e.y)).addE(this.z.mulE(e.z))}crossProduct(e){return new gn(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){let t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),n=e.x.mulE(this.z).subE(this.x.mulE(e.z)),r=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new gn(t,n,r)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(e,t){return e.sub(t).length()}negate(){return new gn(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new gn(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new gn(this.x.subE(e.x),this.y.subE(e.y),this.z.subE(e.z))}subThis(e){return this.x.subThisE(e.x),this.y.subThisE(e.y),this.z.subThisE(e.z),this}addThis(e){return this.x.addThisE(e.x),this.y.addThisE(e.y),this.z.addThisE(e.z),this}mul(e){return new gn(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new gn(this.x.divE(e),this.y.divE(e),this.z.divE(e))}eq(e){return this.x.eq(e.x)&&this.y.eq(e.y)&&this.z.eq(e.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return V.construct(this.x.value(),this.y.value(),this.z.value())}}class _n{m_origin=new V;m_normal=new V;m_axisX=new V;m_axisY=new V;constructor(e){if(!e){this.m_origin=new V,this.m_normal=new V(0,0,1),this.m_axisX=new V(1,0,0),this.m_axisY=new V(0,1,0);return}if(e.pt0&&e.pt1&&e.pt2){this.setFromPoints(e.pt0,e.pt1,e.pt2);return}l(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return l(0),this}set(e,t,n,r){l(0)}setFromPoints(e,t,n){let r=t.sub(e),i=n.sub(e);this.m_normal=r.crossProductVector(i);let a=!0;if(!this.m_normal.isZero())this.m_normal.normalizeThis(),this.m_axisX=r.getUnitVector();else{if(a=!1,r.isZero()&&(r=i),r.isZero())return this.m_normal.setCoords(0,0,1),this.m_axisX.setCoords(1,0,0),this.m_axisY.setCoords(0,1,0),this.m_origin=e,!1;this.m_axisX=r.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,a}getCoord(e,t){return l(0),{}}getCoord2D(e){return l(0),{}}getCoordX(e,t){return l(0),0}getCoordY(e,t){return l(0),0}getCoordZ(e,t){return l(0),0}setPreferredAxisX(e){l(0)}getOrigin(){return l(0),{}}getNormal(){return l(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){l(0)}setAxisY(e,t=!1){l(0)}recalculateAxisY(){l(0)}setOrigin(e){l(0)}setNormal(e,t){l(0)}intersect(e,t){return l(0),!1}intersectLine(e){return l(0),0}intersectLineEx(e,t){return l(0),0}closestCoordinate(e){let t=e.sub(this.m_origin),n=new U;return n.x=t.dotProduct(this.m_axisX),n.y=t.dotProduct(this.m_axisY),n}projectVector(e){return l(0),{}}signedDistance(e){return l(0),0}distance(e){return l(0),0}}function vn(e,t){return!1}function yn(e,t,n,r,i=100,a=vn){l(r>0);let o,s,c,u,d,f,p,m,h,g=0,_=0,v,y,b,x=Qt();t>n&&(n=gt(t,t=n));let S=e(t),C=e(n);S<C?(o=s=c=t,u=d=f=S):(o=s=c=n,u=d=f=C);let w=0;for(;w<i&&(b=(n-t)*.5,h=t+b,v=r*(Math.abs(o)+.25),y=v*2,!(a(o,u)||Math.abs(o-h)<=y-b));++w){if(Math.abs(_)>v){let e=(o-s)*(u-f),r=(o-c)*(u-d),i=(o-c)*r-(o-s)*e;r=2*(r-e),r>0&&(i=-i),r=Math.abs(r);let a=_;_=g,Math.abs(i)>=Math.abs(r*a*.5)||i<=r*(t-o)||i>=r*(n-o)?(_=o>=h?t-o:n-o,g=Qt()*_):(g=i/r,m=o+g,(m-t<y||n-m<y)&&(g=h-o<0?-Math.abs(v):Math.abs(v)))}else _=o>=h?t-o:n-o,g=_*x;m=o+g,p=e(m),p<u?(m>=o?t=o:n=o,c=s,s=o,o=m,f=d,d=u,u=p):(m<o?t=m:n=m,p<=d||s===o?(c=s,s=m,f=d,d=p):(p<=f||c===o||c===s)&&(c=m,f=p))}return yt(o,u)}function bn(e,t,n){if(e>n){let t=Math.ceil((e-n)/tn);e-=t*tn}else if(e<t){let n=Math.ceil((t-e)/tn);e+=n*tn}return e}function xn(e,t,n){return Sn(e,t,n,0)}function Sn(e,t,n,r){let i=n.x,a=n.y;return wn(e,t,Math.cos(i),Math.sin(i),Math.cos(a),Math.sin(a),r)}function Cn(e,t,n,r,i,a){return wn(e,t,n,r,i,a,0)}function wn(e,t,n,r,i,a,o){let s=e/Math.sqrt(1-t*a*a),c=s+o,l=c*i*n,u=c*i*r,d=(s*(1-t)+o)*a;return V.construct(l,u,d)}function Tn(e,t,n){let r=new qt,i=new qt,a=new qt,o=new qt;r.setCos(n.x),i.setSin(n.x),a.setCos(n.y),o.setSin(n.y);let s=o.negate().mulE(o.mul(t)).add(1).sqrt(),c=new qt(e).divE(s),l=c.mulE(a).mulE(r),u=c.mulE(a).mulE(i),d=c.mul(1-t).mulE(o);return new gn(l,u,d)}function En(e,t,n){let r=n.x,i=n.y,a=n.z,o=Math.atan2(i,r),s=Math.sqrt(r*r+i*i),c=Math.atan2(a,(1-t)*s);return U.construct(o,c)}function Dn(e,t,n){let r=1-t,i=e/Math.sqrt(Dt(n.x)+Dt(n.y)+Dt(n.z)/r);return n.mul(i)}function On(e,t,n,r,i){let a=xn(e,t,n),o=xn(e,t,r);return En(e,t,V.lerp(a,o,i))}function kn(e,t,n){let r=new V;return r.setCrossProductVector(t,n),Math.abs(Math.atan2(r.length(),t.dotProduct(n)))*e}function An(e,t,n,r,i){let a=n.getUnitVector(),o=r.getUnitVector(),s=t.getUnitVector(),c=new V;if(c.setCrossProductVector(a,o),!c.isZero()){c.normalizeThis();let t=s.sub(c.mul(c.dotProduct(s)));if(!t.isZero()){t.normalizeThis();let n=a.add(o).mul(.5);if(n.dotProduct(t)>n.dotProduct(a)){let n=Math.abs(c.dotProduct(s)),r=Math.asin(n);return i.assign(t.getUnitVector().mul(e)),r*e}}}let l=kn(1,a,s),u=kn(1,o,s);return l<=u?(i.assign(n),l*e):(i.assign(r),u*e)}function jn(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=e(o,new Sp,!1);return kp.geodeticDistance(n,r,i.x,i.y,a.x,a.y,t,null,null,$.PE_LINETYPE_GEODESIC),t.val}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function Mn(e,t,n,r,i){switch(l(n.isFinite()&&r.isFinite()),i){case 0:return jn(e,t,n,r);case 1:return Fn(e,t,n);case 2:case 3:{let i=xn(e,t,n),a=xn(e,t,r);return V.distance(i,a)}default:p(``)}}function Nn(e,t,n,r,i,a=0,o){if(a===2||a===3)return Pn(e,t,n,r,i,a===3,o);let s=En(e,t,n),c=n=>{let o=En(e,t,V.lerp(r,i,n));return Mn(e,t,s,o,a)},l=V.distance(r,i);if(l>0){let{first:n,second:a}=yn(c,0,1,qn(e,l));return o&&o.assign(Dn(e,t,V.lerp(r,i,n))),yt(n,a)}{let e=c(0);return o&&o.assign(r),yt(.5,e)}}function Pn(e,t,n,r,i,a=!1,o){let s=Dn(e,t,n);if(a){let a=new _n({pt0:new V(0,0,0),pt1:r,pt2:i}),c=a.closestCoordinate(n),l=a.closestCoordinate(r),u=a.closestCoordinate(i),d=U.getClosestCoordinate(l,u,c),f=Dn(e,t,V.lerp(r,i,d)),p=V.distance(f,s);return o&&o.assign(f),yt(d,p)}let c=n=>{let a=Dn(e,t,V.lerp(r,i,n));return V.distance(a,s)},l=V.distance(r,i);if(l>0){let{first:n,second:a}=yn(c,0,1,qn(e,l));return o&&o.assign(Dn(e,t,V.lerp(r,i,n))),yt(n,a)}{let e=V.distance(n,r);return o&&o.assign(n),yt(.5,e)}}function Fn(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=e(o,new Sp,!1);return kp.greatEllipticDistance(n,r,i.x,i.y,i.x,i.y,t,null,null),t.val}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function In(e,t,n,r,i){if(Math.abs(n.x-r.x)>Math.PI||Math.abs(n.y)>G||Math.abs(r.y)>G||(Math.abs(n.y)===G||Math.abs(r.y)===G)&&n.x!==r.x)return NaN;let{first:a,second:o}=Yt(n.x,r.x),s=i;if(s=bn(s,a,o),!W.construct(n.x,r.x).containsCoordinate(s))return NaN;let c=ge.constructPoint2D(n),l=ge.constructPoint2D(r),u=Tn(1,t,c),d=Tn(1,t,l),f=u.crossProductVector(d);if(f.z.isZero())return n.y;let p=f.x.divE(f.z.negate()),m=f.y.divE(f.z.negate()),h=p.mulE(p).addE(m.mulE(m)).sqrt();if(h.isZero()||p.isZero()&&m.isZero())return n.y;let g=Math.atan2(m.value(),p.value()),_=Math.atan2(h.value()*Math.cos(g-s),1-t),v=xn(1,t,U.construct(s,_)),y=V.construct(v.x,v.y,-v.z),b=f.value().dotProduct(v),x=f.value().dotProduct(y);return Math.abs(x)<Math.abs(b)&&(_=-_),_}function Ln(e,t,n,r,i,a){if(a[0]=NaN,a[1]=NaN,Math.abs(n.x-r.x)>Math.PI||Math.abs(n.y)>G||Math.abs(r.y)>G||(Math.abs(n.y)===G||Math.abs(r.y)===G)&&n.x!==r.x||Math.abs(i)>=G||n.y>0&&r.y>0&&n.y>i&&r.y>i||n.y<0&&r.y<0&&n.y<i&&r.y<i)return 0;let o=ge.constructPoint2D(n),s=ge.constructPoint2D(r),c=Tn(1,t,o),l=Tn(1,t,s),u=c.crossProductVector(l);if(u.z.isZero())return W.construct(n.y,r.y).containsCoordinate(i)?(a[0]=n.x,1):0;let d=u.x.divE(u.z.negate()),f=u.y.divE(u.z.negate()),p=d.mulE(d).addE(f.mulE(f)).sqrt();if(p.isZero()||d.isZero()&&f.isZero())return i===0?(a[0]=n.x,a[1]=r.x,2):0;let m=(1-t)*Math.tan(i)/p.value();if(Math.abs(m)>1)return 0;let h=Math.acos(m),g=Math.atan2(f.value(),d.value()),_=g-h,v=g+h,y=Math.min(n.x,r.x),b=Math.max(n.x,r.x);bn(_,y,b),i===0?v=_:bn(v,y,b);let x=0;return y<=_&&_<=b&&(a[x]=_,x++),v!==_&&y<=v&&v<=b&&(a[x]=v,x++),x}function Rn(e,t){t[0]>Math.PI*.5?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<-Math.PI*.5&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),l(t[0]>=-Math.PI*.5&&t[0]<=Math.PI*.5)}function zn(e,t){return e*Math.sqrt(1-t)}function Bn(e){return 1-e}function Vn(e,t,n,r,i){r=At(r,-G,G),i=At(i,-G,G);let a=G-.03,o;o=r>a&&i>a||r<-a&&i<-a?Hn(e,r,i):Un(e,i)-Un(e,r);let s=Bn(e);return .5*(n-t)*o*s}function Hn(e,t,n){let r=1;if(t<0&&(r=-1,t=-t,n=-n),e!==0){let i=e*e,a=i*e,o=a*e,s=[1,(1+11*e)/12,(1+118*e+241*i)/360,(1+1089*e+10419*i+8651*a)/20160,(1+9836*e+318246*i+1027436*a+458881*o)/1814400],c=t=>{let n=0,r=Dt(t)/(e-1);for(let e=s.length-1;e>=0;--e)n=s[e]+n*r;return n*=-Dt(t/(1-e)),n},l=c(G-t);return(c(G-n)-l)*r}{let e=G-t,i=G-n,a=-4*Dt(Math.sin(e/2));return(-4*Dt(Math.sin(i/2))-a)*r}}function Un(e,t){if(t===0)return 0;let n=Math.sin(t),r=n,i=n;return e!==0&&(r/=1-e*n*n,i=n*$t(Math.sqrt(e)*n)),r+i}function Wn(e,t){return e/Math.sqrt(1-t)}function Gn(e,t){return(1-t)*e}function Kn(e,t,n){let r=n/(2*Gn(e,t)),i=r*r;return n*(1-i*(.16666666666666666-.008333333333333333*i))}function qn(e,t){if(t!==0){let n=e*Zt()/t;return Math.min(n,1e-10)}return 0}class Jn{m_parent;m_currentShift=63n;m_currentElt=0n;m_iCurrentElt=-1;m_aiSetElts;constructor(e){this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,this.m_currentShift===64n){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return Jn.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 2**53-1}}function Yn(e){return 1n<<(BigInt(e)&63n)}function Xn(e){return e>>6}class Zn{m_bits=[];constructor(e){if(e!==void 0&&e.copy){this.m_bits=e.copy.m_bits.slice();return}}assignMove(){return this}assignCopy(){return this}hasBit(e){let t=Yn(e),n=Xn(e);return this.m_bits[n]!==void 0&&!!(this.m_bits[n]&t)}setBit(e){let t=Yn(e),n=Xn(e);this.m_bits[n]===void 0&&(this.m_bits[n]=0n),this.m_bits[n]|=t}clearBit(e){}flipBit(e){let t=Yn(e),n=Xn(e);return this.m_bits[n]===void 0&&(this.m_bits[n]=0n),this.m_bits[n]^=t,(this.m_bits[n]&t)!==0n}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(e&2)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((n,r)=>{t|=n===e.m_bits[r]?2:1}),t&1?!1:(e.m_bits.forEach((e,n)=>{t|=e===this.m_bits[n]?2:1}),!(t&1))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]===void 0?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]!==void 0&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]!==void 0&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{this.m_bits[t]===void 0?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>Nt(e,t),lt(0))}getUnorderedBitIterator(){return new Jn(this)}}class Qn{m_map=new Map;m_hf;m_ef;constructor(e,t){this.m_hf=e,this.m_ef=t}add(e){let t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;let n=this.m_map.get(t);return n instanceof Array?n.find(t=>this.m_ef(t,e))||n.push(e):this.m_ef(n,e)||this.m_map.set(t,[n,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){let t=this.m_hf(e);if(!this.m_map.has(t))return!1;let n=this.m_map.get(t);return n instanceof Array?n.find(t=>this.m_ef(t,e))!==void 0:this.m_ef(n,e)}get(e){let t=this.m_hf(e),n=this.m_map.get(t);if(n!==void 0)return n instanceof Array?n.find(t=>this.m_ef(t,e)):n}get size(){let e=0;for(let t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[Symbol.iterator](){return new Set()[Symbol.iterator]()}entries(){return new Set().entries()}keys(){return new Set().keys()}values(){return new Set().values()}get[Symbol.toStringTag](){return`ValueSet`}}class $n extends tt{m_helper;m_bufferLeft=new F;m_bufferRight=new F;m_intervalLeft=W.constructEmpty();m_intervalRight=W.constructEmpty();m_yScanline=NaN;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=t,i=e.getElement(n);this.m_helper.querySegmentXY(r,this.m_bufferLeft),this.m_helper.querySegmentXY(i,this.m_bufferRight);let a=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(a.getStartX(),a.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;let s=a.getStartY()===a.getEndY(),c=o.getStartY()===o.getEndY();if(s||c){if(s&&c)return 0;if(a.getStartY()===o.getStartY()&&a.getStartX()===o.getStartX())return s?1:-1;if(a.getEndY()===o.getEndY()&&a.getEndX()===o.getEndX())return s?-1:1}let l=a.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),u=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(l===u){let e=a.getEndY(),t=o.getEndY(),n=Math.min(e,t),r=(n+this.m_yScanline)*.5;r===this.m_yScanline&&(r=n),l=a.intersectionOfYMonotonicWithAxisX(r,this.m_intervalLeft.vmin),u=o.intersectionOfYMonotonicWithAxisX(r,this.m_intervalRight.vmin)}return l<u?-1:+(l>u)}setY(e){this.m_yScanline=e}}class er{m_parent;m_segmentBuffer=new F;m_point=U.getNAN();constructor(e){this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){let n=e.getElement(t);this.m_parent.querySegmentXY(n,this.m_segmentBuffer);let r=this.m_segmentBuffer.get(),i=new W;if(i.setCoords(r.getStartX(),r.getEndX()),this.m_point.x<i.vmin)return-1;if(this.m_point.x>i.vmax)return 1;let a=r.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<a?-1:+(this.m_point.x>a)}}var tr;(function(e){e[e.enumInputModeBuildGraph=0]=`enumInputModeBuildGraph`,e[e.enumInputModeSimplifyAlternate=1]=`enumInputModeSimplifyAlternate`,e[e.enumInputModeSimplifyWinding=2]=`enumInputModeSimplifyWinding`})(tr||={});var nr;(function(e){e[e.enumSegmentParentageBreakNode=1]=`enumSegmentParentageBreakNode`,e[e.enumPathBreakNode=2]=`enumPathBreakNode`})(nr||={});function rr(e,t){return{parentage:e,rank:t}}function ir(e,t){let n=e.length;if(n!==t.length)return!1;let r=e[0].parentage;if(r!==t[0].parentage)return!1;if(r===-1)return!0;for(let r=1;r<n;++r)if(e[r].parentage!==t[r].parentage)return!1;return!0}function ar(e,t,n){n.length=0;let r=!1;{let i=e.getHalfEdgeVertexIterator(t);for(;i!==z;){let t=e.getVertexFromVertexIterator(i),a=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);r||=o>=0,n.push(rr(o,a)),i=e.incrementVertexIterator(i)}}{let i=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;i!==z;){let t=e.getVertexFromVertexIterator(i),a=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);r||=o>=0,n.push(rr(o,a)),i=e.incrementVertexIterator(i)}}r&&n.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:+(e.parentage>t.parentage)),n[0].parentage===-1&&(n.length=1)}function or(){return new Qn(e=>e.getHashCode(),(e,t)=>e.equals(t))}class sr{m_shape=null;m_clusterData=new rt(8);m_clusterVertices=new rt(2);m_firstCluster=z;m_lastCluster=z;m_halfEdgeData=new rt(8);m_chainData=new rt(8);m_chainAreas=null;m_chainPerimeters=null;static c_EdgeParentageMask=2147483647;static c_EdgeBitMask=1<<31;m_universeChain=-1;m_simplifiedGeometry=-1;m_edgeIndices=[];m_clusterIndices=[];m_chainIndices=[];m_bBuildGeometryParentageSets=!1;m_chainBitSetIndex=-1;m_edgeBitSetIndex=-1;m_edgeBitSetIndexLeft=-1;m_emptyBitSet=null;m_geometryMapID=null;m_uniqueBitSets=null;m_chainBitSets=[];m_edgeBitSets=[];m_checkDirtyPlanesweepTolerance=NaN;m_geometryIDIndex=-1;m_clusterIndex=-1;m_halfEdgeIndex=-1;m_tmpHalfEdgeParentageIndex=-1;m_tmpHalfEdgeParentageIndexLeft=-1;m_tmpHalfEdgeWindingNumberIndex=-1;m_tmpHalfEdgeOddEvenNumberIndex=-1;m_segmentParentageIndex=-1;m_segmentIndexHe=-1;m_clusterBreakNodeIndex=-1;m_universeGeomID=-1;m_pointCount=0;m_progressCounter=0;m_bBuildChains=!0;m_bDirtyCheckFailed=!1;constructor(){}setCheckDirtyPlanesweepTolerance(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,n=!0,r=!1){r?this.setEditShapeImpl3D_(e,tr.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,tr.enumInputModeBuildGraph,null,t,n)}setAndSimplifyEditShapeAlternate(e,t,n=null,r=!1){let a=[];a.push(t),this.m_simplifiedGeometry=t,r?this.setEditShapeImpl3D_(e,tr.enumInputModeSimplifyAlternate,a,n,!1):this.setEditShapeImpl_(e,tr.enumInputModeSimplifyAlternate,a,n,e.getGeometryType(t)===i.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,n=null){let r=[];r.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,tr.enumInputModeSimplifyWinding,r,n,!0)}removeShape(){this.m_shape!==null&&(this.m_geometryIDIndex!==-1&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),this.m_clusterIndex!==-1&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),this.m_halfEdgeIndex!==-1&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.m_tmpHalfEdgeWindingNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),this.m_tmpHalfEdgeOddEvenNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),this.m_segmentParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_segmentIndexHe!==-1&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),this.m_clusterBreakNodeIndex!==-1&&(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=z,this.m_lastCluster=z,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=z,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){let n=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(n))}queryXYZ(e,t){l(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){let n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];return r.size()<=n?-1:r.read(n)}setClusterUserIndex(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1),i.write(r,n)}hasClusterUserIndexFlags(e,t,n){if(t===-1)return!1;let r=this.getClusterUserIndex(e,t);return r!==-1&&(n&r)!==0}setClusterUserIndexFlags(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1);let a=i.read(r);a===-1&&(a=0),i.write(r,n|a)}clearClusterUserIndexFlags(e,t,n){let r=this.getClusterIndex_(e),i=this.m_clusterIndices[t];i.size()<=r&&i.resize(this.m_clusterData.size(),-1);let a=i.read(r);a===-1&&(a=0),i.write(r,~n&a)}createUserIndexForClusters(e=-1){let t=new Re(this.m_clusterData.capacity(),e);for(let e=0,n=this.m_clusterIndices.length;e<n;e++)if(this.m_clusterIndices[e]===null)return this.m_clusterIndices[e]=t,e;return this.m_clusterIndices.push(t),this.m_clusterIndices.length-1}deleteUserIndexForClusters(e){this.m_clusterIndices[e]=null}getHalfEdgeOrigin(e){return this.m_halfEdgeData.getField(e,1)}getHalfEdgeTo(e){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(e))}getHalfEdgeTwin(e){return this.m_halfEdgeData.getField(e,4)}getHalfEdgePrev(e){return this.m_halfEdgeData.getField(e,5)}getHalfEdgeNext(e){return this.m_halfEdgeData.getField(e,6)}getHalfEdgeChain(e){return this.m_halfEdgeData.getField(e,2)}getHalfEdgeFaceParentage(e){return this.getChainParentage(this.getHalfEdgeChain(e))}getHalfEdgeVertexIterator(e){return this.m_halfEdgeData.getField(e,7)}getHalfEdgeFromXY(e,t){this.queryXY(this.getHalfEdgeOrigin(e),t)}getHalfEdgeToXY(e,t){this.queryXY(this.getHalfEdgeTo(e),t)}isHalfEdgeCurve(e){return this.m_segmentIndexHe!==-1&&this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)!==-1}getHalfEdgeFromXYZ(e,t){l(0)}getHalfEdgeToXYZ(e,t){l(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&sr.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){let n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];return r.size()<=n?-1:r.read(n)}setHalfEdgeUserIndex(e,t,n){let r=this.getHalfEdgeIndex_(e),i=this.m_edgeIndices[t];i.size()<=r&&i.resize(this.m_halfEdgeData.size(),-1),i.write(r,n)}createUserIndexForHalfEdges(e){e===void 0&&(e=-1);let t=new Re(this.m_halfEdgeData.capacity(),e);for(let e=0,n=this.m_edgeIndices.length;e<n;e++)if(this.m_edgeIndices[e]===null)return this.m_edgeIndices[e]=t,e;this.m_edgeIndices.push(t);let n=this.m_edgeIndices.length-1;return l(n>=0&&n<=2**53-1),n}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.getHalfEdgeChain(n),i=this.getHalfEdgeTwin(n),a=this.getHalfEdgeChain(i);this.setChainHalfEdge_(r,z),this.setChainHalfEdge_(a,z),this.updateVertexToHalfEdgeConnection_(n,!0),this.deleteEdgeImpl_(n)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonInterior(e,t){return l(0),!1}doesClusterBelongToAPolygonExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return l(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){let t=this.getChainIndex_(e),n=this.m_chainAreas.read(t);return Number.isNaN(n)&&(this.updateChainAreaAndPerimeter_(e),n=this.m_chainAreas.read(t)),n}getChainPerimeter(e){return l(0),0}getChainUserIndex(e,t){let n=this.getChainIndex_(e),r=this.m_chainIndices[t];return r.size()<=n?-1:r.read(n)}setChainUserIndex(e,t,n){let r=this.getChainIndex_(e),i=this.m_chainIndices[t];i.size()<=r&&i.resize(this.m_chainData.size(),-1),i.write(r,n)}createUserIndexForChains(){let e=new Re(this.m_chainData.capacity(),-1);for(let t=0,n=this.m_chainIndices.length;t<n;t++)if(this.m_chainIndices[t]===null)return this.m_chainIndices[t]=e,t;return this.m_chainIndices.push(e),this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,n,r){let a=t===z?e.createGeometry(i.enumPolygon):t,o=new F;this.extractPolygonPathFromChain_(e,a,n,r,o);for(let t=this.getChainFirstIsland(n);t!==z;t=this.getChainNextInParent(t))this.extractPolygonPathFromChain_(e,a,t,r,o);return a}getGeometryID(e){let t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return l(t>=0),1<<Math.min(t,31)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_clusterIndex)}getHalfEdgeFromVertex(e){return this.m_shape.getUserIndex(e,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(e){if(l(this.m_bBuildGeometryParentageSets),this.m_chainBitSetIndex===-1)return this.getEmptySet();let t=this.getChainUserIndex(e,this.m_chainBitSetIndex);l(t>=0);let n=this.m_chainBitSets.at(t);return n||=this.getEmptySet(),n}getChainBoundaryBitSet(e){l(this.m_bBuildGeometryParentageSets);let t=new Zn,n=e=>{let n=this.getChainHalfEdge(e),r=n;do{let e=this.getEdgeBitSet_(r);e!==null&&t.assignOr(e);let n=this.getEdgeBitSet_(this.getHalfEdgeTwin(r));n!==null&&t.assignOr(n),r=this.getHalfEdgeNext(r)}while(r!==n)};n(e);for(let t=this.getChainFirstIsland(e);t!==z;t=this.getChainNextInParent(t))n(e);return t}getChainPolygons(e){return l(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||e===null)return[];if(this.m_geometryMapID===null){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==z;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}let t=[],n=e.getUnorderedBitIterator();for(let e=n.next();e!==Jn.npos();e=n.next())l(this.m_geometryMapID.has(e)),t.push(this.m_geometryMapID.get(e));return t}getVertexDominant(e,t){if(t===z)return e;let n=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(n,t)}getVertexDominantFromCluster(e,t){if(t!==z){let n=z;for(let r=this.getClusterVertexIterator(e);r!==z;r=this.incrementVertexIterator(r)){let e=this.getVertexFromVertexIterator(r);n===z&&(n=e);let i=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(i)===t){n=e;break}}return n}{let t=this.getClusterVertexIterator(e);return t===z?z:this.getVertexFromVertexIterator(t)}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode)}setBreakNode(e,t){l(this.m_clusterBreakNodeIndex!==-1),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode)}setStrongPathNode(e,t){if(this.m_clusterBreakNodeIndex===-1){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,nr.enumPathBreakNode)}getSegmentParentage(e){if(this.m_segmentParentageIndex===-1)return-1;let t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){let t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;let n=this.getHalfEdgeTwin(t),r=this.getHalfEdgeNext(n);return e!==this.getHalfEdgeTwin(r)}isCrossroadBehind(e){return l(0),!1}getHalfEdgeConnector(e,t){let n=this.getClusterHalfEdge(e);if(n===z)return z;let r=n,i=z,a=z;do{if(this.getHalfEdgeTo(r)===t)return r;if(i===z){if(i=this.getClusterHalfEdge(t),i===z)return z;a=i}if(this.getHalfEdgeTo(a)===e)return r=this.getHalfEdgeTwin(a),r;r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r)),a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(r!==n&&a!==i);return z}querySegmentXY(e,t){if(this.m_segmentIndexHe!==-1){let n=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(n!==-1){if(n!==-2){let e=this.m_shape.getSegmentFromIndex(n);t.copyFrom(e,!0)}else{n=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);let r=this.m_shape.getSegmentFromIndex(n);t.copyFrom(r,!0),t.get().reverse()}return}}t.createLine();let n=t.get(),r=U.getNAN();this.getHalfEdgeFromXY(e,r),n.setStartXY(r),this.getHalfEdgeToXY(e,r),n.setEndXY(r)}isCurveEdge(e){return this.m_segmentIndexHe!==-1&&this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)!==-1}compareEdgeAnglesCurveHelper_(e,t,n){let r=new F,i=new F;this.querySegmentXY(e,r),this.querySegmentXY(t,i);let a=r.get(),o=i.get();if(a.equals(o))return 0;let s=new U;this.getHalfEdgeFromXY(e,s);let c=new U;this.getHalfEdgeToXY(e,c);let u=new U;return this.getHalfEdgeToXY(t,u),l(!c.isEqualPoint2D(u)),ce(a,o)}compareEdgeAnglesHelper_(e,t,n){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,n);let r=U.getNAN();this.getHalfEdgeToXY(e,r);let i=U.getNAN();if(this.getHalfEdgeToXY(t,i),r.isEqualPoint2D(i))return 0;let a=U.getNAN();this.getHalfEdgeFromXY(e,a);let o=U.getNAN();o.setSub(r,a);let s=U.getNAN();return s.setSub(i,a),!n||s.y>=0&&o.y>0?U.compareVectors(o,s):0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return l(0),0}compareEdgeAnglesForPair3D_(e,t){return l(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){let t=this.getHalfEdgeChain(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeChain(n);l(r===t),l(e===this.getHalfEdgeNext(n)||n===this.getHalfEdgeNext(e));let i=this.getHalfEdgeNext(e);i===n&&(i=this.getHalfEdgeNext(i),i===e&&(i=z));let a=this.getChainIndex_(t),o=this.m_chainAreas.read(a);Number.isNaN(o)||(this.setChainArea_(t,NaN),this.setChainPerimeter_(t,NaN));let s=this.getChainHalfEdge(t);(s===e||s===n)&&this.setChainHalfEdge_(t,i),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,n){let r=t===z?this.getClusterHalfEdge(e):t;if(r===z)return z;let i=r;for(;;){if(this.getHalfEdgeUserIndex(r,n)!==1)return r;let e=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));if(e===i)return z;r=e}}removeSpikes_(){let e=!1,t=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==z;n=this.getNextCluster(n)){let r=z;for(;;){let i=this.getFirstUnvisitedHalfEdgeOnCluster_(n,r,t);if(i===z)break;r=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));let a=i;for(;;){let n=this.getHalfEdgeNext(a),o=this.getHalfEdgePrev(a),s=this.getHalfEdgeTwin(a);if(o===s){if(this.deleteEdgeInternal_(a),e=!0,(r===a||r===s)&&(r=z),a===i||o===i){if(i=n,a===i||o===i)break;a=n;continue}}else this.setHalfEdgeUserIndex(a,t,1);if(a=n,a===i)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){let e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){let e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);let t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){let e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return l(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){let n=t?z:e;for(let t=this.getHalfEdgeVertexIterator(e);t!==z;t=this.incrementVertexIterator(t)){let e=this.getVertexFromVertexIterator(t);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,n)}}updateVertexToHalfEdgeConnection_(e,t){e!==z&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);let n=this.getChainFirstIsland(t);this.setChainNextInParent_(e,n),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){let n=this.getChainIndex_(e);this.m_chainAreas.write(n,t)}setChainPerimeter_(e,t){let n=this.getChainIndex_(e);this.m_chainPerimeters.write(n,t)}updateChainAreaAndPerimeter_(e){let t=this.m_shape.hasCurves(),n=new St(0),r=new St(0),i=this.getChainHalfEdge(e),a=U.getNAN(),o=U.getNAN(),s=U.getNAN();this.getHalfEdgeFromXY(i,a),o.setCoordsPoint2D(a);let c=i;do this.getHalfEdgeToXY(c,s),(!t||!this.isCurveEdge(c))&&r.pe(U.distance(o,s)),this.getHalfEdgeChain(this.getHalfEdgeTwin(c))!==e&&n.pe((s.x-a.x-(o.x-a.x))*(s.y-a.y+(o.y-a.y))*.5),o.setCoordsPoint2D(s),c=this.getHalfEdgeNext(c);while(c!==i);if(t){let t=new F;c=i;do{this.getHalfEdgeToXY(c,s);let i=this.isCurveEdge(c);if(i&&(this.querySegmentXY(c,t),r.pe(t.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(c))!==e&&i){let e=t.get().calculateArea2DHelper();n.pe(e)}c=this.getHalfEdgeNext(c)}while(c!==i)}let l=this.getChainIndex_(e);this.m_chainAreas.write(l,n.getResult()),this.m_chainPerimeters.write(l,r.getResult())}getChainTopmostEdge_(e){return l(0),0}planeSweepParentage_(e,t){let n=new $n(this),r=new Ie;r.setCapacity(Math.trunc(this.m_pointCount/2)),r.setComparator(n);let i=[],a=this.createUserIndexForHalfEdges(),o=null,s=U.getNAN();for(let c=this.getFirstCluster();c!==z;c=this.getNextCluster(c)){this.progress_(t);let l=this.getClusterHalfEdge(c);if(l!==z){if(i.length=0,!this.tryOptimizedInsertion_(r,a,i,c,l)){this.queryXY(c,s),n.setY(s.y);let e=l;do{let t=this.getHalfEdgeUserIndex(e,a);t!==-1&&(r.deleteNode(t),this.setHalfEdgeUserIndex(e,a,rt.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(l!==e);e=l;do{if(this.getHalfEdgeUserIndex(e,a)===-1){let t=r.addElement(e);i.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(l!==e)}for(let t=i.length-1;t>=0;t--){let n=i[t],o=r.getElement(n),s=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(s,a,n),this.planeSweepParentagePropagateParentage_(r,n,e)}}else if(this.getClusterChain(c)===z){o===null&&(o=new er(this)),this.queryXY(c,s),o.setPointXY(s);let e=r.searchLowerBound(o),t=this.m_universeChain;if(e!==-1){let n=r.getElement(e);this.getHalfEdgeChain(n)===this.getHalfEdgeChain(this.getHalfEdgeTwin(n))&&(n=this.getLeftSkipPolylines_(r,e)),n!==z&&(t=this.getHalfEdgeChain(n))}this.addClusterToExteriorChain_(t,c)}}this.deleteUserIndexForHalfEdges(a)}planeSweepParentagePropagateParentage_(e,t,n){let r=e.getElement(t),i=this.getHalfEdgeChain(r);if(this.getChainParent(i)!==z)return;let a=this.getLeftSkipPolylines_(e,t),o=this.getHalfEdgeTwin(r),s=this.getHalfEdgeChain(o),c=this.getChainParent(i),u=this.getChainParent(s);if(a===z)c===z&&(s===i?(this.setChainParent_(s,this.m_universeChain),u=this.m_universeChain,c=u):(u===z&&(this.setChainParent_(s,this.m_universeChain),u=this.m_universeChain),this.setChainParent_(i,s),c=s));else{let e=this.getHalfEdgeChain(a);if(u===z){if(this.getChainArea(e)<=0){let t=this.getChainParent(e);this.setChainParent_(s,t),u=t}else this.setChainParent_(s,e),u=e;s===i&&(c=u)}}c===z&&(this.trySetChainParentFromTwin_(i,s),c=this.getChainParent(i)),l(c!==z),n===tr.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,r,a):n===tr.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,r,a,o,i,s):n===tr.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,r,a,o,i,s)}propagateParentageBuildGraph_(e,t,n,r){let i=t,a;r===z?(i=e.getNext(i),a=this.getHalfEdgeChain(n)):a=this.getHalfEdgeChain(r);let o=null,s=this.getChainParentage(a);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(a));i!==-1;i=e.getNext(i)){let t=e.getElement(i),n=this.getHalfEdgeTwin(t);a=this.getHalfEdgeChain(t);let r=this.getHalfEdgeChain(n);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(r);e=new Zn({copy:e}),e.assignOr(o),this.setChainBitSet_(r,e);let n=this.getChainBitSet(a),i=this.getLeftEdgeBitSet_(t),s=new Zn({copy:o});if(s.assignSubtract(i),s.isZero())break;n=new Zn({copy:n}),n.assignOr(s),this.setChainBitSet_(a,n),o=n}let c=this.getChainParentage(r),l=c|s;l!==c&&this.setChainParentage_(r,l);let u=this.getChainParentage(a),d=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft),f=s&~d;if(f&&(u|=f,this.setChainParentage_(a,u)),f===0)break;s=u}}propagateParentageWinding_(e,t,n,r,i,a,o){if(a===o)return;let s=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex);s+=this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex);let c=0,u=[],d=[];d.push(0);for(let n=e.getFirst();n!==t;n=e.getNext(n)){let t=e.getElement(n),r=this.getHalfEdgeTwin(t),i=this.getHalfEdgeChain(t),a=this.getHalfEdgeChain(r);if(i!==a){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex),c+=e;let n=!1;u.length!==0&&u.at(-1)===a&&(d.pop(),u.pop(),n=!0),l(this.getChainParent(a)!==z),(!n||this.getChainParent(a)!==i)&&(d.push(c),u.push(i))}}if(c+=s,u.length!==0&&u.at(-1)===o&&(d.pop(),u.pop()),c!==0){if(d.at(-1)===0){let e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}else if(d.at(-1)!==0){let e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(a,t)}}propagateParentageAlternate_(e,t,n,r,i,a,o){let s=this.m_simplifiedGeometry,c=this.getGeometryID(s);if(r===z)this.setChainParentage_(o,this.m_universeGeomID),this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,c):this.setChainParentage_(a,this.m_universeGeomID);else{let e=this.getChainParentage(o);if(e===0){let e=this.getHalfEdgeChain(r),t=this.getChainParentage(e);this.setChainParentage_(o,t),this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,t===c?this.m_universeGeomID:c):this.setChainParentage_(a,t)}else this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex)&1?this.setChainParentage_(a,e===c?this.m_universeGeomID:c):this.setChainParentage_(a,e)}}tryOptimizedInsertion_(e,t,n,r,i){let a=i,o=-1,s=z,c=0;do{if(c===2)return!1;let e=this.getHalfEdgeUserIndex(a,t);if(e!==-1){if(o!==-1)return!1;o=e}else{if(s!==z)return!1;s=a}c++,a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(i!==a);return s===z||o===-1?!1:(this.setHalfEdgeUserIndex(e.getElement(o),t,rt.impossibleIndex2()),e.setElement(o,s),n.push(o),!0)}trySetChainParentFromTwin_(e,t){let n=this.getChainArea(e);if(n===0)return!1;let r=this.getChainArea(t);if(n>0&&r<0||n<0&&r>0)return this.setChainParent_(e,t),!0;{let n=this.getChainParent(t);if(n!==z)return this.setChainParent_(e,n),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let n=0,r=t.size();n<r;n++){let r=t.read(n),a=this.m_shape.getUserIndex(r,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(r),c=this.m_shape.getGeometryFromPath(o),l=this.m_shape.getGeometryType(c);if(s(l)){let t=this.m_shape.getNextVertex(r);if(t===z)continue;let n=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(a===n)continue;let o=this.newHalfEdgePair_(),s=this.getHalfEdgeTwin(o),u=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(u,0,r),this.m_clusterVertices.setField(u,1,-1),this.setHalfEdgeVertexIterator_(o,u),this.m_shape.setUserIndex(r,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,a);let d=this.getClusterHalfEdge(a);if(d===z)this.setClusterHalfEdge_(a,o),this.setHalfEdgePrev_(o,s),this.setHalfEdgeNext_(s,o);else{let e=this.getHalfEdgePrev(d);this.setHalfEdgePrev_(d,s),this.setHalfEdgeNext_(s,d),this.setHalfEdgeNext_(e,o),this.setHalfEdgePrev_(o,e)}this.setHalfEdgeOrigin_(s,n);let f=this.getClusterHalfEdge(n);if(f===z)this.setClusterHalfEdge_(n,s),this.setHalfEdgeNext_(o,s),this.setHalfEdgePrev_(s,o);else{let e=this.getHalfEdgePrev(f);this.setHalfEdgePrev_(f,o),this.setHalfEdgeNext_(o,f),this.setHalfEdgeNext_(e,s),this.setHalfEdgePrev_(s,e)}let p=this.getGeometryID(c);if(e===tr.enumInputModeBuildGraph){let e=l===i.enumPolygon?p:0;if(this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){let e=new Zn,t=this.m_shape.getGeometryUserIndex(c,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(o,e),this.setEdgeBitSet_(s,null),this.setLeftEdgeBitSet_(s,e),this.setLeftEdgeBitSet_(o,null)}}else if(e===tr.enumInputModeSimplifyWinding){let e=this.m_shape.getXY(r),n=this.m_shape.getXY(t),i=0,a=0;e.compare(n)<0?i=1:a=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,i),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex,a)}else e===tr.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex,1));let m=l===i.enumPolygon?sr.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,p|m),this.setHalfEdgeParentage_(s,p|m)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,n=t.size();e<n;e++){let n=t.read(e);if(this.m_shape.getSegment(n)){let e=this.m_shape.getUserIndex(n,this.m_halfEdgeIndex);e!==z&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(n)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{let n=this.getHalfEdgeVertexIterator(t);if(n!==z){let r=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(n,1,r),this.setHalfEdgeVertexIterator_(e,n),this.setHalfEdgeVertexIterator_(t,z)}}let n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeTwin(t);{let e=this.getHalfEdgeVertexIterator(r);if(e!==z){let t=this.getHalfEdgeVertexIterator(n);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(n,e),this.setHalfEdgeVertexIterator_(r,z)}}if(this.m_segmentIndexHe!==-1){let i=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(i!==-1){if(i===-2){let n=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,n)}if(i=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe),i===-2){let e=this.getHalfEdgeUserIndex(r,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(n,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){let t=[];for(let n=this.getFirstCluster();n!==z;n=this.getNextCluster(n)){t.length=0;let r=this.getClusterHalfEdge(n);if(r!==z){let i=r;do t.push(i),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));while(i!==r);if(t.length>1){let i=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=gt(t[0],t[0]=t[1]):i=!1;let a=t[0],o=a,s=this.getHalfEdgeTo(o),c=this.getHalfEdgeTwin(o),l=z;for(let n=1,r=t.length;n<r;n++){let r=t[n],i=this.getHalfEdgeTwin(r),u=this.getHalfEdgeOrigin(i);if(u===s&&r!==o){if(e===tr.enumInputModeBuildGraph){let e=this.getHalfEdgeParentageMask_(o)|this.getHalfEdgeParentageMask_(r);if(this.setHalfEdgeParentage_(o,e),this.setHalfEdgeParentage_(c,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,n;e=this.getEdgeBitSet_(o),t=this.getEdgeBitSet_(r),n=new Zn({copy:e}),n.assignOr(t),this.setEdgeBitSet_(o,n),e=this.getEdgeBitSet_(c),t=this.getEdgeBitSet_(i),n=new Zn({copy:e}),n.assignOr(t),this.setEdgeBitSet_(c,n),e=this.getLeftEdgeBitSet_(o),t=this.getLeftEdgeBitSet_(r),n=new Zn({copy:e}),n.assignOr(t),this.setLeftEdgeBitSet_(o,n),e=this.getLeftEdgeBitSet_(c),t=this.getLeftEdgeBitSet_(i),n=new Zn({copy:e}),n.assignOr(t),this.setLeftEdgeBitSet_(c,n)}}else if(this.m_tmpHalfEdgeWindingNumberIndex!==-1){let e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(this.m_tmpHalfEdgeOddEvenNumberIndex!==-1){let e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(c,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(c,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(o,r),this.deleteEdgeImpl_(r),l=o,t[n]=z,r===a&&(t[0]=z,a=z);continue}this.updateVertexToHalfEdgeConnection_(l,!1),l=z,o=r,s=u,c=i}if(this.updateVertexToHalfEdgeConnection_(l,!1),l=z,!i){a=z;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n!==z){a=n;break}}r!==a&&this.setClusterHalfEdge_(n,a);continue}a=z;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n===z)continue;if(a===z){a=n,o=a,s=this.getHalfEdgeTo(o),c=this.getHalfEdgeTwin(o);continue}if(n===o)continue;let r=this.getHalfEdgeTwin(n),i=this.getHalfEdgeOrigin(r);this.setHalfEdgeNext_(c,n),this.setHalfEdgePrev_(n,c),o=n,s=i,c=r}this.setClusterHalfEdge_(n,a)}}}}sortHalfEdgesByAngle3D_(e){l(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,z);let t=this.m_universeChain,n=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let r=this.getClusterHalfEdge(e);if(r!==z){let e=r;do{if(this.getHalfEdgeUserIndex(e,n)!==1){let r=this.newChain_();this.setChainHalfEdge_(r,e),this.setChainPrev_(r,t),this.setChainNext_(t,r);let i=null;this.m_bBuildGeometryParentageSets&&(i=new Zn),t=r;let a=0,o=e;do this.m_tmpHalfEdgeParentageIndex!==-1&&(a|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&i.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,r),this.setHalfEdgeUserIndex(o,n,1),o=this.getHalfEdgeNext(o);while(o!==e);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(r,i),this.setChainParentage_(r,a)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(e!==r)}}this.m_chainAreas=new it(this.m_chainData.size(),NaN),this.m_chainPerimeters=new it(this.m_chainData.size(),NaN),this.setChainArea_(this.m_universeChain,1/0),this.setChainPerimeter_(this.m_universeChain,1/0),this.deleteUserIndexForHalfEdges(n)}simplify_(e){l(0)}simplifyAlternate_(){l(0)}simplifyWinding_(){l(0)}setEditShapeImpl_(e,t,n,r,i){this.removeShape(),this.m_bBuildChains=i,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let a=this.m_shape.getTotalPointCount();if(n){a=0;for(let e=0,t=n.length;e<t;e++)a+=this.m_shape.getPointCount(n[e])}let o=new Re(0),s=0,c=0;{let e=n==null?this.m_shape.getFirstGeometry():n[0],t=1;for(;e!==z;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,c++);for(let t=this.m_shape.getFirstPath(e);t!==z;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let n=0,r=this.m_shape.getPathSize(t);n<r;n++)o.add(e),e=this.m_shape.getNextVertex(e)}b(this.m_shape.getGeometryType(e))||(s+=this.m_shape.getPathCount(e)),n==null?e=this.m_shape.getNextGeometry(e):(e=t<n.length?n[t]:z,t++)}}this.m_universeGeomID=1<<Math.min(c,31),this.m_pointCount=o.size(),this.m_shape.sortVerticesSimpleByY(o,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(r,!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,s)),this.m_clusterIndex=this.m_shape.createUserIndex();let l=U.getNAN(),u=0,d=U.getNAN();for(let e=0;e<=this.m_pointCount;e++){if(e<this.m_pointCount){let t=o.read(e);this.m_shape.queryXY(t,d)}else d.setNAN();if(!l.isEqualPoint2D(d)){if(u<e){let t=this.newCluster_(),n=z,r=-1;for(let i=u;i<e;i++){r=o.read(i),this.m_shape.setUserIndex(r,this.m_clusterIndex,t);let e=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(e,0,r),this.m_clusterVertices.setField(e,1,n),n=e;let a=this.m_shape.getPathFromVertex(r),s=this.m_shape.getGeometryFromPath(a),c=this.getGeometryID(s);this.setClusterParentage_(t,this.getClusterParentage(t)|c)}this.setClusterVertexIterator_(t,n),this.setClusterVertexIndex_(t,this.m_shape.getVertexIndex(r)),this.m_lastCluster!==z&&this.setNextCluster_(this.m_lastCluster,t),this.setPrevCluster_(t,this.m_lastCluster),this.m_lastCluster=t,this.m_firstCluster===z&&(this.m_firstCluster=t)}u=e,l.setCoordsPoint2D(d)}}if(this.m_shape.hasSegmentParentage()){this.m_clusterBreakNodeIndex===-1&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){let t=o.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){let e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(r,!0);{let e=n==null?this.m_shape.getFirstGeometry():n[0],t=1;for(;e!==z;){for(let t=this.m_shape.getFirstPath(e);t!==z;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){let e=this.m_shape.getFirstVertex(t),n=this.getClusterFromVertex(e);this.setStrongPathNode(n,!0)}if(this.m_shape.isStrongPathEnd(t)){let e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),n=this.getClusterFromVertex(e);this.setStrongPathNode(n,!0)}}n==null?e=this.m_shape.getNextGeometry(e):(e=t<n.length?n[t]:z,t++)}}if(t===tr.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===tr.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===tr.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,o),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_()){this.m_bDirtyCheckFailed=!0,this.cleanSetEditShapeImpl_();return}this.buildChains_(t),this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,r),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(e,t,n,r,i){l(0)}cleanSetEditShapeImpl_(){this.m_tmpHalfEdgeParentageIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_tmpHalfEdgeParentageIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.m_tmpHalfEdgeWindingNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),this.m_tmpHalfEdgeOddEvenNumberIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){l(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){let t=this.getHalfEdgeNext(e),n=this.getHalfEdgePrev(e),r=this.getHalfEdgeTwin(e),i=this.getHalfEdgeNext(r),a=this.getHalfEdgePrev(r);t!==r&&(this.setHalfEdgeNext_(a,t),this.setHalfEdgePrev_(t,a)),n!==r&&(this.setHalfEdgeNext_(n,i),this.setHalfEdgePrev_(i,n));let o=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(o)===e&&(i===e?this.setClusterHalfEdge_(o,z):this.setClusterHalfEdge_(o,i));let s=this.getHalfEdgeOrigin(r);this.getClusterHalfEdge(s)===r&&(t===r?this.setClusterHalfEdge_(s,z):this.setClusterHalfEdge_(s,t)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(r)}getLeftSkipPolylines_(e,t){let n=t;for(;;)if(n=e.getPrev(n),n!==-1){let t=e.getElement(n);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}else return z}checkStructureAfterDirtySweep_(){let e=Dt(this.m_checkDirtyPlanesweepTolerance),t=new U,n=new U,r=new U,i=new U,a=new U;for(let o=this.getFirstCluster();o!==z;o=this.getNextCluster(o)){let s=this.getClusterHalfEdge(o);if(s!==z){let o=s;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,n),r.setSub(n,t);let c=r.sqrLength();do{let s=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==s){this.getHalfEdgeToXY(o,i),a.setSub(i,t);let s=a.sqrLength(),l=a.crossProduct(r),u=l*l/(s*c);if(Math.min(s,c)*u<=e&&a.dotProduct(r)>=0)return!1;r.assign(a),c=s,n.assign(i)}}while(o!==s)}}return!0}extractPolygonPathFromChain_(e,t,n,r,i){let a=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(n),s=o,c=z,l=new B;do{let o=this.getHalfEdgeTwin(s);if(this.getHalfEdgeChain(o)!==n){let n=z,o=this.getHalfEdgeOrigin(s);if(r===z){let e=this.getClusterVertexIterator(o);n=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==z;e=this.incrementVertexIterator(e)){let t=this.getVertexFromVertexIterator(e);n===z&&(n=t);let i=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(i)===r){n=t;break}}c===z&&(c=e.insertPath(t,z),e.setClosedPath(c,!0));let u;if(this.m_shape===e?u=e.addVertex(c,n):(this.m_shape.queryPoint(n,l),u=e.addPoint(c,l)),this.isHalfEdgeCurve(s)&&(this.querySegmentXY(s,i),e.setSegmentToIndex(e.getVertexIndex(u),i.get().clone())),a){let t=this.getSegmentParentage(s);e.setSegmentParentageAndBreak(u,t,this.isBreakNode(o))}}s=this.getHalfEdgeNext(s)}while(s!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;l(this.m_clusterBreakNodeIndex!==-1),l(this.m_segmentParentageIndex===-1);for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let t=0,n=this.getClusterHalfEdge(e);if(n!==z){let e=n;do t++,e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e));while(e!==n&&t<3)}t!==2&&this.setBreakNode(e,!0)}let e=[],t=[],n=e,r=t;this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();let i=this.createUserIndexForHalfEdges();for(let e=this.getFirstCluster();e!==z;e=this.getNextCluster(e)){let t=this.getClusterHalfEdge(e);if(t!==z){let e=!1,a=t;do{let t=a;for(;this.getHalfEdgeUserIndex(t,i)===-1;){let a=this.getHalfEdgeNext(t),o=this.getHalfEdgeTwin(t);ar(this,t,r);let s=r.at(-1).parentage;if(!e){let r=this.getHalfEdgeOrigin(t);if(!this.isBreakNode(r)){let r=this.getHalfEdgePrev(t);t!==r&&(ar(this,r,n),e=!0)}}if(e&&!ir(r,n)){let e=this.getHalfEdgeOrigin(t);this.setBreakNode(e,!0)}n=gt(r,r=n),e=!0;let c=this.getHalfEdgeOrigin(a);this.isBreakNode(c)&&(e=!1),this.setHalfEdgeUserIndex(t,this.m_segmentParentageIndex,s),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,s),this.setHalfEdgeUserIndex(t,i,1),this.setHalfEdgeUserIndex(o,i,1),t=a}a=this.getHalfEdgeNext(this.getHalfEdgeTwin(a))}while(a!==t)}}this.deleteUserIndexForHalfEdges(i)}registerNewBitSet(e){return this.m_uniqueBitSets===null&&(this.m_uniqueBitSets=or(),this.m_uniqueBitSets.add(this.getEmptySet())),e===null?this.getEmptySet():this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){let t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return l(t>=0),l(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){let t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return l(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_edgeBitSetIndex===-1&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());let n=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);n===-1?(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t)):this.m_edgeBitSets[n]=t}setLeftEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_edgeBitSetIndexLeft===-1&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());let n=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);n===-1?(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t)):this.m_edgeBitSets[n]=t}setChainBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),this.m_chainBitSetIndex===-1&&(this.m_chainBitSetIndex=this.createUserIndexForChains());let n=this.getChainUserIndex(e,this.m_chainBitSetIndex);n===-1?(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t)):this.m_chainBitSets[n]=t}getEmptySet(){return this.m_emptyBitSet||=new Zn,this.m_emptyBitSet}deleteEdgeBitSets_(){this.m_edgeBitSetIndex!==-1&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),this.m_edgeBitSetIndexLeft!==-1&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){this.m_chainBitSetIndex!==-1&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(e){}dbgVerifyEdgeSegment(e){}}class Y{m_listNodes=new rt(2);m_lists;m_listOfLists=Y.st_nullNode();m_bAllowNavigationBetweenLists=!0;freeNode_(e){this.m_listNodes.deleteElement(e)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){this.m_lists.deleteElement(e)}newList_(){return this.m_lists.newElement()}Init_(e){l(0)}constructor(e){e===void 0&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new rt(this.m_bAllowNavigationBetweenLists?4:2)}createList(){let e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==Y.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,e),this.m_listOfLists=e),e}deleteList(e){let t=this.getFirst(e);for(;t!==Y.st_nullNode();){let e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){let t=this.m_lists.getField(e,2),n=this.m_lists.getField(e,3);t===Y.st_nullNode()?this.m_listOfLists=n:this.m_lists.setField(t,3,n),n!==Y.st_nullNode()&&this.m_lists.setField(n,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);let n=this.m_lists.getField(e,1),r=this.newNode_();return n===Y.st_nullNode()?(this.m_lists.setField(e,0,r),this.m_lists.setField(e,1,r)):(this.m_listNodes.setField(n,1,r),this.m_lists.setField(e,1,r)),this.m_listNodes.setField(r,0,t),r}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,n){t===Y.st_nullNode()?(this.m_lists.setField(e,0,this.m_listNodes.getField(n,1)),this.m_lists.getField(e,1)===n&&this.m_lists.setField(e,1,Y.st_nullNode())):(this.m_listNodes.setField(t,1,this.m_listNodes.getField(n,1)),this.m_lists.getField(e,1)===n&&this.m_lists.setField(e,1,t)),this.freeNode_(n)}deleteElementSearch(e,t){let n=-1,r=this.getFirst(e);for(;r!==t;)n=r,r=this.getNext(r);this.deleteElementDirect(e,n,t)}concatenateLists(e,t){let n=this.m_lists.getField(e,1),r=this.m_lists.getField(t,0);if(r!==Y.st_nullNode()&&(n===Y.st_nullNode()?(this.m_lists.setField(e,0,r),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_listNodes.setField(n,1,r),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){let e=this.m_lists.getField(t,2),n=this.m_lists.getField(t,3);e===Y.st_nullNode()?this.m_listOfLists=n:this.m_lists.setField(e,3,n),n!==Y.st_nullNode()&&this.m_lists.setField(n,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){l(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){let t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=Y.st_nullNode()}isEmpty(e){return l(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(e){return this.m_lists.getField(e,3)}}function cr(e=-1){return{m_value:e,m_line:new I,m_segment:null,m_segmentInfo:new Se(-1),m_env:new W(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class lr extends tt{m_shape;m_bIntersectionDetected=!1;m_nonSimpleResult=new J;m_tempSimpleEdge1=cr();m_tempSimpleEdge2=cr();m_prev1=z;m_prev2=z;m_vertex1=z;m_vertex2=z;m_currentNode=-1;m_prevX1=NaN;m_prevX2=NaN;m_prevY=NaN;m_prevX=0;m_sweepY=NaN;m_sweepX=0;m_ptSweep=new U;m_tolerance;m_tolerance10;m_bIsSimple;m_bShapeHasSegments;m_simpleEdgesCache=[];m_simpleEdgesRecycle=[];m_cOutstandingConstructedEdges=0;constructor(e,t,n){super(!0),this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=n;let r=Math.trunc(Math.min(e.getTotalPointCount()*3/2,67)),i=Math.min(7,r);this.m_simpleEdgesCache.length=i}tryGetCachedEdge_(e){let t=this.m_simpleEdgesCache[(e&It())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){let t=(e&It())%this.m_simpleEdgesCache.length,n=this.m_simpleEdgesCache[t];n&&n.m_value===e&&(this.m_simpleEdgesRecycle.push(n),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){let t=(e&It())%this.m_simpleEdgesCache.length,n=this.m_simpleEdgesCache[t];return n?null:(this.m_simpleEdgesRecycle.length===0?(n=cr(),this.m_cOutstandingConstructedEdges++):n=this.m_simpleEdgesRecycle.pop(),n.m_value=e,this.m_simpleEdgesCache[t]=n,n)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=e.m_segment!==null,e.m_bCurve){let t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){let n=e.getStartXY(),r=e.getEndXY(),i=t.getStartXY(),a=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),n.isEqualPoint2D(i)&&this.m_sweepY===n.y){this.m_ptSweep.assign(r.compare(a)<0?r:a);let n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(n-i)>this.m_tolerance)return n<i?-1:1}let o=n.compare(i)<0?i:n,s=r.compare(a)<0?r:a,c=0,l=0;for(let n=1;n<5;n++){Tt(o,s,n/5,this.m_ptSweep);let r=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),a=Math.abs(r-i);a>c&&(c=a,l=r<i?-1:1)}return l===0?this.errorCracking():l}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);let n=this.compareNonHorizontalLowerEnd_(e,t),r=this.compareNonHorizontalUpperEnd_(e,t);return n<0&&r<0?-1:n>0&&r>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(e,t){let n=U.getNAN();n.setSub(t.getEndXY(),t.getStartXY()),n.rightPerpendicularThis(),n.normalize();let r=U.getNAN();r.setSub(e.getStartXY(),t.getStartXY());let i=U.getNAN();i.setSub(e.getEndXY(),t.getStartXY());let a=r.dotProduct(n),o=i.dotProduct(n),s=Math.abs(a),c=Math.abs(o);if(s<c){if(s<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(c<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return a<0&&o<0?-1:a>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let n=1;if(e.m_line.getStartY()<t.m_line.getStartY()){n=-1;let r=e;e=t,t=r}let r=e.m_line,i=t.m_line,a=r.getStartX()-i.getStartX(),o=t.m_dxdy*(r.getStartY()-i.getStartY()),s=this.m_tolerance10;return a<o-s?-n:a>o+s?n:i.isIntersectingPoint(r.getStartXY(),this.m_tolerance,!0)?this.errorCracking():a<o?-n:n}compareNonHorizontalUpperEnd_(e,t){let n=1;if(t.m_line.getEndY()<e.m_line.getEndY()){n=-1;let r=e;e=t,t=r}let r=e.m_line,i=t.m_line,a=r.getEndX()-i.getStartX(),o=t.m_dxdy*(r.getEndY()-i.getStartY()),s=this.m_tolerance10;return a<o-s?-n:a>o+s?n:i.isIntersectingPoint(r.getEndXY(),this.m_tolerance,!0)?this.errorCracking():a<o?-n:n}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new J(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){return this.m_bIntersectionDetected=!0,this.m_bIsSimple?this.m_nonSimpleResult=new J(6,this.m_vertex1,this.m_vertex2):(this.m_prev1=z,this.m_prev2=z,this.m_vertex1=z,this.m_vertex2=z),-1}compareSegments_(e,t,n,r){if(n.m_env.vmax<r.m_env.vmin)return-1;if(r.m_env.vmax<n.m_env.vmin)return 1;if(!n.m_bCurve&&!r.m_bCurve){let e=+!!n.m_bHorizontal;return e|=r.m_bHorizontal?2:0,e===0?this.compareNonHorizontal_(n,r):e===1?this.compareHorizontal1_(n.m_line,r.m_line):e===2?this.compareHorizontal1_(r.m_line,n.m_line)*-1:this.compareHorizontal2_(n.m_line,r.m_line)}if(this.m_bIntersectionDetected)return-1;let i=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX,a;i&&e===this.m_prev1?a=this.m_prevX1:(a=NaN,this.m_prev1=z);let o;if(i&&t===this.m_prev2?o=this.m_prevX2:(o=NaN,this.m_prev2=z),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(a)){this.m_prev1=e;let t=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=t,this.m_prevX1=t}if(Number.isNaN(o)){this.m_prev2=t;let e=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX2=e}let s=de(!0,!0,n.m_segment,r.m_segment,this.m_tolerance,!0);return s===0?Math.abs(a-o)<=this.m_tolerance?this.compareTwoSegments_(n.m_segment,r.m_segment):a<o?-1:+(a>o):s===2?this.m_bIsSimple?this.errorCoincident():n.m_segmentInfo.equals(r.m_segmentInfo)?0:this.errorCracking():this.errorCracking()}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=z,this.m_prev2=z,this.m_vertex1=z,this.m_vertex2=z}compare(e,t,n){if(this.m_bIntersectionDetected)return-1;let r=e.getElement(n),i=t;return this.m_currentNode=n,this.compareSegments(i,i,r,r)}compareSegments(e,t,n,r){let i=this.tryGetCachedEdge_(e);i===null?this.m_vertex1===t?i=this.m_tempSimpleEdge1:(this.m_vertex1=t,i=this.tryCreateCachedEdge_(e),i===null&&(i=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(i,t)):this.m_vertex1=t;let a=this.tryGetCachedEdge_(n);return a===null?this.m_vertex2===r?a=this.m_tempSimpleEdge2:(this.m_vertex2=r,a=this.tryCreateCachedEdge_(n),a===null&&(a=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=n),this.initSimpleEdge_(a,r)):this.m_vertex2=r,this.compareSegments_(t,r,i,a)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class ur{m_shape;m_bIntersectionDetected=!1;m_pointOfInterest=U.getNAN();m_line1=new I;m_seg1=null;m_env=W.constructEmpty();m_vertex1=-1;m_currentNode=-1;m_minDist=Number.MAX_VALUE;m_tolerance;constructor(e,t){this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){let n=e.getElement(t);return this.compareVertex(e,t,n)}compareVertex(e,t,n){let r=this.m_shape.getSegment(n),i,a=!0;if(r==null)this.m_shape.queryLineConnector(n,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),r=this.m_line1,i=this.m_line1.getStartY()===this.m_line1.getEndY();else{let e=T.constructEmpty();r.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),i=e.height()===0,a=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(i)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let o=0;if(a){me(this.m_line1);let e=this.m_line1.getStartXY(),t=new U;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();let n=new U;n.setSub(this.m_pointOfInterest,e),o=t.dotProduct(n),o/=t.length()}else o=r.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x;return o<-this.m_tolerance*10?-1:o>this.m_tolerance*10?1:(r.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(o)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=o),this.m_bIntersectionDetected=!0),o<0?-1:+(o>0))}}class dr{m_bitFilter;m_hashBuckets;m_lists=new Y(!1);m_hash;constructor(e,t){this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(dr.st_nullNode()),this.m_bitFilter=new Int32Array(e*10+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){t===void 0&&(t=this.m_hash.getHash(e));let n=t%(this.m_bitFilter.length<<5);this.m_bitFilter[n>>5]|=1<<(n&31);let r=t%this.m_hashBuckets.length,i=this.m_hashBuckets[r];return i===Y.st_nullNode()&&(i=this.m_lists.createList(),this.m_hashBuckets[r]=i),this.m_lists.addElement(i,e)}deleteElement(e,t){t===void 0&&(t=this.m_hash.getHash(e));let r=t%this.m_hashBuckets.length,i=this.m_hashBuckets[r];i===Y.st_nullNode()&&n(``);let a=this.m_lists.getFirst(i),o=Y.st_nullNode();for(;a!==Y.st_nullNode();){let t=this.m_lists.getData(a),n=this.m_lists.getNext(a);t===e?(this.m_lists.deleteElementDirect(i,o,a),this.m_lists.getFirst(i)===Y.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[r]=Y.st_nullNode())):o=a,a=n}}getFirstInBucket(e){let t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(t&31)))return Y.st_nullNode();let n=e%this.m_hashBuckets.length,r=this.m_hashBuckets[n];return r===Y.st_nullNode()?Y.st_nullNode():this.m_lists.getFirst(r)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){let t=this.m_hash.getHash(e),n=this.getFirstInBucket(t);for(;n!==Y.st_nullNode();){let t=this.m_lists.getData(n);if(this.m_hash.equal(t,e))return n;n=this.m_lists.getNext(n)}return Y.st_nullNode()}deleteNode(e){let t=this.getElement(e),r=this.m_hash.getHash(t)%this.m_hashBuckets.length,i=this.m_hashBuckets[r];i===Y.st_nullNode()&&n(``),this.m_lists.deleteElementSearch(i,e),this.m_lists.getFirst(i)===Y.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[r]=Y.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return Y.st_nullNode()}clear(){l(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function fr(e,t,n,r,i){let a=new br(i);return a.m_shape=e,a.m_sqrTolerance=t*t,a.m_cellSize=2*t,a.m_invCellSize=1/a.m_cellSize,a.m_geometry=n,a.m_bTrackChanges=r,a.m_bHasSegmentParentage=e.hasSegmentParentage(),a.clusterNonReciprocal()}function pr(e,t,n,r,i){let a=e-n,o=t-r;return a*a+o*o<=i}function mr(){return{pt:new U,weight:0,rank:0,bMerged:!1}}function hr(e,t,n,r,i,a){let o=mr(),s=n+i,c=!1,l=e.x;e.x!==t.x&&(r===a&&(l=(e.x*n+t.x*i)/s),c=!0);let u=e.y;return e.y!==t.y&&(r===a&&(u=(e.y*n+t.y*i)/s),c=!0),r===a?(o.pt.setCoords(l,u),o.weight=s,o.rank=r):r>a?(o.rank=r,o.weight=n,o.pt=e):(o.rank=a,o.weight=i,o.pt=t),o.bMerged=c,o}function gr(e,t,n,r,i,a,o,s,c){let l=e.equals(t);if(r>a)return o.assignCopy(e),c[0]=r,s[0]=n,l;if(a>r)return o=t,c[0]=a,s[0]=i,l;o.assignCopy(e);let u=hr(e.getXY(),t.getXY(),n,r,i,a);return o.setXY(u.pt),s[0]=u.weight,c[0]=u.rank,l}function _r(e,t,n,r,i){let a=new br(i);return a.m_shape=e,a.m_sqrTolerance=t*t,a.m_cellSize=2*t,a.m_invCellSize=1/a.m_cellSize,a.m_geometry=n,a.m_bTrackChanges=!1,a.needsClustering()}function vr(e,t){let n=en(e);return Xt(n,t)}class yr{m_shape;m_sqrTolerance;m_invCellSize;m_origin;m_hashValues;m_workPt=new U;constructor(e,t,n,r,i){this.m_shape=e,this.m_sqrTolerance=n,this.m_invCellSize=r,this.m_origin=t.clone(),this.m_hashValues=i}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);let t=this.m_workPt.x-this.m_origin.x,n=Math.trunc(t*this.m_invCellSize+.5),r=this.m_workPt.y-this.m_origin.y;return vr(n,Math.trunc(r*this.m_invCellSize+.5))}equal(e,t){return l(0),!1}}class br{m_origin=U.getNAN();m_sqrTolerance=0;m_cellSize=0;m_invCellSize=0;m_geometry=z;m_bucketArray=H(4,NaN);m_bucketHash=H(4,NaN);m_dbgCandidateCheckCount=0;m_progressTracker;m_nsr=new J;m_hashValues=-1;m_newClusters=-1;m_bTrackChanges=!1;m_bHasSegmentParentage=!1;m_shape=null;m_clusters=new Y;m_hashFunction=null;m_hashTable=null;m_progressCounter=0;constructor(e){this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){let n=U.getNAN();this.m_shape.queryXY(e,n);let r=(n.x-this.m_origin.x)*this.m_invCellSize,i=(n.y-this.m_origin.y)*this.m_invCellSize,a=Math.trunc(r),o=Math.trunc(i),s=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1){let n=vr(a+e,o+t),r=this.m_hashTable.getFirstInBucket(n);r!==dr.st_nullNode()&&(this.m_bucketArray[s]=r,this.m_bucketHash[s]=n,s++)}for(let e=s-1;e>=1;e--){let t=this.m_bucketArray[e];for(let n=e-1;n>=0;n--)if(t===this.m_bucketArray[n]){this.m_bucketHash[n]=-1,s--,e!==s&&(this.m_bucketHash[e]=this.m_bucketHash[s],this.m_bucketArray[e]=this.m_bucketArray[s]);break}}for(let r=0;r<s;r++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[r],n,this.m_bucketArray[r],t)}collectNearestNeighbourCandidates(e,t,n,r,i){let a=U.getNAN();for(let o=r;o!==dr.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){let r=this.m_hashTable.getElement(o);e===r||t!==-1&&this.m_shape.getUserIndex(r,this.m_hashValues)!==t||(this.m_shape.queryXY(r,a),pr(n.x,n.y,a.x,a.y,this.m_sqrTolerance)&&i.push(o))}}mergeClusters(e,t,n){let r=this.m_shape.getUserIndex(e,this.m_newClusters),i=this.m_shape.getUserIndex(t,this.m_newClusters);r===-1&&(r=this.m_clusters.createList(),this.m_clusters.addElement(r,e),this.m_shape.setUserIndex(e,this.m_newClusters,r)),i===-1?this.m_clusters.addElement(r,t):this.m_clusters.concatenateLists(r,i),this.m_shape.setUserIndex(t,this.m_newClusters,rt.impossibleIndex2());let a=this.mergeVertices(e,t);if(n){let t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return a}mergeVertices(e,t){let n=U.getNAN();this.m_shape.queryXY(e,n);let r=U.getNAN();this.m_shape.queryXY(t,r);let i=this.m_shape.getRank(e),a=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),s=this.m_shape.getWeight(t),c,l,u,d,f=!1;if(i===a?(c=i,l=o+s,u=n.x,n.x!==r.x&&(u=(n.x*o+r.x*s)/l,f=!0),d=n.y,n.y!==r.y&&(d=(n.y*o+r.y*s)/l,f=!0)):(i>a?(u=n.x,d=n.y,l=o,c=i):(u=r.x,d=r.y,l=s,c=a),f=!n.equals(r)),f&&(this.m_shape.setXYMonotonic(e,u,d),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){let n=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,n),this.m_shape.setSegmentParentageBreakVertex(t,n)}return this.m_shape.setWeight(e,l),this.m_shape.setRank(e,c),f}needsClustering(){let n={stack:[],error:void 0,hasError:!1};try{e(n,Et(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);let t=this.m_shape.getSelectedCount(),r=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(r.getLowerLeft());let i=Math.max(r.height(),r.width())/(Ut()-1);this.m_cellSize<i&&(this.m_cellSize=i,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 yr(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new dr(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let a=!1;for(let e=0;e<2;e++){let t=[],n=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let r=n.next();r!==z;r=n.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(r,this.m_newClusters)===rt.impossibleIndex2())continue;let n;if(e===0?(n=this.m_hashFunction.calculateHashFromVertex(r),this.m_shape.setUserIndex(r,this.m_hashValues,n)):n=this.m_shape.getUserIndex(r,this.m_hashValues),this.collectClusterCandidates(r,t),t.length!==0){for(let e=0,n=t.length;e<n;e++){this.progress_();let n=t[e],i=this.m_hashTable.getElement(n);if(this.m_hashTable.deleteNode(n),!this.m_shape.isEqualXY(r,i))return this.m_nsr=new J(5,this.m_shape.getVertexIndex(r),this.m_shape.getVertexIndex(i)),a=!0,a;this.mergeClusters(r,i,!1)}t.length=0}e===0&&this.m_hashTable.addElement(r,n)}}return a}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}clusterNonReciprocal(){let e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();let n=Math.max(t.height(),t.width())/(Ut()-1);this.m_cellSize<n&&(this.m_cellSize=n,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 yr(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new dr(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let r=!1;{let e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==z;t=e.next()){this.progress_();let e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{let e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=t.next();n!==z;n=t.next()){if(this.m_shape.getUserIndex(n,this.m_newClusters)===rt.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(n,this.m_hashValues);this.m_hashTable.deleteElement(n,t);let i=!1;for(;this.collectClusterCandidates(n,e),e.length!==0;){let t=0;for(let r=0,i=e.length;r<i;r++){this.progress_();let a=e[r],o=this.m_hashTable.getElement(a);this.m_hashTable.deleteNode(a);let s=r+1===i;t|=+!!this.mergeClusters(n,o,s)}if(i||=t!==0,r||=t!==0,e.length=0,!t)break}i&&(t=this.m_shape.getUserIndex(n,this.m_hashValues)),this.m_hashTable.addElement(n,t)}e.length=0}return r&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),r}applyClusterPositions_(){let e=U.getNAN();for(let t=this.m_clusters.getFirstList();t!==Y.st_nullNode();t=this.m_clusters.getNextList(t)){let n=this.m_clusters.getFirst(t),r=this.m_clusters.getElement(n);this.m_shape.queryXY(r,e);let i=this.m_shape.getRank(r),a=this.m_shape.getWeight(r);for(n=this.m_clusters.getNext(n);n!==Y.st_nullNode();n=this.m_clusters.getNext(n)){let t=this.m_clusters.getElement(n);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentageBreakVertex(r)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(r,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,a),this.m_shape.setRank(t,i)}}}}class xr{static maxWeight=Number.MAX_VALUE*.1;static c_smallToleranceFactor=.01;static c_maxGeometryTypeToRankDelta=8;m_inputParts=[];m_resultParts1=[];m_resultParts2=[];m_resultSegments=[];m_freeSegments=[];m_inputSegments=[];m_param1=[];m_param2=[];m_tolerance=0;m_toleranceZ=0;m_point=new B;m_pointWeight=1;m_maxDensifyLimit=0;m_pointRank=0;m_changed1=!1;m_changed2=!1;m_adaptiveDensify=!1;clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(e,t,n,r,i,a,o,s,c,l){return Cr(e,t,n,r,i,a,o,s,c,l)}pushSegment(e,t,n,r,i,a,o,s,c,l){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,n,r,i,a,o,s,c,l)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?e===0?this.m_param1.length-1:this.m_param2.length-1:e===0?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return e===0?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return e===0?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){this.m_inputSegments.length!==2&&o(``),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;let n=Dt(e*xr.c_smallToleranceFactor),r=!1,i=this.m_inputParts[0],a=this.m_inputParts[1],s=this.m_inputSegments[i.segmentIndex],c=this.m_inputSegments[a.segmentIndex];if(t||L(!0,s,c,e,!0)&5){let t=pe(!0,s,c,null,this.m_param1,this.m_param2,e);t===0&&o(``);let l=Array(t);for(let e=0;e<t;++e)l[e]=U.getNAN();let u=new Float64Array(t),d=new Int32Array(t),f=Array(t),p=Array(t);for(let e=0;e<t;++e)f[e]=wr(),p[e]=wr();for(let e=0;e<t;e++){let t=this.m_param1[e],o=this.m_param2[e],m=i.rankInterior,h=i.weightInterior,g;t===0?(m=i.rankStart,h=i.weightStart,g=i.u.bBreakStart):t===1?(m=i.rankEnd,h=i.weightEnd,g=i.u.bBreakEnd):(this.m_changed1=!0,g=!1);let _=a.rankInterior,v=a.weightInterior,y;o===0?(_=a.rankStart,v=a.weightStart,y=a.u.bBreakStart):o===1?(_=a.rankEnd,v=a.weightEnd,y=a.u.bBreakEnd):(this.m_changed2=!0,y=!1);let b=m,x=_,S=1,C=0,w=U.getNAN();if(b===x){let r=s.getCoord2D(t),i=c.getCoord2D(o);S=h+v;let a=v/S;C=m,Tt(r,i,a,w);let l=U.sqrDistance(w,r),u=U.sqrDistance(w,i);f[e].bBigMove=l>n,p[e].bBigMove=u>n,!this.m_changed1&&!r.equals(w)&&(this.m_changed1=!0),!this.m_changed2&&!i.equals(w)&&(this.m_changed2=!0)}else if(b>x){w=s.getCoord2D(t);let r=c.getCoord2D(o);S=h,C=m;let i=U.sqrDistance(w,r);f[e].bBigMove=!1,p[e].bBigMove=i>n,!this.m_changed2&&!r.equals(w)&&(this.m_changed2=!0)}else{w=c.getCoord2D(o),S=v,C=_;let r=s.getCoord2D(t),i=U.sqrDistance(w,r);f[e].bBigMove=i>n,p[e].bBigMove=!1,!this.m_changed1&&!r.equals(w)&&(this.m_changed1=!0)}l[e].assign(w),u[e]=S,d[e]=C,f[e].bIsBreak=g||y,p[e].bIsBreak=g||y,r||=f[e].bBigMove||p[e].bBigMove}let m=i.rankInterior,h=i.weightInterior,g=0,_=-1;for(let n=0;n<=t;n++){let r=n<t?this.m_param1[n]:1;if(r!==g){let a=this.allocResultSegment(),o=this.m_resultSegments[a];s.queryCut(g,r,o,!1),o.get().snapControlPoints(e*e);let c,p,v,y,b=!1,x=!1,S=!1,C=!1,w=!1,T=U.getNAN(),E=U.getNAN();_===-1?(c=i.weightStart,p=i.rankStart,T=o.get().getStartXY(),S=i.u.bBreakStart):(p=d[_],c=u[_],b=f[_].bBigMove,T.assign(l[_]),S=f[_].bIsBreak,w=!0),n<t?(y=d[n],v=u[n],x=f[n].bBigMove,E.assign(l[n]),C=f[n].bIsBreak,w=!0):(v=i.weightEnd,y=i.rankEnd,E=o.get().getEndXY(),C=i.u.bBreakEnd),w&&o.get().setCoordsForIntersector(T,E,!0),this.m_resultParts1.push(this.newIntersectionPart_(a,c,p,v,y,h,m,S,C,i.segmentParentage));let D=this.m_resultParts1.at(-1);D.u.bBigMoveStart=b,D.u.bBigMoveEnd=x,g=r,_=n}else _===-1&&(_=n)}let v=H(t,0);for(let e=0;e<t;e++)v[e]=e;t>2?(v.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:+(this.m_param2[e]>this.m_param2[t])),dt(this.m_param2)):t===2&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=gt(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),v[1]=gt(v[0],v[0]=v[1]));let y=a.rankInterior,b=a.weightInterior;g=0,_=-1;for(let n=0;n<=t;n++){let r=n<t?this.m_param2[n]:1;if(r!==g){let i=this.allocResultSegment(),o=this.m_resultSegments[i];c.queryCut(g,r,o,!1),o.get().snapControlPoints(e*e);let s,f,m,h,x=U.getNAN(),S=U.getNAN(),C=!1,w=!1,T=!1,E=!1,D=!1;if(_!==-1){let e=v[_];s=u[e],f=d[e],x.assign(l[e]),T=p[e].bBigMove,C=p[e].bIsBreak,D=!0}else s=a.weightStart,f=a.rankStart,x=o.get().getStartXY(),C=a.u.bBreakStart;if(n!==t){let e=v[n];m=u[e],h=d[e],S.assign(l[e]),E=p[e].bBigMove,w=p[e].bIsBreak,D=!0}else m=a.weightEnd,h=a.rankEnd,S=o.get().getEndXY(),w=a.u.bBreakEnd;D&&o.get().setCoordsForIntersector(x,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(i,s,f,m,h,b,y,C,w,a.segmentParentage));let O=this.m_resultParts2.at(-1);O.u.bBigMoveStart=T,O.u.bBigMoveEnd=E,g=r,_=n}else _===-1&&(_=n)}return r?3:2}return 0}intersectLines3D(e,t,n,r){return l(0),1}intersect2D(e,t){let n=this.m_inputParts[0],r=this.m_inputParts[1],a=this.m_inputSegments[n.segmentIndex].getGeometryType(),o=this.m_inputSegments[r.segmentIndex].getGeometryType();return a!==i.enumLine||o!==i.enumLine?new Or(this).intersectCurves(e,t):this.intersectLines(e,t)}intersect2DEx(e,t,n,r,i){this.m_point.assignCopy(t),this.m_inputSegments.length!==1&&o(``),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;let a=Dt(e*xr.c_smallToleranceFactor),s=!1,c=this.m_inputParts[0],l=this.m_inputSegments[c.segmentIndex];if(i||l.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=H(16,NaN);let i=l.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=i;let o=c.rankInterior,u=c.weightInterior;i===0?(o=c.rankStart,u=c.weightStart):i===1?(o=c.rankEnd,u=c.weightEnd):this.m_changed1=!0;let d=o,f=n,p=r;d===f&&l.isCurve()&&(d=f+1);let m=1,h=0,g=new U;if(d===f){let e=l.getCoord2D(i),n=t.getXY();m=u+p,h=o;let r=p/m;Tt(e,n,r,g),!this.m_changed1&&!e.equals(g)&&(this.m_changed1=!0),!this.m_changed2&&!n.equals(g)&&(this.m_changed2=!0),s=U.sqrDistance(g,e)>a}else d>f?(g.assign(l.getCoord2D(i)),m=u,h=o,!this.m_changed2&&!g.equals(t.getXY())&&(this.m_changed2=!0)):(g.assign(l.getCoord2D(i)),m=p,h=f,!this.m_changed1&&!g.equals(t.getXY())&&(this.m_changed1=!0),s=U.sqrDistance(g,t.getXY())>a);let _=0,v=-1;for(let t=0;t<=1;t++){let n=t<1?this.m_param1[0]:1;if(n!==_){let r=this.allocResultSegment(),i=this.m_resultSegments[r];l.queryCut(_,n,i),i.get().snapControlPoints(e*e);let a=c.weightStart,o=c.weightEnd,s=c.rankStart,u=c.rankEnd,d=c.rankInterior,f=c.weightInterior,p=c.u.bBreakStart,y=c.u.bBreakEnd;v!==-1&&(a=m,s=h,p=!0,i.get().setCoordsForIntersector(g,i.get().getEndXY(),!0)),t!==1&&(o=m,u=h,y=!0,i.get().setCoordsForIntersector(i.get().getStartXY(),g,!0)),_=n,this.m_resultParts1.push(this.newIntersectionPart_(r,a,s,o,u,f,d,p,y,c.segmentParentage))}v=t}return this.m_point.setXY(g),this.m_pointWeight=m,this.m_pointRank=h,s?3:2}return 0}intersect3D(e,t,n,r){return l(0),1}intersect3DEx(e,t,n,r,i,a,o){return l(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let e=new F,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let t=new F({copy:e}),n=this.m_resultSegments.length;return this.m_resultSegments.push(t),n}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length)return this.m_freeSegments.pop();let t=new F({segment:e}),n=this.m_resultSegments.length;return this.m_resultSegments.push(t),n}}function Sr(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function Cr(e,t,n,r,i,a,o,s,c,l){return{segmentIndex:e,weightStart:t,rankStart:n,weightEnd:r,rankEnd:i,weightInterior:a,rankInterior:o,segmentParentage:l,u:Sr(s,c)}}function wr(){return{bBigMove:!1,bIsBreak:!1}}let Tr=class{start=null;end=null;equalEdge=null;segmentIndex=-1;segmentParentage=-1;weight=0;rank=0;hasSegment(){return this.segmentIndex>=0}transferAttributes(e,t,n){if(t.getDescription().getAttributeCount()===1)return;let r=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),i=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),a=new B;t.queryStart(a),n?(a.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setStart(a)):(a.setXY(i),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(a)),t.queryEnd(a),n?(a.setXY(i),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(a)):(a.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setStart(a))}copyFromWhenOverlap(e,t,n){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,n?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class Er{hash=0;pt=new U;prevInChain=null;nextInChain=null;prevInHash=null;nextInHash=null;prevEqual=null;nextEqual=null;weight=0;rank=0;bBigMove=!1;bIsBreak=!1;copyFrom(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;e.prevEqual!==null;e=e.prevEqual);return e}}function Dr(e,t,n,r){return{edge1:e,edge2:t,recursion:n,bIsIntersecting:r}}class Or{parent;m_pairs=[];m_chainOrigin1=null;m_chainOrigin2=null;m_newNodes=[];m_hashTableOfEquals=[];m_hashTableOfEqualsSize=0;m_origin=new U;m_cell=new U;constructor(e){this.parent=e}addSegment(e,t,n,r,i,a,o,s,c,u,d){let f=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),n,r,c),p=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),i,a,u);this.newEdge(f,p,e,o,s,d),this.m_chainOrigin1===null?this.m_chainOrigin1=f:this.m_chainOrigin2===null?this.m_chainOrigin2=f:l(0)}intersectCurvesHelper(e,t,n,r,a){let s=this.getSegment(e).get(),c=this.getSegment(t).get();if(s.isDegenerate(0)||c.isDegenerate(0))return 0;let u=this.tryOverlapIntersectCurves(e,t,n,r);if(u!==0)return u;let d=Dt(n*.01),f=!1,p=this.processSharpCorners(s,c,n,a>4),m=p>0;if(!m){if(!r&&!(de(!0,!1,s,c,n,!0)&5))return 0;p=pe(!0,s,c,null,this.parent.m_param1,this.parent.m_param2,n)}p===0&&o(``);let h=s.getGeometryType(),g=c.getGeometryType(),_=bt(U,p),v=bt(U,p),y=H(p,NaN),b=H(p,NaN),x=H(p,NaN),S=H(p,NaN),C=Wt(wr,p),w=Wt(wr,p),T=!1,E=!1;for(let r=0;r<p;r++){let i=this.parent.m_param1[r],a=this.parent.m_param2[r],o=e.rank,l=e.weight,u=!0,p=!1;i===0?(o=e.start.rank,l=e.start.weight,p=e.start.bIsBreak):i===1?(o=e.end.rank,l=e.end.weight,p=e.end.bIsBreak):(T=!0,u=!1);let D=t.rank,O=t.weight,k=!1,A=!0;a===0?(D=t.start.rank,O=t.start.weight,k=t.start.bIsBreak):a===1?(D=t.end.rank,O=t.end.weight,k=t.end.bIsBreak):(E=!0,A=!1);let j=o,M=D;if(j===M&&(j*=xr.c_maxGeometryTypeToRankDelta,M*=xr.c_maxGeometryTypeToRankDelta,j+=kr(h,s,!1),M+=kr(g,c,!1)),u&&A&&M===j){let e=s.getCoord2D(i),t=c.getCoord2D(a);e.equals(t)&&(M=j-1)}let N=1,P=0,F=1,I=0,L=new U,R=new U,ee=s.getCoord2D(i),z=c.getCoord2D(a);if(m&&U.distance(ee,z)>n)L.setCoordsPoint2D(ee),R.setCoordsPoint2D(z),N=l,F=O,P=o,I=D,C[r].bBigMove=!1,w[r].bBigMove=!1,p=!0,k=!0;else if(j===M){F=N=l+O,I=P=o;let e=O/N;Tt(ee,z,e,L),R.setCoordsPoint2D(L);let t=U.sqrDistance(L,ee),n=U.sqrDistance(L,z);C[r].bBigMove=t>d,w[r].bBigMove=n>d,!T&&!ee.equals(L)&&(T=!0),!E&&!z.equals(R)&&(E=!0)}else if(j>M){L.setCoordsPoint2D(ee),R.setCoordsPoint2D(L),F=N=l,I=P=o;let e=U.sqrDistance(L,z);C[r].bBigMove=!1,w[r].bBigMove=e>d,!E&&!z.equals(R)&&(E=!0)}else{R.setCoordsPoint2D(z),L.setCoordsPoint2D(R),F=N=O,I=P=D;let e=U.sqrDistance(L,ee);C[r].bBigMove=e>d,w[r].bBigMove=!1,!T&&!ee.equals(L)&&(T=!0)}_[r].assign(L),v[r].assign(R),y[r]=N,b[r]=F,x[r]=P,S[r]=I,C[r].bIsBreak=p||k,w[r].bIsBreak=p||k,f||=C[r].bBigMove||w[r].bBigMove,r>0&&(i===this.parent.m_param1[r-1]||a===this.parent.m_param2[r-1])&&(x[r]<=x[r-1]?(_[r].assign(v[r-1]),y[r]=b[r-1],x[r]=S[r-1],v[r].assign(v[r-1]),b[r]=b[r-1],S[r]=S[r-1],C[r].bBigMove||=C[r-1].bBigMove,w[r].bBigMove||=w[r-1].bBigMove,C[r].bIsBreak||=C[r-1].bIsBreak,w[r].bIsBreak||=w[r-1].bIsBreak):(_[r-1].assign(_[r]),y[r-1]=y[r],x[r-1]=x[r],v[r-1].assign(v[r]),b[r-1]=b[r],S[r-1]=S[r],C[r-1].bBigMove||=C[r].bBigMove,w[r-1].bBigMove||=w[r].bBigMove,C[r-1].bIsBreak||=C[r].bIsBreak,w[r-1].bIsBreak||=w[r].bIsBreak))}if(!T&&!E&&p===2&&(h!==i.enumLine||g!==i.enumLine)){if(this.processDoublyConnectedEdges(e,t,a+1,n))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;l(0)}this.parent.m_changed1||=T,this.parent.m_changed2||=E;let D=e,O=e.end.weight,k=e.end.rank,A=e.end.bBigMove,j=e.end.bIsBreak,M=0,N=-1;for(let t=0;t<=p;t++){let r=t<p?this.parent.m_param1[t]:1;if(r!==M){let i=this.parent.allocResultSegment(),a=this.parent.m_resultSegments[i];s.queryCut(M,r,a,!1),a.get().snapControlPoints(n*n);let o,c,l,u,d=!1,f=!1,m=!1,h=!1,g=new U,v=new U;N===-1?(o=e.start.weight,c=e.start.rank,m=e.start.bBigMove,d=e.start.bIsBreak,g.assign(a.get().getStartXY())):(c=x[N],o=y[N],m=C[N].bBigMove,d=C[N].bIsBreak,g.assign(_[N])),t<p?(u=x[t],l=y[t],h=C[t].bBigMove,f=C[t].bIsBreak,v.assign(_[t])):(l=O,u=k,h=A,f=j,v.assign(a.get().getEndXY()));let b=D;r<1&&(this.splitEdgeInPlace(D),b=D.getNextInChain()),this.updateSegmentOnly(D,i),D.start.hash!==0&&!D.start.pt.equals(g)&&(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),D.end.hash!==0&&!D.end.pt.equals(v)&&(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(g),D.end.pt.assign(v),D.start.bBigMove||=m,D.end.bBigMove||=h,D.start.bIsBreak||=d,D.end.bIsBreak||=f,D.start.weight=o,D.start.rank=c,D.end.weight=l,D.end.rank=u,D=b,M=r,N=t}else N===-1&&(N=t)}let P=D.getNextInChain(),F=[];F.length=p;for(let e=0;e<p;e++)F[e]=e;p>2?(F.sort((e,t)=>Gt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Gt)):p===2&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=gt(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),F[1]=gt(F[0],F[0]=F[1])),D=t,O=t.end.weight,k=t.end.rank,A=t.end.bBigMove,j=t.end.bIsBreak,M=0,N=-1;for(let e=0;e<=p;e++){let r=e<p?this.parent.m_param2[e]:1;if(r!==M){let i=this.parent.allocResultSegment(),a=this.parent.m_resultSegments[i];c.queryCut(M,r,a,!1),a.get().snapControlPoints(n*n);let o,s,l,u,d=new U,f=new U,m=!1,h=!1,g=!1,_=!1;if(N!==-1){let e=F[N];o=b[e],s=S[e],d.assign(v[e]),g=w[e].bBigMove,m=w[e].bIsBreak}else o=t.start.weight,s=t.start.rank,g=t.start.bBigMove,m=t.start.bIsBreak,d.assign(a.get().getStartXY());if(e!==p){let t=F[e];l=b[t],u=S[t],f.assign(v[t]),_=w[t].bBigMove,h=w[t].bIsBreak}else l=O,u=k,_=A,h=j,f.assign(a.get().getEndXY());let y=D;r<1&&(this.splitEdgeInPlace(D),y=D.getNextInChain()),this.updateSegmentOnly(D,i),D.start.hash!==0&&!D.start.pt.equals(d)&&(this.m_newNodes.push(D.start),this.removeNodeFromHash(D.start),D.start.hash=0),D.end.hash!==0&&!D.end.pt.equals(f)&&(this.m_newNodes.push(D.end),this.removeNodeFromHash(D.end),D.end.hash=0),D.start.pt.assign(d),D.end.pt.assign(f),D.start.bBigMove||=g,D.end.bBigMove||=_,D.start.bIsBreak||=m,D.end.bIsBreak||=h,D.start.weight=o,D.start.rank=s,D.end.weight=l,D.end.rank=u,D=y,M=r,N=e}else N===-1&&(N=e)}let I=D.getNextInChain();return this.postProcessResultPartsForCurves(e,P,t,I,a+1),f?3:2}intersectCurves(e,t){this.parent.m_inputSegments.length!==2&&o(``),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=ut(16);let n=T.constructEmpty();for(let e=0;e<2;e++){let t=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex]),r=T.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[e].segmentIndex].queryLooseEnvelope(r),n.mergeEnvelope2D(r);let i=this.parent.m_inputParts[e];this.addSegment(t,0,i.weightStart,i.rankStart,i.weightEnd,i.rankEnd,i.weightInterior,i.rankInterior,i.u.bBreakStart,i.u.bBreakEnd,i.segmentParentage)}n.inflateCoords(100*e,100*e),this.m_origin.assign(n.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(Dr(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let r=0,i=!0;for(;this.m_pairs.length;){let t=this.m_pairs.at(-1);this.m_pairs.pop(),l(t.recursion>=0),l(t.recursion<=256),this.clusterNodes(e);let n=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,r=n)}for(let e=0;e<2;e++){let t=e===0?this.parent.m_resultParts1:this.parent.m_resultParts2,n=e===0?this.m_chainOrigin1:this.m_chainOrigin2;for(let e=n.nextInChain;e!=null;e=e.getNextInChain())t.push(this.parent.newIntersectionPart_(e.segmentIndex,e.start.weight,e.start.rank,e.end.weight,e.end.rank,e.weight,e.rank,e.start.bIsBreak,e.end.bIsBreak,e.segmentParentage)),t.at(-1).u.bBigMoveStart=e.start.bBigMove,t.at(-1).u.bBigMoveEnd=e.end.bBigMove}return r}tryOverlapIntersectCurves(e,t,n,r){let i=this.parent.m_resultSegments[e.segmentIndex].get(),a=this.parent.m_resultSegments[t.segmentIndex].get(),o=i.getStartXY().equals(a.getStartXY())&&i.getEndXY().equals(a.getEndXY()),s=i.getStartXY().equals(a.getEndXY())&&i.getEndXY().equals(a.getStartXY());if(!o&&!s)return 0;let c=ye(i,a,!0);if(c!==0&&be(i,a)&&e.segmentParentage===t.segmentParentage){let e=!1;if(c>0)e=i.equals(a);else{l(c===-1);let t=new F({segment:a});t.get().reverse(),e=i.equals(t.get())}if(e)return 1}let u=n*xr.c_smallToleranceFactor,d=!1;if(c===0){let e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,r=e.length;t<r;++t){let r=e[t],o=new U;i.queryCoord2D(r,o);let s=a.getClosestCoordinate(o,!1),c=new U;a.queryCoord2D(s,c);let l=U.distance(o,c);if(l>n)return 0;d||=l>u}for(let t=0,r=e.length;t<r;++t){let r=e[t],o=new U;a.queryCoord2D(r,o);let s=i.getClosestCoordinate(o,!1),c=new U;i.queryCoord2D(s,c);let l=U.distance(o,c);if(l>n)return 0;d||=l>u}}let f=e.rank,p=t.rank,m=f,h=p;return m===h&&(m*=xr.c_maxGeometryTypeToRankDelta,h*=xr.c_maxGeometryTypeToRankDelta,m+=kr(i.getGeometryType(),i,!0),h+=kr(a.getGeometryType(),a,!0)),m>h?(t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,i,o)):h>m?(e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,a,o)):e.segmentParentage<=t.segmentParentage?(e.weight+=t.weight,t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,i,o)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,a,o)),d?3:2}postProcessResultPartsForCurves(e,t,n,r,i){i===Kt()&&o(`curve_helper`);for(let n=e;n!==t;n=n.getNextInChain())this.updateSegmentToNodes(n);for(let e=n;e!==r;e=e.getNextInChain())this.updateSegmentToNodes(e);for(let a=e;a!==t;a=a.getNextInChain()){let e=a.end.pt.sub(a.start.pt);for(let t=n;t!==r;t=t.getNextInChain()){let n=0;if(a.start.pt.equals(t.start.pt)&&a.end.pt.equals(t.end.pt)?n=1:a.start.pt.equals(t.end.pt)&&a.end.pt.equals(t.start.pt)&&(n=-1),!n){let n=+!!a.start.pt.equals(t.start.pt);if(n||(n=a.end.pt.equals(t.end.pt)?2:0,n||(n=a.end.pt.equals(t.start.pt)?3:0,n||=a.start.pt.equals(t.end.pt)?4:0)),n){let r=t.end.pt.sub(t.start.pt),s=e.dotProduct(r),c;switch(n){case 1:case 2:c=s>0;break;case 3:case 4:c=s<0;break;default:o(`post_process_result_parts_for_curves_`)}c&&this.m_pairs.push(Dr(a,t,i,!1))}continue}let r=this.parent.m_resultSegments[a.segmentIndex],s=this.parent.m_resultSegments[t.segmentIndex],c=[.5,.25,.75];for(let e=0,t=c.length;e<t;++e){let t=c[e],i=new U;r.get().queryCoord2D(t,i);let a=s.get().getClosestCoordinate(i,!1),o=new U;if(s.get().queryCoord2D(a,o),U.distance(i,o)>this.parent.m_tolerance){n=0;break}}if(!n){this.m_pairs.push(Dr(a,t,i,!1));continue}for(let e=0,t=c.length;e<t;++e){let t=c[e],i=new U;s.get().queryCoord2D(t,i);let a=r.get().getClosestCoordinate(i,!1),o=new U;if(r.get().queryCoord2D(a,o),U.distance(i,o)>this.parent.m_tolerance){n=0;break}}if(!n){this.m_pairs.push(Dr(a,t,i,!1));continue}a.equalEdge=t,t.equalEdge=a;let l=a.rank,u=t.rank;l===u&&(l*=xr.c_maxGeometryTypeToRankDelta,u*=xr.c_maxGeometryTypeToRankDelta,l+=kr(r.get().getGeometryType(),r.get(),!0),u+=kr(s.get().getGeometryType(),s.get(),!0)),l>u||l===u&&a.segmentParentage<=t.segmentParentage?(r.copyTo(s,!1),t.segmentParentage=a.segmentParentage,n===-1&&s.get().reverse()):(s.copyTo(r,!1),a.segmentParentage=t.segmentParentage,n===-1&&r.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(n.start),r&&this.updateAttachedEdgesAfterNodeChange(r.start)}processDoublyConnectedEdges(e,t,n,r){n===Kt()&&o(`curve_helper`);let i=this.getSegment(e).get(),a=this.getSegment(t).get(),s=i.getStartXY().equals(a.getStartXY())&&i.getEndXY().equals(a.getEndXY())?1:i.getEndXY().equals(a.getStartXY())&&i.getStartXY().equals(a.getEndXY())?-1:0;if(s!==0){let o=new F;i.queryCut(0,.5,o),o.get().snapControlPoints(r*r);let c=new F;i.queryCut(.5,1,c),c.get().snapControlPoints(r*r),this.splitEdgeInPlace(e),e.end.pt=o.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(c);let l=a.getClosestCoordinate(e.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),a.queryCut(0,l,o),o.get().snapControlPoints(r*r),a.queryCut(l,1,c),c.get().snapControlPoints(r*r),this.splitEdgeInPlace(t),t.end.pt=o.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(c),s>0?(this.m_pairs.push(Dr(e,t,n,!1)),this.m_pairs.push(Dr(e.getNextInChain(),t.getNextInChain(),n,!1))):(this.m_pairs.push(Dr(e,t.getNextInChain(),n,!1)),this.m_pairs.push(Dr(e.getNextInChain(),t,n,!1))),!0}return!1}newNode(e,t,n,r){let i=new Er;return this.m_newNodes.push(i),i.pt=e,i.rank=n,i.weight=t,i.bIsBreak=r,i}newEdge(e,t,n,r,i,a){let o=new Tr;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=n,o.segmentParentage=a,o.rank=i,o.weight=r,o}splitEdgeInPlace(e){e.segmentIndex=-1;let t=new Tr,n=new Er;this.m_newNodes.push(n),n.pt.setNAN(),n.nextInChain=t,n.prevInChain=e,n.prevInHash=null,n.nextInHash=null,n.prevEqual=null,n.nextEqual=null,n.weight=e.weight,n.rank=e.rank,n.bIsBreak=!1,n.bBigMove=!1,t.start=n,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=n,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();t!==null;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){let t=e.prevInChain;if(t&&t.hasSegment()){let n=this.getSegment(t).get();e.pt.equals(n.getEndXY())||(n.setCoordsForIntersector(t.start.pt,t.end.pt,!1),n.ensureXYMonotone())}let n=e.nextInChain;if(n&&n.hasSegment()){let t=this.getSegment(n).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(n.start.pt,n.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){let t=this.getSegment(e).get();(!e.start.pt.equals(t.getStartXY())||!e.end.pt.equals(t.getEndXY()))&&(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1,n=[],r=[],i=[];for(let e=0,t=this.m_newNodes.length;e<t;e++){let n=this.m_newNodes[e];if(n===null)continue;let r=n;for(let i=e+1;i<t;i++){let e=this.m_newNodes[i];e!==null&&n.pt.equals(e.pt)&&(r.nextInHash=e,e.prevInHash=r,r=e,this.m_newNodes[i]=null)}}for(let a=0,o=this.m_newNodes.length;a<o;a++){let o=this.m_newNodes[a];if(o==null)continue;for(o.hash=this.calculateHash(o.pt);;){let a=ut(4),s=this.hashTableBinsToCheck(o,a);for(let t=0;t<s;t++)if(a[t]!==null)for(let s=a[t];s!==null;){let t=s.nextInHash;U.distance(o.pt,s.pt)<=e&&(n.push(s),this.removeNodeFromHash(s),s.hash=0,i.push(s),r.push(s)),s=t}let c=!1;for(let e of n)if(!o.pt.equals(e.pt)){let n=hr(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(n.pt),o.weight=n.weight,o.rank=n.rank,c=!0,t=!0}if(n.length=0,c){o.hash=this.calculateHash(o.pt);continue}break}i.push(o),r.push(o);for(let e=o.nextInHash;e!==null;){e.prevInHash=null;let t=e.nextInHash;e.nextInHash=null,i.push(e),r.push(e),e=t}let s=o.hash,c=null,l=null;for(let e of r)o!==e&&(e.hash=s,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=c,c&&(c.nextInHash=e),e.prevEqual=l,e.nextEqual=null,l&&(l.nextEqual=e),l=e,c=e;let u=s%this.m_hashTableOfEquals.length;c.nextInHash=this.m_hashTableOfEquals[u],this.m_hashTableOfEquals[u]!==null&&(this.m_hashTableOfEquals[u].prevInHash=c),this.m_hashTableOfEquals[u]=r[0],this.m_hashTableOfEqualsSize+=r.length,r.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(let e of i)this.updateAttachedEdgesAfterNodeChange(e)}rehashIfNeeded(){if(this.m_hashTableOfEqualsSize*2>this.m_hashTableOfEquals.length){let e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=ut(e.length*2),this.m_hashTableOfEqualsSize=0;for(let t of e){let e=t;for(;e;){let t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){let t=e.hash%this.m_hashTableOfEquals.length,n=this.m_hashTableOfEquals[t];e.nextInHash=n,n!==null&&(n.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){let t=e.hash%this.m_hashTableOfEquals.length,n=e.prevInHash,r=e.nextInHash;n?n.nextInHash=r:this.m_hashTableOfEquals[t]=r,r&&(r.prevInHash=n),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){let n=(e.pt.x-this.m_origin.x)/this.m_cell.x,r=(e.pt.y-this.m_origin.y)/this.m_cell.y,i=Ut()-1,a=Math.round(At(n,-i,i)),o=Math.round(At(r,-i,i)),s=a|o<<32;s=lt(s),t[0]=this.m_hashTableOfEquals[s%this.m_hashTableOfEquals.length];let c=a+1|o<<32;c=lt(c);let l=1;t[1]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(l=2);let u=a+1|o+1<<32;u=lt(u),t[l]=this.m_hashTableOfEquals[u%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}l++;let d=a|o+1<<32;d=lt(d),t[l]=this.m_hashTableOfEquals[d%this.m_hashTableOfEquals.length];for(let e=0;e<l;e++)if(t[l]===t[e]){l--;break}return l++,l}calculateHash(e){let t=(e.x-this.m_origin.x)/this.m_cell.x,n=(e.y-this.m_origin.y)/this.m_cell.y,r=Ut()-1,i=Math.round(At(t,-r,r))|Math.round(At(n,-r,r))<<32;return i=lt(i),i===0&&(i=1),i}processSharpCorners(e,t,n,r){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){let i=[0,0],a=[0,0],o=xe(e,t,0,0,n,2,i,a,r);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return o+1}}if(e.getEndXY().equals(t.getEndXY())){let i=[0,0],a=[0,0],o=xe(e,t,1,1,n,2,i,a,r);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),o+1}}if(e.getStartXY().equals(t.getEndXY())){let i=[0,0],a=[0,0],o=xe(e,t,0,1,n,2,i,a,r);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return o+1}}if(e.getEndXY().equals(t.getStartXY())){let i=[0,0],a=[0,0],o=xe(e,t,1,0,n,2,i,a,r);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(i[e]),this.parent.m_param2.push(a[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),o+1}}return 0}}function kr(e,t,n){let r=0;switch(e){case i.enumLine:r=0;break;case i.enumBezier:r=2;break;case i.enumRationalBezier2:r=3;break;case i.enumBezier2:r=1;break;case i.enumEllipticArc:r=t.projectionBehavior()===0?5:4;break;default:o(``)}return n?5-r:r}class Ar extends lr{m_parent;constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,n){if(this.m_bIntersectionDetected)return-1;let r=e.getElement(n),i=this.m_parent.getEdgeOriginVertices(t),a=this.m_parent.m_edgeVertices.getFirstElement(i),o=this.m_parent.getEdgeOriginVertices(r),s=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=n,this.compareSegments(t,a,r,s)}}class jr extends ur{m_parent;constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;let n=e.getElement(t),r=this.m_parent.getEdgeOriginVertices(n),i=this.m_parent.m_edgeVertices.getFirstElement(r);return this.m_currentNode=t,this.compareVertex(e,t,i)}}class Mr extends tt{m_shape;pt1=U.getNAN();pt2=U.getNAN();constructor(e){super(),this.m_shape=e}compare(e,t,n){this.m_shape.queryXY(t,this.pt1);let r=e.getElement(n);return this.m_shape.queryXY(r,this.pt2),this.pt1.compare(this.pt2)}}class Nr{m_shape;m_point=U.getNAN();m_pt=U.getNAN();constructor(e){this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){let n=e.getElement(t);return this.m_shape.queryXY(n,this.m_pt),this.m_point.compare(this.m_pt)}}class Pr{m_shape=null;m_progressTracker=null;m_edges=new rt(8);m_clusters=new rt(5);m_clusterVertices=new Y(!1);m_edgeVertices=new Y(!1);m_helperPoint=new B;m_eventQ=new Ie;m_sweepStructure=new Ie;m_bComplications=!1;m_bTrackChanges;m_sweepComparator=null;m_tempEdgeBuffer=[];m_modifiedClusters=[];m_edgesToInsertInSweepStructure=[];m_prevNeighbour=-1;m_nextNeighbour=-1;m_bContinuingSegmentChainOptimization=!1;m_progressCounter=0;m_segmentIntersector=new xr;m_segBuf1=new F;m_segBuf2=new F;m_sweepPoint=new U(0,0);m_tolerance=0;m_toleranceSqr=0;m_sweepPointCluster=-1;m_vertexClusterIndex=-1;m_bCracked=!1;m_bSweepPointClusterWasModified=!1;constructor(e,t){this.m_progressTracker=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){let n=new K;n.setSwapCoordinates(),e.applyTransformation(n),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let r=this.sweepImpl_();return e.applyTransformation(n),r||=(this.fillEventQueuePass2(),this.sweepImpl_()||r),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let n=this.sweepImpl_();if(!this.m_bComplications){let r=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,z);this.m_bComplications=r===1,n||=r===1}return this.m_vertexClusterIndex!==-1&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,n}getEdgeCluster(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,n){this.m_edges.setField(e,0+t,n)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,n){this.m_edges.setField(e,3+t,n)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){let n=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+n)}setNextEdge_(e,t,n){let r=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+r,n)}getPrevEdge(e,t){let n=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+n)}setPrevEdge_(e,t,n){let r=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+r,n)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){let t=this.m_clusters.newElement(),n=this.m_clusterVertices.createList();return this.setClusterVertices_(t,n),e!==z&&(this.m_clusterVertices.addElement(n,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){let n=this.getClusterVertices(e);this.m_clusterVertices.addElement(n,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){let t=this.m_edges.newElement(),n=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,n),e!==-1&&this.m_edgeVertices.addElement(n,e),t}addVertexToEdge_(e,t){let n=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(n,t)}deleteEdge_(e){this.m_edges.deleteElement(e);let t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&kt(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){this.getEdgeCluster(e,0)===-1?this.setEdgeCluster_(e,0,t):this.getEdgeCluster(e,1)===-1?this.setEdgeCluster_(e,1,t):o(``),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){let n=this.getClusterFirstEdge(t);if(n!==-1){let r=this.getNextEdge(n,t);this.setPrevEdge_(r,t,e),this.setNextEdge_(e,t,r),this.setNextEdge_(n,t,e),this.setPrevEdge_(e,t,n)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);let n=this.getClusterEventQNode(t);n!==-1&&(this.m_eventQ.deleteNode(n),this.setClusterEventQNode_(t,-1));let r=this.getClusterFirstEdge(e),i=this.getClusterFirstEdge(t);if(i!==-1){let n=i,a=i,o=!1;do{this.dbgCheckEdge_(n),o=!1;let r=this.getEdgeEnd(n,t),s=this.getNextEdgeEx(n,r);if(this.getEdgeCluster(n,r+1&1)===e){this.disconnectEdge_(n);let e=this.getEdgeOriginVertices(n);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(n),n===s){i=-1;break}i===n&&(i=this.getClusterFirstEdge(t),a=s,o=!0)}n=s}while(n!==a||o);if(i!==-1){do{let r=this.getEdgeEnd(n,t),i=this.getNextEdgeEx(n,r);this.setEdgeCluster_(n,r,e),n=i}while(n!==a);if(r=this.getClusterFirstEdge(e),r!==-1){let t=this.getNextEdge(r,e),n=this.getNextEdge(i,e);t===r?(this.setClusterFirstEdge_(e,i),this.addEdgeToClusterImpl_(r,e),this.setClusterFirstEdge_(e,r)):n===i&&this.addEdgeToClusterImpl_(i,e),this.setNextEdge_(i,e,t),this.setPrevEdge_(t,e,i),this.setNextEdge_(r,e,n),this.setPrevEdge_(n,e,r)}else this.setClusterFirstEdge_(e,i)}}let a=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(o);t!==-1;t=this.m_clusterVertices.getNext(t)){let n=this.m_clusterVertices.getElement(t);this.m_shape.setUserIndex(n,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(a,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);let n=this.getEdgeCluster(e,0),r=this.getEdgeCluster(e,1),i=this.getEdgeCluster(t,0),a=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),s=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,s),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),t===this.getClusterFirstEdge(r)&&this.setClusterFirstEdge_(r,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(n===i&&r===a||r===i&&n===a)){let e=this.getClusterXY(n),t=this.getClusterXY(i);e.isEqualPoint2D(t)?(n!==i&&this.mergeClusters_(n,i),r!==a&&this.mergeClusters_(r,a)):(r!==i&&this.mergeClusters_(r,i),n!==a&&this.mergeClusters_(n,a))}this.dbgCheckEdge_(e)}disconnectEdge_(e){let t=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,n)}disconnectEdgeFromCluster_(e,t){let n=this.getNextEdge(e,t),r=this.getPrevEdge(e,t),i=this.getClusterFirstEdge(t);n===e?this.setClusterFirstEdge_(t,-1):(this.setNextEdge_(r,t,n),this.setPrevEdge_(n,t,r),i===e&&this.setClusterFirstEdge_(t,n))}applyIntersectorToEditShape_(e,t,n){let r=this.m_edgeVertices.getFirst(e),i=this.m_edgeVertices.getElement(r),a=this.getClusterFromVertex(i),o=this.m_shape.getNextVertex(i),s=this.getClusterFromVertex(o),c=this.m_shape.getXY(i),l=this.m_shape.getXY(o),u=!1,d=!1,f=t.getResultSegment(n,0).getStartXY(),p=t.getResultSegment(n,t.getResultSegmentCount(n)-1).getEndXY();c.equals(f)||(u=!0),l.equals(p)||(d=!0),this.m_shape.splitSegmentWithIntersector(i,t,n,!0,!0);let m=this.m_bTrackChanges&&t.getSegmentChanged(n);for(m&&this.m_shape.setGeometryModifiedWithVertex(i,!0),r=this.m_edgeVertices.getNext(r);r!==-1;r=this.m_edgeVertices.getNext(r)){let e=this.m_edgeVertices.getElement(r),i=this.getClusterFromVertex(e)===a;this.m_shape.splitSegmentWithIntersector(e,t,n,i,!0),m&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(u&&this.updateClusterXY(!0,a,f,t.getResultSegmentStartPointWeight(n,0),t.getResultSegmentStartPointRank(n,0)),d){let e=t.getResultSegmentCount(n)-1;this.updateClusterXY(!0,s,p,t.getResultSegmentEndPointWeight(n,e),t.getResultSegmentEndPointRank(n,e))}}createEdgesAndClustersFromSplitEdge_(e,t,n){this.dbgCheckNewEdgesArray_();let r=this.getEdgeOriginVertices(e),i=this.getEdgeCluster(e,0),a=this.getEdgeCluster(e,1),o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);let s=rt.impossibleIndex3();this.setEdgeSweepNode_(o,s),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,i);let c=t.getResultSegmentCount(n);for(let e=1;e<c;e++){let e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);let t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,s),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,a);for(let e=this.m_edgeVertices.getFirst(r);e!==-1;e=this.m_edgeVertices.getNext(e)){let t=this.m_edgeVertices.getElement(e);if(this.getClusterFromVertex(t)===i){let e=0,n=this.m_tempEdgeBuffer.length;do{if(e>0){let n=this.m_tempEdgeBuffer[e-1];this.addVertexToCluster_(n,t)}let n=this.m_tempEdgeBuffer[e];e+=2,this.addVertexToEdge_(n,t),t=this.m_shape.getNextVertex(t)}while(e<n)}else{let e=this.m_tempEdgeBuffer.length-1;do{if(e<this.m_tempEdgeBuffer.length-2){let n=this.m_tempEdgeBuffer[e+1];this.addVertexToCluster_(n,t)}let n=this.m_tempEdgeBuffer[e];e-=2,this.addVertexToEdge_(n,t),t=this.m_shape.getNextVertex(t)}while(e>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){let t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,n){let r=this.getEdgeCluster(t,0),i=this.getClusterXY(r),a=this.getEdgeCluster(t,1),o=this.getClusterXY(a),s=n.getResultSegmentCount(e),c=n.getResultSegment(e,0),l=c.getStartXY();if(i.isEqualPoint2D(l)||(this.m_bComplications||i.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(r,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(r)),!this.m_bComplications&&s>1){let e=i.compare(o),t=c.getEndXY();(i.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}c=n.getResultSegment(e,s-1);let u=c.getEndXY();o.isEqualPoint2D(u)||(this.m_bComplications||o.compare(this.m_sweepPoint)*u.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(a,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(a)),this.m_tempEdgeBuffer.push(t);for(let e=0,n=this.m_tempEdgeBuffer.length;e<n;e++){let n=this.m_tempEdgeBuffer[e],r=this.getEdgeSweepNode(n);rt.isValidElement(r)&&(this.m_sweepStructure.deleteNode(r),this.setEdgeSweepNode_(n,-1));let i=rt.impossibleIndex3();n!==t&&this.getEdgeSweepNode(n)!==i&&(this.m_edgesToInsertInSweepStructure.push(n),this.setEdgeSweepNode_(n,i))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){let n=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,n,t),this.m_sweepComparator.intersectionDetected()?(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0):!1}fixIntersection_(e,t){this.m_bCracked=!0;let n=this.m_sweepStructure.getElement(e),r=this.m_sweepStructure.getElement(t),i=null,a=null,o=this.getEdgeOriginVertices(n),s=this.m_edgeVertices.getFirstElement(o),c=this.getEdgeOriginVertices(r),l=this.m_edgeVertices.getFirstElement(c);this.m_shape.querySegment(s,this.m_segBuf1,!1,!1),i=this.m_segBuf1.get();let u=this.m_shape.getNextVertex(s),d=this.m_shape.getWeight(s),f=this.m_shape.getSegmentParentageBreakVertex(s),p=this.m_shape.getWeight(u),m=this.m_shape.getSegmentParentageBreakVertex(u),h=this.m_shape.getSegmentWeight(s),g=this.m_shape.getRank(s),_=this.m_shape.getRank(u),v=this.m_shape.getSegmentRank(s),y=this.m_shape.getSegmentParentage(s);this.m_shape.querySegment(l,this.m_segBuf2,!1,!1),a=this.m_segBuf2.get();let b=this.m_shape.getNextVertex(l),x=this.m_shape.getWeight(l),S=this.m_shape.getSegmentParentageBreakVertex(l),C=this.m_shape.getWeight(b),w=this.m_shape.getSegmentParentageBreakVertex(b),T=this.m_shape.getSegmentWeight(l),E=this.m_shape.getRank(l),D=this.m_shape.getRank(b),O=this.m_shape.getSegmentRank(l),k=this.m_shape.getSegmentParentage(l);this.m_segmentIntersector.pushSegment(i,d,g,p,_,h,v,f,m,y),this.m_segmentIntersector.pushSegment(a,x,E,C,D,T,O,S,w,k),this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)===3&&(this.m_bComplications=!0),this.splitEdge_(n,r,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;let n=this.m_sweepStructure.getElement(t),r=null,i=this.getEdgeOriginVertices(n),a=this.m_edgeVertices.getFirstElement(i);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();let o=this.m_shape.getNextVertex(a),s=this.m_shape.getWeight(a),c=this.m_shape.getSegmentParentageBreakVertex(a),l=this.m_shape.getWeight(o),u=this.m_shape.getSegmentParentageBreakVertex(o),d=this.m_shape.getSegmentWeight(a),f=this.m_shape.getRank(a),p=this.m_shape.getRank(o),m=this.m_shape.getSegmentRank(a),h=this.m_shape.getSegmentParentage(a),g=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(r,s,f,l,p,d,m,c,u,h),this.m_shape.queryPoint(g,this.m_helperPoint);let _=this.m_shape.getWeight(g),v=this.m_shape.getRank(g);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,v,_,!0),this.splitEdge_(n,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(this.m_edgesToInsertInSweepStructure.length===0)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=0,n=this.m_edgesToInsertInSweepStructure.length,r=Math.max(2*n+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||t>r){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}let n=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(n,-1);let i=this.isEdgeOnSweepLine_(n);rt.isValidElement(i)?(this.insertNewEdgeToSweepStructure_(n,i),t++):i!==rt.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let n;if(this.m_bContinuingSegmentChainOptimization?(n=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):n=this.m_sweepStructure.addUniqueElement(e),n===-1){let t=this.m_sweepStructure.getDuplicateElement(),n=this.m_sweepStructure.getElement(t);return this.mergeEdges_(n,e),!1}if(this.setEdgeSweepNode_(e,n),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();let e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,n),!0}return!1}isEdgeOnSweepLine_(e){let t=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getClusterXY(t),i=this.getClusterXY(n);if(U.sqrDistance(r,i)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;let a=r.compare(this.m_sweepPoint),o=i.compare(this.m_sweepPoint);return a<=0&&o>0?n:o<=0&&a>0?t:a>0&&o>0?rt.impossibleIndex2():-1}fillEventQueue(){let e=new Re(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let n=t.next();n!==z;n=t.next())this.m_shape.getUserIndex(n,this.m_vertexClusterIndex)!==-1&&e.add(n);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(e.size()),this.m_eventQ.setComparator(new Mr(this.m_shape));let n=U.getNAN();n.setNAN();let r=-1;for(let t=0,i=e.size();t<i;t++){let i=e.read(t);if(this.m_shape.getXY(i).isEqualPoint2D(n)){let e=this.m_shape.getUserIndex(i,this.m_vertexClusterIndex);this.mergeClusters_(r,e);continue}r=this.getClusterFromVertex(i),this.m_shape.queryXY(i,n);let a=this.m_eventQ.addBiggestElement(i);this.setClusterEventQNode_(r,a)}}fillEventQueuePass2(){let e=new Re(0);for(let t=this.m_eventQ.getFirst();t!==-1;t=this.m_eventQ.getNext(t)){let n=this.m_eventQ.getElement(t);e.add(n)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,n=e.size();t<n;t++){let n=e.read(t),r=this.getClusterFromVertex(n),i=this.m_eventQ.addBiggestElement(n);this.setClusterEventQNode_(r,i)}}getAffectedEdges(e,t){let n=this.getClusterFirstEdge(e);if(n===-1)return;let r=n;do{let n=this.getEdgeSweepNode(r);rt.isValidElement(n)&&t.push(r),r=this.getNextEdge(r,e)}while(r!==n)}updateClusterXY(e,t,n,r,i){let a=this.getClusterVertices(t);for(let t=this.m_clusterVertices.getFirst(a);t!==-1;t=this.m_clusterVertices.getNext(t)){let a=this.m_clusterVertices.getElement(t);this.m_shape.setXYMonotonicPoint2D(a,n),this.m_shape.setWeight(a,r),this.m_shape.setRank(a,i),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(a,!0),this.m_shape.setSegmentParentageBreakVertex(a,!0)}}splitEdge_(e,t,n,r){this.dbgCheckEdge_(e),t!==-1&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),t!==-1&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,r),t!==-1&&this.processSplitHelper1_(1,t,r),n!==-1&&r.getResultPointChanged()&&this.m_modifiedClusters.push(n);for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){let t=this.m_modifiedClusters[e],n=this.getClusterEventQNode(t);n!==-1&&(this.m_eventQ.deleteNode(n),this.setClusterEventQNode_(t,-1))}let i=this.getEdgeOriginVertices(e),a=t===-1?-1:this.getEdgeOriginVertices(t);if(this.applyIntersectorToEditShape_(i,r,0),a!==-1)this.applyIntersectorToEditShape_(a,r,1);else{let e=r.getResultPoint().getXY();this.updateClusterXY(r.getResultPointChanged(),n,e,r.getResultPointWeight(),r.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,r,0),t!==-1&&this.createEdgesAndClustersFromSplitEdge_(t,r,1),this.m_edgeVertices.deleteList(i),this.deleteEdge_(e),t!==-1&&(this.m_edgeVertices.deleteList(a),this.deleteEdge_(t));for(let e=0,t=this.m_modifiedClusters.length;e<t;e++){let t=this.m_modifiedClusters[e];t===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let n=this.getClusterEventQNode(t);if(n===-1){let e=this.getClusterFirstVertex(t);if(n=this.m_eventQ.addUniqueElement(e),n===-1){let e=this.m_eventQ.getDuplicateElement(),n=this.m_eventQ.getElement(e),r=this.getClusterFromVertex(n);this.mergeClusters_(r,t)}else this.setClusterEventQNode_(t,n)}}this.m_modifiedClusters.length=0}getClusterXY(e){let t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){let t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,this.m_sweepComparator===null&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new Ar(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));let e=[],t=null,n=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;let r=rt.impossibleIndex2(),i=rt.impossibleIndex3();for(let a=this.m_eventQ.getFirst();a!==-1;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;let o=this.m_eventQ.getElement(a);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 s=!1;{let t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(s=t===-1,!s){let n=t;do{let t=this.getEdgeSweepNode(n);t===-1?(this.m_edgesToInsertInSweepStructure.push(n),this.setEdgeSweepNode_(n,i)):t!==i&&e.push(t),n=this.getNextEdge(n,this.m_sweepPointCluster)}while(n!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=e.length===1&&this.m_edgesToInsertInSweepStructure.length===1;for(let t=0,n=e.length;t<n;t++){let n=this.m_sweepStructure.getElement(e[t]);this.setEdgeSweepNode_(n,r)}let t=r,n=r;for(let i=0,a=e.length;i<a;i++){let a=e[i];if(t===r){let e=this.m_sweepStructure.getPrev(a);if(e!==-1){let n=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(n)!==r&&(t=e)}else t=-1}if(n===r){let e=this.m_sweepStructure.getNext(a);if(e!==-1){let t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==r&&(n=e)}else n=-1}if(t!==r&&n!==r)break}for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_sweepStructure.getElement(n);this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(r,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=n,t!==-1&&n!==-1?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,n):t===-1&&n===-1&&(this.m_bContinuingSegmentChainOptimization=!1)}else s&&(t===null&&(t=new jr(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.getCurrentNode())));let c=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&c&&this.m_prevNeighbour!==-1&&this.m_nextNeighbour!==-1&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,n===null&&(n=new Nr(this.m_shape)),n.setPoint(this.m_sweepPoint),a=this.m_eventQ.searchUpperBound(n)):a=this.m_eventQ.getNext(a)}return this.m_bCracked}setEditShape_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==z;t=this.m_shape.getNextGeometry(t)){if(!s(this.m_shape.getGeometryType(t))){for(let e=this.m_shape.getFirstPath(t);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,r=this.m_shape.getPathSize(e);n<r;n++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}continue}for(let n=this.m_shape.getFirstPath(t);n!==z;n=this.m_shape.getNextPath(n)){let t=this.m_shape.getPathSize(n),r=this.m_shape.getFirstVertex(n);if(r===z)continue;let i=this.m_shape.getNextVertex(r);if(i===z||i===r)continue;let a=-1;e.selected(r)&&(a=this.newCluster_(r));let o=-1;a!==-1&&e.selected(i)&&(o=this.newEdge_(r),this.addEdgeToCluster(o,a));let s=o;for(let e=0,n=t-2;e<n;e++){let e=this.m_shape.getNextVertex(i),t=-1;if(this.m_shape.selected(i)){let n=this.newCluster_(i);s!==-1&&this.addEdgeToCluster(s,n),this.m_shape.selected(e)&&(t=this.newEdge_(i),this.addEdgeToCluster(t,n))}s=t,i=e}if(this.m_shape.isClosedPath(n)){let e=this.m_shape.getNextVertex(i);if(this.m_shape.selected(i)){let t=this.newCluster_(i);if(s!==-1&&this.addEdgeToCluster(s,t),this.m_shape.selected(e)){let e=this.newEdge_(i);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,a)}}}else{let e=-1;this.m_shape.selected(i)&&(e=this.newCluster_(i),s!==-1&&this.addEdgeToCluster(s,e))}}}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function Fr(e,t,n,r){n>0&&fr(e,n,t,!1,r),new Lr(r).executeImpl_(e,t)}function Ir(e,t,n){return{vertex0:e,vertex1:t,dir:n}}class Lr{m_shape=null;m_progressTracker;m_spikes=[];m_points=new Re(0);m_pointsIndex=-1;m_dissolvedEdges=0;constructor(e){this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let n=e.getFirstPath(t);n!==z;n=e.getNextPath(n)){let t=e.getFirstVertex(n);for(let r=0,i=e.getPathSize(n);r<i;r++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let t=0,n=this.m_points.size();t<n;++t)e.setUserIndex(this.m_points.read(t),this.m_pointsIndex,t);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let n=this.m_points.read(0),r=e.getXY(n),i=1,a=0,o=[];for(let t=1;t<this.m_points.size();t++){let s=this.m_points.read(t);if(s===z||e.getUserIndex(s,this.m_pointsIndex)===-1)continue;let c=e.getXY(s);if(c.isEqualPoint2D(r))i++;else{if(i>1){for(let n=a;n<t;n++){let t=this.m_points.read(n);if(e.getUserIndex(t,this.m_pointsIndex)===-1)continue;let i=e.getNextVertex(t),a=e.getPrevVertex(t);if(t!==i&&!e.isEqualXYPoint2D(i,r)){let e=Ir(t,i,1);o.push(e)}if(t!==a&&a!==i&&!e.isEqualXYPoint2D(a,r)){let e=Ir(t,a,-1);o.push(e)}}o.length>0&&this.processBunch_(o,r)}n=s,r.assign(c),i=1,a=t}}if(this.m_dissolvedEdges===0){e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1;return}let s=e.getPointCount(t);for(let t=0;t<this.m_points.size();t++){let n=this.m_points.read(t);if(n===z)continue;if(e.getUserIndex(n,this.m_pointsIndex)!==-1){e.setUserIndex(n,this.m_pointsIndex,-1);continue}let r=e.getPathFromVertex(n);e.getFirstVertex(r)===n&&e.setFirstVertex(r,z),e.freeVertex(n),this.m_points.write(t,z),s--}let c=e.createPathUserIndex(),u=e.getPathCount(t);for(let n=0,r=this.m_points.size();n<r;++n){if(this.m_points.read(n)===z)continue;let r=this.m_points.read(n);if(e.getUserIndex(r,this.m_pointsIndex)!==-1)continue;let i=e.getPathFromVertex(r),a=-1;if(e.getPathUserIndex(i,c)===2){i=z;for(let t=e.getNextVertex(r);t!==r;t=e.getNextVertex(t)){let n=e.getPathFromVertex(t);if(e.getPathUserIndex(n,c)!==2){i=n,r=t;break}}i===z&&(i=e.insertPath(t,z),e.setClosedPath(i,!0),u++),l(i!==z)}e.setPathUserIndex(i,c,2),a=e.getFirstVertex(i);let o=0,s=!1,d=r;do{a===d&&(s=!0),e.setUserIndex(d,this.m_pointsIndex,1);let t=e.getPathFromVertex(d);t!==i&&(e.getPathUserIndex(t,c)!==2&&(e.setPathUserIndex(t,c,1),e.setFirstVertex(t,z)),e.setPathToVertex(d,i)),o++,d=e.getNextVertex(d)}while(d!==r);s||e.setFirstVertex(i,r),e.setPathSize(i,o)}for(let n=e.getFirstPath(t);n!==z;){let t=e.getNextPath(n);(e.getPathUserIndex(n,c)===1||e.getFirstVertex(n)===z)&&(e.removePathOnly(n),u--),n=t}e.setGeometryVertexCount(t,s),e.setGeometryPathCount(t,u),e.removePathUserIndex(c),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,n)=>{let r=this.m_shape.getXY(e.vertex1).sub(t),i=this.m_shape.getXY(n.vertex1).sub(t),a=U.compareVectors(r,i);return a===0?e.dir<n.dir?-1:1:a});let n=0,r=this.m_shape.getXY(e[0].vertex1),i=1,a=this.m_shape.hasCurves();for(let t=1,o=e.length;t<o;t++){let s=this.m_shape.getXY(e[t].vertex1);if(!(s.isEqualPoint2D(r)&&(i++,t+1<o))){if(i===2){let t=e[n],r=e[n+1],i=t.dir;if(i!==r.dir){let e=!0;if(a&&(e=!this.m_shape.isCurve(t.dir===1?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(r.dir===1?r.vertex0:r.vertex1)),e){if(i===1){let e=t.vertex0,n=r.vertex0;this.m_shape.setNextVertex(e,n),this.m_shape.setPrevVertex(n,e),this.m_shape.getPrevVertex(e)===n&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(n,this.m_pointsIndex,-1));let i=t.vertex1,a=r.vertex1;this.m_shape.setPrevVertex(i,a),this.m_shape.setNextVertex(a,i),this.m_shape.getNextVertex(i)===a&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(a,this.m_pointsIndex,-1))}else{let e=t.vertex0,n=r.vertex0;this.m_shape.setPrevVertex(e,n),this.m_shape.setNextVertex(n,e),this.m_shape.getNextVertex(e)===n&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(n,this.m_pointsIndex,-1));let i=t.vertex1,a=r.vertex1;this.m_shape.setNextVertex(i,a),this.m_shape.setPrevVertex(a,i),this.m_shape.getPrevVertex(i)===a&&(this.m_shape.setUserIndex(i,this.m_pointsIndex,-1),this.m_shape.setUserIndex(a,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}r.assign(s),n=t,i=1}}e.length=0}}function Rr(e){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))if(s(e.getGeometryType(t)))return!0;return!1}function zr(e,t,n,r){if(!Rr(e))return!1;let i=new Ur(r);i.m_shape=e,i.m_tolerance=t,i.m_bTrackChanges=n;let a=!1,o=e.hasCurves()?5:15;return a=e.getTotalPointCount()<o?i.crackBruteForce_():i.crackerPlaneSweep_(),a}function Br(e,t,n,r,i){if(!Rr(t))return!1;let a=new Ur(i);if(a.m_shape=t,a.m_tolerance=n,a.m_bAllowCoincident=e,a.m_bNeedsNonSimpleResult=r!==null,a.needsCrackingImpl_())return r&&r.assign(a.m_nonSimpleResult),!0;let o=new K;o.setSwapCoordinates(),t.applyTransformation(o),a=new Ur(i),a.m_shape=t,a.m_tolerance=n,a.m_bAllowCoincident=e,a.m_bNeedsNonSimpleResult=r!==null;let s=a.needsCrackingImpl_();return t.applyTransformation(o),s?(r&&r.assign(a.m_nonSimpleResult),!0):!1}function Vr(e,t,n,r){let i=t.getGeometryType();if(s(i))return new Ur(r).crackAWithBMultiPath_(e,t,n);p(`crack_A_with_B`)}function Hr(e,t){return{t:e,index:t}}class Ur{static s_bForceBruteForce=!0;m_shape=null;m_progressTracker=null;m_nonSimpleResult=new J;m_tolerance=0;m_sweepComparator=null;m_progressCounter=0;m_bTrackChanges=!1;m_bNeedsNonSimpleResult=!1;m_bAllowCoincident=!0;crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){let t=new K;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1,t=new F,n=new F,r=T.constructEmpty(),i=T.constructEmpty(),a=new B,o=new xr,s=this.m_shape.getTotalPointCount(),c=s*s*2,u=this.m_shape.queryVertexIteratorOnSelection();for(let s=u.next();s!==z;s=u.next()){let d=this.m_shape.getGeometryType(u.currentGeometry()),f=1,p=1,m=1,h=0,g=0,_=0,v=this.m_shape.getSegmentParentage(s),y=!1,x=!1,S=null,C=!1;if(b(d))f=this.m_shape.getWeight(s),h=this.m_shape.getRank(s);else{if(S=this.getSegment_(s,t),S===null)continue;let e=this.m_shape.getVertexIndex(s);f=this.m_shape.getWeightWithIndex(e),h=this.m_shape.getRankWithIndex(e),m=this.m_shape.getSegmentWeightWithIndex(e),_=this.m_shape.getSegmentRankWithIndex(e),y=this.m_shape.getSegmentParentageBreakVertex(s);{let e=this.m_shape.getNextVertex(s);p=this.m_shape.getWeight(e),g=this.m_shape.getRank(e),x=this.m_shape.getSegmentParentageBreakVertex(e)}if(S.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),S.isDegenerate(this.m_tolerance)){if(S.isDegenerate(0))C=!0,S=null;else continue}}let w=new ue({copy:u}),T=w.next();T!==z&&(T=w.next());let E=0;for(;T!==z;T=w.next()){if(E!==0){E--;continue}if(this.m_shape.getTotalPointCount()>c)return e;this.progress_();let d=this.m_shape.getGeometryType(w.currentGeometry()),D=null,O=!1,k=0,A=0,j=0,M=0,N=0,P=0,F=!1,I=!1,L=this.m_shape.getSegmentParentage(T);if(b(d))k=this.m_shape.getWeight(T),M=this.m_shape.getRank(T);else{if(D=this.getSegment_(T,n),D===null)continue;let e=this.m_shape.getVertexIndex(T);k=this.m_shape.getWeightWithIndex(e),M=this.m_shape.getRankWithIndex(e),j=this.m_shape.getSegmentWeightWithIndex(e),P=this.m_shape.getSegmentRankWithIndex(e),F=this.m_shape.getSegmentParentageBreakVertex(T);{let e=this.m_shape.getNextVertex(T);A=this.m_shape.getWeight(e),N=this.m_shape.getRank(e),I=this.m_shape.getSegmentParentageBreakVertex(e)}if(D.queryLooseEnvelope(i),D.isDegenerate(this.m_tolerance)){if(D.isDegenerate(0))O=!0,D=null;else continue}}let R=0,ee=0;if(S!==null&&D!==null)r.isIntersectingNe(i)&&de(!0,!0,S,D,this.m_tolerance,!0)!==0&&(o.pushSegment(S,f,h,p,g,m,_,y,x,v),o.pushSegment(D,k,M,A,N,j,P,F,I,L),o.intersect2D(this.m_tolerance,!0),e||=o.getSegmentChanged(0)||o.getSegmentChanged(1),R=o.getResultSegmentCount(0),ee=o.getResultSegmentCount(1),R+ee>0&&(this.m_shape.splitSegmentWithIntersector(s,o,0,!0,!0),this.m_shape.splitSegmentWithIntersector(T,o,1,!0,!0),this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(T,!0))),ee>1&&(E+=ee-1),o.clear());else if(S!==null){let t=this.m_shape.getXY(T);if(r.contains(t)){if(o.pushSegment(S,f,h,p,g,m,_,y,x,v),this.m_shape.queryPoint(T,a),o.intersect2DEx(this.m_tolerance,a,M,k,!1),e||=o.getSegmentChanged(0)||o.getResultPointChanged(),R=o.getResultSegmentCount(0),R>0){if(this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(T,!0)),this.m_shape.splitSegmentWithIntersector(s,o,0,!0,!0),O){let e=z;for(let t=this.m_shape.getNextVertex(T);t!==z&&t!==T&&(D=this.getSegment_(t,n),e=t,D!=null&&D.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=T;t!==z&&(this.m_shape.setPoint(t,o.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(T,o.getResultPoint(),!0)}o.clear()}}else if(D!==null){let t=this.m_shape.getXY(s);if(i.inflateCoords(this.m_tolerance,this.m_tolerance),i.contains(t)){if(o.pushSegment(D,k,M,A,N,j,P,F,I,L),this.m_shape.queryPoint(s,a),o.intersect2DEx(this.m_tolerance,a,h,f,!1),e||=o.getSegmentChanged(0)||o.getResultPointChanged(),ee=o.getResultSegmentCount(0),ee>0){if(this.m_bTrackChanges&&(o.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(T,!0),o.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(s,!0)),this.m_shape.splitSegmentWithIntersector(T,o,0,!0,!0),E+=ee-1,C){let e=z;for(let t=this.m_shape.getNextVertex(s);t!==z&&t!==s&&(D=this.getSegment_(t,n),e=t,D!=null&&D.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=s;t!==z&&(this.m_shape.setPoint(t,o.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(s,o.getResultPoint(),!0)}o.clear()}}else continue;if(R+ee!==0&&R!==0){let e=!1;for(;S=this.getSegment_(s,t),S!=null&&(S.queryEnvelope(r),S.isDegenerate(this.m_tolerance));)if(R>1)s=u.next(),R--,l(s!==z);else{e=!0;break}if(e)break}}}return e}m_sweepStructure=new Ie;crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Pr(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1,t=new Re(0);t.resize(this.m_shape.getSelectedCount());let n=this.m_shape.queryVertexIteratorOnSelection();for(let e=0,r=n.next();r!==z;++e,r=n.next())t.write(e,r);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(z);let r=this.m_shape.createUserIndex(),i=this.m_shape.createUserIndex();this.m_sweepComparator=new lr(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let a=null,s=[],c=[],l=0,u=new U;for(let n=t.read(l++);n!==z;){this.m_shape.queryXY(n,u);let d=!1;do{let e=this.m_shape.getNextVertex(n),a=this.m_shape.getPrevVertex(n);d||=e!==z||a!==z,e!==z&&!this.m_shape.selected(e)&&(e=z),a!==z&&!this.m_shape.selected(a)&&(a=z),e!==z&&this.m_shape.compareVerticesSimpleY(n,e)<0&&(c.push(n),c.push(e)),a!==z&&this.m_shape.compareVerticesSimpleY(n,a)<0&&(c.push(a),c.push(a));let o=this.m_shape.getUserIndex(n,r);o!==-1&&(s.push(o),this.m_shape.setUserIndex(n,r,-1));let u=this.m_shape.getUserIndex(n,i);u!==-1&&(s.push(u),this.m_shape.setUserIndex(n,i,-1)),n=t.read(l++)}while(n!==z&&this.m_shape.isEqualXYPoint2D(n,u));if(!d&&(a===null&&(a=new ur(this.m_shape,this.m_tolerance)),a.setPoint(u),this.m_sweepStructure.searchUpperBound(a),a.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(o(`needsCrackingIMpl_`),this.m_nonSimpleResult=new J(6,-1,-1));break}let f=s.length===1&&c.length===2;s.length>32&&dt(s);let p=-1,m=-1;if(!f)for(let t=0,n=s.length;t<n;t++){let n=s[t],r=this.m_sweepStructure.getPrev(n);if(r!==-1&&s.indexOf(r)===-1){if(p===-1)p=r;else if(e=!0,this.m_bNeedsNonSimpleResult)this.m_nonSimpleResult=new J(6,-1,-1);else break}let i=this.m_sweepStructure.getNext(n);if(i!==-1&&s.indexOf(i)===-1){if(m===-1)m=i;else if(e=!0,this.m_bNeedsNonSimpleResult)this.m_nonSimpleResult=new J(6,-1,-1);else break}if(p!==-1&&m!==-1)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(u.y,u.x),!f){for(let e=0,t=s.length;e<t;e++){let t=s[e];this.m_sweepStructure.deleteNode(t)}s.length=0}if(!f&&p!==-1&&m!==-1&&this.checkForIntersections_(p,m)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,n=c.length;t<n;t+=2){let n=c[t],a=c[t+1],o;if(f?(o=this.m_sweepStructure.replaceElementAtPosition(s[0],n,!0,!0),s.length=0,f=!1):o=this.m_sweepStructure.addElement(n),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}this.m_shape.getUserIndex(a,r)===-1?this.m_shape.setUserIndex(a,r,o):this.m_shape.setUserIndex(a,i,o)}if(e)break;c.length=0}return this.m_shape.removeUserIndex(r),this.m_shape.removeUserIndex(i),e}checkForIntersections_(e,t){let n=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,n,t);let r=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),r}getSegment_(e,t){return Ur.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,n){return e.querySegment(t,n,!1,!1)?n.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,n){let r=T.constructEmpty();e.queryLooseEnvelope(r);let a=T.constructEmpty();if(t.queryLooseEnvelope(a),a.inflateCoords(n,n),!a.isIntersecting(r))return e;let o=e.getImpl(),s=o.getAccelerators(),c=null,u=null;s&&(u=s.getQuadTree()),Wr(e,m(t))&&(c=qe(o,a),u=c);let d=u?u.getIteratorForQT():null,f=t.querySegmentIterator(),p=e.querySegmentIterator(),h=H(15,NaN),g=[];for(;f.nextPath();)for(;f.hasNextSegment();){let e=f.nextSegment();if(u){d.resetIterator(e,n);for(let t=d.next();t!==-1;t=d.next()){this.progress_();let r=u.getElement(t);if(p.resetToVertex(r,-1),p.hasNextSegment()){let t=p.nextSegment().intersect(e,null,h,null,n);for(let e=0;e<t;e++){let t=h[e];if(t===0||t===1)continue;let n=Hr(t,p.getStartPointIndex());g.push(n)}}}}else{let t=T.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(p.resetToFirstPath();p.nextPath();)for(;p.hasNextSegment();){let r=p.nextSegment(),i=T.constructEmpty();if(r.queryLooseEnvelope(i),!i.isIntersecting(t))continue;let a=r.intersect(e,null,h,null,n);for(let e=0;e<a;e++){let t=h[e];if(t===0||t===1)continue;let n=Hr(t,p.getStartPointIndex());g.push(n)}}}}if(g.length===0)return e;g.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:+(e.t>t.t));let _=e.createInstance();for(_.getGeometryType()===i.enumPolygon&&_.setFillRule(e.getFillRule()),p.resetToFirstPath();p.nextPath()&&!p.hasNextSegment(););l(p.hasNextSegment());let v=p.nextSegment(),y=new F,b=-1;for(let e=0,t=g.length;e<t;){let n=g[e].index,r=e+1;for(;r<t&&g[r].index===n;)++r;for(;p.getStartPointIndex()<n;){this.progress_();let e=p.hasNextSegment(),t=p.getPathIndex();if((e||!p.isClosingSegment()||p.isCurve())&&(l(v!==null),_.addSegment(v,b!==t)),b=t,!e){for(p.isPathClosed();p.nextPath()&&!p.hasNextSegment(););l(p.hasNextSegment())}v=p.nextSegment()}let i=0;for(let t=e;t<r;t++){let e=g[t].t;if(e===i)continue;l(v!==null),v.queryCut(i,e,y),i=e;let n=p.getPathIndex();_.addSegment(y.get(),b!==n),b=n}let a=p.hasNextSegment();if((a||!p.isClosingSegment()||p.isCurve())&&(l(v!=null),v.queryCut(i,1,y),_.addSegment(y.get(),!1)),a)v=p.nextSegment();else{for(;p.nextPath()&&!p.hasNextSegment(););v=p.hasNextSegment()?p.nextSegment():null}e=r}if(v!==null){let e=p.getPathIndex();(p.hasNextSegment()||!p.isClosingSegment()||p.isCurve())&&_.addSegment(v,b!==e),b=e}let x=p.hasNextSegment();for(;;){if(!x){for(;p.nextPath()&&(x=p.hasNextSegment(),!x););if(!x)break}v=p.nextSegment();let e=p.getPathIndex();x=p.hasNextSegment(),(x||!p.isClosingSegment()||p.isCurve())&&_.addSegment(v,b!==e),b=e}return _}constructor(e){this.m_progressTracker=e}}function Wr(e,t){let n=e.getPointCount();return n<16?!1:2*n+Math.log(n)/Math.log(2)*1*t<1*n*t}class Gr{m_inputPoint;m_windnum;m_monotoneParts=bt(F,16);m_xOrds=H(16,NaN);m_tolerance;m_toleranceSqr;m_miny;m_maxy;m_bAlternate;m_bTestBorder;m_bBreak;constructor(e,t){this.m_inputPoint=U.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY()))){this.m_bBreak=!0;return}if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){let t=Math.min(e.getStartX(),e.getEndX()),n=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<n&&(this.m_bBreak=!0)}return}let t=!1,n=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>n)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){let r=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,n);t=!Number.isNaN(r)&&r<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){let t=e.getClosestCoordinate(this.m_inputPoint,!1),n=e.getCoord2D(t);return U.sqrDistance(n,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){let t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let n=0;if(e.isCurve()&&(this.m_monotoneParts.length===0&&(this.m_monotoneParts.length=128),n=e.getMonotonicParts(this.m_monotoneParts,!0),l(this.m_monotoneParts.length>=n)),n>0)for(let e=0;e<n;e++){let t=this.m_monotoneParts[e].get(),n=W.construct(t.getStartY(),t.getEndY());if(!(n.vmin>this.m_inputPoint.y||n.vmax<this.m_inputPoint.y)&&(this._DoOne(t),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return l(0),2}}function Kr(e,t,n,r){let i=new T;e.queryLooseEnvelope(i),i.inflateCoords(r,r);let a=e.getFillRule()===0,o=new Gr(a,r);o.setInputPoint(n);let s=i.clone();s.xmax=n.x+r,s.ymin=n.y-r,s.ymax=n.y+r;let c=e.getImpl().querySegmentIterator(),l=t.getIterator(s,r);for(let e=l.next();e!==-1;e=l.next())if(c.resetToVertex(t.getElement(e),-1),c.hasNextSegment()){let e=c.nextSegment();if(o.processSegment(e))return-1}return+!!o._Result()}function qr(e,t,n){let r=e.getFillRule()===0,i=new Gr(r,n);i.setInputPoint(t);let a=e.getImpl().querySegmentIterator();for(;a.nextPath();)for(;a.hasNextSegment();){let e=a.nextSegment();if(i.processSegment(e))return-1}return+!!i._Result()}function Jr(e,t,n){return t.isEmpty()?0:Yr(e,t.getXY(),n)}function Yr(e,t,n){if(e.isEmpty())return 0;let r=T.constructEmpty();if(e.queryLooseEnvelope(r),r.inflateCoords(n,n),!r.contains(t))return 0;let i=e.getImpl().getAccelerators();if(i){i.getRasterizedGeometry()&&l(0);let r=i.getQuadTree();if(r)return Kr(e,r,t,n)}return qr(e,t,n)}function Xr(e,t){let n=e.getPointCount();return n<16?!1:2*n+Math.log(n)/Math.log(2)*1*t<1*n*t}function Zr(e,t,n,r,i){let a=new ni(i);return a.m_shape=e,a.m_geometry=t,a.m_sortedVertices=n,a.m_bFixSelfTangency=r,a.fixRingOrientation_()}function Qr(e,t,n){let r=new ni(n);return r.m_shape=e,r.m_geometry=t,r.m_sortedVertices=null,r.m_bFixSelfTangency=!1,r.fixRingOrientationForMp2sp_()}class $r{m_shape;m_end1Nodes=[];m_end2Nodes=[];m_directions=[];m_firstFree;getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){let t=this.getEnd1(e),n=this.getEnd2(e);return this.m_shape.getNextVertex(t)===n?n:t}constructor(e){this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),n=this.getEnd2(e);this.m_shape.getPrevVertex(t)===n&&(n=gt(t,t=n));let r=U.getNAN(),i=U.getNAN();return this.m_shape.queryXY(t,r),this.m_shape.queryXY(n,i),l(!r.equals(i)),r.y<i.y}getStart(e){let t=this.getEnd1(e),n=this.getEnd2(e);return this.m_shape.getNextVertex(t)===n?t:n}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(this.m_firstFree!==-1){let t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}let t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let ei=class extends tt{m_helper;m_line1=new I;m_line2=new I;m_leftElm=-1;m_leftx=0;m_seg1=null;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_edges,a;this.m_leftElm===t?a=this.m_leftx:(this.m_seg1=i.getSegment(t),this.m_seg1?a=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(i.getShape().queryLineConnector(i.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,a=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=a,this.m_leftElm=t);let o=i.getSegment(r),s;if(o?s=o.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(i.getShape().queryLineConnector(i.getStart(r),this.m_line2,!0),o=this.m_line2,s=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),a===s){let e=i.isBottomUp(t),n=i.isBottomUp(r),c=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=n?o.getEndY():o.getStartY(),u=Math.min(c,l),d=(u+this.m_helper.m_yScanline)*.5;d===this.m_helper.m_yScanline&&(d=u),a=this.m_seg1.intersectionOfYMonotonicWithAxisX(d,0),s=o.intersectionOfYMonotonicWithAxisX(d,0),a===s&&w(``)}return a<s?-1:+(a>s)}reset(){this.m_leftElm=-1}};class ti{m_sortedVertices;m_sortedVerticesArray;m_node=-1;m_index=0;constructor(e){this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){let e=this.m_node;if(e===-1)return z;let t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){let e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return z}}class ni{m_edges=null;m_sweepComparator;m_shape=null;m_AET=new Ie;m_yScanline=0;m_geometry=z;m_unknownRingOrientationCount=-1;m_sortedVertices=null;m_sortedVerticesArray=null;m_unknownNodes=[];m_progressTracker;m_node1UserIndex=-1;m_node2UserIndex=-1;m_pathOrientationIndex=-1;m_pathParentageIndex=-1;m_pathParentsIndex=-1;m_progressCounter=0;m_bFixSelfTangency=!1;constructor(e){this.m_progressTracker=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new ei(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){let e=this.fixRingOrientationImplMain_();return this.m_pathOrientationIndex===-1||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),this.m_pathOrientationIndex===-1?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||=new $r(this.m_shape),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let n=0,r=e.length;n<r;n++)e[n]!==-1&&t++;(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let t=0,n=e.length;t<n;t++){let n=e[t];n!==z&&this.insertEdge_(n,-1)}for(let e=0;e<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;e++){let n=this.m_unknownNodes[e],r=this.m_AET.getElement(n),i=this.m_edges.getPath(r),a=this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex),o=z;if(a===0){let e=this.m_AET.getPrev(n),r=n,i=!1;for(;e!==Ie.st_nullNode();){let t=this.m_AET.getElement(e),n=this.m_edges.getPath(t);if(this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)!==0){o=n;break}r=e,e=this.m_AET.getPrev(e)}if(e===Ie.st_nullNode())i=!0,e=r;else{let t=this.m_AET.getElement(e);i=this.m_edges.isBottomUp(t),e=this.m_AET.getNext(e),i=!i}do{let n=this.m_AET.getElement(e),a=this.m_edges.getPath(n);if(this.m_shape.getPathUserIndex(a,this.m_pathOrientationIndex)===0){if(i!==this.m_edges.isBottomUp(n)){let e=this.m_shape.getFirstVertex(a);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(a,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(a,this.m_pathOrientationIndex,i?3:2),!i){let e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);e===2?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),l(e===3)):l(e===3);let t=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,a),this.m_shape.setPathUserIndex(a,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(a,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}o=a,r=e,e=this.m_AET.getNext(e),i=!i}while(r!==n)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_shape.getUserIndex(n,this.m_node1UserIndex),i=this.m_shape.getUserIndex(n,this.m_node2UserIndex);if(r!==-1){let e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(n,this.m_node1UserIndex,-1)}if(i!==-1){let e=this.m_AET.getElement(i);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(n,this.m_node2UserIndex,-1)}let a=-1;r!==-1&&i!==-1?(this.m_AET.deleteNode(r),this.m_AET.deleteNode(i),e[t]=z):a=r===-1?i:r,a!==-1&&(this.insertEdge_(n,a)||this.m_AET.deleteNode(a),e[t]=z)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){let n=U.getNAN(),r=U.getNAN();this.m_shape.queryXY(e,n);let i=this.m_shape.getNextVertex(e);this.m_shape.queryXY(i,r);let a=!1;if(n.y<r.y){a=!0;let n=this.m_edges.newEdge(e),r;t===-1?r=this.m_AET.addElement(n):(r=t,this.m_AET.setElement(r,n)),this.m_shape.getUserIndex(i,this.m_node1UserIndex)===-1?this.m_shape.setUserIndex(i,this.m_node1UserIndex,r):this.m_shape.setUserIndex(i,this.m_node2UserIndex,r);let o=this.m_shape.getPathFromVertex(e);this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)===0&&this.m_unknownNodes.push(r)}let o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,r),n.y<r.y){a=!0;let n=this.m_edges.newEdge(o),r;t===-1?r=this.m_AET.addElement(n):(r=t,this.m_AET.setElement(r,n)),this.m_shape.getUserIndex(o,this.m_node1UserIndex)===-1?this.m_shape.setUserIndex(o,this.m_node1UserIndex,r):this.m_shape.setUserIndex(o,this.m_node2UserIndex,r);let i=this.m_shape.getPathFromVertex(e);this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)===0&&this.m_unknownNodes.push(r)}return a}fixRingSelfTangency_(){let e=[],t=[],n=-1,r=-1,i=new U,a=z,o=z,s=-1,c=new ti(this);for(let l=c.next();l!==z;l=c.next()){let c=new U;this.m_shape.queryXY(l,c);let u=this.m_shape.getPathFromVertex(l);i.equals(c)&&o===u?(r===-1&&(n=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,n,-1),r=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,r,-1)),s===-1&&(s=t.length,this.m_shape.setUserIndex(a,r,s),t.push(1),this.m_shape.getPathUserIndex(u,n)===-1&&(this.m_shape.setPathUserIndex(u,n,a),e.push(u))),this.m_shape.setUserIndex(l,r,s),t[t.length-1]++):(s=-1,i.assign(c)),a=l,o=u}if(e.length===0)return!1;l(n!==-1);for(let i=0,a=e.length;i<a;i++){let a=e[i],o=this.m_shape.getPathUserIndex(a,n),s=this.m_shape.getUserIndex(o,r),c=[],l=[];c.push(o),l.push(s);for(let e=this.m_shape.getNextVertex(o);e!==o;e=this.m_shape.getNextVertex(e)){let n=e,i=this.m_shape.getUserIndex(n,r);if(i!==-1){if(l.length===0){l.push(i),c.push(n);continue}if(l.at(-1)===i){let a=c.at(-1);this.m_shape.peelALoopIntoAPath(a,n),this.m_shape.setUserIndex(e,r,-1),t[i]--,t[i]===1&&(t[i]=0,l.pop(),c.pop()),o=a,e=a}else c.push(e),l.push(i)}}}return this.m_shape.removePathUserIndex(n),this.m_shape.removeUserIndex(r),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){let n={stack:[],error:void 0,hasError:!1};try{let t=!1,r,i=e(n,Et(()=>{this.m_sortedVerticesArray=null}),!1);if(this.m_sortedVertices===null){let e=this.m_shape.getPointCount(this.m_geometry);r=new Re(0);for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let n=0,i=this.m_shape.getPathSize(e);n<i;n++)r.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(r,0,e),this.progress_(!0),this.m_sortedVerticesArray=r}else i.bForget=!0;if(this.m_bFixSelfTangency&&(t=this.fixRingSelfTangency_()),this.m_shape.getPathCount(this.m_geometry)===1){let e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){let t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);let a=[];this.m_yScanline=NaN;let o=U.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);let s=new ti(this);for(let e=s.next();e!==z&&(this.progress_(),this.m_shape.queryXY(e,o),o.y!==this.m_yScanline&&a.length&&(t=this.processBunchForRingOrientationTest_(a)||t,this.m_sweepComparator.reset(),a.length=0),a.push(e),this.m_yScanline=o.y,this.m_unknownRingOrientationCount!==0);e=s.next());return this.m_unknownRingOrientationCount>0&&(t=this.processBunchForRingOrientationTest_(a)||t,a.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),t}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}fixRingOrientationImplSimplify_(){let e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==z;)if(this.progress_(),this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)===3){this.m_shape.setExterior(t,!0);for(let n=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);n!==z;){let r=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e.push(n),this.m_shape.setExterior(n,!1),this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,t),n=r}let n=t,r=e.length;for(let e=this.m_shape.getNextPath(t);r>0&&e!==z;e=this.m_shape.getNextPath(e),--r){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)===t){n=e;continue}n=z;break}if(r!==0){n=t;for(let t=0,r=e.length;t<r;t++){let r=e[t];this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,nt),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(n),r),n=r}}e.length=0,t=this.m_shape.getNextPath(n)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){let e=this.m_shape.createPathUserIndex(),t=0,n=[];for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==z;)if(this.progress_(),this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)===3){this.m_shape.setExterior(r,!0),this.m_shape.setPathUserIndex(r,e,t),t++;for(let e=this.m_shape.getPathUserIndex(r,this.m_pathParentageIndex);e!==z;){let t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);n.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,r),e=t}let i=r,a=n.length,o=t;for(let t=this.m_shape.getNextPath(r);a>0&&t!==z;t=this.m_shape.getNextPath(t),--a){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)===r){i=t,this.m_shape.setPathUserIndex(t,e,-o),o++;continue}i=z;break}if(a!==0){i=r,o=t;for(let t=0,r=n.length;t<r;t++){let r=n[t];this.m_shape.setPathUserIndex(r,e,-o),o++,this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,nt)}i=r}t=o,n.length=0,r=this.m_shape.getNextPath(i)}else r=this.m_shape.getNextPath(r);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function ri(e,t,n,r,i,a){let o=new ii(a);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=n,o.m_bFixSelfTangency=r,o.m_polylineDegeneracies=i,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class ii{m_shape=null;m_progressTracker;m_geometry=z;m_sortedVertices=new Fe;m_bunchEdgeEndPoints=[];m_bunchEdgeCenterPoints=[];m_bunchEdgeIndices=[];m_sorterSegmentBuffer1=null;m_sorterSegmentBuffer2=null;m_knownSimpleResult=-1;m_sortedVerticesListIndex=-1;m_polylineDegeneracies=z;m_userIndexSortedIndexToVertex=-1;m_userIndexSortedAngleIndexToVertex=-1;m_nextVertexToProcess=-1;m_firstCoincidentVertex=-1;m_progressCounter=0;m_bFixSelfTangency=!1;m_bHasSegmentParentage=!1;m_bHasSegments=!1;constructor(e){this.m_progressTracker=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){let n=this.m_bunchEdgeEndPoints[e],r=new U;this.m_shape.queryXY(n,r);let i=new U,a=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(a,i),r.equals(i))return 0;let o=this.m_bunchEdgeCenterPoints[e],s=new U;this.m_shape.queryXY(o,s);let c=this.m_bunchEdgeCenterPoints[t],l=new U;this.m_shape.queryXY(c,l);let u=new U;u.setSub(r,s);let d=new U;return d.setSub(i,l),(u.isZero()||d.isZero())&&w(``),U.compareVectors(u,d)}compareAnglesCurves_(e,t){let n=this.m_bunchEdgeEndPoints[e],r=this.m_bunchEdgeEndPoints[t],i=this.m_bunchEdgeCenterPoints[e],a=this.m_bunchEdgeCenterPoints[t],o=this.m_shape.getNextVertex(i)===n,s=this.m_shape.getNextVertex(a)===r,c=o?this.m_shape.isCurve(i):this.m_shape.isCurve(n),l=s?this.m_shape.isCurve(a):this.m_shape.isCurve(r);return!c&&!l?this.compareAnglesLines_(e,t):(this.m_sorterSegmentBuffer1||=new F,this.m_sorterSegmentBuffer2||=new F,o?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),s?this.m_shape.querySegment(a,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(r,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse()),ce(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get()))}beforeRemoveVertex_(e,t){let n=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===n&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===n&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,n),this.removeAngleSortInfo_(e),t){let t=this.m_shape.getPathFromVertex(e);if(t!==z&&this.m_shape.getFirstVertex(t)===e){let n=this.m_shape.getNextVertex(e);if(n!==e){if(this.m_shape.getPathFromVertex(n)===t){this.m_shape.setFirstVertex(t,n);return}{let n=this.m_shape.getPrevVertex(e);if(n!==e&&this.m_shape.getPathFromVertex(n)===t){this.m_shape.setFirstVertex(t,n);return}}}this.m_shape.setFirstVertex(t,z),this.m_shape.setLastVertex(t,z)}}}processBunch_(){let e=!1,t=new U(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let n=this.m_firstCoincidentVertex,r=0,i=!0;for(;n!==this.m_nextVertexToProcess;){let e=this.m_sortedVertices.getData(n);i&&=(this.m_shape.queryXY(e,t),!1);let a=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex)!==nt&&(this.m_bunchEdgeEndPoints.push(a),this.m_shape.setUserIndex(a,this.m_userIndexSortedAngleIndexToVertex,nt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(r++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==nt&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,nt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(r++)),n=this.m_sortedVertices.getNext(n)}if(this.m_bunchEdgeEndPoints.length<2){this.m_bunchEdgeEndPoints.length===1&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){let t=this.m_bunchEdgeIndices[e],n=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(n,this.m_userIndexSortedAngleIndexToVertex,e)}let a=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){let t=this.m_bunchEdgeIndices[e];if(t===-1)continue;let n=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(n,this.m_userIndexSortedAngleIndexToVertex,-1)}if(a){e=!0;continue}break}return e}processCrossOvers_(e){let t=!1,n=!0;for(;n;){n=!1;let r=0;this.m_bunchEdgeIndices[r]===-1&&(r=this.getNextEdgeIndex_(r));let i=this.getNextEdgeIndex_(r);for(let a=0,o=this.m_bunchEdgeIndices.length;a<o&&r!==-1&&i!==-1&&r!==i;a++){let a=this.m_bunchEdgeIndices[r],o=this.m_bunchEdgeIndices[i],s=this.m_bunchEdgeEndPoints[a],c=this.m_bunchEdgeEndPoints[o],l=this.m_shape.getNextVertex(s),u=!1;this.m_shape.isEqualXYPoint2D(l,e)||(l=this.m_shape.getPrevVertex(s),u=!0);let d=this.m_shape.getNextVertex(c),f=!1;this.m_shape.isEqualXYPoint2D(d,e)||(d=this.m_shape.getPrevVertex(c),f=!0);let p=u?this.m_shape.getPrevVertex(l):this.m_shape.getNextVertex(l),m=f?this.m_shape.getPrevVertex(d):this.m_shape.getNextVertex(d),h=!1;(this.removeSpike_(l)||this.removeSpike_(d)||this.removeSpike_(s)||this.removeSpike_(c)||this.removeSpike_(p)||this.removeSpike_(m))&&(h=!0),l!==d&&(!h&&this.m_shape.isEqualXY(s,c)&&(h=this.resolveOverlap_(u,f,l,s,d,c)),!h&&this.m_shape.isEqualXY(p,m)&&(h=this.resolveOverlap_(!u,!f,l,p,d,m)),!h&&this.m_shape.isEqualXY(s,m)&&(h=this.resolveOverlap_(u,!f,l,s,d,m)),!h&&this.m_shape.isEqualXY(p,c)&&(h=this.resolveOverlap_(!u,f,l,p,d,c))),h&&(t=!0),n||=h,r=h?this.getNextEdgeIndex_(r):i,i=this.getNextEdgeIndex_(r)}}if(!t){let n=0;this.m_bunchEdgeIndices[n]===-1&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,a=this.m_bunchEdgeIndices.length;i<a&&n!==-1&&r!==-1&&n!==r;i++){let i=this.m_bunchEdgeIndices[n],a=this.m_bunchEdgeIndices[r],o=this.m_bunchEdgeEndPoints[i],s=this.m_bunchEdgeEndPoints[a],c=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(c,e)||(c=this.m_shape.getPrevVertex(o));let l=this.m_shape.getNextVertex(s);this.m_shape.isEqualXYPoint2D(l,e)||(l=this.m_shape.getPrevVertex(s));let u=this.getDirection_(c,o),d=this.getDirection_(l,s),f=u?this.m_shape.getPrevVertex(c):this.m_shape.getNextVertex(c),p=d?this.m_shape.getPrevVertex(l):this.m_shape.getNextVertex(l),m=this.detectAndResolveCrossOver_(u,d,o,c,f,s,l,p);if(m===1){t=!0;continue}m===0?(n=this.getNextEdgeIndex_(n),r=this.getNextEdgeIndex_(n)):(n=this.getPrevEdgeIndex_(n),r=this.getNextEdgeIndex_(n))}}return t}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===i.enumPolygon&&this.m_shape.getFillRule(this.m_geometry)===1&&new Xs(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();let t=this.m_shape.getPointCount(this.m_geometry),n=new Re(0);this.m_shape.dbgVerifyMonotone();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==z;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let r=0,i=this.m_shape.getPathSize(e);r<i;r++)this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1),n.add(t),t=this.m_shape.getNextVertex(t)}this.m_shape.sortVerticesSimpleByY(n,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let e=0;e<t;e++){let t=n.read(e),r=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,t);this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,r)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let r=0,a=!1;do{a=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);let t=new U(0,0);this.m_firstCoincidentVertex!==Fe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let n=0,i=this.m_firstCoincidentVertex;for(;i!==Fe.st_nullNode()&&(i=this.m_sortedVertices.getNext(i),i!==Fe.st_nullNode());){this.progress_();let e=this.m_sortedVertices.getData(i),r=U.getNAN();if(this.m_shape.queryXY(e,r),t.equals(r)){n++;continue}if(n>0){this.m_nextVertexToProcess=i;let e=this.processBunch_();i=this.m_nextVertexToProcess,i!==Fe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(i),r),e&&(a=!0)}t.setCoordsPoint2D(r),this.m_firstCoincidentVertex=i,n=0}this.m_nextVertexToProcess=-1,n>0&&this.processBunch_()&&(a=!0),r++>10&&o(``),a&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(a=!0),e||=a}while(a);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=Zr(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,n,r,i,a,o,s){if(r===o)return this.removeAngleSortInfo_(n),this.removeAngleSortInfo_(a),-1;let c=this.m_shape.getUserIndex(n,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),u=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),d=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),f=H(8,NaN),p=H(4,NaN);f[0]=0,p[0]=c,f[1]=0,p[1]=l,f[2]=1,p[2]=u,f[3]=1,p[3]=d;for(let e=1;e<4;e++){let t=p[e],n=f[e],r=e-1;for(;r>=0&&p[r]>t;)p[r+1]=p[r],f[r+1]=f[r],r--;p[r+1]=t,f[r+1]=n}let m=0;if(f[0]&&(m|=1),f[1]&&(m|=2),f[2]&&(m|=4),f[3]&&(m|=8),m!==5&&m!==10)return 0;if(e!==t&&(s=gt(a,a=s)),e)this.m_shape.setNextVertex(s,r),this.m_shape.setPrevVertex(r,s),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(s,r),this.m_shape.setNextVertex(r,s),this.m_shape.setPrevVertex(i,o),this.m_shape.setNextVertex(o,i),this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(r),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(r,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){let e=this.m_shape.getVertexIndex(r),t=this.m_shape.getVertexIndex(o),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);let i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}}return 1}resolveOverlap_(e,t,n,r,i,a){return this.resolveOverlapOddEven_(e,t,n,r,i,a)}resolveOverlapOddEven_(e,t,n,r,i,a){if(e!==t){e||(i=gt(n,n=i),a=gt(r,r=a));let t=this.m_shape.getNextVertex(i),o=this.m_shape.getNextVertex(n);if(this.m_shape.setNextVertex(n,t),this.m_shape.setPrevVertex(t,n),this.m_shape.setNextVertex(i,o),this.m_shape.setPrevVertex(o,i),this.m_bHasSegments){let e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(i),r=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);let a=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,a),this.m_shape.setSegmentToIndex(t,r)}if(this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(i);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(i,e,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(a,!0)}this.removeSpike_(i)}else{let o=e?n:r,s=t?i:a,c=e?r:n,l=t?a:i,u=null;if(this.m_bHasSegments){let e=this.m_shape.getVertexIndex(l);u=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);let t=this.m_shape.getVertexIndex(s);this.m_shape.setSegmentToIndex(t,null);let n=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(n,null)}let d=-1;this.m_bHasSegmentParentage&&(d=this.m_shape.getSegmentParentage(l));let f=!1;this.m_shape.setNextVertex(o,s),this.m_shape.setNextVertex(s,o),this.m_shape.setPrevVertex(c,l),this.m_shape.setPrevVertex(l,c);let p=l;for(;p!==s;){let e=this.m_shape.getPrevVertex(p),t=this.m_shape.getNextVertex(p);if(this.m_shape.setPrevVertex(p,t),this.m_shape.setNextVertex(p,e),f||=p===o,this.m_bHasSegments&&p!==o){let e=this.m_shape.getVertexIndex(t),n=u;u=this.m_shape.getSegmentFromIndex(e),n!==null&&n.reverse(),this.m_shape.setSegmentToIndex(e,n)}if(this.m_bHasSegmentParentage){let e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,d),d=e}p=t}let m=null;if(!f){let e=this.m_shape.getPrevVertex(s),t=this.m_shape.getNextVertex(s);if(this.m_shape.setPrevVertex(s,t),this.m_shape.setNextVertex(s,e),this.m_bHasSegments){let e=this.m_shape.getVertexIndex(s);m=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let h=-1,g=-1;if(this.m_bHasSegmentParentage&&(h=f?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(s),g=this.m_shape.getSegmentParentage(c)),this.transferVertexData_(s,o),this.beforeRemoveVertex_(s,!0),this.m_shape.removeVertexInternal(s,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(l,c),this.beforeRemoveVertex_(l,!0),this.m_shape.removeVertexInternal(l,!0),this.removeAngleSortInfo_(c),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,h,!0),this.m_shape.setSegmentParentageAndBreak(c,g,!0)),m){let e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,m)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==z;){let n=this.m_shape.getNextPath(t),r=this.m_shape.getFirstVertex(t);for(let n=0,i=this.m_shape.getPathSize(t);n<i&&i>1;){this.progress_();let{v:a,bModified:o}=this.checkAndCleanupSpike_(t,r);if(a===z)break;o?(e=!0,r=a,n=0,i=this.m_shape.getPathSize(t)):(r=a,n++)}t=n}return e}checkAndCleanupSpike_(e,t){let n={v:z,bModified:!1},r=this.m_shape.getPrevVertex(t),i=this.m_shape.getNextVertex(t),a=z,o=z;for(;this.m_shape.isEqualXY(r,i)&&(a=r,o=i,i!==t);)r=this.m_shape.getPrevVertex(r),i=this.m_shape.getNextVertex(i);if(a===z)return n.v=i,n;n.bModified=!0;for(let e=this.m_shape.getNextVertex(a);this.beforeRemoveVertex_(e,!1),e!==o;e=this.m_shape.getNextVertex(e));if(a!==t){let e=this.m_shape.peelALoopIntoAPath(a,o);this.m_polylineDegeneracies===z?this.m_shape.removePath(e):this.m_shape.movePath(this.m_polylineDegeneracies,z,e)}else return this.m_polylineDegeneracies===z?this.m_shape.removePath(e):this.m_shape.movePath(this.m_polylineDegeneracies,z,e),n.v=z,n;return n.v=a,n}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),n=this.m_shape.getNextVertex(e),r=z,i=z;for(;this.m_shape.isEqualXY(t,n)&&(r=t,i=n,n!==e);)t=this.m_shape.getPrevVertex(t),n=this.m_shape.getNextVertex(n);if(r===z)return!1;if(this.m_shape.peelALoop(r,i),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)),this.removeAngleSortInfo_(r),this.m_polylineDegeneracies===z)for(let e=this.m_shape.getNextVertex(i);;){let t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(e),null),this.m_shape.removeVertexInternal(e,!1),e===i)break;e=t}else{for(let e=i;;){let t=this.m_shape.getNextVertex(e);if(this.removeAngleSortInfo_(e),this.beforeRemoveVertex_(e,!1),e=t,e===i)break}this.m_shape.insertClosedPath(this.m_polylineDegeneracies,z,i,i,[!1])}return!0}fixOrphanVertices_(){let e=0;for(let e=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());e!==-1;e=this.m_sortedVertices.getNext(e)){let t=this.m_sortedVertices.getData(e);this.m_shape.setPathToVertex(t,z)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==z;){let r=this.m_shape.getFirstVertex(n);if(r===z||this.m_shape.getPathFromVertex(r)!==z){let e=n;n=this.m_shape.getNextPath(n),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(r,n);let i=1;for(let e=this.m_shape.getNextVertex(r);e!==r;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,n),i++;this.m_shape.setRingAreaValid(n,!1),this.m_shape.setPathSize(n,i),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(r)),t+=i,e++,n=this.m_shape.getNextPath(n)}for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());n!==-1;n=this.m_sortedVertices.getNext(n)){let r=this.m_sortedVertices.getData(n);if(this.m_shape.getPathFromVertex(r)!==z)continue;let i=this.m_shape.insertClosedPath(this.m_geometry,z,r,r,[!1]);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let n=0;for(let e=this.m_shape.getFirstGeometry();e!==z;e=this.m_shape.getNextGeometry(e))n+=this.m_shape.getPointCount(e);this.m_shape.setTotalPointCount(n)}getNextEdgeIndex_(e){if(e===-1)return-1;for(let t=0,n=this.m_bunchEdgeIndices.length-1;t<n;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,this.m_bunchEdgeIndices[e]!==-1)return e;return-1}getPrevEdgeIndex_(e){if(e===-1)return-1;for(let t=0,n=this.m_bunchEdgeIndices.length-1;t<n;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,this.m_bunchEdgeIndices[e]!==-1)return e;return-1}transferVertexData_(e,t){let n=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),r=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,n),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,r)}removeAngleSortInfo_(e){let t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);t!==-1&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function ai(e,t,r,a,o,s=!0){switch(ci(a)){case 0:break;case 1:n(`relation string length has to be 9 characters`);break;default:n(`relation string`)}if(s){let n=xi(a,e.getDimension(),t.getDimension());if(n!==0)return Ri(e,t,r,n,o)}let c=0;if(typeof r==`number`)c=r;else{let n=T.constructEmpty();e.queryEnvelope(n);let i=T.constructEmpty();t.queryEnvelope(i);let a=T.constructEmpty();a.setCoords({env2D:n}),a.mergeEnvelope2D(i),c=Oe(r,a,!1)}let l=Mi(e,c),u=Mi(t,c);if(l.isEmpty()||u.isEmpty())return bi(l,u,a);let d=l.getGeometryType(),f=u.getGeometryType(),p=!1;switch(d){case i.enumPolygon:switch(f){case i.enumPolygon:p=li(l,u,c,a,o);break;case i.enumPolyline:p=ui(l,u,c,a,o);break;case i.enumPoint:p=hi(l,u,c,a);break;case i.enumMultiPoint:p=di(l,u,c,a,o)}break;case i.enumPolyline:switch(f){case i.enumPolygon:p=ui(u,l,c,Ni(a),o);break;case i.enumPolyline:p=fi(l,u,c,a,o);break;case i.enumPoint:p=gi(l,u,c,a,o);break;case i.enumMultiPoint:p=pi(l,u,c,a,o)}break;case i.enumPoint:switch(f){case i.enumPolygon:p=hi(u,l,c,Ni(a));break;case i.enumPolyline:p=gi(u,l,c,Ni(a),o);break;case i.enumPoint:p=vi(l,u,c,a);break;case i.enumMultiPoint:p=_i(u,l,c,Ni(a))}break;case i.enumMultiPoint:switch(f){case i.enumPolygon:p=di(u,l,c,Ni(a),o);break;case i.enumPolyline:p=pi(u,l,c,Ni(a),o);break;case i.enumMultiPoint:p=mi(l,u,c,a,o);break;case i.enumPoint:p=_i(l,u,c,a)}break;default:p=!1}return p}function oi(e,t,n,r){let i=new Ai;i.resetMatrix_(),i.setPredicates_(`T*****F**`),i.setAreaAreaPredicates_();let a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(o);let s=!1;if(Hi(a,o,n)&&(i.areaAreaDisjointPredicates_(e,t),s=!0),s||X(e,t),s)return yi(i.m_matrix,i.m_scl);let c=new N,l=c.addGeometry(e),u=c.addGeometry(t),d=null,f=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){d=new _s;let e=ms(n,c.getEnvelope2D(r));f=gs(e,0),ss(c,e,n,12e3,d,null,r)}ys(c,new Ne(n,0).add(f),r,!1,!1);let p=c.getGeometry(u).getBoundary();if(c.filterClosePoints(0,!0,!0,!1,z),ri(c,l,-1,!1,z,r),c.getPointCount(l)===0)return!1;ri(c,u,-1,!1,z,r),i.setEditShape_(c,r);let m=c.getPointCount(u)===0;if(!m){i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape();let e=yi(i.m_matrix,i.m_scl);if(!e)return e}let h=c.getGeometry(l);return c=new N,l=c.addGeometry(h),u=c.addGeometry(p),i.setEditShape_(c,r),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(m?`T*****F**`:`******F**`),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape(),yi(i.m_matrix,i.m_scl)}function si(e,t,n,r){let i=new Ai;i.resetMatrix_(),i.setPredicates_(`T*****F**`),i.setAreaLinePredicates_();let a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(o);let s=!1;if(Hi(a,o,n)&&(i.areaLineDisjointPredicates_(e,t),s=!0),s||X(e,t),s)return yi(i.m_matrix,i.m_scl);let c=new N,l=c.addGeometry(e),u=c.addGeometry(t);return i.setEditShapeCrackAndCluster_(c,new Ne(n,0),r),c.getPointCount(l)!==0&&(i.computeMatrixTopoGraphHalfEdges_(l,u),i.m_topoGraph.removeShape(),yi(i.m_matrix,i.m_scl))}function ci(e){if(e.length!==9)return 1;for(let t=0;t<9;t++){let n=e[t];if(n!==`*`&&n!==`T`&&n!==`F`&&n!==`0`&&n!==`1`&&n!==`2`)return 2}return 0}function li(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaAreaPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaAreaDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function ui(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaLinePredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaLineDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexB=a.m_topoGraph.createUserIndexForClusters(),ki(s,a.m_topoGraph,a.m_clusterIndexB),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexB),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function di(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaPointPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.areaPointDisjointPredicates_(e),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function fi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLineLinePredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.lineLineDisjointPredicates_(e,t),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexA=a.m_topoGraph.createUserIndexForClusters(),a.m_clusterIndexB=a.m_topoGraph.createUserIndexForClusters(),ki(o,a.m_topoGraph,a.m_clusterIndexA),ki(s,a.m_topoGraph,a.m_clusterIndexB),a.computeMatrixTopoGraphHalfEdges_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexA),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexB),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function pi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLinePointPredicates_();let o=T.constructEmpty(),s=T.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.linePointDisjointPredicates_(e),c=!0),c||X(e,t),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.m_clusterIndexA=a.m_topoGraph.createUserIndexForClusters(),ki(o,a.m_topoGraph,a.m_clusterIndexA),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.deleteUserIndexForClusters(a.m_clusterIndexA),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function mi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setPointPointPredicates_();let o=new T,s=new T;e.queryEnvelope(o),t.queryEnvelope(s);let c=!1;if(Hi(o,s,n)&&(a.pointPointDisjointPredicates_(),c=!0),!c){let r=new N,o=r.addGeometry(e),s=r.addGeometry(t);a.setEditShapeCrackAndCluster_(r,new Ne(n,0),i),a.computeMatrixTopoGraphClusters_(o,s),a.m_topoGraph.removeShape()}return yi(a.m_matrix,a.m_scl)}function hi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setAreaPointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=!1;if(Ui(s,o,n)&&(a.areaPointDisjointPredicates_(e),c=!0),!c){let t=qo(e,s,n);if(t===1)a.m_matrix[0]=0,a.m_matrix[2]=2,a.m_matrix[3]=-1,a.m_matrix[5]=1,a.m_matrix[6]=-1;else if(t===2){if(a.m_matrix[6]=-1,e.calculateArea2D()!==0)a.m_matrix[0]=-1,a.m_matrix[3]=0,a.m_matrix[2]=2,a.m_matrix[5]=1;else{a.m_matrix[0]=0,a.m_matrix[3]=-1,a.m_matrix[5]=-1;let t=T.constructEmpty();e.queryEnvelope(t),a.m_matrix[2]=!t.height()&&!t.width()?-1:1}}else a.areaPointDisjointPredicates_(e)}return yi(a.m_matrix,r)}function gi(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setLinePointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=!1;if(Ui(s,o,n)&&(a.linePointDisjointPredicates_(e),c=!0),!c){let r=null,o=!1,s=!1;if((a.m_performPredicates[0]||a.m_performPredicates[6])&&(Ri(e,t,n,4,i)?(a.m_matrix[0]=-1,a.m_matrix[6]=0):(a.m_performPredicates[0]&&(r=P(e),s=!Ri(r,t,n,4,i),o=!0,s?a.m_matrix[0]=-1:a.m_matrix[0]=0),a.m_matrix[6]=-1)),a.m_performPredicates[3]&&(r!==null&&r.isEmpty()?a.m_matrix[3]=-1:(o||=(r??=P(e),s=!Ri(r,t,n,4,i),!0),a.m_matrix[3]=s?0:-1)),a.m_performPredicates[5]){if(r!==null&&r.isEmpty())a.m_matrix[5]=-1;else if(o&&!s)a.m_matrix[5]=0;else{r===null&&(r=P(e));let o=Ri(r,t,n,3,i);a.m_matrix[5]=o?-1:0}}if(a.m_performPredicates[2]){if(e.calculateLength2D()!==0)a.m_matrix[2]=1;else{let r=new A({vd:e.getDescription()});r.addPoints(e,0,e.getPointCount());let o=Ri(r,t,n,3,i);a.m_matrix[2]=o?-1:0}}}return yi(a.m_matrix,a.m_scl)}function _i(e,t,n,r,i){let a=new Ai;a.resetMatrix_(),a.setPredicates_(r),a.setPointPointPredicates_();let o=T.constructEmpty();e.queryEnvelope(o);let s=t.getXY(),c=new U,l=!1;if(Ui(s,o,n)&&(a.pointPointDisjointPredicates_(),l=!0),!l){let t=!1,r=!0,i=n*n;for(let n=0;n<e.getPointCount()&&(e.queryXY(n,c),U.sqrDistance(c,s)<=i?t=!0:r=!1,!t||r);n++);t?(a.m_matrix[0]=0,r?a.m_matrix[2]=-1:a.m_matrix[2]=0,a.m_matrix[6]=-1):(a.m_matrix[0]=-1,a.m_matrix[2]=0,a.m_matrix[6]=0)}return yi(a.m_matrix,r)}function vi(e,t,n,r,i){let a=e.getXY(),o=t.getXY(),s=H(9,-1);return U.sqrDistance(a,o)<=n*n?s[0]=0:(s[2]=0,s[6]=0),s[8]=2,yi(s,r)}function yi(e,t){for(let n=0;n<9;n++)switch(t[n]){case`T`:if(e[n]===-1)return!1;break;case`F`:if(e[n]!==-1)return!1;break;case`0`:if(e[n]!==0)return!1;break;case`1`:if(e[n]!==1)return!1;break;case`2`:if(e[n]!==2)return!1}return!0}function bi(e,t,n){let r=H(9,-1);if(e.isEmpty()&&t.isEmpty())return yi(r,n);let a=!1,o;e.isEmpty()?(o=t,a=!0):o=e,r[0]=-1,r[1]=-1,r[3]=-1,r[4]=-1,r[6]=-1,r[7]=-1,r[8]=2;let c=o.getGeometryType();if(s(c)){if(c===i.enumPolygon){if(o.calculateArea2D()!==0)r[2]=2,r[5]=1;else{r[5]=-1;let e=T.constructEmpty();o.queryEnvelope(e),r[2]=!e.height()&&!e.width()?0:1}}else r[2]=+(o.calculateLength2D()!==0),r[5]=M(o)?0:-1}else r[2]=0,r[5]=-1;return a&&ji(r),yi(r,n)}function xi(e,t,n){return Si(e)?3:Ci(e)?4:wi(e,t,n)?8:Ti(e,t,n)?16:Di(e)?64:Ei(e)?1:Oi(e,t,n)?32:0}function Si(e){return e===`T*F**FFF*`}function Ci(e){return e===`FF*FF****`}function wi(e,t,n){return t===0&&n===0?!1:t===2&&n===2?e===`F***T****`:(t===2||t===1)&&n===0&&e===`F**T*****`}function Ti(e,t,n){return t>n?e===`T*****T**`:t===1&&n===1&&e===`0********`}function Ei(e){return e===`T*****FF*`}function Di(e){return e===`T**FF*FF*`}function Oi(e,t,n){return t===n?t===1?e===`1*T***T**`:e===`T*T***T**`:!1}function ki(e,t,n){let r=t.getGeometryID(e);for(let e=t.getFirstCluster();e!==z;e=t.getNextCluster(e)){if((t.getClusterParentage(e)&r)===0)continue;let i=t.getClusterHalfEdge(e);if(i===z){t.setClusterUserIndex(e,n,0);continue}let a=i,o=0;do{let e=a;(t.getHalfEdgeParentage(e)&r)!==0&&o++,a=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(a!==i);t.setClusterUserIndex(e,n,o)}}class Ai{m_clusterIndexA=-1;m_clusterIndexB=-1;m_visitedIndex=-1;m_topoGraph=new sr;m_matrix=H(9,0);m_maxDim=H(9,0);m_performPredicates=H(9,!1);m_scl=``;m_predicateCount=0;nullFunc(){return o(`should not be called`),!1}m_predicatesHalfEdge=this.nullFunc;m_predicatesCluster=this.nullFunc;constructor(){}resetMatrix_(){this.m_matrix.fill(-2),this.m_maxDim.fill(-2)}setPredicates_(e){this.m_scl=e;for(let e=0;e<9;e++)this.m_scl[e]===`*`?this.m_performPredicates[e]=!1:(this.m_performPredicates[e]=!0,this.m_predicateCount++)}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&this.m_matrix[e]===-2&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return this.m_matrix[e]===-2?!1:this.m_matrix[e]===-1?(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):this.m_scl[e]!==`T`&&this.m_scl[e]!==`F`&&this.m_matrix[e]<this.m_maxDim[e]?!1:(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0)}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,n,r,i){let a=t!==-1,o=r!==-1;if(a||o){if(!(n!==`T`&&n!==`F`&&a||i!==`T`&&i!==`F`&&o)||e.calculateArea2D()!==0)a&&(this.m_matrix[t]=2),o&&(this.m_matrix[r]=1);else if(o&&(this.m_matrix[r]=-1),a){let n=T.constructEmpty();e.queryEnvelope(n),this.m_matrix[t]=!n.height()&&!n.width()?0:1}}}areaAreaContainsPredicates_(e){this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(e){this.areaAreaContainsPredicates_(e),ji(this.m_matrix)}areaLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){let e=this.m_scl[6],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[6]=+!!n}this.m_performPredicates[7]&&(M(t)?this.m_matrix[7]=0:this.m_matrix[7]=-1),this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){let e=this.m_scl[0],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[0]=+!!n}this.m_performPredicates[1]&&(M(t)?this.m_matrix[1]=0:this.m_matrix[1]=-1),this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){let t=this.m_scl[2],n=t!==`T`&&t!==`F`?e.calculateLength2D()!==0:!0;this.m_matrix[2]=+!!n}if(this.m_performPredicates[5]&&(M(e)?this.m_matrix[5]=0:this.m_matrix[5]=-1),this.m_performPredicates[6]){let e=this.m_scl[6],n=e!==`T`&&e!==`F`?t.calculateLength2D()!==0:!0;this.m_matrix[6]=+!!n}this.m_performPredicates[7]&&(M(t)?this.m_matrix[7]=0:this.m_matrix[7]=-1)}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){let t=this.m_scl[2],n=t!==`T`&&t!==`F`?e.calculateLength2D()!==0:!0;this.m_matrix[2]=+!!n}if(this.m_performPredicates[5]){let t=M(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);let n=this.isPredicateKnown_(1);r&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,n,3);let t=this.isPredicateKnown_(3);r&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,n);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,n,5);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,n,t,7);let i=this.isPredicateKnown_(7);r&&=i}return r}areaLinePredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(1);r&&=i}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,n);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,n);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);let n=this.isPredicateKnown_(6);r&&=n}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,n,this.m_clusterIndexB);let i=this.isPredicateKnown_(7);r&&=i}return r}lineLinePredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB,1);let i=this.isPredicateKnown_(1);r&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,n,t,this.m_clusterIndexB,this.m_clusterIndexA,3);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,n,this.m_clusterIndexA,this.m_clusterIndexB);let i=this.isPredicateKnown_(4);r&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,n,this.m_clusterIndexA,5);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,n,t,this.m_clusterIndexB,7);let i=this.isPredicateKnown_(7);r&&=i}return r}areaPointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);let n=this.isPredicateKnown_(0);r&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);let n=this.isPredicateKnown_(2);r&&=n}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);let n=this.isPredicateKnown_(5);r&&=n}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);let n=this.isPredicateKnown_(6);r&&=n}return r}linePointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(3);r&&=i}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,n,this.m_clusterIndexA);let i=this.isPredicateKnown_(5);r&&=i}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(6);r&&=i}return r}pointPointPredicates_(e,t,n){let r=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,n);let i=this.isPredicateKnown_(0);r&&=i}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,n,2);let i=this.isPredicateKnown_(2);r&&=i}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,n,t,6);let i=this.isPredicateKnown_(6);r&&=i}return r}interiorAreaInteriorArea_(e,t,n){if(this.m_matrix[0]===2)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e);(r&t)!==0&&(r&n)!==0&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,n){if(this.m_matrix[n]===1)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(r&t)!==0&&(i&t)!==0&&(this.m_matrix[n]=1)}interiorAreaExteriorArea_(e,t,n,r){if(this.m_matrix[r]===2)return;let i=this.m_topoGraph.getHalfEdgeFaceParentage(e);(i&t)!==0&&(i&n)===0&&(this.m_matrix[r]=2)}boundaryAreaBoundaryArea_(e,t,n){if(this.m_matrix[4]===1)return;let r=this.m_topoGraph.getHalfEdgeParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[4]=1;return}if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if((i&t)!==0&&(i&n)!==0){this.m_matrix[4]=0;return}}}boundaryAreaExteriorArea_(e,t,n,r){if(this.m_matrix[r]===1)return;let i=this.m_topoGraph.getHalfEdgeFaceParentage(e),a=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(i&n)===0&&(a&n)===0&&(this.m_matrix[r]=1)}interiorAreaInteriorLine_(e,t,n){if(this.m_matrix[0]===1)return;let r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(r&t)!==0&&(i&t)!==0&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[1]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)===0&&(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[1]=0;return}}}}interiorAreaExteriorLine_(e,t,n){this.m_matrix[2]!==2&&(this.m_topoGraph.getHalfEdgeParentage(e)&t)!==0&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,n,r){if(this.m_matrix[3]===1)return;let i=this.m_topoGraph.getHalfEdgeParentage(e);if((i&t)!==0&&(i&n)!==0){this.m_matrix[3]=1;return}if(this.m_matrix[3]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2==0){this.m_matrix[3]=0;return}}}}boundaryAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)!==0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[4]=0;return}}}}boundaryAreaExteriorLine_(e,t,n){if(this.m_matrix[5]===1)return;let r=this.m_topoGraph.getHalfEdgeParentage(e);(r&t)!==0&&(r&n)===0&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(this.m_matrix[6]===1)return;let n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));(n&t)===0&&(r&t)===0&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,n,r){if(this.m_matrix[7]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let i=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(i);if((a&t)===0&&(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)===0){let e=this.m_topoGraph.getClusterUserIndex(i,r);if((a&n)!==0&&e%2!=0){this.m_matrix[7]=0;return}}}}interiorLineInteriorLine_(e,t,n,r,i){if(this.m_matrix[0]===1)return;let a=this.m_topoGraph.getHalfEdgeParentage(e);if((a&t)!==0&&(a&n)!==0){this.m_matrix[0]=1;return}if(this.m_matrix[0]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let a=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(a);if((o&t)!==0&&(o&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(a,r),t=this.m_topoGraph.getClusterUserIndex(a,i);if(e%2==0&&t%2==0){this.m_matrix[0]=0;return}}}}interiorLineBoundaryLine_(e,t,n,r,i,a){if(this.m_matrix[a]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let o=this.m_topoGraph.getHalfEdgeTo(e),s=this.m_topoGraph.getClusterParentage(o);if((s&t)!==0&&(s&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(o,r),t=this.m_topoGraph.getClusterUserIndex(o,i);if(e%2==0&&t%2!=0){this.m_matrix[a]=0;return}}}}interiorLineExteriorLine_(e,t,n,r){if(this.m_matrix[r]===1)return;let i=this.m_topoGraph.getHalfEdgeParentage(e);(i&t)!==0&&(i&n)===0&&(this.m_matrix[r]=1)}boundaryLineBoundaryLine_(e,t,n,r,i){if(this.m_matrix[4]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let a=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(a);if((o&t)!==0&&(o&n)!==0){let e=this.m_topoGraph.getClusterUserIndex(a,r),t=this.m_topoGraph.getClusterUserIndex(a,i);if(e%2!=0&&t%2!=0){this.m_matrix[4]=0;return}}}}boundaryLineExteriorLine_(e,t,n,r,i){if(this.m_matrix[i]!==0&&this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)!==1){let t=this.m_topoGraph.getHalfEdgeTo(e);if((this.m_topoGraph.getClusterParentage(t)&n)===0&&this.m_topoGraph.getClusterUserIndex(t,r)%2!=0){this.m_matrix[i]=0;return}}}interiorAreaInteriorPoint_(e,t){if(this.m_matrix[0]!==0&&(this.m_topoGraph.getClusterParentage(e)&t)===0){let n=this.m_topoGraph.getClusterChain(e);if((this.m_topoGraph.getChainParentage(n)&t)!==0){this.m_matrix[0]=0;return}}}interiorAreaExteriorPoint_(e,t){this.m_matrix[2]!==2&&(this.m_topoGraph.getClusterParentage(e)&t)!==0&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,n){if(this.m_matrix[3]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[3]=0;return}}boundaryAreaExteriorPoint_(e,t){this.m_matrix[5]!==1&&(this.m_topoGraph.getClusterParentage(e)&t)!==0&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(this.m_matrix[6]!==0&&(this.m_topoGraph.getClusterParentage(e)&t)===0){let n=this.m_topoGraph.getClusterChain(e);if((this.m_topoGraph.getChainParentage(n)&t)===0){this.m_matrix[6]=0;return}}}interiorLineInteriorPoint_(e,t,n,r){if(this.m_matrix[0]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)!==0&&this.m_topoGraph.getClusterUserIndex(e,r)%2==0){this.m_matrix[0]=0;return}}interiorLineExteriorPoint_(e,t,n,r){if(this.m_matrix[2]!==1){if(this.m_topoGraph.getClusterHalfEdge(e)!==-1){this.m_matrix[2]=1;return}if(this.m_matrix[2]!==0&&(this.m_topoGraph.getClusterParentage(e)&n)===0){this.m_matrix[2]=0;return}}}boundaryLineInteriorPoint_(e,t,n,r){if(this.m_matrix[3]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)!==0&&this.m_topoGraph.getClusterUserIndex(e,r)%2!=0){this.m_matrix[3]=0;return}}boundaryLineExteriorPoint_(e,t,n,r){if(this.m_matrix[5]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)===0&&this.m_topoGraph.getClusterUserIndex(e,r)%2!=0){this.m_matrix[5]=0;return}}exteriorLineInteriorPoint_(e,t,n){if(this.m_matrix[6]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)===0&&(r&n)!==0){this.m_matrix[6]=0;return}}interiorPointInteriorPoint_(e,t,n){if(this.m_matrix[0]===0)return;let r=this.m_topoGraph.getClusterParentage(e);if((r&t)!==0&&(r&n)!==0){this.m_matrix[0]=0;return}}interiorPointExteriorPoint_(e,t,n,r){if(this.m_matrix[r]===0)return;let i=this.m_topoGraph.getClusterParentage(e);if((i&t)!==0&&(i&n)===0){this.m_matrix[r]=0;return}}computeMatrixTopoGraphHalfEdges_(e,t){let n=!1,r=this.m_topoGraph.getGeometryID(e),i=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z){if(this.m_predicatesCluster!==null&&(n=this.m_predicatesCluster(e,r,i),n))break;continue}let a=t;do{let e=a;if(this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex)!==1)do{if(n=this.m_predicatesHalfEdge(e,r,i),n)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==a&&!n);if(n)break;a=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(a!==t);if(n)break}n||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let n=!1,r=this.m_topoGraph.getGeometryID(e),i=this.m_topoGraph.getGeometryID(t);for(let e=this.m_topoGraph.getFirstCluster();e!==z&&(n=this.m_predicatesCluster(e,r,i),!n);e=this.m_topoGraph.getNextCluster(e));n||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,n){let r=0;if(e.hasCurves()){let i=new _s,a=e.getEnvelope2D(n),o=ms(t.total(),a);r=gs(o,0),ss(e,o,t.total(),12e3,i,null,n),i.clearStitcher(e)}ys(e,t.add(r),n,!1,!1),e.filterClosePoints(0,!0,!0,!1,z);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,!1,z,n);this.setEditShape_(e,n)}}function ji(e){let t=e[1],n=e[2],r=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=n,e[7]=r}function Mi(e,t,n){let r=e.getGeometryType();if(a(r)){let t=new E({vd:e.getDescription()});return t.addSegment(e,!0),t}if(r===i.enumEnvelope){let n=e,r=T.constructEmpty();if(e.queryEnvelope(r),r.height()<=t&&r.width()<=t){let t=new B({vd:e.getDescription()});return n.getCenter(t),t}if(r.height()<=t||r.width()<=t){let t=new E({vd:e.getDescription()}),r=new B;return n.queryCornerByVal(0,r),t.startPathPoint(r),n.queryCornerByVal(2,r),t.lineToPoint(r),t}let i=new k({vd:e.getDescription()});return i.addEnvelope(n,!1),i}return e}function Ni(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Pi{m_multiVertexImplA;m_multiVertexImplB;m_queryType;m_bPaths;m_bQuadTree;m_bDone=!1;m_bSwapElements;m_tolerance=0;m_pathIndex;m_pointIndex;m_elementHandle=-1;m_query=T.constructEmpty();m_envInter=T.constructEmpty();m_quadTree=null;m_qtIter;m_segIter;m_function;m_intersector=null;nullFunc(){return o(`should not be called`),!1}constructor(e,t,n,r=!1){this.m_function=this.nullFunc;let i=e.getAccelerators(),a=null;i!=null&&(a=r?i.getQuadTreeForPaths():i.getQuadTree());let o=t.getAccelerators(),c=null;if(o!=null&&(c=r?o.getQuadTreeForPaths():o.getQuadTree()),a===null&&c===null&&!r){let r=e.getPointCount(),i=t.getPointCount();if(r>10&&i>10){let o=T.constructEmpty(),l=T.constructEmpty(),u=T.constructEmpty();e.queryLooseEnvelope(o),t.queryLooseEnvelope(l),o.inflateCoords(n,n),l.inflateCoords(n,n),u.setCoords({env2D:o}),u.intersect(l),r>=i?a=s(e.getGeometryType())?qe(e,u):Je(e,u):c=s(t.getGeometryType())?qe(t,u):Je(t,u)}}this.construct_(e,a,t,c,n,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():!1}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):s(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?s(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||y(``),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||y(``),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(e,t,n,r,a,o){let c=T.constructEmpty(),l=T.constructEmpty();e.queryLooseEnvelope(c),n.queryLooseEnvelope(l),c.inflateCoords(a,a),l.inflateCoords(a,a),this.m_envInter.setCoords({env2D:c}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;let u=e.getGeometryType(),d=n.getGeometryType();this.m_bPaths=o,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.enumUnknown,this.m_bQuadTree=!1,t!==null&&(this.m_bDone=!1,this.m_tolerance=a,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,s(d)?(this.m_queryType=d,this.m_function=this.nextPath_,o?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=d,this.m_function=this.nextPoint_,this.m_pointIndex=n.getPointCount())),this.m_bQuadTree||r!==null&&(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,s(u)?(this.m_queryType=u,this.m_function=this.nextPath_,o?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(!o||!s(u)||!s(d)?s(u)&&s(d)?(this.m_intersector=Ye(e,n,a),this.m_bSwapElements=!1):s(u)&&!s(d)?(this.m_intersector=Xe(e,n,a),this.m_bSwapElements=!1):!s(u)&&s(d)?(this.m_intersector=Xe(n,e,a),this.m_bSwapElements=!0):(this.m_intersector=Ze(e,n,a),this.m_bSwapElements=!1):this.m_intersector=Qe(e,n,a))}nextPath_(){return this.m_bPaths?--this.m_pathIndex===-1?(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;let e=this.m_segIter.nextSegment(),t=new T;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(--this.m_pointIndex===-1)return this.m_bDone=!0,!1;let e=new U;if(this.m_bSwapElements){let t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{let t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(T.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),this.m_elementHandle===-1?s(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0):!1}}function Fi(e){return e===2?1:e===1?2:e===128?64:e===64?128:e}function Ii(e,t,n){let r;if(e instanceof rp||e===null){let i=T.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(n),r=Oe(e,i,!1)}else r=e;return r}function Li(e,t,n){let r;if(e instanceof rp||e===null){let i=T.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(n),r=Oe(e,i,!1)}else r=e;return r}function Ri(e,t,n,o,s){if(e.isEmpty()||t.isEmpty())return o===4;r(e),r(t);let c=e.getGeometryType(),l=t.getGeometryType();if(c===i.enumEnvelope){if(l===i.enumEnvelope)return zi(e,t,n,o);if(l===i.enumPoint)return Bi(t,e,n,Fi(o))}else if(c===i.enumPoint){if(l===i.enumEnvelope)return Bi(e,t,n,o);if(l===i.enumPoint)return Vi(e,t,n,o)}let u=T.constructEmpty();e.queryEnvelope(u);let d=T.constructEmpty();t.queryEnvelope(d);let f=Li(n,u,d);if(Hi(u,d,f))return o===4;let p=!1,m=null,h=null,g=null,_=null;switch(a(c)?(m=new E({vd:e.getDescription()}),m.addSegment(e,!0),g=m,c=i.enumPolyline):g=e,a(l)?(h=new E({vd:t.getDescription()}),h.addSegment(t,!0),_=h,l=i.enumPolyline):_=t,c!==i.enumEnvelope&&l!==i.enumEnvelope?(g.getDimension()<_.getDimension()||c===i.enumPoint&&l===i.enumMultiPoint)&&(o=Fi(o)):c!==i.enumPolygon&&l!==i.enumEnvelope&&(o=Fi(o)),c){case i.enumPolygon:switch(l){case i.enumPolygon:p=Wi(g,_,f,o,s);break;case i.enumPolyline:p=Gi(g,_,f,o,s);break;case i.enumPoint:p=Ki(g,_,f,o);break;case i.enumMultiPoint:p=qi(g,_,f,o);break;case i.enumEnvelope:p=Ji(g,_,f,o,s)}break;case i.enumPolyline:switch(l){case i.enumPolygon:p=Gi(_,g,f,o,s);break;case i.enumPolyline:p=Yi(g,_,f,o,s);break;case i.enumPoint:p=Xi(g,_,f,o);break;case i.enumMultiPoint:p=Zi(g,_,f,o);break;case i.enumEnvelope:p=Qi(g,_,f,o,s)}break;case i.enumPoint:switch(l){case i.enumPolygon:p=Ki(_,g,f,o);break;case i.enumPolyline:p=Xi(_,g,f,o);break;case i.enumMultiPoint:p=ea(_,g,f,o)}break;case i.enumMultiPoint:switch(l){case i.enumPolygon:p=qi(_,g,f,o);break;case i.enumPolyline:p=Zi(_,g,f,o);break;case i.enumMultiPoint:p=$i(g,_,f,o);break;case i.enumPoint:p=ea(g,_,f,o);break;case i.enumEnvelope:p=ta(g,_,f,o)}break;case i.enumEnvelope:switch(l){case i.enumPolygon:p=Ji(_,g,f,o,s);break;case i.enumPolyline:p=Qi(_,g,f,o,s);break;case i.enumMultiPoint:p=ta(_,g,f,o)}}return p}function zi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=T.constructEmpty();e.queryEnvelope(a);let o=T.constructEmpty();t.queryEnvelope(o);let s=Li(n,a,o);switch(r){case 4:return Hi(a,o,s);case 2:return mo(o,a,s,!1);case 128:return mo(o,a,s,!0);case 1:return mo(a,o,s,!1);case 64:return mo(a,o,s,!0);case 3:return uo(a,o,s);case 8:return fo(a,o,s);case 32:return po(a,o,s);case 16:return!1}return!1}function Bi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=e.getXY(),o=T.constructEmpty();t.queryEnvelope(o);let s=Ii(n,a,o);switch(r){case 4:return Ui(a,o,s);case 2:case 128:return lo(a,o,s);case 1:case 64:return!1;case 3:return so(a,o,s);case 8:return co(a,o,s)}return!1}function Vi(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return r===4;let a=e.getXY(),o=t.getXY(),s;if(n instanceof rp||n===null){let e=T.constructEmpty();e.setCoords({pt:a}),e.merge(o),s=Oe(n,e,!1)}else s=n;switch(r){case 4:return ao(a,o,s);case 2:case 128:return oo(o,a,s);case 1:case 64:return oo(a,o,s);case 3:return io(a,o,s)}return!1}function Hi(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!e.isIntersecting(r)}function X(e,t,n,r=!1){let i=e.getGeometryType(),a=t.getGeometryType();do if(f(i)){let t=e.getImpl().getAccelerators();if(t!==null){let e=t.getRasterizedGeometry();l(e===null)}}while(0);do if(f(a)){let e=t.getImpl().getAccelerators();if(e!==null){let t=e.getRasterizedGeometry();l(t===null)}}while(0);return 0}function Ui(e,t,n,r){let i=T.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(n,n),!i.contains(e)}function Wi(e,t,n,r,i){switch(r){case 4:return ra(e,t,n);case 2:return oa(t,e,n,i);case 128:return sa(t,e,n);case 1:return oa(e,t,n,i);case 64:return sa(e,t,n);case 3:return na(e,t,n,i);case 8:return ia(e,t,n);case 32:return aa(e,t,n,i)}return!1}function Gi(e,t,n,r,i){switch(r){case 4:return ca(e,t,n);case 1:return da(e,t,n,i);case 64:return fa(e,t,n);case 8:return la(e,t,n,i);case 16:return ua(e,t,n)}return!1}function Ki(e,t,n,r,i){switch(r){case 4:return pa(e,t,n);case 1:case 64:return ha(e,t,n);case 8:return ma(e,t,n)}return!1}function qi(e,t,n,r,i){switch(r){case 4:return ga(e,t,n);case 1:return ya(e,t,n,!1);case 64:return ya(e,t,n,!0);case 8:return _a(e,t,n);case 16:return va(e,t,n)}return!1}function Ji(e,t,n,r,i){if(xa(e,t,n))return r===4;if(r===4)return!1;switch(r){case 2:return wa(e,t,n,!1);case 128:return wa(e,t,n,!0);case 1:return Ta(e,t,n,!1,i);case 64:return Ta(e,t,n,!0,i);case 3:return ba(e,t,n,i);case 8:return Sa(e,t,n,i);case 32:return Ca(e,t,n,i);case 16:return!1}return!1}function Yi(e,t,n,r,i){switch(r){case 4:return Da(e,t,n);case 2:return ja(t,e,n,i);case 128:return Ma(t,e,n,i);case 1:return ja(e,t,n,i);case 64:return Ma(e,t,n,i);case 3:return Ea(e,t,n,i);case 8:return Oa(e,t,n,i);case 32:return Aa(e,t,n,i);case 16:return ka(e,t,n,i)}return!1}function Xi(e,t,n,r,i){switch(r){case 4:return Na(e,t,n);case 1:case 64:return Fa(e,t,n);case 8:return Pa(e,t,n)}return!1}function Zi(e,t,n,r,i){switch(r){case 4:return Ia(e,t,n);case 1:case 64:return za(e,t,n);case 8:return La(e,t,n);case 16:return Ra(e,t,n)}return!1}function Qi(e,t,n,r,i){if(Va(e,t,n))return r===4;if(r===4)return!1;switch(r){case 2:return Ua(e,t,n,!1);case 128:return Ua(e,t,n,!0);case 1:case 64:return!1;case 3:return Ba(e,t,n);case 8:return Ha(e,t,n,i);case 32:return!1;case 16:return Wa(e,t,n)}return!1}function $i(e,t,n,r,i){switch(r){case 4:return Ka(e,t,n);case 2:case 128:return Ja(t,e,n);case 1:case 64:return Ja(e,t,n);case 3:return Ga(e,t,n);case 32:return qa(e,t,n)}return!1}function ea(e,t,n,r,i){switch(r){case 4:return Xa(e,t,n);case 2:case 128:return Za(e,t,n);case 1:case 64:return Qa(e,t,n);case 3:return Ya(e,t,n)}return!1}function ta(e,t,n,r,i){switch(r){case 4:return eo(e,t,n);case 2:return no(e,t,n,!1);case 128:return no(e,t,n,!0);case 1:case 64:return!1;case 3:return $a(e,t,n);case 8:return to(e,t,n);case 16:return ro(e,t,n)}return!1}function na(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(a),!uo(i,a,n))return!1;if(X(e,t),xo(e,t,n))return!0;let o=e.calculateLength2D(),s=t.calculateLength2D(),c=Math.max(e.getPointCount(),t.getPointCount());return Math.abs(o-s)>c*4*n?!1:e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`**F**FFF*`,r,!1):wo(e,t,n,!0)}function ra(e,t,n,r){return X(e,t,n,!0),ho(e,t,n,!0)===1}function ia(e,t,n,r){return X(e,t),Mo(e,t,n,null)}function aa(e,t,n,r){return X(e,t),No(e,t,n,r)}function oa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),Po(e,t,n,r)):!1}function sa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ho(e,t,n,!1)===2):!1}function ca(e,t,n,r){return X(e,t,n,!0),ho(e,t,n,!0)===1}function la(e,t,n,r){return X(e,t),Fo(e,t,n,r)}function ua(e,t,n,r){return X(e,t),Io(e,t,n,null)}function da(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),Lo(e,t,n,r)):!1}function fa(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ho(e,t,n,!1)===2):!1}function pa(e,t,n,r){return Ko(e,t,n)===0}function ma(e,t,n,r){return zo(e,t.getXY(),n)}function ha(e,t,n,r){return Ro(e,t.getXY(),n)}function ga(e,t,n,r,i){return X(e,t),go(e,t,n)===1}function _a(e,t,n,r){X(e,t);let i=T.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);let a=new U,o=!1,s=e.getImpl(),c=new k,l=e,u=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,a),i.contains(a)){let e=qo(l,a,n);if(e===2)o=!0;else if(e===1)return!1}u||=(Xr(e,t.getPointCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()===null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),l=c):l=e,!0)}return!!o}function va(e,t,n,r){X(e,t);let i=new T,a=new T,o=new T;e.queryEnvelope(i),t.queryEnvelope(o),a.setCoords({env2D:i}),a.inflateCoords(n,n);let s=!1,c=!1,l=new U,u=e.getImpl(),d=new k,f=e,p=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,l),!a.contains(l))c=!0;else{let e=qo(f,l,n);e===0?c=!0:e===1&&(s=!0)}if(s&&c)return!0;p||=(Xr(e,t.getPointCount()-1)&&(u.getAccelerators()===null||u.getAccelerators().getQuadTree()===null)?(e.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),f=d):f=e,!0)}return!1}function ya(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=!1,c=new U,l=e.getImpl(),u=new k,d=e,f=!1;for(let i=0;i<t.getPointCount();i++){if(t.queryXY(i,c),!a.contains(c))return!1;let o=qo(d,c,n);if(o===1)s=!0;else if(o===0)return!1;if(r&&o===2)return!1;f||=(Xr(e,t.getPointCount()-1)&&(l.getAccelerators()===null||l.getAccelerators().getQuadTree()===null)?(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),d=u):d=e,!0)}return s}function ba(e,t,n,r){let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),!uo(i,a,n))return!1;let o=new k;return o.addEnvelope(t,!1),na(e,o,n,r)}function xa(e,t,n,r){X(e,t);let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||qo(e,a.getLowerLeft(),0)!==0||a.contains(e.getXY(0))?!1:!jo(e,a,n)}function Sa(e,t,n,r){X(e,t);let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new k;return o.addEnvelope(t,!1),Mo(e,o,n,r)}function Ca(e,t,n,r){X(e,t);let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new k;return o.addEnvelope(t,!1),No(e,o,n,r)}function wa(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();return e.queryEnvelope(a),t.queryEnvelope(o),r?yo(o,a,n):vo(o,a,n)}function Ta(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=new k;return s.addEnvelope(t,!1),r?ho(e,s,n,!1)===2:Po(e,s,n,i)}function Ea(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)?(X(e,t),xo(e,t,n)?!0:e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`**F**FFF*`,r,!1):wo(e,t,n,!1)):!1}function Da(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl();return!new Pi(i,a,n,!0).next()||!Eo(e,t,n)}function Oa(e,t,n,r){X(e,t);let i=[],a=Do(e,t,n,i);if(a===-2){let i=T.constructEmpty(),a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a),i.inflateCoords(1e3*n,1e3*n),a.inflateCoords(1e3*n,1e3*n),o.setCoords({env2D:i}),o.intersect(a);let s,c;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(c=q(t,o,n,0,r),c.isEmpty())return!1}else c=t;return ai(s,c,n,`F********`,r,!1)}if(a!==0)return!1;let o=new A;for(let e=0;e<i.length;e+=2){let t=i[e],n=i[e+1];o.addXY(t,n)}let s=e.getBoundary(),c=t.getBoundary();return s.addPoints(c,0,c.getPointCount()),!s.isEmpty()&&Ja(s,o,n)}function ka(e,t,n,r){X(e,t);let i=[],a=Do(e,t,n,i);if(a===-2){let i=T.constructEmpty(),a=T.constructEmpty(),o=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a),i.inflateCoords(1e3*n,1e3*n),a.inflateCoords(1e3*n,1e3*n),o.setCoords({env2D:i}),o.intersect(a);let s,c;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(c=q(t,o,n,0,r),c.isEmpty())return!1}else c=t;return ai(s,c,n,`0********`,r,!1)}if(a!==0)return!1;let o=new A;for(let e=0;e<i.length;e+=2){let t=i[e],n=i[e+1];o.addXY(t,n)}let s=e.getBoundary(),c=t.getBoundary();return s.addPoints(c,0,c.getPointCount()),s.isEmpty()?!0:!Ja(s,o,n)}function Aa(e,t,n,r){X(e,t);let i=T.constructEmpty(),a=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a);let o=bo(i,a,n),s=bo(a,i,n),c=e.hasNonLinearSegments(),l=t.hasNonLinearSegments(),u=Do(e,t,n,null);if(u===-1)return!1;if(u===1){if(o&&s)return!0;if(!c&&!l)return o&&!s?!To(t,e,n,!1):s&&!o?!To(e,t,n,!1):!To(e,t,n,!1)&&!To(t,e,n,!1)}let d=T.constructEmpty(),f=T.constructEmpty(),p=T.constructEmpty();d.setCoords({env2D:i}),d.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:a}),f.inflateCoords(1e3*n,1e3*n),p.setCoords({env2D:d}),p.intersect(f);let m,h,g=``;if(g+=`1*`,o){if(t.getPointCount()>10){if(h=q(t,p,n,0,r),h.isEmpty())return!1}else h=t;g+=`****`}else h=t,g+=`T***`;if(s){if(e.getPointCount()>10){if(m=q(e,p,n,0,r),m.isEmpty())return!1}else m=e;g+=`***`}else m=e,g+=`T**`;return ai(m,h,n,g,r,!1)}function ja(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()?ai(e,t,n,`******FF*`,r,!1):To(t,e,n,!1)):!1}function Ma(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?(X(e,t),ai(e,t,n,`T**FF*FF*`,r,!1)):!1}function Na(e,t,n,r){return X(e,t),!ko(e,t.getXY(),n)}function Pa(e,t,n,r){return X(e,t),Vo(e,t.getXY(),n)}function Fa(e,t,n,r){return X(e,t),Ao(e,t.getXY(),n)}function Ia(e,t,n,r){return X(e,t),!Oo(e,t,n,!1)}function La(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl(),o=new A,s=new Pi(i,a,n,!1),c=i.querySegmentIterator(),l=!1;for(;s.next();){let e=s.getRedElement(),t=s.getBlueElement();c.resetToVertex(e,-1);let r=c.nextSegment(),i=a.getXY(t);r.isIntersectingPoint(i,n)&&(l=!0,o.addPoint2D(i))}if(!l)return!1;let u=e.getBoundary();return!u.isEmpty()&&Ja(u,o,n)}function Ra(e,t,n,r){X(e,t);let i=e.getImpl(),a=t.getImpl(),o=a.getPointCount(),s=H(o,!1),c=new Pi(i,a,n,!1),l=i.querySegmentIterator(),u=!1;for(;c.next();){let e=c.getRedElement(),t=c.getBlueElement();l.resetToVertex(e,-1);let r=l.nextSegment(),i=a.getXY(t);r.isIntersectingPoint(i,n)&&(u=!0,s[t]=!0)}if(!u)return!1;let d=!1;for(let e=0;e<o;e++)if(!s[e]){d=!0;break}if(!d)return!1;let f=e.getBoundary();if(f.isEmpty())return!0;let p=new A;for(let e=0;e<o;e++)s[e]&&p.addPoint2D(a.getXY(e));return!Ja(f,p,n)}function za(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),!vo(a,o,n))return!1;X(e,t);let s=Oo(e,t,n,!0);if(!s)return s;let c=e.getBoundary();return c.isEmpty()?s:!Ja(c,t,n)}function Ba(e,t,n,r){let i=new T,a=new T;return e.queryEnvelope(i),t.queryEnvelope(a),a.height()>n&&a.width()>n?!1:uo(i,a,n)}function Va(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(a);let o=Ho(a,i,n);return o===0?!jo(e,a,n):o===4}function Ha(e,t,n,r){let a=new T,s=new T;if(e.queryEnvelope(a),t.queryEnvelope(s),s.height()<=n||s.width()<=n)return!1;let c=new T,l=new T;if(c.setCoords({env2D:s}),l.setCoords({env2D:s}),c.inflateCoords(n,n),l.inflateCoords(-n,-n),l.containsEnvelope(a)||!a.isIntersecting(c))return!1;let u=e.getImpl().querySegmentIterator();u.stripAttributes();let d=e.getImpl().getAccelerators(),f=null,p=null;d!==null&&(f=d.getQuadTree(),f!==null&&(p=f.getIterator(s,n))),p||u.nextPath()||o(`relational_operations`);let m=!1,h=null,g=new U,_=new U,v=e.hasNonLinearSegments(),y=!1;for(;;){if(p!==null){let e=p.next();if(e===-1)break;u.resetToVertex(f.getElement(e),-1),h=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;h=u.nextSegment()}if(!v||h.getGeometryType()===i.enumLine){g.assign(h.getStartXY()),_.assign(h.getEndXY());let e=l.clipLine(g,_);if(e!==0)return!1;m||(e=c.clipLine(g,_),e!==0&&(m=!0))}else{let e=new T;if(h.queryEnvelope(e),l.containsEnvelope(e))return!1;if(c.isIntersecting(e)){y=!0;break}}}if(!y)return m;let b=new k;return b.addEnvelope(s,!1),la(b,e,n,r)}function Ua(e,t,n,r,a){let s=T.constructEmpty(),c=T.constructEmpty();if(e.queryEnvelope(s),t.queryEnvelope(c),c.height()<=n||c.width()<=n)return!1;if(r)return yo(c,s,n);if(!vo(c,s,n))return!1;let l=T.constructEmpty();l.setCoords({env2D:c}),l.inflateCoords(-n,-n);let u=T.constructEmpty();if(u.setCoords({env2D:c}),u.inflateCoords(n,n),l.containsEnvelope(s))return!0;let d=e.getImpl().querySegmentIterator();d.stripAttributes(),d.nextPath()||o(`relational_operations`);let f=!1,p,m,h,g,_,v,y=e.hasNonLinearSegments();for(y&&(h=new I,g=new I,_=new I,v=new I,l.querySide(0,h),l.querySide(1,g),l.querySide(2,_),l.querySide(3,v));;){for(;!d.hasNextSegment()&&d.nextPath(););if(!d.hasNextSegment())break;let e=d.nextSegment();if(!y||e.getGeometryType()===i.enumLine){if(p=e.getStartXY(),m=e.getEndXY(),l.clipLine(p,m)!==0){f=!0;break}}else{if(e.isIntersecting(h,n)){f=!0;break}if(e.isIntersecting(g,n)){f=!0;break}if(e.isIntersecting(_,n)){f=!0;break}if(e.isIntersecting(v,n)){f=!0;break}}}return f}function Wa(e,t,n,r){let a=new T,o=new T;if(e.queryEnvelope(a),t.queryEnvelope(o),o.height()<=n||o.width()<=n)return!1;let s=new T;if(s.setCoords({env2D:o}),s.inflateCoords(n,n),s.containsEnvelope(a))return!1;let c=new T;if(c.setCoords({env2D:o}),c.inflateCoords(-n,-n),!c.isIntersecting(a))return!1;let u=e.getImpl().querySegmentIterator();u.stripAttributes();let d=e.getImpl().getAccelerators(),f=null,p=null;if(d!==null&&(f=d.getQuadTree(),f!==null&&(p=f.getIterator(o,n))),!p){let e=u.nextPath();l(e)}let m=!1,h=null,g=new U,_=new U,v=e.hasNonLinearSegments(),y=null,b=null,x=null,S=null;for(v&&(y=new I,b=new I,x=new I,S=new I,c.querySide(0,y),c.querySide(1,b),c.querySide(2,x),c.querySide(3,S));;){if(p!==null){let e=p.next();if(e===-1)break;u.resetToVertex(f.getElement(e),-1),h=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;h=u.nextSegment()}if(h.getGeometryType()===i.enumLine){if(g.assign(h.getStartXY()),_.assign(h.getEndXY()),c.clipLine(g,_)!==0){m=!0;break}}else{if(y.isIntersecting(h,n)){m=!0;break}if(b.isIntersecting(h,n)){m=!0;break}if(x.isIntersecting(h,n)){m=!0;break}if(S.isIntersecting(h,n)){m=!0;break}}}return m&&!0}function Ga(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)?So(e,t,n)?!0:Co(e,t,n,!1,!0,!1):!1}function Ka(e,t,n,r){let i=e,a=t,o=new Pi(i,a,n,!1),s=n*n,c=new U,l=new U;for(;o.next();){let e=o.getRedElement(),t=o.getBlueElement();if(i.queryXY(e,c),a.queryXY(t,l),U.sqrDistance(c,l)<=s)return!1}return!0}function qa(e,t,n,r){return Co(e,t,n,!1,!1,!0)}function Ja(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),vo(i,a,n)?Co(t,e,n,!0,!1,!1):!1}function Ya(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(a),uo(i,a,n)}function Xa(e,t,n,r){return Bo(e,t.getXY(),n)}function Za(e,t,n,r){return Ya(e,t,n)}function Qa(e,t,n,r){return!Xa(e,t,n)}function $a(e,t,n,r){let i=new T,a=new T;return e.queryEnvelope(i),t.queryEnvelope(a),a.height()>n||a.width()>n?!1:uo(i,a,n)}function eo(e,t,n,r){let i=T.constructEmpty(),a=T.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n))return!1;let o=T.constructEmpty();o.setCoords({env2D:a}),o.inflateCoords(n,n);let s=new U;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,s),o.contains(s))return!1;return!0}function to(e,t,n,r){let i=new T,a=new T,o=new T;if(t.queryEnvelope(i),i.height()<=n||i.width()<=n)return!1;a.setCoords({env2D:i}),o.setCoords({env2D:i}),a.inflateCoords(n,n),o.inflateCoords(-n,-n);let s=new U,c=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,s),a.contains(s)){if(o.containsExclusive(s))return!1;c=!0}return c}function no(e,t,n,r,i){let a=T.constructEmpty(),o=T.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(o),o.height()<=n||o.width()<=n)return!1;if(r)return yo(o,a,n);if(!vo(o,a,n))return!1;let s=!1,c=T.constructEmpty(),l=T.constructEmpty();c.setCoords({env2D:o}),l.setCoords({env2D:o}),c.inflateCoords(-n,-n),l.inflateCoords(n,n);let u=new U;for(let t=0;t<e.getPointCount();t++){if(e.queryXY(t,u),!l.contains(u))return!1;c.containsExclusive(u)&&(s=!0)}return s}function ro(e,t,n,r){let i=new T,a=new T;if(e.queryEnvelope(i),t.queryEnvelope(a),vo(a,i,n)||a.height()<=n||a.width()<=n)return!1;let o=new T,s=new T;o.setCoords({env2D:a}),o.inflateCoords(-n,-n),s.setCoords({env2D:a}),s.inflateCoords(n,n);let c=new U,l=!1,u=!1;for(let t=0;t<e.getPointCount();t++)if(e.queryXY(t,c),!l&&o.containsExclusive(c)&&(l=!0),!u&&!s.contains(c)&&(u=!0),l&&u)return!0;return!1}function io(e,t,n,r){return U.sqrDistance(e,t)<=n*n}function ao(e,t,n,r){return U.sqrDistance(e,t)>n*n}function oo(e,t,n,r){return io(e,t,n)}function so(e,t,n,r){let i=new T;return i.setCoords({pt:e}),uo(i,t,n)}function co(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;let i=new T,a=new T;return i.setCoords({env2D:t}),i.inflateCoords(n,n),!(!i.contains(e)||(a.setCoords({env2D:t}),a.inflateCoords(-n,-n),a.containsExclusive(e)))}function lo(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;let i=T.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(-n,-n),i.containsExclusive(e)}function uo(e,t,n,r){return vo(e,t,n)&&vo(t,e,n)}function fo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;let i=new T;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&i.height()>n&&i.width()>n?!1:(i.setCoords({env2D:e}),i.inflateCoords(n,n),i.intersect(t),!i.isEmpty())}function po(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n||vo(e,t,n)||vo(t,e,n))return!1;let i=new T;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&(i.height()>n||i.width()>n)}function mo(e,t,n,r,i){if(e.height()<=n||e.width()<=n)return!1;if(r)return yo(e,t,n);if(!vo(e,t,n))return!1;let a=T.constructEmpty();return a.setCoords({env2D:e}),a.inflateCoords(-n,-n),a.intersect(t),!a.isEmpty()}function ho(e,t,n,r,a){let o=new U,s=new U,c=T.constructEmpty(),l=T.constructEmpty(),u=e.getImpl(),d=t.getImpl(),f=d.getGeometryType(),p=new Pi(u,d,n,!0);if(!p.next())return 1;if(Eo(e,t,n))return r?4:0;let m=new k,h=e,g=new k,_=null;f===i.enumPolygon&&(_=t);let v=f===i.enumPolygon?H(u.getPathCount(),!1):[],y=H(d.getPathCount(),!1),b=!1,x=!1,S=!1,C=!1,w=!1,E=!1;do{if(S&&w||C&&E||S&&C)break;let a=p.getRedElement(),T=p.getBlueElement();if(!y[T]&&(s.assign(t.getXY(t.getPathStart(T))),c.setCoords({env2D:p.getRedEnvelope()}),c.inflateCoords(n,n),c.contains(s))){if(qo(h,s,0)!==0){if(C=!0,r)return 4}else E=!0;y[T]=!0}if(f===i.enumPolygon&&!v[a]&&(o.assign(e.getXY(e.getPathStart(a))),l.setCoords({env2D:p.getBlueEnvelope()}),l.inflateCoords(n,n),l.contains(o))){if(qo(_,o,0)!==0){if(S=!0,r)return 4}else w=!0;v[a]=!0}if(b||=(Xr(e,t.getPathCount()-1)&&(u.getAccelerators()===null||u.getAccelerators().getQuadTree()===null)?(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m):h=e,!0),f===i.enumPolygon&&!x){let n=t;Xr(n,e.getPathCount()-1)&&(d.getAccelerators()===null||d.getAccelerators().getQuadTree()===null)?(n.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),_=g):_=t,x=!0}}while(p.next());if(!S&&!C)return 1;if(!w||!E){if(f===i.enumPolygon){for(let e=0,t=u.getPathCount();e<t;e++)if(!v[e]){w=!0;break}}for(let e=0,t=d.getPathCount();e<t;e++)if(!y[e]){E=!0;break}}return S&&w||C&&E||S&&C?4:C?2:3}function go(e,t,n,r,i){let a=T.constructEmpty();e.queryEnvelope(a),a.inflateCoords(n,n);let o=new U,s=e.getImpl(),c=new k,l=e,u=!1,d=!1,f=!1;for(let r=0;r<t.getPointCount();r++){if(t.queryXY(r,o),a.contains(o)){let e=qo(l,o,n);if(e===1)return d=!0,4;if(e===2)return 4;f=!0}else f=!0;u||=(Xr(e,t.getPointCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()==null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),l=c):l=e,!0)}return d?f?4:2:1}function _o(e,t,n,r,a){r[0]=!1;let o=e.getImpl(),s=t.getImpl(),c=o.querySegmentIterator(),u=s.querySegmentIterator(),d=[0,0],f=[0,0],p=new Pi(o,s,n),m=!1;for(;p.next();){let e=p.getRedElement(),t=p.getBlueElement();c.resetToVertex(e,-1),u.resetToVertex(t,-1);let i=c.nextSegment(),a=u.nextSegment(),o=0;if(Uo(i,a)?!m&&a.isIntersecting(i,n)&&(m=!0):o=a.intersect(i,null,f,d,n),o!==0&&(m=!0,o===1)){let e=d[0],t=f[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!m){r[0]=!0;let a=T.constructEmpty();e.queryEnvelope(a),a.inflateCoords(n,n);let c=new k,u=e,d=!1;for(let n=0,r=t.getPathCount();n<r;n++)if(t.getPathSize(n)>0){let r=T.constructEmpty();if(t.queryPathEnvelope(n,r),a.isIntersecting(r)){let e=t.getXY(t.getPathStart(n)),r=Yr(u,e,0);if(l(r!==-1),r===0)return!1}else return!1;d||=(Xr(e,t.getPathCount()-1)&&(o.getAccelerators()===null||o.getAccelerators().getQuadTree()===null)?(e.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),u=c):u=e,!0)}if(e.getPathCount()===1||t.getGeometryType()===i.enumPolyline)return!0;let f=t,p=T.constructEmpty();f.queryEnvelope(p),p.inflateCoords(n,n);let m=new k,h=f,g=!1;for(let t=0,n=e.getPathCount();t<n;t++)if(e.getPathSize(t)>0){let n=T.constructEmpty();if(e.queryPathEnvelope(t,n),p.isIntersecting(n)){let n=e.getXY(e.getPathStart(t)),r=Yr(h,n,0);if(l(r!==-1),r===1)return!1}g||=(Xr(f,e.getPathCount()-1)&&(s.getAccelerators()===null||s.getAccelerators().getQuadTree()===null)?(f.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m):h=f,!0)}return!0}return!1}function vo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)}function yo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),e.containsExclusiveEnvelope(r)}function bo(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!r.contains(e.getLowerLeft())||!r.contains(e.getLowerRight())||!r.contains(e.getUpperLeft())||!r.contains(e.getUpperRight())}function xo(e,t,n,r){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);let i=new U,a=new U,o=!0,s=n*n;for(let n=0;n<e.getPathCount();n++){if(e.getPathEnd(n)!==t.getPathEnd(n)){o=!1;break}for(let r=e.getPathStart(n);r<t.getPathEnd(n);r++)if(e.queryXY(r,i),t.queryXY(r,a),U.sqrDistance(i,a)>s){o=!1;break}if(!o)break}return!!o}function So(e,t,n,r){if(e.getPointCount()!==t.getPointCount())return!1;let i=new U,a=new U,o=!0,s=n*n;for(let n=0;n<e.getPointCount();n++)if(e.queryXY(n,i),t.queryXY(n,a),U.sqrDistance(i,a)>s){o=!1;break}return!!o}function Co(e,t,n,r,i,a,o){let s=e.getImpl(),c=t.getImpl(),l=s.getPointCount(),u=c.getPointCount(),d=H(l,!1),f=i||a?H(u,!1):[],p=n*n,m=new Pi(s,c,n);for(;m.next();){let e=m.getRedElement(),t=m.getBlueElement(),n=s.getXY(e),r=c.getXY(t);U.sqrDistance(n,r)<=p&&(d[e]=!0,(i||a)&&(f[t]=!0))}let h=!1,g=!1;for(let e=0;e<l;e++){let t=d[e];if(h||=!t,g||=t,(i||r)&&h)return!1}if(r)return!0;let _=!1,v=!1;for(let e=0;e<u;e++){let t=f[e];if(_||=!t,v||=t,i&&_)return!1}return i?!0:h&&g&&_&&v}function wo(e,t,n,r){return To(e,t,n,r)&&To(t,e,n,r)}function To(e,t,n,r){if(S(e),S(t),t.isEmpty())return!1;let i=!0,a=H(2,NaN),s=H(2,NaN),c=[],l=new Go,u,d=T.constructEmpty(),f=T.constructEmpty(),p=T.constructEmpty();e.queryEnvelope(d),t.queryEnvelope(f),d.inflateCoords(n,n),f.inflateCoords(n,n),p.setCoords({env2D:d}),p.intersect(f);let m=e.getImpl().querySegmentIterator(),h=t.getImpl().querySegmentIterator(),g=t.getImpl().getAccelerators(),_=null,v=null,y=null,b=null;if(g!==null&&(_=g.getQuadTree(),v=g.getQuadTreeForPaths(),v!==null&&(b=v.getIteratorForQT())),_===null){let n=e.getPointCount(),r=t.getPointCount();n>10&&r>10&&(_=qe(t.getImpl(),p))}for(_!==null&&(y=_.getIteratorForQT());m.nextPath();)for(;m.hasNextSegment();){let e=m.nextSegment();if(e.queryEnvelope(d),!d.isIntersecting(p))return i=!1,!1;if(b!==null&&(b.resetIterator(d,n),b.next()===-1))continue;let t=0,g=null;if(y!=null)y.resetIterator(e,n);else if(h.resetToFirstPath(),!h.nextPath())return i=!1,!1;do if(t=0,y!==null){let r=y.next();if(r===-1)return i=!1,!1;h.resetToVertex(_.getElement(r),-1),g=h.nextSegment(),t=e.intersect(g,null,a,s,n)}else{for(;!h.hasNextSegment();)if(!h.nextPath())return i=!1,!1;g=h.nextSegment(),g.queryEnvelope(f),f.inflateCoords(n,n),d.isIntersecting(f)&&(t=e.intersect(g,null,a,s,n))}while(!(t===2&&a[0]===0&&(!r||s[0]<=s[1])));let v=NaN,x=!1;do{let r=!1;if(a[1]===1){if(!m.hasNextSegment()){x=!0;break}e=m.nextSegment(),r=!0}if(s[1]===1&&s[0]<=s[1]){if(v===-1||(v=1,!h.hasNextSegment()))break;g=h.nextSegment(),r=!0}if(s[1]===0&&s[0]>s[1]){if(v===1)break;if(Number.isNaN(v)){if(!h.hasPreviousSegment())break;h.previousSegment(),v=-1}if(!h.hasPreviousSegment())break;g=h.previousSegment(),r=!0}if(!r)break;t=e.intersect(g,null,a,s,n)}while(t===2&&(!r||s[0]<=s[1]));if(x)continue;let S=e.calculateLength2D();e.queryEnvelope(d),c.length=0,l.m_overlapEvents.length=0;let C=!1,w=!1,T=0,E=Oe(null,d,!0);for(y===null?(h.resetToFirstPath(),h.nextPath()||o(`relational_operations`)):y.resetIterator(e,n);;){if(t=0,y!==null){let r=y.next();if(r===-1)break;h.resetToVertex(_.getElement(r),-1),g=h.nextSegment(),t=e.intersect(g,null,a,s,n)}else{for(;!h.hasNextSegment()&&h.nextPath(););if(!h.hasNextSegment())break;g=h.nextSegment(),g.queryEnvelope(f),f.inflateCoords(n,n),d.isIntersecting(f)&&(t=e.intersect(g,null,a,s,n))}if(t===2&&(!r||s[0]<=s[1])){let e=m.getStartPointIndex(),t=m.getPathIndex(),r=h.getStartPointIndex(),i=h.getPathIndex();if(u=Wo(e,t,a[0],a[1],r,i,s[0],s[1]),l.m_overlapEvents.push(u),c.push(c.length),!C&&!(u.m_scalarA0<T&&u.m_scalarA1<T)){if(T===0&&S*(u.m_scalarA0-T)>n)C=!0;else if(T!==0&&S*(u.m_scalarA0-T)>E)C=!0;else if(T=u.m_scalarA1,S*(1-T)<=n||T===1){w=!0;break}}}}if(!w){if(!C)return i=!1,!1;c.length>1&&c.sort((e,t)=>l.compareOverlapEvents(e,t)),T=0;for(let e=0;e<l.m_overlapEvents.length;e++)if(u=l.m_overlapEvents[c[e]],!(u.m_scalarA0<T&&u.m_scalarA1<T)){if(T===0&&S*(u.m_scalarA0-T)>n||T!==0&&S*(u.m_scalarA0-T)>E)return i=!1,!1;if(T=u.m_scalarA1,S*(1-T)<=n||T===1)break}if(S*(1-T)>n)return i=!1,!1;c.length=0,l.m_overlapEvents.length=0}}return i}function Eo(e,t,n){let r=e.getImpl(),i=t.getImpl(),a=r.querySegmentIterator(),o=i.querySegmentIterator(),s=new Pi(r,i,n);for(;s.next();){let e=s.getRedElement(),t=s.getBlueElement();a.resetToVertex(e,-1),o.resetToVertex(t,-1);let r=a.nextSegment();if(o.nextSegment().isIntersecting(r,n))return!0}return!1}function Do(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=new Pi(i,a,n),u=!1,d=-1;for(;l.next();){let e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let i=o.nextSegment(),a=s.nextSegment(),f=0;if(Uo(i,a)){if(a.isIntersecting(i,n))return-2}else f=i.intersect(a,null,c,null,n);if(f){if(f===2){let e=i.calculateLength2D(),t=c[0];if(e*(c[1]-t)>n)return d=1,d;u=!0}else if(d=0,r){let e=c[0],t=new U;i.queryCoord2D(e,t),r.push(t.x),r.push(t.y)}}}return u?-2:d}function Oo(e,t,n,r){let i=e.getImpl(),a=t,o=a.getPointCount(),s=r?H(o,!1):[],c=new Pi(i,a,n,!1),l=i.querySegmentIterator();for(;c.next();){let e=c.getRedElement(),t=c.getBlueElement();l.resetToVertex(e,-1);let i=l.nextSegment(),o=a.getXY(t);if(i.isIntersectingPoint(o,n)){if(!r)return!0;s[t]=!0}}if(!r)return!1;for(let e=0;e<o;e++)if(!s[e])return!1;return!0}function ko(e,t,n){let r=new U,i=n*n,a=e.querySegmentIterator(),o=e.getImpl().getAccelerators();if(o!==null){let e=o.getQuadTree();if(e!==null){let o=T.constructEmpty();o.setCoords({pt:t});let s=e.getIterator(o,n);for(let n=s.next();n!==-1;n=s.next())if(a.resetToVertex(e.getElement(n),-1),a.hasNextSegment()){let e=a.nextSegment(),n=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(n,r),U.sqrDistance(t,r)<=i)return!0}return!1}}let s=T.constructEmpty();for(;a.nextPath();)for(;a.hasNextSegment();){let e=a.nextSegment();if(e.queryEnvelope(s),s.inflateCoords(n,n),!s.contains(t))continue;let o=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(o,r),U.sqrDistance(t,r)<=i)return!0}return!1}function Ao(e,t,n){return ko(e,t,n)&&!Vo(e,t,n)}function jo(e,t,n,r){let a=e.querySegmentIterator(),o=e.getImpl().getAccelerators(),s=e.hasNonLinearSegments(),c=null,l=null,u=null,d=null;if(o!==null){let e=o.getQuadTree();if(e!==null){let r=e.getIterator(t,n);s&&(c=new I,l=new I,u=new I,d=new I,t.querySide(0,c),t.querySide(1,l),t.querySide(2,u),t.querySide(3,d));let o=T.constructEmpty();o.setCoords({env2D:t}),o.inflateCoords(n,n);for(let s=r.next();s!==-1;s=r.next())if(a.resetToVertex(e.getElement(s),-1),a.hasNextSegment()){let e=a.nextSegment();if(e.getGeometryType()===i.enumLine){let t=e.getStartXY(),n=e.getEndXY();if(o.clipLine(t,n))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY())||e.isIntersecting(c,n)||e.isIntersecting(l,n)||e.isIntersecting(u,n)||e.isIntersecting(d,n))return!0}return!1}}if(s){c=new I,l=new I,u=new I,d=new I,t.querySide(0,c),t.querySide(1,l),t.querySide(2,u),t.querySide(3,d);let r=e.querySegmentIterator();for(;r.nextPath();)for(;r.hasNextSegment();){let e=r.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY())||e.isIntersecting(c,n)||e.isIntersecting(l,n)||e.isIntersecting(u,n)||e.isIntersecting(d,n))return!0}}else{let r=T.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(n,n);let i=e.getImpl(),a=i.getAttributeStreamRef(0),o=new U;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0,n=new U,s=new U,c=new U,l=i.getPathStart(e),u=new U;for(let d=l,f=i.getPathEnd(e);d<f;d++){if(t){a.queryPoint2D(2*d,n),u.assign(n),t=!1;continue}if(a.queryPoint2D(2*d,o),s.setCoordsPoint2D(n),c.setCoordsPoint2D(o),r.clipLine(s,c))return!0;n.assign(o)}if(i.isClosedPath(e)&&!t&&(s.setCoordsPoint2D(n),c.setCoordsPoint2D(u),r.clipLine(s,c)))return!0}}return!1}function Mo(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=[0],s=We(i.getIsSimple(0,o))&&We(a.getIsSimple(0,o)),c=i.querySegmentIterator(),l=a.querySegmentIterator(),u=H(2,0),d=H(2,0),f=new Pi(i,a,n),p=!1;for(;f.next();){let e=f.getRedElement(),t=f.getBlueElement();c.resetToVertex(e,-1),l.resetToVertex(t,-1);let r=c.nextSegment(),i=l.nextSegment(),a=0;if(Uo(r,i)){if(i.isIntersecting(r,n)){p=!0;break}}else a=i.intersect(r,null,d,u,n);if(a===2){let e=u[0],t=u[1],i=r.calculateLength2D();if(s&&(t-e)*i>n)return!1;p=!0}else if(a){let e=u[0],t=d[0];if(e>0&&e<1&&t>0&&t<1)return!1;p=!0}}if(!p)return!1;let m=T.constructEmpty(),h=T.constructEmpty(),g=T.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(h),m.inflateCoords(1e3*n,1e3*n),h.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:m}),g.intersect(h);let _,v;if(e.getPointCount()>10){if(_=q(e,g,n,0,r),_.isEmpty())return!1}else _=e;if(t.getPointCount()>10){if(v=q(t,g,n,0,r),v.isEmpty())return!1}else v=t;return ai(_,v,n,`F********`,r,!1)}function No(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=[0],s=We(i.getIsSimple(0,o))&&We(a.getIsSimple(0,o)),c=T.constructEmpty(),l=T.constructEmpty(),u=T.constructEmpty();e.queryEnvelope(c),t.queryEnvelope(l);let d=!1,f=bo(c,l,n),p=bo(l,c,n),m=i.querySegmentIterator(),h=a.querySegmentIterator(),g=H(2,NaN),_=H(2,NaN),v=new Pi(i,a,n);for(;v.next();){let e=v.getRedElement(),t=v.getBlueElement();m.resetToVertex(e,-1),h.resetToVertex(t,-1);let r=m.nextSegment(),i=h.nextSegment(),a=0;if(Uo(r,i)){if(i.isIntersecting(r,n))break}else a=i.intersect(r,null,_,g,n);if(a===2){let e=g[0],t=g[1],i=r.calculateLength2D();if(s&&(t-e)*i>n&&(d=!0,f&&p))return!0}else if(a){let e=g[0],t=_[0];if(e>0&&e<1&&t>0&&t<1)return!0}}let y=T.constructEmpty(),b=T.constructEmpty();y.setCoords({env2D:c}),y.inflateCoords(1e3*n,1e3*n),b.setCoords({env2D:l}),b.inflateCoords(1e3*n,1e3*n),u.setCoords({env2D:y}),u.intersect(b);let x,S,C=``;if(C+=d?`**`:`T*`,f){if(t.getPointCount()>10){if(S=q(t,u,n,0,r),S.isEmpty())return!1}else S=t;C+=`****`}else S=t,C+=`T***`;if(p){if(e.getPointCount()>10){if(x=q(e,u,n,0,r),x.isEmpty())return!1}else x=e;C+=`***`}else x=e,C+=`T**`;return ai(x,S,n,C,r,!1)}function Po(e,t,n,r){let i=[!1],a=_o(e,t,n,i);if(i[0])return a;let o=T.constructEmpty();t.queryEnvelope(o),o.inflateCoords(1e3*n,1e3*n);let s;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;return oi(s,t,n,r)}function Fo(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=H(2,NaN),u=new Pi(i,a,n),d=!1;for(;u.next();){let e=u.getRedElement(),t=u.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let r=o.nextSegment(),i=s.nextSegment(),a=0;if(Uo(r,i)?!d&&i.isIntersecting(r,n)&&(d=!0):a=i.intersect(r,null,l,c,n),a===2)d=!0;else if(a){let e=c[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!1;d=!0}}if(!d)return!1;let f=T.constructEmpty(),p=T.constructEmpty(),m=T.constructEmpty();e.queryEnvelope(f),t.queryEnvelope(p),f.inflateCoords(1e3*n,1e3*n),p.inflateCoords(1e3*n,1e3*n),m.setCoords({env2D:f}),m.intersect(p);let h,g;if(e.getPointCount()>10){if(h=q(e,m,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(g=q(t,m,n,0,r),g.isEmpty())return!1}else g=t;return ai(h,g,n,`F********`,r,!1)}function Io(e,t,n,r){let i=e.getImpl(),a=t.getImpl(),o=i.querySegmentIterator(),s=a.querySegmentIterator(),c=H(2,NaN),l=H(2,NaN),u=new Pi(i,a,n),d=!1;for(;u.next();){let e=u.getRedElement(),t=u.getBlueElement();o.resetToVertex(e,-1),s.resetToVertex(t,-1);let r=o.nextSegment(),i=s.nextSegment(),a=0;if(Uo(r,i)?!d&&i.isIntersecting(r,n)&&(d=!0):a=i.intersect(r,null,l,c,n),a===2)d=!0;else if(a){let e=c[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!0;d=!0}}if(!d)return!1;let f=T.constructEmpty(),p=T.constructEmpty(),m=T.constructEmpty(),h=T.constructEmpty(),g=T.constructEmpty();if(e.queryEnvelope(f),t.queryEnvelope(p),bo(p,f,n)){m.setCoords({env2D:f}),m.inflateCoords(1e3*n,1e3*n),h.setCoords({env2D:p}),h.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:m}),g.intersect(h);let i,a;if(e.getPointCount()>10){if(i=q(e,g,n,0,r),i.isEmpty())return!1}else i=e;if(t.getPointCount()>10){if(a=q(t,g,n,0,r),a.isEmpty())return!1}else a=t;return ai(i,a,n,`T********`,r,!1)}return ai(e,t,n,`T*****T**`,r,!1)}function Lo(e,t,n,r){let i=[!1],a=_o(e,t,n,i);if(i[0])return a;let o=T.constructEmpty();t.queryEnvelope(o),o.inflateCoords(1e3*n,1e3*n);let s;if(e.getPointCount()>10){if(s=q(e,o,n,0,r),s.isEmpty())return!1}else s=e;return si(s,t,n,r)}function Ro(e,t,n,r){return qo(e,t,n)===1}function zo(e,t,n,r){return qo(e,t,n)===2}function Bo(e,t,n,r){let i=new U,a=n*n;for(let n=0;n<e.getPointCount();n++)if(e.queryXY(n,i),U.sqrDistance(i,t)<=a)return!1;return!0}function Vo(e,t,n){let r=e.getBoundary();return!r.isEmpty()&&!Bo(r,t,n)}function Ho(e,t,n){let r=T.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)?1073741824:r.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}function Uo(e,t){return e.getGeometryType()!==i.enumLine||t.getGeometryType()!==i.enumLine}function Wo(e,t,n,r,i,a,o,s){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:n,m_scalarA1:r,m_ivertexB:i,m_ipathB:a,m_scalarB0:o,m_scalarB1:s}}class Go{m_overlapEvents=[];compareOverlapEvents(e,t){let n=this.m_overlapEvents[e],r=this.m_overlapEvents[t];return n.m_ipathA<r.m_ipathA||n.m_ipathA===r.m_ipathA&&(n.m_ivertexA<r.m_ivertexA||n.m_ivertexA===r.m_ivertexA&&(n.m_scalarA0<r.m_scalarA0||n.m_scalarA0===r.m_scalarA0&&(n.m_scalarA1<r.m_scalarA1||n.m_scalarA1===r.m_scalarA1&&n.m_ivertexB<r.m_ivertexB)))?-1:1}}function Ko(e,t,n){let r=Jr(e,t,n);return r?r===1?1:2:0}function qo(e,t,n){let r=Yr(e,t,n);return r?r===1?1:2:0}function Jo(e,t,n,r,i){for(let a=0;a<n;a++)i[a]=qo(e,t[a],r)}function Yo(e,t,n,r,a){if(e.getGeometryType()===i.enumPolygon)Jo(e,t,n,r,a);else if(e.getGeometryType()===i.enumEnvelope){let i=T.constructEmpty();e.queryEnvelope(i),Zo(i,t,n,r,a)}else y(``)}function Xo(e,t,n,r,o){let s=e.getGeometryType();s===i.enumPolyline?ts(e,t,n,r,o):a(s)?es():y(``)}function Zo(e,t,n,r,i){if(e.isEmpty()){for(let e=0;e<n;e++)i[e]=0;return}let a=e.clone();a.inflateCoords(-r*.5,-r*.5);let o=e.clone();o.inflateCoords(r*.5,r*.5);for(let e=0;e<n;e++)a.contains(t[e])?i[e]=1:o.contains(t[e])?i[e]=2:i[e]=0}function Qo(e){if(e.isEmpty())return 0;switch(e.getGeometryType()){case i.enumMultiPoint:return e.getImpl().getPointCount();case i.enumPolyline:return e.getImpl().getPathCount();case i.enumPolygon:return e.getImpl().getOGCPolygonCount();case i.enumGeometryCollection:return e.getGeometryCount()}return 1}function $o(e,t,n){if(n.reset(),t<3)return;let r=e[0].clone(),i=r.x,a=r.y,o=e[1].clone(),s=new U;for(let i=2;i<t;i++)s.assign(e[i]),n.pe((s.x-r.x)*(o.y-a)),r.assign(o),o.assign(s);n.pe((i-r.x)*(o.y-a))}function es(e,t,n,r,i){l(0)}function ts(e,t,n,r,i){let a=e.getImpl(),o=a.getAccelerators(),s=null;o&&(s=o.getRasterizedGeometry());let c=n;for(let e=0;e<n;e++)i[e]=1,s&&l(0);if(c){if(o){let e=null;o!==null&&o.getQuadTree()!==null&&(e=o.getQuadTree());let s=a.getPointCount();if(e===null&&s>20&&s*n>4*s+Math.log(s)*n&&(e=qe(a)),e){let o=null,s=a.querySegmentIterator(),l=new T;for(let a=0;a<n&&c;a++)if(i[a]===1){l.setCoords(t[a]),o===null?o=e.getIterator(l,r):o.resetIterator(l,r);let n=-1;for(let l=o.next();l!==-1;l=o.next()){if(s.resetToVertex(e.getElement(l),n),n=s.getPathIndex(),s.nextSegment().isIntersectingPoint(t[a],r)){i[a]=2,c--;break}i[a]=0}}return}}let e=a.querySegmentIterator();for(;e.nextPath()&&c;)for(;e.hasNextSegment()&&c;){let a=e.nextSegment();for(let e=0;e<n&&c;e++)i[e]===1&&a.isIntersectingPoint(t[e],r)&&(i[e]=2,c--)}}for(let e=0;e<n;e++)i[e]===1&&(i[e]=0)}function ns(e,t,n,r,i){let a=fe(t),o=Math.max(4*a,n);return new os(t,null,o,NaN,i).approximateWithCirclesImpl(e,r)}function rs(){return Number.isNaN(this.radius.value())}function is(){return{ptStart:new U,ptEnd:new U,center:new ge,radius:new qt,fcenter:new he,fradius2:new Lt,maxError:NaN,isLine:rs}}function as(e,t,n,r){return{pt:e.clone(),t,err:n,checkCount:r}}class os{m_left;m_eps;m_tolerance;m_circleCheckCounter;m_bReversedLeft;m_leftArc;m_tracker;m_trackerCounter;constructor(e,t,n,r,i){this.m_left=e,this.m_tracker=i,this.m_eps=n,this.m_trackerCounter=0,this.m_tolerance=r,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc=is()}closeToCircularArc(e,t,n,r,i,a){if(this.m_circleCheckCounter++,a.maxError=0,!os.checkSweepAngle(e,t))return!1;if(a.ptStart.setCoordsPoint2D(n),a.ptEnd.setCoordsPoint2D(i),e.isCircular()){let t=e;return a.fradius2=Lt.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),a.radius.set(t.getSemiMajorAxis()),a.fcenter.assignPoint2D(t.getCenter()),a.center.set(t.getCenter()),!0}let o=a.ptEnd.sub(a.ptStart).clone();if(o.leftPerpendicularThis(),o.normalize(),Math.abs(o.dotProduct(r.sub(a.ptStart)))<=this.m_eps)return this.confirmIsLine(a,o)?(a.radius.set(NaN),a.center.setCoords(0,0),!0):!1;{let n=a.ptEnd.sub(a.ptStart),i=r.sub(a.ptStart),o=n.crossProduct(i);if(o===0)return!1;let s=n.sqrLength()*.5,c=i.sqrLength()*.5,l=s*i.y-c*n.y;l/=o;let u=n.x*c-i.x*s;u/=o;let d=Math.sqrt(l*l+u*u);if(2**-52*4*d>this.m_eps)return!1;let f=l+a.ptStart.x,p=u+a.ptStart.y;a.radius.set(d),a.center.setCoords(f,p);let m=this.maxCircleApproximationError(e,t,a);if(m>this.m_eps)return a.maxError=m,!1}let s=new he().assignPoint2D(a.ptStart),c=new he().assignPoint2D(a.ptEnd).sub(s),l=new he().assignPoint2D(r).sub(s),u=c.crossProduct(l);if(u.isZero())return!1;let d=c.sqrLength().mulDouble(.5),f=l.sqrLength().mulDouble(.5),p=d.mul(l.y).sub(f.mul(c.y)),m=c.x.mul(f).sub(l.x.mul(d)),h=p.mul(p).add(m.mul(m)),g=u.clone();g.invertThis(),a.fradius2=h.mul(g).mul(g),a.fcenter.setCoords(p.mul(g).add(s.x),m.mul(g).add(s.y)),a.center.setWithEps(a.fcenter.asPoint2D()),a.radius.setWithEps(Math.sqrt(a.fradius2.toDouble()));let _=ge.constructPoint2D(a.ptStart).subE(a.center),v=ge.constructPoint2D(a.ptEnd).subE(a.center);if(!_.dotProduct(v).gt(Rt))return!1;let y=this.maxCircleApproximationError(e,t,a);return a.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.enumEllipticArc){let n=e,r=_e(n,t.vmin),i=_e(n,t.vmax);return!(Math.abs(i-r)>G*.5)}return!0}confirmIsLine(e,t){let n=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(n.mul(.25)))>this.m_eps||Math.abs(t.dotProduct(n.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,n){let r=[.25,.75],a=[.1,.25,.75,.9],o,s;e.getGeometryType()===i.enumEllipticArc?(o=r,s=r.length):(o=a,s=a.length);let c=0;for(let r=0;r<s;++r){let i=new U;e.queryCoord2D(Ct(t.vmin,t.vmax,o[r]),i);let a=i.sub(n.center.value()).length(),s=Math.abs(a-n.radius.value());s>c&&(c=s)}return c}approximateWithCirclesImpl(e,t){let n=1;t&&t.push(0);let r=H(9,NaN),i;e?i=this.m_left.getMonotonicPartParams(r.length,r):(r[0]=0,r[1]=1,i=2);let a=[],o=[],s=new U(0,0);for(let e=1;e<i;e++){let i=new W(r[e-1],r[e]);for(this.m_bReversedLeft=!os.goodOrientation(this.m_left,i),this.m_bReversedLeft?(a.push(as(s,i.vmin,0,0)),a.push(as(s,i.vmax,0,0))):(a.push(as(s,i.vmax,0,0)),a.push(as(s,i.vmin,0,0))),a[0].pt=this.m_left.getCoord2D(a[0].t),a[1].pt=this.m_left.getCoord2D(a[1].t);a.length>1;){this.progress_();let e=a.at(-1),r=e.checkCount,i=e.err,s=e.pt.clone(),c=e.t,l=a[a.length-2].t,u=(c+l)*.5,d=this.m_left.getCoord2D(u);if(i<=this.m_eps||r>=5){let e=new W;if(e.setCoords(c,l),this.closeToCircularArc(this.m_left,e,s,d,a[a.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(c):t.push(l)),n++,a.pop();continue}r=0,i=this.m_leftArc.maxError}e.t=u,e.pt.setCoordsPoint2D(d),i*=.125,r++,e.err=i,e.checkCount=r,a.push(as(s,c,i,r))}this.m_bReversedLeft&&t&&(t.length+=o.length,zt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),a.length=0}return n}approximateWithCirclesImplPolyline(e){let t=new E,n=[];if(!this.approximateWithCirclesImpl(!0,n))return t;let r=0,i=this.m_left.getStartXY();t.startPath(i);for(let a=1;a<n.length;++a)if(e)t.lineTo(this.m_left.getCoord2D(n[a]));else{let e=new U;this.m_left.queryCoord2D(n[a],e);let o=new U;this.m_left.queryCoord2D((n[a]+r)*.5,o);let s=new ie;s.constructCircularArcThreePoint(i,e,o),t.addSegment(s,!1),i.assign(e),r=n[a]}return t}static goodOrientation(e,t){let n=e.getCoord2D(t.vmin),r=e.getCoord2D(t.vmax);return n.compare(r)<0}progress_(e=!1){}}function ss(e,t,n,r,i,a,o){ls(e,t,n,i,a,o),Cs(e,n,o)}function cs(e,t,n,r){if(!s(e.getGeometryType()))return e;let a=e.getImpl();if(!a.hasNonLinearSegments())return e;let o=e.createInstance();o.getGeometryType()===i.enumPolygon&&o.setFillRule(e.getFillRule()),new N;let c=new B,l=new F,u=[],d=[],f=[],p=e.getDescription().getAttributeCount()>1,m=a.querySegmentIterator();for(;m.nextPath();){let e=!0;for(;m.hasNextSegment();){let r=m.isClosingSegment(),a=m.nextSegment();if(!a.isCurve()){o.addSegment(a,e,r),e=!1;continue}let s,h=!1;switch(a.getGeometryType()){case i.enumEllipticArc:s=ee(a,t,n,!0,!0,d,f,u),h=!0;break;case i.enumRationalBezier2:s=ee(a,t,n,!0,!0,d,f,u),h=!0;break;default:s=R(a,t,n,!0,!0,d,u)}let g=h?2:3;d[1].isNAN()?(l.createLine(),l.get().construct(d[0],d[g])):h?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(d,f)):(l.createCubicBezier(),l.get().constructPoints(d)),p&&e&&(a.queryCoord(u[0],c),l.get().setStart(c)),p&&(a.queryCoord(u[1],c),l.get().setEnd(c)),o.addSegment(l.get(),e,r&&s===1),e=!1;for(let e=1,t=s,n=g;e<t;++e,n+=g)d[n+1].isNAN()?(l.createLine(),l.get().construct(d[n],d[n+g])):h?(l.createQuadraticRationalBezier(),l.get().constructArrayWeights(d.slice(n),f.slice(n))):(l.createCubicBezier(),l.get().constructPoints(d.slice(n))),p&&(a.queryCoord(u[e+1],c),l.get().setEnd(c)),o.addSegment(l.get(),!1,r&&e+1===t)}}return o}function ls(e,t,n,r,i,a){if(!e.hasCurves()){r.m_impl=null;return}e.setCurveStitcherPointer(r),r.m_impl=new vs(a,!1,null),r.m_impl.buildMonotonicCurveParentage(e,t,n,i)}function us(e,t,n,r,i,a,o,s){if(!e.hasCurves()){a.m_impl=null;return}e.setCurveStitcherPointer(a),a.m_impl=new vs(s,!0,i),a.m_impl.buildMonotonicCurveParentage(e,t,n,o),Cs(e,n,s)}function ds(e){if(!e.hasSegmentParentage())return;let t=e.queryVertexIteratorOnSelection();for(let n=t.next();n!==z;n=t.next())if(!e.getSegmentParentageBreakVertex(n)){e.getPathFromVertex(n);let t=e.getPrevVertex(n),r=t===z?-1:e.getSegmentParentage(t),i=e.getSegmentParentage(n);i!==-1&&r!==-1&&i!==r&&e.setSegmentParentageBreakVertex(n,!0)}}function fs(e){if(!e.hasSegmentParentage())return;ds(e);let t=new Re(0),n=e.queryVertexIteratorOnSelection();for(let e=n.next();e!==z;e=n.next())t.add(e);if(t.size()===0)return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(z);let r=U.getNAN();e.queryXY(t.read(0),r);let i=0,a=U.getNAN();for(let n=1,o=t.size();n<o;n++){{let r=t.read(n);r===z?a.setNAN():e.queryXY(r,a)}if(!a.isEqualPoint2D(r)){if(n-i>1){let r=!1;for(let a=i;a<n;++a){let n=t.read(a);if(e.getSegmentParentageBreakVertex(n)){r=!0;break}}if(!r){let a=(t,n,r)=>{let i=e.getPrevVertex(t),a=e.getNextVertex(t);i===z?n.setNAN():n.assign(e.getXY(i)),a===z?r.setNAN():r.assign(e.getXY(a))},o=new U,s=new U;a(t.read(i),o,s);for(let e=i+1;e<n;++e){let n=t.read(e);if(n===z)continue;let i=new U,c=new U;a(n,i,c);let l=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if((!l(i,o)||!l(c,s))&&(!l(c,o)||!l(i,s))){r=!0;break}}}if(r)for(let r=i;r<n;++r)e.setSegmentParentageBreakVertex(t.read(r),!0)}r.setCoordsPoint2D(a),i=n}}}function ps(e,t){let n=t.isEmpty()?e:je(null,t,!0).total();return n>e&&(n=e),n*.125}function ms(e,t){return t||=T.constructEmpty(),ps(e,t)}function hs(e,t){return e*.125}function gs(e,t){return 3*e+3*t}class _s{m_impl=null;stitchCurves(e,t,n,r){this.m_impl&&(this.m_impl.stitchCurves(e,t,n),r&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&=(this.m_impl.clearStitcher(e),null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class vs{constructor(e,t,n){this.m_progressTracker=e,this.m_nsr=n,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,n,r){if(!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=n;let a=new B,o=new F,s=[],c=[],u=[];for(let r=e.getFirstGeometry();r!==z;r=e.getNextGeometry(r))for(let d=e.getFirstPath(r);d!==z;d=e.getNextPath(d)){let r=e.getPathSize(d),f=e.getFirstVertex(d),p=0,m=-1;for(let h=0;h<r;h++){let g=e.getNextVertex(f);if(!e.querySegment(f,o,!0,!1)){f=g;continue}if(p===0){m=e.getVertexIndex(f);let t=vs.regularizeCurve(e,o.get(),f,n);if(t>=0){this.m_nsr&&this.m_nsr.m_reason===0&&this.m_nsr.assign(new J(13,m,-1)),p=t,r=e.getPathSize(d),g=e.getNextVertex(f);let n=e.querySegment(f,o,!0,!1);l(n)}}else p--;let _=e.getVertexIndex(f);this.m_originalVertexIndex!==-1&&e.setUserIndex(f,this.m_originalVertexIndex,m),e.setSegmentToIndex(_,null);let v,y=!1;switch(o.get().getGeometryType()){case i.enumEllipticArc:v=ee(o.get(),t,n,!1,!0,c,u,s),y=!0;break;case i.enumRationalBezier2:v=ee(o.get(),t,n,!1,!0,c,u,s),y=!0;break;default:{let e=!this.m_bIsSimple||!o.get().isMonotoneQuickAndDirty();v=R(o.get(),t,n,e,!1,c,s)}}let b=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(f,b,!0),!c[1].isNAN()){let t=null;t=y?new ne({points:c,weights:u}):new te({cp:c}),t.snapControlPoints(n*n),e.setSegmentToIndex(_,t)}let x=y?2:3;for(let t=1,r=v,i=x;t<r;++t,i+=x){o.get().queryCoord(s[t],a);let r=e.insertVertex(d,g,a);if(this.m_originalVertexIndex!==-1&&e.setUserIndex(r,this.m_originalVertexIndex,m),!c[i+1].isNAN()){if(y){let t=new ne({points:c.slice(i),weights:u.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(r),t)}else{let t=new te({cp:c.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(r),t)}}e.setSegmentParentageAndBreak(r,b,!1)}v>1&&(h+=v-1,r=e.getPathSize(d)),this.m_originalPlanarSegments.push(o.releaseSegment()),f=g}}}buildLinearSegmentParentage(e,t,n,r,i){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=r,!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_tolerance=n,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());let a=new B,o=new F,s=new re(0,t,0,this.m_progressTracker,!1,r),c=[];for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))for(let r=e.getFirstPath(t);r!==z;r=e.getNextPath(r)){let t=e.getPathSize(r),i=e.getFirstVertex(r);for(let u=0;u<t;u++){let u=e.getNextVertex(i);if(!e.querySegment(i,o,!0,!1)){i=u;continue}if(vs.regularizeCurve(e,o.get(),i,n)>=0){t=e.getPathSize(r),u=e.getNextVertex(i);let n=e.querySegment(i,o,!0,!1);l(n)}let d=e.getVertexIndex(i);this.m_originalVertexIndex!==-1&&e.setUserIndex(i,this.m_originalVertexIndex,d),e.setSegmentToIndex(d,null),c.length=0,s.densifySegment(o.get(),c),this.progress_();let f=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(i,f,!0);for(let t=1,n=c.length-1;t<n;++t){o.get().queryCoord(c[t],a);let n=e.insertVertex(r,u,a);e.setSegmentParentageAndBreak(n,f,!1),this.m_originalVertexIndex!==-1&&e.setUserIndex(n,this.m_originalVertexIndex,d)}this.m_originalPlanarSegments.push(o.releaseSegment()),i=u}}e.clearSegments()}stitchCurves(e,t,n){vs.st_stitchCurvesImpl(this,e,t,n,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,this.m_originalVertexIndex!==-1&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){vs.st_stitchCurvesImpl(null,e,z,0,!0)}getOriginalVertexIndex(e,t){return this.m_originalVertexIndex===-1||t===z?-1:e.getUserIndex(t,this.m_originalVertexIndex)}getOriginalSegmentTypeInfo(e){if(e!==-1){let t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.enumEllipticArc:return t.projectionBehavior()===0?0:1;case i.enumBezier:return 2;case i.enumBezier2:return 3;case i.enumLine:return-1;case i.enumRationalBezier2:return 4;default:p(``)}}return-1}m_originalPlanarSegments=[];m_progressTracker=null;m_nsr=null;m_tolerance;m_densificationDeviation;m_maxSegmentsPerCurve;m_originalVertexIndex;m_type;m_progressCounter;m_bIsSimple;progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,n,r,i,a,o){if(t===n&&r===0){l(e.getNextVertex(t)===z),e.setSegmentToIndex(e.getVertexIndex(t),null),e.setSegmentParentageAndBreak(t,-1);return}let s=e.getNextVertex(t),c=e.getXY(t),u=e.getXY(n),d=0;{let t=2,i=c;for(let r=s;r!==n;r=e.getNextVertex(r)){let n=e.getXY(r);d+=U.distance(n,i),i=n,t++}d+=U.distance(u,i),l(t===r)}if(i===null){e.setSegmentToIndex(e.getVertexIndex(t),null),e.removeVertices(s,n);return}let f,p=o,m=i.getClosestCoordinate(c,!1),h=i.getClosestCoordinate(u,!1),g=i.calculateLength2D(),_=i.tToLength(m),v=i.tToLength(h),y=Math.abs(_)>10*p&&Math.abs(_-g)>10*p,b=Math.abs(v)>10*p&&Math.abs(v-g)>10*p,x=e=>{let t=e.calculateLength2D();return Math.abs(t-d)>Math.max(d*.2,4*p)?null:e},S=i.isClosed();if(!S){let e=U.distance(i.getStartXY(),i.getEndXY());e<=p&&g>5*e&&(S=!0)}if(S){let a=new U,o,s;if(r===2)a=U.lerp(c,u,.5),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o);else{let n=e.getNextNthVertex(t,(r-1)/2);a=e.getXY(n),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o);let c=Math.abs(s)>10*p&&Math.abs(s-g)>10*p;if(!c&&(r-1>=4&&(n=e.getNextNthVertex(t,(r-1)/4),o=i.getClosestCoordinate(a,!1),s=i.tToLength(o),c=Math.abs(s)>10*p&&Math.abs(s-g)>10*p),!c))return}let d=!1,S=_===v;if(S){let n=2,a=4;r-1<=4&&(n=1,a=2);let o=c,s=e.getXY(e.getNextNthVertex(t,n)),l=e.getXY(e.getNextNthVertex(t,a));d=-U.orientationNonRobust(o,s,l)*_t(i.calculateArea2DHelper())>0}else b?y?d=s>_:s<v?(_=0,m=0):(_=g,m=1):s>_?(v=g,h=1):(v=0,h=0);if(S)f=i.clone(),f.dropAllAttributes(),d||f.reverse(),l(c.equals(u));else{let e=!1;m>h&&(e=!0,[m,h]=[h,m]),f=i.cut(m,h,!0),f.getDescription().getAttributeCount(),e&&f.reverse()}f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}else if(y||b){if((!y||!b)&&U.distance(i.getStartXY(),i.getEndXY())<10*p){let r=[yt(m,h),yt(m,h),yt(m,h)];y?(r[1].second=0,r[2].second=1):(r[1].first=1,r[2].first=0);let a=[null,null,null],o=[0,0,0],s=Number.MAX_VALUE,l=0;for(let e=0;e<3;e++){let t=!1;if(r[e].first>r[e].second){t=!0;let n=r[e].first;r[e].first=r[e].second,r[e].second=n}a[e]=i.cut(r[e].first,r[e].second,!0),a[e].dropAllAttributes(),t&&a[e].reverse(),a[e].setCoordsForIntersector(c,u,!1),o[e]=a[e].calculateLength2D();let n=Math.abs(d-o[e]);n<s&&(s=n,l=e)}f=a[l],f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f));return}let r=!1;m>h&&(r=!0,[m,h]=[h,m]),f=i.cut(m,h,!0),f.dropAllAttributes(),r&&f.reverse(),f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}else{if(f=i.clone(),f.dropAllAttributes(),_>v&&f.reverse(),d<Math.max(g*.75,g-this.m_densificationDeviation*(r-1))){let e=m>h?h:m,t=f.tToLength(e)+d,n=f.lengthToT(t);n=At(n,e,1),f=f.cut(e,n,!0)}f.setCoordsForIntersector(c,u,!1),f=x(f),f&&(this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),f))}}processSpanCurves_(e,t,n,r,i,a,o){if(t===n&&r===0){l(e.getNextVertex(t)===z),e.setSegmentToIndex(e.getVertexIndex(t),null),e.setSegmentParentageAndBreak(t,-1);return}let s=e.getNextVertex(t);{let t=2;for(let r=s;r!==n;r=e.getNextVertex(r))t++;l(t===r)}if(i===null){e.setSegmentToIndex(e.getVertexIndex(t),null),e.removeVertices(s,n);return}let c=e.getXY(t),u=e.getXY(n);if(i.isClosed()){if(c.isEqualPoint2D(u)&&c.isEqualPoint2D(i.getStartXY())){let s;if(s=this.verifySegmentFitnessCurves(e,t,n,r,i,a,o)){let r=i.clone();r.dropAllAttributes(),s<0&&r.reverse(),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),r);return}}}else if(c.isEqualPoint2D(i.getStartXY())){if(u.isEqualPoint2D(i.getEndXY())){let s=i.clone();s.dropAllAttributes();let c=this.verifySegmentFitnessCurves(e,t,n,r,s,a,o);if(c){l(c>0),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),s);return}}}else if(u.isEqualPoint2D(i.getStartXY())&&c.isEqualPoint2D(i.getEndXY())){let s=i.getReversed();s.dropAllAttributes();let c=this.verifySegmentFitnessCurves(e,t,n,r,s,a,o);if(c){l(c>0),this.removeSpanBetween(e,t,n),e.setSegmentToIndex(e.getVertexIndex(t),s);return}}this.processSpanSplitSegmentCurves(e,t,n,r,i,a,o)}processSpan_(e,t,n,r,i,a,o){if(this.m_type===0){this.processSpanSmartTe_(e,t,n,r,i,a,o);return}this.processSpanCurves_(e,t,n,r,i,a,o)}processSpanSplitSegmentCurves(e,t,n,r,i,a,o){if(i.isLine()||this.fitSegmentToSpanCurves(e,t,n,r,i,a,o))return;let s=o*o,c=r,l=t,u=e.getXY(t),d=i.getClosestCoordinate(u,!1),f=i.getCoord2D(d),p=!1,m=U.sqrDistance(u,f);if(m>s){let r=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,i,a,o),r===n)return;l=r,p=!0,--c}let h=n,g=e.getXY(n);d=i.getClosestCoordinate(g,!1);let _=i.getCoord2D(d),v=!1,y=U.sqrDistance(g,_);if(y>s){let t=e.getPrevVertex(n);if(this.approximateSpanSectionCurves(e,t,i,a,o),t===l)return;h=t,v=!0,--c}if((p||v)&&this.fitSegmentToSpanCurves(e,l,h,c,i,a,o))return;let b=!1;if(!p&&m>0){let n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,i,a,o),n===h)return;l=n,p=!0,b=!0,--c}if(!v&&y>0){let t=e.getPrevVertex(n);if(this.approximateSpanSectionCurves(e,t,i,a,o),t===l)return;h=t,v=!0,b=!0,--c}if(b&&this.fitSegmentToSpanCurves(e,l,h,c,i,a,o))return;let x=l;for(;;){let t=e.getNextVertex(x);if(this.approximateSpanSectionCurves(e,x,i,a,o),x=t,x===h)return}}fitSegmentToSpanCurves(e,t,n,r,i,a,o){let s=[];s.push(e.getXY(t));let c=t,l=new F;for(;;){e.querySegment(c,l,!1,!0);let t=[.1,.25,.4,.5,.6,.75,.9,1],i=0;for(let e of t)(r===2||i&1)&&s.push(l.get().getCoord2D(e)),i++;if(c=e.getNextVertex(c),c===n)break}let u=(()=>{let e=s[0].compare(s.at(-1));if(e===0){let t=new St(0);$o(s,s.length,t),e=t.getResult()>=0?-1:1}return e>0})();u&&s.reverse();let d=i.clone();if(d.dropAllAttributes(),u&&d.reverse(),d.setSegmentFromCoordsForStitcher(s,s.length),u&&d.reverse(),d.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,n,r,d,a,o)){this.removeSpanBetween(e,t,n);let r=e.getVertexIndex(t);return e.setSegmentToIndex(r,d),!0}return!1}approximateSpanSectionCurves(e,t,n,r,a){let s=new F;if(!e.querySegment(t,s,!0,!1))return;let c=n.getGeometryType();if(c!==s.get().getGeometryType()){if(c===i.enumEllipticArc){if(s.get().getGeometryType()!==i.enumRationalBezier2)return;if(n.projectionBehavior()===0){let n=[];ns(!1,s.get(),a,n,this.m_progressTracker);let r=e.getNextVertex(t),i=e.getPathFromVertex(t),o=new B,c=t;for(let t=1,a=n.length;t<a;t++){let a=n[t],l=s.get().getCoord2D(n[t-1]),u=s.get().getCoord2D(Ct(n[t-1],a,.5));s.get().queryCoord(a,o);let d=o.getXY(),f=new ie;f.constructCircularArcThreePoint(l,d,u);let p=z;a<1&&(p=e.insertVertex(i,r,o)),e.setSegmentToIndex(e.getVertexIndex(c),f),c=p}return}{let n=bt(U,3);s.get().queryControlPoints(n);let r=[0,0,0];s.get().queryWeights(r);let i=ae(r),a=new ie;oe(n,i*i,null,!1,a),e.setSegmentToIndex(e.getVertexIndex(t),a);return}}o(`approximate_span_section_`)}}verifySegmentFitnessCurves(e,t,n,r,i,a,o){let s=e.getXY(t),c=e.getXY(n);if(!s.isEqualPoint2D(i.getStartXY())||!c.isEqualPoint2D(i.getEndXY()))return 0;let l=0;if(i.isClosed()){let e=i.getCoord2D(.1).sub(s);l=i.getCoord2D(.7).sub(s).crossProduct(e)>=0?1:-1}let u=H(se.s_maxMonotonicPartParams,NaN),d=i.getMonotonicPartParams(u.length,u);d--;let f=new I,p=[1,.5,.75,.25],m=0,h=t,g=s.clone();for(;;){let t=e.getNextVertex(h),r=e.getSegment(h);r===null&&(e.queryLineConnector(h,f,!0),r=f);for(let e=+(t===n);e<p.length;e++){let t=r.getCoord2D(p[e]);if(!i.isCloserThanDistance(t,W.unit(),o))return 0}if(d>1)for(let e=1;e<d;){let t=i.getCoord2D(u[e]);r.isCloserThanDistance(t,W.unit(),o)?(u[d-1]=gt(u[e],u[e]=u[d-1]),d--):e++}if(l){let e=r.getCoord2D(.25);m+=e.sub(s).crossProduct(g.sub(s)),g.assign(e),e.assign(r.getCoord2D(.75)),m+=e.sub(s).crossProduct(g.sub(s)),g.assign(e)}if(h=t,h===n)return d>1?0:l?m<0?-l:l:1}}removeSpanBetween(e,t,n){e.setSegmentToIndex(e.getVertexIndex(t),null);let r=e.getNextVertex(t);r!==n&&e.removeVertices(r,n)}static st_stitchCurvesImpl(e,t,n,r,i){if(!t.hasSegmentParentage())return;ds(t);let a=n===z?t.getFirstGeometry():n;for(;a!==z;){if(!C(t.getGeometryType(a))){a=n===z?t.getNextGeometry(a):z;continue}for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n),o=t.isClosedPath(n);o&&(a+=1);let s=t.getFirstVertex(n),c=t.getSegmentParentage(s);if(o){if(c!==-1&&!t.getSegmentParentageBreakVertex(s)){let e=t.getPrevVertex(s),n=s;for(let r=0;;r++){let i=t.getSegmentParentage(e);if(c!==i){l(i===-1);break}if(s=e,t.getSegmentParentageBreakVertex(e))break;if(e===n){s=n,t.setSegmentParentageBreakVertex(s,!0);break}e=t.getPrevVertex(e),l(r<a)}}}else l(c===-1||t.getSegmentParentageBreakVertex(s));let u=s;for(let n=0;n<a&&u!==z;){let o=t.getSegmentParentage(u);if(o===-1){if(n++,u=t.getNextVertex(u),u===s)break;continue}let c=0,d=z,f=u;c=1;let p=t.getNextVertex(f);for(;n<a&&p!==z;){n++,d=p,c++;let e=t.getSegmentParentage(p);if(e===-1||t.getSegmentParentageBreakVertex(p))break;l(e===o),p=t.getNextVertex(p)}if(d===z){l(0);break}if(!i){let n=e.m_originalPlanarSegments[o];e.processSpan_(t,f,d,c,n,o,r)}if(u=d,u===s)break}}if(n!==z)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromLinesImpl(e,t,n,r,i){let a=n===z?t.getFirstGeometry():n;for(;a!==z;){for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n);t.isClosedPath(n)&&(a+=1);let o=!0,s=!1,c=t.getFirstVertex(n),u=c;for(let n=0;n<a&&u!==z;){let d=t.getSegmentParentage(u);if(d===-1||o){o=!1,n++,u=t.getNextVertex(u),s=!0;continue}let f=0,p,m;if(s?(p=t.getPrevVertex(u),m=u,l(p!==z),l(m!==p),l(t.getSegmentParentage(p)===-1||c===p)):(p=u,m=t.getNextVertex(p),n++,l(m!==z),l(m!==p),d=t.getSegmentParentage(m)),f=2,s=!1,d===-1||t.getSegmentParentageBreakVertex(m)){u=m;continue}let h=t.getNextVertex(m);for(n++;n<a&&h!==z;){m=h,f++;let e=t.getSegmentParentage(h);if(e===-1||t.getSegmentParentageBreakVertex(h))break;l(e===d),n++,h=t.getNextVertex(h)}if(!i){let n=e.m_originalPlanarSegments[d];e.processSpan_(t,p,m,f,n,d,r)}u=m}}if(n!==z)break;a=t.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(e,t,n,r,i){let a=n===z?t.getFirstGeometry():n;for(;a!==z;){if(!C(t.getGeometryType(a))){a=n===z?t.getNextGeometry(a):z;continue}for(let n=t.getFirstPath(a);n!==z;n=t.getNextPath(n)){let a=t.getPathSize(n),o=t.isClosedPath(n);o&&(a+=1);let s=t.getFirstVertex(n);if(o){if(t.getSegmentParentage(s)!==-1){let e=s;for(let r=0;!t.getSegmentParentageBreakVertex(e);r++){if(r===a){s=t.getFirstVertex(n),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else l(t.getSegmentParentage(s)===-1||t.getSegmentParentageBreakVertex(s));let c=s;for(let n=0;n<a&&c!==z;){let o=t.getSegmentParentage(c);if(o===-1){n++,c=t.getNextVertex(c);continue}let s=0,u=z,d=c;s=1;let f=t.getNextVertex(d);for(;n<a&&f!==z;){n++,u=f,s++;let e=t.getSegmentParentage(f);if(e===-1||t.getSegmentParentageBreakVertex(f))break;l(e===o),f=t.getNextVertex(f)}if(u===z)break;if(!i){let n=e.m_originalPlanarSegments[o];e.processSpan_(t,d,u,s,n,o,r)}c=u}}if(n!==z)break;a=t.getNextGeometry(a)}}static regularizeCurve(e,t,n,r){let i=t.snapControlPoints(r*r);if(i){let r=e.getVertexIndex(n),i=t.clone();e.setSegmentToIndex(r,i)}if(t.getGeometryType()===te.type){let a=[],o=t.calculateSpecialPointsForCracking(r,a);if(o>0){let s=[];if(o>1){for(let e=0;e<o;e++)if(s.push(t.getCoord2D(a[e])),e>0){let t=(Math.abs(s[e].x)+Math.abs(s[e].y))*wt(),n=U.distance(s[e-1],s[e]);if(n<t&&n>0){let t=new U;Tt(s[e-1],s[e],.5,t),s[e-1]=t,s[e]=t}}}e.splitSegment(n,a,o),i=e.snapControlPoints(n,o+1,r*r)||i;for(let t=0;t<o;t++)n=e.getNextVertex(n),e.setSegmentParentageBreakVertex(n,!0);return o}}return i?0:-1}}function ys(e,t,n,r,i){return new Ts(e,n,t,r,i).do_()}function bs(e,t,n){let r=Pe(e);return pr(t.getX(),t.getY(),n.getX(),n.getY(),Dt(r))}function xs(e,t,n=1,r=1,i=1,a=1){if(r>a)return e;if(a>r)return t;let o=[0],s=[0],c=new B;return gr(e,t,n,r,i,a,c,s,o),c}function Ss(e,t,n){let r=Pe(t),i=Le(t);return _r(e,r,z,null,n)?!0:Br(!0,e,i,null,n)}function Cs(e,t,n){return Ts.fixCurveTwoPointLoops(e,t,n)}function ws(e){return Pe(e)}class Ts{m_shape;m_progressTracker;m_tolerance;m_bFilterDegenerateSegments;m_bTrackChanges;m_progressCounter;constructor(e,t,n,r,i){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=n,this.m_bFilterDegenerateSegments=r,this.m_bTrackChanges=i,this.m_progressCounter=0}do_(){let e=new Ne(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=ws(e),n=Le(e),r=n*(1+1e-5);n*=1+1e-6;let i=!1,a=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),s=this.m_shape.hasPointFeatures();for(let e=0;;e++){this.m_shape.dbgCheckSelection(),e>a&&o(`crack_and_cluster_iteration_exceeded`),this.m_shape.dbgVerifyMonotone();let c=-1;e===0&&(c=this.firstCrack_(),i||=c>0);let l=this.cluster_(t);if(this.m_shape.dbgVerifyMonotone(),i||=l,this.m_bFilterDegenerateSegments){let e=this.m_shape.filterClosePoints(t,!0,!1,this.m_bTrackChanges,z)!==0;i||=e,this.m_shape.dbgVerifyMonotone()}let u=this.m_shape.snapControlPointsOnSelection(r*r);i||=u,this.m_shape.dbgCheckSelection();let d=!1;if((e===0&&c===-1||s||Br(!0,this.m_shape,n,null,this.m_progressTracker))&&(d=this.crack_(r),i||=d,this.m_shape.dbgVerifyMonotone()),!d&&!Ts.fixCurveTwoPointLoops(this.m_shape,t,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return i&&fs(this.m_shape),i}cluster_(e){return fr(this.m_shape,e,z,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return zr(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,n){if(!e.hasCurves())return!1;e.dbgVerifyCurves();let r=e.createUserIndexUninitialized(),i=new Re(0),a=e.queryVertexIteratorOnSelection();for(let t=a.next();t!==z;t=a.next())i.add(t),e.setUserIndex(t,r,-1);if(i.size()===0)return!1;i.add(z),e.sortVerticesSimpleByY(i,0,i.size()-1);let o=0,s=e.getXY(i.read(o)),c=new U(NaN,NaN),u=[];for(let t=1,n=i.size();t<n;++t){let n=i.read(t),a=n===z?c:e.getXY(n);if(a.equals(s))continue;let l=[];for(let n=o;n<t;n++){let t=i.read(n),a=e.getPrevVertex(t);if(a!==z&&e.getUserIndex(a,r)===-1){let t=Es(e.getXY(a),e.getSegment(a));U.sqrDistance(s,t.otherPt)!==0&&(t.vert=a,t.dir=-1,l.push(t)),e.setUserIndex(a,r,1)}let o=e.getNextVertex(t);if(o!==z&&e.getUserIndex(t,r)===-1){let n=Es(e.getXY(o),e.getSegment(t));U.sqrDistance(s,n.otherPt)!==0&&(n.vert=t,n.dir=1,l.push(n)),e.setUserIndex(t,r,1)}}if(l.length>1){l.sort((e,t)=>ks(e,t));let e=Es(c.clone(),null);l.push(e);let t=0;for(let e=1,n=l.length;e<n;e++)if(!l[e].otherPt.equals(l[e-1].otherPt)){if(e-t>1&&l[t].seg!==null){let n=!1,r=t;for(let i=t+1;i<e;i++)if(!Ds(l[r],l[i])){n=!0;break}if(n)for(let n=t;n<e&&l[n].seg!==null;n++)u.push(l[n].vert)}t=e}}o=t,s.setCoordsPoint2D(a)}for(let n of u){let r=e.getSegment(n);l(r!==null);let i=e.getXY(n),a=e.getXY(e.getNextVertex(n));if(U.distance(i,a)<t*3)e.setSegmentToIndex(e.getVertexIndex(n),null);else{let t=r.lengthToT(r.calculateLength2D()*.5);e.splitSegment(n,[t],1)}}return e.removeUserIndex(r),u.length>0}firstCrack_(){let e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=je(null,e,!0).total();if(t*4<this.m_tolerance.total()){let e=!1,n=t*1.1,r=t,i=this.cluster_(n);e||=i;let a=0;this.m_bFilterDegenerateSegments&&(a=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,z));let o=this.crack_(r);return e||=o,e?1:a?2:0}return-1}progress_(e=!1){this.m_progressCounter++,(e||!(this.m_progressCounter&4095))&&(this.m_progressCounter=0)}}function Es(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function Ds(e,t){if(l(e.otherPt.equals(t.otherPt)),e.seg===null)return t.seg===null;if(t.seg===null)return!1;let n=e.seg.getGeometryType();if(n!==t.seg.getGeometryType())return!1;if(n===i.enumBezier){let n=e.seg,r=t.seg,i=n.getControlPoint1(),a=n.getControlPoint2();e.dir===-1&&(a=gt(i,i=a));let o=r.getControlPoint1(),s=r.getControlPoint2();return t.dir===-1&&(s=gt(o,o=s)),i.equals(o)&&a.equals(s)}if(n===i.enumRationalBezier2){let n=e.seg,r=t.seg,i=n.getControlPoint1(),a=r.getControlPoint1();if(!i.equals(a))return!1;let o=[0,0,0];n.queryWeights(o),e.dir===-1&&(o[2]=gt(o[0],o[0]=o[2]));let s=[0,0,0];return r.queryWeights(s),t.dir===-1&&(s[2]=gt(s[0],s[0]=s[2])),o[0]===s[0]&&o[1]===s[1]&&o[2]===s[2]}o(``)}function Os(e,t){if(e.seg===null||t.seg===null)return e.seg===null?t.seg===null?0:1:-1;let n=e.seg.getGeometryType(),r=t.seg.getGeometryType();return n<r?-1:+(n>r)}function ks(e,t){let n=e.otherPt.compare(t.otherPt);return n===0?Os(e,t):n}var As=s,js=a,Ms=u;function Ns(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:l(0,`unrecognized cut side`)}return 3}function Ps(){return{unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1}}function Fs(e,t,n,r){return new Xs(r).autoCompleteImpl(e,t,n)}function Is(e,t,n,r,a,o,s){let c=new Xs(a);c.m_bOGCOutput=!0;let l=e.getGeometryType()===i.enumPolygon&&e.getFillRule()===1&&!We(r);return c.planarSimplifyImpl_(e,t,l,n,r,a,o,s)}function Ls(e,t,n,r,i,a,o,s){return new Xs(a).planarSimplifyImpl_(e,t,n,r,i,a,o,s)}function Rs(e,t,n,r){let i=new Xs(r),a=new N,o=a.addGeometry(t),s=i.planarSimplifyNoCrackingAndCluster(e,a,o,n);return l(s,`planar_simplify_no_cracking_and_cluster`),a.getGeometry(o)}function zs(e,t,n,r,i,a,o){return l(0),{}}function Bs(e,t,n,r){return l(0),{}}function Vs(e,t,n){return Qs(e,t,n)}function Hs(e,t,n,r){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return $s(ec(e),e,t,`-`);let a=new T;e.queryEnvelope(a);let o=new T;t.queryEnvelope(o);let s=new T;s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=o.clone(),u=Pe(c);if(l.inflateCoords(u,u),!a.isIntersecting(l))return $s(ec(e),e,t,`-`);let d=new Xs(r),f=new N,p=f.addGeometry(ec(e)),m=f.addGeometry(ec(t)),h=0,g=0,_=null;if(f.hasCurves()){_=new _s;let e=f.getEnvelope2D(r);g=hs(c.total());let t=ms(c.total(),e);h=gs(t,g),ss(f,t,c.total(),12e3,_,null,r)}d.setEditShapeCrackAndCluster(f,c.add(h));let v=d.difference(p,m);_!==null&&_.stitchCurves(f,v,g,!0);let y=$s(f.getGeometry(v),e,t,`-`);return As(y.getGeometryType())&&(y.getImpl().setIsSimple(4,c.total()),y.getGeometryType()===i.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Us(e,t,n,r){if(e.getDimension()>t.getDimension())return $s(ec(e),e,t,`^`);if(e.getDimension()<t.getDimension()||e.isEmpty())return $s(ec(t),e,t,`^`);if(t.isEmpty())return $s(ec(e),e,t,`^`);let a=new T;e.queryEnvelope(a);let o=new T;t.queryEnvelope(o);let s=new T;s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=new Xs(r),u=new N,d=u.addGeometry(ec(e)),f=u.addGeometry(ec(t)),p=0,m=null;if(u.hasCurves()){m=new _s;let e=u.getEnvelope2D(r);p=hs(c.total()),ss(u,ms(c.total(),e),c.total(),12e3,m,null,r)}l.setEditShapeCrackAndCluster(u,c);let h=l.symmetricDifference(d,f);m!==null&&m.stitchCurves(u,h,p,!0);let g=$s(u.getGeometry(h),e,t,`^`);return As(g.getGeometryType())&&(g.getImpl().setIsSimple(4,c.total()),g.getGeometryType()===i.enumPolygon&&g.getImpl().updateOGCFlagsProtected()),g}function Ws(e,t,n){return Zs(e,t,n,!0)}function Gs(e,t,n){return e.isEmpty()||t.isEmpty()?e.createInstance():bs(n,e,t)?new B({copy:xs(e,t)}):e.createInstance()}function Ks(e,t,n,r){let a=T.constructEmpty();e.queryEnvelope(a);let o=T.constructEmpty();t.queryEnvelope(o);let s=T.constructEmpty();s.setCoords({env2D:a}),s.mergeEnvelope2D(o);let c=je(n,s,!0),l=new T(o),u=Pe(c);if(l.inflateCoords(u,u),!a.isIntersecting(l)){if(e.getDimension()<=t.getDimension())return $s(ec(e.createInstance()),e,t,`&`);if(e.getDimension()>t.getDimension())return $s(ec(t.createInstance()),e,t,`&`)}let d=new Xs(r),f=new N,p=f.addGeometry(ec(e)),m=f.addGeometry(ec(t)),h=0,g=0,_=null;if(f.hasCurves()){_=new _s;let e=f.getEnvelope2D(r);g=hs(c.total());let t=ms(c.total(),e);h=gs(t,g),ss(f,t,c.total(),12e3,_,null,r)}d.setEditShapeCrackAndCluster(f,c.add(h));let v=d.intersection(p,m);_!==null&&_.stitchCurves(f,v,g,!0);let y=$s(f.getGeometry(v),e,t,`&`);return As(y.getGeometryType())&&(y.getImpl().setIsSimple(4,c.total()),y.getGeometryType()===i.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function qs(e,t,n,r){let a=[,,,],o=T.constructEmpty();e.queryEnvelope(o);let s=T.constructEmpty();t.queryEnvelope(s);let c=T.constructEmpty();c.setCoords({env2D:o}),c.mergeEnvelope2D(s);let l=je(n,c,!0),u=new T(s),d=Pe(l);if(u.inflateCoords(d,d),!o.isIntersecting(u)){if(e.getDimension()<=t.getDimension()){let n=$s(ec(e.createInstance()),e,t,`&`);return a[n.getDimension()]=n,a}if(e.getDimension()>t.getDimension()){let n=$s(ec(t.createInstance()),e,t,`&`);return a[n.getDimension()]=n,a}}let f=new Xs(r),p=new N,m=p.addGeometry(ec(e)),h=p.addGeometry(ec(t)),g=0,_=0,v=null;if(p.hasCurves()){v=new _s;let e=p.getEnvelope2D(r);_=hs(l.total());let t=ms(l.total(),e);g=gs(t,_),ss(p,t,l.total(),12e3,v,null,r)}f.setEditShapeCrackAndCluster(p,l.add(g)),p.dbgVerifyCurves();let y=f.intersectionEx(m,h);for(let n of y){v!==null&&v.stitchCurves(p,n,_,!1);let r=$s(p.getGeometry(n),e,t,`&`);As(r.getGeometryType())&&(r.getImpl().setIsSimple(4,l.total()),r.getGeometryType()===i.enumPolygon&&r.getImpl().updateOGCFlagsProtected()),a[r.getDimension()]=r}return v!==null&&v.clearStitcher(p),a}function Js(e,t,r,i,a,o=!1){t===0&&n(`not enough geometries to dissolve`);let s=0;for(let n=0,r=t;n<r;n++)s=Math.max(e[n].getDimension(),s);if(s===2||s===1)return new Xs(i).dissolveMultiPaths_(s,!1,e,t,r,a,o);let c=0,l=-1;for(let n=0,r=t;n<r;n++)e[n].getDimension()===s&&(l===-1&&(l=n),e[n].isEmpty()||(l=n,c++));if(c<2)return ec(e[l]);let u=Ge.constructEmpty(),d=new N,f=z;for(let n=0,r=t;n<r;n++)if(e[n].getDimension()===s&&!e[n].isEmpty()){f===z?f=d.addGeometry(ec(e[n])):d.appendGeometry(f,ec(e[n]));let t=Ge.constructEmpty();e[n].queryLooseEnvelope(t),u.mergeEnv3D(t)}let p=je(r,u.getEnvelope2D(),!0),m=new Xs(i);if(o){let e=Ke(r,u.getEnvelopeZs(),!0);return m.planarSimplify3DImpl_(d,p,e,0,!0)}return m.m_bOGCOutput=!0,m.planarSimplifyMultiPoints(d,p,!1,-1)}function Ys(e,t,r,i,a,o=!1){t<2&&n(`not enough geometries to dissolve`);let s=0;for(let n=0,r=t;n<r;n++)s=Math.max(e[n].getDimension(),s);if(s===2||s===1)return new Xs(i).dissolveMultiPaths_(s,!0,e,t,r,a,o);let c=Ge.constructEmpty(),l=new N,u=z,d=0,f=-1;for(let n=0,r=t;n<r;n++)if(e[n].getDimension()===s&&(f===-1&&(f=n),!e[n].isEmpty())){f=n,u===z?u=l.addGeometry(ec(e[n])):l.appendGeometry(u,ec(e[n]));let t=Ge.constructEmpty();e[n].queryLooseEnvelope(t),c.mergeEnv3D(t),d++}if(d<2)return ec(e[f]);let p=s===0?r:null,m=je(p,c.getEnvelope2D(),!0),h=new Xs(i);if(o){let e=Ke(p,c.getEnvelopeZs(),!0);return h.m_bOGCOutput=!0,h.planarSimplify3DImpl_(l,m,e,0,!0)}return h.planarSimplifyMultiPoints(l,m,!0,-1)}class Xs{m_progressTracker;m_topoGraph=null;m_maskLookup=[];m_dummyPt1=U.getNAN();m_dummyPt2=U.getNAN();m_fromEdgeForPolylines=z;m_progressCounter=0;m_bOGCOutput=!1;constructor(e){this.m_progressTracker=e}linesToPolygonsImpl(e,t){let n=0,r=0,i=null;if(e.hasCurves()){i=new _s;let a=e.getEnvelope2D(this.m_progressTracker);r=hs(t.total());let o=ms(t.total(),a);n=gs(o,r),ss(e,o,t.total(),12e3,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(n));let a=this.m_topoGraph.createUserIndexForChains(),o=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(o,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(o);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);let s=[];for(let t=this.m_topoGraph.getFirstChain();t!==z;t=this.m_topoGraph.getChainNext(t)){if(this.m_topoGraph.getChainUserIndex(t,a)===1)continue;this.m_topoGraph.setChainUserIndex(t,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);if(this.m_topoGraph.getChainArea(t)===0)continue;let n=this.m_topoGraph.extractPolygonFromChainAndIslands(e,z,t,z);i?.stitchCurves(e,n,r,!1);let o=e.getGeometry(n);s.push(o)}return new sn(s)}autoCompleteImpl(e,t,n){let r=0,i=0,a=null;if(e.hasCurves()){a=new _s;let t=e.getEnvelope2D(this.m_progressTracker);i=hs(n.total());let o=ms(n.total(),t);r=gs(o,i),ss(e,o,n.total(),12e3,a,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,n.add(r));let o=this.m_topoGraph.getGeometryID(t),s=this.m_topoGraph.createUserIndexForChains(),c=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(c,s,1);for(let e=this.m_topoGraph.getChainFirstIsland(c);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,s,1);let l=[];for(let t=this.m_topoGraph.getFirstChain();t!==z;t=this.m_topoGraph.getChainNext(t)){if(this.m_topoGraph.getChainUserIndex(t,s)===1)continue;this.m_topoGraph.setChainUserIndex(t,s,1);for(let e=this.m_topoGraph.getChainFirstIsland(t);e!==z;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,s,1);if(this.m_topoGraph.getChainParentage(t)!==0)continue;let n=this.m_topoGraph.getChainHalfEdge(t),r=n,c=!1;do{let e=this.m_topoGraph.getHalfEdgeTwin(r);if(this.m_topoGraph.getHalfEdgeChain(e)!==t&&(this.m_topoGraph.getHalfEdgeParentage(r)&o)!==0){c=!0;break}r=this.m_topoGraph.getHalfEdgeNext(r)}while(r!==n);if(!c||this.m_topoGraph.getChainArea(t)===0)continue;let u=this.m_topoGraph.extractPolygonFromChainAndIslands(e,z,t,z);a!==null&&a.stitchCurves(e,u,i,!1);let d=e.getGeometry(u);l.push(d)}return new sn(l)}setEditShape(e,t=!1){this.m_topoGraph===null&&(this.m_topoGraph=new sr),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){ys(e,t,this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,this.m_bOGCOutput,z,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){let n=this.m_topoGraph.getShape();for(let r=n.getFirstGeometry();r!==z;r=n.getNextGeometry(r))if(r===t)for(let t=n.getFirstPath(r);t!==z;t=n.getNextPath(t)){let r=n.getFirstVertex(t);if(r===z)continue;let i=n.getNextVertex(r);for(;i!==z;){let t=this.m_topoGraph.getClusterFromVertex(r),a=this.m_topoGraph.getClusterFromVertex(i),o=this.m_topoGraph.getHalfEdgeConnector(t,a);if(o!==z){let t=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}r=i,i=n.getNextVertex(r)}}}flushVertices_(e,t){let n=this.m_topoGraph.getShape(),r=n.hasSegmentParentage(),i=new F,a=n.insertPath(e,z);t.push(t[0]);let o=t.length,s=z;for(let e=0;e<o;e++){let c=t[e];if(s=n.addVertex(a,c),!r)continue;let l=this.m_topoGraph.getClusterFromVertex(c);if(e>0&&this.m_topoGraph.isBreakNode(l)&&n.setSegmentParentageBreakVertex(s,!0),e<o-1){let r=this.m_topoGraph.getHalfEdgeConnector(l,this.m_topoGraph.getClusterFromVertex(t[e+1])),a=this.m_topoGraph.getSegmentParentage(r);n.setSegmentParentageAndBreak(s,a,e>0||this.m_topoGraph.isBreakNode(l)),this.m_topoGraph.isHalfEdgeCurve(r)&&(this.m_topoGraph.querySegmentXY(r,i),n.setSegmentToIndex(n.getVertexIndex(s),i.get().clone()))}}if(r){let e=this.m_topoGraph.getClusterFromVertex(t[o-1]);this.m_topoGraph.isBreakNode(e)&&n.setSegmentParentageBreakVertex(s,!0)}n.setClosedPath(a,!0)}processPolygonCuts_(e,t,n,r){let a=this.m_topoGraph.getGeometryID(n),o=this.m_topoGraph.getGeometryID(r),s=[],c=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n)){let r=this.m_topoGraph.getClusterHalfEdge(n);if(r===z)continue;let u=r;do{if(this.m_topoGraph.getHalfEdgeUserIndex(u,l)!==1){let n=u,r=u,d=!1,f=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(n,l,1),d||(this.m_topoGraph.getHalfEdgeParentage(n)&o)!==0&&(this.m_topoGraph.getHalfEdgeFaceParentage(n)&a)!==0&&(r=n,d=!0),d){let t=this.m_topoGraph.getHalfEdgeOrigin(n),r=this.m_topoGraph.getClusterVertexIterator(t),i=this.m_topoGraph.getVertexFromVertexIterator(r);if(s.push(i),e!==-1&&(this.m_topoGraph.getHalfEdgeParentage(n)&o)!==0){let t=this.m_topoGraph.getHalfEdgeUserIndex(n,e);f|=t}}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==r);if(d&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(r))>0){let e=c.createGeometry(i.enumPolygon);this.flushVertices_(e,s),t!==-1&&c.setGeometryUserIndex(e,t,f)}s.length=0}u=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(u))}while(u!==r)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(e,t,n,r){this.m_topoGraph.removeSpikes_();let i=-1;e!==-1&&(i=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(i,n)),this.processPolygonCuts_(i,e,t,n),i!==-1&&(this.m_topoGraph.deleteUserIndexForHalfEdges(i),i=-1);let a=this.m_topoGraph.getShape();for(let e=a.getFirstGeometry();e!==z;e=a.getNextGeometry(e))e!==t&&e!==n&&r.push(e);r.sort((e,t)=>{let n=a.getFirstPath(e),r=a.getRingArea(n),i=a.getFirstPath(t),o=a.getRingArea(i);return r<o?-1:+(r>o)})}cut(e,t,n,r,i){let a=this.m_topoGraph.getShape().getGeometryType(n),s=this.m_topoGraph.getShape().getGeometryType(r),c=u(a),l=u(s);if(c===2&&l===1){this.cutPolygonPolyline_(t,n,r,i);return}if(c===1&&l===1){new nc(this,e,t,n,r,i).Do();return}o(``)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){let t=e.getGeometryType();if(t===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(a(t)){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n(`Unexpected geometry type`),e}dissolveNonSimplePolygons(e,t,n,r){l(t>0);let i=new N,a=0,o=-1;for(let n=0,r=t;n<r;n++)e[n].getDimension()===2&&(o===-1&&(o=n),e[n].isEmpty()||(a++,i.addGeometry(e[n])));return a===0?(l(o>=0),this.normalizeInputGeometry(e[o])):this.planarSimplifyPolygons(i,n,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,n,r,o,c,u){l(e>=1&&e<=2),l(r>0);let d=8&c?1:2,f=Ge.constructEmpty(),p=0,h=-1,g=!0;for(let t=0,a=r;t<a;t++)if(n[t].getDimension()===e&&(h===-1&&(h=t),!n[t].isEmpty())){h=t,p++;let r=Ge.constructEmpty();if(n[t].queryLooseEnvelope(r),f.mergeEnv3D(r),e===2&&g&&n[t].getGeometryType()===i.enumPolygon){if(c&16){let e=n[t].getImpl().getIsSimple(0,[0]),r=this.m_bOGCOutput?e===5:De(e);g&&=r}else{let e=$e(n[t],0);g&&=e}}}if(p<2&&(l(h>=0),p===0||!(c&16)))return this.normalizeInputGeometry(n[h]);if(!g){let e=je(t?null:o,f.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(n,r,e,c)}let _=n.slice(0,r),v=je(o,f.getEnvelope2D(),!0),y=Pe(v)*10,b=new Ne(0,0);if(u&&(b=Ke(o,f.getEnvelopeZs(),!0)),p===1&&e===1&&d===2&&!t)return u?zs():this.m_bOGCOutput?Is(_[h],v,!1,-1,this.m_progressTracker,d,!1):Ls(_[h],v,!1,!1,-1,this.m_progressTracker,d,!1);let x=new et;x.startConstruction();let S=e===2?3:4,C=0;for(let n=0,o=r;n<o;n++){if(_[n].getDimension()!==e||_[n].isEmpty())continue;let r=_[n].getGeometryType();if(r!==i.enumEnvelope){if(a(r)?(_[n]=this.normalizeInputGeometry(_[n]),r=i.enumPolyline):l(s(r)),e===1){l(r===i.enumPolyline);let e=-1;u?l(0,`3d not implemented yet`):e=_[n].getImpl().getIsSimple(v.total(),[0]),(this.m_bOGCOutput?e!==5:!De(e))&&(t?S=-1:(u?l(0,`3d not implemented yet`):this.m_bOGCOutput?_[n]=Is(_[n],v,!1,-1,this.m_progressTracker,d,!1):_[n]=Ls(_[n],v,!1,!1,-1,this.m_progressTracker,d,!1),l(De(_[n].getImpl().getIsSimple(v.total(),[0])))))}else{l(r===i.enumPolygon);let e=_[n].getImpl().getIsSimple(0,[0]);l(We(e))}let o=_[n].getImpl();for(let e=0,t=o.getPathCount();e<t;e++){let t=T.constructEmpty();o.queryLoosePathEnvelope(e,t),t.inflateCoords(y,y),x.addEnvelope(C,t),C++}}else{l(r===i.enumEnvelope);let e=T.constructEmpty();_[n].queryLooseEnvelope(e),e.inflateCoords(y,y),x.addEnvelope(C,e),C++,S=-1}}x.endConstruction();let w=C,D=H(w,-2147483647),O=H(w,-1),A=0;h=-1,C=0;for(let t=0,n=r;t<n;t++){if(_[t].getDimension()!==e||(h===-1&&(h=t),_[t].isEmpty()))continue;h=t,A++;let n=_[t].getGeometryType();if(s(n)){let e=_[t];for(let n=0,r=e.getPathCount();n<r;n++)O[C]=t,D[C]=-n-1,C++}else l(n===i.enumEnvelope),O[C]=t,D[C]=-1,C++}if(A<2&&e===2)return l(h>=0),this.normalizeInputGeometry(_[h]);let j=w;for(;x.next()&&j>0;){this.progress_();let e=x.getHandleA(),t=x.getHandleB(),n=x.getElement(e),r=x.getElement(t);O[n]!==O[r]&&(D[n]<0&&(j--,D[n]=-(D[n]+1)),D[r]<0&&(j--,D[r]=-(D[r]+1)))}let M=new N,P=!1,F=0;for(let t=0,n=r;t<n;t++){if(_[t].getDimension()!==e||_[t].isEmpty())continue;let n=_[t].getGeometryType(),r=F,a=0,o=0,c=s(n)?_[t]:null;for(let e=r,n=D.length;e<n&&O[e]===t;e++)D[e]>=0&&(a++,o+=c?c.getPathSize(D[e]):m(_[t])),F++;let u=m(_[t]);if(o>.95*u){M.addGeometry(this.normalizeInputGeometry(_[t]));for(let e=r;e<F;e++)D[e]<0&&(D[e]=-(D[e]+1))}else if(a===0){P=!0;continue}else{P=!0,l(s(n)),l(c!=null);let e=new k({vd:_[t].getDescription()}),a=new E({vd:_[t].getDescription()}),o=n===i.enumPolygon?e:a;for(let e=r;e<F;e++)D[e]>=0&&o.addPath(c,D[e],!0);M.addGeometry(o)}}let I=M.getFirstGeometry(),L;if(I!==z){let n=e===2,r=t?je(null,f.getEnvelope2D(),!0):v,i=new Ne(0,0);if(u&&(i=t?Ke(null,f.getEnvelopeZs(),!0):b),e===2&&!(c&2)){M.collapseAllGeometriesToFirst();let e=0,t=null;if(M.hasCurves()&&!M.hasSegmentParentage()){t=new _s;let n=M.getEnvelope2D(this.m_progressTracker);e=hs(r.total()),ss(M,ms(r.total(),n),r.total(),12e3,t,null,this.m_progressTracker)}Fr(M,M.getFirstGeometry(),r.total(),this.m_progressTracker),t!==null&&t.stitchCurves(M,z,e,!0)}if(u)L=this.planarSimplify3DImpl_(M,r,i,d,!0);else if(e===2)L=this.planarSimplifyPolygons(M,r,n,t,-1,!1);else{let e=Ps();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=d,L=this.planarSimplifyPolylines(M,r,t,e,-1)}P||(S=L.getImpl().getIsSimple(r.total(),[0]))}else l(P),l(h>=0),L=e===2?new k({vd:_[h].getDescription()}):new E({vd:_[h].getDescription()});if(P){let e=0;for(let t=0,n=D.length;t<n;t++){let n=O[t];if(!(n<0)&&D[t]<0){let r=_[n].getGeometryType(),i=s(r)?_[n]:null;if(i){let n=-(D[t]+1);e+=i.getPathSize(n)}else e+=4}}L.reserve(L.getPointCount()+e);for(let e=0,t=D.length;e<t;e++){let t=O[e];if(!(t<0)&&D[e]<0){let n=_[t].getGeometryType(),r=s(n)?_[t]:null;if(r){let t=-(D[e]+1);L.addPath(r,t,!0)}else n===i.enumEnvelope?L.addEnvelope(_[t],!1):(l(a(n)),L.addSegment(_[t],!0))}}}let R=0;if(e===2?S!==-1&&(S=3,R=t?0:v.total()):(l(e===1),!t&&S!==-1&&(R=v.total())),u||L.getImpl().setIsSimple(S,R),!t&&P){if(e===2){if(u)l(0,`3d not yet implemented`);else return new xc().execute(L,o,!1,this.m_progressTracker)}else e===1&&d!==1&&(L=u?Bs():Rs(this.m_bOGCOutput,L,d,this.m_progressTracker),L.getImpl().setIsSimple(S,R))}return L}dissolveTopoGraphCommonEdges_(){let e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n)){let r=this.m_topoGraph.getClusterHalfEdge(n),i=r;if(r!==z)do{if(this.progress_(),this.m_topoGraph.getHalfEdgeUserIndex(i,e)!==1){let n=this.m_topoGraph.getHalfEdgeTwin(i);this.m_topoGraph.setHalfEdgeUserIndex(n,e,1),this.m_topoGraph.setHalfEdgeUserIndex(i,e,1);let r=this.m_topoGraph.getHalfEdgeFaceParentage(i);if(this.isGoodParentage(r)){let e=this.m_topoGraph.getHalfEdgeFaceParentage(n);this.isGoodParentage(e)&&t.push(i)}}i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(i))}while(i!==r)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,n,r){let i=It(),a=z;for(let r=this.m_topoGraph.getClusterVertexIterator(e);r!==z;r=this.m_topoGraph.incrementVertexIterator(r)){let e=this.m_topoGraph.getVertexFromVertexIterator(r),o=t.getUserIndex(e,n);o>=0&&o<i&&(i=o,a=e)}l(a!==z);let o=t.getUserIndex(a,r);return o>0&&(t.setUserIndex(a,r,--o),o===0&&t.setUserIndex(a,n,-1)),a}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,n,r,a){let o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==i.enumPolygon)return;let s=o.hasSegmentParentage(),c=new F;for(let i=o.getFirstPath(e);i!==z;i=o.getNextPath(i)){let e=o.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);let l=this.m_topoGraph.getHalfEdgeFromVertex(e);if(l===z)continue;let u=this.m_topoGraph.getHalfEdgeUserIndex(l,n);if(u===1||u===2)continue;let d=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(!this.isGoodParentage(d)){this.m_topoGraph.setHalfEdgeUserIndex(l,n,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(l,n,1);let f=o.insertPath(t,z);o.setClosedPath(f,!0);let p=l,m=e,h=this.m_topoGraph.getClusterFromVertex(m),g=1;do{this.progress_();let e=this.chooseVertexFromVertexCluster_(m,a),t=o.addVertex(f,e);if(this.m_topoGraph.isHalfEdgeCurve(p)&&(this.m_topoGraph.querySegmentXY(p,c),o.setSegmentToIndex(o.getVertexIndex(t),c.get().clone())),s){let e=this.m_topoGraph.getSegmentParentage(p);o.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(h))}r!==-1&&this.m_topoGraph.setClusterUserIndex(h,r,1),this.m_topoGraph.setHalfEdgeUserIndex(p,n,1),p=this.m_topoGraph.getHalfEdgeNext(p);let i,l;do i=g===1?o.getNextVertex(m):o.getPrevVertex(m),l=i===z?z:this.m_topoGraph.getClusterFromVertex(i);while(l===h);let u=this.m_topoGraph.getHalfEdgeOrigin(p);if(u!==l){do i=g===1?o.getPrevVertex(m):o.getNextVertex(m),l=i===z?z:this.m_topoGraph.getClusterFromVertex(i);while(l===h);if(u!==l){l=u;let e=this.m_topoGraph.getClusterVertexIterator(l);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else g=-g}h=l,m=i}while(p!==l)}}topoOperationPolygonPolygonHelper_(e,t,n,r,i,a){this.progress_(!0),e!==z&&this.collectPolygonPathsPreservingFrom_(e,n,i,a,r),t!==z&&this.collectPolygonPathsPreservingFrom_(t,n,i,a,r);let o=new F,s=this.m_topoGraph.getShape();s.dbgVerifyCurves();let c=s.hasSegmentParentage();for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z)continue;let l=t;do{this.progress_();let e=this.m_topoGraph.getHalfEdgeUserIndex(l,i);if(e!==1&&e!==2){let e=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(e)){let e=s.insertPath(n,z);s.setClosedPath(e,!0);let t=l;do{let n=this.m_topoGraph.getHalfEdgeVertexIterator(t),l=z;if(n!==z)l=this.m_topoGraph.getVertexFromVertexIterator(n);else{let e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(t));l=this.m_topoGraph.getVertexFromVertexIterator(e),l=s.getNextVertex(l)}let u=this.chooseVertexFromVertexCluster_(l,r),d=s.addVertex(e,u);if(c){let e=this.m_topoGraph.getSegmentParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t);s.setSegmentParentageAndBreak(d,e,this.m_topoGraph.isBreakNode(n))}if(this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,o),s.setSegmentToIndex(s.getVertexIndex(d),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(t,i,1),a!==-1){let e=this.m_topoGraph.getClusterFromVertex(u);this.m_topoGraph.setClusterUserIndex(e,a,1)}t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,i,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==t)}}topoOperationPolygonPolygon_(e,t,n,r=!1){this.dissolveTopoGraphCommonEdges_();let a=this.m_topoGraph.getShape(),o=a.createGeometry(i.enumPolygon),s=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,n,s,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(s),r||ri(a,o,3,this.m_bOGCOutput,z,this.m_progressTracker),o}topoOperationPolyline_(e,t){let n=Ps();return n.allCrossRoadsImpassable=!1,n.ogcRule=t,n.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(z,e,!1,n).first}topoOperationMultiPoint_(){let e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),n=e.insertPath(t,z);for(let t=this.m_topoGraph.getFirstCluster();t!==z;t=this.m_topoGraph.getNextCluster(t)){let r=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(r)){let r=z;for(let n=this.m_topoGraph.getClusterVertexIterator(t);n!==z;n=this.m_topoGraph.incrementVertexIterator(n)){let t=this.m_topoGraph.getVertexFromVertexIterator(n);r===z&&(r=t);let i=e.getGeometryFromPath(e.getPathFromVertex(t)),a=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(a)){r=t;break}}e.addVertex(n,r)}}return t}intersection(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=u(n),a=u(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s|c]=!0;let d=z;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(d=e),i===2&&a===2)return this.topoOperationPolygonPolygon_(e,t,d);if(i===1&&a>0||a===1&&i>0)return this.topoOperationPolyline_(d,this.m_bOGCOutput);if(i===0||a===0)return this.topoOperationMultiPoint_();o(``)}topoOperationPolygonPolygonEx(e,t,n){let r=this.m_topoGraph.getShape(),a=r.createGeometry(i.enumPolygon),o=r.createGeometry(i.enumPolyline),s=r.createGeometry(i.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let c=z,l=this.m_topoGraph.createUserIndexForHalfEdges(),u=this.m_topoGraph.createUserIndexForClusters();r.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,a,n,l,u),r.dbgVerifyCurves();let d=r.hasSegmentParentage(),f=new F;for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){let t=this.m_topoGraph.getClusterHalfEdge(e);if(t===z)continue;let i=t;do{let t=this.m_topoGraph.getHalfEdgeUserIndex(i,l),a=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(i),l),s=t|a;if(s===2){let c=this.m_topoGraph.getHalfEdgeParentage(i);if(this.isGoodParentage(c)){let p=r.insertPath(o,z),m=i,h=this.chooseVertexFromCluster_(e,n),g=r.addVertex(p,h);if(d){let e=this.m_topoGraph.getSegmentParentage(i),t=this.m_topoGraph.getHalfEdgeOrigin(i);r.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}this.m_topoGraph.isHalfEdgeCurve(i)&&(this.m_topoGraph.querySegmentXY(i,f),r.setSegmentToIndex(r.getVertexIndex(g),f.get().clone())),this.m_topoGraph.setClusterUserIndex(e,u,1);do{this.progress_();let e=this.m_topoGraph.getHalfEdgeTo(m),o=this.chooseVertexFromCluster_(e,n);if(g=r.addVertex(p,o),d){let e=this.m_topoGraph.getSegmentParentage(i),t=this.m_topoGraph.getHalfEdgeOrigin(i);r.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.setHalfEdgeUserIndex(m,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l,1),this.m_topoGraph.setClusterUserIndex(e,u,1),m=this.m_topoGraph.getHalfEdgeNext(m),t=this.m_topoGraph.getHalfEdgeUserIndex(m,l),a=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l),s=t|a,s!==2)break;if(c=this.m_topoGraph.getHalfEdgeParentage(m),!this.isGoodParentage(c)){this.m_topoGraph.setHalfEdgeUserIndex(m,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(m),l,1);break}this.m_topoGraph.isHalfEdgeCurve(i)&&m!==i&&(this.m_topoGraph.querySegmentXY(i,f),r.setSegmentToIndex(r.getVertexIndex(g),f.get().clone()))}while(m!==i)}else this.m_topoGraph.setHalfEdgeUserIndex(i,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(i),l,1)}i=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(i))}while(i!==t)}for(let e=this.m_topoGraph.getFirstCluster();e!==z;e=this.m_topoGraph.getNextCluster(e)){if(this.progress_(),this.m_topoGraph.getClusterUserIndex(e,u)===1)continue;let t=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(t)){c===z&&(c=r.insertPath(s,z));let t=this.m_topoGraph.getClusterVertexIterator(e),i=z;if(t!==z){i=this.m_topoGraph.getVertexFromVertexIterator(t);let e=this.chooseVertexFromVertexCluster_(i,n);r.addVertex(c,e)}}}this.m_topoGraph.deleteUserIndexForClusters(u),this.m_topoGraph.deleteUserIndexForHalfEdges(l),r.dbgVerifyCurves(),ri(r,a,3,this.m_bOGCOutput,z,this.m_progressTracker);let p=[z,z,z];return p[0]=s,p[1]=o,p[2]=a,p}topoOperationPolylinePolylineOrPolygonEx(e,t){let n=Ps();return n.allCrossRoadsImpassable=!1,n.ogcRule=t,n.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(z,e,!0,n)}topoOperationMultiPoint(){let e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),n=e.insertPath(t,z);for(let t=this.m_topoGraph.getFirstCluster();t!==z;t=this.m_topoGraph.getNextCluster(t)){let r=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(r)){let r=z;for(let n=this.m_topoGraph.getClusterVertexIterator(t);n!==z;n=this.m_topoGraph.incrementVertexIterator(n)){let t=this.m_topoGraph.getVertexFromVertexIterator(n);r===z&&(r=t);let i=e.getGeometryFromPath(e.getPathFromVertex(t)),a=this.m_topoGraph.getGeometryID(i);if(this.isGoodParentage(a)){r=t;break}}e.addVertex(n,r)}}return t}intersectionEx(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=Ms(n),a=Ms(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s|c]=!0;let u=z;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(u=e),i===2&&a===2)return this.topoOperationPolygonPolygonEx(e,t,u);if(i===1&&a>0||a===1&&i>0){let{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(u,this.m_bOGCOutput);return[t,e]}if(i===0||a===0){let e=[];return e.push(this.topoOperationMultiPoint()),e}o(``)}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){let n=this.getCombinedHalfEdgeParentage(t),r=this.m_topoGraph.getHalfEdgeOrigin(t),i=this.m_topoGraph.getHalfEdgeTo(t),a=0,o=0;for(let s=this.m_topoGraph.getClusterVertexIterator(r);s!==z;s=this.m_topoGraph.incrementVertexIterator(s)){let r=this.m_topoGraph.getVertexFromVertexIterator(s),c=e.getPathFromVertex(r),l=e.getGeometryFromPath(c),u=this.m_topoGraph.getGeometryID(l),d=e.getFirstVertex(c),f=(u&n)!==0;f&&d===r&&(this.m_fromEdgeForPolylines=t);let p=e.getNextVertex(r);if(p!==z&&this.m_topoGraph.getClusterFromVertex(p)===i){if(a++,f){if(this.m_fromEdgeForPolylines===z&&d===p){let e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o++}}else{let n=e.getPrevVertex(r);if(n!==z&&this.m_topoGraph.getClusterFromVertex(n)===i&&(a--,f)){if(this.m_fromEdgeForPolylines===z&&d===n){let e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o--}}}this.m_topoGraph.queryXY(r,this.m_dummyPt1),this.m_topoGraph.queryXY(i,this.m_dummyPt2);let s=U.distance(this.m_dummyPt1,this.m_dummyPt2);return(o===0?a:o)*s}tryMoveThroughCrossroadBackwards(e,t){let n=this.m_topoGraph.getHalfEdgePrev(e),r=this.m_topoGraph.getHalfEdgeTwin(n);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return z;let t=this.m_topoGraph.getHalfEdgeTwin(e);if(r===this.m_topoGraph.getHalfEdgeNext(t))return n}let i=r,a=z;for(;i!==e;){let e=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(e)){if(a!==z)return z;a=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(i))}return a}tryMoveThroughCrossroadForward(e,t){let n=this.m_topoGraph.getHalfEdgeNext(e),r=this.m_topoGraph.getHalfEdgeTwin(n);if(!t){let t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return z;if(r===this.m_topoGraph.getHalfEdgePrev(t))return n}let i=r,a=z;for(;i!==e;){let e=this.getCombinedHalfEdgeParentage(i);if(this.isGoodParentage(e)){if(a!==z)return z;a=this.m_topoGraph.getHalfEdgeTwin(i)}i=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(i))}return a}isOnALoop(e,t){let n=e,r=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let i=0;i<r;i++){if(this.m_topoGraph.getHalfEdgeUserIndex(n,t)===1)return!1;let r=this.m_topoGraph.getHalfEdgeNext(n);if(r===this.m_topoGraph.getHalfEdgeTwin(n))return!1;if(n=r,n===e)return!0}o(`is_on_a_loop_`)}restorePolylineParts(e,t,n,r,i,a,o,s,c,u){l(i===z&&a>=0&&o>=0||a===-1&&o===-1),l(s===-1&&u.unsplitBehavior!==1||s!==-1&&u.unsplitBehavior===1);let d=u.ogcRule,f=u.allCrossRoadsImpassable,p=u.unsplitBehavior===1,m=u.unsplitBehavior===0,h=this.m_topoGraph.getShape(),g=h.hasSegmentParentage(),_=e,v=this.m_topoGraph.getHalfEdgeTwin(_),y=new F;this.m_fromEdgeForPolylines=z;let b=this.prevailingDirection(h,_),x=_,S=z,C=!1,w=!1,T=!1;if(!p)do{let t=this.m_topoGraph.getHalfEdgePrev(_);if(t===v){T=!0;break}let r=this.m_topoGraph.getHalfEdgeNext(v);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(r))){C=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==r){if(f){C=!0;break}if(_=this.tryMoveThroughCrossroadBackwards(_,!0),_===z){C=!0;break}v=this.m_topoGraph.getHalfEdgeTwin(_)}else _=t,v=r;if(this.m_topoGraph.getHalfEdgeUserIndex(_,n)===1){T=!0;break}if(_===e){S=e,w=!0;break}let i=this.getCombinedHalfEdgeParentage(_);if(!this.isGoodParentage(i))break;x=_,b+=this.prevailingDirection(h,_)}while(1);if(S===z){for(_=e,v=this.m_topoGraph.getHalfEdgeTwin(_),S=_;;){let e=this.m_topoGraph.getHalfEdgeNext(_),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){C=!0;break}if(e===v){T=!0;break}if(s!==-1){let e=this.m_topoGraph.getHalfEdgeOrigin(v);if(this.m_topoGraph.getClusterUserIndex(e,s)===1){C=!0;break}}let r=this.m_topoGraph.getHalfEdgePrev(v);if(this.m_topoGraph.getHalfEdgeTwin(e)!==r){if(t||f){C=!0;break}if(_=this.tryMoveThroughCrossroadForward(_,!0),_===z){C=!0;break}v=this.m_topoGraph.getHalfEdgeTwin(_)}else _=e,v=r;if(this.m_topoGraph.getHalfEdgeUserIndex(_,n)===1){T=!0;break}let i=this.getCombinedHalfEdgeParentage(_);if(!this.isGoodParentage(i))break;S=_,b+=this.prevailingDirection(h,_)}let t=this.m_topoGraph.getHalfEdgeOrigin(x);w=this.m_topoGraph.getHalfEdgeTo(S)===t}else if(this.m_fromEdgeForPolylines!==z){x=e,S=this.tryMoveThroughCrossroadBackwards(x,!1),l(S!==z);let t=this.m_topoGraph.getHalfEdgeTwin(x);this.m_topoGraph.getHalfEdgeNext(t)}let E=w;!w&&!T&&c&&(E=this.isOnALoop(e,n),E||=this.isOnALoop(v,n));let D=b>=0,O=!1;E&&C&&(w?(O=d,D&&(O||p||m)&&x!==e&&(l(!p),x=e,O=!1)):(p||D&&m)&&(x=e));let k=0;for(_=x;v=this.m_topoGraph.getHalfEdgeTwin(_),this.m_topoGraph.setHalfEdgeUserIndex(_,n,1),this.m_topoGraph.setHalfEdgeUserIndex(v,n,1),k++,_!==S;)_=f?this.m_topoGraph.getHalfEdgeNext(_):this.tryMoveThroughCrossroadForward(_,!1);D||(S=gt(x,x=S),S=this.m_topoGraph.getHalfEdgeTwin(S),x=this.m_topoGraph.getHalfEdgeTwin(x));let A=h.insertPath(t,z);_=x;let j=this.m_topoGraph.getHalfEdgeOrigin(x),M;M=a===-1?this.chooseVertexFromCluster_(j,i):this.chooseVertexByOrder(j,h,a,o),this.m_topoGraph.isStrongPathNode(j)&&h.setStrongPathStart(A,!0);let N=h.addVertex(A,M),P=N;r!==-1&&this.m_topoGraph.setClusterUserIndex(j,r,1);let I=0,L=O?Math.trunc((k+1)/2):-1,R=z,ee=!0,te=z;for(;;){if(g){let e=this.m_topoGraph.getSegmentParentage(_),t=this.m_topoGraph.getHalfEdgeOrigin(_);h.setSegmentParentageAndBreak(P,e,ee||this.m_topoGraph.isBreakNode(t))}ee=!1,this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,y),h.setSegmentToIndex(h.getVertexIndex(P),y.get().clone())),R!==z&&o!==-1&&h.addToUserIndex(R,o,-1);let e=f?this.m_topoGraph.getHalfEdgeNext(_):this.tryMoveThroughCrossroadForward(_,!1),n=this.m_topoGraph.getHalfEdgeTo(_),s;if(s=a===-1?this.chooseVertexFromCluster_(n,i):this.chooseVertexByOrder(n,h,a,o),N=h.addVertex(A,s),te=n,r!==-1&&this.m_topoGraph.setClusterUserIndex(n,r,1),g&&this.m_topoGraph.isBreakNode(n)&&h.setSegmentParentageBreakVertex(N,!0),R=s,I++,O&&I===L&&(A=h.insertPath(t,z),N=h.addVertex(A,s),ee=!0,o!==-1&&h.addToUserIndex(s,o,-1),R=z),_===S)break;_=e,P=N}te!==z&&this.m_topoGraph.isStrongPathNode(te)&&h.setStrongPathEnd(A,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,n,r){l(t===z||e===z);let a=this.m_topoGraph.getShape(),o=t=>(t=e===z?t===z?a.getFirstGeometry():a.getNextGeometry(t):t===z?e:z,t),s=a.createGeometry(i.enumPolyline),c=-1;n&&(c=this.m_topoGraph.createUserIndexForClusters());let u=this.m_topoGraph.createUserIndexForHalfEdges(),d=t===z?a.createUserIndex():-1,f=t===z?a.createUserIndex():-1,p=-1;if(r.unsplitBehavior===1){p=this.m_topoGraph.createUserIndexForClusters();for(let e=o(z);e!==z;e=o(e))for(let t=a.getFirstPath(e);t!==z;t=a.getNextPath(t)){{let e=a.getFirstVertex(t),n=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(n,p,1)}if(!a.isClosedPath(t)){let e=a.getLastVertex(t),n=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(n,p,1)}}}if(t===z){let e=0;for(let t=o(z);t!==z;t=o(t))for(let n=a.getFirstPath(t);n!==z;n=a.getNextPath(n))if(a.isClosedPath(n)){let t=a.getFirstVertex(n);for(let r=0,i=a.getPathSize(n);r<i;r++,t=a.getNextVertex(t))a.setUserIndex(t,d,e++),a.setUserIndex(t,f,2)}else{let t=a.getFirstVertex(n);a.setUserIndex(t,d,e++),a.setUserIndex(t,f,1);let r=a.getNextVertex(t);for(let t=1,i=a.getPathSize(n)-1;t<i;++t)a.setUserIndex(r,d,e++),a.setUserIndex(r,f,2),r=a.getNextVertex(r);a.setUserIndex(r,d,e++),a.setUserIndex(r,f,1)}}for(let e=o(z);e!==z;e=o(e))for(let n=a.getFirstPath(e);n!==z;n=a.getNextPath(n)){let e=a.getFirstVertex(n);for(let i=0,o=a.getPathSize(n);i<o;i++,e=a.getNextVertex(e)){let n=this.m_topoGraph.getHalfEdgeFromVertex(e);if(n===z||this.m_topoGraph.getHalfEdgeUserIndex(n,u)===1)continue;let a=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(a)){let e=i===0;this.restorePolylineParts(n,s,u,c,t,d,f,p,e,r)}}}let m=z;if(n){m=a.createGeometry(i.enumMultiPoint);let e=z;for(let n=this.m_topoGraph.getFirstCluster();n!==z;n=this.m_topoGraph.getNextCluster(n))if(this.progress_(),this.m_topoGraph.getClusterUserIndex(n,c)!==1){let r=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(r)){e===z&&(e=a.insertPath(m,z));let r=this.m_topoGraph.getClusterVertexIterator(n);if(r!==z){this.m_topoGraph.getVertexFromVertexIterator(r);let i;i=d===-1?this.chooseVertexFromCluster_(n,t):this.chooseVertexByOrder(n,a,d,f),a.addVertex(e,i)}}}}return f!==-1&&a.removeUserIndex(f),d!==-1&&a.removeUserIndex(d),c!==-1&&a.removeUserIndex(c),this.m_topoGraph.deleteUserIndexForHalfEdges(u),yt(s,m)}difference(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=u(n),a=u(r);if(i>a)return e;let s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s]=!0,i===2&&a===2){let n=z;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(n=e),this.topoOperationPolygonPolygon_(e,t,n)}if(i===1&&a===2){let t=Ps();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}if(i===1&&a===1){let t=Ps();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,z,!1,t).first}if(i===0)return this.topoOperationMultiPoint_();o(``)}symmetricDifference(e,t){let n=this.m_topoGraph.getShape().getGeometryType(e),r=this.m_topoGraph.getShape().getGeometryType(t),i=Ms(n),a=Ms(r),s=this.m_topoGraph.getGeometryID(e),c=this.m_topoGraph.getGeometryID(t);if(l(s>=0),l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=(s|c)+1,this.m_maskLookup[s]=!0,this.m_maskLookup[s]=!0,this.m_maskLookup[c]=!0,i===2&&a===2)return this.topoOperationPolygonPolygon_(e,t,z);if(i===1&&a===1)return this.topoOperationPolyline_(z,this.m_bOGCOutput);if(i===0&&a===0)return this.topoOperationMultiPoint();o(``)}planarSimplifyNoCrackingAndCluster(e,t,n,r){this.m_bOGCOutput=e,this.m_topoGraph=new sr;let a=t.getFillRule(n),s=t.getGeometryType(n);if(a!==1||s===i.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let c=this.m_topoGraph.getGeometryID(n);if(l(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0,t.getGeometryType(n)===i.enumPolygon||a===1&&t.getGeometryType(n)!==i.enumMultiPoint){t.setFillRule(n,0);let i=this.topoOperationPolygonPolygon_(n,z,z);if(t.swapGeometry(i,n),t.removeGeometry(i),a===1&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,n,r)}else if(t.getGeometryType(n)===i.enumPolyline){let e=Ps();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=r;let i=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(i,n),t.removeGeometry(i)}else if(t.getGeometryType(n)===i.enumMultiPoint){let e=this.topoOperationMultiPoint_();t.swapGeometry(e,n),t.removeGeometry(e)}else o(``);return!0}unsplitPolylineExact(e){return l(0),new E}planarSimplifyPolylines(e,t,n,r,a){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let n=e.getGeometryType(t);l(n===i.enumPolyline)}let o=0,s=0,c=null;if(e.hasCurves()&&!e.hasSegmentParentage()){c=new _s;let n=e.getEnvelope2D(this.m_progressTracker);s=hs(t.total());let r=ms(t.total(),n);o=gs(r,s),ss(e,r,t.total(),12e3,c,null,this.m_progressTracker)}{let n=ws(t.add(o));e.filterClosePoints(n,!1,!1,!1,z)}if(this.m_topoGraph=new sr,a!==4&&a!==5){if(c===null&&n){let r=new Pr(this.m_progressTracker,!1);r.sweepVertical(e,t.total()),r.hadComplications()?(ys(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ys(e,t.add(o),this.m_progressTracker,!0,!1),n=!1}else n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();let u=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,u,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n&&c===null),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,r,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let d=this.m_topoGraph.getGeometryID(u);l(d>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=d+1,this.m_maskLookup[d]=!0;let f=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),r);c!==null&&c.stitchCurves(e,f,s,!0);let p=e.getGeometry(f);return n||p.getImpl().setIsSimple(4,t.total()),p}planarSimplifyMultiPoints(e,t,n,r){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let n=e.getGeometryType(t);l(n===i.enumMultiPoint)}this.m_topoGraph=new sr,r!==4&&r!==5&&ys(e,t,this.m_progressTracker,!0,!1),n=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();let a=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,a,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let o=this.m_topoGraph.getGeometryID(a);l(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0;let s=this.topoOperationMultiPoint(),c=e.getGeometry(s);return n||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyPolygons(e,t,n,r,a,o){for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t)){let r=e.getGeometryType(t);l(r===i.enumPolygon||r===i.enumPolyline&&n)}let s=0,c=0,u=null;if(e.hasCurves()&&!e.hasSegmentParentage()){u=new _s;let n=e.getEnvelope2D(this.m_progressTracker);c=hs(t.total());let r=ms(t.total(),n);s=gs(r,c),ss(e,r,t.total(),12e3,u,null,this.m_progressTracker)}if(o){ys(e,t.add(s),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==z;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&ri(e,t,-1,!1,z,this.m_progressTracker)}if(this.m_topoGraph=new sr,!o&&a!==4&&a!==5){if(u===null&&r){let n=new Pr(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(ys(e,t,this.m_progressTracker,!0,!1),r=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ys(e,t.add(s),this.m_progressTracker,!0,!1),r=!1}else r=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();let d=e.getFirstGeometry();if(n?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,d,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,d,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(r&&u===null),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,n,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(NaN);let f=this.m_topoGraph.getGeometryID(d);l(f>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=f+1,this.m_maskLookup[f]=!0,e.setFillRule(d,0);let p=this.m_bOGCOutput&&n,m=p,h=this.topoOperationPolygonPolygon_(d,z,z,m);p&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(d),this.m_topoGraph=new sr,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,h,this.m_progressTracker),h=this.topoOperationPolygonPolygon_(h,z,z,!1)),u!==null&&u.stitchCurves(e,h,c,!0);let g=e.getGeometry(h);return g.setFillRule(0),r?g.getImpl().setIsSimple(3,0):(g.getImpl().setIsSimple(4,t.total()),g.getImpl().updateOGCFlagsProtected()),g}planarSimplify3DImpl_(e,t,n,r,i){return l(0),{}}planarSimplifyImpl_(e,t,n,r,a,s,c,l){if(e.isEmpty())return e.clone();let u=e.getGeometryType(),d=new N,f=d.addGeometry(e);if(We(a)&&u===i.enumPolygon&&(n=!1,d.setFillRule(f,0)),l&&(e.hasAttribute(1)&&d.replaceNaNs(1,0),d.removeNaNVertices()),u===i.enumPolygon||u===i.enumPolyline&&n)return this.planarSimplifyPolygons(d,t,n,r,a,!1);if(u===E.type){let e=Ps();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=c,this.planarSimplifyPolylines(d,t,r,e,a)}if(u===i.enumMultiPoint)return this.planarSimplifyMultiPoints(d,t,r,a);o(`what else?`)}}function Zs(e,t,n,r){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return r?e.createInstance():new B({copy:e});let i=[new U],a=[0],s=t.getDimension()===2;return t.getDimension()!==1&&t.getDimension()!==2&&o(``),i[0]=e.getXY(),s?Yo(t,i,1,n.total(),a):Xo(t,i,1,n.total(),a),a[0]===0?e.createInstance():e}function Qs(e,t,n,r){let i=e.createInstance(),a=bt(U,100),s=Array(100),c=e.getPointCount(),l=!0,u=t.getDimension()===2;t.getDimension()!==1&&t.getDimension()!==2&&o(``);for(let r=0;r<c;){let o=e.queryCoordinates(a,a.length,r,-1)-r;u?Yo(t,a,o,n.total(),s):Xo(t,a,o,n.total(),s);let c=0;for(let t=0;t<o;t++)s[t]===0&&(l&&(l=!1,i.addPoints(e,0,r)),c!==t&&i.addPoints(e,r+c,r+t),c=t+1);!l&&c!==o&&i.addPoints(e,r+c,r+o),r+=o}return l?e:i}function $s(e,t,n,r){let a=e.getGeometryType();if(a===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(a===i.enumPoint&&(r===`|`||r===`^`)){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(a===i.enumLine){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(a===i.enumMultiPoint&&r===`-`&&t.getGeometryType()===i.enumPoint){let t=new B({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(a===i.enumMultiPoint&&r===`&`&&t.getGeometryType()===i.enumPoint){let t=new B({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function ec(e){let t=e.getGeometryType();if(t===i.enumEnvelope){let t=new k({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){let t=new A({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(js(t)){let t=new E({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n(`Unexpected geometry type`),e}function tc(e,t,n,r){let i=n===z?e.getClusterHalfEdge(t):n,a=i;l(e.getHalfEdgeOrigin(i)===t);do r(a),a=e.getHalfEdgeNext(e.getHalfEdgeTwin(a));while(a!==i)}class nc{m_rParent;m_rTopoGraph;m_rShape;m_rCutHandles;m_IDCuttee;m_IDCutter;m_IDBoth;m_sideIndex;m_cutteeBreadcrumbsIndex;m_clusterParentageIndex;m_cuttee;m_cutter;m_bConsiderTouch;constructor(e,t,n,r,i,a){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(r),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(i),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=n,this.m_cuttee=r,this.m_cutter=i,this.m_rCutHandles=a,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let t=0,n=this.m_rShape.getPathSize(e);for(let r=this.m_rShape.getFirstVertex(e);t<n;t++,r=this.m_rShape.getNextVertex(r))this.m_rShape.setUserIndex(r,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(r)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return e|8}classifyStandardCut(e,t,n,r){let i=this.m_rShape.getPrevVertex(e),a=this.m_rShape.getNextVertex(e),o=i===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),s=a===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(a)),c=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n)),l=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),u=1,d=32,f=32;if(tc(this.m_rTopoGraph,t,l,e=>{e===c&&(u=2),e===o&&(d=u),e===s&&(f=u)}),this.m_bConsiderTouch)d!==32&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|d),f!==32&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|f);else{if(d===32||f===32||d===f&&o!==c&&o!==l&&s!==c&&s!==l)return 1;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|d),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|f)}return 0}classifyTouchCut(e,t,n,r){let i=this.m_rShape.getPrevVertex(e),a=this.m_rShape.getNextVertex(e),o=i===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),s=a===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(a)),c=n===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n)),l=r===z?z:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r));if(!this.m_bConsiderTouch){let t;return(t=c===o||l===o)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=c===s||l===s)&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),+!t}if(o===z)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===z)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;if(o===s)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(l!==z){if(o===l)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===l)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let n=1;tc(this.m_rTopoGraph,t,l,t=>{if(t===o){let e=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,e),n=2}else if(t===s){let t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),n=2}})}else{if(o===c)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(s===c)return this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex))),0;let n=2;tc(this.m_rTopoGraph,t,c,t=>{if(t===o){let e=this.m_rShape.getUserIndex(i,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,e),n=1}else if(t===s){let t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|n;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),n=1}})}return 0}classifyCutVertex(e,t){let n=0,r=0;for(let i=this.m_rTopoGraph.getClusterVertexIterator(t);i!==z;i=this.m_rTopoGraph.incrementVertexIterator(i)){let a=this.m_rTopoGraph.getVertexFromVertexIterator(i);if(this.m_rShape.getGeometryFromVertex(a)===this.m_cutter){r++;let i=this.m_rShape.getPrevVertex(a),o=this.m_rShape.getNextVertex(a);n+=i===z||o===z?this.classifyTouchCut(e,t,i,o):this.classifyStandardCut(e,t,i,o)}}r&&n===r&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let t=this.m_rShape.getPathSize(e),n=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,n=this.m_rShape.getNextVertex(n))this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,0);n=this.m_rShape.getFirstVertex(e);for(let e=0;e<t;++e,n=this.m_rShape.getNextVertex(n)){let e=this.m_rTopoGraph.getClusterFromVertex(n);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(n,e)}}let e=(e,t)=>{let n=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex),r=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(r)&this.m_IDBoth)===this.m_IDBoth&&(n|=4),n};for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==z;t=this.m_rShape.getNextPath(t)){let n=this.m_rShape.getFirstVertex(t),r=this.m_rShape.isClosedPath(t),i=this.m_rShape.getPathSize(t)+ +!!r,a=1,o=32;for(let t=this.m_rShape.getNextVertex(n);a<i;++a,n=t,t=this.m_rShape.getNextVertex(t)){let r=e(n,t);this.m_rShape.getUserIndex(n,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=r),o!==32&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,o|r)}n=this.m_rShape.getLastVertex(t);let s=32;a=1;for(let t=this.m_rShape.getPrevVertex(n);a<i;++a,n=t,t=this.m_rShape.getPrevVertex(t)){let r=e(t,n);this.m_rShape.getUserIndex(n,this.m_clusterParentageIndex)===this.m_IDBoth&&(s=r),s!==32&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,s|r)}}let t=z,n=z,r=32,a=this.m_rShape.hasSegmentParentage(),o=new F;for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==z;e=this.m_rShape.getNextPath(e)){let s=this.m_rShape.isClosedPath(e),c=this.m_rShape.getPathSize(e)+ +!!s,l=1,u=this.m_rShape.getFirstVertex(e),d=z,f=!0;for(let e=this.m_rShape.getNextVertex(u);l<c;++l,e=this.m_rShape.getNextVertex(e)){let s=this.m_rShape.getUserIndex(u,this.m_cutteeBreadcrumbsIndex);s===8?s=3:(s&=-9,s&4?s=4:(s&3)==3&&(s=3)),s===r?this.m_rShape.getUserIndex(u,this.m_clusterParentageIndex)===this.m_IDBoth&&s!==4&&(d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),n=this.m_rShape.insertPath(t,z),f=!0):(t!==z&&(d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,r)),t=this.m_rShape.createGeometry(i.enumPolyline),n=this.m_rShape.insertPath(t,z),r=s,f=!0),d=this.m_rShape.addVertex(n,u);let c=this.m_rTopoGraph.getClusterFromVertex(u);!f&&a&&this.m_rTopoGraph.isBreakNode(c)&&this.m_rShape.setSegmentParentageBreakVertex(d,!0);let l=this.m_rTopoGraph.getHalfEdgeFromVertex(u);if(a){let e=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(d,e,f||this.m_rTopoGraph.isBreakNode(c))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,o),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(d),o.get().clone())),u=e,f=!1}d=this.m_rShape.addVertex(n,u),a&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(d,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,r),t=z,n=z,r=32}}}function rc(e,t,n){return new Xs(n).linesToPolygonsImpl(e,t)}function ic(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=new T;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),oc(a,t,n,r,s)}let u=e.getImpl().getIsSimple(l,[0]),d=n?-1:u;if(De(d)||d===0)return d;let f=new bc(e,t,d,s,!1);return c===i.enumMultiPoint||c===i.enumPolyline||c===i.enumPolygon?d=f.isSimplePlanarImpl():o(``),e.getImpl().setIsSimple(d,l),r&&r.assign(f.m_nonSimpleResult),d}function ac(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=new T;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),ac(a,t,n,r,s)}d(c),f(c)||p(`OGC simplify is not implemented for this geometry type`);let u=e.getImpl().getIsSimple(l,[0]),m=n?-1:u;if(m===5||m===0)return m;let h=new bc(e,t,m,s,!0);return c===i.enumMultiPoint||c===i.enumPolyline||c===i.enumPolygon?(m=h.isSimplePlanarImpl(),De(m)&&(m=5)):o(``),e.getImpl().setIsSimple(m,l),r&&r.assign(h.m_nonSimpleResult),m}function oc(e,t,n,r,s){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;let c=e.getGeometryType();if(c===i.enumPoint)return lc(e,r);let l=Te(t,e,!1).total();if(c===i.enumEnvelope){let t=e,n=T.constructEmpty();return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(a(c)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),oc(a,t,n,r,s)}let u=e.getImpl().getIsSimple(l,[0]),d=n?-1:u;if(d!==-1)return d;let f=new bc(e,t,d,s,!1);return c===i.enumMultiPoint?d=f.multipointIsSimpleAsFeature():c===i.enumPolyline?d=f.polylineIsSimpleAsFeature():c===i.enumPolygon?d=f.polygonIsSimpleAsFeature():o(``),e.getImpl().setIsSimple(d,l),r&&r.assign(f.m_nonSimpleResult),d}function sc(e,t,n,r){if(e.isEmpty())return e;let s=e.getGeometryType();if(s===i.enumPoint){let t=new J;if(lc(e,t),t.m_reason===3){let t=e.clone();return t.replaceNaNs(1,0),t}return t.m_reason===2?e.createInstance():e}if(s===i.enumEnvelope){let n=Te(t,e,!0).total(),r=e,i=T.constructEmpty();return r.queryEnvelope(i),i.isDegenerate(n)?r.createInstance():e}if(a(s)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),sc(a,t,n,r)}d(s);let c=Te(t,e,!1).total(),l=e.getImpl().getIsSimple(c,[0]),u=n?-1:l;if(De(u)){if(s===i.enumPolygon&&e.getFillRule()!==0){let t=e.clone();return t.setFillRule(0),t}return e}if((s===i.enumMultiPoint||s===i.enumPolyline)&&u>=1)return e;let f=new bc(e,t,u,r,!1),p;return s===i.enumMultiPoint?p=f.multipointSimplifyAsFeature():s===i.enumPolyline?p=f.polylineSimplifyAsFeature():s===i.enumPolygon?p=f.polygonSimplifyAsFeature():o(``),p}function cc(e,t,n,r){if(e.isEmpty())return e;let o=e.getGeometryType();if(o===i.enumPoint){let t=new J;if(lc(e,t),t.m_reason===3){let t=e.clone();return t.replaceNaNs(1,0),t}return t.m_reason===2?e.createInstance():e}if(o===i.enumEnvelope){let n=e,r=new T;n.queryEnvelope(r);let i=Te(t,e,!0).total();return r.isDegenerate(i)?n.createInstance():e}if(a(o)){let i=e,a=new E({vd:i.getDescription()});return a.addSegment(i,!0),cc(a,t,n,r)}d(o),f(o)||p(`OGC simplify is not implemented for this geometry type`);let s=Te(t,e,!1).total(),c=e.getImpl().getIsSimple(s,[0]),l=n?-1:c;if(l===5){if(o===i.enumPolygon&&e.getFillRule()!==0){let t=e.clone();return t.setFillRule(0),t}return e}return Is(e,Te(t,e,!0),!1,l,r,0,!0)}function lc(e,t){let n=e.getX(),r=e.getY();if(!Number.isFinite(n)||!Number.isFinite(r))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){let n=e.getZ();if(!Number.isFinite(n))return t&&(t.m_reason=Number.isNaN(n)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class uc{m_segment=null;m_vertexIndex=-1;m_pathIndex=-1;m_flags=0;setReversed(e){this.m_flags&=-2,this.m_flags|=+!!e}getReversed(){return!!(this.m_flags&1)}getRightSide(){return+!this.getReversed()}}function dc(){return{x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1}}function fc(e,t,n,r,i){return{x:e,y:t,ipath:n,ivertex:r,ipolygon:i}}function pc(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function mc(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function hc(){return{x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1}}function gc(e,t,n,r,i,a){return{x:e,y:t,ipath:n,ivertex:r,bBoundary:i,bEndPoint:a}}function _c(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.bBoundary=t.bBoundary,e.bEndPoint=t.bEndPoint}class vc extends tt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*r);return i<0?-1:+(i>0)}}class yc extends tt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,n){let r=e.getElement(n),i=this.m_helper.m_edges[t],a=this.m_helper.m_edges[r],o=i.getReversed(),s=a.getReversed(),c=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),l=a.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(c===l){let e=o?i.m_segment.getStartY():i.m_segment.getEndY(),t=s?a.m_segment.getStartY():a.m_segment.getEndY(),n=Math.min(e,t),r=(n-this.m_helper.m_yScanline)*.5+this.m_helper.m_yScanline;r===this.m_helper.m_yScanline&&(r=n),c=i.m_segment.intersectionOfYMonotonicWithAxisX(r,0),l=a.m_segment.intersectionOfYMonotonicWithAxisX(r,0)}return c<l?-1:+(c>l)}}class bc{m_description;m_geometry;m_multiVertexGeom=null;m_sr;m_toleranceIsSimpleClustering;m_toleranceIsSimpleCracking;m_toleranceIsSimple;m_toleranceSimplify;m_knownSimpleResult;m_attributeCount;m_edges=[];m_freeEdges=[];m_lineEdgesRecycle=[];m_newEdges=[];m_recycledSegIter=null;m_crossOverHelperList=new Fe;m_progressTracker=null;m_progressCounter=0;m_AET=new Ie;m_xyToNode1=null;m_xyToNode2=null;m_pathOrientations=null;m_pathParentage=null;m_unknownOrientationPathCount;m_yScanline;m_xy=null;m_pairs=[];m_pairIndices=null;m_pathsForOGCTests=[];m_curveStitcher=null;m_editShape=null;m_multiPathStitcher=null;m_bOGCRestrictions;m_bPlanarSimplify;m_nonSimpleResult=new J;constructor(e,t,n,r,i){this.m_progressCounter=0,this.m_progressTracker=r,this.m_geometry=e,this.m_knownSimpleResult=n,this.m_sr=t;let a=Te(t,e,!1);this.m_toleranceIsSimple=a,this.m_toleranceIsSimpleClustering=Pe(a),this.m_toleranceIsSimpleCracking=Le(a),this.m_toleranceSimplify=Te(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=i,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;let e=this.m_geometry.getGeometryType();return s(e)&&!this.checkDegenerateSegments(!1)||!this._CheckClustering()?0:s(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5}isSimplePlanarImpl3D(){return l(0),7}generateSortedPairs(e){let t=null;s(e.getGeometryType())&&(t=e);let n=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&t!==null,r=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new Re(0),n&&(this.m_pathsForOGCTests.length=0);let i=0;for(let e=0;e<r;e++)if(this.m_pairs.push(2*e),this.m_pairs.push(2*e+1),this.m_pairIndices.add(2*e),this.m_pairIndices.add(2*e+1),n){for(;e>=t.getPathEnd(i);)i++;this.m_pathsForOGCTests.push(i)}let a=new ze,o={parent:this,workPt:new U,userSort(e,t,r){r.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,n))},getValue(e){let t=this.parent.m_pairs[e],n=t>>1;return this.parent.m_xy.queryPoint2D(2*n,this.workPt),this.workPt.y+(t&1?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};a.sort(this.m_pairIndices,0,2*r,o)}_TestToleranceDistancePlanar(e,t){let n=this.m_xy.read(2*e),r=this.m_xy.read(2*e+1),i=this.m_xy.read(2*t),a=this.m_xy.read(2*t+1);return!pr(n,r,i,a,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||this.m_geometry.getDimension()!==0&&n===i&&r===a}checkStructure(){let e=this.m_geometry.getGeometryType();if(s(e)){let e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.enumPolygon?3:2;for(let n=0,r=e.getPathCount();n<r;n++)if(e.getPathSize(n)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(n)&&e.getPathSize(n)>0)continue;return this.m_nonSimpleResult=new J(1,n,0),!1}}if(f(e)){let e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let n=0,r=e.getPointCount();n<r;n++)if(!t.readPoint2D(n*2).isFinite())return this.m_nonSimpleResult=new J(2,n,0),!1;if(this.m_geometry.hasAttribute(1)){let t=e.getAttributeStreamRef(1);for(let n=0,r=e.getPointCount();n<r;n++){let e=t.read(n);if(!Number.isFinite(e))return this.m_nonSimpleResult=Number.isNaN(e)?new J(3,n,0):new J(2,n,0),!1}}}return!0}checkDegenerateSegments(e){let t=this.m_geometry.getImpl(),n=t.querySegmentIterator(),r=t.hasAttribute(1),i=r?Be(this.m_sr,t,!1).total():0,a=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;n.nextPath();)for(;n.hasNextSegment();){let t=n.nextSegment(),s=t.calculateLowerLength2D();if(!(s>o)&&!(a&&t.isCurve()&&(s=t.calculateLength2D(),s>o))){if(e&&r){let e=t.getStartAttributeAsDbl(1,0),n=t.getEndAttributeAsDbl(1,0);if(Math.abs(n-e)>i)continue}return this.m_nonSimpleResult=new J(4,n.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return l(0),!1}_CheckClustering(){let e=this.m_geometry.getImpl();this.generateSortedPairs(e);let t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new vc(this)),this.m_AET.setCapacity(t);for(let e=0,n=t*2;e<n;e++){this.progress_();let t=this.m_pairIndices.read(e),n=this.m_pairs[t],r=n>>1;if(n&1){let e=this.m_AET.search(r),t=this.m_AET.getPrev(e),n=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==Ie.st_nullNode()&&n!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(n)))return this.m_nonSimpleResult=new J(5,this.m_AET.getElement(t),this.m_AET.getElement(n)),!1}else{let e=this.m_AET.addElement(r),t=this.m_AET.getPrev(e);if(t!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),r))return this.m_nonSimpleResult=new J(5,r,this.m_AET.getElement(t)),!1;let n=this.m_AET.getNext(e);if(n!==Ie.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(n),r))return this.m_nonSimpleResult=new J(5,r,this.m_AET.getElement(n)),!1}}return!0}_CheckCracking(){let e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new N,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new _s;let e=T.constructEmpty();this.m_geometry.queryEnvelope(e);let t=ms(this.m_toleranceSimplify.total(),e),n=new J;if(us(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,n,this.m_curveStitcher,null,this.m_progressTracker),n.m_reason!==0)return this.m_editShape=null,this.m_nonSimpleResult.assign(n),!1}let e=new J;return Br(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(this.m_curveStitcher==null?(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)):(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(this.m_curveStitcher??(this.m_editShape=null),!0)}_CheckCrackingBrute(){let e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),n=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){let e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){n.resetTo(t);do for(;n.hasNextSegment();){let r=n.nextSegment(),i=L(!0,e,r,this.m_toleranceIsSimpleCracking,!0);if(i){let e=i===2?7:6;return this.m_nonSimpleResult=new J(e,t.getStartPointIndex(),n.getStartPointIndex()),!1}}while(n.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();this.m_curveStitcher!==null&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);let t=[],n=e.getPointCount(),r=NaN,i=0;for(let e=0,a=n*2;e<a;e++){this.progress_();let n=this.m_pairIndices.read(e),a=this.m_pairs[n];if(a&1)continue;let o=a>>1,s=this.m_xy.read(2*o),c=this.m_xy.read(2*o+1);if(t.length&&(s!==r||c!==i)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),r=s,i=c}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){let e=this.m_geometry.getImpl(),t=[];for(let n=0,r=e.getPathCount();n<r;n++)t.push(e.isClosedPathInXYPlane(n));let n=hc(),r,i,a;{let o=this.m_pairIndices.read(0),s=this.m_pairs[o]>>1,c=this.m_xy.readPoint2D(2*s),l=this.m_pathsForOGCTests[s];r=t[l],i=e.getPathStart(l),a=e.getPathEnd(l)-1,n.bEndPoint=s===i||s===a,n.bBoundary=this.m_bOGCRestrictions?!r&&n.bEndPoint:n.bEndPoint,n.ipath=l,n.x=c.x,n.y=c.y,n.ivertex=s}for(let o=1,s=this.m_pairIndices.size();o<s;o++){let s=this.m_pairIndices.read(o),c=this.m_pairs[s];if(c&1)continue;let l=c>>1,u=this.m_xy.readPoint2D(2*l),d=this.m_pathsForOGCTests[l];d!==n.ipath&&(r=t[d],i=e.getPathStart(d),a=e.getPathEnd(d)-1);let f,p=l===i||l===a;f=this.m_bOGCRestrictions?!r&&p:p;let m=gc(u.x,u.y,d,l,f,p);if(m.x===n.x&&m.y===n.y){if(this.m_bOGCRestrictions){if((!m.bBoundary||!n.bBoundary)&&(m.ipath!==n.ipath||!m.bEndPoint||!n.bEndPoint))return this.m_nonSimpleResult=new J(10,m.ivertex,n.ivertex),!1}else if(!m.bEndPoint||!n.bEndPoint)return this.m_nonSimpleResult=new J(7,m.ivertex,n.ivertex),!1}_c(n,m)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return l(0),!1}checkSelfIntersectionsPolygonsOGC(){let e=this.m_geometry.getImpl(),t=[],n=-1,r=!1;for(let i=0,a=e.getPathCount();i<a;i++)e.isExteriorRingOGC(i)&&(r=!1,n++,i<a-1&&(e.isExteriorRingOGC(i+1)||(r=!0))),t.push(r?n:-1);let i=dc();{let e=this.m_pairIndices.read(0),n=this.m_pairs[e]>>1,r=this.m_xy.readPoint2D(2*n),a=this.m_pathsForOGCTests[n];i.ipath=a,i.x=r.x,i.y=r.y,i.ivertex=n,i.ipolygon=t[a]}let a=[];for(let e=1,n=this.m_pairIndices.size();e<n;e++){let n=this.m_pairIndices.read(e),r=this.m_pairs[n];if(r&1)continue;let o=r>>1,s=this.m_xy.readPoint2D(2*o),c=this.m_pathsForOGCTests[o],l=fc(s.x,s.y,c,o,t[c]);if(l.x===i.x&&l.y===i.y){if(l.ipath===i.ipath)return this.m_nonSimpleResult=new J(11,l.ivertex,i.ivertex),!1;t[l.ipath]>=0&&t[l.ipath]===t[i.ipath]&&((a.length===0||!pc(a.at(-1),i))&&a.push({...i}),a.push(l))}mc(i,l)}if(a.length===0)return!0;let o=new Fe(!0);t.fill(-1);let s=-1,c=new U;for(let e=0,n=a.length;e<n;e++){let n=a[e];(n.x!==c.x||n.y!==c.y)&&(s=o.createList(0),c.x=n.x,c.y=n.y);let r=t[n.ipath];r===-1&&(r=o.createList(2),t[n.ipath]=r),o.addElement(r,s),o.addElement(s,r)}let l=[];for(let e=o.getFirstList();e!==-1;e=o.getNextList(e)){let n=o.getListData(e);if(n&1||!(n&2))continue;let r=-1;for(l.push(e),l.push(-1);l.length;){let e=l.at(-1);l.pop();let t=l.at(-1);l.pop();let n=o.getListData(t);if(n&1){r=n&2?t:e;break}o.setListData(t,n|1);for(let n=o.getFirst(t);n!==-1;n=o.getNext(n)){let r=o.getData(n);r!==e&&(l.push(r),l.push(t))}}if(r!==-1){let e=t.indexOf(r);return this.m_nonSimpleResult=new J(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){let e=this.m_multiPathStitcher===null?this.m_geometry.getImpl():this.m_multiPathStitcher.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new J(8,e.getPathCount()===1?1:-1,-1),0;if(e.getPathCount()===1)return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new Ve(e.getPathCount(),0),this.m_pathParentage=new Re(e.getPathCount(),-1);let t=-1,n=0;for(let r=0,i=e.getPathCount();r<i;r++){let i=e.calculateRingArea2D(r);if(this.m_pathOrientations.write(r,i<0?0:8),i>0)t=r,n=i;else if(i===0)return this.m_nonSimpleResult=new J(8,r,-1),0;else{if((t<0||n<Math.abs(i))&&(this.m_nonSimpleResult=new J(9,r,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(r,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;let r=e.getPointCount();this.m_yScanline=NaN;let i=[];this.m_xyToNode1=new Re(r,Ie.st_nullNode()),this.m_xyToNode2=new Re(r,Ie.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new yc(this));for(let e=0,t=r*2;this.m_unknownOrientationPathCount>0&&e<t;e++){let t=this.m_pairIndices.read(e),n=this.m_pairs[t];if(n&1)continue;let r=n>>1,a=this.m_xy.read(2*r+1);if(a!==this.m_yScanline&&i.length){if(!this.processBunchForRingOrientationTest(i))return 0;i.length=0}i.push(r),this.m_yScanline=a}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(i)?0:this.m_bOGCRestrictions?this.m_nonSimpleResult.m_reason!==0||!this.checkSelfIntersectionsPolygonsOGC()?0:5:this.m_nonSimpleResult.m_reason===0?4:3}processBunchForSelfIntersectionTest(e){if(e.length===1)return!0;for(let t=0,n=e.length;t<n;t++){let n=e[t];this.m_recycledSegIter.resetToVertex(n,-1);let r=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(r,n,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();let i=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(i,n,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();t===-1&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let e=0,n=this.m_edges.length;e<n;e++)this.m_crossOverHelperList.addElement(t,e);let n=!0,r=-1,i=-1;for(;n;){n=!1;let e=this.m_crossOverHelperList.getFirst(t);if(e===-1)break;let a=this.m_crossOverHelperList.getNext(e);for(;a!==-1;){let o=this.m_crossOverHelperList.getData(e),s=this.m_crossOverHelperList.getData(a);if(r=this.m_edges[o].m_vertexIndex,i=this.m_edges[s].m_vertexIndex,r===i){if(n=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(a),a=this.m_crossOverHelperList.deleteElement(t,a),a===-1||e===-1)break;continue}e=a,a=this.m_crossOverHelperList.getNext(e)}}let a=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),a>0)return this.m_nonSimpleResult=new J(7,r,i),!1;for(let t=0,n=e.length;t<n;t++)this.recycleEdge(this.m_edges[t]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,n=e.length;t<n;t++){let n=e[t],r=this.m_xyToNode1.read(n);if(r!==Ie.st_nullNode()){let e=this.m_AET.getElement(r);this.m_freeEdges.push(e),this.m_AET.deleteNode(r),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(n,Ie.st_nullNode())}if(r=this.m_xyToNode2.read(n),r!==Ie.st_nullNode()){let e=this.m_AET.getElement(r);this.m_freeEdges.push(e),this.m_AET.deleteNode(r),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(n,Ie.st_nullNode())}}for(let t=0,n=e.length;t<n;t++){let n=e[t];this.m_recycledSegIter.resetToVertex(n,-1);let r=this.m_recycledSegIter.previousSegment();if(r.getStartY()>r.getEndY()){let e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(r,n,this.m_recycledSegIter.getPathIndex(),!0),i;this.m_freeEdges.length>0?(i=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[i]=t):(i=this.m_edges.length,this.m_edges.push(t));let a=this.m_AET.addElement(i);this.m_xyToNode1.read(e)===Ie.st_nullNode()?this.m_xyToNode1.write(e,a):this.m_xyToNode2.write(e,a),this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())&3||this.m_newEdges.push(a)}this.m_recycledSegIter.nextSegment();let i=this.m_recycledSegIter.nextSegment();if(i.getStartY()<i.getEndY()){let e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(i,n,this.m_recycledSegIter.getPathIndex(),!1),r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));let a=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===Ie.st_nullNode()?this.m_xyToNode1.write(e,a):this.m_xyToNode2.write(e,a),this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())&3||this.m_newEdges.push(a)}}for(let e=0,t=this.m_newEdges.length;e<t&&this.m_unknownOrientationPathCount>0;e++){let t=this.m_newEdges[e],n=this.m_AET.getElement(t),r=this.m_edges[n].m_pathIndex;if(!(this.m_pathOrientations.read(r)&3)){let e=-1,n=this.m_AET.getPrev(t),r=t,i=0;{let t=-1,a=null,o=-1,s=0;for(;n!==Ie.st_nullNode()&&(t=this.m_AET.getElement(n),a=this.m_edges[t],o=a.m_pathIndex,s=this.m_pathOrientations.read(o),!(s&3));)r=n,n=this.m_AET.getPrev(n);n===Ie.st_nullNode()?(i=1,n=r):(e=(s&3)==1?o:this.m_pathParentage.read(o),i=+!a.getRightSide(),n=this.m_AET.getNext(n))}do{let t=this.m_AET.getElement(n),a=this.m_edges[t],o=a.m_pathIndex,s=this.m_pathOrientations.read(o);if(!(s&3)){if(i!==a.getRightSide())return this.m_nonSimpleResult=new J(8,o,-1),!1;let t=i&&!a.getReversed()?1:2;if(s=s&-4|t,this.m_pathOrientations.write(o,s),t===2&&this.m_nonSimpleResult.m_reason===0){let t=this.m_pathParentage.read(o);if(t!==e&&(this.m_nonSimpleResult=new J(9,o,t),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}e=(s&3)==1?o:this.m_pathParentage.read(o),r=n,n=this.m_AET.getNext(n),i=+!i}while(r!==t)}}return this.m_newEdges.length=0,!0}createEdge(e,t,n,r){let a;return e.getGeometryType()===i.enumLine?a=this.createEdgeLine(e):(a=new uc,a.m_segment=e.clone()),a.m_vertexIndex=t,a.m_pathIndex=n,a.m_flags=0,a.setReversed(r),a}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new uc,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,n,r){let i=e.calculateLowerLength2D();if(i<=n){let a=!0;if(e.isCurve()&&(i=e.calculateLength2D(),a=i<=n),a){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let n=e.getStartAttributeAsDbl(1,0);return Number.isNaN(n)&&(n=0),Math.abs(n-t)<=r}return!0}return!1}return!1}static isShortSegmentPoints(e,t,n,r,i){if(n){let n=e.getXYZ(),a=t.getXYZ();return He(n,a,r,i)}{let n=e.getXY(),i=t.getXY();return U.sqrDistance(n,i)<=r*r}}removeDegenerateSegmentsFromCurvedPath(e,t,n,r){let i=e.hasAttribute(1),a=e.querySegmentIterator();a.resetToPath(t),l(a.nextPath());let o=this.m_toleranceSimplify.total(),s=!1,c=!0,u=new B,d=new B,f=new U;for(;a.hasNextSegment();){this.progress_();let e=a.nextSegment();if(bc.isShortSegment(e,i,o,n)){if(s){if(e.queryEnd(d),bc.isShortSegmentPoints(u,d,i,o,n))continue;c&&=(r.startPathPoint(u),!1),e.queryEnd(u),r.lineToPoint(u),s=!1}else f.assign(e.getStartXY()),e.queryStart(u),s=!0;continue}if(!s)r.addSegment(e,c),c=!1;else if(e.isCurve()){let t=e.clone();if(t.setCoordsForIntersector(f,e.getEndXY(),!1),t.setStart(u),!bc.isShortSegment(t,i,o,n))r.addSegment(t,c),c=!1,s=!1;else continue}else if(e.queryEnd(d),!bc.isShortSegmentPoints(u,d,i,o,n))c&&=(r.startPathPoint(u),!1),r.lineToPoint(d),s=!1;else continue}if(c||!s)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),u):e.getPointByVal(e.getPathEnd(t)-1,u);let p=r.querySegmentIterator();p.resetToLastPath(),p.resetToLastSegment();let m=r.getDescription().getAttributeCount()>1;for(l(p.previousPath());p.hasPreviousSegment();){let e=p.previousSegment();if(e.isCurve()){let t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),u.getXY(),!1),!bc.isShortSegment(t,i,o,n)){m&&t.setEnd(u);let e=p.getEndPointIndex();for(let t=r.getPointCount()-1;t>=e;t--)r.removePoint(t);r.addSegment(t,!1);return}}else if(e.queryStart(d),!bc.isShortSegmentPoints(d,u,i,o,n)){let e=p.getEndPointIndex();for(let t=r.getPointCount()-1;t>=e;t--)r.removePoint(t);r.lineToPoint(u);return}}r.removePath(r.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;let e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;let t=e.getPointCount(),n=H(t,0);for(let e=0;e<t;e++)n[e]=e;n.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let e=1;e<t;e++)if(this.compareVerticesMultiPoint(n[e-1],n[e])===0)return this.m_nonSimpleResult=new J(5,n[e-1],n[e]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()?+!!this.checkDegenerateSegments(!0):0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl(),t=bc.hasNanZs(e),n=this.m_geometry,r;t&&(r=this.m_geometry.clone(),e=r.getImpl(),r.replaceNaNs(1,Ue.getDefaultValue(1)),n=r),this.m_multiVertexGeom=e;let i=e.getPointCount(),a=H(i,0);for(let e=0;e<i;e++)a[e]=e;a.sort((e,t)=>this.compareVerticesMultiPoint(e,t));let o=Array(i);o.fill(!1);let s=-1;for(let t=0;t<i;t++){let n=a[t];e.getXY(n).isFinite()&&((s<0||this.compareVerticesMultiPoint(s,n)!==0)&&(o[n]=!0),s=n)}let c=this.m_geometry.createInstance(),l=0,u=0;for(let e=0;e<i;e++)o[e]?u=e+1:(l<u&&c.addPoints(n,l,u),l=e+1);return l<u&&c.addPoints(n,l,u),c.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),c}polylineSimplifyAsFeature(){let e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),n=e.querySegmentIterator(),r=this.m_geometry.createInstance(),i=this.m_geometry,a=e.hasAttribute(1),o=a?Be(this.m_sr,e,!0).total():0,s=[],c=[],l=null;a&&(l=e.getAttributeStreamRef(1));let u=new B,d=e.hasNonLinearSegments(),f=this.m_toleranceSimplify.total();for(;t.nextPath();){if(n.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(d&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,r);continue}n.resetToLastSegment();let p=0,m=0,h=!0,g=!0;for(;t.hasNextSegment();){this.progress_();let r=t.nextSegment(),i=n.previousSegment();if(t.getStartPointIndex()>n.getStartPointIndex())break;if(h){let n=t.getStartPointIndex();e.getXY(n).isNAN()||(h=!1,s.push(n))}if(g){let t=n.getEndPointIndex();e.getXY(t).isNAN()||(c.push(t),g=!1)}if(!h){let n=s.at(-1),i=t.getEndPointIndex();if(i-n>1){let t=new U;t.setSub(e.getXY(n),e.getXY(i)),p=t.length()}else p=r.calculateLength2D();if(p>f)s.push(i),p=0;else if(a){let e=l.read(n);Number.isNaN(e)&&(e=0);let t=l.read(i);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(s.push(i),p=0)}}if(!g){let t=c.at(-1),r=n.getStartPointIndex();if(r-t>1){let n=new U;n.setSub(e.getXY(t),e.getXY(r)),m=n.length()}else m=i.calculateLength2D();if(m>f)c.push(r),m=0;else if(a){let e=l.read(t);Number.isNaN(e)&&(e=0);let n=l.read(r);Number.isNaN(n)&&(n=0),Math.abs(n-e)>o&&(c.push(r),m=0)}}}if(s.length>0&&c.length>0&&(s.at(-1)<c.at(-1)?s.length>c.length?s.pop():c.pop():(s.at(-1)===c.at(-1)||c.pop(),c.pop())),c.length+s.length>=2){let e=!1;for(let t=0,n=s.length;t<n;t++)i.getPointByVal(s[t],u),e?r.lineToPoint(u):(r.startPathPoint(u),e=!0);for(let t=c.length-1;t>0;t--)i.getPointByVal(c[t],u),e?r.lineToPoint(u):(r.startPathPoint(u),e=!0);i.isClosedPath(t.getPathIndex())?r.closePathWithLine():c.length>0&&(i.getPointByVal(c[0],u),r.lineToPoint(u))}s.length=0,c.length=0}return a&&r.replaceNaNs(1,0),r.getImpl().setIsSimple(1,f),r}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(this.m_geometry.getFillRule()===1&&!We(this.m_knownSimpleResult))return Ls(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);let e=new N;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),e.getTotalPointCount()!==0){let t=null,n=0,r=0;if(e.hasCurves()){t=new _s;let i=T.constructEmpty();this.m_geometry.queryEnvelope(i);let a=ms(this.m_toleranceSimplify.total(),i);n=hs(this.m_toleranceSimplify.total()),r=gs(a,n),ss(e,a,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}We(this.m_knownSimpleResult)||ys(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1),this.m_geometry.getGeometryType()===i.enumPolygon&&ri(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),t!==null&&t.stitchCurves(e,e.getFirstGeometry(),n,!0)}let t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===i.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){let t=e.getAttributeStreamRef(1);for(let n=0,r=e.getPointCount();n<r;n++){let e=t.read(n);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,n){if(e===t)return 0;let r=this.m_pairs[e],i=this.m_pairs[t],a=r>>1,o=i>>1,s=this.m_xy.readPoint2D(2*a);s.y+=r&1?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;let c=this.m_xy.readPoint2D(2*o);c.y+=i&1?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;let l=s.compare(c);if(l===0&&n){let e=this.m_pathsForOGCTests[a]-this.m_pathsForOGCTests[o];return _t(e)}return l}compareVerticesMultiPoint(e,t){if(e===t)return 0;let n=this.m_multiVertexGeom.getXY(e),r=this.m_multiVertexGeom.getXY(t),i=!n.isFinite(),a=!r.isFinite();if(i||a)return i<a?-1:+(i>a);if(n.y<r.y)return-1;if(n.y>r.y)return 1;if(n.x<r.x)return-1;if(n.x>r.x)return 1;for(let n=1;n<this.m_attributeCount;n++){let r=this.m_description.getSemantics(n),i=Ue.getComponentCount(r);for(let n=0;n<i;n++){let i=this.m_multiVertexGeom.getAttributeAsDbl(r,e,n),a=this.m_multiVertexGeom.getAttributeAsDbl(r,t,n),o=xt(i,a);if(o!==0)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;let n=e.m_segment.getTangent(+!!e.getReversed());e.getReversed()&&n.negateThis();let r=t.m_segment.getTangent(+!!t.getReversed());t.getReversed()&&r.negateThis();let i=n.getQuarter(),a=r.getQuarter();if(a===i){let e=n.crossProduct(r);return e<0?1:e>0?-1:0}return i<a?-1:1}}class xc{getOperatorType(){return 10103}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,n,r,i){let a=oc(e,t,n,r,i);return Ee(e.getGeometryType(),a)}isSimplePlanarDONOTUSE(e,t,n,r,i){let a=ic(e,t,n,r,i);return De(a)}executeMany(e,t,n,r){return new Sc(e,t,n,r)}execute(e,t,n,r){let i=new sn([e]),a=this.executeMany(i,t,n,r).next();return a||o(`null geometry`),a}}class Sc extends on{m_inputGeometryCursor;m_spatialReference;m_progressTracker;m_index;m_bForceSimplify;constructor(e,t,n,r){super(),this.m_progressTracker=r,this.m_bForceSimplify=n,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){let e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||n(``),e.getGeometryType()===i.enumGeometryCollection){let t=j(e,-1),n=new xc().executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),r=e.createInstance();for(let e=n.next();e!=null;e=n.next())r.addGeometry(e);return r}return sc(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Cc(e,t,n){let r=new T;e.queryEnvelope(r);let a=new T;t.queryEnvelope(a);let o=new T(a);if(o.inflate(2*n),!o.isIntersecting(r))return 4;let s=e.getGeometryType(),c=t.getGeometryType();do{if(s===i.enumEnvelope&&r.containsEnvelope(o))return 1;if(c===i.enumEnvelope){let e=new T(r);if(e.inflate(2*n),a.containsEnvelope(e))return 2}}while(0);return 0}class wc{m_intersectorGeom=null;m_sr=null;m_dimensionMask=-1;m_progressTracker=null;m_intersectorGeomType=i.enumUnknown;m_geomIntersectorEmptyGeom=null;constructor(e,t,n,r){this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=n,this.m_progressTracker=r,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){let t=this.tryFastImplementation(e);if(t!==null)return t;let n=Ae(this.m_intersectorGeom,e),r=je(this.m_sr,n,!0).total(),i=T.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);let a=T.constructEmpty();e.queryEnvelope(a),i.inflateCoords(2*r,2*r),i.intersect(a),i.inflateCoords(100*r,100*r);let o=q(this.m_intersectorGeom,i,0,0,this.m_progressTracker),s=q(e,i,0,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(o=gt(s,s=o)),Ks(s,o,this.m_sr,this.m_progressTracker)}intersectEx(e){let t=this.tryFastImplementation(e);if(t!==null){let n=[];return n.length=3,n[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,n)}let n=Ae(this.m_intersectorGeom,e),r=je(this.m_sr,n,!0).total(),i=T.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);let a=T.constructEmpty();e.queryEnvelope(a),i.inflateCoords(2*r,2*r),i.intersect(a),i.inflateCoords(100*r,100*r);let o=q(this.m_intersectorGeom,i,0,0,this.m_progressTracker),s=q(e,i,0,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(o=gt(s,s=o));let c=qs(s,o,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,c)}init(e,t,n,r=null){l(0)}static intersectPoints(e,t,n){let r=Ae(e,t);return Gs(e,t,je(n,r,!0))}tryFastImplementation(e){let t=e.getGeometryType();if(this.m_intersectorGeomType===i.enumPoint&&t===i.enumPoint){let t=wc.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(this.m_dimensionMask!==-1){let e=new A({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.enumEnvelope&&this.m_intersectorGeomType===i.enumEnvelope&&(this.m_dimensionMask===-1||this.m_dimensionMask===4)){let t=e,n=this.m_intersectorGeom,r=new Me({copy:t});return r.intersect(n),r}let n=Ae(e,this.m_intersectorGeom),r=je(this.m_sr,n,!0),a=e.isEmpty(),s=this.m_intersectorGeom.isEmpty(),c=a||s;if(!c){let t=Cc(this.m_intersectorGeom,e,r.total());if(t===4)c=!0;else if(t&2)return this.m_intersectorGeom;else if(t&1)return e}if(c){let n=u(t),r=u(this.m_intersectorGeomType);return n<r?wc.ReturnEmpty(e,a):n>r||n===0&&t===i.enumMultiPoint&&this.m_intersectorGeomType===i.enumPoint?this.ReturnEmptyIntersector():wc.ReturnEmpty(e,a)}if(t===i.enumEnvelope&&u(this.m_intersectorGeomType)===0||this.m_intersectorGeomType===i.enumEnvelope&&u(t)===0){let n=t===i.enumEnvelope?e:this.m_intersectorGeom,a=t===i.enumEnvelope?this.m_intersectorGeom:e,o=T.constructEmpty();return n.queryEnvelope(o),q(a,o,r.total(),0,this.m_progressTracker)}if(u(t)===0&&u(this.m_intersectorGeomType)>0||u(t)>0&&u(this.m_intersectorGeomType)===0){if(t===i.enumMultiPoint)return Vs(e,this.m_intersectorGeom,r);if(t===i.enumPoint)return Ws(e,this.m_intersectorGeom,r);if(this.m_intersectorGeomType===i.enumMultiPoint)return Vs(this.m_intersectorGeom,e,r);if(this.m_intersectorGeomType===i.enumPoint)return Ws(this.m_intersectorGeom,e,r);o(``)}return null}ReturnEmptyIntersector(){return this.m_geomIntersectorEmptyGeom===null&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,n){let r=0;return t&1?(n[0]||=new A({vd:e}),r++):n.shift(),t&2?(n[r]||(n[r]=new E({vd:e})),r++):n.splice(r,1),t&4?n[r]||(n[r]=new k({vd:e})):n.splice(r,1),new sn(n)}}class Tc extends on{m_inputGeoms;m_smallCursor=null;m_progressTracker;m_geomIntersector;m_index;m_dimensionMask;m_intersector;constructor(e,t,r,i,a){super(),this.m_progressTracker=i,this.m_geomIntersector=t.next(),this.m_intersector=new wc(this.m_geomIntersector,r,a,i),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=a,this.m_dimensionMask!==-1&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&n(`bad dimension mask`)}next(){if(!this.m_geomIntersector)return null;let e;if(this.m_smallCursor!==null){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();)return r(e),this.m_index=this.m_inputGeoms.getGeometryID(),this.m_dimensionMask===-1?this.m_intersector.intersect(e):(this.m_smallCursor=this.m_intersector.intersectEx(e),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Ec{getOperatorType(){return 1e4}accelerateGeometry(e,t,n){if(!this.canAccelerateGeometry(e))return!1;Te(t,e,!0);let r=0;return(e.getGeometryType()===i.enumPolygon||e.getGeometryType()===i.enumPolyline)&&D(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeAccelerator(n)),!!r}canAccelerateGeometry(e){return D(e)}supportsCurves(){return!0}executeMany(e,t,n,r,i=-1){return new Tc(e,t,n,r,i)}execute(e,t,n,r){if(e.getGeometryType()===i.enumPoint&&t.getGeometryType()===i.enumPoint)return wc.intersectPoints(e,t,n);let a=new sn([e]),s=new sn([t]),c=this.executeMany(a,s,n,r,-1).next();return c||o(`null output`),c}}function Dc(e,t,n){return t.m_projector.project(e,n)}function Oc(e,t,n,r,i){e.m_projector.transformInPlaceZ(t,null,n,r,null,i);let a=r.slice(0,n).filter(e=>!e.isNAN());for(let e=0,t=a.length;e<t;++e)r[e].assign(a[e]);return a.length}function kc(e,t,n,r,i){return e.m_projector.transformInPlaceZ(t,null,n,r,null,i)}function Ac(e,t,r,o){if((!e||!t||!t.isPannable())&&n(`fold_into_360_range_geodetic`),e.isEmpty())return e;if(r===4)return jc(e,t,o);let c=e,l=c.getGeometryType();if(s(l)){c=Fu(e,t);let n=new T;c.queryEnvelope(n);let i=je(t,n,!1).total(),a=t.getPannableExtent(),o=Math.floor((n.xmin-a.xmin)/a.width())*a.width()+a.xmin,s=c;for(;o<n.xmax;)o>n.xmin+i&&o<n.xmax-i&&(s=Nu(s,t,r,!0,o)),o+=a.width();c=s}else{if(l===i.enumEnvelope){let e=new k({vd:c.getDescription()});return e.addEnvelope(c,!1),Ac(e,t,r,o)}if(a(l)){let e=new E({vd:c.getDescription()});return e.addSegment(c,!0),Ac(e,t,r,o)}}return jc(c,t,o)}function jc(e,t,r){if((!e||!t||!t.isPannable())&&n(``),e.isEmpty())return e;let o,s=e.getGeometryType();if(s===i.enumEnvelope){let t=new k({vd:e.getDescription()});t.addEnvelope(e,!1),o=t}else if(a(s)){let t=new E({vd:e.getDescription()});t.addSegment(e,!0),o=t}else o=e;let c=Fu(o,t);return c.isEmpty()?c:Eu(c,t,0,c!==e,0,r)}function Mc(e,t,n){if(!t.isPannable()||e.isEmpty())return e;let r=t.getPannableExtent().width(),i=r*.5,a=e.queryInterval(0,0);if(a.width()<i||!f(e.getGeometryType())){if(Number.isNaN(n))return e;let t=a.getCenter();if(Math.abs(t-n)<=i)return e;{let i=new K,a=n-t,o=ht(a/r)*r;i.setShiftCoords(o,0);let s=e.clone();return s.applyTransformation(i),s}}let o=e.getGeometryType(),c=e,l=c.getAttributeStreamRef(0),u=e.clone(),d=u.getAttributeStreamRef(0),p=0,m=0,h=0,g=s(o)?0:-1,_=W.constructEmpty(),v=!1;for(let e=0,t=c.getPointCount();e<t;e++){let t=l.read(e*2);e===m&&(s(o)?(g===0&&Number.isNaN(n)&&(v=!0),g>0&&Number.isNaN(n)&&(n=_.getCenter(),v=!1),m=c.getPathEnd(g),g++):m=c.getPointCount(),Number.isNaN(n)?h=t:(h=n,p=0));let a=t-h;Math.abs(a)>i&&(a=ht(a/r)*r,p-=a,Math.abs(p)<.1*r&&(p=0));let u=t+p;d.write(e*2,u),v&&_.mergeCoordinate(u),h=t}return u.notifyModified(),u}function Nc(e,t,n,r){let i=t.getCoordinateSystemType();if(i===0){let r=new ip;return t.queryPrecisionDescriptor(r),Pc(e,r,t,n)}let a=e;(r===2||r===3)&&t.isPannable()&&(a=jc(a,t,n));let s=new ip;if(t.queryPrecisionDescriptor(s),a=Pc(a,s,t,n),r===0||a.isEmpty())return a;if(i===1){if(r===1){let e=new T;a.queryLooseEnvelope(e);let r=t.getPannableExtent(),i=.01*r.width();return r.xmin=e.xmin-i,r.xmax=e.xmax+i,new nn().execute(a,r,t,n)}return a}if(i===2){let e=t.getPCSHorizon();if(r===1||r===2){let r=new Ec().execute(a,e,t,n);return r===e?r.clone():r}return a}if(i===3)return a;o(`missing implementation`)}function Pc(e,t,n,r){let i=t.getXYGridRange(),a=e.hasAttribute(1),o=e.hasAttribute(2),s=new W,c=new W;a&&(s=t.getZGridRange()),o&&(c=t.getMGridRange());let l=new nn().execute(e,i,n,r);if(a){let t=l.queryInterval(1,0);s.contains(t)||(e===l&&(l=l.clone()),ot(l,s,1,0))}if(o){let t=l.queryInterval(2,0);c.contains(t)||(e===l&&(l=l.clone()),ot(l,c,2,0))}return l}class Fc{m_projTransform;m_inputPCSHorizonClipOption=0;m_outputPCSHorizonClipOption=0;m_bDontGeonormalizePolygon=!1;m_bClipOutCurvedPoles=!1;m_bNormalizeOutputGeometry=!1;m_bDontHackPolesInGeogToGeog=!1;m_centralMeridianOfOutputGCS=0;m_densificationStepInput=0;constructor(e){e||n(``),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;let t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.densificationStep;let r=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=r.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=r.hasFlag(1073741824),this.m_bClipOutCurvedPoles=r.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;let n=e.getGeometryType();if(n===i.enumPoint)return this.projectPoint(e,t);let r=this.m_projTransform.getInputSR().getCoordinateSystemType(),a=this.m_projTransform.getOutputSR().getCoordinateSystemType(),s=this.m_projTransform.getInputSR(),c=this.m_projTransform.getOutputSR();if(r===0&&r===a){let t=Lc(s,c),n=e.clone();return n.applyTransformation(t),n}switch(n){case i.enumPolyline:case i.enumPolygon:return this.projectMultiPath(e,t);case i.enumMultiPoint:return this.projectMultiPoint(e,t);case i.enumEnvelope:return this.projectEnvelope(e,t);case i.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:o(``)}}projectPoint(e,t){let n=[e.getXY()],r=null,i;(i=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(n,r,1,n,r,null);let a=e.clone();return a.setXY(n[0]),i&&a.setZ(r[0]),a}projectMultiPoint(e,t){let n=new A({copy:e}),r=this.m_projTransform.getInputSR(),i=this.m_projTransform.getOutputSR(),a=r.getCoordinateSystemType(),o=i.getCoordinateSystemType();if(a===3&&l(0),n=Uu(n,r,this.m_inputPCSHorizonClipOption,t),n.isEmpty())return n;a===2&&Qu(r,0,n),ud(this.m_projTransform,n,!1);let s=0;o===3&&l(0);let c=o===2;return c?s=i.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS),(!c||this.m_outputPCSHorizonClipOption===0)&&(n=Eu(n,Yf(i),s,!1,0,t)),c&&(n=xu(n,i,this.m_outputPCSHorizonClipOption,t),Yu(i,n,this.m_bNormalizeOutputGeometry),n.isEmpty()),n}projectMultiPath(e,t){let n=e.getGeometryType();if(n===i.enumPolygon)return this.projectPolygon(e,t);if(n===i.enumPolyline)return this.projectPolyline(e,t);o(`project_multi_path_`)}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();let n=this.m_projTransform.isVertical()&&e.hasAttribute(1),r=W.constructEmpty();if(n&&(r=e.queryInterval(1,0)),r.width()>0){let n=e.clone();n.setInterval(1,0,r.vmin,r.vmin);let i=this.projectEnvelopeHelper(n,t);n.setInterval(1,0,r.vmax,r.vmax);let a=this.projectEnvelopeHelper(n,t);return i.merge(a),i}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){l(e.getGeometryType()===i.enumPolygon),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());let n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),o=r.getCoordinateSystemType(),s=new k({copy:e});a===3&&l(0),o===3&&l(0);let c=a===2,u=o===2,d=c?n.getGCS():n,f=u?r.getGCS():r,p=!u&&!this.m_bDontHackPolesInGeogToGeog,m=!1,h=Uu(s,n,this.m_inputPCSHorizonClipOption,t);if(h.isEmpty())return h;let g=this.m_densificationStepInput,_=!Number.isNaN(g);_&&(h=new an().execute(h,g,0,0,t));let v,y=u?r.getPCSInfo():null,b=NaN;c&&(b=n.getCentralMeridian());let x=r.getGCSSplitLines()!==null;if(this.m_bDontGeonormalizePolygon){let e=h;if(c&&(sd(n,b,e),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,e,p),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}v=e}else{let e=new E({vd:h.getDescription()});if(e.addAndExplicitlyOpenAllPaths(h,!1),c){if(sd(n,b,e),_){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(this.m_bClipOutCurvedPoles){let r=n.getPCSInfo(),i=r.getSouthPoleGeometry()===Ep.PE_POLE_LINE_CURVED,a=r.getNorthPoleGeometry()===Ep.PE_POLE_LINE_CURVED;if(i||a){let n=T.constructEmpty();e.queryLooseEnvelope(n),n.inflateCoords(1,1);let r=89.9999*d.getOneDegreeGCSUnit();i&&(n.ymin=-r),a&&(n.ymax=r),e=rn(e,n,d,0,0,t)}}}if(fd(this.m_projTransform,e,p),_){let e=Yf(n).getUnitsPerMillimeter(),t=Yf(r).getUnitsPerMillimeter();g*=t/e}let i=NaN;u?(y=r.getPCSInfo(),i=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=Ic(n)|Ic(r),o=f.getTolerance(0)*10;this.m_bDontHackPolesInGeogToGeog&&(a=3,o=f.getTolerance(0)*10),v=ju(h,n,e,f,i,t,a,o,this.m_bNormalizeOutputGeometry),a=0}if(x&&(l(!r.isPannable()),v=fu(v,r,t)),u){if(!m){let e=f.getPannableExtent().width();if(v.queryInterval(0,0).width()>=e-f.getTolerance(0)*10){let e=y.getNorthPoleLocation(),t=y.getSouthPoleLocation(),n=y.getNorthPoleGeometry(),r=y.getSouthPoleGeometry(),i=0;n===Ep.PE_POLE_POINT&&e!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(i=1),r===Ep.PE_POLE_POINT&&t!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(i|=2),m||=i!==0}}v=xu(v,r,this.m_outputPCSHorizonClipOption,t),_&&(v=new an().execute(v,g,0,0,t)),Zu(r,v,this.m_bNormalizeOutputGeometry)}return v.isEmpty()||m&&(v=new xc().execute(v,r,!1,t)),v}projectPolyline(e,t){l(e.getGeometryType()===i.enumPolyline),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());let n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),a=n.getCoordinateSystemType(),o=r.getCoordinateSystemType(),s=new E({copy:e});a===3&&l(0),o===3&&l(0);let c=a===2,u=o===2;c&&n.getGCS();let d=u?r.getGCS():r,f=!u&&!this.m_bDontHackPolesInGeogToGeog,p=Uu(s,n,this.m_inputPCSHorizonClipOption,t);if(p.isEmpty())return p;let m=NaN;c&&(m=n.getCentralMeridian());let h=r.getGCSSplitLines()!==null,g=this.m_densificationStepInput,_=!Number.isNaN(g);_&&(p=new an().execute(p,g,0,0,t));let v;if(this.m_bDontGeonormalizePolygon){if(c&&(sd(n,m,p),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,p,f),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}v=p}else{let e=new E({vd:p.getDescription()});if(e.addAndExplicitlyOpenAllPaths(p,!1),c&&(sd(n,m,e),_)){let e=n.getUnitsPerMillimeter(),t=n.getGCS().getUnitsPerMillimeter();g*=t/e}if(fd(this.m_projTransform,e,f),_){let e=n.getGCS().getUnitsPerMillimeter(),t=r.getGCS().getUnitsPerMillimeter();g*=t/e}let i=NaN;u?i=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let a=Ic(n)|Ic(r),o=d.getTolerance(0)*10;this.m_bDontHackPolesInGeogToGeog&&(a=3,o=0),v=Mu(p,n,e,d,i,t,a,o,this.m_bNormalizeOutputGeometry),a=0}return h&&(l(!r.isPannable()),v=fu(v,r,t)),u&&(v=xu(v,r,this.m_outputPCSHorizonClipOption,t),_&&(v=new an().execute(v,g,0,0,t)),Zu(r,v,this.m_bNormalizeOutputGeometry)),v.isEmpty(),v}projectGeometryCollection(e,t){return l(0),{}}projectEnvelopeHelper(e,t){let n=(e.height()+e.width())/400;if(n!==0){let r=new an().execute(e,n,0,0,t),i=this.projectMultiPath(r,t),a=new Me({vd:e.getDescription()});if(i.isEmpty()){let n=Math.min(e.height(),e.width()),i=Te(this.m_projTransform.getInputSR(),e,!0).total();if(n>100*i){let e=T.constructEmpty(),t=je(this.m_projTransform.getOutputSR(),e,!0).total(),r=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(n>100*Math.max(i,t*r))return a}let o=new E;o.addAndExplicitlyOpenAllPaths(r,!1),this.projectMultiPath(o,t).queryEnvelope(a);let s=new A({vd:e.getDescription()});s.reserve(4);let c=new B;for(let t=0;t<4;t++)e.queryCornerByVal(t,c),s.add(c);let l=this.projectMultiPoint(s,t),u=new Me;return l.queryEnvelope(u),a.merge(u),a}return i.queryEnvelope(a),a}{let n=e.getCenterXY(),r=new B(n),i=this.projectPoint(r,t),a=new Me({vd:e.getDescription()});if(i.isEmpty())a.setEmpty();else{e.copyTo(a);let t=i.getXY();a.setCoords(t.x,t.y,t.x,t.y)}return a}}transformInPlace(e,t,n,r){return l(0),0}transformInPlaceZ(e,t,n,r,i,a){if(this.m_projTransform.isIdentity())return e!==r&&ft(r,e,n),t!==i&&zt(i,t,0,0,n),n;let o=this.m_projTransform,s=o.getInputSR(),c=o.getOutputSR(),u=s.getCoordinateSystemType(),d=c.getCoordinateSystemType();if(u===0&&u===d)return Lc(s,c).transformPoints2D(e,n,r),o.isVertical()&&l(0),n;u===3&&p(`image: transform_in_place_`),d===3&&p(`image: transform_in_place_`),Wu(e,n,r,s,this.m_inputPCSHorizonClipOption),i!==t&&zt(i,t,0,0,n),u===2&&cd(s,0,r,n),gd(this.m_projTransform,r,i,n,!1);let f=0,m=d===2;m?f=c.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(f=this.m_centralMeridianOfOutputGCS),(!m||this.m_outputPCSHorizonClipOption===0)&&Du(r,n,c.getGCS(),f),m&&(Tu(r,n,c,this.m_outputPCSHorizonClipOption),Ku(c,r,n,!1));let h=n;for(let e=0;e<n;++e)r[e].isNAN()&&(i&&(i[e]=NaN),h--);return h}}function Ic(e){if(e.getCoordinateSystemType()!==2)return 0;let t=0,n=e.getPCSInfo(),r=n.getNorthPoleLocation(),i=n.getSouthPoleLocation(),a=n.getNorthPoleGeometry(),o=n.getSouthPoleGeometry();return a===Ep.PE_POLE_POINT&&r!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===Ep.PE_POLE_POINT&&i!==Ep.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function Lc(e,t){let n=e.getHorzUnitFactor(),r=t.getHorzUnitFactor(),i=1,a=1,o=20015077/180;e.getUnit().getUnitType()===1&&(i=o),t.getUnit().getUnitType()===1&&(a=o);let s=i===a?1:i/a,c=n/r*s,l=new K;return l.setScaleCoords(c,c),l}class Rc{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n){return!t||t.isIdentity()?e:new zc(e,t,n)}execute(e,t,n){return t.isIdentity()?e:Dc(e,t,n)}transform(e,t,n,r,i=!0){return i?Oc(e,t,n,r,null):kc(e,t,n,r,null)}transform3D(e,t,n,r,i=!0){return l(0),0}foldInto360Range(e,t){return jc(e,t,null)}foldInto360RangeGeodetic(e,t,n){return Ac(e,t,n,null)}normalizeGeometryEx(e,t,n,r,i=0){return Ol(e,t,n,r,i)}normalizeGeometry(e,t,n){return Mc(e,t,n)}clipToSpatialReference(e,t,n,r=0){return Nc(e,t,n,r)}}class zc extends on{m_inputGeoms;m_projTrans;m_index;m_progressTracker;constructor(e,t,r){super(),this.m_projTrans=t,this.m_progressTracker=r,this.m_index=-1,e||n(``),this.m_inputGeoms=e}next(){let e=this.m_inputGeoms.next();return e==null?null:(S(e),r(e),this.m_index=this.m_inputGeoms.getGeometryID(),Dc(e,this.m_projTrans,this.m_progressTracker))}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Bc(e,t,o,c,u,d,f=!1){e||n(`Geometry.Geodetic_densify.densify`);let p=e.getGeometryType();if(r(e),e.isEmpty()||b(p))return e;let m=new Kc;m.m_sr=t,m.m_gcs=t.getGCS(),m.m_transform=m.m_gcs===t?null:t.getSRToGCSTransform(),m.m_progressTracker=d;let h=Pf();m.m_gcs.querySpheroidData(h),m.m_a=h.majorSemiAxis,m.m_eSquared=h.e2,m.m_rpu=m.m_gcs.getUnit().getUnitToBaseFactor(),m.m_gcsTolerance=m.m_gcs.getTolerance(0),m.m_radTolerance=m.m_gcsTolerance*m.m_rpu,m.m_maxLength=c,m.m_maxDeviation=u,m.m_curveType=o;let g,_,v;if(p===i.enumEnvelope){let t=new k({vd:e.getDescription()});t.addEnvelope(e,!1),g=t,p=i.enumPolygon}else if(a(p)){let t=new E({vd:e.getDescription()});t.addSegment(e,!0),g=t,p=i.enumPolyline}else g=e;if(m.m_curveType!==4){if(l(s(p)),_=m.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(g),_.isEmpty())return _;_=Vc(m.m_rpu,_);let e=m.geodeticDensify(_);f||(e=new Rc().foldInto360RangeGeodetic(e,m.m_gcs,m.m_curveType)),v=m.m_transform&&!m.m_transform.isIdentity()?new Rc().execute(e,m.m_transform.getInverse(),d):e}else{l(s(p));let e;if(t.isPannable())e=Fu(g,t);else{let n=t.getPCSHorizon();e=new Ec().execute(g,n,t,d),e===n&&(e=n.clone())}if(_=e,_.isEmpty())return _;v=m.shapePreservingDensify(_)}return v}function Vc(e,t){let n=new T;if(t.queryLooseEnvelope(n),n.width()*e<Math.PI)return t;let r=!1,i=t.querySegmentIterator(),a=new U,o=new U;for(;i.nextPath();)for(;i.hasNextSegment();){let t=i.nextSegment();if(a.setCoordsPoint2D(t.getStartXY()),o.setCoordsPoint2D(t.getEndXY()),a.scale(e),o.scale(e),Math.abs(a.x-o.x)>Math.PI){if(!Uc(a,o)){r=!0;break}if(Math.abs(a.x-o.x)>Math.PI*2){r=!0;break}}}if(!r)return t;let s=t.createInstance();s.reserve(t.getPointCount());let c=t.getDescription().getAttributeCount()>1,l=new U,u=new U,d=new U(0,0),f=new U(0,0),p=new B;for(i.resetToFirstPath();i.nextPath();){let t=NaN,n=0;for(;i.hasNextSegment();){let r=i.nextSegment();if(a.setCoordsPoint2D(r.getStartXY()),o.setCoordsPoint2D(r.getEndXY()),a.scale(e),o.scale(e),Number.isNaN(t)?(n=il(a.x,NaN,n),d.setCoordsPoint2D(a)):d.setCoordsPoint2D(f),t=d.x,!Uc(a,o))l.setCoordsPoint2D(o),ul(l),n=il(l.x,t,n),f.setCoords(n+l.x,l.y);else{if(o.x-a.x>Math.PI*2)for(;o.x-a.x>Math.PI*2;)o.x-=Math.PI*2;else if(o.x-a.x<-Math.PI*2)for(;o.x-a.x<-Math.PI*2;)o.x+=Math.PI*2;n=il(o.x,NaN,n),f.setCoordsPoint2D(o)}if(Math.abs(f.x-o.x)<.5&&f.setCoordsPoint2D(o),c)r.queryCoord(0,p),u.setCoordsPoint2D(d),u.scale(1/e),p.setXY(u),i.isFirstSegmentInPath()?s.startPathPoint(p):s.lineToPoint(p),i.isLastSegmentInPath()&&!i.isPathClosed()&&(r.queryCoord(1,p),u.setCoordsPoint2D(f),u.scale(1/e),p.setXY(u),s.lineToPoint(p));else{i.isFirstSegmentInPath()&&s.insertPath2D(-1,null,0,0,!0);let t=s.getPathCount()-1;u.setCoordsPoint2D(d),u.scale(1/e),s.insertPoint2D(t,-1,u),i.isLastSegmentInPath()&&!i.isPathClosed()&&(u.setCoordsPoint2D(f),u.scale(1/e),s.insertPoint2D(t,-1,u))}}}return s}function Hc(e,t,n,r,i,a,o,s,c,l,u,d){let f=new U,p=new U,m=r.compare(i)>0;nl(m,r,i,f,p);let h=Yc(e,t,n,f,p,a,o,s,c,l,null,u,d);return m&&tl(c,l,null,u),h}function Uc(e,t){return!!(Z(e.y,G)&&Z(t.y,G)||Z(e.y,-G)&&Z(t.y,-G))}function Wc(e,t){return!!(Z(e.y,G)&&!Z(t.y,G)||Z(e.y,-G)&&!Z(t.y,-G))}function Gc(e,t){return!!(Z(t.y,G)&&!Z(e.y,G)||Z(t.y,-G)&&!Z(e.y,-G))}class Kc{m_sr=null;m_gcs=null;m_transform=null;m_progressTracker=null;m_a=0;m_eSquared=0;m_rpu=0;m_gcsTolerance=0;m_radTolerance=0;m_maxLength=0;m_maxDeviation=0;m_curveType=0;geodeticDensify(e){let t=e.createInstance(),n=e.querySegmentIterator(),r=[],i=[],a=new F,o=e.getDescription().getAttributeCount()>1;for(;n.nextPath();){let e=[0];for(;n.hasNextSegment();){let s=n.nextSegment(),c=s.getStartXY(),l=s.getEndXY();c.scale(this.m_rpu),l.scale(this.m_rpu);let u=new U,d=new U,f=c.compare(l)>0;nl(f,c,l,u,d),r.length=0,i.length=0,this.m_maxLength>0?Yc(this.m_a,this.m_eSquared,this.m_curveType,u,d,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,o?i:null,r,e):Xc(),f&&tl(null,null,o?i:null,r),r[0].setCoordsPoint2D(s.getStartXY()),r.at(-1).setCoordsPoint2D(s.getEndXY());let p=1/this.m_rpu;for(let e=1,t=r.length-1;e<t;e++)r[e].scale(p);if(!o)qc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),r,t);else{let e=rl(f,s,a);Jc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),s,e,i,r,t)}}}return t}shapePreservingDensify(e){let t=e.createInstance(),n=e.querySegmentIterator(),r=[],i=[],a=new F,o=e.getDescription().getAttributeCount()>1;for(;n.nextPath();)for(;n.hasNextSegment();){let e=n.nextSegment(),s=e.getStartXY(),c=e.getEndXY(),l=s.compare(c)>0,u=rl(l,e,a);r.length=0,i.length=0,el(this.m_a,this.m_eSquared,this.m_rpu,u,this.m_sr,this.m_maxLength,this.m_maxDeviation,o?i:null,r),l&&tl(null,null,o?i:null,r),o?Jc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),e,u,i,r,t):qc(n.isFirstSegmentInPath(),n.isLastSegmentInPath()&&!n.isPathClosed(),r,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){let t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Fu(e,this.m_gcs),!t))return e;let n=e.createInstance();n.reserveParts(e.getPointCount(),e.getPathCount());for(let t=0,r=e.getPathCount();t<r;++t){let r=new A,i=e.getPathStart(t),a=e.getPathEnd(t);r.addPoints(e,i,a);let o=e.isClosedPath(t),s=!1;if(o&&a-i===1&&e.hasNonLinearSegmentsPath(t)){let t=new B;e.getPointByVal(i,t),r.add(t),s=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!s){let t=new B;e.getPointByVal(i,t),r.add(t)}if(r=new Rc().execute(r,this.m_transform,this.m_progressTracker),o&&r.getPointCount()>1){let e=r.getXY(0),t=r.getXY(r.getPointCount()-1);e.equals(t)&&r.removePoint(r.getPointCount()-1)}}r.getPointCount()>1&&(n.addPathMultiPoint(r,0,-1,!0),o&&n.closePathWithLine())}return n}}function qc(e,t,n,r){e&&r.insertPath2D(-1,null,0,0,!0);let i=r.getPathCount()-1;r.insertPointsFromPoints(i,-1,n,0,n.length-1,!0),t&&r.insertPoint2D(i,-1,n.at(-1))}function Jc(e,t,n,r,i,a,o){o.reserve(o.getPointCount()+a.length-1);let s=new B;if(n.queryStart(s),e?o.startPathPoint(s):o.lineToPoint(s),a.length>2){let e=r.calculateLength2D();for(let t=1;t<a.length-1;t++){let n=r.lengthToT(i[t]*e);r.queryCoord(n,s),s.setXY(a[t]),o.lineToPoint(s)}}t&&(n.queryEnd(s),o.lineToPoint(s))}function Yc(n,r,i,a,o,s,c,l,u,d,f,p,m){let h={stack:[],error:void 0,hasError:!1};try{let t=e(h,new Sp,!1),g=e(h,new Sp,!1),_=e(h,new Sp,!1);kp.geodeticDistance(n,r,a.x,a.y,o.x,o.y,_,t,g,i);let v=_.val,y=t.val,b=g.val,x=y,S=b;x<0&&(x+=Math.PI*2),S<0&&(S+=Math.PI*2),u&&(u[0]=x),d&&(d[0]=S);let C=NaN,w=NaN;if(f!==null){let e=Ap.q90(n,r),t=Ap.q(n,r,a.y);C=(e-t)/v,w=(e+t)/v}let T=Wc(a,o),E=Gc(a,o),D=T||E,O=cl(a,o,l),k=e(h,new jt(new Sp,new Sp),!1),A=new U,j=new U,M=new U;m[0]=il(a.x,NaN,m[0]);let N=m[0];if(v<=s)return p.push(a.clone()),m[0]=il(o.x,NaN,m[0]),f?.push(0),D?(T&&al(a,o,f,p),E&&ol(a,o,f,p)):O?sl(a,o,y,C,w,f,p):c>0&&(j.setCoords(a.x-N,a.y),A.setCoords(o.x-m[0],o.y),N=Zc()),p.push(o.clone()),v;let P=1+Math.ceil(v/s),F=v/(P-1),I=new U;p.push(a.clone()),I.setCoordsPoint2D(a),j.setCoords(a.x-m[0],a.y),f!==null&&f.push(0);for(let e=1;e<P;e++){let t;if(e<P-1){let o=e*F;kp.geodeticCoordinate(n,r,a.x,a.y,o,y,k.at(0),k.at(1),i),A.setCoords(k.at(0).val,k.at(1).val),m[0]=il(A.x,I.x,m[0]),M.setCoords(m[0]+A.x,A.y),t=e/(P-1)}else m[0]=il(o.x,NaN,m[0]),A.setCoords(o.x-m[0],o.y),M.setCoordsPoint2D(o),t=1;D?(e===1&&T&&al(a,M,f,p),e===P-1&&E&&ol(I,o,f,p)):O?ll(I,M,l)&&(a.x<o.x?I.x>M.x&&(m[0]+=Math.PI*2,M.setCoords(m[0]+A.x,A.y)):I.x<M.x&&(m[0]-=Math.PI*2,M.setCoords(m[0]+A.x,A.y)),sl(I,M,y,C,w,f,p)):c>0&&Zc(),p.push(M.clone()),f?.push(t),I.setCoordsPoint2D(M),j.setCoordsPoint2D(A),N=m[0]}return v}catch(e){h.error=e,h.hasError=!0}finally{t(h)}}function Xc(e,t,n,r,i,a,o,s,c,u){l(0)}function Zc(e,t,n,r,i,a,o,s,c,u,d,f,p,m,h){return l(0),0}function Qc(e,t,n,r){let i=xn(e,t,n),a=xn(e,t,r);return V.distance(i,a)}function $c(e,t,n,r,i,a,o,s){let c=[],u=bt(Array,8),d=2,f=i.getCoord2D(a);u[0][0]=f.x,u[0][1]=f.y,f=i.getCoord2D(o),u[1][0]=f.x,u[1][1]=f.y;let p=e=>{if(n!==null){let t=wp.projToGeog(n,e,u);l(t===e)}for(let e of u)e[0]*=r,e[1]*=r};p(2),c.push(xn(e,t,new U(u[0][0],u[0][1]))),c.push(xn(e,t,new U(u[1][0],u[1][1])));let m=V.distance(c[0],c[1]);if(m>s)return m;let h=0;for(d=3;d<=17;){let n=1/(d-1),r=0;for(let e=1;e<d;++e)if(e&1){let t=Ct(a,o,e*n);i.queryCoord2D(t,f),u[r][0]=f.x,u[r][1]=f.y,r++}p(r);let g=1;for(let n=0;n<r;++n)c.splice(g,0,xn(e,t,new U(u[n][0],u[n][1]))),g++;g=0;let _=c[g];g++;let v=0;for(;g!==c.length;++g){let e=c[g],t=V.distance(_,e);v+=t,_=e}if(v>s)return v;if(h=v-m,l(h>=0||Math.abs(h)<v*1e-14),h<0&&(h=0),m=v,v+h<=s)return v+h;d=2*d-1}return m+h}function el(e,t,n,r,i,a,o,s,c){let u=r.isCurve(),d=zn(e,t)*Math.PI*179/180,f=a;(!(a>0)||a>d)&&(f=d);let p=o,m=p>0,h=NaN;m&&(h=Kn(e,t,p));let g=i.getCoordinateSystemType()===1,_=null;g||(_=i.getPECoordSys());let v=i.getTolerance(0),y=r.getStartXY(),b=r.getEndXY(),x=new U,S=new U;if(g)x.setCoordsPoint2D(y),x.scale(n),S.setCoordsPoint2D(b),S.scale(n);else{let e=[y.x,y.y,b.x,b.y];wp.projToGeog(_,2,e),x.setCoords(e[0],e[1]),x.scale(n),S.setCoords(e[2],e[3]),S.scale(n)}let C=0,w=0,T=[],E=[],D=[];T.push(b.clone()),E.push(S.clone()),D.push(1),c.push(y.clone()),s!==null&&s.push(w);let O=i.isPannable(),k=y.clone(),A=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333],j=5;u||(m?(A[0]=.5,A[1]=.25,A[2]=.75,j=3):j=1),l(f>0);let M=e=>{if(e=e.clone(),_!==null){let t=[e.x,e.y];wp.projToGeog(_,1,t),e.setCoords(t[0],t[1])}return e.scale(n),e};for(;E.length>0;){let a=T.at(-1).clone();S.assign(E.at(-1));let o=D.at(-1),d=!1,p=NaN,y=$c(e,t,_,n,r,w,o,f),b=f>=y&&Math.abs(x.y-S.y)<Math.PI*.9;g&&b&&(b=Math.abs(x.x-S.x)<Math.PI*.9);let N=new U,P=new U,F=!1;if(!m&&b&&b&&(F=!0),r.calculateSubLength(w,o)<=v&&(F=!0),!F)for(let s=0;s<j;s++){let c=Ct(w,o,A[s]),f=new U;r.queryCoord2D(c,f);let _=M(f);if(s===0&&(p=c,N.setCoordsPoint2D(f),P.setCoordsPoint2D(_),!b)){d=!0;break}if(l(m),g&&Math.abs(x.x-_.x)>=Math.PI){d=!0;break}let v=new U,y=new U;u?(v=U.lerp(k,a,A[s]),y=M(v)):(v=f.clone(),y=_.clone());let C=On(e,t,x,S,A[s]),T=C.clone();if(g?(T.x/=n,T.y/=n):(T.x/=n,T.y/=n,kc(i.getGCSToSRTransform(),[T],1,[T],null)),T.isNAN()){let{second:n}=Nn(e,t,xn(e,t,_),xn(e,t,x),xn(e,t,S),2,null);if(n>h){d=!0;break}}else{if(O){let e=i.getPannableExtent().width(),t=Ct(r.getStartX(),r.getEndX(),.5);for(;T.x<t-e*.5;)T.x+=e;for(;T.x>=t+e*.5;)T.x-=e}let n=r.getClosestCoordinateOnInterval(T,new W(w,o),-1),a=r.getCoord2D(n);a=M(a);let s=Qc(e,t,a,C);if(s>h){if(s<4*h){let{second:n}=Nn(e,t,xn(e,t,a),xn(e,t,x),xn(e,t,S),2,null);s=n}if(s>h){d=!0;break}}else if(u){let n=xn(e,t,_),r=xn(e,t,x),i=xn(e,t,S),{second:a}=Nn(e,t,n,r,i,3,null);if(a<=h){n=xn(e,t,y);let{second:o}=Nn(e,t,n,r,i,3,null);a=o}if(a>h){d=!0;break}}}}d?(T.push(N.clone()),E.push(P.clone()),D.push(p)):(T.pop(),E.pop(),D.pop(),c.push(a.clone()),C+=y,s!==null&&s.push(C),k.setCoordsPoint2D(a),x.setCoordsPoint2D(S),w=o)}if(s!==null){let e=1/C;for(let t=0;t<s.length;t++)s[t]*=e}}function tl(e,t,n,r){if(r.reverse(),n!==null&&n.reverse(),e){let n=e[0];e[0]=t[0],t[0]=n}}function nl(e,t,n,r,i){e?(r.setCoordsPoint2D(n),i.setCoordsPoint2D(t)):(r.setCoordsPoint2D(t),i.setCoordsPoint2D(n))}function rl(e,t,n){return e?(n.create(t.getGeometryType()),t.copyTo(n.get()),n.get().reverse(),n.get()):t}function il(e,t,n){if(Number.isNaN(t)){for(;n-e>Math.PI;)n-=Math.PI*2;for(;e-n>Math.PI;)n+=Math.PI*2;return n}return n+e-t>Math.PI?n-=Math.PI*2:t-(n+e)>Math.PI&&(n+=Math.PI*2),n}function al(e,t,n,r){if(e.y>0){let i=new U;i.setCoords(t.x,G),!Z(e.x,i.x)&&!Z(t.y,i.y)&&(r.push(i),n!==null&&n.push(0))}else{let i=new U;i.setCoords(t.x,-G),!Z(e.x,i.x)&&!Z(t.y,i.y)&&(r.push(i),n!==null&&n.push(0))}}function ol(e,t,n,r){if(t.y>0){let i=new U;i.setCoords(e.x,G),!Z(t.x,i.x)&&!Z(e.y,i.y)&&(r.push(i),n!==null&&n.push(1))}else{let i=new U;i.setCoords(e.x,-G),!Z(t.x,i.x)&&!Z(e.y,i.y)&&(r.push(i),n!==null&&n.push(1))}}function sl(e,t,n,r,i,a,o){if(xp(n)){if(G-e.y>0){let t=new U;t.setCoords(e.x,G),o.push(t),a!==null&&a.push(r)}if(G-t.y>0){let e=new U;e.setCoords(t.x,G),o.push(e),a!==null&&a.push(r)}}else{if(G+e.y>0){let t=new U;t.setCoords(e.x,-G),o.push(t),a!==null&&a.push(i)}if(G+t.y>0){let e=new U;e.setCoords(t.x,-G),o.push(e),a!==null&&a.push(i)}}}function cl(e,t,n){return!(!ll(e,t,n)||Z(e.y,G)||Z(e.y,-G)||Z(t.y,G)||Z(t.y,-G))}function ll(e,t,n){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=n}function ul(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=Math.PI*2;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=Math.PI*2}function dl(n,r,i,a){let o={stack:[],error:void 0,hasError:!1};try{let t=[i.x],s=[i.y-a],c=[i.x],l=[i.y+a];Rn(t,s),Rn(c,l);let u=e(o,new Sp,!1),d=e(o,new Sp,!1);return kp.greatEllipticDistance(n,r,i.x,i.y,t[0],s[0],u,null,null),kp.greatEllipticDistance(n,r,i.x,i.y,c[0],l[0],d,null,null),Math.min(u.val,d.val)}catch(e){o.error=e,o.hasError=!0}finally{t(o)}}function fl(e,t,n,r,i){let a=new T;n.queryEnvelope(a);let o=Te(null,n,!0).total();if(t.xmin-a.xmin<=o&&a.xmax-t.xmax<=o)return n;let s=t.width(),c=0;for(;t.xmin+c*s<a.xmin;)c++;for(;t.xmin+c*s>a.xmin;)c--;let l=c*s,u=new K;u.setShiftCoords(-l,0);let d=n;d.applyTransformation(u);let f=new T;d.queryEnvelope(f);let p=null;if(f.xmax>t.xmax){let n=0,r=new T;r.setCoords({env2D:t}),--r.ymin,r.ymax+=1;let a=d;for(;r.xmin<f.xmax;){f.xmax>r.xmax&&(a=Nu(a,e,2,!0,r.xmax));let o=st(a,r),c=je(null,o,!0).total(),l=q(a,r,c,NaN,i);p===null?p=l===a?l.clone():l:(u.setShiftCoords(-n*s,0),l.applyTransformation(u),p.add(l,!1)),n++,r.xmin=r.xmax,r.xmax=t.xmax+n*s}}else p=d;return p}class pl{m_gcs;m_a;m_e2;m_rpu;m_curvCenterRad;m_cartCenter3D;m_basisX=new V;m_basisY=new V;m_normal=new V;m_d;m_northPolePcs;m_southPolePcs;constructor(e,t){l(e.getCoordinateSystemType()===1),this.m_gcs=e;let n=Pf();e.querySpheroidData(n),this.m_a=n.majorSemiAxis,this.m_e2=n.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);let r=this.m_curvCenterRad.x,i=this.m_curvCenterRad.y,a=Math.cos(r),o=Math.sin(r),s=Math.cos(i),c=Math.sin(i);this.m_cartCenter3D=Cn(this.m_a,this.m_e2,a,o,s,c),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),V.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(U.construct(0,Math.PI*.5/this.m_rpu)),this.m_southPolePcs=this.projectPoint(U.construct(0,-Math.PI*.5/this.m_rpu))}project(e){let t=e.getGeometryType();if(f(t)){S(e);let t=e;return this.projectMultiVertex(t)}n(`Gnomonic.project`)}unproject(e,t,r){let a=e.getGeometryType();if(f(a)){S(e);let n=e,o=[];if(a===i.enumPolygon){let e=n.getPathCount();for(let t=0;t<e;t++){let e=n.calculateRingArea2D(t);o.push(e)}}return this.unprojectMultiVertex(t,n),s(a)?(Sl(this.m_gcs,0,n),ml(o,this.m_gcs,0,n,r)):n=Eu(n,this.m_gcs,0,!0,0,r),n}n(`Gnomonic.unproject`)}projectPoint(e){let t=e.mul(this.m_rpu),n=xn(this.m_a,this.m_e2,t),r=this.m_normal.dotProduct(n);if(r<=0)return U.construct(NaN,NaN);let i=this.m_d/r,a=n.mul(i).sub(this.m_cartCenter3D),o=new U;return o.x=this.m_basisX.dotProduct(a),o.y=this.m_basisY.dotProduct(a),o}unprojectPoint(e){let t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return En(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){let t=e.getImpl(),n=!0,r=new U,i=new U;for(let e=0,a=t.getPointCount();e<a;e++)t.queryXY(e,r),r.y*this.m_rpu>Math.PI*.5?i.assign(this.m_northPolePcs):r.y*this.m_rpu<-Math.PI*.5?i.assign(this.m_southPolePcs):i.assign(this.projectPoint(r)),t.setXYNoCurves(e,i),i.isNAN()&&(n=!1);return t.notifyModifiedFlags(2001),n}unprojectMultiVertex(e,t){let n=t.getImpl(),r=e*e,i=!this.m_northPolePcs.isNAN(),a=!this.m_southPolePcs.isNAN();for(let e=0,t=n.getPointCount();e<t;e++){let t=n.getXY(e),o=new U;i&&U.sqrDistance(t,this.m_northPolePcs)<=r?(o.setCoords(this.m_curvCenterRad.x,Math.PI*.5),o.scale(1/this.m_rpu)):a&&U.sqrDistance(t,this.m_southPolePcs)<=r?(o.setCoords(this.m_curvCenterRad.x,-Math.PI*.5),o.scale(1/this.m_rpu)):o=this.unprojectPoint(t),n.setXYNoCurves(e,o)}n.notifyModifiedFlags(2001)}}function ml(e,t,n,r,a){let o=r.getGeometryType(),s=t.getPannableExtent(),c=r,l=!1,u=!1;if(o===i.enumPolygon){let r=new T,i=U.construct(n,0);r.setCoords({env2D:s}),r.centerAt(i),l=hl(e,t,r,c,a);let o=xl(t,r,c,a);o!==c&&(u=!0),c=o}else c=new Rc().foldInto360RangeGeodetic(c,t,2);o===i.enumPolygon&&(l||u)&&(c=new xc().execute(c,t,!1,a)),c!==r&&(r.setEmpty(),r.add(c,!1))}function hl(e,t,n,r,i){let a=gl(n,r),o=_l(e,t,n,r,i);return a||o}function gl(e,t){let n=new T;t.queryEnvelope(n);let r=Z(e.ymax,n.ymax),i=Z(e.ymin,n.ymin),a=r||i;return a?(vl(e,t),a):!1}function _l(e,t,n,r,i){let a=[],o=[],s=.5*n.width();for(let c=0;c<r.getPathCount();c++){let l=r.getXY(r.getPathStart(c)),u=r.getXY(r.getPathEnd(c)-1),d=e[c]<0;if(Math.abs(l.x-u.x)>s){let e=yl(d,t,n,c,r,i);a.push(e),o.push(c)}else if(!d&&r.calculateRingArea2D(c)<0){let e=bl(t,n,c,r,i);a.push(e),o.push(c)}}if(a.length===0)return!1;let c=new k({vd:r.getDescription()}),l=0,u=o[l];for(let e=0;e<r.getPathCount();e++)e===u?(c.add(a[l],!1),l++,l<o.length&&(u=o[l])):c.addPath(r,e,!0);return r.setEmpty(),r.add(c,!1),!0}function vl(e,t){let n=new k,r=new T;for(let i=0;i<t.getPathCount();i++){t.queryPathEnvelope(i,r);let a=Z(e.ymax,r.ymax),o=Z(e.ymin,r.ymin);if(!(a||o)){n.addPath(t,i,!0);continue}n.insertPath2D(-1,null,0,0,!0);let s=t.getPathStart(i),c=t.getPathEnd(i),l=c-s,u=-1;for(u=s;u<c;u++){let n=t.getXY(u);if(a=Z(e.ymax,n.y),o=Z(e.ymin,n.y),!a&&!o)break}let d=u,f=!1,p=NaN;do{let r=t.getXY(d);a=Z(e.ymax,r.y),o=Z(e.ymin,r.y);let c=s+(d+1-s)%l;if(!a&&!o)n.insertPoint2D(i,-1,r),p=r.x,f=!1;else{let a=U.construct(p,r.y);n.insertPoint2D(i,-1,a);let o=t.getXY(c),s=Z(e.ymax,o.y),l=Z(e.ymin,o.y);!s&&!l&&(a=U.construct(o.x,r.y),f?n.setXYNoCurves(n.getPointCount()-1,a):n.insertPoint2D(i,-1,a)),f=!0}d=c}while(d!==u)}t.setEmpty(),t.add(n,!1)}function yl(e,t,n,r,i,a){let o=new k,s=new k,c=new K,l=i.getXY(i.getPathStart(r)),u=i.getXY(i.getPathEnd(r)-1),d=n.width(),f=.5*d,p=new T;i.queryEnvelope(p);let m=Math.ceil(p.width()/d)+1,h,g;l.x>u.x?(h=-d,g=e?n.ymin:n.ymax):(h=d,g=e?n.ymax:n.ymin),c.setShiftCoords(h,0),o.addPath(i,r,!0),s.add(o,!1);let _=new B;for(let e=0;e<m;e++)s.applyTransformation(c),s.getPointByVal(0,_),o.lineToPoint(_),o.addSegmentsFromPath(s,0,0,s.getSegmentCount()-1,!1);let v=o.getXY(0),y=o.getXY(o.getPointCount()-1);v.y=g,y.y=g,o.lineTo(y);let b=new U;for(b.setCoordsPoint2D(y),b.x-=.5*h;Math.abs(b.x-v.x)>f;)o.lineTo(b),b.x-=.5*h;o.lineTo(v);let x=n.getCenter().x,S=new T;o.queryEnvelope(S);let C=0,w=S.getCenter().x;w-x>f?C=-Math.ceil((w-x-f)/d):x-w>f&&(C=Math.ceil((x-w-f)/d)),C!==0&&(c.setShiftCoords(C*d,0),o.applyTransformation(c));let E=new N,D=E.addGeometry(o);Pu(E,D,t,0,2,!0,n.xmin),Pu(E,D,t,0,2,!0,n.xmax);let O=E.getGeometry(D),A=st(O,n);A.inflateCoords(0,1);let j=je(null,A,!0);return q(O,n,j.total(),NaN,a)}function bl(e,t,n,r,i){let a=t.width(),o=.5*a,s=t.getCenter().x,c=new T;r.queryPathEnvelope(n,c);let l=0,u=c.getCenter().x;if(u-s>o?l=-Math.ceil((u-s-o)/a):s-u>o&&(l=Math.ceil((s-u-o)/a)),l!==0){let e=new K;e.setShiftCoords(l*a,0),r.getImpl().applyTransformationToPath(e,n),r.queryPathEnvelope(n,c),u=c.getCenter().x}let d,f=new T;t.containsExclusiveEnvelope(c)?(d=!1,f.setCoords({env2D:t})):(d=!0,f.setCoords({env2D:t}),f.xmin-=a,f.xmax+=a);let p=r.createInstance();p.addPathPoint2D(null,0,!0);let m=new U;if(m.setCoords(f.xmin,f.ymin),p.insertPoint2D(0,-1,m),m.setCoords(f.xmin,f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(.5*(f.xmin+f.xmax),f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(f.xmax,f.ymax),p.insertPoint2D(0,-1,m),m.setCoords(f.xmax,f.ymin),p.insertPoint2D(0,-1,m),m.setCoords(.5*(f.xmin+f.xmax),f.ymin),p.insertPoint2D(0,-1,m),!d)p.addPath(r,n,!0);else{p.addPath(r,n,!0);let o=new K;u<s?o.setShiftCoords(a,0):o.setShiftCoords(-a,0),r.getImpl().applyTransformationToPath(o,n),p.addPath(r,n,!0);let c=new N,l=c.addGeometry(p);Pu(c,l,e,0,2,!0,t.xmin),Pu(c,l,e,0,2,!0,t.xmax),p=c.getGeometry(l);let d=st(p,t);d.inflateCoords(0,1);let f=je(null,d,!0).total();p=q(p,t,f,NaN,i)}return p}function xl(e,t,n,r){let i=new T;n.queryEnvelope(i);let a=Te(null,n,!0).total();if(t.xmin-i.xmin<=a&&i.xmax-t.xmax<=a)return n;let o=n.createInstance(),s=n.createInstance(),c=new T,l=n.getPathCount();for(let i=0;i<l;i++){if(n.queryPathEnvelope(i,c),t.xmin-c.xmin<=a&&c.xmax-t.xmax<=a){o.addPath(n,i,!0);continue}s.setEmpty(),s.addPath(n,i,!0),s=fl(e,t,s,!0,r),o.add(s,!0)}return o}function Sl(e,t,n){let r=e.getPannableExtent(),i=U.construct(t,0);r.centerAt(i);let a=r.width(),o=.5*a,s=new U;s.setNAN();let c=NaN;for(let e=0;e<n.getPathCount();e++)for(let t=n.getPathStart(e);t<n.getPathEnd(e);t++){let i=n.getXY(t),l=Z(i.y,r.ymax)||Z(r.ymin,i.y);t===n.getPathStart(e)?(s.setNAN(),c=0):!s.isNAN()&&!l&&(c=Cl(i.x,s.x,o,a,c)),i.x+=c,n.setXYNoCurves(t,i),l||s.setCoordsPoint2D(i)}n.getImpl().notifyModifiedFlags(2001)}function Cl(e,t,n,r,i){return i+e-t>n?i-=r:t-(i+e)>n&&(i+=r),i}function wl(e,t,n,r,i,a){let o=t.getAttributeStreamRef(0),s=t.getPointCount(),c=!1,l=new U;for(let e=0;e<s;++e){if(o.queryPoint2D(2*e,l),a&1&&l.y>=n){c=!0;break}if(a&2&&l.y<=-n){c=!0;break}}if(!c)return!1;let u=!1;e&&(u=t.getImpl().isClosedPathInXYPlane(0));let d=new N,f=d.addGeometry(t),p=d.getFirstPath(f),m=-1,h=!0,g=new U,_=new B,v=z,y=kl*i/360;for(let e=d.getFirstVertex(p);e!==z;e=d.getNextVertex(e)){d.queryXY(e,l);let t=a&1&&l.y>=n?1:0;if(t|=a&2&&l.y<=-n?2:0,m>0&&m!==t){if(g.x!==l.x){let t=d.getPrevVertex(e);d.queryPoint(t,_);let n=d.insertVertex(p,e,_);g.x=l.x,d.setXY(n,g)}if(u){let t=v===z?d.getFirstVertex(p):d.getNextVertex(v),n=d.getPrevVertex(e);for(;t!==n;)t=d.removeVertex(t,!1);if(v!==z){let e=d.getXY(v),t=d.getXY(n);if(Math.abs(e.x-t.x)>y){d.queryPoint(v,_);let r=d.insertVertex(p,n,_);e.x=Ct(e.x,t.x,.5),d.setXY(r,e)}}}v=z}if(t&&(l.y=Mt(r,l.y),d.setXY(e,l),!h&&m!==t)){if(l.x!==g.x){d.queryPoint(e,_);let t=d.insertVertex(p,e,_);d.setXYCoords(t,g.x,l.y),v=t}else v=e}m=t,g.assign(l),h=!1}if(u){if(v!==z){let e=d.getNextVertex(v);for(;e!==z;)e=d.removeVertex(e,!1)}let e=d.getFirstVertex(p),t=d.getLastVertex(p),n=d.getXY(e),r=d.getXY(t);if(!n.equals(r)&&(d.queryPoint(e,_),t=d.insertVertex(p,z,_),Math.abs(n.x-r.x)>y)){let e=d.insertVertex(p,t,_);n.x=Ct(n.x,r.x,.5),d.setXY(e,n)}}return t.assignCopy(d.getGeometry(f)),!0}function Tl(e,t){let n=new k({vd:e});n.addEnvelope(t,!1);let r=t.width()/180;return n=new an().execute(n,r,0,0,null),n}function El(e,t){let n=e.getPannableExtent();return Number.isNaN(t)||n.centerAtCoords(t,0),n}function Dl(e,t,n){let r=Pf();t.querySpheroidData(r);let i=t.getGCS()===t?null:t.getSRToGCSTransform(),a=bt(U,100),o=new V(0,0,0),s=e.getPointCount(),c=t.getGCS().getUnit().getUnitToBaseFactor();for(let t=0,n=s;t<n;){let s=Math.min(100,n-t);e.queryCoordinates(a,s,t,t+s),i&&new Rc().transform(i,a,s,a,!1);for(let e=0;e<s;e++){if(a[e].isNAN())continue;a[e].scale(c);let t=xn(r.majorSemiAxis,r.e2,a[e]);o.addThis(t)}t+=s}let l=En(r.majorSemiAxis,r.e2,o);l.scale(1/c);let u=new pl(t.getGCS(),l),d=e;if(!u.project(d))return 0;n.length=e.getPathCount();let f=d.calculateArea2D()<0;for(let t=0,r=e.getPathCount();t<r;t++){let e=d.calculateRingArea2D(t);n[t]=f?e<0:e>0}return f?-1:1}function Ol(e,t,n,r,a){if(!t.isPannable()||e.isEmpty())return e;let s=e.getGeometryType();s===i.enumGeometryCollection&&p(`not yet impl for geometry collection`);let c=t.getPannableExtent();Number.isNaN(n)&&(n=c.getCenterX());let l=c.width(),u=l*.5,d=a>0,m=e.queryInterval(0,0);if(!d&&m.width()<u||!f(e.getGeometryType())){let t=m.getCenter();if(Math.abs(t-n)<=u)return e;{let r=new K,i=n-t,a=ht(i/l)*l;r.setShiftCoords(a,0);let o=e.clone();return o.applyTransformation(r),o}}if(s===i.enumPolygon){let i=new E({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),d&&(i=Bc(i,t,2,a,NaN,null,!0));let o=[];if(!r){{let n=e;d&&(n=new k,n.add(i,!1));let r=Dl(e,t,o);if(r)r<0&&i.reverseAllPaths();else{let e=n.getPathCount();for(let t=0;t<e;t++)o.push(n.calculateRingArea2D(t)>0)}}r=o}return new Al(null,r,i,null,t,n,3,0,null).geoNormalizePolygonGeometry(!0)}if(s===i.enumPolyline){let r=new E({vd:e.getDescription()});return r.addAndExplicitlyOpenAllPaths(e,!1),d&&(r=Bc(r,t,2,a,NaN,null,!0)),new Al(null,null,r,null,t,n,3,0,null).geoNormalizePolylineGeometry(!0)}if(s===i.enumMultiPoint){let t=e,r=t.getAttributeStreamRef(0),i,a=null,o=n,s=0,c=.1*l;for(let n=0,d=t.getPointCount();n<d;n++){let t=r.read(n*2),d=t-o;if(Math.abs(d)>u&&(d=ht(d/l)*l,s-=d,Math.abs(s)<c&&(s=0)),s!==0){a||=(i=e.clone(),i.getAttributeStreamRef(0));let r=t+s;a.write(n*2,r)}o=t}return a?(i.notifyModified(),i):e}o(``)}const kl=210;class Al{m_inputPoly;m_originalGeometry;m_polygonRingFlags;m_originalSR;m_pannableSR;m_pannableExtent;m_progressTracker;m_centralLongitude;m_poleSnappingTolerance;m_width360;m_degree;m_GCSLargeDelta;m_poleFlags;m_bAdjustedAtPoles=0;constructor(e,t,n,r,i,a,o,s,c){this.m_inputPoly=n,this.m_progressTracker=c,this.m_originalGeometry=e,this.m_originalSR=r,this.m_polygonRingFlags=t,this.m_pannableSR=i,this.m_poleSnappingTolerance=s,this.m_poleFlags=o,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=El(this.m_pannableSR,a),this.m_centralLongitude=Number.isNaN(a)?this.m_pannableExtent.getCenterX():a,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=210*this.m_degree,l(this.m_originalGeometry===null&&this.m_originalSR===null||this.m_originalGeometry!==null&&this.m_originalSR!==null)}geonormalizeRing(e,t,n,r,i,a,s){let c=n,u=new E({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,e,!0),this.m_poleFlags!==0&&(this.m_bAdjustedAtPoles|=+!!wl(!0,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags),this.m_bAdjustedAtPoles&&(c=!1));let d=-1;c&&(d=this.m_originalGeometry.getPathStart(e));let f=u.getAttributeStreamRef(0),p=u.getPointCount(),m=0,h=f.read(0),g=0,_=3*this.m_pannableSR.getTolerance(0),v=!1,y=new U,b=new U,x=!1,S=u.hasNonLinearSegments(),C=new U;for(let e=1;e<p;++e){f.queryPoint2D(2*e,C);let t=C.x,n=t+m,i=n-h;if(C.x=n,Math.abs(i)>this.m_GCSLargeDelta){if(c){let t=d+e-1,n=d+(e+1<p?e:0),o=a.read(t*2),s=(a.read(n*2)-o)*r;Math.abs(i-s)>1*this.m_degree&&(c=!1)}if(!c){let e=Mt(this.m_width360,n-h);m-=e,n=t+m,++g,x=m!==0,C.x=n}}else v||at(y,b,C,_)&&(v=!0);x&&(S&&o(`error in geonormalize_ring_ for curves`),f.write(2*e,n)),h=n,y.setCoordsPoint2D(b),b.setCoordsPoint2D(C)}g&&u.notifyModified();let w=u.getXY(0),T=u.getXY(p-1);if(U.distance(w,T)<_){let e=this.finalizeGeoNormalizeClosedRing(u,v,i);s.add(e,!1)}else{t<0&&(this.m_originalGeometry===null?t=1:(l(this.m_originalGeometry!==null),t=+(this.m_originalGeometry.calculateRingArea2D(e)>0)));let n=this.finalizeGeoNormalizeOpenedRing(t>0,u);s.add(n,!1)}}geoNormalizePolygonGeometry(e){l(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),l(this.m_pannableSR.isPannable());let t=null,n=NaN,r=!!this.m_originalSR&&this.m_originalSR.isPannable();r&&(t=this.m_originalGeometry.getAttributeStreamRef(0),n=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;let i=new k({vd:this.m_inputPoly.getDescription()});for(let a=0,o=this.m_inputPoly.getPathCount();a<o;++a){let o=this.m_polygonRingFlags?+!!this.m_polygonRingFlags[a]:-1;this.geonormalizeRing(a,o,r,n,e,t,i)}let a=this.m_pannableSR.getTolerance(0),o=this.m_pannableExtent.width()/180;Bu(i,this.m_pannableExtent,a*.1,!1);let s=T.constructEmpty();if(s.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;let t=T.constructEmpty();for(let n=0,r=i.getPathCount();n<r;n++)if(i.queryPathEnvelope(n,t),!(s.xmin<=t.xmin&&s.xmax>=t.xmax)&&!(t.xmin>=s.xmax||t.xmax<=s.xmin)){e=!1;break}if(e)break;s.move(this.m_width360*.5,0)}e||s.setCoords({env2D:this.m_pannableExtent})}let c=q(i,s,a,o,this.m_progressTracker),u=i!==c,d=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,f=c.calculateArea2D(),p=0;if(f>0&&d<0)p=1;else if(f<=0&&d>0){if(f===0){if(this.m_originalSR){let e=NaN;this.m_originalSR.getCoordinateSystemType()===2?e=this.m_originalSR.getPCSHorizon().calculateArea2D():this.m_originalSR.getCoordinateSystemType()===1&&(e=this.m_originalSR.getPannableExtent().getArea()),d>e*.99&&(p=-1)}}else p=-1}if(p!==0){let e=Tl(c.getDescription(),s);e.add(c,!1),u=!0,c=e}return u&&(c=new xc().execute(c,this.m_pannableSR,!1,this.m_progressTracker)),c}geoNormalizePolylineGeometry(e){l(this.m_pannableSR.isPannable());let t=null,n=this.m_originalSR&&this.m_originalSR.isPannable(),r=1;n&&(l(this.m_originalGeometry),r=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));let i=this.m_pannableExtent.width(),a=i*vt()*4,s=e,c=NaN,u=W.constructEmpty();this.m_bAdjustedAtPoles=0;let d=new E({vd:this.m_inputPoly.getDescription()});for(let e=0,f=this.m_inputPoly.getPathCount();e<f;++e){let f=n,p=new E({vd:this.m_inputPoly.getDescription()});p.addPath(this.m_inputPoly,e,!0);let m=this.m_inputPoly.isClosedPath(e);this.m_poleFlags!==0&&(this.m_bAdjustedAtPoles|=+!!wl(m,p,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags),this.m_bAdjustedAtPoles&&(f=!1));let h=-1,g=p.getPointCount(),_=!1;f&&(h=this.m_originalGeometry.getPathStart(e),_=this.m_originalGeometry.isClosedPath(e));let v=p.getAttributeStreamRef(0),y=0,b=v.read(0),x=0,S=new U,C=new U,w=!1,D=p.hasNonLinearSegments(),O=new U;for(let e=1;e<g;++e){v.queryPoint2D(2*e,O);let n=O.x,i=n+y,a=i-b;if(O.x=i,Math.abs(a)>this.m_GCSLargeDelta){if(f){let n=h+e-1,i=h;(!_||e+1<g)&&(i+=e);let o=t.read(n*2),s=(t.read(i*2)-o)*r;Math.abs(a-s)>1*this.m_degree&&(f=!1)}if(!f){let e=Mt(this.m_width360,i-b);y-=e,i=n+y,++x,w=y!==0,O.x=i}}w&&(D&&o(`error in geonormalize_ring_ for curves`),v.write(2*e,i)),b=i,S.setCoordsPoint2D(C),C.setCoordsPoint2D(O)}if(x&&p.notifyModified(),s){let e=!1;if(!p.isEmpty()){let t=T.constructEmpty();if(p.queryEnvelope(t),t.width()>=i||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(c)){let e=this.m_centralLongitude-i*.5;c=t.xmin,c+=Math.round((e-t.xmin)/i)*i,c>e&&(c-=i),l(c<=e),c<e&&(c+=i),l(c>=e)}let n=Math.round((c-t.xmin)/i)*i;if(t.xmin+n>c+a&&(n-=i),t.xmin+n<c-a&&(n+=i),u.mergeCoordinate(t.xmin+n),u.mergeCoordinate(t.xmax+n),e=u.width()>=i,!e){let e=new K;e.setShiftCoords(n,0),p.applyTransformation(e)}}}d.add(p,!1),e&&(d=(()=>{let e=new E({vd:d.getDescription()});for(let t=0,n=d.getPathCount();t<n;++t){let n=new E({vd:d.getDescription()});n.addPath(d,t,!0);let r=Eu(n,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(r,!1)}return e})(),s=!1)}else{let e=Eu(p,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);d.add(e,!1)}}if(s)return d;let f=this.m_pannableSR.getTolerance(0),p=this.m_pannableExtent.width()/180;return Bu(d,this.m_pannableExtent,f*.1,!1),q(d,this.m_pannableExtent,f,p,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){let n=t.getPointCount(),r=t.getXY(0),i=t.getXY(n-1);{let e=Math.abs(i.x-r.x),t=Math.round(e/this.m_width360)*this.m_width360;l(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}let a=_t(i.x-r.x),o=T.constructEmpty();t.queryLooseEnvelope(o);let s=this.m_pannableExtent.getCenterX(),c=0,u=s-this.m_width360,d=s+this.m_width360;if(a>=0){let e=Math.ceil((u-o.xmin)/this.m_width360);for(e*=this.m_width360;u>o.xmin+e;)e+=this.m_width360;for(;u<o.xmax+e;)e-=this.m_width360;for(c=e,o.width()>720&&(d=u+Math.ceil(o.width()/360)*360);d<o.xmax;)d+=this.m_width360}else{let e=Math.ceil((d-o.xmax)/this.m_width360);for(e*=this.m_width360;d<o.xmax+e;)e-=this.m_width360;for(;d>o.xmin+e;)e+=this.m_width360;for(c=e,o.width()>720&&(u=d-Math.ceil(o.width()/360)*360);u>o.xmin;)u-=this.m_width360}let f=Math.round(Math.abs(i.x-r.x)/this.m_width360)*this.m_width360,p=a*f,m=o.clone();m.move(c,0);let h=new U(0,0),g=new K;g.setShiftCoords(c,0),t.applyTransformation(g);let _=new E({vd:t.getDescription()});_.add(t,!1),h.assign(t.getXY(n-1));let v=0,y=_.getXY(0).x;for(;a>0?m.xmax<d:m.xmin>u;)m.move(p,0),g.xd=p,t.applyTransformation(g),y+=p,this.m_pannableExtent.xmin<=y&&this.m_pannableExtent.xmax>=y&&(v=_.getPointCount()-1),t.setXY(0,h),h.assign(t.getXY(n-1)),_.addSegmentsFromPath(t,0,0,n-1,!1);let b=new k({vd:_.getDescription()});b.add(_,!1);let x=_.getXY(0),S=_.getXY(_.getPointCount()-1),C=a<0?e:!e,w=b.getPointCount()-1;if(C){let e=new U(S.x,this.m_pannableExtent.ymax);b.lineTo(e);let t=new U(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);b.lineTo(t);let n=new U(x.x,this.m_pannableExtent.ymax);b.lineTo(n)}else{let e=new U(S.x,this.m_pannableExtent.ymin);b.lineTo(e);let t=new U(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);b.lineTo(t);let n=new U(x.x,this.m_pannableExtent.ymin);b.lineTo(n)}if(b.interpolateAttributesPath(0,w,0),b.getImpl().changeRingStartPoint(v),f>this.m_width360){let e=new k({copy:b});g.setShiftCoords(this.m_width360,0),e.applyTransformation(g),b.add(e,!1)}return b}finalizeGeoNormalizeClosedRing(e,t,n){let r=new k({vd:e.getDescription()});if(r.add(e,!1),!r.hasNonLinearSegments()||!(()=>{let e=r.getPointCount()-2;return r.getSegmentType(e)!==i.enumLine})())r.removePointFromPath(0,r.getPointCount()-1);else{let e=new F,t=r.getPointCount()-2;r.getSegmentBuffer(t,e,!1),r.removePointFromPath(0,t+1),r.closeLastPathWithSegment(e.get())}let a=T.constructEmpty();r.queryLooseEnvelope(a);let o=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(o*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+o;)o+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+o;)o-=this.m_width360;if(o+=this.m_width360,o!==0){a.move(o,0);let e=new K;e.setShiftCoords(o,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){let e=r.calculateArea2D(),t=new xc().execute(r,this.m_pannableSR,!0,this.m_progressTracker);if(t!==r){let n=t.calculateArea2D();_t(e)!==_t(n)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=n?new k({copy:r}):new k({move:r}),n)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);let t=new K;t.setShiftCoords(this.m_width360,0),r.applyTransformation(t),e.add(r,!1)}return e}let s=new k({vd:e.getDescription()});s.add(r,!1);let c=t||a.width()>this.m_width360-this.m_pannableSR.getTolerance(0)*10;for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);let e=new K;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),s.add(r,!1)}if(c){let e=s.calculateArea2D();s.setFillRule(1),s=new xc().execute(s,this.m_pannableSR,!0,this.m_progressTracker);let t=s.calculateArea2D();_t(e)!==_t(t)&&s.reverseAllPaths()}return s}geonormalize_ring_(e,t,n,r,i,a,o){l(0)}}function jl(e){l(0);let t=of(e),n=new Pl;return n.setVertProj_(t),n}function Ml(e,t=!0){return l(0),{}}function Nl(e){return Sf()}class Pl{m_hashCode=0;m_peVertSysVal=null;m_verticalUnit=new Tf;m_verticalShift=0;m_userVerticalWKID=0;m_bIsDepth=!1;getType(){return l(0),0}getID(){return l(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return l(0),``}getTextExtended(e){return l(0),``}getText2(e){return l(0),``}getUnit(){return l(0),{}}equals(e){return l(0),!1}equalForProjection(e){return l(0),!1}getPeVertcsCopy(){return l(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return l(0),0}isDepth(){return l(0),!1}getVerticalShift(){return l(0),0}isCustomWkid(){return this.m_peVertSysVal?this.m_peVertSysVal.isCustomWkid():!1}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Fl(e,t,n,r,i){if(e.equals(t))return!1;if(r){let n=1,a=0,o=1,s=1,c=0,l=1;Number.isNaN(e.m_heightMetersPerUnit)||(n=e.m_heightMetersPerUnit,a=e.m_heightZ0,o=e.m_heightSign,s=t.m_heightMetersPerUnit,c=t.m_heightZ0,l=t.m_heightSign);let u=o*l*n/s;for(let e=0;e<i;e++)r[e]=(r[e]-a)*u+c}let a=1,o=0;if(Number.isNaN(e.m_XYToRadians)||(a=e.m_XYToRadians/t.m_XYToRadians,o=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,o!==0&&(o=ve(o),o/=t.m_XYToRadians)),Array.isArray(n)){let e=n;for(let t=0;t<i;t++)e[t][0]=e[t][0]*a+o,e[t][1]=e[t][1]*a}else{let e=n;for(let t=0;t<i;t++){let n=t<<1;e[n]=e[n]*a+o,e[n+1]=e[n+1]*a}}return!0}function Il(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(e){this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0,this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees},equals(e){return mt(this.m_heightSign,e.m_heightSign)&&mt(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&mt(this.m_heightZ0,e.m_heightZ0)&&mt(this.m_XYToRadians,e.m_XYToRadians)&&mt(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=NaN,this.m_heightZ0=0,this.m_XYToRadians=NaN,this.m_PrimeMeridianDegrees=NaN,t&&l(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){let n=e?e.getPECoordSys():null,r=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(n,r)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Ll{m_inputUnitParams;m_outputUnitParams;m_constantsLoaded=-1;m_isUsable=-1;m_latestID;m_inputSR=null;m_outputSR=null;m_inputSRHorz=null;m_outputSRHorz=null;m_inputVCS=null;m_outputVCS=null;m_geogTran;m_vertTran;m_hashCode=0;m_areaOfUse=new Me;constructor(e){this.m_inputUnitParams=Il(),this.m_outputUnitParams=Il(),l(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=Q.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);let t=this.m_geogTran.getGeogcs1();Q.getCode(t);let n=this.m_geogTran.getGeogcs2();Q.getCode(n),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():(l(0),``)}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(t===-1){if(!e){this.m_geogTran||o(`vcs not impl`);let t=this.m_geogTran.getParameters();t[$.PE_PARM_ND]!==null&&(e=t[$.PE_PARM_ND].getValue()===0)}t=+!!this.m_geogTran.loadConstants(),this.m_constantsLoaded=t}return t!==0}isUsable(){let e=this.m_isUsable;return e===-1&&(this.m_isUsable=e=this.m_geogTran?+!!this.m_geogTran.usable():+!!this.m_vertTran),e===1}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return e===0&&(e=this.m_latestID>0?lt(this.m_latestID):Ot(this.getText()),e===0&&(e=345),this.m_hashCode=e),e}isGeogtran(){return this.m_geogTran!==null}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():(p(`vcs not impl`),``)}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,n,r,i,a;if(this.m_geogTran){let o=this.m_geogTran.getGeogcs1(),s=rf(o),c=this.m_geogTran.getGeogcs2(),l=rf(c),u=-1,d=-1;u=s.getVcsCode(),d=l.getVcsCode(),n=Uf(o,null,null,1),r=Uf(c,null,null,1),u>0&&d>0?(i=jl(u),a=jl(d),e=Kf(),t=Kf()):(e=n,t=r)}else l(0);!this.m_inputSR&&!this.m_inputVCS&&(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=n,this.m_outputSRHorz=r,this.m_inputVCS=i,this.m_outputVCS=a)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=NaN,this.m_outputUnitParams.m_XYToRadians=NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=NaN,this.m_vertTran)l(0);else if(this.m_geogTran){let e=this.m_geogTran,t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function Rl(e,t,n,r,i,a,o){let s=null;t&&(s=t.getPEVerticalCoordSys());let c=null;e&&(c=e.getPECoordSys());let l=null;r&&(l=r.getPEVerticalCoordSys());let u=null;if(n&&(u=n.getPECoordSys()),!c&&!s&&!u&&!l)return!1;let d=Il();d.initFromGcsAndVcsPe(c,s);let f=Il();return f.initFromGcsAndVcsPe(u,l),Fl(d,f,i,a,o)}function zl(e,t,n,r,i,a,o,s){let c=t,l=e,u=Il();u.initFromGcsAndVcsPe(l,c),s.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),s.processUnitParams(u),u.processUnitParams(s),o>0&&Fl(u,s,i,a,o)}function Bl(e,t,n,r,i,a,o,s){let c=Il();c.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),c.processUnitParams(e);let l=null;r&&(l=r.getPECoordSys());let u=Il();u.initFromGcsAndVcsPe(l,null),u.processUnitParams(c),c.processUnitParams(u),s>0&&Fl(c,u,a,o,s)}function Vl(e,t,n,r,i,a,o,s,c){let l=Il(),u=Il();l.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),u.assign(i?r.m_outputUnitParams:r.m_inputUnitParams),l.processUnitParams(e),u.processUnitParams(l),l.processUnitParams(u),s>0&&Fl(l,u,a,o,s),c.assign(u)}function Hl(e,t,n,r,i,a,o){let s=t.getVerttran(),c=t.getGeogtran();if(o.assign(n?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),a>0){t.prepareOrThrow();let e=n?$.PE_TRANSFORM_2_TO_1:$.PE_TRANSFORM_1_TO_2;s?md():hd(c,a,r,i,e)}}function Ul(e,t,n,r,i){let a=e.getVerttran(),o=e.getGeogtran();if(i>0){e.prepareOrThrow();let s=t?$.PE_TRANSFORM_2_TO_1:$.PE_TRANSFORM_1_TO_2;a?md():hd(o,i,n,r,s)}}class Wl{supportsCurves(){return!0}accelerateGeometry(e,t,n){return Gl(e,t,n)}canAccelerateGeometry(e){return Kl(e)}}function Gl(e,t,n){if(!Kl(e))return!1;ke(t,e,!1);let r=0,i=e.getGeometryType();return s(i)&&D(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeAccelerator(n)),s(i)&&O(e)&&n!==0&&(r|=+!!e.getImpl().buildQuadTreeForPathsAccelerator(n)),r>0}function Kl(e){return D(e)||O(e)}class ql extends Wl{getOperatorType(){return 8}execute(e,t,n,r){return Ri(e,t,n,1,r)}}function Jl(e,t,r,o){if(e.isEmpty()||t.isEmpty())return e;let s=e.getDimension(),c=t.getDimension();if(s>c)return e;let l=e.getGeometryType(),u=t.getGeometryType(),d=new T,f=new T,p=new T;e.queryEnvelope(d),t.queryEnvelope(f),p.setCoords({env2D:d}),p.mergeEnvelope2D(f);let m=je(r,p,!0),h=Pe(m),g=new T;if(g.setCoords({env2D:d}),g.inflateCoords(h,h),!g.isIntersecting(f))return e;if(s===1&&c===2){let n=au(e,t,u,r,o);if(n)return n}if(l===i.enumPoint){let r;switch(a(u)?(r=new E({vd:t.getDescription()}),r.addSegment(t,!0)):r=t,u){case i.enumPolygon:return Zl(e,r,m);case i.enumPolyline:return Ql(e,r,m);case i.enumMultiPoint:return $l(e,r,m);case i.enumEnvelope:return eu(e,r,m);case i.enumPoint:return tu(e,r,m);default:n(`invalid shape type`)}}else if(l===i.enumMultiPoint)switch(u){case i.enumPolygon:return nu(e,t,m);case i.enumEnvelope:return ru(e,t,m);case i.enumPoint:return iu(e,t,m)}let _=new T(d);return _.inflate(100*m.total()),Hs(e,q(t,_,0,0,o),r,o)}class Yl{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n,r){return new Xl(e,t,n,r)}execute(e,t,n,r){return this.executeMany(new sn([e]),new sn([t]),n,r).next()}}class Xl extends on{m_inputGeoms;m_progressTracker;m_spatialReference;m_geomSubtractor;m_index;constructor(e,t,n,r){super(),this.m_progressTracker=r,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=n;let i=t.next();this.m_geomSubtractor=i||new k}next(){let e=this.m_inputGeoms.next();return e?(r(e),c(e),this.m_index=this.m_inputGeoms.getGeometryID(),Jl(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Zl(e,t,n,r){return Ko(t,e,n.total())===0?e:e.createInstance()}function Ql(e,t,n,r){let i=e.getXY(),a=t.querySegmentIterator(),o=Pe(n),s=o*o;for(;a.nextPath();)for(;a.hasNextSegment();){let t=a.nextSegment(),r=new T;if(t.queryEnvelope(r),r.inflateCoords(o,o),!r.contains(i))continue;if(t.isIntersectingPoint(i,n.total()))return e.createInstance();let c=t.getStartXY();if(U.sqrDistance(i,c)<=s||(c=t.getEndXY(),U.sqrDistance(i,c)<=s))return e.createInstance()}return e}function $l(e,t,n,r){let i=t.getImpl().getAttributeStreamRef(0),a=t.getPointCount(),o=e.getXY(),s=Pe(n),c=s*s,l=new U;for(let t=0;t<a;t++)if(i.queryPoint2D(2*t,l),U.sqrDistance(l,o)<=c)return e.createInstance();return e}function eu(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getXY();return i.contains(a)?e.createInstance():e}function tu(e,t,n,r){let i=Pe(n),a=i*i,o=e.getXY(),s=t.getXY();return U.sqrDistance(o,s)<=a?e.createInstance():e}function nu(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getPointCount(),o=!1,s=H(a,!1),c=new U;for(let r=0;r<a;r++)e.queryXY(r,c),i.contains(c)&&qo(t,c,n.total())!==0&&(o=!0,s[r]=!0);if(!o)return e;let l=e.createInstance();for(let t=0;t<a;t++)s[t]||l.addPoints(e,t,t+1);return l}function ru(e,t,n,r){let i=new T;t.queryEnvelope(i),i.inflate(n.total());let a=e.getPointCount(),o=!1,s=H(a,!1),c=new U;for(let t=0;t<a;t++)e.queryXY(t,c),i.contains(c)&&(o=!0,s[t]=!0);if(!o)return e;let l=e.createInstance();for(let t=0;t<a;t++)s[t]||l.addPoints(e,t,t+1);return l}function iu(e,t,n,r){let i=e.getImpl().getAttributeStreamRef(0),a=e.getPointCount(),o=t.getXY(),s=!1,c=H(a,!1),l=Pe(n),u=l*l,d=new U;for(let e=0;e<a;e++)i.queryPoint2D(2*e,d),U.sqrDistance(d,o)<=u&&(s=!0,c[e]=!0);if(!s)return e;let f=e.createInstance();for(let t=0;t<a;t++)c[t]||f.addPoints(e,t,t+1);return f}function au(e,t,n,r,a){let o=new Me;e.queryEnvelope(o);let s=new T;t.queryEnvelope(s),o.merge(s);let c=.1*o.width(),l=.1*o.height();o.inflateCoords(c,l);let u=new k;u.addEnvelope(o,!1);let d=u.getImpl();if(n===i.enumPolygon){let e=t.getImpl();d.add(e,!0)}else d.addEnvelope(t,!0);return new wc(u,r,-1,a).tryFastImplementation(e)}class ou{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n,r=0){return new uu(e,t,n,r)}execute(e,t,n,r){let i=new sn([e,t]),a=new uu(i,n,r,0).next();return a||o(`null output`),a}}function su(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new U}}function cu(e,t){return U.compareZorder(e.location,t.location)?-1:+!e.location.equals(t.location)}class lu{binVertexCount;geometries;constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>cu(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class uu extends on{m_inputGeoms;m_progressTracker;m_spatialReference;m_bUnionAllDimensions;m_bPreserveAllPathEnds;m_index=-1;m_currentDim=-1;m_bDone=!1;m_unionBins=[];m_readyGeoms=ut(4);m_dimGeomCounts=H(4,0);m_addedGeoms=0;m_options;m_maxDimension=-1;m_bHadGeometry=H(4,!1);m_bIs3D;m_complexUnionGeoms=ut(4);m_totalNonEmptyGeomCounters=H(4,0);constructor(e,t,n,r,i=!1){super(),this.m_progressTracker=n,this.m_bUnionAllDimensions=!!(r&4),this.m_bPreserveAllPathEnds=!!(r&8),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=r,this.m_bIs3D=i}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(this.m_maxDimension===-1)return null;if(this.m_bUnionAllDimensions){if(this.m_currentDim===-1){for(let e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?l(0):this.m_complexUnionGeoms[e]=new Yl().execute(this.m_complexUnionGeoms[e],this.m_complexUnionGeoms[t],this.m_spatialReference,this.m_progressTracker))}}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&o(``),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,this.m_currentDim===0&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.enumPoint){let e=new A({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(e){return this.m_readyGeoms[e]}finishDim(e,t,n){let r=t;if(n){if(this.m_options&1)return r;if(e===1){if(!(this.m_options&8)&&(this.m_options&16||this.m_totalNonEmptyGeomCounters[e]>1)){r=Js([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options|16,this.m_bIs3D);let e=r.getImpl().getIsSimple(0,[0]);l(this.m_bIs3D||De(e))}else this.m_totalNonEmptyGeomCounters[e]===1&&(this.m_bIs3D?l(0):r=new xc().execute(r,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?l(0):r=new xc().execute(r,this.m_spatialReference,!1,this.m_progressTracker);if(e===0&&r.getGeometryType()===i.enumPoint){let e=new A({vd:r.getDescription()});r.isEmpty()||e.add(r),r=e}}else return this.m_options&16&&(r=Js([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D)),r;return r}static getLevel(e){let t=m(e),n=t>0?(Math.log(t)-Math.log(32))/Math.log(4):0;return n<0&&(n=0),Math.floor(n)}step_(){if(this.m_bDone)return!0;let e;if(this.m_inputGeoms?(e=this.m_inputGeoms.next(),e===null?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,e!==null){let t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let e=0;e<=this.m_maxDimension;e++){for(;this.m_dimGeomCounts[e]>1;){let t=this.collectGeometriesToUnion(e);if(t!==null){let n;n=this.m_options&1?Js(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Ys(t,t.length,this.m_spatialReference,this.m_progressTracker,this.m_options|8,this.m_bIs3D),this.addGeom(e,!0,n)}else break}if(this.m_bDone&&(l(this.m_dimGeomCounts[e]<=1),this.m_dimGeomCounts[e]!==0)){let t=this.m_unionBins[e].entries().next().value,n=t[1].geomPairs()[0].geom,r=t[1].geomPairs()[0].bUnioned;this.m_unionBins[e].clear(),this.m_readyGeoms[e]=this.finishDim(e,n,r)}}return this.m_bDone}addGeom(e,t,n){let r=su();r.geom=n;let i=m(n);r.vertexCount=i;let a=T.constructEmpty();n.queryEnvelope(a),r.location=i>0?a.getCenter():new U(0,0);let o=uu.getLevel(n);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let s=null,c=this.m_unionBins[e].get(o);c&&(s=c),s===null&&(s=new lu,this.m_unionBins[e].set(o,s)),r.bUnioned=t,s.addPair(r),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(this.m_options&1&&!this.m_bDone)return null;let t=null,n=[];for(let t of this.m_unionBins[e].keys())n.push(t);dt(n);for(let r=0;r<n.length;r++){if(n[r]===-1)continue;let i=this.m_unionBins[e].get(n[r]);{let a=i.getBinVertexCount()>5e3&&i.geomCount()>=4;if(this.m_bDone||a){for(let i=0;i<r;i++){if(n[i]===-1)continue;let r=this.m_unionBins[e].get(n[i]);r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(let e of r.geomPairs())t||=[],t.push(e.geom);r.clear(),this.m_unionBins[e].delete(n[i]),n[i]=-1}i.sort(),this.m_dimGeomCounts[e]-=i.geomCount(),this.m_addedGeoms-=i.geomCount();for(let e of i.geomPairs())t||=[],t.push(e.geom);if(i.clear(),this.m_unionBins[e].delete(n[r]),n[r]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&h(),e.hasAttribute(1)||n(`Geometry must have Zs`)),r(e)}}class du extends Wl{getOperatorType(){return 3}execute(e,t,n,r=null){return Ri(e,t,n,4,r)}}function fu(e,t,n){let r=t.getGCSSplitLines();if(r===null)return e;let i=t.getGCS(),a=i.getPannableExtent().width(),o=T.constructEmpty();e.queryLooseEnvelope(o);let s=W.constructEmpty();o.queryIntervalX(s);let c=r.querySegmentIterator(),l=null,u=new K;for(;c.nextPath();)for(;c.hasNextSegment();){let e=c.nextSegment(),t=e.queryInterval(0,0),n=W.constructEmpty();n.setCoordsFromEnvelope(t);let r=0;for(;n.vmax>s.vmin;)n.move(-a),r--;for(;n.vmin<=s.vmax;){if(n.isIntersecting(s)){l===null&&(l=new E);let t=new I({start:e.getStartXY(),end:e.getEndXY()});r!==0&&(u.setShiftCoords(r*a,0),t.applyTransformation(u)),l.addSegment(t,!0)}n.move(a),++r}}if(l!==null){let t=Te(i,l,!0),r=Pe(t);return Vr(e,l,r,n)}return e}function pu(e,t,n){let r=e.getName();return np(r)||(n||t>0?(r=e.toString($.PE_STR_NAME_CANON|$.PE_STR_AUTH_NONE),r=vu(r)):r=e.toString($.PE_STR_AUTH_TOP)),r}function mu(e,t,n,r){return l(0),``}function hu(e,t=-1){if((t>1||t<-1)&&n(`verbosity`),t===-1)return e.toString();{let n=t===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL;return e.toString(n)}}function gu(e,t){(t>1||t<-1)&&n(`verbosity`);let r=$.PE_STR_FMT_WKT2;return t!==-1&&(r|=t===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL),e.toString(r)}function _u(e){return l(0),``}function vu(e){return e.toLocaleUpperCase(`en-US`)}function yu(e,t,r){let a=e.getPCSHorizon();if(a.getGeometryType()===i.enumPolygon){let n=e.getDefaultPrecisionSR().getTolerance(0),i=a;for(let e=0;e<r;e++)qo(i,t[e],n)!==1&&t[e].setNAN();return}if(a.getGeometryType()===i.enumEnvelope){let e=a;for(let n=0;n<r;n++)e.contains(t[n])||t[n].setNAN();return}n(``)}function bu(e,t,n,r){for(let i=0;i<t;i++){if(e[i].y<n.ymin||e[i].y>n.ymax){e[i].setNAN();continue}let t=e[i].x;e[i].x=ku(t,n,r)}}function xu(e,t,n,r){if(e.isEmpty()||n===1)return e;let a=e.getGeometryType();if(a===i.enumPoint){let r=e,i=r.getXY();return Tu([i],1,t,n)===0||i.isNAN()?r.setEmpty():r.setXY(i),e}if(a===i.enumMultiPoint){let r=e,i=e.createInstance(),a=r.getPointCount();i.reserve(a);let o=r.getAttributeStreamRef(0),s=r.getDescription().getAttributeCount()>1,c=new B,l=Float64Array.from(o.getArray());if(Tu(l,a,t,n)>0)for(let e=0,t=a*2;e<t;e+=2)Number.isNaN(l[e])||(s?(r.getPointByVal(e>>1,c),c.setXYCoords(l[e],l[e+1]),i.add(c)):i.addXY(l[e],l[e+1]));return i}let c=e,l=t.getOneDegreeGCSUnit(),u=l*90,d=l*180,f=l*360,p=t.getCentralMeridian(),m=.5*l,h=T.constructEmpty();c.queryEnvelope(h);let g=t.getGCSHorizon(),_=t.getGCSHorisonIsInclusive(),v=g.getGeometryType()===i.enumEnvelope,y=T.constructEmpty();g.queryEnvelope(y);let b=t.getGCS();if((n===2||n===4)&&(y.xmin=p-d,y.xmax=y.xmin+f),n===4){if(h.width()>f-l)n=2;else{let e=T.constructEmpty();e.setCoords({xmin:h.xmin-l,ymin:y.ymin,xmax:h.xmax+l,ymax:y.ymax}),c=new nn().execute(c,e,b,r);let t=Math.floor((p-h.getCenterX())/f);for(h.move(t*f,0);h.xmin>y.xmax;)--t,h.move(-f,0);for(;h.xmin<y.xmin;)t+=1,h.move(f,0);if(t!==0){let e=new K;e.setShiftCoords(t*f,0),c.applyTransformation(e)}return c}}if(n===2&&(y.xmin=p-d,y.xmax=y.xmin+f),h.ymin<-u||h.ymax>u){let e=T.constructEmpty();if(e.setCoords({xmin:h.xmin-l,ymin:-u,xmax:h.xmax+l,ymax:u}),c=new nn().execute(c,e,b,r),c.isEmpty())return c;c.queryEnvelope(h)}if(_&&(y.ymax<h.ymin||y.ymin>h.ymax))return c.createInstance();h.width()>f&&(c=Ru(c,p-d,f,b,!0,0,!0,r),c.queryEnvelope(h));let x=Lu(h.xmin,h.xmax,y.xmin,y.xmax,f);if(x!==0&&h.move(x,0),h.xmax>y.xmax||h.xmin<y.xmin){if(h.xmax>y.xmax)for(;h.xmin>=y.xmax;)h.move(-f,0),x-=f;for(;h.xmin<y.xmax-f;)h.move(f,0),x+=f}let S=ke(b,g,!1);if(x!==0){let e=new K;e.setShiftCoords(x,0),c.applyTransformation(e),x=0}if(_){if(v&&y.containsEnvelope(h))return c;let e=[,,];for(let t=0;t<2;t++){let n;if(v?n=s(a)?q(c,y,S,m,r):q(c,y,S,0,r):(n=new Ec().execute(c,g,b,r),n===g&&(n=n.clone())),y.xmin<=h.xmin&&y.xmax>=h.xmax||y.xmin>=h.xmin&&y.xmax<=h.xmax)return n;if(e[t]=n,t===0){h.move(-f,0);let e=new K;e.setShiftCoords(-f,0),c.applyTransformation(e)}}return s(a)?e[0].add(e[1],!1):o(`intersect_with_GCS_horizon: unexpected geometry type`),e[0]}{if(y.ymax<h.ymin||y.ymin>h.ymax)return c;let e=0;for(;!c.isEmpty()&&h.xmax>y.xmin;){if(e!==0){let t=new K;t.setShiftCoords(e,0),c.applyTransformation(t)}if(new du().execute(c,g,b,r)||(c=new Yl().execute(c,g,b,r),g===c&&(c=c.clone())),e!==0){let t=new K;t.setShiftCoords(-e,0),c.applyTransformation(t)}e-=f,h.move(-f,0)}return c}}function Su(n,r,i,a,o,s){let c={stack:[],error:void 0,hasError:!1};try{if(s===2)return In(n,r,i,a,o);if(Math.abs(i.x-a.x)>=Math.PI||!Md(i.x,a.x,o))return NaN;i.x>a.x&&(a=gt(i,i=a));let t=e(c,new Sp,!1),l=e(c,new Sp,!1),u=e(c,new Sp,!1),d=i.clone();kp.geodeticDistance(n,r,i.x,i.y,a.x,a.y,l,t,null,s);let f=l.val,p=0,m=1;for(;f*(m-p)>n*1e-12;){let e=.5*(p+m);if(kp.geodeticCoordinate(n,r,i.x,i.y,f*e,t.val,l,u,s),d.x=l.val,d.y=u.val,d.x===o)return d.y;if(Md(i.x,d.x,o))m=e;else if(Md(a.x,d.x,o))p=e;else return NaN}return d.y}catch(e){c.error=e,c.hasError=!0}finally{t(c)}}function Cu(e,t){let n;if(Array.isArray(e)){let r=e;n=new Float64Array(t*2);for(let e=0,i=0;e<t;e++,i+=2)n[i]=r[e].x,n[i+1]=r[e].y}else n=e;return n}function wu(e,t,n,r){for(let i=0,a=0;i<r;i++,a+=2)t[n+i].x=e[a],t[n+i].y=e[a+1]}function Tu(e,t,n,r){if(t===0||r===1)return t;let a=Cu(e,t);if(r===2){let r=n.getPannableExtentInGCS(),i=t;for(let e=0,n=t*2;e<n;e+=2)(a[e+1]>r.ymax||a[e+1]<r.ymin)&&(a[e]=NaN,i--);return i?(zu(a,t,r.xmin,r.width(),!0),e!==a&&wu(a,e,0,t),i):(e!==a&&wu(a,e,0,t),0)}let o=n.getOneDegreeGCSUnit(),s=o*90,c=o*180,l=o*360,u=t;for(let e=0,n=t*2;e<n;e+=2)(a[e+1]>s||a[e+1]<-s)&&(a[e]=NaN,u--);if(!u)return e!==a&&wu(a,e,0,t),0;let d=T.constructEmpty();d.setFromPoints(a,t);let f=n.getGCSHorizon(),p=n.getGCSHorisonIsInclusive(),m=f.getGeometryType()===i.enumEnvelope,h=T.constructEmpty();if(f.queryEnvelope(h),p&&(h.ymax<d.ymin||h.ymin>d.ymax))return e!==a&&wu(a,e,0,t),0;if(p){if(zu(a,t,h.getCenterX()-c,l,!0),u=t,m)for(let e=0,n=t*2;e<n;e+=2)h.containsCoords(a[e],a[e+1])||(a[e]=NaN,u--);else{let e=ke(n.getGCS(),f,!1),r=new U;for(let n=0,i=t*2;n<i;n+=2)r.setCoords(a[n],a[n+1]),qo(f,r,e)!==0||(a[n]=NaN,u--)}}else{zu(a,t,-c,l,!0),u=t;let e=ke(n.getGCS(),f,!1),r=new U;for(let n=0,i=t*2;n<i;n+=2){r.setCoords(a[n],a[n+1]),r.isNAN()&&u--;let t=Iu(r.x,h.xmin,h.xmax,l);r.x+=t,qo(f,r,e)!==0&&(a[n]=NaN,u--)}}return e!==a&&wu(a,e,0,t),u}function Eu(e,t,r,i,a,o){if(t.isPannable()||n(`fold_into_360_degree_range`),e.isEmpty())return e;let s,c;if(t.getCoordinateSystemType()===2){let e=t.getPannableExtent();c=e.xmin,s=e.width()}else{let e=t.getOneDegreeGCSUnit(),n=e*180;s=e*360,c=r-n}return Ru(e,c,s,t,i,a,!0,o)}function Du(e,t,n,r){let i,a;if(n.getCoordinateSystemType()===2){let e=n.getPannableExtent();i=e.xmin,a=e.width()}else{let e=n.getOneDegreeGCSUnit(),t=e*180;a=e*360,i=r-t}zu(e,t,i,a)}function Ou(e,t){let n=t.width(),r=pt(e-t.vmin,n);return r<0&&(r+=n),t.snapClip(r+t.vmin)}function ku(e,t,n){return e>t.xmax&&e-t.xmax<n?t.xmax:e<t.xmin&&t.xmin-e<n?t.xmin:e}function Au(e,t,n){if(e[0]<t.vmin||e[0]>t.vmax||n&&e[0]===t.vmax){let n=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/n)*n,e[0]=t.snapClip(e[0]),!0}return!1}function ju(e,t,n,r,i,a,o,s,c){return new Al(e,null,n,t,r,i,o,s,a).geoNormalizePolygonGeometry(c)}function Mu(e,t,n,r,i,a,o,s,c){return new Al(e,null,n,t,r,i,o,s,a).geoNormalizePolylineGeometry(c)}function Nu(e,t,n,r,i){let a=new N,o=a.addGeometry(e);return Pu(a,o,t,ke(t,e,!1),n,r,i),a.getGeometry(o)}function Pu(n,r,i,a,o,s,c){let u={stack:[],error:void 0,hasError:!1};try{l(Rf()),i.isPannable()||y(`insert_geodetic_points`);let t=i.getPannableExtent(),d=i.getGCS(),f=Pf();d.querySpheroidData(f);let p=d.getUnit().getUnitToBaseFactor(),m=f.majorSemiAxis,h=f.e2,g=0,_=new W;t.queryIntervalX(_);let v=null,b=H(4,NaN);i.getCoordinateSystemType()===2?(v=i.getPECoordSys(),s?(b[0]=Ou(c,_),b[1]=t.getCenterY(),wp.projToGeog(v,1,b),g=b[0]*p):(b[0]=t.getCenterX(),b[1]=c,wp.projToGeog(v,1,b),g=b[1]*p)):g=c*p,!s&&g!==0&&o!==2&&y(`insert_geodetic_points: 1`);let x=e(u,new Sp,!1),S=new U,C=new U,w=new U,T=new U,E=new U,D=new U;for(let e=n.getFirstPath(r);e!==z;e=n.getNextPath(e)){let t=n.getFirstVertex(e);n.queryXY(t,w);let r=!1,l=n.getNextVertex(t);for(let e=l;e!==z;e=n.getNextVertex(e)){if(e===l){if(r)break;r=!0}if(n.queryXY(e,T),s&&(a<c-w.x&&T.x-c>a||a<c-T.x&&w.x-c>a)||!s&&(c!==0||a<-w.y&&T.y>a||a<-T.y&&w.y>a))do{if(Math.abs(w.x-T.x)>=_.width()*.5)break;i.getCoordinateSystemType()===2?(b[0]=Ou(w.x,_),b[1]=w.y,b[2]=Ou(T.x,_),b[3]=T.y,od(v,2,b,0),E.x=b[0]*p,E.y=b[1]*p,D.y=b[3]*p):(E.x=w.x*p,E.y=w.y*p,D.y=T.y*p),D.x=(T.x-w.x)*Math.PI*2/_.width()+E.x;let t=0,r=bt(U,2);if(s){if(C.x=g,C.y=Su(m,h,E,D,g,o),Number.isNaN(C.y))break;r[0]=C,t=1}else if(o===2){let e=[0,0];if(t=Ln(m,h,E,D,g,e),!t)break;r[0].x=e[0],r[0].y=g,t===2&&(r[1].x=e[1],r[1].y=g)}else{if(C.x=Nd(m,h,E,D,o),Number.isNaN(C.x))break;C.y=0,r[0]=C,t=1}let a=-1;for(let l=0;l<t;l++){kp.geodeticDistance(m,h,E.x,E.y,D.x,D.y,x,null,null,o);let t=x.val;kp.geodeticDistance(m,h,E.x,E.y,r[l].x,r[l].y,x,null,null,o);let u=x.val;i.getCoordinateSystemType()===2?(b[0]=r[l].x/p,b[1]=r[l].y/p,wp.geogToProj(v,1,b),s?(S.y=b[1],S.x=c):(S.x=Pd(b[0],w.x,T.x,_),S.y=c)):s?(S.x=c,S.y=r[l].y/p):(S.x=Pd(r[l].x/p,w.x,T.x,_),S.y=c);let d=t>0?At(u/t,0,1):.5;if(d===0||d===1||a>d)continue;let f=n.getPrevVertex(e);n.splitSegment(f,[d],1);let g=n.getNextVertex(f);n.setXYCoords(g,S.x,S.y),a=d}}while(0);w.setCoordsPoint2D(T)}}}catch(e){u.error=e,u.hasError=!0}finally{t(u)}}function Fu(e,t){l(t.isPannable());let n=t.getPannableExtent();if(e.getGeometryType()===i.enumPoint){let t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}let r=T.constructEmpty();e.queryEnvelope(r);let a=T.constructEmpty();a.setCoords({env2D:n}),a.xmin=r.xmin,a.xmax=r.xmax,a.inflateCoords(a.height()*.01,0);let o=Oe(t,r,!1),s;return s=a.containsEnvelope(r)?e:q(e,a,o,0,null),s}function Iu(e,t,n,r){let i=(n+t)*.5;return ht((i-e)/r)*r}function Lu(e,t,n,r,i){return e>=n&&t<=r?0:Iu((t+e)*.5,n,r,i)}function Ru(e,t,n,r,a,o,s,c){let l=e.getGeometryType(),u=W.constructEmpty();u.setCoords(t,t+n);let d=[0];if(l===i.enumPoint){if(d[0]=e.getX(),Au(d,u,s)){let t=a?e:e.clone();return t.setX(d[0]),t}return e}let f=T.constructEmpty();if(e.queryEnvelope(f),f.isEmpty())return e;if(l===i.enumMultiPoint){let t=a?e:e.clone(),n=t.getImpl(),r=n.getAttributeStreamRef(0),i=n.getPointCount()*2,o=!1;for(let e=0;e<i;e+=2)d[0]=r.read(e),Au(d,u,s)&&(r.write(e,d[0]),o=!0);return o&&n.notifyModifiedFlags(2001),t}let p=W.constructEmpty();if(f.queryIntervalX(p),u.contains(p))return u.vmax,p.vmax,e;let m=T.constructEmpty();if(m.setCoords({env2D:f}),p.width()===0){let t=p.vmin;t+=Math.ceil((u.vmin-t)/n)*n,t=u.snapClip(t);let r=a?e:e.clone();return r.setAttributeBasic(0,0,t),r}if(l===i.enumEnvelope){let t=a?e:e.clone();return f.intersect(m),t.setEnvelope(f),t}let h=Math.max(f.height(),f.width())*.1*1;m.inflateCoords(0,h);let g=e,_=r.getTolerance(0),v=new K;for(;;){let e=Math.floor((p.vmin-t)/n),a=Math.ceil((p.vmax-t)/n);if(a-e>3){let s=Math.floor((a+e)*.5);m.xmin=f.xmin-h,m.xmax=t+n*s;let u=q(g,m,_,o,c);m.xmin=m.xmax,m.xmax=f.xmax+h;let d=q(g,m,_,o,c);v.setShiftCoords((s-a)*n,0),d.applyTransformation(v),l===i.enumPolygon?g=new ou().execute(u,d,r,c):(g=u,g.add(d,!1)),g.queryEnvelope(f),f.queryIntervalX(p)}else break}m.xmin=t,m.xmax=t+n;let y=T.constructEmpty();y.setCoords({env2D:m}),y.inflateCoords(_,0);let b=Math.floor((f.xmin-m.xmin)/n)*n;b?(m.move(b,0),v.setShiftCoords(-b,0)):v.setIdentity();let x;x=l===i.enumPolyline?new E({vd:g.getDescription()}):new k({vd:g.getDescription()});let S=T.constructEmpty(),C=T.constructEmpty();for(;f.xmax>m.xmin;){let e=q(g,m,_,0,c);e.queryEnvelope(C);let t=!1;t=l===i.enumPolyline?!e.isEmpty()&&(C.width()>_||C.height()>_):!e.isEmpty()&&(l!==i.enumPolygon||C.width()>_),t&&(e.applyTransformation(v),e.queryEnvelope(C),x.queryEnvelope(S),S.inflateCoords(_,_),S.isIntersecting(C)&&l===i.enumPolygon?x=new ou().execute(x,e,r,c):x.add(e,!1)),m.move(n,0),v.shiftCoords(-n,0)}return x}function zu(e,t,n,r,i=!0){let a=new W;a.setCoords(n,n+r);let o=[0];if(Array.isArray(e)){let n=e;for(let e=0;e<t;e++)a.containsRightExclusive(n[e].x)||(o[0]=n[e].x,Au(o,a,i),n[e].x=o[0])}else{let n=e;for(let e=0;e<t;e++){let t=e<<1;a.containsRightExclusive(n[t])||(o[0]=n[t],Au(o,a,i),n[t]=o[0])}}}function Bu(e,t,n,r=!0){if(e.isEmpty())return;let a=e.getGeometryType();if(!(r&&a===i.enumPolygon)){if(f(a)){let r=s(a)&&e.hasNonLinearSegments(),i=!1;if(r){let r=e.getImpl(),a=r.getAttributeStreamRef(0),o=r.getSegmentFlagsStreamRef();l(o!==null);for(let e=0,s=r.getPathCount();e<s;e++){let s=!0,c=r.isClosedPath(e),l=r.getPathEnd(e);c&&r.getPathSize(e)>0&&(s=(o.read(l-1)&31)==1);for(let c=r.getPathStart(e);c<l;c++)if((o.read(c)&31)==1){if(s){let e=a.read(2*c),r=ku(e,t,n);r!==e&&(i=!0,a.write(2*c,r))}s=!0}else s=!1}}else{let r=e.getImpl(),a=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){let r=a.read(2*e),o=ku(r,t,n);o!==r&&(i=!0,a.write(2*e,o))}}i&&e.getImpl().notifyModifiedFlags(2001)}else if(a===i.enumEnvelope){let r=e,i=T.constructEmpty();r.queryEnvelope(i),i.xmin=ku(i.xmin,t,n),i.xmax=ku(i.xmax,t,n),r.setEnvelope(i)}else if(a===i.enumPoint){let r=e;r.setX(ku(r.getX(),t,n))}else o(``)}}function Vu(e,t,n){let r=new U;return r.x=ku(e.x,t,n),r.y=e.y,r}function Hu(e,t){if(t.isEmpty())return 0;let n=e.getPECoordSys();if(n.getProjection().getCode()===$.PE_PRJ_AZIMUTHAL_EQUIDISTANT){let r=Pf();e.querySpheroidData(r);let i=n.getParameters();if(i[$.PE_PARM_LAM0]===null||i[$.PE_PARM_PHI0]===null)return 0;let a=[i[$.PE_PARM_LAM0].getValue(),i[$.PE_PARM_PHI0].getValue()];wp.geogToProj(n,1,a);let o=new U(a[0],a[1]),s=T.constructEmpty();t.queryEnvelope(s);let c=bt(U,4);s.queryCorners(c);let l=0,u=e.getOneMeter(),d=Math.max(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,f=Math.min(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,p=d/180;f-=p,d*=u,f*=u;for(let e=0;e<4;e++){let t=U.distance(c[e],o);if(t>d)l++;else if(t>f)return-1}if(l===0)return 1;if(l===4){let e=T.constructEmpty();return e.setCoords({center:o,width:d,height:d}),s.isIntersectingNe(e)?-1:0}return-1}return-1}function Uu(e,t,n,r){let a=e.getGeometryType();l(a===i.enumPolygon||a===i.enumPolyline||a===i.enumMultiPoint);let o=t.getCoordinateSystemType();if(o===2){let o=e;if(n===0){let n=Hu(t,e);if(n===0)return e.createInstance();if(n===1)return e;let a=t.getPCSHorizon(),s=a.getGeometryType(),c=t.getDefaultPrecisionSR();if(s===i.enumEnvelope){let n=T.constructEmpty();a.queryEnvelope(n);let i=Oe(c,n,!1);o=q(e,n,i,t.getOneMeterPCSUnit()*5e4,r)}else new ql().execute(a,e,c,r)||(o=new Ec().execute(o,a,c,r),o===a&&(o=o.clone()))}else if(t.isPannable()){let e=T.constructEmpty();o.queryEnvelope(e);let s=t.getPannableExtent();s.containsEnvelope(e)||(Bu(o,s,t.getTolerance(0)),(n===2||n===4)&&(o=Fu(o,t)),n===4?a===i.enumPolygon&&e.width()>s.width()*2&&(o=Ru(o,-2*s.width(),2*s.width(),t,!0,0,!0,r)):o=Eu(o,t,0,!0,t.getOneMeterPCSUnit()*1e5,r))}return o}if(l(o===1),a===i.enumMultiPoint)return Bu(e,t.getPannableExtent(),t.getTolerance(0)),e;{let n=T.constructEmpty();e.queryEnvelope(n);let o=e,s=t.getPannableExtent();if(n.ymin<s.ymin||n.ymax>s.ymax){let e=Math.max(1,n.calculateToleranceFromEnvelope()),i=new T(n.xmin-e,s.ymin,n.xmax+e,s.ymax);if(o=new nn().execute(o,i,t,r),o.isEmpty())return o}return a===i.enumPolygon&&n.width()>s.width()*2&&(o=Ru(o,-2*s.width(),2*s.width(),t,!0,0,!0,r)),o}}function Wu(e,t,n,r,i,a){let o=r.getCoordinateSystemType();if(o===2){if(i===0)n!==e&&ft(n,e,t),yu(r,n,t);else if(n!==e&&ft(n,e,t),r.isPannable()){let e=r.getTolerance(0);bu(n,t,r.getPannableExtent(),e),Du(n,t,r,0)}}else{l(o===1);let i=r.getTolerance(0),a=r.getPannableExtent();for(let r=0;r<t;r++)n[r].assign(Vu(e[r],a,i))}}function Gu(e,t){let n=t.getPointCount();if(!n)return;let r=t.getImpl(),i=r.getAttributeStreamRef(0),a=e;wp.geogToProj(a,n,i.getArray()),r.notifyModifiedFlags(2001)}function Ku(e,t,n,r){if(!n)return;let i=e.getPECoordSys();if(n===1){if(t[0].isNAN())return;let n=[t[0].x,t[0].y];if(wp.geogToProj(i,1,n),r){let{first:r,second:i}=e.m_peCoordSysVal.getGeogToProjFactors();n[0]=r*(t[0].x-e.getCentralMeridian())+i}t[0].setCoords(n[0],n[1]);return}let a=e.isPannable(),o=a?e.getPannableExtent().width():0,s=o*179/360,c=0;a&&(c=e.getCentralMeridian());let l=new Float64Array(512);for(let u=0;u<n;){for(let e=u;e<n&&t[e].isNAN();++e)u++;let d=Math.min(256,n-u);if(d>0){for(let e=1,n=u+1;e<d;++e,++n)if(t[n].isNAN()){d=e;break}for(let e=0;e<d;++e){let n=e<<1;l[n]=t[u+e].x,l[n+1]=t[u+e].y}if(wp.geogToProj(i,d,l),r){let{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<d;++e){let i=e<<1;l[i]=n*(t[u+e].x-c)+r}}if(a)for(let e=0,n=u;e<d;e++,n++){let r=e<<1,i=l[r],a=_t(i),u=t[n].x-c;a*_t(u)<0&&Math.abs(i)>s&&(l[r]-=a*o)}wu(l,t,u,d),u+=d}}}function qu(e,t,n,r){let i=e.getSRToGCSTransform();return new Rc().transform(i,t,n,r,!1)}function Ju(e,t,n,r){let i=new A({vd:t.getDescription()});i.addPoints(t,0,-1);let a;a=new Rc().execute(i,e,r);let o=t.getPointCount();if(n.setEmpty(),e.getInputSR().isPannable()){if(o!==a.getPointCount())return!1;let r=new T;t.queryEnvelope(r);let i=new T;a.queryEnvelope(i);let s=r.width(),c=i.width();if(s!==0&&c!==0){let t=c/s,n=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/n-1)>1e-10)return!1}else if(s!==0||c!==0)return!1;n.add(t,!1);for(let e=0;e<o;e++){let t=a.getXY(e);n.setXY(e,t)}return!0}return!1}function Yu(e,t,n){l(!n||e.isPannable());let r=t.getPointCount();if(!r)return;let i=t.getImpl(),a=i.getAttributeStreamRef(0),o=e.getPECoordSys(),s=0,c=a.readRange(0,r*2),u=()=>{wp.geogToProj(o,r,c)},d=e.isPannable()&&!n,f=d?e.getPannableExtent().width():0,p=f*179/360;if(e.isPannable()&&(s=e.getCentralMeridian(),n)){let t=e.m_peCoordSysVal.getGeogToProjFactors(),n=t.first,i=t.second;u=()=>{wp.geogToProj(o,r,c);for(let e=0;e<r;e++){let t=e<<1,r=a.read(t),o=n*(r-s)+i;c[t]=o}}}if(u(),d)for(let e=0;e<r;e++){let t=e<<1,n=c[t],r=_t(n),i=a.read(t)-s;r*_t(i)<0&&Math.abs(n)>p&&(c[t]+=-r*f)}a.writeRangeFromArray(0,r*2,c,!0,1),i.notifyModifiedFlags(2001)}function Xu(e,t,n){switch(t.getGeometryType()){case i.enumLine:Cd(e,t,n);return;case i.enumBezier:kd(e,t,n);return;case i.enumEllipticArc:Td(e,t,n);return;case i.enumBezier2:Ad();return;case i.enumRationalBezier2:jd();return;default:o(``)}}function Zu(e,t,n){if(!t.hasNonLinearSegments()){Yu(e,t,n);return}if(l(!n||e.isPannable()),t.isEmpty())return;let r=e.getPECoordSys(),i=e.isPannable(),a=i?e.getPannableExtent().width():0,o=a*179/360,s=0;i&&(s=e.getCentralMeridian());let c=t.createInstance();c.reserveParts(t.getPointCount(),t.getPathCount());let u=t.getImpl(),d=new F;for(let l=0,f=t.getPathCount();l<f;++l)if(u.hasNonLinearSegmentsPath(l)){let t=!0,r=-1,i=u.getPathStart(l),a=i+u.getSegmentCountPath(l);u.isClosedPath(l)&&(r=a-1);let o=new U;for(let s=i;s<a;++s){if(u.getSegmentBuffer(s,d,!1),Xu(e,d.get(),n),t||d.get().getStartXY().equals(o)||d.get().moveTo(o),s!==r)c.addSegment(d.get(),t);else{if(t){let e=new B;d.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(d.get())}o.assign(d.get().getEndXY()),t=!1}}else{let e=1024,n=u.getPathSize(l),d=Math.min(n,e),f;c.insertPath(-1,t,l,!0);let p=u.getAttributeStreamRef(0),m=c.getAttributeStreamRef(0);for(let t=u.getPathStart(l),c=u.getPathEnd(l);t<c;){if(f=p.readRange(t,d),wp.geogToProj(r,d,f),i)for(let e=0;e<d;e++){let t=e<<1,n=f[t],r=_t(n),i=p.read(2*(0+e))-s;r*_t(i)<0&&Math.abs(n)>o&&(f[t]+=-r*a)}m.writeRangeFromArray(t,d,f,!0,1),t+=d,n-=d,d=Math.min(n,e)}}t.assignMove(c)}function Qu(e,t,n){let r=1e3,i=n.getPointCount();if(!i)return;let a=n.getImpl(),o=a.getAttributeStreamRef(0),s=Math.min(i,r),c=0,l=e.getPECoordSys();Number.isNaN(t)&&(t=0);let u=e.isPannable(),d=e.getOneDegreeGCSUnit(),f=d*360,p=d*179,m;for(;i;){if(m=o.readRange(c*2,s*2),od(l,s,m,t),u)for(let e=0;e<s;e++){let n=e<<1,r=m[n]-t,i=_t(r),a=o.read(2*(c+e));i*_t(a)<0&&Math.abs(r)>p&&(m[n]+=-i*f)}o.writeRangeFromArray(c*2,s*2,m,!0,1),c+=s,i-=s,s=Math.min(i,r)}a.notifyModifiedFlags(2001)}function $u(e,t,n){switch(n.getGeometryType()){case i.enumLine:ed(e,t,n);return;case i.enumBezier:rd(e,t,n);return;case i.enumEllipticArc:td(e,t,n);return;case i.enumBezier2:id();return;case i.enumRationalBezier2:ad();return;default:o(``)}}function ed(e,t,n){let r=[n.getStartXY(),n.getEndXY()];cd(e,t,r,2),n.setStartXY(r[0]),n.setEndXY(r[1]),n.normalizeAfterEndpointChange()}function td(e,t,n){if(n.projectionBehavior()===0)nd(e,t,n);else{let r=n.isClosed()&&n.isMajor(),i=[n.getStartXY(),r?n.getCenter():n.getEndXY()],a=[i[0].clone(),i[1].clone()];Ed(e,t,a,2);let o=new K;o.initializeFromTwoPointsArray(i,a),n.applyTransformation(o);let s=+!r;n.setCoordsForIntersector(a[0],a[s],!1)}}function nd(e,t,n){Dd(!1,e,t,n,!1)}function rd(e,t,n){let r=bt(U,4);n.queryControlPoints(r),Ed(e,t,r,4),n.setControlPoints(r)}function id(e,t,n){l(0)}function ad(e,t,n){l(0)}function od(e,t,n,r){let i=wp.projToGeogCenter(e,t,n,r);for(let e=0;e<t;++e){let t=e<<1;l(Number.isFinite(n[t]+n[t+1]))}return i}function sd(e,t,n){if(!n.hasNonLinearSegments()){Qu(e,t,n);return}if(n.isEmpty())return;let r=e.getPECoordSys();Number.isNaN(t)&&(t=0);let i=e.isPannable(),a=e.getOneDegreeGCSUnit(),o=a*360,s=a*179,c=n.createInstance();c.reserveParts(n.getPointCount(),n.getPathCount());let l=n.getImpl(),u=new F;for(let a=0,d=n.getPathCount();a<d;++a)if(l.hasNonLinearSegmentsPath(a)){let n=!0,r=-1,i=l.getPathStart(a),o=i+l.getSegmentCountPath(a);l.isClosedPath(a)&&(r=o-1);let s=new U;for(let a=i;a<o;++a){if(l.getSegmentBuffer(a,u,!1),$u(e,t,u.get()),n||u.get().getStartXY().equals(s)||u.get().moveTo(s),a!==r)c.addSegment(u.get(),n);else{if(n){let e=new B;u.get().queryStart(e),c.startPathPoint(e)}c.closeLastPathWithSegment(u.get())}s.assign(u.get().getEndXY()),n=!1}}else{let e=1e3,u=l.getPathSize(a),d=Math.min(u,e),f;c.insertPath(-1,n,a,!0);let p=l.getAttributeStreamRef(0),m=c.getAttributeStreamRef(0);for(let n=l.getPathStart(a),c=l.getPathEnd(a);n<c;){if(f=p.readRange(2*n,2*d),od(r,d,f,t),i)for(let e=0;e<d;e++){let r=e<<1,i=f[r]-t,a=_t(i),c=p.read(2*n);a*_t(c)<0&&Math.abs(i)>s&&(f[r]+=-a*o)}m.writeRangeFromArray(2*n,2*d,f,!0,1),n+=d,u-=d,d=Math.min(u,e)}}n.assignMove(c)}function cd(e,t,n,r){let i=e.getPECoordSys();Number.isNaN(t)&&(t=0);let a=e.isPannable(),o=e.getOneDegreeGCSUnit(),s=o*360,c=o*179,l=new Float64Array(512);for(let e=0;e<r;){for(let t=e;t<r&&n[t].isNAN();++t)e++;let o=Math.min(256,r-e);if(o>0){for(let t=1,r=e+1;t<o;++t,++r)if(n[r].isNAN()){o=t;break}for(let t=0;t<o;t++){let r=t<<1;l[r]=n[e+t].x,l[r+1]=n[e+t].y}if(od(i,o,l,t),a)for(let r=0,i=e;r<o;++r,++i){let e=r<<1,a=n[i].x,o=l[e]-t,u=_t(o);u*_t(a)<0&&Math.abs(o)>c&&(l[e]-=u*s)}for(let t=0;t<o;t++){let r=t<<1;n[e+t].x=l[r],n[e+t].y=l[r+1]}e+=o}}}function ld(e,t,n,r){l(0)}function ud(e,t,n){let r=t.getPointCount();if(!r)return!1;let i=t.getImpl(),a=i.getAttributeStreamRef(0),o=null,s=e.getInputSR(),c=e.getOutputSR();s.getVCS(),c.getVCS();let l=s.getOneDegreeGCSUnit(),u=c.getOneDegreeGCSUnit(),d=e.isVertical();d&&t.hasAttribute(1)&&(o=i.getAttributeStreamRef(1));let f=e.getDatumTransformation(),p=f?f.getType()===1:!1;if(!p&&o!==null&&(ld(o.getArray()),o=null),!f||f.count()===0){let e=s.getGcsUnitFactor()/c.getGcsUnitFactor(),t=(s.getPrimeMeridian()-c.getPrimeMeridian())*u,n=l*-90,o=l*90,d=0,f=a.getArray(),p=[0];for(let e=1,t=r*2;e<t;)p[0]=f[e],d|=+!!Jt(p,n,o),f[e]=p[0],e+=2;if(t!==0||e!==1){d=1;let n=a.getArray();for(let i=0,a=r*2;i<a;){let r=n[i];r*=e,r+=t,n[i]=r,n[i+1]*=e,i+=2}}return d!==0&&i.notifyModifiedFlags(2001),!!d}let m=1e3,h=Math.min(r,m),g=H(h,NaN),_=H(h,NaN),v=null;o!==null&&(v=new Float64Array(h));let y=0,b=NaN,x=NaN,S=u*360,C=u/l;n&&(x=u*90,b=l*89.9,_.fill(0));let w=!0,T=0;for(;r;){let e=!1,t=a.readRange(y*2,h*2);for(let e=0;e<h;e++)g[e]=t[e<<1];if(n)for(let n=0;n<h;n++){let r=(n<<1)+1,i=Math.abs(t[r])-b;if(i>0){let a=t[r];t[r]=Mt(b,a),_[n]=Mt(i,a),e=!0}}let i=t[0];if(p){let e=f;v&&o.queryRange(y,h,v,!0,1),e.transform(!1,t,v,h),v&&o.writeRangeFromArray(y,h,v,!0,1)}else f.transform(!1,t,h);w&&=(T=t[0]-C*i,!1);for(let e=0;e<h;e++){let n=e<<1,r=t[n]-g[e]*C-T;Math.abs(r)>200&&(r>0?t[n]+=-S:t[n]+=S)}if(e){for(let e=0;e<h;e++)if(_[e]){let n=(e<<1)+1;t[n]+=C*_[e],t[n]>x?t[n]=x:t[n]<-x&&(t[n]=-x)}_.fill(0)}a.writeRangeFromArray(y*2,h*2,t,!0,1),d&&o&&o.writeRangeFromArray(y,h,v,!0,1),y+=h,r-=h,h=Math.min(r,m)}return i.notifyModifiedFlags(2001),!0}function dd(e,t,n){switch(t.getGeometryType()){case i.enumLine:return _d(e,t,n);case i.enumBezier:return bd(e,t,n);case i.enumEllipticArc:return vd(e,t,n);case i.enumBezier2:return xd();case i.enumRationalBezier2:return Sd();default:o(``)}}function fd(e,t,n){if(!t.hasNonLinearSegments())return ud(e,t,n);if(t.isEmpty())return!1;let r=t.createInstance();r.reserveParts(t.getPointCount(),t.getPathCount());let i=t.getImpl(),a=new F;for(let o=0,s=t.getPathCount();o<s;++o){let t=!0,s=-1,c=i.getPathStart(o),l=c+i.getSegmentCountPath(o);i.isClosedPath(o)&&(s=l-1);let u=new U;for(let o=c;o<l;++o){if(i.getSegmentBuffer(o,a,!1),dd(e,a.get(),n),t||a.get().getStartXY().equals(u)||a.get().moveTo(u),o!==s)r.addSegment(a.get(),t);else{if(t){let e=new B;a.get().queryStart(e),r.startPathPoint(e)}r.closeLastPathWithSegment(a.get())}u.assign(a.get().getEndXY()),t=!1}}return t.assignMove(r),!0}function pd(e,t,n,r,i,a){if(e.isIdentityGeogToGeog()){let n=e.getInputSR().getOneDegreeGCSUnit()*90,i=0,a=[0];for(let e=0;e<r;e++)a[0]=t[e].y,i|=+!!Jt(a,-n,n),t[e].y=a[0];return i}let o=e.getInputSR(),s=e.getOutputSR(),c=o.getVCS(),l=s.getVCS(),u=o.getOneDegreeGCSUnit(),d=u*90,f=s.getOneDegreeGCSUnit(),p=e.isVertical(),m=e.getDatumTransformation(),h=m?m.getType()===1:!1;if(p||(n=null),!m||m.count()===0){let e=0,i=[0];for(let n=0;n<r;n++)i[0]=t[n].y,e|=+!!Jt(i,-d,d),t[n].y=i[0];return e|=+!!Rl(o.getGCS(),c,s.getGCS(),l,t,n,r),e}!h&&n!==null&&ld();let g=1024,_=Math.min(r,g),v=H(_,NaN),y=H(_,NaN),b=0,x=NaN,S=NaN,C=f*360,w=f/u;i&&(S=f*90,x=u*89.9);let T=!0,E=0,D=r;for(;D;){let e=!1;for(let e=0;e<_;e++)v[e]=t[e+b].x;if(i)for(let n=0;n<_;n++){let r=Math.abs(t[n+b].y)-x;if(r>0){let i=t[n+b].y;t[n+b].y=Mt(x,i),y[n]=Mt(r,i),e=!0}}let r=t[0].x;h?m.transform(!1,t,n,_):m.transform(!1,t,_),T&&=(E=t[0].x-w*r,!1);for(let e=0;e<_;e++){let n=t[b+e].x-v[e]*w-E;Math.abs(n)>200&&(n>0?t[b+e].x-=C:t[b+e].x+=C)}if(e){for(let e=0;e<_;e++)y[e]&&(t[b+e].y+=w*y[e],t[b+e].y>S?t[b+e].y=S:t[b+e].y<-S&&(t[b+e].y=-S));y.fill(0,0,_)}b+=_,D-=_,_=Math.min(D,g)}return 1}function md(e,t,n,r,i){return l(0),0}function hd(e,t,n,r,i){l(r===null),l(t<2147483647);let a=Array.isArray(n),o;o=a?Bt(n):n;let s=Tp.geogToGeog(e,t,o,null,i);return a&&Vt(o,n),s}function gd(e,t,n,r,i,a){let o=0,s=!0,c=0;for(let a=0;a<r;++a)t[a].isNAN()?s||=(o|=pd(e,t.slice(c,a-c),n?n.slice(c,a-c):null,a-c,i),c=a,!0):s&&=(c=a,!1);return s||(o|=pd(e,c===0?t:t.slice(c),n?c===0?n:n.slice(c):null,r-c,i)),o!==0}function _d(e,t,n){let r=[t.getStartXY(),t.getEndXY()],i=[0,0],a=null;t.hasAttribute(1)&&(a=i,a[0]=t.getAttributeAsDbl(0,1,0),a[1]=t.getAttributeAsDbl(1,1,0));let o=gd(e,r,a,2,n);return t.setStartXY(r[0]),t.setEndXY(r[1]),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,a[1])),t.normalizeAfterEndpointChange(),o}function vd(e,t,n){if(t.projectionBehavior()===0)return yd(e,t,n);let r=t.getStartXY().equals(t.getEndXY()),i=bt(U,3),a=bt(U,3),o=[0,0,0],s=null;i[0].assign(t.getStartXY()),i[1].assign(r?t.getCenter():t.getEndXY());let c=!1;t.hasAttribute(1)&&(s=o,s[0]=t.getAttributeAsDbl(0,1,0),s[1]=t.getAttributeAsDbl(1,1,0),s[2]=Ct(s[0],s[1],.5),r&&(s[1]=s[2])),a[0].setCoordsPoint2D(i[0]),a[1].setCoordsPoint2D(i[1]);let l=new K;if(r||t.isDegenerateToLine())c=gd(e,a,s,2,n),l.initializeFromTwoPoints(i[0],i[1],a[0],a[1]);else{let r=new U;t.queryCoord2D(.5,r),i[2].setCoordsPoint2D(r),a[2].setCoordsPoint2D(r),c=gd(e,a,s,3,n),l.setFromTwoTriangles(i,a)}return l.isIdentity()||(t.applyTransformation(l),t.setStartXY(a[0]),t.setEndXY(r?a[0]:a[1]),t.normalizeAfterEndpointChange()),s&&(t.setStartAttribute(1,0,s[0]),t.setEndAttribute(1,0,r?s[0]:s[1])),c}function yd(e,t,n){let r=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()],i=4;t.isDegenerateToLine()&&(i=2);let a=[0,0,0,0],o=null;if(t.hasAttribute(1)){o=a,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);let e=Ct(o[0],o[1],.5);o[2]=e,o[3]=e}let s=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),c=gd(e,r,o,i,n);return s?t.constructCircleCenterAndPoint(r[3],r[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(r[0],r[1]):t.constructCircularArcThreePoint(r[0],r[1],r[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),c}function bd(e,t,n){let r=bt(U,4);t.queryControlPoints(r);let i=[0,0,0,0],a=null;t.hasAttribute(1)&&(a=i,a[0]=t.getAttributeAsDbl(0,1,0),a[3]=t.getAttributeAsDbl(1,1,0),a[1]=Ct(a[0],a[3],.5),a[2]=a[1]);let o=gd(e,r,a||null,r.length,n);return t.setControlPoints(r),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,a[3])),t.normalizeAfterEndpointChange(),o}function xd(e,t,n){return l(0),!1}function Sd(e,t,n){return l(0),!1}function Cd(e,t,n){let r=[t.getStartXY(),t.getEndXY()];Ku(e,r,2,n),t.setStartXY(r[0]),t.setEndXY(r[1]),t.normalizeAfterEndpointChange()}function wd(e,t,n,r){Ku(e,t,n,r)}function Td(e,t,n){if(t.projectionBehavior()===0)Od(e,t,n);else{let r=t.isClosed()&&t.isMajor(),i=[t.getStartXY(),r?t.getCenter():t.getEndXY()],a=[i[0].clone(),i[1].clone()];wd(e,a,2,n);let o=new K;o.initializeFromTwoPointsArray(i,a),t.applyTransformation(o);let s=+!r;t.setCoordsForIntersector(a[0],a[s],!1)}}function Ed(e,t,n,r){cd(e,t,n,r);let i=new T;i.setFromPoints(n,r);let a=e.getOneDegreeGCSUnit(),o=a*360,s=a*180;if(i.width()>s){for(let e=0;e<r;e++)for(;n[e].x<t;)n[e].x+=o;if(i.setFromPoints(n,r),i.xmax>s+t)for(let e=0;e<r;e++)n[e].x-=o}}function Dd(e,t,n,r,i){let a=bt(U,3),o=0,s=!1,c=!1,l=r.isDegenerateToLine();if(l?(a[0].assign(r.getStartXY()),a[1].assign(r.getEndXY()),a[2].setCoords(0,0),o=2):r.isClosed()&&r.isMajor()?(s=!0,c=!r.isClockwise(),a[0].assign(r.getStartXY()),a[1].assign(r.getCenter()),a[2].setCoords(0,0),o=2):(a[0].assign(r.getStartXY()),a[1].assign(r.getEndXY()),a[2].assign(r.getInteriorPoint()),o=3),e?wd(t,a,o,i):Ed(t,n,a,o),l){r.constructLineCircularArc(a[0],a[1]);return}if(s){r.constructCircleCenterAndPoint(a[1],a[0],c);return}r.constructCircularArcThreePoint(a[0],a[1],a[2])}function Od(e,t,n){Dd(!0,e,0,t,n)}function kd(e,t,n){let r=bt(U,4);t.queryControlPoints(r),wd(e,r,4,n),t.setControlPoints(r)}function Ad(e,t,n){l(0)}function jd(e,t,n){l(0)}function Md(e,t,n){let r=we(e),i=we(t),a=Ce(r,i),o=Ce(r,we(n));return o===0||a>0&&o>0&&o<=a||a<0&&o<0&&o>=a}function Nd(n,r,i,a,o){let s={stack:[],error:void 0,hasError:!1};try{let t=i.clone(),c=a.clone();if(o===2){let e=[0,0];return Ln(n,r,t,c,0,e),e[0]}if(t.y>c.y){let e=new U;e.assign(t),t.assign(c),c.assign(e)}let u=e(s,new Sp,!1),d=e(s,new Sp,!1),f=e(s,new Sp,!1),p=new W;if(p.setCoords(t.y,c.y),!p.containsCoordinate(0)||Math.abs(t.x-c.x)>=Math.PI)return NaN;if(t.x===c.x)return t.x;kp.geodeticDistance(n,r,t.x,t.y,c.x,c.y,d,u,null,o);let m=d.val,h=0,g=1,_=t.clone();for(;m*(g-h)>n*1e-12;){let e=.5*(h+g);if(kp.geodeticCoordinate(n,r,t.x,t.y,m*e,u.val,d,f,o),_.x=d.val,_.y=f.val,p.setCoords(t.y,_.y),_.y===0)return _.x;if(p.containsCoordinate(0))g=e;else if(p.setCoords(c.y,_.y),p.containsCoordinate(0))h=e;else return l(!1),NaN}return _.x}catch(e){s.error=e,s.hasError=!0}finally{t(s)}}function Pd(e,t,n,r){let i=new W;i.setCoords(t,n);let a=r.width(),o=Math.floor((e-t)/a)*a+e,s=i.getCenter();for(;Math.abs(o-s)>Math.abs(o+a-s);)o+=a;return o}class Fd extends on{m_geometryDeque=[];m_index=-1;constructor(){super()}next(){if(this.m_geometryDeque.length>0){this.m_index++;let e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}function Id(e,t){return e===t?!0:e===null||t===null||e.m_csType!==t.m_csType?!1:e.m_WKID===0&&t.m_WKID===0?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID}function Ld(e,t){return e===t?!0:e===null||t===null||e.m_csType!==t.m_csType?!1:e.m_WKID===0&&t.m_WKID===0?e.m_csType===1?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID}class Rd{m_csType;m_PCSHorizon=null;m_GCSHorizon=null;m_GCSSplitLines=null;m_bGCSHorisonIsInclusive=!1;m_oneMeterPCS=0;m_oneDegreeGCS=0;m_gcsUnitFactor=0;m_northPole=U.getNAN();m_southPole=U.getNAN();m_polesUpdated=0;m_domain=T.constructEmpty();m_primeMeridian=NaN;m_geogToProjFactor=1;m_geogToProjOffset=0;m_geogToProjFactorsUpdated=0;m_oneMillimeter=0;m_centralMeridian=0;m_pPCSInfoNoDomain=null;m_WKID;m_oldWKID=-1973;m_vcsWKID=-1;m_bIsPannable=!1;m_bCached=!1;m_pannableExtent=T.constructEmpty();m_pannableExtentGCS=T.constructEmpty();m_unit;m_areaOfUse=null;m_canonicalWkt=``;m_hashCode;m_peCoordSys;constructor(e,t=!0){this.m_peCoordSys=e,this.m_WKID=Q.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=pu(e,0,!0),this.m_hashCode=Ot(this.m_canonicalWkt)):this.m_hashCode=Pt(this.m_WKID);let r=this.m_peCoordSys.getType();this.m_csType=r===$.PE_TYPE_PROJCS?2:1,l(r===$.PE_TYPE_PROJCS||r===$.PE_TYPE_GEOGCS),r===$.PE_TYPE_PROJCS&&(e.loadConstants()||n(`PeProjcs.loadConstants failed`));let i=r===$.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();r!==$.PE_TYPE_GEOGCS&&Q.getCode(i),this.m_unit=hn(e),this.m_primeMeridian=i.getPrimem().getLongitude();{let e=i.getUnit().getUnitFactor();this.m_gcsUnitFactor=e;let t=Math.PI/(180*e);Math.abs(t-1)<1e-10&&(t=1),this.m_oneDegreeGCS=t}if(r===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=Ep.generate(e,Ep.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||o(`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;let e=1/i.getUnit().getUnitFactor(),t=i.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/t*e,this.m_centralMeridian=0}this.m_bIsPannable&&(this.updateGCSHorizon(),this.updatePCSHorizon(),this.updatePoles(),this.updateDomain(),this.updatePannableExtent(),this.updatePannableExtentGCS())}[Symbol.dispose](){}getHashCode(){return this.m_hashCode}getPCSHorizonPannable(){return this.m_PCSHorizon}getGCSHorizonPannable(){return this.m_GCSHorizon}getPCSInfo(){return l(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==$.PE_TYPE_PROJCS)return;let e=!0,t=this.m_peCoordSys,n=t.getGeogcs(),r=t.horizonGcsGenerate();if(!r)return;l(r.length>0);let i=r[0].getNump(),a=r[0].getKind(),o;e=r[0].getInclusive()>0;let s,c=this.getOneDegreeGCSUnit(),u=c*90,d=c*180,f=c*360,p=c*370,m=d*$.PE_HORIZON_DELTA/Math.PI,h=T.constructEmpty(),g=null;if(i>1){for(let e=1;e<i;e++)if(r[e].getKind()===$.PE_HORIZON_LINE){g||=new E;let t=r[e].getCoord();g.startPathCoords(t[0][0],t[0][1]),g.lineToCoords(t[1][0],t[1][1])}}if(a===$.PE_HORIZON_RECT){let t=r[0].getCoord();if(h.setFromPoints([new U(t[0][0],t[0][1]),new U(t[1][0],t[1][1])],2),Math.abs(h.ymax-u)<m*1e-7&&(h.ymax=u),Math.abs(h.ymin+u)<m*1e-7&&(h.ymin=-u),h.width()>p){let e=-400*c,t=e+5*f;h.setCoords({xmin:e,ymin:h.ymin,xmax:t,ymax:h.ymax})}let n=new Me({env2D:h});this.m_GCSHorizon||(this.m_GCSHorizon=n,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap(),a=Uf(n,null,null,1),d=[],p=new W;for(let e=0;e<i;e++){if(r[e].getKind()!==$.PE_HORIZON_POLY)continue;o=r[e].getSize();let t=r[e].getCoord(),n=T.constructEmpty();n.setFromPoints(Ft(t),o),d.push(new W(n.xmin,n.xmax)),n.width(),p.merge(d.at(-1))}let m=!1,h=new W;p.width()>f&&d.length>1?(h.vmin=this.getCentralMeridian()-f,h.vmax=h.vmin+f*2,m=!0,t=!0):(h.vmin=p.vmin,h.vmax=h.vmin+f);let _=e=>{let t=0;for(;d[e].vmin+t<h.vmin;)t+=f;for(;d[e].vmax+t-f>h.vmin;)t-=f;return t},v=new k;if(t){let e=new Fd,t=new ou().executeMany(e,a,null);for(let n=0;n<i;n++){if(r[n].getKind()!==$.PE_HORIZON_POLY)continue;o=r[n].getSize();let i=r[n].getCoord();s=r[n].getInclusive()>0;let a=new k;if(a.addPathPoint2D(Ft(i),o-1,!0),!m)e.tick(a),t.tock();else{let t=_(n),r=d[n].clone();r.move(t);let i=t,o=new K;do{o.setShiftCoords(i,0);let t=a.clone();t.applyTransformation(o),e.tick(t),e.tock(),i+=f,r.move(f)}while(r.vmin<h.vmax)}}v=t.next()}else{v=new k;for(let t=0;t<i;t++){if(r[t].getKind()!==$.PE_HORIZON_POLY)continue;o=r[t].getSize();let n=r[t].getCoord();if(s=r[t].getInclusive()>0,l(s===e),!m)v.addPathPoint2D(Ft(n),o-1,!0);else{let e=new k;e.addPathPoint2D(Ft(n),o-1,!0);let r=_(t),i=d[t].clone();i.move(r);let a=r,s=new K;do{if(a!==0){s.setShiftCoords(a,0);let t=new k({copy:e});t.applyTransformation(s),v.addPath(t,0,!0)}else v.addPath(e,0,!0);a+=f,i.move(f)}while(i.vmin<h.vmax)}}}m&&(v=new nn().execute(v,new T(h.vmin,-u-c,h.vmax,u+c),a,null)),e?new Ec().accelerateGeometry(v,a,1):new Yl().accelerateGeometry(v,a,1),new du().accelerateGeometry(v,a,1),this.m_GCSHorizon===null&&(this.m_GCSHorizon=v,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=g)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==$.PE_TYPE_PROJCS)return;let e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();let n=e[0].getKind();e[0].getInclusive();let r=T.constructEmpty(),i=e[0].getNump(),a=!1;if(n===$.PE_HORIZON_RECT){let n=e[0].getCoord();r.setFromPoints(Ft(n),2),t=new Me({env2D:r})}else{let n=-1;for(let t=0;t<i;t++)e[t].getKind()===$.PE_HORIZON_POLY&&(n=t);l(n>=0);let r=e[n].getSize()-1,o=e[n].getCoord(),s=new k;t=s,s.addPathPoint2D(Ft(o),r,!0),a=!0}if(this.getPCSInfo().isDensificationNeeded()){l(n!==$.PE_HORIZON_RECT);let e=1e5*this.getOneMeterPCSUnit();t=new an().execute(t,e,0,0,null)}if(a){{let e=new Me;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}new Ec().accelerateGeometry(t,null,1)}this.m_PCSHorizon===null&&(this.m_PCSHorizon=t)}updatePannableExtent(){let e=this.m_peCoordSys.getType();if(e===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),n=e.getGeogcs();n||o(``);let r=[t+1/n.getUnit().getUnitFactor()*Math.PI,0];wp.geogToProj(e,1,r);let i=r[0],a=e.getParameters()[$.PE_PARM_X0].getValue(),s=this.getPCSHorizon(),c=T.constructEmpty();s.queryEnvelope(c);let l=Math.abs(i-a),u=-1*l,d=l+a,f=u+a,p=c.ymax,m=c.ymin;this.m_pannableExtent.setCoords({xmin:f,ymin:m,xmax:d,ymax:p})}else if(e===$.PE_TYPE_GEOGCS){let e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o(``)}updatePannableExtentGCS(){let e=this.m_peCoordSys.getType();if(e===$.PE_TYPE_PROJCS){let e=this.m_peCoordSys,t=this.m_centralMeridian,n=e.getGeogcs();n||o(``);let r=1/n.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),a=T.constructEmpty();i.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:t-r,ymin:a.ymin,xmax:t+r,ymax:a.ymax})}else if(e===$.PE_TYPE_GEOGCS){let e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o(``)}updateDomain(){if(this.m_csType===1){let e=400*this.getOneDegreeGCSUnit();this.m_domain=T.construct(-e,-e,e,e)}else{l(this.m_csType===2);let e=Ep.generate(this.m_peCoordSys,Ep.PE_PCSINFO_OPTION_DOMAIN);e||o(`generate pcs info failed`);let t=new T(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===$.PE_TYPE_PROJCS){let e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];wp.geogToProj(this.m_peCoordSys,2,t);let n=this.getPCSInfo().getNorthPoleLocation()!==Ep.PE_POLE_OUTSIDE_BOUNDARY,r=this.getPCSInfo().getSouthPoleLocation()!==Ep.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||=(n&&this.m_northPole.setCoords(t[0][0],t[0][1]),r&&this.m_southPole.setCoords(t[1][0],t[1][1]),1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===$.PE_TYPE_PROJCS){let e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),n=[0,0,0,0];n[0]=t,n[1]=0,n[2]=t+e,n[3]=0;let r=wp.geogToProj(this.m_peCoordSys,2,n);l(r===2);let i=(n[2]-n[0])/e,a=n[0];this.m_geogToProjFactorsUpdated===0&&(this.m_geogToProjFactor=i,this.m_geogToProjOffset=a,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():(this.m_GCSHorizon===null&&this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(this.m_PCSHorizon===null&&this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(e){return this.m_bIsPannable||this.m_polesUpdated!==0||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return this.m_geogToProjFactorsUpdated===0&&this.updateGeogToProjFactors(),yt(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){let t=[0];Ip(this.m_peCoordSys.getType(),this.m_WKID,t,[0])||o(`query_code_change`),e=t[0]}this.m_oldWKID=e}return e}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return this.m_areaOfUse===null?this.updateAreaOfUse():this.m_areaOfUse}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}class zd{m_oneMeter=0;m_WKID=-1;m_oldWKID=-1;m_canonicalWkt=`not yet implemented`;m_model=0;m_unit=new Tf;m_cached=!1;m_peVertcs;static st_DeadWeedCount;constructor(e,t=!0){}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function Bd(e,t,n){return Vd(e,t,T.constructEmpty())}function Vd(e,t,n,r){return Ud(!0,e,t,n)}function Hd(e,t,n,r){return Wd(!0,e,t,n,r)}function Ud(e,t,n,r,i){return Rf()||v(`cannot create projection transformation`),t.hasVCS()&&n.hasVCS()?qd():Jd(t,n,r)}function Wd(e,t,n,r,i,a){return Rf()||v(`cannot create projection transformation`),new $d(e?2:1,t,n,r,i,a)}function Gd(e,t,r,i,a,o=!1){if((!t||!r)&&n(``),Rf()||v(`cannot obtain geotransformation list`),e===1&&t.hasVCS()&&r.hasVCS())return p(`hv xform not impl`),[];{let e=Jp(t,r,i,a,o),n=[];for(let t of e)n.push(t);return n}}function Kd(){return{centralMeridianOfOutputGCS:NaN,densificationStep:NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return mt(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&mt(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function qd(e,t,n,r){return l(0),{}}function Jd(e,t,r,i){(!e||!t)&&n(`!inputSR || !outputSR`);let a=e.getLatestID(),o=t.getLatestID();if(a===3857&&o===4326){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return mf()}else if(a===4326&&o===3857&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return gf();let s=T.constructEmpty();s.setCoords({env2D:r});let c=e.getCoordinateSystemType(),l=t.getCoordinateSystemType();if(c===0||l===0)return Yd(e,t);let u=e.getGCS().getLatestID(),d=t.getGCS().getLatestID();if(u>0&&u===d)return Yd(e,t);let f=new lf(e,t,r);{let e=df(f);if(e)return e}let p=Gd(0,e,t,s,1,!0);return ff(f,Yd(e,t,p.length?p[0]:void 0))}function Yd(e,t,n,r,i){return new $d(1,e,t,n,r,i)}function Xd(){return{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return(this.flagsMask&e)!==0}}}function Zd(){return{m_extendedParams:Kd(),m_extendedParamsInternal:Xd()}}function Qd(){return Zd()}class $d{m_inputSR;m_outputSR;m_datumTran=null;m_params;m_bIdentity=!0;m_bIdentityGeogToGeog=!0;m_bVertical=!1;m_bNormalize=!1;m_projector;constructor(e,t,r,i,a,o){(!t||!r)&&n(`!inputSR || !outputSR`),i&&i.getType()===0&&(i.m_bReadOnly=!0),this.m_bNormalize=!1;let s,c;e!==1&&(s=t.getVCS(),c=r.getVCS(),this.m_bVertical=s!=null&&c!=null),this.m_inputSR=t,this.m_outputSR=r,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,l(!this.m_params),a&&(this.m_params=Zd(),this.m_params.m_extendedParams=a),o&&(this.m_params||=Zd(),this.m_params.m_extendedParamsInternal=o);let u=!1,d=i!=null,f=t.getCoordinateSystemType(),p=r.getCoordinateSystemType();if(r.isPannable()&&f!==0&&a){let e=a.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&r.isPannable()){let t=r.getPannableExtent(),n=t.getCenterX();if(n!==e){let r=Math.ceil(t.width());e+r!==n+r&&(u=!0)}}}let m=a&&a.normalizeResultGeometry;if(t.equals(r)){this.m_bIdentity=!u,this.m_bIdentityGeogToGeog=!0,this.updateProjector();return}let h=!d&&t.equalForProjection(r,this.m_bVertical);this.m_bIdentity=h&&!u,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:f!==0&&p!==0&&(m&&this.m_outputSR.isPannable()&&(this.m_bNormalize=m),this.m_datumTran=i||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||this.m_datumTran.count()===0)&&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(){let e=new $d(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:Qd().m_extendedParams}equals(e){return l(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return l(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:Qd().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:Qd().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new Fc(this)}}const ef=new Map,tf=new Map,nf=new Map;function rf(e){let t=e.getCode();if(t>0)return wf(t)||Cf(Q.coordsys(t));let n=e.getName();if(tf.has(n)){let t=tf.get(n);if(t&&t.deref()){let n=t.deref();if(n.m_peCoordSys.isEqual(e))return n}}return t=Q.getCode(e),Cf(t>0?Q.coordsys(t):e)}function af(e){e<=0&&g(e);{let t=wf(e);if(t)return t}let t=Cp(Q.coordsys(e));t.get()||g(e);let n=Cf(t.release());return n.getLatestID()!==e&&ef.set(e,new WeakRef(n)),n}function of(e){let t=new zd({},!0);return t.m_WKID=e,t}function sf(e){let t=Cp(Q.fromString($.PE_TYPE_COORDSYS,e));return t.get()||_(e),rf(t.release())}function cf(e){tf.delete(e.m_peCoordSys.getName()),nf.delete(pu(e.m_peCoordSys,0,!1))}class lf{m_inputSR;m_outputSR;m_env;m_hashCode=-1;constructor(e,t,n){e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=n.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=ct(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.xmin)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.xmax)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.ymin)),this.m_hashCode=ct(this.m_hashCode,Ht(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR?!1:this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR)}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const uf=new Map;function df(e){if(uf.has(e.getHashCode()))return uf.get(e.getHashCode())}function ff(e,t){return uf.set(e.getHashCode(),t),t}let pf;function mf(){return pf||=Hd(op(),up()),pf}let hf;function gf(){return hf||=mf().getInverse(),hf}let _f;function vf(){return _f||=Q.unit(9001),_f}function yf(e){return Cp(Q.coordsys(e)).get()!==null}const bf=new Map;function xf(e){if(bf.has(e))return bf.get(e);{let t=yf(e);return bf.set(e,t),t}}function Sf(e){return!1}function Cf(e){let t=Cp(e),n=e.getCode();if(n>0){let e=wf(n);if(e)return e}let r=e.getName(),i=tf.get(r);if(i){let t=i.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}let a=new Rd(t.release());if(n>0)return a.setCached(),ef.set(n,new WeakRef(a)),tf.set(r,new WeakRef(a)),a;let o=pu(e,0,!1);if(i=nf.get(o),i){let e=i.deref();if(e)return e}return a.setCached(),nf.set(o,new WeakRef(a)),a}function wf(e){let t=ef.get(e);if(t)return t.deref()}class Tf extends ln{constructor(e){if(e===void 0){super(),this.m_wkid=9001,this.m_peUnit=null;return}if(typeof e==`number`){super(),this.m_factor=e,this.m_wkid=0;return}super(e),e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=vf())}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const Ef=`0123456789bcdefghjkmnpqrstuvwxyz`.split(``);function Df(e,t,n){let r=H(t,`R`),i=0,a=0;for(let n=0;n<t;n++){let o=e[i]>>a&31;if(a+=5,a>31){let t=37-a;o&=(1<<t)-1,a-=32,i++,o|=(e[i]&(1<<a)-1)<<t}let s=Ef[o];r[t-1-n]=s}return n>t?r.push(...`0`.repeat(n-t)):n<t&&(r.length=n),r.join(``)}function Of(e,t,n,r,i){l(r>>5<i.length);let a=t,o=n;for(let t=r;t>=0;t-=2){let n=t&31,r=t>>5,s=(o+a)*.5;e>=s?(i[r]|=1<<n,a=s):o=s}}let kf=new Set;const Af=2147483645n,jf=9007199254740990n,Mf=`operation is not supported for unknown coordinate systems`;var Nf;(function(e){e[e.utmDefault=0]=`utmDefault`,e[e.utmNorthSouth=1]=`utmNorthSouth`})(Nf||={});function Pf(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return this.e2===0}}}function Ff(e,t,n){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-n),e.e2=n*(2-n),e.flattening=n}function If(e){if(Q)return;Fp(e);let t=kf;kf=null,t.forEach(e=>{let t=e.deref();t&&t.attachToPe()})}function Lf(e){Pp(e)}function Rf(){return!!Q}function zf(){return!!Mp}function Bf(){return!!Q||!!Mp}function Vf(e,t,n){return l(Bf()),hp(e,t===void 0?0:t,null,!1)}function Hf(e,t){l(Bf());let n=new rp,r;return Rf()?(r=sf(e),n.setHorzProj_(r),n.m_vertcs=null,n.m_userWKID=r.getLatestID()):(r=Np(e),n.m_unit=r.isPCS?new Tf(r.metersOrRadiansPerUnit):new fn(r.metersOrRadiansPerUnit)),fp(n.m_precisionDescriptor,r,null,1),n.m_bDefaultDescriptor=!0,n.m_userWKT=e,n.calculateHashCode(),n.initDbgName(),n}function Uf(e,t,n,r,i=!0){let a=null;return t&&(a=Ml(t,i)),Wf(e,a,n,r,i)}function Wf(e,t,r,i,a){e||n(`!PE_coord_sys`);let o=new rp,s;return s=a?rf(e):new Rd(e,!1),fp(o.m_precisionDescriptor,s,t,i),o.m_bDefaultDescriptor=!0,o.setHorzProj_(s),o.m_vertcs=t,o.m_userWKID=s.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Gf(e,t,r=!1){e.getCoordinateSystemType()===3&&n(`image spatial reference cannot be altered`);let i=new rp,a=e;return i.m_peCoordSysVal=a.m_peCoordSysVal,i.m_vertcs=a.m_vertcs,i.m_unit=a.m_unit,i.m_precisionDescriptor.assign(t),i.m_localZToXYFactor=a.m_localZToXYFactor,(Number.isNaN(i.m_precisionDescriptor.m_falseX)||Number.isNaN(i.m_precisionDescriptor.m_falseY))&&(i.m_precisionDescriptor.m_falseX=a.m_precisionDescriptor.m_falseX,i.m_precisionDescriptor.m_falseY=a.m_precisionDescriptor.m_falseY),i.m_precisionDescriptor.snapPrecision(),i.m_precisionDescriptor.fixTolerance(),i.m_userWKID=a.m_userWKID,i.m_bDefaultDescriptor=i.m_precisionDescriptor.equals(a.m_precisionDescriptor)?a.m_bDefaultDescriptor:!1,r&&(i.m_bDefaultDescriptor=!0),i.calculateHashCode(),i.initDbgName(),i}function Kf(e,t,n){return{}}function qf(e,t,r){t===void 0&&(t=1),(t<=0||!Number.isFinite(t))&&n(``),!e&&t!==1&&n(`null Unit has to have z_to_xy_factor equal to 1`);let i=new rp;i.m_unit=e;let a=e||new Tf(9001);return mp(i.m_precisionDescriptor,a,null,1),i.m_bDefaultDescriptor=!0,Number.isNaN(i.m_precisionDescriptor.m_falseX)&&n(`NAN false X/Y are not allowed here`),i.m_localZToXYFactor=t,i.calculateHashCode(),i.initDbgName(),i}function Jf(e,t){return e.snapGeometry(t)}function Yf(e){let t=e.getCoordinateSystemType();return t===1?e:(t===3&&l(0),e.getGCS())}function Xf(e){return l(Bf()),zf()?Lp(e):xf(e)}function Zf(n){if(Rf()){let r={stack:[],error:void 0,hasError:!1};try{return e(r,Q.fromString($.PE_TYPE_COORDSYS,n,!0),!1)!==null}catch(e){r.error=e,r.hasError=!0}finally{t(r)}}try{return Np(n),!0}catch{}return!1}let Qf;function $f(){return Qf||=(()=>{let e=Math.trunc(Math.random()*Ut()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})(),Qf}let ep=0;function tp(e=``){let t=`${$f()}${ep++}`;return e!==``&&(t+=`|${e}`),t}function np(e){return e.startsWith($f())}class rp{m_vertcs=null;m_peCoordSysVal=null;m_unit;m_userWKID=0;m_userWKT=null;m_geogSpatialReference=null;m_srToGcs=null;m_gcsToSr=null;m_defaultPrecisionSR=null;m_localZToXYFactor=-1;m_precisionDescriptor=new ip;m_hashCode=0;m_bDefaultDescriptor=!1;destroy(){cf(this.m_peCoordSysVal),this.getCoordinateSystemType()===1||this.getCoordinateSystemType()===2?this.getPECoordSys().destroy():o(`SpatialReference.destroy`)}constructor(){dp(this.m_precisionDescriptor),kf&&kf.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Vf(this.m_userWKID):Hf(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(this.getCoordinateSystemType()===1)return Hd(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;let n=this.getGCS(),r=this;t=e?Hd(r,n,null):Hd(n,r,null);let i=t;return(e?this.m_srToGcs:this.m_gcsToSr)||(e?this.m_srToGcs=i:this.m_gcsToSr=i,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal(),t=this.getHashCodeVertical(),n=this.m_precisionDescriptor.getHashCode();e=ct(e,t),this.m_hashCode=ct(e,n)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),this.getCoordinateSystemType()===1?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){let e=this.getPECoordSys();if(e)switch(e.getType()){case $.PE_TYPE_GEOGCS:return 1;case $.PE_TYPE_PROJCS:return 2;default:return 0}else if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof Tf)return 2;else if(this.m_unit instanceof fn)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 p(`vcs not implemented`),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return p(`vcs not implemented`),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){let e=this.getPECoordSys();return e?hu(e):this.m_userWKT??``}getTextExtended(e){let t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?mu(null,t,this.getPEVerticalCoordSys()):hu(t,e):this.m_userWKT??``}getText2(e=-1){let t=this.getPECoordSys();return t?gu(t,e):this.m_userWKT??``}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof Tf?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof fn?.001/(Np(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):(y(`sr object not in valid state`),0)}getAuthorityName(){return this.getPECoordSys()?_u():``}getVerticalUnit(){return p(`vcs not implemented`),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){let e=this.getCoordinateSystemType();if(e===0)y(Mf);else if(e===1)return this;else e===3&&y(`image cs not supported`);if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===op()||this===cp())t=up();else{l(this.m_peCoordSysVal);let e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||o(``),t=Uf(e,this.m_vertcs,null,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?t=this.m_geogSpatialReference:this.m_geogSpatialReference=t,t}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(e.length===0)return 0;e.length>t.length&&n(`coordsSrc.size() > coordsDst.size()`);let r=this.getCoordinateSystemType();if(r===0&&y(Mf),r===1)return ft(t,e,e.length),e.length;l(this.m_peCoordSysVal);let i=this.getSRToGCSTransform();return new Rc().transform(i,e,e.length,t)}toGeohash(e,t=8){let n=e.clone();n.scale(this.getGCS().getUnit().getID()===9102?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),n.x<-180?(n.x=pt(n.x,360),n.x<-180&&(n.x+=360)):n.x>180&&(n.x=pt(n.x,360),n.x>180&&(n.x-=360)),n.y>90&&(n.y=90),n.y<-90&&(n.y=-90);let r=t*5,i=new Uint32Array(4);return Of(n.x,-180,180,r-1,i),Of(n.y,-90,90,r-2,i),Df(i,t,t)}isPannable(){let e=this.getCoordinateSystemType();return e===0||e===3?!1:(l(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||n(`!is_pannable`),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||n(`!is_pannable`),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){let e=this.getCoordinateSystemType();e!==1&&e!==2&&n(`Not a GCS or PCS`)}getDomainXY(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX)){if(Rf()||v(`cannot query precision descriptor`),l(this.m_peCoordSysVal!==null),this.m_precisionDescriptor.m_precision!==2){let t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=NaN,e.m_falseY=NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{let t=this.getCoordinateSystemType();t===0?mp(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):t===3?p(`image cs`):fp(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=NaN,e.m_falseY=NaN}horizontalEqual(e){return Id(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return this.m_vertcs!==null==(e.m_vertcs!==null)?!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs):!1}equals(e){let t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t)||!t.m_peCoordSysVal&&(l(!this.m_peCoordSysVal),this.m_unit!==null!=(t.m_unit!==null)||this.m_unit&&!this.m_unit.equals(t.m_unit)||this.m_localZToXYFactor!==t.m_localZToXYFactor))return!1;if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;l(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,n=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){let t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,n=t.ymin}let r=t.m_precisionDescriptor.m_falseX,i=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(r)){let e=t.m_peCoordSysVal.getDomainXY();r=e.xmin,i=e.ymin}return e===r&&n===i}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;let n=this.getCoordinateSystemType(),r=e.getCoordinateSystemType();if(n===0||r===0)return n===0&&r===0?t&&this.getZToXYFactor()!==e.getZToXYFactor()?!1:this.getUnit()&&e.getUnit()?this.getUnit().equals(e.getUnit()):!0:n===3||r===3?!1:this.getUnit()===null||e.getUnit()===null?!0:t&&this.getZToXYFactor()!==e.getZToXYFactor()?!1:this.getUnit().equals(e.getUnit());if(n!==r)return!1;if(n===3)return this.equals(e);if(Ld(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(this.m_vertcs!==null==(e.m_vertcs!==null))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return l(0),!1}equalVerticalVCS(e){return l(0),!1}convergenceAngle(e){return l(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){let e=this.m_peCoordSysVal.m_peCoordSys;return e||o(`cannot clone coord sys`),e}return null}getPeVertcsCopy(){return l(0),0}throwIfLocal(){this.getCoordinateSystemType()===0&&n(Mf)}getPrimeMeridian(){return this.throwIfLocal(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return this.getUnitsPerMillimeter()*1e3}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(this.m_defaultPrecisionSR===null){let e=new ip;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=Gf(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal);let t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),n=t.getFlattening();Ff(e,t.getAxis(),n)}getAreaOfUse(){this.getCoordinateSystemType()===0&&y(``),l(this.m_peCoordSysVal);let e=this.m_peCoordSysVal.getAreaOfUse();return e===null?new cn:new cn({geom:e.clone(),sr:Vf(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty()||this.m_precisionDescriptor.getPrecision()===2)return!1;let t=e.getGeometryType();if(f(t))return this.snapMultiVertex_(e);if(t===i.enumPoint)return this.snapPoint_(e);if(t===i.enumEnvelope)return this.snapEnvelope_(e);if(a(t))return this.snapSegment_(e);if(t===i.enumGeometryCollection){let t=e,n=!1;for(let e=0,r=t.getGeometryCount();e<r;++e)n=this.snapGeometry(t.getGeometry(e))||n;return n}o(`what else?`)}snapMultiVertex_(e){if(l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2),s(e.getGeometryType())){let t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}let t=e.getImpl(),n=t.getDescription(),r=!1;for(let e=0,i=n.getAttributeCount();e<i;e++){let i=n.getSemantics(e),a=t.getAttributeStreamRef(i);r=this.snapAttributes(i,a,0,t.getPointCount())||r}return r&&t.notifyModifiedFlags(2001),r}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2);let t=new ip;this.queryPrecisionDescriptor(t);let n=e.getStartXY(),r=new U;r.x=gp(n.x,t.getFalseX(),t.getGridUnitsXY()),r.y=gp(n.y,t.getFalseY(),t.getGridUnitsXY());let i=!r.equals(n),a=e.getEndXY(),o=new U;o.x=gp(a.x,t.getFalseX(),t.getGridUnitsXY()),o.y=gp(a.y,t.getFalseY(),t.getGridUnitsXY()),i||=!o.equals(a),i&&e.changeEndPoints2D(r,o);let s=(t,n,r)=>{let i=!1;{let a=e.getStartAttributeAsDbl(t,0),o=gp(a,n,r),s=!mt(o,a);i||=s,s&&e.setStartAttribute(t,0,o)}{let a=e.getEndAttributeAsDbl(t,0),o=gp(a,n,r),s=!mt(o,a);i||=s,s&&e.setEndAttribute(t,0,o)}return i},c=+!!i;return e.hasAttribute(1)&&(c|=+!!s(1,t.getFalseZ(),t.getGridUnitsZ())),e.hasAttribute(2)&&(c|=+!!s(2,t.getFalseM(),t.getGridUnitsM())),!!c}snapGeometryWithCurves_(e){l(!e.isEmpty()),l(this.m_precisionDescriptor.getPrecision()!==2);let t=e.createInstance(),n=new F,r=0;for(let i=0,a=e.getPathCount();i<a;++i){let a=e.getSegmentCountPath(i);if(a===0){if(t.addPath(e,i,!0),t.getPathSize(i)===1){let e=new B;t.getPointByVal(t.getPointCount()-1,e),r|=+!!this.snapGeometry(e),t.setPointByVal(t.getPointCount()-1,e)}continue}let o=e.isClosedPath(i);for(let s=0,c=o?a-1:a;s<c;++s)e.getSegmentFromPath(i,s,n,!1),r|=+!!this.snapGeometry(n.get()),t.addSegment(n.get(),s===0);o&&(e.getSegmentFromPath(i,a-1,n,!1),r|=+!!this.snapGeometry(n.get()),a===1?t.addPathFromClosedSegment(n.get(),!1):t.closeLastPathWithSegment(n.get()))}return r&&t.copyTo(e),!!r}snapAttributes(e,t,n,r){let i=!1,a=new ip;if(this.queryPrecisionDescriptor(a),e===0){let e=t;for(let t=n;t<r;t++){let n=e.read(2*t),r=rp.s_SnapValue(n,a.getFalseX(),a.getGridUnitsXY()),o=e.read(2*t+1),s=rp.s_SnapValue(o,a.getFalseY(),a.getGridUnitsXY());i=i||r!==n||s!==o,i&&(e.write(2*t,r),e.write(2*t+1,s))}}else if(e===1){let e=t;for(let t=n;t<r;t++){let n=e.read(t),r=rp.s_SnapValue(n,a.getFalseZ(),a.getGridUnitsZ());i||=!mt(r,n),i&&e.write(t,r)}}else if(e===2){let e=t;for(let t=n;t<r;t++){let n=e.read(t),r=rp.s_SnapValue(n,a.getFalseM(),a.getGridUnitsM());i||=!mt(r,n),i&&e.write(t,r)}}return i}static s_SnapValue(e,t,n){return ht((e-t)*n)/n+t}}class ip{m_falseX;m_falseY;m_unitsXY;m_falseZ;m_unitsZ;m_falseM;m_unitsM;m_toleranceXY;m_toleranceZ;m_toleranceM;m_precision;constructor(){let e=jf,t=1e-4,n=.001,r=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-r,this.m_falseY=-r,this.m_unitsXY=Number(e)/(2*r),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=n,this.m_toleranceM=n,this.m_toleranceZ=n}getHashCode(){let e=7777,t=7777;return t=ct(t,this.m_falseM),t=ct(t,this.m_unitsM),e=ct(e,this.m_unitsXY),t=ct(t,this.m_toleranceXY),e=ct(e,this.m_falseZ),t=ct(t,this.m_toleranceZ),e=ct(e,this.m_unitsZ),t=ct(t,this.m_toleranceM),e=ct(e,this.m_precision),ct(e,t)}clone(){let e=new ip;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(this.m_precision===2)return 0;switch(e){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){let e=new T;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 2:e.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:e.setEmpty(),o(``)}return e}getZGridRange(){let e=new W;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),o(``)}return e}getMGridRange(){let e=new W;switch(this.m_precision){case 0:{let t=ip.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{let t=Number(ip.getLimit64())/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),o(``)}return e}setTolerance(e,t){switch(t<0&&n(`tol < 0`),Number.isFinite(t)||n(`tol is not finite`),e){case 0:this.m_toleranceXY=t;break;case 1:this.m_toleranceZ=t;break;case 2:this.m_toleranceM=t;break;default:n(`cannot set tolerance for this attribute`)}}setGridParams(e,t,r){(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&n(`grid params are not finite`),r<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=r}setZParams(e,t){(!Number.isFinite(e)||!Number.isFinite(t))&&n(`grid params are not finite`),t<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseZ=e,this.m_unitsZ=t}setMParams(e,t){(!Number.isFinite(e)||!Number.isFinite(t))&&n(`grid params are not finite`),t<1&&n(`grid units cannot be smaller than 1.0`),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||mt(this.m_falseX,e.m_falseX)&&mt(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(this.m_precision===2)return;let e=(e,t,n,r)=>{if(!Number.isFinite(t)||!Number.isFinite(n))return n;if(n<1)return 1;if(!r)return n;let i=Number(e)/n;return Math.trunc((t+i-t)*n)>e&&(n=e/(t+i-t)),Math.max(1,n)},t=Number(this.m_precision===0?Af:jf);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(this.m_precision===2)return!0;let e=(e,t,n,r)=>{if(n<1||!Number.isFinite(t)||!Number.isFinite(n))return!1;if(!r)return!0;let i=Number(e)/n;return!(BigInt((t+i-t)*n)>e)},t=this.m_precision===0?Af:jf;return!(!e(t,this.m_falseX,this.m_unitsXY,!0)||!e(t,this.m_falseY,this.m_unitsXY,!0)||!e(t,this.m_falseZ,this.m_unitsZ,!1)||!e(t,this.m_falseM,this.m_unitsM,!1))}fixTolerance(){this.m_precision!==2&&(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=NaN))}equalsWithoutFalseXY(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,n){}setBestMDomainFromMRange(e,t,n){}}let ap;function op(){return(!ap||Rf()&&ap.getPECoordSys()===null)&&(ap=hp(3857,0,null,!0)),ap}let sp;function cp(){return(!sp||Rf()&&sp.getPECoordSys()===null)&&(sp=hp(102100,0,null,!0)),sp}let lp;function up(){return(!lp||Rf()&&lp.getPECoordSys()===null)&&(lp=hp(4326,0,null,!0)),lp}function dp(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=vt()*100,e.m_toleranceZ=vt()*100,e.m_toleranceM=vt()*100,e.m_precision=2}function fp(e,t,r,i){let a=t instanceof Rd;dp(e),e.m_precision=i,e.m_falseX=NaN,e.m_falseY=NaN;let o=1e-4,s=.001,c=a?t.m_csType:t.isPCS?2:1;c===1?e.m_unitsXY=1/((i===0?5.555555555555555e-7:1e-9)*(a?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180)):c===2?e.m_unitsXY=1/((i===0?s:o)*(a?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit)):n(`unrecognized cs type`),e.m_falseM=-1e5,e.m_unitsM=1/(i===0?s:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let l=0,u=0;(i===0||i===1)&&(l=2/e.m_unitsXY,u=2/e.m_unitsM),e.m_toleranceXY=Math.max(l,a?t.getUnitsPerMillimeter():c===2?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(s,u),pp(e,r)}function pp(e,t){let n=1e-4,r=.001;e.m_falseZ=-1e5,e.m_unitsZ=t?1/((e.m_precision===0?r:n)*t.getOneMeter()):1/(e.m_precision===0?r:n),e.m_unitsZ=Math.max(1,e.m_unitsZ);let i=0;(e.m_precision===0||e.m_precision===1)&&(i=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*r:r,i)}function mp(e,t,n,r){dp(e),e.m_precision=r;let i=r===0?Af:jf,a=1e-4,o=.001,s=1,c=1,l=.001;t&&(c=t.getUnitToBaseFactor()),t&&t.getUnitType()===1?(s=400*Math.PI/180,l=8.983152841195215e-9*Math.PI/180/c):(s=(r===0?o:a)*Number(i)*.5,l=o/c),s/=c,e.m_falseX=-s,e.m_falseY=-s,e.m_unitsXY=Number(i)/(2*s),e.m_falseM=-1e5,e.m_unitsM=1/(r===0?o:a),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let u=0,d=0;(e.m_precision===0||e.m_precision===1)&&(d=2/e.m_unitsM,u=2/e.m_unitsXY),e.m_toleranceXY=Math.max(u,l),e.m_toleranceM=Math.max(o,d),pp(e,n)}function hp(e,t,n,r){if(!r&&t<=0){if(e===3857)return op();if(e===102100)return cp();if(e===4326)return up()}let i=new rp,a,o=null;return Rf()?(a=af(e),t>0?o=null:t=0,i.setHorzProj_(a),i.m_vertcs=o):(a=Np(e),i.m_unit=a.isPCS?new Tf(a.metersOrRadiansPerUnit):new fn(a.metersOrRadiansPerUnit)),fp(i.m_precisionDescriptor,a,o,1),i.m_bDefaultDescriptor=!0,i.m_userWKID=e,i.calculateHashCode(),i.initDbgName(),i}function gp(e,t,n){return ht((e-t)*n)/n+t}let _p=null;const vp=3552713678800501e-30;function yp(e,t,n){return e===t||Math.abs(e-t)<=n*(1+(Math.abs(e)+Math.abs(t))/2)}function Z(e,t){return yp(e,t,vp)}function bp(e,t){return e===0||Math.abs(e)<=t}function xp(e){return bp(e,vp)}let Sp;function Cp(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){let e=this._this;return this._this=null,e}}}let Q,$,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp=null;function Np(e){l(Mp);let t=Mp(e);return t.semiMajor=t.isPCS?NaN:Bp(e),t}function Pp(e){Mp=e,l(Mp)}function Fp(e){let t=e;Q=t.PeFactory,l(Q),jp=t.PeGCSExtent,l(jp),kp=t.PeLineType,l(kp),Ap=t.PeMath,l(Ap),Sp=t.PeDouble,l(Sp),$=t.PeDefs,l($),wp=t.PeCSTransformations,l(wp),Tp=t.PeGTTransformations,l(Tp),Ep=t.PePCSInfo,l(Ep),Dp=t.PeGTlistExtended,l(Dp),Q.initialize(),Op=t.PeGTlistExtendedEntry,l(Op),$.PE_TYPE_ANGUNIT=512,$.PE_STR_AUTH_ALL=2,Ep.PE_POLE_LINE_STRAIGHT=2,Ep.PE_POLE_LINE_CURVED=3,$.PE_PARM_LAM0=2,$.PE_PARM_PHI0=6,$.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,$.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,$.PE_PRJ_ALBERS=43007,$.PE_PRJ_CYLINDRICAL_EQAREA=43034,$.PE_TYPE_VERTCS=8,$.PE_LINETYPE_GEODESIC=0,$.PE_LINETYPE_LOXODROME=1,$.PE_LINETYPE_GREAT_ELLIPTIC=2,$.PE_LINETYPE_NORMAL_SECTION=3,Dp.PE_GTLIST_OPTS_USABLE=1,Mp=null}function Ip(e,t,n,r){return t<=0?(n[0]=0,r[0]=0,!1):(n[0]=t,r[0]=t,!0)}function Lp(e){return l(zf()),Mp(e).isPCS?!0:Rp(e)}function Rp(e){return Q&&y(`pe has been loaded. no-pe methods should not be used at this point.`),_p||Vp(),_p.has(e)}const zp=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Bp(e){if(Q&&y(`pe has been loaded. no-pe methods should not be used at this point.`),typeof e==`string`){let t=e.match(zp);(!t||t.length!==2)&&n(`bad gcs wkt`);let r=Number.parseFloat(t[1]);return Number.isFinite(r)||n(`bad gcs wkt`),r}return _p||Vp(),_p.has(e)||y(`gcs wkid not found`),_p.get(e)}function Vp(){_p=new Map;for(let e in un){let t=Number.parseFloat(e),n=un[e];if(Array.isArray(n))for(let e of n)_p.set(e,t);else _p.set(n,t)}dn()}function Hp(e,t){let n=Q.geogtran(e);return n||g(e),new qp(n,t)}function Up(e,t){let n=Q.fromString($.PE_TYPE_GEOGTRAN,e);return n||_(e),new qp(n,t)}function Wp(e,t){return new qp(e,t)}const Gp=lt(0),Kp=lt(1);class qp{m_geogTranWrapper;m_hashCode;m_bInverted;constructor(e,t){if(e instanceof qp){this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,this.m_hashCode=ct(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Kp:Gp);return}this.m_geogTranWrapper=new Ll(e),this.m_bInverted=t,this.m_hashCode=ct(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Kp:Gp)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return``;if(e===-1)return this.m_geogTranWrapper.getGeogtran().toString();{let t=e===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=$.PE_STR_FMT_WKT2;return e!==-1&&(t|=e===0?$.PE_STR_AUTH_TOP:$.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(t)}getName(){return!this.m_geogTranWrapper||!this.m_geogTranWrapper.getGeogtran()?``:this.m_geogTranWrapper.getGeogtran().getName()}getInputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getOutputSr(!1):this.m_geogTranWrapper.getInputSr(!1)}getOutputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getInputSr(!1):this.m_geogTranWrapper.getOutputSr(!1)}getInverse(){return new qp(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){let t=e;return t===this?!0:this.m_bInverted===t.m_bInverted?this.GetPeGeogtran()===t.GetPeGeogtran()||!(this.getID()!==t.getID()||this.getID()===0&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())):!1}referencesMissingData(){return this.m_geogTranWrapper?!this.m_geogTranWrapper.isUsable():!1}getWrapper(){return this.m_geogTranWrapper}}function Jp(n,r,i,a,o){let s=n.getGCS(),c=r.getGCS(),u=s,d=c,f=u.getPECoordSys(),p=d.getPECoordSys(),m=null;if(!i.isEmpty()){let e=i.clone();if(!e.isEmpty()&&n.getCoordinateSystemType()===2){let t=new Me({env2D:e}),r=Hd(n,s,null);t=new Rc().execute(t,r,null),t.queryEnvelope(e)}if(!e.isEmpty()){let t=f.getPrimem().getLongitude(),n=f.getUnit().getUnitFactor();m=new jp(e.xmin,e.ymin,e.xmax,e.ymax,t,n)}}let h=a;h>=Ut()&&(h=0);let g=[],_=Dp.PE_GTLIST_OPTS_COMMON;o||(_&=~Dp.PE_GTLIST_OPTS_USABLE);for(let n=0;n<2;n++){let n={stack:[],error:void 0,hasError:!1};try{g.length=0;let t=Dp.getGTlist(f,p,2,_,m,h);if(t==null||t.length===0)break;e(n,{[Symbol.dispose](){Op.destroy(t)}},!1);let r=!1;for(let e of t){let t=Xp(e);if(l(t),o&&t.referencesMissingData()){r=!0,h=0;continue}if(g.push(t),g.length===a)break}if(!r)break}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}return m&&m.destroy(),g}function Yp(){return new Zp([],null,null,null)}function Xp(e){let t=new Qp,n=e.getSteps();if(n){let r=e.getEntries();for(let e=0;e<n;e++){let n=r[e].getDirection()!==0,i,a=r[e].getGeogtran().getCode();if(a>=0)i=Q.geogtran(a);else{let t=r[e].getGeogtran().toString($.PE_STR_FMT_WKT);i=Q.fromString($.PE_TYPE_GEOGTRAN,t)}if(i==null)return null;let o=Wp(i,n);t.add(o)}return t.create()}return null}class Zp{m_bReadOnly=!0;m_transforms;m_inputSr;m_outputSr;m_name=``;m_fastTrack=-1;m_bNameIsSet=!1;constructor(e,t,n,r){this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=n,this.m_outputSr=r}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(this.m_transforms.length===0)return``;let e=``;for(let t of this.m_transforms)e.length>0&&(e+=` + `),t.isInverted()&&(e+=`~`),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=ct(e,this.m_transforms[t].getHashCode());return e}equals(e){return l(0),!1}referencesMissingData(){if(this.m_transforms.length===0)return!1;for(let e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return l(0),!1}validateTransformation(e,t){return l(0),!1}nameIsSet(){return l(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&x(``),this.m_transforms[e]}getInverse(){let e=new Qp;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,n){if(this.count()===0)return;let r=this.m_inputSr,i=this.m_outputSr;if(e&&(i=gt(r,r=i)),this.m_transforms.length===0){Rl(r,null,i,null,t,null,n);return}let a=this.m_fastTrack;if(a===1){le(e,this.m_transforms,r=>{Ul(r.getWrapper(),e!==r.isInverted(),t,null,n)});return}let o=Il();a===-1&&o.initFromGcsAndVcs(r,null);let s=Il(),c=e?this.m_transforms.length-1:0,l=e?-1:1;for(let i=0,u=this.m_transforms.length;i<u;i++,c+=l){if(i===0){let i=this.m_transforms[c];zl(r.getPECoordSys(),null,i.getWrapper(),e!==i.isInverted(),t,null,n,s),a===-1&&(o.equals(s)||(a=0)),o.assign(s)}else{let r=this.m_transforms[c-l],i=this.m_transforms[c];Vl(o,r.getWrapper(),e!==r.isInverted(),i.getWrapper(),e!==i.isInverted(),t,null,n,s),a===-1&&(o.equals(s)||(a=0)),o.assign(s)}let u=this.m_transforms[c];Hl(o,u.getWrapper(),e!==u.isInverted(),t,null,n,s),o.assign(s)}let u=this.m_transforms[c-l];Bl(o,u.getWrapper(),e!==u.isInverted(),i,null,t,null,n),a===-1&&(s.initFromGcsAndVcs(i,null),o.equals(s)||(a=0)),this.m_fastTrack=a===0?0:1}}class Qp{m_transforms=[];m_inputGCS=null;m_outputGCS=null;m_name=``;m_bNameIsSet=!1;getInputSpatialReference(){return this.m_inputGCS===null?this.count()>0?this.m_transforms[0].getInputSpatialReference():null:this.m_inputGCS}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return this.m_outputGCS===null?this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null:this.m_outputGCS}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(this.m_transforms.length===0)return``;let e=``;for(let t of this.m_transforms)e.length>0&&(e+=` + `),t.isInverted()&&(e+=`~`),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&x(``),this.m_transforms[e]}setStep(e,t){l(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let t=e.count()-1;t>=0;--t)this.add(e.getStep(t).getInverse());else for(let t=0;t<e.count();++t)this.add(e.getStep(t))}clear(){this.m_transforms=[],this.m_name=``,this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){l(0)}create(){let e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),n=new Zp(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return n.m_bReadOnly=!0,this.clear(),n}}export{ai as $,Wp as A,Gd as B,Bd as C,Hd as D,Vd as E,Wd as F,qp as G,Kd as H,Xd as I,xc as J,qo as K,ri as L,ms as M,hs as N,Rc as O,$d as P,ss as Q,Ss as R,rp as S,ys as T,_s as U,gs as V,J as W,ac as X,cc as Y,Wl as Z,Ri as _,ip as a,cn as a$,ci as a0,Gl as a1,Kl as a2,Yl as a3,Ec as a4,ou as a5,Xs as a6,Ns as a7,us as a8,Qr as a9,Ru as aA,Yo as aB,En as aC,wp as aD,Ou as aE,Ju as aF,Gn as aG,An as aH,Nn as aI,kc as aJ,Wn as aK,kn as aL,qu as aM,$ as aN,fu as aO,gd as aP,cs as aQ,Us as aR,Fs as aS,rc as aT,sr as aU,Y as aV,Jn as aW,Q as aX,Gu as aY,Vn as aZ,Nl as a_,Qo as aa,Ls as ab,Qp as ac,Yp as ad,Ap as ae,Bc as af,Fu as ag,Vc as ah,pn as ai,Fd as aj,fl as ak,Pu as al,Z as am,Sp as an,kp as ao,dl as ap,Wc as aq,Gc as ar,Hc as as,Uc as at,pl as au,xn as av,Ku as aw,cd as ax,yn as ay,Uu as az,Hf as b,Vf as c,Uf as d,qf as e,Gf as f,Kf as g,Yf as h,If as i,tp as j,zf as k,Rf as l,Lf as m,Bf as n,np as o,Xf as p,Zf as q,Pf as r,Jf as s,cp as t,up as u,du as v,op as w,ql as x,Hp as y,Up as z};
|