@arcgis/core 5.2.0-next.15 → 5.2.0-next.16

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.
Files changed (830) hide show
  1. package/applications/Urban/editingSessionUtils.js +1 -1
  2. package/arcade/featureSetUtils.js +1 -1
  3. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  4. package/arcade/featureset/sources/FeatureLayerParquet.js +2 -0
  5. package/arcade/featureset/support/FeatureSet.js +1 -1
  6. package/arcade/featureset/support/shared.js +1 -1
  7. package/arcade.d.ts +2 -1
  8. package/arcgisGlobal.d.ts +3 -1
  9. package/assets/esri/core/t9n/Units_ar.json +1 -1
  10. package/assets/esri/core/t9n/Units_bg.json +1 -1
  11. package/assets/esri/core/t9n/Units_bs.json +1 -1
  12. package/assets/esri/core/t9n/Units_ca.json +1 -1
  13. package/assets/esri/core/t9n/Units_cs.json +1 -1
  14. package/assets/esri/core/t9n/Units_da.json +1 -1
  15. package/assets/esri/core/t9n/Units_de.json +1 -1
  16. package/assets/esri/core/t9n/Units_el.json +1 -1
  17. package/assets/esri/core/t9n/Units_es.json +1 -1
  18. package/assets/esri/core/t9n/Units_et.json +1 -1
  19. package/assets/esri/core/t9n/Units_fi.json +1 -1
  20. package/assets/esri/core/t9n/Units_fr.json +1 -1
  21. package/assets/esri/core/t9n/Units_he.json +1 -1
  22. package/assets/esri/core/t9n/Units_hr.json +1 -1
  23. package/assets/esri/core/t9n/Units_hu.json +1 -1
  24. package/assets/esri/core/t9n/Units_id.json +1 -1
  25. package/assets/esri/core/t9n/Units_it.json +1 -1
  26. package/assets/esri/core/t9n/Units_ja.json +1 -1
  27. package/assets/esri/core/t9n/Units_ko.json +1 -1
  28. package/assets/esri/core/t9n/Units_lt.json +1 -1
  29. package/assets/esri/core/t9n/Units_lv.json +1 -1
  30. package/assets/esri/core/t9n/Units_nl.json +1 -1
  31. package/assets/esri/core/t9n/Units_no.json +1 -1
  32. package/assets/esri/core/t9n/Units_pl.json +1 -1
  33. package/assets/esri/core/t9n/Units_pt-BR.json +1 -1
  34. package/assets/esri/core/t9n/Units_pt-PT.json +1 -1
  35. package/assets/esri/core/t9n/Units_ro.json +1 -1
  36. package/assets/esri/core/t9n/Units_ru.json +1 -1
  37. package/assets/esri/core/t9n/Units_sk.json +1 -1
  38. package/assets/esri/core/t9n/Units_sl.json +1 -1
  39. package/assets/esri/core/t9n/Units_sr.json +1 -1
  40. package/assets/esri/core/t9n/Units_sv.json +1 -1
  41. package/assets/esri/core/t9n/Units_th.json +1 -1
  42. package/assets/esri/core/t9n/Units_tr.json +1 -1
  43. package/assets/esri/core/t9n/Units_uk.json +1 -1
  44. package/assets/esri/core/t9n/Units_vi.json +1 -1
  45. package/assets/esri/core/t9n/Units_zh-CN.json +1 -1
  46. package/assets/esri/core/t9n/Units_zh-HK.json +1 -1
  47. package/assets/esri/core/t9n/Units_zh-TW.json +1 -1
  48. package/assets/esri/core/workers/RemoteClient.js +1 -1
  49. package/assets/esri/core/workers/chunks/007485862ce95928717a.js +1 -0
  50. package/assets/esri/core/workers/chunks/{d9d4754062758789f186.js → 05016e5a1de384994001.js} +2 -2
  51. package/assets/esri/core/workers/chunks/05b6b2c0b76afb100e33.js +1 -0
  52. package/assets/esri/core/workers/chunks/{8927fb4aa68f7e541a39.js → 05d597dd117766beadd8.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{b045bffb4f2eb9203183.js → 05e1f1628a3726eca03d.js} +1 -1
  54. package/assets/esri/core/workers/chunks/0a52373c4ba652e0ee0f.js +1 -0
  55. package/assets/esri/core/workers/chunks/0b522e05668bef729b1b.js +1 -0
  56. package/assets/esri/core/workers/chunks/0d42322362e76f674d94.js +2 -0
  57. package/assets/esri/core/workers/chunks/{81e3bd1a0634ddc2b833.js → 0f10d7d592c36ee2d1ea.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{cdf6ad970dc1893dac58.js → 110135b0562a3b5708b9.js} +1 -1
  59. package/assets/esri/core/workers/chunks/122892f365f5327d290c.js +1 -0
  60. package/assets/esri/core/workers/chunks/1305690054214a9cf48d.js +1 -0
  61. package/assets/esri/core/workers/chunks/168c15cf462f9abcbdd2.js +1 -0
  62. package/assets/esri/core/workers/chunks/169bfafec4d59be2beb0.js +1 -0
  63. package/assets/esri/core/workers/chunks/1c689bb502657b1f173b.js +1 -0
  64. package/assets/esri/core/workers/chunks/1d2609ce6220b5af5526.js +1 -0
  65. package/assets/esri/core/workers/chunks/1d38b2fcd85ac9ebd7c6.js +1 -0
  66. package/assets/esri/core/workers/chunks/1e109a521ca8772fdf04.js +1 -0
  67. package/assets/esri/core/workers/chunks/1ea840b7ac1ffaa0c389.js +1 -0
  68. package/assets/esri/core/workers/chunks/1f48438b3055afeb710f.js +1 -0
  69. package/assets/esri/core/workers/chunks/{c2cd80b712f29e8cbb8d.js → 1ff57bf19f021f5fd246.js} +1 -1
  70. package/assets/esri/core/workers/chunks/2353fbc1ff4481dcfb1f.js +1 -0
  71. package/assets/esri/core/workers/chunks/2509da565e5a2b43ac7f.js +1 -0
  72. package/assets/esri/core/workers/chunks/255c8e937e7a123ebb04.js +1 -0
  73. package/assets/esri/core/workers/chunks/256cc116e3be4feee593.js +1 -0
  74. package/assets/esri/core/workers/chunks/26aa8190ac439f634c5b.js +1 -0
  75. package/assets/esri/core/workers/chunks/{a442534ac0956a68b769.js → 282930645ce525d5bc92.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{45b560ca01fb566ba560.js → 2a8d791aef3123e6a3c4.js} +1 -1
  77. package/assets/esri/core/workers/chunks/2b781de7b467c61849b2.js +1 -0
  78. package/assets/esri/core/workers/chunks/2baee42e1797a709fe4b.js +1 -0
  79. package/assets/esri/core/workers/chunks/2c017eae434254610c8e.js +1 -0
  80. package/assets/esri/core/workers/chunks/2d7a4b669804d0c5029b.js +1 -0
  81. package/assets/esri/core/workers/chunks/2f40193d1b2e534c5226.js +1 -0
  82. package/assets/esri/core/workers/chunks/303e723e829ea7088d43.js +1 -0
  83. package/assets/esri/core/workers/chunks/35533c8ef541f7643497.js +2 -0
  84. package/assets/esri/core/workers/chunks/36913f0f944a9eb82cd3.js +1 -0
  85. package/assets/esri/core/workers/chunks/{cc62e5095e328bed3e01.js → 3aa0a34d2b7dbf2e2c66.js} +1 -1
  86. package/assets/esri/core/workers/chunks/3d4ad7c728e02aa90551.js +1 -0
  87. package/assets/esri/core/workers/chunks/{3526ab3b1f87c24ae6f8.js → 4162a2bb774e6ba2c0db.js} +1 -1
  88. package/assets/esri/core/workers/chunks/436d51b9f1b1b5abc4bc.js +1 -0
  89. package/assets/esri/core/workers/chunks/43ef6dee2e1d9ed7885e.js +1 -0
  90. package/assets/esri/core/workers/chunks/442424200e7475e9a08f.js +1 -0
  91. package/assets/esri/core/workers/chunks/4b96aa2dc5b88846bb53.js +1 -0
  92. package/assets/esri/core/workers/chunks/4ea325c829d3b82854b1.js +1 -0
  93. package/assets/esri/core/workers/chunks/51a53011478e0cf96e0b.js +1 -0
  94. package/assets/esri/core/workers/chunks/51a8a47aac1d8d22ba9d.js +1 -0
  95. package/assets/esri/core/workers/chunks/5481af25fd46914498df.js +1 -0
  96. package/assets/esri/core/workers/chunks/54f54623532f633dc0e2.js +1 -0
  97. package/assets/esri/core/workers/chunks/5809e70a8e57e9b05959.js +1 -0
  98. package/assets/esri/core/workers/chunks/589b31cc5c663a288942.js +1 -0
  99. package/assets/esri/core/workers/chunks/58ce4bcfb15f378b1b9f.js +1 -0
  100. package/assets/esri/core/workers/chunks/58e0e50b6c3abaa4798f.js +1 -0
  101. package/assets/esri/core/workers/chunks/595bc41ff36c77324d01.js +261 -0
  102. package/assets/esri/core/workers/chunks/599bd80379423c99799d.js +1 -0
  103. package/assets/esri/core/workers/chunks/5bf01e0eff8a78b65e9e.js +1 -0
  104. package/assets/esri/core/workers/chunks/5dfeefee96659832398a.js +1 -0
  105. package/assets/esri/core/workers/chunks/{011a4d4201696fa10408.js → 5ea1113b7bdcf94b2822.js} +1 -1
  106. package/assets/esri/core/workers/chunks/5fab14c5f1febebb75f1.js +1 -0
  107. package/assets/esri/core/workers/chunks/609edb4da427ec37bcf7.js +1 -0
  108. package/assets/esri/core/workers/chunks/60d4a3f770bb1e01cd10.js +1 -0
  109. package/assets/esri/core/workers/chunks/63858dfcff1177e597e7.js +1 -0
  110. package/assets/esri/core/workers/chunks/686c1a1b794ebe1a0341.js +1 -0
  111. package/assets/esri/core/workers/chunks/68b77b36daae2b4b4237.js +1 -0
  112. package/assets/esri/core/workers/chunks/{11c3b1e8ca21ad62fdd1.js → 6db5ee9c589265b23b60.js} +1 -1
  113. package/assets/esri/core/workers/chunks/6dc60afb0c39bbb001a3.js +1 -0
  114. package/assets/esri/core/workers/chunks/{5bfae465872760e7af6d.js → 6f240fe78b299e6c4fcc.js} +1 -1
  115. package/assets/esri/core/workers/chunks/70cb825bb37f1977d2ab.js +1 -0
  116. package/assets/esri/core/workers/chunks/71a593fa116770e58832.js +1 -0
  117. package/assets/esri/core/workers/chunks/71f09e34d56c9fe5c307.js +1 -0
  118. package/assets/esri/core/workers/chunks/{72cfb186e50537bcdd19.js → 75915f81caaf9e5345a9.js} +1 -1
  119. package/assets/esri/core/workers/chunks/7832d94f35b79e27ee51.js +1 -0
  120. package/assets/esri/core/workers/chunks/{e5f8c73349407c25956b.js → 7c61b18e43c789aaecc6.js} +1 -1
  121. package/assets/esri/core/workers/chunks/818a481ce579f519de1c.js +1 -0
  122. package/assets/esri/core/workers/chunks/831455798b177678720c.js +1 -0
  123. package/assets/esri/core/workers/chunks/83ce38342796bd6d73ce.js +1 -0
  124. package/assets/esri/core/workers/chunks/84a0bb53fcbd99b5aa0c.js +1 -0
  125. package/assets/esri/core/workers/chunks/87b86375f8557418dbe6.js +1 -0
  126. package/assets/esri/core/workers/chunks/8817d25c7f4cf0e6c6bd.js +1 -0
  127. package/assets/esri/core/workers/chunks/{0b55fc5050e718371e05.js → 888af532ad48fd86f285.js} +1 -1
  128. package/assets/esri/core/workers/chunks/{9331969046f2b277d620.js → 8a39dd585742960d3ca2.js} +1 -1
  129. package/assets/esri/core/workers/chunks/8ade399db21938822a7c.js +1 -0
  130. package/assets/esri/core/workers/chunks/8c62e2dabd1f1e13d244.js +1 -0
  131. package/assets/esri/core/workers/chunks/{5cb1b950249d651f3837.js → 8dcb3e77f76d8396706b.js} +1 -1
  132. package/assets/esri/core/workers/chunks/909e88c27d80777b047c.js +1 -0
  133. package/assets/esri/core/workers/chunks/91c5205d1274c7f190d5.js +1 -0
  134. package/assets/esri/core/workers/chunks/91c543443cd6768ad6ff.js +1 -0
  135. package/assets/esri/core/workers/chunks/9230ad807020fc2bbf8e.js +1 -0
  136. package/assets/esri/core/workers/chunks/92458803531fdfe1557a.js +1 -0
  137. package/assets/esri/core/workers/chunks/{976ab2be6c244768c08a.js → 940ebb13618d38c6b459.js} +1 -1
  138. package/assets/esri/core/workers/chunks/987594539981483a7c5e.js +1 -0
  139. package/assets/esri/core/workers/chunks/99c002015c2127e6cbfc.js +2 -0
  140. package/assets/esri/core/workers/chunks/9da1a514e042eb642d35.js +1 -0
  141. package/assets/esri/core/workers/chunks/a1509e2e7809b6754b4f.js +1 -0
  142. package/assets/esri/core/workers/chunks/{a4f3bcfabd4ad127abf2.js → a3195521a83565c7c2d3.js} +1 -1
  143. package/assets/esri/core/workers/chunks/a3393780655152102c45.js +1 -0
  144. package/assets/esri/core/workers/chunks/{52175ff9e8c2c136f90a.js → a3ecde3794a7db3cf283.js} +1 -1
  145. package/assets/esri/core/workers/chunks/a4d918b47cd4ee0e1666.js +1 -0
  146. package/assets/esri/core/workers/chunks/a844c4e031e77db11478.js +1 -0
  147. package/assets/esri/core/workers/chunks/{bfd1aef8ac795e1ce227.js → a892b3be70f482bef0ba.js} +1 -1
  148. package/assets/esri/core/workers/chunks/a8ef7acb6d3d1f45e14c.js +1 -0
  149. package/assets/esri/core/workers/chunks/a99ce2f12c8204ee542a.js +1 -0
  150. package/assets/esri/core/workers/chunks/aba7a053015a9738d8a0.js +1 -0
  151. package/assets/esri/core/workers/chunks/{c8460bdf60aca749ed05.js → ac16016964be3b684e98.js} +1 -1
  152. package/assets/esri/core/workers/chunks/ac7ecd90330090c90005.js +1 -0
  153. package/assets/esri/core/workers/chunks/adce59e4111bae4225f7.js +1 -0
  154. package/assets/esri/core/workers/chunks/af3b060fdfa3b6174340.js +1 -0
  155. package/assets/esri/core/workers/chunks/b0212df1fe8d9448f3d6.js +1 -0
  156. package/assets/esri/core/workers/chunks/b289c46ce2dc04d32e81.js +1 -0
  157. package/assets/esri/core/workers/chunks/{c983e5ce0ff952b65d7f.js → b2b342b06d502fc61ea5.js} +1 -1
  158. package/assets/esri/core/workers/chunks/{67ebde34377f98d17cda.js → b5571e93bc136dac8ee1.js} +1 -1
  159. package/assets/esri/core/workers/chunks/ba1c4a8794ac55942e35.js +1 -0
  160. package/assets/esri/core/workers/chunks/bbcad2fde838819ffc7b.js +1 -0
  161. package/assets/esri/core/workers/chunks/bd260798b8de09a1eeb2.js +1 -0
  162. package/assets/esri/core/workers/chunks/{44d0ca9d4c5f1722688c.js → bf67e0f6064fb9d94ac8.js} +1 -1
  163. package/assets/esri/core/workers/chunks/{0bf72e9d0a6deceeb406.js → bfa6f4c08e7571bb1f37.js} +1 -1
  164. package/assets/esri/core/workers/chunks/c030a974a63155f450e9.js +1 -0
  165. package/assets/esri/core/workers/chunks/c0b7b9d115dccb2924ff.js +1 -0
  166. package/assets/esri/core/workers/chunks/c2db773201adca204f95.js +1 -0
  167. package/assets/esri/core/workers/chunks/c318e6dbb8651433038f.js +2 -0
  168. package/assets/esri/core/workers/chunks/c4a2ec2e5897300163ac.js +1 -0
  169. package/assets/esri/core/workers/chunks/{8b0a01ebc86ab226f01f.js → c538435216d253f7702e.js} +1 -1
  170. package/assets/esri/core/workers/chunks/c5e172d3baf5414868f0.js +1 -0
  171. package/assets/esri/core/workers/chunks/c63b315c6b76b4860fc5.js +1 -0
  172. package/assets/esri/core/workers/chunks/c8091e8fd7ca43a4490a.js +1 -0
  173. package/assets/esri/core/workers/chunks/{2413b383b7f2bdcd4ced.js → c8672a54c98d472aa24d.js} +1 -1
  174. package/assets/esri/core/workers/chunks/cf9a132c4c37e62de3d7.js +1 -0
  175. package/assets/esri/core/workers/chunks/d0321dd4b5b2d863eecd.js +1 -0
  176. package/assets/esri/core/workers/chunks/{886ae23a1d8fa21e531f.js → d750e4abeb777caa8c36.js} +1 -1
  177. package/assets/esri/core/workers/chunks/{bd36c57dd0cd28dee55f.js → d7acbc2ddff4cee8a465.js} +1 -1
  178. package/assets/esri/core/workers/chunks/{cb8c4d8334fab9bd9a04.js → d90bc34d97bb21c29c40.js} +1 -1
  179. package/assets/esri/core/workers/chunks/d9fcc63df008f687848a.js +1 -0
  180. package/assets/esri/core/workers/chunks/db96a0c66578b2d1b715.js +1 -0
  181. package/assets/esri/core/workers/chunks/{6a1b6f8c868f8edce1d7.js → dd3b0070081eaf805d95.js} +1 -1
  182. package/assets/esri/core/workers/chunks/dd5dddf7e422216d3806.js +1 -0
  183. package/assets/esri/core/workers/chunks/de83c177f8a1234a5b2e.js +1 -0
  184. package/assets/esri/core/workers/chunks/{07ca020796c57cefda62.js → dfb19701b488089874fd.js} +1 -1
  185. package/assets/esri/core/workers/chunks/e2f33945d838183a2192.js +1 -0
  186. package/assets/esri/core/workers/chunks/{d97c0c18202b8c578f8c.js → e5471373f89fd7cb9844.js} +1 -1
  187. package/assets/esri/core/workers/chunks/e65d291bab13f7f5323b.js +1 -0
  188. package/assets/esri/core/workers/chunks/e95ee94027c1934086d8.js +1 -0
  189. package/assets/esri/core/workers/chunks/ecbf84a1f42e6188faab.js +1 -0
  190. package/assets/esri/core/workers/chunks/efaa1d05705f6b450e8f.js +1 -0
  191. package/assets/esri/core/workers/chunks/efaf998d18479a0380ae.js +1 -0
  192. package/assets/esri/core/workers/chunks/f0573db9a3d3e1499a7e.js +1 -0
  193. package/assets/esri/core/workers/chunks/f07722efd7fa2b75d4dd.js +1 -0
  194. package/assets/esri/core/workers/chunks/{520e0e5307eef27becc6.js → f0924613f818dd165ad9.js} +1 -1
  195. package/assets/esri/core/workers/chunks/f3fd40df92e59f7c687c.js +1 -0
  196. package/assets/esri/core/workers/chunks/{3d20c86f1fe877bf884b.js → f59b76fde2cbd17f64b3.js} +1 -1
  197. package/assets/esri/core/workers/chunks/f6afc597eaf2afa9a4a0.js +1 -0
  198. package/assets/esri/core/workers/chunks/{ed2a1c371dfc5d4a744e.js → f7f820483e45c05ab9e4.js} +2 -2
  199. package/assets/esri/core/workers/chunks/f98bb3885bfc7f18f26c.js +1 -0
  200. package/assets/esri/core/workers/chunks/f9b44ff9bb4f7a88ab56.js +1 -0
  201. package/assets/esri/core/workers/chunks/{b102beeeb7a919f68b51.js → fb81705cec1be2431876.js} +1 -1
  202. package/assets/esri/core/workers/chunks/fd53ef66176ae164e221.js +1 -0
  203. package/assets/esri/core/workers/chunks/fd956a58787020d610af.js +1 -0
  204. package/assets/esri/core/workers/chunks/fdec3a2e100688c42e41.js +1 -0
  205. package/assets/esri/core/workers/chunks/fe6385115d76e16e8da0.js +1 -0
  206. package/assets/esri/core/workers/chunks/fedbeb488d5d7c07c7dc.js +1 -0
  207. package/assets/esri/core/workers/chunks/{d9695794cfaa014a55b1.js → ff00ac01f0baaecaa890.js} +1 -1
  208. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  209. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +62 -90
  210. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +0 -2
  211. package/assets/esri/themes/dark/main.css +1 -1
  212. package/assets/esri/themes/light/main.css +1 -1
  213. package/assets/esri/themes/light/view.css +1 -1
  214. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ar.json +1 -1
  215. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_bg.json +1 -1
  216. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_bs.json +1 -1
  217. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ca.json +1 -1
  218. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_cs.json +1 -1
  219. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_da.json +1 -1
  220. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_de.json +1 -1
  221. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_el.json +1 -1
  222. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_es.json +1 -1
  223. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_et.json +1 -1
  224. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_fi.json +1 -1
  225. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_fr.json +1 -1
  226. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_he.json +1 -1
  227. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_hr.json +1 -1
  228. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_hu.json +1 -1
  229. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_id.json +1 -1
  230. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_it.json +1 -1
  231. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ja.json +1 -1
  232. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ko.json +1 -1
  233. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_lt.json +1 -1
  234. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_lv.json +1 -1
  235. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_nl.json +1 -1
  236. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_no.json +1 -1
  237. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_pl.json +1 -1
  238. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_pt-BR.json +1 -1
  239. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_pt-PT.json +1 -1
  240. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ro.json +1 -1
  241. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_ru.json +1 -1
  242. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_sk.json +1 -1
  243. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_sl.json +1 -1
  244. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_sr.json +1 -1
  245. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_sv.json +1 -1
  246. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_th.json +1 -1
  247. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_tr.json +1 -1
  248. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_uk.json +1 -1
  249. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_vi.json +1 -1
  250. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_zh-CN.json +1 -1
  251. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_zh-HK.json +1 -1
  252. package/assets/esri/views/3d/analysis/ShadowCast/t9n/ShadowCastAnalysis_zh-TW.json +1 -1
  253. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ar.json +1 -1
  254. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bg.json +1 -1
  255. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bs.json +1 -1
  256. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ca.json +1 -1
  257. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_cs.json +1 -1
  258. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_da.json +1 -1
  259. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_de.json +1 -1
  260. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_el.json +1 -1
  261. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_es.json +1 -1
  262. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_et.json +1 -1
  263. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fi.json +1 -1
  264. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fr.json +1 -1
  265. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_he.json +1 -1
  266. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hr.json +1 -1
  267. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hu.json +1 -1
  268. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_id.json +1 -1
  269. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_it.json +1 -1
  270. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ja.json +1 -1
  271. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ko.json +1 -1
  272. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lt.json +1 -1
  273. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lv.json +1 -1
  274. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_nl.json +1 -1
  275. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_no.json +1 -1
  276. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pl.json +1 -1
  277. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-BR.json +1 -1
  278. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-PT.json +1 -1
  279. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ro.json +1 -1
  280. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ru.json +1 -1
  281. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sk.json +1 -1
  282. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sl.json +1 -1
  283. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sr.json +1 -1
  284. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sv.json +1 -1
  285. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_th.json +1 -1
  286. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_tr.json +1 -1
  287. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_uk.json +1 -1
  288. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_vi.json +1 -1
  289. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-CN.json +1 -1
  290. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-HK.json +1 -1
  291. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-TW.json +1 -1
  292. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  293. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  294. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  295. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  296. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  297. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  298. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  299. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  300. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  301. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  302. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  303. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  304. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  305. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  306. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  307. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  308. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  309. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  310. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  311. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  312. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  313. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  314. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  315. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  316. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  317. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  318. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  319. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  320. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  321. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  322. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  323. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  324. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  325. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  326. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  327. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  328. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  329. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  330. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  331. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  332. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  333. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  334. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  335. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  336. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  337. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  338. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  339. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  340. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  341. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  342. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  343. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  344. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  345. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  346. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  347. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  348. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  349. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  350. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  351. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  352. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  353. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  354. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  355. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  356. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  357. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  358. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  359. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  360. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  361. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  362. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  363. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  364. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  365. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  366. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  367. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  368. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  369. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  370. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  371. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  372. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  373. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  374. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  375. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  376. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  377. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  378. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  379. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  380. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  381. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  382. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  383. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  384. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  385. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  386. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  387. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  388. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  389. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  390. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  391. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  392. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  393. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  394. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  395. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  396. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  397. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  398. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  399. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  400. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  401. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  402. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  403. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  404. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  405. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  406. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  407. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  408. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  409. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ar.json +1 -1
  410. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_bg.json +1 -1
  411. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_bs.json +1 -1
  412. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ca.json +1 -1
  413. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_cs.json +1 -1
  414. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_da.json +1 -1
  415. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_de.json +1 -1
  416. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_el.json +1 -1
  417. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_es.json +1 -1
  418. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_et.json +1 -1
  419. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_fi.json +1 -1
  420. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_fr.json +1 -1
  421. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_he.json +1 -1
  422. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_hr.json +1 -1
  423. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_hu.json +1 -1
  424. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_id.json +1 -1
  425. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_it.json +1 -1
  426. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ja.json +1 -1
  427. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ko.json +1 -1
  428. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_lt.json +1 -1
  429. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_lv.json +1 -1
  430. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_nl.json +1 -1
  431. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_no.json +1 -1
  432. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_pl.json +1 -1
  433. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_pt-BR.json +1 -1
  434. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_pt-PT.json +1 -1
  435. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ro.json +1 -1
  436. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_ru.json +1 -1
  437. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_sk.json +1 -1
  438. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_sl.json +1 -1
  439. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_sr.json +1 -1
  440. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_sv.json +1 -1
  441. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_th.json +1 -1
  442. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_tr.json +1 -1
  443. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_uk.json +1 -1
  444. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_vi.json +1 -1
  445. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_zh-CN.json +1 -1
  446. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_zh-HK.json +1 -1
  447. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_zh-TW.json +1 -1
  448. package/chunks/Bufferer-CclWhXVb.js +2 -0
  449. package/chunks/Distance2DCalculator-DjIp2uQi.js +2 -0
  450. package/chunks/Envelope.js +1 -1
  451. package/chunks/Envelope2D.js +1 -1
  452. package/chunks/GaussianSplatComposition.glsl.js +1 -1
  453. package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +2 -0
  454. package/chunks/GeodeticUtils.js +1 -1
  455. package/chunks/Geometry.js +1 -1
  456. package/chunks/{GeometryCleaner-BEJM7I4l.js → GeometryCleaner-CIE8Wfmb.js} +1 -1
  457. package/chunks/GlowComposition.glsl.js +1 -1
  458. package/chunks/MultiPathImpl.js +1 -1
  459. package/chunks/OITBlend.glsl.js +1 -1
  460. package/chunks/OITDimOpaque.glsl.js +1 -1
  461. package/chunks/OperatorClip.js +1 -1
  462. package/chunks/OperatorCrosses.js +1 -1
  463. package/chunks/OperatorCut.js +1 -1
  464. package/chunks/OperatorDefinitions.js +1 -1
  465. package/chunks/OperatorDensify.js +1 -1
  466. package/chunks/OperatorGeneralize.js +1 -1
  467. package/chunks/OperatorGeodesicBuffer.js +1 -1
  468. package/chunks/OperatorGeodeticArea.js +1 -1
  469. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  470. package/chunks/OperatorGeodeticDistance.js +1 -1
  471. package/chunks/OperatorGeodeticLength.js +1 -1
  472. package/chunks/OperatorGraphicBuffer.js +2 -0
  473. package/chunks/OperatorIntegrate.js +1 -1
  474. package/chunks/OperatorIntersects.js +1 -1
  475. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  476. package/chunks/OperatorOverlaps.js +1 -1
  477. package/chunks/OperatorProximity.js +1 -1
  478. package/chunks/OperatorProximityGeodesic.js +1 -1
  479. package/chunks/OperatorShapePreservingLength.js +1 -1
  480. package/chunks/OperatorShapePreservingProject.js +1 -1
  481. package/chunks/OperatorSimplifyOGC.js +1 -1
  482. package/chunks/OperatorTouches.js +1 -1
  483. package/chunks/OperatorWithin.js +1 -1
  484. package/chunks/Point2D.js +1 -1
  485. package/chunks/ProjectionTransformation.js +1 -1
  486. package/chunks/{SideCalculator2D-BNwb5gvz.js → SideCalculator2D-DX0718xq.js} +1 -1
  487. package/chunks/SimpleGeometryCursor.js +1 -1
  488. package/chunks/SpatialReference.js +1 -1
  489. package/chunks/Transformation2D.js +1 -1
  490. package/chunks/centroidOperator.js +1 -1
  491. package/chunks/containsOperator.js +1 -1
  492. package/chunks/disjointOperator.js +1 -1
  493. package/chunks/distanceOperator.js +1 -1
  494. package/chunks/equalsOperator.js +1 -1
  495. package/chunks/languageUtils.js +1 -1
  496. package/config.js +1 -1
  497. package/core/has.js +1 -1
  498. package/core/screenUtils.js +1 -1
  499. package/editing/types.d.ts +22 -2
  500. package/form/elements/UtilityNetworkAssociationsElement.d.ts +0 -1
  501. package/geometry/Mesh.d.ts +1 -1
  502. package/geometry/operators/extendOperator.js +1 -1
  503. package/geometry/operators/gx/operatorAffineTransform.js +1 -1
  504. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  505. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  506. package/geometry/operators/gx/operatorBoundary.js +1 -1
  507. package/geometry/operators/gx/operatorBuffer.js +1 -1
  508. package/geometry/operators/gx/operatorConvexHull.js +1 -1
  509. package/geometry/operators/gx/operatorDifference.js +1 -1
  510. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  511. package/geometry/operators/gx/operatorIntersection.js +1 -1
  512. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  513. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  514. package/geometry/operators/gx/operatorLocateBetween.js +1 -1
  515. package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
  516. package/geometry/operators/gx/operatorOffset.js +1 -1
  517. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  518. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  519. package/geometry/operators/gx/operatorSinglePartToMultiPart.js +1 -1
  520. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  521. package/geometry/operators/gx/operatorUnion.js +1 -1
  522. package/geometry/operators/isNearOperator.js +1 -1
  523. package/geometry/operators/json/containsOperator.js +1 -1
  524. package/geometry/operators/json/disjointOperator.js +1 -1
  525. package/geometry/operators/reshapeOperator.js +1 -1
  526. package/geometry/operators/support/apiConverter.js +1 -1
  527. package/geometry/operators/support/initNoPeFactory.js +1 -1
  528. package/geometry/operators/support/jsonConverter.js +1 -1
  529. package/geometry/support/aaBoundingRect.js +1 -1
  530. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +5 -2
  531. package/graphic/AnnotationFeatureGraphicOrigin.js +1 -1
  532. package/graphic/DimensionFeatureGraphicOrigin.js +1 -1
  533. package/graphic/graphicOrigins.js +1 -1
  534. package/graphic/isAnnotationFeatureGraphicOrigin.d.ts +29 -0
  535. package/graphic/isAnnotationFeatureGraphicOrigin.js +2 -0
  536. package/graphic/isDimensionFeatureGraphicOrigin.d.ts +29 -0
  537. package/graphic/isDimensionFeatureGraphicOrigin.js +2 -0
  538. package/interfaces.d.ts +3 -3
  539. package/kernel.js +1 -1
  540. package/layers/AnnotationFeatureLayer.d.ts +73 -0
  541. package/layers/AnnotationFeatureLayer.js +1 -1
  542. package/layers/FeatureLayer.d.ts +7 -4
  543. package/layers/FeatureLayer.js +1 -1
  544. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  545. package/layers/ParquetLayer.js +1 -1
  546. package/layers/SubtypeGroupLayer.d.ts +7 -4
  547. package/layers/SubtypeGroupLayer.js +1 -1
  548. package/layers/graphics/applyEditsUtils.js +1 -1
  549. package/layers/graphics/data/QueryEngine.js +1 -1
  550. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  551. package/layers/graphics/sources/ParquetSource.js +1 -1
  552. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  553. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  554. package/layers/orientedImagery/transformations/utils.js +1 -1
  555. package/layers/support/{AnnotationSublayer.d.ts → AnnotationFeatureSublayer.d.ts} +12 -12
  556. package/layers/support/AnnotationFeatureSublayer.js +2 -0
  557. package/layers/support/EditingCapabilities.js +1 -1
  558. package/layers/support/ParquetPortalItemData.js +1 -1
  559. package/layers/support/SubtypeSublayer.d.ts +7 -4
  560. package/layers/support/SubtypeSublayer.js +1 -1
  561. package/layers/support/featureLayerUtils.js +1 -1
  562. package/networks/UtilityNetwork.js +1 -1
  563. package/package.json +3 -3
  564. package/popup/Feature.d.ts +57 -6
  565. package/popup/Features.d.ts +86 -7
  566. package/popup/content/UtilityNetworkAssociationsContent.d.ts +0 -1
  567. package/popup/support/UtilityNetworkAssociationType.d.ts +0 -1
  568. package/rest/print.js +1 -1
  569. package/rest/query/operations/query.js +1 -1
  570. package/smartMapping/renderers/location.js +1 -1
  571. package/smartMapping/renderers/opacity.js +1 -1
  572. package/smartMapping/renderers/predominance.js +1 -1
  573. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  574. package/smartMapping/renderers/support/rendererUtils.d.ts +3 -1
  575. package/smartMapping/renderers/support/rendererUtils.js +1 -1
  576. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  577. package/support/revision.js +1 -1
  578. package/symbols/WebStyleSymbol.js +1 -1
  579. package/symbols/cim/effects/EffectOffset.js +1 -1
  580. package/symbols/support/symbolUtils.js +1 -1
  581. package/symbols/support/webStyleSymbolCache.js +2 -0
  582. package/third-party-notices.txt +0 -32
  583. package/undoredo/support/ApplySet.js +1 -1
  584. package/undoredo/support/ApplySetItem.js +1 -1
  585. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  586. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  587. package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
  588. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
  589. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  590. package/views/2d/engine/webgl/shaderGraph/techniques/animated/attributes.js +1 -1
  591. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterVertexPack.js +1 -1
  592. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  593. package/views/2d/engine/webgl/util/AnnotationMatcher.js +1 -1
  594. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  595. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  596. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  597. package/views/2d/layers/support/annodime/annotationGraphic.js +1 -1
  598. package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
  599. package/views/2d/layers/support/annodime/utils.js +1 -1
  600. package/views/2d/support/hitTestUtils.js +1 -1
  601. package/views/2d/unitBezier.js +1 -1
  602. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +2 -0
  603. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  604. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  605. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +2 -0
  606. package/views/3d/analysis/Viewshed/ViewshedDrawToolRenderer.js +1 -1
  607. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  608. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  609. package/views/3d/analysis/Viewshed/ViewshedPlacementRootPlugin.js +1 -1
  610. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  611. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  612. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  613. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  614. package/views/3d/layers/graphics/SymbolComplexity.js +1 -1
  615. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  616. package/views/3d/support/QualityProfile.js +1 -1
  617. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  618. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  619. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathEvaluate.glsl.js +14 -6
  620. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +2 -1
  621. package/views/3d/webgl-engine/core/shaderLibrary/util/EmissionDimming.glsl.js +1 -1
  622. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  623. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  624. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  625. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  626. package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
  627. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  628. package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
  629. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  630. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +6 -7
  631. package/views/3d/webgl-engine/shaders/ditherNoise.glsl.js +1 -1
  632. package/views/LinkChartView.d.ts +3 -1
  633. package/views/View2D.d.ts +3 -1
  634. package/views/draw/support/editingSessionUtils.js +1 -1
  635. package/views/interactive/snapping/SnappingManager.js +1 -1
  636. package/views/interactive/snapping/candidates/dehydrated/{DehydratedVertexSnappingCandidate.js → DehydratedFeatureSnappingCandidate.js} +1 -1
  637. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +10 -3
  638. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  639. package/widgets/BatchAttributeForm/attachmentUtils.d.ts +9 -0
  640. package/widgets/BatchAttributeForm/attachmentUtils.js +1 -1
  641. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  642. package/widgets/BatchAttributeForm/css.js +1 -1
  643. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +3 -3
  644. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  645. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  646. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  647. package/widgets/BatchAttributeForm/inputs/GroupInput.js +1 -1
  648. package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
  649. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
  650. package/widgets/BatchAttributeForm/inputs/support/attachmentValidationCriteriaState.d.ts +1 -1
  651. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  652. package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
  653. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  654. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  655. package/widgets/BatchAttributeForm/types.d.ts +92 -7
  656. package/widgets/BatchAttributeForm.js +1 -1
  657. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  658. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  659. package/widgets/Editor/EditorViewModel.d.ts +1 -1
  660. package/widgets/Editor/EditorViewModel.js +1 -1
  661. package/widgets/Editor/Edits.js +1 -1
  662. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  663. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  664. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  665. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  666. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  667. package/widgets/Editor/UpdateWorkflow.js +1 -1
  668. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  669. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  670. package/widgets/Editor/support/EditorItem.js +1 -1
  671. package/widgets/Editor/support/SketchController.js +1 -1
  672. package/widgets/Editor/support/attachmentUtils.js +2 -0
  673. package/widgets/Editor/workflowUtils.js +1 -1
  674. package/widgets/Editor.js +1 -1
  675. package/widgets/Feature/FeatureViewModel.d.ts +0 -1
  676. package/widgets/FeatureForm/UtilityNetworkAssociationInput.d.ts +0 -1
  677. package/widgets/Features/FeaturesViewModel.d.ts +0 -1
  678. package/widgets/Features/FeaturesViewModel.js +1 -1
  679. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  680. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  681. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  682. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  683. package/widgets/OrientedImageryViewer.js +1 -1
  684. package/widgets/Popup.js +1 -1
  685. package/widgets/Sketch/SketchViewModel.d.ts +10 -1
  686. package/widgets/Sketch/SketchViewModel.js +1 -1
  687. package/widgets/Sketch.js +1 -1
  688. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  689. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  690. package/assets/components/assets/icon/orientedImageryFullSuperimpose16.json +0 -1
  691. package/assets/components/assets/icon/orientedImageryFullSuperimpose24.json +0 -1
  692. package/assets/components/assets/icon/orientedImageryFullSuperimpose32.json +0 -1
  693. package/assets/components/assets/icon/orientedImageryHalfSuperimpose16.json +0 -1
  694. package/assets/components/assets/icon/orientedImageryHalfSuperimpose24.json +0 -1
  695. package/assets/components/assets/icon/orientedImageryHalfSuperimpose32.json +0 -1
  696. package/assets/components/assets/icon/orientedImagerySceneOnly16.json +0 -1
  697. package/assets/components/assets/icon/orientedImagerySceneOnly24.json +0 -1
  698. package/assets/components/assets/icon/orientedImagerySceneOnly32.json +0 -1
  699. package/assets/components/assets/icon/parquetFeatureLayer16.json +0 -1
  700. package/assets/components/assets/icon/parquetFeatureLayer24.json +0 -1
  701. package/assets/components/assets/icon/parquetFeatureLayer32.json +0 -1
  702. package/assets/esri/core/workers/chunks/013708f40f811158d42c.js +0 -1
  703. package/assets/esri/core/workers/chunks/03354e9256b2f77fd4f2.js +0 -1
  704. package/assets/esri/core/workers/chunks/0436fe89adc78696251c.js +0 -1
  705. package/assets/esri/core/workers/chunks/079b412d07d02504f1db.js +0 -1
  706. package/assets/esri/core/workers/chunks/0826d36dfbfa28442b70.js +0 -1
  707. package/assets/esri/core/workers/chunks/0ded58ccb83f624f1460.js +0 -1
  708. package/assets/esri/core/workers/chunks/0ecc1bc1686844cdd60e.js +0 -1
  709. package/assets/esri/core/workers/chunks/152f1c08197955224ad3.js +0 -1
  710. package/assets/esri/core/workers/chunks/174cc2e69e5b5a13d880.js +0 -1
  711. package/assets/esri/core/workers/chunks/181e948d076a9a7aae8a.js +0 -1
  712. package/assets/esri/core/workers/chunks/18e7784f13a57a75585a.js +0 -1
  713. package/assets/esri/core/workers/chunks/1c8436b27a3d3cde5cfc.js +0 -1
  714. package/assets/esri/core/workers/chunks/1d81e667a580c5cdeda1.js +0 -262
  715. package/assets/esri/core/workers/chunks/1dacc0b64bd27ce2de3a.js +0 -1
  716. package/assets/esri/core/workers/chunks/1eeb1edca0ad5db6917c.js +0 -1
  717. package/assets/esri/core/workers/chunks/1f289aa69dd6b6be534a.js +0 -1
  718. package/assets/esri/core/workers/chunks/27c6def22c2b0791ce9e.js +0 -1
  719. package/assets/esri/core/workers/chunks/2bc4aff77c830061e16e.js +0 -1
  720. package/assets/esri/core/workers/chunks/2c3fc2805f6de0963789.js +0 -1
  721. package/assets/esri/core/workers/chunks/2d2895f1fdf44d212a4d.js +0 -1
  722. package/assets/esri/core/workers/chunks/2e6382d50bf012064eae.js +0 -1
  723. package/assets/esri/core/workers/chunks/3248001d9dfb9153699e.js +0 -1
  724. package/assets/esri/core/workers/chunks/33b4f5dfe1a16b59b010.js +0 -1
  725. package/assets/esri/core/workers/chunks/36dac6ab51d9dbdd091d.js +0 -1
  726. package/assets/esri/core/workers/chunks/36dd3ad3ef2fbfc15cbd.js +0 -1
  727. package/assets/esri/core/workers/chunks/39974d1e5d3820ef1680.js +0 -1
  728. package/assets/esri/core/workers/chunks/42e5e00610f281ca8ffa.js +0 -1
  729. package/assets/esri/core/workers/chunks/4301cb9670fa7c907460.js +0 -1
  730. package/assets/esri/core/workers/chunks/493a0981e90a5799fb5b.js +0 -1
  731. package/assets/esri/core/workers/chunks/4c54cb80c4dc9bbbd395.js +0 -1
  732. package/assets/esri/core/workers/chunks/4cc78493805671708a9b.js +0 -1
  733. package/assets/esri/core/workers/chunks/4e788fc6cb2ea936f676.js +0 -1
  734. package/assets/esri/core/workers/chunks/4efef5fa8bf23aaf34cd.js +0 -1
  735. package/assets/esri/core/workers/chunks/5100b5a6a506c704dfaf.js +0 -1
  736. package/assets/esri/core/workers/chunks/5121768c70f1e03b685c.js +0 -1
  737. package/assets/esri/core/workers/chunks/52afd43bbe23e358efb5.js +0 -1
  738. package/assets/esri/core/workers/chunks/52f354bf80ee5ab0379a.js +0 -1
  739. package/assets/esri/core/workers/chunks/5359ff9492383c5bd9b1.js +0 -1
  740. package/assets/esri/core/workers/chunks/54d7f07e3348ddb6d9a2.js +0 -1
  741. package/assets/esri/core/workers/chunks/57b7e5fde972d3ad7884.js +0 -1
  742. package/assets/esri/core/workers/chunks/597aa39cdb5366ef9a74.js +0 -1
  743. package/assets/esri/core/workers/chunks/5aba23584e0b230c75f5.js +0 -1
  744. package/assets/esri/core/workers/chunks/5cb274e5759f7ca0d4ed.js +0 -1
  745. package/assets/esri/core/workers/chunks/5d8924fdcdb473d261cd.js +0 -1
  746. package/assets/esri/core/workers/chunks/62de9e83331fb10aac6a.js +0 -2
  747. package/assets/esri/core/workers/chunks/62e77e3c5ca9b4887923.js +0 -2
  748. package/assets/esri/core/workers/chunks/64114a7d2da162987958.js +0 -1
  749. package/assets/esri/core/workers/chunks/641cddee377599916de2.js +0 -2
  750. package/assets/esri/core/workers/chunks/65520a443e3811255bea.js +0 -1
  751. package/assets/esri/core/workers/chunks/65f02eca694cc1c9f5a7.js +0 -1
  752. package/assets/esri/core/workers/chunks/6821462e5c1e9c76010a.js +0 -1
  753. package/assets/esri/core/workers/chunks/6a3d207308b29651f397.js +0 -1
  754. package/assets/esri/core/workers/chunks/6f5d61f734ec40dafabb.js +0 -1
  755. package/assets/esri/core/workers/chunks/737de87bfb9b5f5a9c6c.js +0 -1
  756. package/assets/esri/core/workers/chunks/7748743d4be047094d67.js +0 -1
  757. package/assets/esri/core/workers/chunks/78c53aeb0a408ab3c80c.js +0 -1
  758. package/assets/esri/core/workers/chunks/79f2d4b3af5776ec2045.js +0 -1
  759. package/assets/esri/core/workers/chunks/7a8ed08cd173963b3112.js +0 -1
  760. package/assets/esri/core/workers/chunks/7b5c1030a7cf0f382cc4.js +0 -1
  761. package/assets/esri/core/workers/chunks/7cadb872b9ca96eedca5.js +0 -1
  762. package/assets/esri/core/workers/chunks/7cee81c5aa1e6b7d2452.js +0 -1
  763. package/assets/esri/core/workers/chunks/7ed3d6c72f23c628df3b.js +0 -1
  764. package/assets/esri/core/workers/chunks/80f4f686ce403cb2693f.js +0 -1
  765. package/assets/esri/core/workers/chunks/8351012ceb466f01b8fd.js +0 -1
  766. package/assets/esri/core/workers/chunks/859bc873e7af911a518f.js +0 -1
  767. package/assets/esri/core/workers/chunks/8e99f937fd36cf2cd05f.js +0 -1
  768. package/assets/esri/core/workers/chunks/93bd56396b8cd020f965.js +0 -1
  769. package/assets/esri/core/workers/chunks/94fac056e14caed09682.js +0 -1
  770. package/assets/esri/core/workers/chunks/957f7b8de4aecb6f644e.js +0 -1
  771. package/assets/esri/core/workers/chunks/97d2bdbea39cbcf8fd0f.js +0 -1
  772. package/assets/esri/core/workers/chunks/99101789035f1787c630.js +0 -1
  773. package/assets/esri/core/workers/chunks/9c6d34bb666f630d511f.js +0 -1
  774. package/assets/esri/core/workers/chunks/a0208e35b217808777c4.js +0 -1
  775. package/assets/esri/core/workers/chunks/a320998f18922a35899f.js +0 -1
  776. package/assets/esri/core/workers/chunks/a4e9a17dacbb52444d75.js +0 -1
  777. package/assets/esri/core/workers/chunks/a5abba59e738c3240c22.js +0 -1
  778. package/assets/esri/core/workers/chunks/a63bba226de6c5e464b0.js +0 -1
  779. package/assets/esri/core/workers/chunks/a9f29ff36a7ae5bae686.js +0 -1
  780. package/assets/esri/core/workers/chunks/aae0049c2c3e15a813e8.js +0 -1
  781. package/assets/esri/core/workers/chunks/adc32f6b45ea3026fc34.js +0 -1
  782. package/assets/esri/core/workers/chunks/af8ef6701631ed5e5b80.js +0 -1
  783. package/assets/esri/core/workers/chunks/b666027b9022fa346a79.js +0 -1
  784. package/assets/esri/core/workers/chunks/b73c146d3e550eaf07eb.js +0 -1
  785. package/assets/esri/core/workers/chunks/b803e7b0d489bb628d72.js +0 -1
  786. package/assets/esri/core/workers/chunks/bb24972603fb35dd8dcf.js +0 -1
  787. package/assets/esri/core/workers/chunks/bcc097271f5cdf0a97a7.js +0 -1
  788. package/assets/esri/core/workers/chunks/c0cbc50e5afd68bd485c.js +0 -1
  789. package/assets/esri/core/workers/chunks/c3ff2ff0a86a9143d7a5.js +0 -1
  790. package/assets/esri/core/workers/chunks/c6d0b4875b6b8d6bc25a.js +0 -1
  791. package/assets/esri/core/workers/chunks/c9a4601073e1a3eee9d0.js +0 -1
  792. package/assets/esri/core/workers/chunks/cf8ce21dc649021e97f6.js +0 -1
  793. package/assets/esri/core/workers/chunks/d78b7cac322755e87eb8.js +0 -1
  794. package/assets/esri/core/workers/chunks/dddb57ff637643ccfc87.js +0 -1
  795. package/assets/esri/core/workers/chunks/df18b0a653b328d8d052.js +0 -1
  796. package/assets/esri/core/workers/chunks/e1bf87077541da6853c6.js +0 -1
  797. package/assets/esri/core/workers/chunks/e3b713a590cce6245ee2.js +0 -1
  798. package/assets/esri/core/workers/chunks/e4406baf206b9e4c7e4f.js +0 -1
  799. package/assets/esri/core/workers/chunks/e499252cb52f7aed49a0.js +0 -1
  800. package/assets/esri/core/workers/chunks/e4e2f479c0c45ae1b2c3.js +0 -1
  801. package/assets/esri/core/workers/chunks/e656fd5ecf9ac059a87b.js +0 -1
  802. package/assets/esri/core/workers/chunks/e92698f50089484c4901.js +0 -1
  803. package/assets/esri/core/workers/chunks/e9c5c295b6bf10e942a4.js +0 -1
  804. package/assets/esri/core/workers/chunks/eb91dc957c328674e119.js +0 -1
  805. package/assets/esri/core/workers/chunks/ed3d16a5b4084ef61f8a.js +0 -1
  806. package/assets/esri/core/workers/chunks/edcde00495727d506c46.js +0 -1
  807. package/assets/esri/core/workers/chunks/efb4aa5886730ea377bd.js +0 -1
  808. package/assets/esri/core/workers/chunks/f0832b413612c77a62ca.js +0 -1
  809. package/assets/esri/core/workers/chunks/f116331c6eca937aac8e.js +0 -1
  810. package/assets/esri/core/workers/chunks/f334bf192dff5af10a70.js +0 -1
  811. package/assets/esri/core/workers/chunks/f518835b2dc89a48cfb1.js +0 -1
  812. package/assets/esri/core/workers/chunks/f5731ad4cfbbf1cc569a.js +0 -2
  813. package/assets/esri/core/workers/chunks/f76b1fc36f5606cac2c8.js +0 -1
  814. package/assets/esri/core/workers/chunks/f7fca88d120d45bb782a.js +0 -1
  815. package/assets/esri/core/workers/chunks/f819854098d63fe4ccdb.js +0 -1
  816. package/assets/esri/core/workers/chunks/f98118127469449ca145.js +0 -1
  817. package/assets/esri/core/workers/chunks/f9e22cf59e2e2782d70f.js +0 -1
  818. package/assets/esri/core/workers/chunks/fbe7dae0b4bf2d172487.js +0 -1
  819. package/assets/esri/core/workers/chunks/fea3b6bef761ef78630e.js +0 -1
  820. package/chunks/Bufferer-Dw9Qi4T1.js +0 -2
  821. package/chunks/Distance2DCalculator-CXhBP-8I.js +0 -2
  822. package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +0 -2
  823. package/layers/support/AnnotationSublayer.js +0 -2
  824. package/views/3d/analysis/LineOfSight/LineOfSightPlacementTool.js +0 -2
  825. /package/assets/esri/core/workers/chunks/{d9d4754062758789f186.js.LICENSE.txt → 05016e5a1de384994001.js.LICENSE.txt} +0 -0
  826. /package/assets/esri/core/workers/chunks/{62e77e3c5ca9b4887923.js.LICENSE.txt → 0d42322362e76f674d94.js.LICENSE.txt} +0 -0
  827. /package/assets/esri/core/workers/chunks/{62de9e83331fb10aac6a.js.LICENSE.txt → 35533c8ef541f7643497.js.LICENSE.txt} +0 -0
  828. /package/assets/esri/core/workers/chunks/{641cddee377599916de2.js.LICENSE.txt → 99c002015c2127e6cbfc.js.LICENSE.txt} +0 -0
  829. /package/assets/esri/core/workers/chunks/{f5731ad4cfbbf1cc569a.js.LICENSE.txt → c318e6dbb8651433038f.js.LICENSE.txt} +0 -0
  830. /package/chunks/{Centroid-DZi-eb9F.js → Centroid-CA-TwbbN.js} +0 -0
@@ -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{Envelope2D as s}from"./Envelope2D.js";import{a as n,c as r,G as i,h as o,d as a,j as h,y as m,g as l,f as g,z as u,v as c,A as _,t as d,q as p,e as f,i as x,p as y,B as P,C as E,w as S,m as C,D as I,r as b}from"./Geometry.js";import{a as w,I as v,J as N,P as T,M as G,K as D,E as V,c as F,g as H,S as k,L as A,N as M,O as U,n as q,Q as B,R as O,y as Y,T as R,D as X,l as L,U as z,V as W,W as j,X as Z,Y as K,Z as Q,_ as J,$,a0 as ee,a1 as te,a2 as se,a3 as ne,a4 as re,a5 as ie,a6 as oe,a7 as ae,a8 as he,a9 as me,b as le}from"./MultiPathImpl.js";import{e as ge,d as ue,N as ce,Q as _e,i as de,g as pe,c as fe,E as xe,P as ye,C as Pe,f as Ee,R as Se,T as Ce,U as Ie,a as be,B as we,W as ve,b as Ne,X as Te,V as Ge,Y as De,p as Ve,Z as Fe,H as He,_ as ke,$ as Ae,a0 as Me,a1 as Ue,a2 as qe,j as Be,a3 as Oe,k as Ye,a4 as Re,a5 as Xe,S as Le,A as ze,a6 as We,a7 as je,h as Ze}from"./Envelope.js";import{at as Ke,au as Qe,o as Je,d as $e,P as et,av as tt,v as st,aw as nt,Q as rt,ax as it,n as ot,E as at,c as ht,e as mt,O as lt,m as gt,S as ut,r as ct,f as _t,K as dt,a as pt,t as ft,ay as xt,k as yt,s as Pt,az as Et,g as St,U as Ct,aA as It,B as bt,aB as wt,j as vt,b as Nt,i as Tt,h as Gt,p as Dt,a7 as Vt,aC as Ft,aD as Ht,aE as kt,H as At,M as Mt,J as Ut,aF as qt,aG as Bt,aH as Ot,aI as Yt,aJ as Rt,aq as Xt,y as Lt,aK as zt,l as Wt}from"./Point2D.js";import{T as jt}from"./Transformation2D.js";import{c as Zt,O as Kt,a as Qt}from"./OperatorClip.js";import{O as Jt}from"./OperatorDensify.js";import{G as $t}from"./GeometryCursor.js";import{S as es}from"./SimpleGeometryCursor.js";import{NonSimpleResult as ts}from"./OperatorDefinitions.js";class ss{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move)return this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,void(e.move.m_sr=null);if(e.copy)return this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,void(this.m_sr=e.copy.m_sr);e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){const s=e;return!(!this.m_sr&&s.m_sr)&&(!(this.m_sr&&!s.m_sr)&&(!(!this.m_geom&&s.m_geom)&&(!(this.m_geom&&!s.m_geom)&&(!(this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr))&&!(this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,t))))))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new ss({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class ns{constructor(e){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():""}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&n("unit type mismatch"),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return Ke(Qe(this.getUnitType()),Qe(this.getUnitToBaseFactor()))}equals(e){return!!e&&(this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName())}static isValidWkid(e){return!1}}const rs={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104220,104221,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,10635,10636,10735,10736,10758,37e3,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,6377397.155:[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,10898,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],6377563.396:[4001,4188,4277,4278,4279],6377340.189:[4002,4299,4300],6377492.018:[4005,4273,4817],6377483.865280418:[4006,4293],6378293.645208759:[4007,4157,4302,4738,5464],6378206.4:[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],6378450.047:[4009,4268],6378300.789:[4010,4281],6378249.2:[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],6378249.145:[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104032,104103,104305],6377276.345:[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],6377298.556:[4016,4298],6377304.063:[4018,4245],6378298.3:[4028,4903],6378136.2:4032,6378136.3:4033,6378249.144808011:[4034,4241],20922931.8:[4042,4243],6377301.243:[4044,4145,37203],6377299.151:[4045,4146],6377019.27:[4657,10256,10260,10265],6378306.3696:[4748,4752],6377295.664:[4751,37006],6378136.5:[7682,7683],6371008.7714:104047,6378418.941:[104700,104726,104760],6378586.581:[104701,104743],6378505.809:104702,6378544.823:104703,6378490.569:104704,6378470.757:[104705,104776],6378403.701:[104706,104750],6378434.181:[104707,104724,104739,104764],6378454.907:104708,6378400.653:104709,6378567.378:104710,6378546.957:[104711,104717,104780],6378476.853:[104712,104736],6378411.321:[104713,104728],6378647.541:[104714,104715],6378514.953:[104716,104782],6378421.989:[104718,104770],6378481.425:[104719,104753,104774,104781],6378518.001:[104720,104725],6378521.049:[104721,104723,104731,104745,104748],6378464.661:104722,6378436.619:104727,6378574.389:[104729,104730],6378472.281:[104732,104756],6378498.189:[104733,104746],6378449.421:[104734,104766],6378525.621:[104735,104754],6378466.185:104737,6378496.665:104738,6378643.579:104740,6378559.758:104741,6378414.369:[104742,104763,104772],6378441.801:104744,6378502.761:[104747,104759,104773,104775],6378617.061:104749,6378624.681:[104751,104765],6378468.623:104752,6378445.763:[104755,104758,104761],6378670.401:104757,6378438.753:104762,6378543.909:104767,6378605.783:104768,6378540.861:104769,6378443.325:[104771,104784],6378548.481:104777,6378463.746:104778,6378426.561:104779,6378453.688:104783,6378530.193:104785,6378376.271:[104800,104828],6378471.92:104801,6378472.931:104802,6378411.351:104803,6378380.991:104805,6378414.96:104806,6378345.09:[104807,104819,104844,104870],6378412.542:104808,6378470.401:104809,6378376.331:104810,6378379.031:104811,6378407.621:104812,6378376.811:[104813,104827],6378313.92:104814,6378414.93:104815,6378413.021:104816,6378380.381:104817,6378530.851:104818,6378591.521:104820,6378378.881:104821,6378408.481:[104822,104832],6378375.601:[104823,104838],6378408.041:104824,6378655.071:104825,6378409.151:104826,6378315.7:[104829,104840,104845,104851],6378285.86:[104830,104835,104859],6378379.301:104831,6378560.121:104833,6378531.821:104834,6378500.6:104836,6378376.041:104837,6378406.601:104839,6378438.991:104841,6378345.42:104842,6378593.86:104843,6378381.271:[104846,104847],6378413.671:104848,6378344.377:104849,6378563.891:104850,6378408.091:104852,6378377.671:104853,6378472.751:104854,6378412.511:104855,6378407.281:104856,6378534.451:104857,6378406.051:104858,6378532.921:104860,6378380.091:104861,6378408.941:104862,6378624.171:104863,6378377.411:104864,6378474.591:104865,6378407.141:104866,6378376.871:104867,6378375.251:104868,6378405.971:104869,6378437.651:104871};function is(){for(const e in rs)delete rs[e]}class os extends ns{constructor(e){if("number"==typeof e)return super(),this.m_factor=e,void(this.m_wkid=0);super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function as(e){return new bu}function hs(e){return e.getType()===bc.PE_TYPE_LINUNIT?new bu(e):e.getType()===bc.PE_TYPE_ANGUNIT?new os(e):void n("peUnit")}function ms(e){const t=Hc(null);return e.getType()===bc.PE_TYPE_PROJCS||e.getType()===bc.PE_TYPE_GEOGCS?t.reset(e.getUnit()):n("PE_coord_sys"),t.get()||a("cannot create units from coord sys"),hs(t.get())}class ls{constructor(e,t,s){void 0===e?(this.x=new At,this.y=new At,this.z=new At):e instanceof Ye?(this.x=new At(e.x),this.y=new At(e.y),this.z=new At(e.z)):e instanceof At?(this.x=e.clone(),this.y=t.clone(),this.z=s.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 ls(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){const t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),s=e.x.mulE(this.z).subE(this.x.mulE(e.z)),n=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new ls(t,s,n)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(e,t){return e.sub(t).length()}negate(){return new ls(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new ls(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new ls(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 ls(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new ls(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 Ye.construct(this.x.value(),this.y.value(),this.z.value())}}class gs{constructor(e){if(this.m_origin=new Ye,this.m_normal=new Ye,this.m_axisX=new Ye,this.m_axisY=new Ye,!e)return this.m_origin=new Ye,this.m_normal=new Ye(0,0,1),this.m_axisX=new Ye(1,0,0),void(this.m_axisY=new Ye(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):l(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return l(0),this}set(e,t,s,n){l(0)}setFromPoints(e,t,s){let n=t.sub(e);const r=s.sub(e);this.m_normal=n.crossProductVector(r);let i=!0;if(this.m_normal.isZero()){if(i=!1,n.isZero()&&(n=r),n.isZero()){const t=0,s=1;return this.m_normal.setCoords(t,t,s),this.m_axisX.setCoords(s,t,t),this.m_axisY.setCoords(t,s,t),this.m_origin=e,!1}this.m_axisX=n.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}else this.m_normal.normalizeThis(),this.m_axisX=n.getUnitVector();return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,i}getCoord(e,t){return 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){const t=e.sub(this.m_origin),s=new et;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return l(0),{}}signedDistance(e){return l(0),0}distance(e){return l(0),0}}function us(e,t){return!1}function cs(e,t,s,n,r=100,i=us){let o,a,h,m,g,u,c,_,d;l(n>0);let p,f,x,y=0,P=0;const E=Xt();t>s&&(s=ht(t,t=s));const S=e(t),C=e(s);S<C?(o=a=h=t,m=g=u=S):(o=a=h=s,m=g=u=C);let I=0;for(;I<r&&(x=.5*(s-t),d=t+x,p=n*(Math.abs(o)+.25),f=2*p,!(i(o,m)||Math.abs(o-d)<=f-x));++I){if(Math.abs(P)>p){const e=(o-a)*(m-u);let n=(o-h)*(m-g),r=(o-h)*n-(o-a)*e;n=2*(n-e),n>0&&(r=-r),n=Math.abs(n);const i=P;P=y,Math.abs(r)>=Math.abs(n*i*.5)||r<=n*(t-o)||r>=n*(s-o)?(P=o>=d?t-o:s-o,y=Xt()*P):(y=r/n,_=o+y,(_-t<f||s-_<f)&&(y=d-o<0?-Math.abs(p):Math.abs(p)))}else P=o>=d?t-o:s-o,y=P*E;_=o+y,c=e(_),c<m?(_>=o?t=o:s=o,h=a,a=o,o=_,u=g,g=m,m=c):(_<o?t=_:s=_,c<=g||a===o?(h=a,a=_,u=g,g=c):(c<=u||h===o||h===a)&&(h=_,u=c))}return ot(o,m)}function _s(e,t,s){if(e>s){e-=Math.ceil((e-s)/Wt)*Wt}else if(e<t){e+=Math.ceil((t-e)/Wt)*Wt}return e}function ds(e,t,s){return ps(e,t,s,0)}function ps(e,t,s,n){const r=s.x,i=s.y;return xs(e,t,Math.cos(r),Math.sin(r),Math.cos(i),Math.sin(i),n)}function fs(e,t,s,n,r,i){return xs(e,t,s,n,r,i,0)}function xs(e,t,s,n,r,i,o){const a=e/Math.sqrt(1-t*i*i),h=a+o,m=h*r*s,l=h*r*n,g=(a*(1-t)+o)*i;return Ye.construct(m,l,g)}function ys(e,t,s){const n=new At,r=new At,i=new At,o=new At;n.setCos(s.x),r.setSin(s.x),i.setCos(s.y),o.setSin(s.y);const a=o.negate().mulE(o.mul(t)).add(1).sqrt(),h=new At(e).divE(a),m=h.mulE(i).mulE(n),l=h.mulE(i).mulE(r),g=h.mul(1-t).mulE(o);return new ls(m,l,g)}function Ps(e,t,s){const n=s.x,r=s.y,i=s.z,o=Math.atan2(r,n),a=Math.sqrt(n*n+r*r),h=Math.atan2(i,(1-t)*a);return et.construct(o,h)}function Es(e,t,s){const n=1-t,r=e/Math.sqrt(pt(s.x)+pt(s.y)+pt(s.z)/n);return s.mul(r)}function Ss(e,t,s,n,r){const i=ds(e,t,s),o=ds(e,t,n);return Ps(e,t,Ye.lerp(i,o,r))}function Cs(e,t,s){const n=new Ye;return n.setCrossProductVector(t,s),Math.abs(Math.atan2(n.length(),t.dotProduct(s)))*e}function Is(e,t,s,n,r){const i=s.getUnitVector(),o=n.getUnitVector(),a=t.getUnitVector(),h=new Ye;if(h.setCrossProductVector(i,o),!h.isZero()){h.normalizeThis();const t=a.sub(h.mul(h.dotProduct(a)));if(!t.isZero()){t.normalizeThis();const s=i.add(o).mul(.5);if(s.dotProduct(t)>s.dotProduct(i)){const s=Math.abs(h.dotProduct(a)),n=Math.asin(s);return r.assign(t.getUnitVector().mul(e)),n*e}}}const m=Cs(1,i,a),l=Cs(1,o,a);return m<=l?(r.assign(s),m*e):(r.assign(n),l*e)}function bs(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,t,null,null,bc.PE_LINETYPE_GEODESIC),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function ws(e,t,s,n,r){switch(l(s.isFinite()&&n.isFinite()),r){case 0:return bs(e,t,s,n);case 1:return Ts(e,t,s);case 2:case 3:{const r=ds(e,t,s),i=ds(e,t,n);return Ye.distance(r,i)}default:d("")}}function vs(e,t,s,n,r,i=0,o){if(2===i||3===i)return Ns(e,t,s,n,r,3===i,o);const a=Ps(e,t,s),h=s=>{const o=Ps(e,t,Ye.lerp(n,r,s));return ws(e,t,a,o,i)},m=Ye.distance(n,r);if(m>0){const s=Os(e,m),{first:i,second:a}=cs(h,0,1,s);return o&&o.assign(Es(e,t,Ye.lerp(n,r,i))),ot(i,a)}{const e=h(0);return o&&o.assign(n),ot(.5,e)}}function Ns(e,t,s,n,r,i=!1,o){const a=Es(e,t,s);if(i){const i=new gs({pt0:new Ye(0,0,0),pt1:n,pt2:r}),h=i.closestCoordinate(s),m=i.closestCoordinate(n),l=i.closestCoordinate(r),g=et.getClosestCoordinate(m,l,h),u=Es(e,t,Ye.lerp(n,r,g)),c=Ye.distance(u,a);return o&&o.assign(u),ot(g,c)}const h=s=>{const i=Es(e,t,Ye.lerp(n,r,s));return Ye.distance(i,a)},m=Ye.distance(n,r);if(m>0){const s=Os(e,m),{first:i,second:a}=cs(h,0,1,s);return o&&o.assign(Es(e,t,Ye.lerp(n,r,i))),ot(i,a)}{const e=Ye.distance(s,n);return o&&o.assign(s),ot(.5,e)}}function Ts(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.greatEllipticDistance(s,n,r.x,r.y,r.x,r.y,t,null,null),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function Gs(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>yt||Math.abs(n.y)>yt)return Number.NaN;if((Math.abs(s.y)===yt||Math.abs(n.y)===yt)&&s.x!==n.x)return Number.NaN;const{first:i,second:o}=kt(s.x,n.x);let a=r;a=_s(a,i,o);if(!at.construct(s.x,n.x).containsCoordinate(a))return Number.NaN;const h=J.constructPoint2D(s),m=J.constructPoint2D(n),l=ys(1,t,h),g=ys(1,t,m),u=l.crossProductVector(g);if(u.z.isZero()){return s.y}const c=u.x.divE(u.z.negate()),_=u.y.divE(u.z.negate()),d=c.mulE(c).addE(_.mulE(_)).sqrt();if(d.isZero()||c.isZero()&&_.isZero()){return s.y}const p=Math.atan2(_.value(),c.value());let f=Math.atan2(d.value()*Math.cos(p-a),1-t);const x=ds(1,t,et.construct(a,f)),y=Ye.construct(x.x,x.y,-x.z),P=u.value().dotProduct(x),E=u.value().dotProduct(y);return Math.abs(E)<Math.abs(P)&&(f=-f),f}function Ds(e,t,s,n,r,i){if(i[0]=Number.NaN,i[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>yt||Math.abs(n.y)>yt)return 0;if((Math.abs(s.y)===yt||Math.abs(n.y)===yt)&&s.x!==n.x)return 0;if(Math.abs(r)>=yt)return 0;if(s.y>0&&n.y>0&&s.y>r&&n.y>r||s.y<0&&n.y<0&&s.y<r&&n.y<r)return 0;const o=J.constructPoint2D(s),a=J.constructPoint2D(n),h=ys(1,t,o),m=ys(1,t,a),l=h.crossProductVector(m);if(l.z.isZero()){return at.construct(s.y,n.y).containsCoordinate(r)?(i[0]=s.x,1):0}const g=l.x.divE(l.z.negate()),u=l.y.divE(l.z.negate()),c=g.mulE(g).addE(u.mulE(u)).sqrt();if(c.isZero()||g.isZero()&&u.isZero())return 0===r?(i[0]=s.x,i[1]=n.x,2):0;const _=(1-t)*Math.tan(r)/c.value();if(Math.abs(_)>1)return 0;const d=Math.acos(_),p=Math.atan2(u.value(),g.value()),f=p-d;let x=p+d;const y=Math.min(s.x,n.x),P=Math.max(s.x,n.x);_s(f,y,P),0!==r?_s(x,y,P):x=f;let E=0;return y<=f&&f<=P&&(i[E]=f,E++),x!==f&&y<=x&&x<=P&&(i[E]=x,E++),E}function Vs(e,t){t[0]>.5*Math.PI?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<.5*-Math.PI&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),l(t[0]>=.5*-Math.PI&&t[0]<=.5*Math.PI)}function Fs(e,t){return e*Math.sqrt(1-t)}function Hs(e){return 1-e}function ks(e,t,s,n,r){n=Pt(n,-yt,yt),r=Pt(r,-yt,yt);const i=yt-.03;let o;o=n>i&&r>i||n<-i&&r<-i?As(e,n,r):Ms(e,r)-Ms(e,n);return.5*(s-t)*o*Hs(e)}function As(e,t,s){let n=1;if(t<0&&(n=-1,t=-t,s=-s),0!==e){const r=e*e,i=r*e,o=[1,(1+11*e)/12,(1+118*e+241*r)/360,(1+1089*e+10419*r+8651*i)/20160,(1+9836*e+318246*r+1027436*i+458881*(i*e))/1814400],a=t=>{let s=0;const n=pt(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-pt(t/(1-e)),s},h=a(yt-t);return(a(yt-s)-h)*n}{const e=yt-t,r=yt-s,i=-4*pt(Math.sin(e/2));return(-4*pt(Math.sin(r/2))-i)*n}}function Ms(e,t){if(0===t)return 0;const s=Math.sin(t);let n=s,r=s;if(0!==e){n/=1-e*s*s;const t=Math.sqrt(e);r=s*Lt(t*s)}return n+r}function Us(e,t){return e/Math.sqrt(1-t)}function qs(e,t){return(1-t)*e}function Bs(e,t,s){const n=s/(2*qs(e,t)),r=n*n;return s*(1-r*(.16666666666666666-.008333333333333333*r))}function Os(e,t){if(0!==t){const s=e*Rt()/t;return Math.min(s,1e-10)}return 0}class Ys{constructor(e){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return Ys.npos();this.m_currentShift=0n,this.m_currentElt=this.m_parent.m_bits[this.m_aiSetElts[this.m_iCurrentElt]]}for(;this.m_currentShift<63n&&!(this.m_currentElt&1n<<this.m_currentShift);)this.m_currentShift++;return this.m_currentElt&1n<<this.m_currentShift?64*this.m_aiSetElts[this.m_iCurrentElt]+Number(this.m_currentShift):this.next()}static npos(){return Number.MAX_SAFE_INTEGER}}function Rs(e){return 1n<<(0x3fn&BigInt(e))}function Xs(e){return e>>6}class Ls{constructor(e){this.m_bits=[],void 0!==e&&e.copy&&(this.m_bits=e.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(e){const t=Rs(e),s=Xs(e);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&t)}setBit(e){const t=Rs(e),s=Xs(e);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=t}clearBit(e){}flipBit(e){const t=Rs(e),s=Xs(e);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=t,0n!==(this.m_bits[s]&t)}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(2&e)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((s,n)=>{t|=s===e.m_bits[n]?2:1}),!(1&t)&&(e.m_bits.forEach((e,s)=>{t|=e===this.m_bits[s]?2:1}),!(1&t))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>Et(e,t),Qe(0))}getUnorderedBitIterator(){return new Ys(this)}}class zs{constructor(e,t){this.m_map=new Map,this.m_hf=e,this.m_ef=t}add(e){const t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;const s=this.m_map.get(t);return s instanceof Array?s.find(t=>this.m_ef(t,e))||s.push(e):this.m_ef(s,e)||this.m_map.set(t,[s,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){const t=this.m_hf(e);if(!this.m_map.has(t))return!1;const s=this.m_map.get(t);return s instanceof Array?void 0!==s.find(t=>this.m_ef(t,e)):this.m_ef(s,e)}get(e){const t=this.m_hf(e),s=this.m_map.get(t);if(void 0!==s)return s instanceof Array?s.find(t=>this.m_ef(t,e)):s}get size(){let e=0;for(const t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[Symbol.iterator](){return(new Set)[Symbol.iterator]()}entries(){return(new Set).entries()}keys(){return(new Set).keys()}values(){return(new Set).values()}get[Symbol.toStringTag](){return"ValueSet"}}class Ws extends We{constructor(e){super(),this.m_bufferLeft=new k,this.m_bufferRight=new k,this.m_intervalLeft=at.constructEmpty(),this.m_intervalRight=at.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=e}compare(e,t,s){const n=t,r=e.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(r,this.m_bufferRight);const i=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(i.getStartX(),i.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=i.getStartY()===i.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(i.getStartY()===o.getStartY()&&i.getStartX()===o.getStartX())return a?1:-1;if(i.getEndY()===o.getEndY()&&i.getEndX()===o.getEndX())return a?-1:1}let m=i.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const e=i.getEndY(),t=o.getEndY(),s=Math.min(e,t);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),m=i.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(e){this.m_yScanline=e}}class js{constructor(e){this.m_segmentBuffer=new k,this.m_point=et.getNAN(),this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){const s=e.getElement(t);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),r=new at;if(r.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<r.vmin)return-1;if(this.m_point.x>r.vmax)return 1;const i=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<i?-1:this.m_point.x>i?1:0}}var Zs,Ks;function Qs(e,t){return{parentage:e,rank:t}}function Js(e,t){const s=e.length;if(s!==t.length)return!1;const n=e[0].parentage;if(n!==t[0].parentage)return!1;if(-1===n)return!0;for(let r=1;r<s;++r)if(e[r].parentage!==t[r].parentage)return!1;return!0}function $s(e,t,s){s.length=0;let n=!1;{let r=e.getHalfEdgeVertexIterator(t);for(;r!==q;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}{let r=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;r!==q;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}n&&s.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:e.parentage>t.parentage?1:0),-1===s[0].parentage&&(s.length=1)}function en(){return new zs(e=>e.getHashCode(),(e,t)=>e.equals(t))}!function(e){e[e.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",e[e.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",e[e.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding"}(Zs||(Zs={})),function(e){e[e.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",e[e.enumPathBreakNode=2]="enumPathBreakNode"}(Ks||(Ks={}));class tn{constructor(){this.m_shape=null,this.m_clusterData=new Le(8),this.m_clusterVertices=new Le(2),this.m_firstCluster=q,this.m_lastCluster=q,this.m_halfEdgeData=new Le(8),this.m_chainData=new Le(8),this.m_chainAreas=null,this.m_chainPerimeters=null,this.m_universeChain=-1,this.m_simplifiedGeometry=-1,this.m_edgeIndices=[],this.m_clusterIndices=[],this.m_chainIndices=[],this.m_bBuildGeometryParentageSets=!1,this.m_chainBitSetIndex=-1,this.m_edgeBitSetIndex=-1,this.m_edgeBitSetIndexLeft=-1,this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_uniqueBitSets=null,this.m_chainBitSets=[],this.m_edgeBitSets=[],this.m_checkDirtyPlanesweepTolerance=Number.NaN,this.m_geometryIDIndex=-1,this.m_clusterIndex=-1,this.m_halfEdgeIndex=-1,this.m_tmpHalfEdgeParentageIndex=-1,this.m_tmpHalfEdgeParentageIndexLeft=-1,this.m_tmpHalfEdgeWindingNumberIndex=-1,this.m_tmpHalfEdgeOddEvenNumberIndex=-1,this.m_segmentParentageIndex=-1,this.m_segmentIndexHe=-1,this.m_clusterBreakNodeIndex=-1,this.m_universeGeomID=-1,this.m_pointCount=0,this.m_progressCounter=0,this.m_bBuildChains=!0,this.m_bDirtyCheckFailed=!1}setCheckDirtyPlanesweepTolerance(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,s=!0,n=!1){n?this.setEditShapeImpl3D_(e,Zs.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,Zs.enumInputModeBuildGraph,null,t,s)}setAndSimplifyEditShapeAlternate(e,t,s=null,n=!1){const r=[];r.push(t),this.m_simplifiedGeometry=t,n?this.setEditShapeImpl3D_(e,Zs.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyAlternate,r,s,e.getGeometryType(t)===i.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,s=null){const n=[];n.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyWinding,n,s,!0)}removeShape(){null!==this.m_shape&&(-1!==this.m_geometryIDIndex&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),-1!==this.m_clusterIndex&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),-1!==this.m_halfEdgeIndex&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),-1!==this.m_segmentParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),-1!==this.m_segmentIndexHe&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),-1!==this.m_clusterBreakNodeIndex&&(this.deleteUserIndexForClusters(this.m_clusterBreakNodeIndex),this.m_clusterBreakNodeIndex=-1),this.deleteEdgeBitSets_(),this.deleteChainBitSets_(),this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_shape=null,this.m_clusterData.deleteAll(!0),this.m_clusterVertices.deleteAll(!0),this.m_firstCluster=q,this.m_lastCluster=q,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=q,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){const s=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(e,t){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){const s=this.getClusterIndex_(e),n=this.m_clusterIndices[t];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1),r.write(n,s)}hasClusterUserIndexFlags(e,t,s){if(-1===t)return!1;const n=this.getClusterUserIndex(e,t);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,s|i)}clearClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,~s&i)}createUserIndexForClusters(e=-1){const t=new be(this.m_clusterData.capacity(),e);for(let s=0,n=this.m_clusterIndices.length;s<n;s++)if(null===this.m_clusterIndices[s])return this.m_clusterIndices[s]=t,s;this.m_clusterIndices.push(t);return 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){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}getHalfEdgeFromXYZ(e,t){l(0)}getHalfEdgeToXYZ(e,t){l(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&tn.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){const s=this.getHalfEdgeIndex_(e),n=this.m_edgeIndices[t];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(e,t,s){const n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];r.size()<=n&&r.resize(this.m_halfEdgeData.size(),-1),r.write(n,s)}createUserIndexForHalfEdges(e){void 0===e&&(e=-1);const t=new be(this.m_halfEdgeData.capacity(),e);for(let n=0,r=this.m_edgeIndices.length;n<r;n++)if(null===this.m_edgeIndices[n])return this.m_edgeIndices[n]=t,n;this.m_edgeIndices.push(t);const s=this.m_edgeIndices.length-1;return l(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.getHalfEdgeChain(s),r=this.getHalfEdgeTwin(s),i=this.getHalfEdgeChain(r);this.setChainHalfEdge_(n,q),this.setChainHalfEdge_(i,q),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}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){const t=this.getChainIndex_(e);let s=this.m_chainAreas.read(t);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(e),s=this.m_chainAreas.read(t)),s}getChainPerimeter(e){return l(0),0}getChainUserIndex(e,t){const s=this.getChainIndex_(e),n=this.m_chainIndices[t];return n.size()<=s?-1:n.read(s)}setChainUserIndex(e,t,s){const n=this.getChainIndex_(e),r=this.m_chainIndices[t];r.size()<=n&&r.resize(this.m_chainData.size(),-1),r.write(n,s)}createUserIndexForChains(){const e=new be(this.m_chainData.capacity(),-1);for(let t=0,s=this.m_chainIndices.length;t<s;t++)if(null===this.m_chainIndices[t])return this.m_chainIndices[t]=e,t;this.m_chainIndices.push(e);return this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,s,n){const r=t===q?e.createGeometry(i.enumPolygon):t,o=new k;this.extractPolygonPathFromChain_(e,r,s,n,o);for(let i=this.getChainFirstIsland(s);i!==q;i=this.getChainNextInParent(i))this.extractPolygonPathFromChain_(e,r,i,n,o);return r}getGeometryID(e){const 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),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);l(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){l(this.m_bBuildGeometryParentageSets);const t=new Ls,s=e=>{const s=this.getChainHalfEdge(e);let n=s;do{const e=this.getEdgeBitSet_(n);null!==e&&t.assignOr(e);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&t.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(e);for(let n=this.getChainFirstIsland(e);n!==q;n=this.getChainNextInParent(n))s(e);return t}getChainPolygons(e){return l(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||null===e)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==q;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}const t=[],s=e.getUnorderedBitIterator();for(let n=s.next();n!==Ys.npos();n=s.next())l(this.m_geometryMapID.has(n)),t.push(this.m_geometryMapID.get(n));return t}getVertexDominant(e,t){if(t===q)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==q){let s=q;for(let n=this.getClusterVertexIterator(e);n!==q;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===q&&(s=e);const r=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(r)===t){s=e;break}}return s}{const t=this.getClusterVertexIterator(e);if(t!==q){return this.getVertexFromVertexIterator(t)}return q}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}setBreakNode(e,t){l(-1!==this.m_clusterBreakNodeIndex),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}setStrongPathNode(e,t){if(-1===this.m_clusterBreakNodeIndex){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}getSegmentParentage(e){if(-1===this.m_segmentParentageIndex)return-1;const t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){const t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(s);return e!==this.getHalfEdgeTwin(n)}isCrossroadBehind(e){return l(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===q)return q;let n=s,r=q,i=q;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===q){if(r=this.getClusterHalfEdge(t),r===q)return q;i=r}if(this.getHalfEdgeTo(i)===e)return n=this.getHalfEdgeTwin(i),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(n!==s&&i!==r);return q}querySegmentXY(e,t){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const e=this.m_shape.getSegmentFromIndex(s);t.copyFrom(e,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);t.copyFrom(n,!0),t.get().reverse()}return}}t.createLine();const s=t.get(),n=et.getNAN();this.getHalfEdgeFromXY(e,n),s.setStartXY(n),this.getHalfEdgeToXY(e,n),s.setEndXY(n)}isCurveEdge(e){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}compareEdgeAnglesCurveHelper_(e,t,s){const n=new k,r=new k;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const i=n.get(),o=r.get();if(i.equals(o))return 0;const a=new et;this.getHalfEdgeFromXY(e,a);const h=new et;this.getHalfEdgeToXY(e,h);const m=new et;this.getHalfEdgeToXY(t,m),l(!h.isEqualPoint2D(m));return O(i,o)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=et.getNAN();this.getHalfEdgeToXY(e,n);const r=et.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=et.getNAN();this.getHalfEdgeFromXY(e,i);const o=et.getNAN();o.setSub(n,i);const a=et.getNAN();if(a.setSub(r,i),!s||a.y>=0&&o.y>0){return et.compareVectors(o,a)}return 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){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);l(n===t),l(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=q));const i=this.getChainIndex_(t),o=this.m_chainAreas.read(i);Number.isNaN(o)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const a=this.getChainHalfEdge(t);a!==e&&a!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==q?t:this.getClusterHalfEdge(e);if(n===q)return q;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return q;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==q;s=this.getNextCluster(s)){let n=q;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===q)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));let i=r;for(;;){const s=this.getHalfEdgeNext(i),o=this.getHalfEdgePrev(i),a=this.getHalfEdgeTwin(i);if(o===a){if(this.deleteEdgeInternal_(i),e=!0,n!==i&&n!==a||(n=q),i===r||o===r){if(r=s,i===r||o===r)break;i=s;continue}}else this.setHalfEdgeUserIndex(i,t,1);if(i=s,i===r)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){const e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){const e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);const t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){const e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return 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){const s=t?q:e;for(let n=this.getHalfEdgeVertexIterator(e);n!==q;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==q&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);const s=this.getChainFirstIsland(t);this.setChainNextInParent_(e,s),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){const s=this.getChainIndex_(e);this.m_chainAreas.write(s,t)}setChainPerimeter_(e,t){const s=this.getChainIndex_(e);this.m_chainPerimeters.write(s,t)}updateChainAreaAndPerimeter_(e){const t=this.m_shape.hasCurves(),s=new dt(0),n=new dt(0),r=this.getChainHalfEdge(e),i=et.getNAN(),o=et.getNAN(),a=et.getNAN();this.getHalfEdgeFromXY(r,i),o.setCoordsPoint2D(i);let h=r;do{this.getHalfEdgeToXY(h,a),t&&this.isCurveEdge(h)||n.pe(et.distance(o,a));this.getHalfEdgeChain(this.getHalfEdgeTwin(h))!==e&&s.pe((a.x-i.x-(o.x-i.x))*(a.y-i.y+(o.y-i.y))*.5),o.setCoordsPoint2D(a),h=this.getHalfEdgeNext(h)}while(h!==r);if(t){const t=new k;h=r;do{this.getHalfEdgeToXY(h,a);const r=this.isCurveEdge(h);r&&(this.querySegmentXY(h,t),n.pe(t.get().calculateLength2D()));if(this.getHalfEdgeChain(this.getHalfEdgeTwin(h))!==e&&r){const e=t.get().calculateArea2DHelper();s.pe(e)}h=this.getHalfEdgeNext(h)}while(h!==r)}const m=this.getChainIndex_(e);this.m_chainAreas.write(m,s.getResult()),this.m_chainPerimeters.write(m,n.getResult())}getChainTopmostEdge_(e){return l(0),0}planeSweepParentage_(e,t){const s=new Ws(this),n=new Ce;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let o=null;const a=et.getNAN();for(let h=this.getFirstCluster();h!==q;h=this.getNextCluster(h)){this.progress_(t);const m=this.getClusterHalfEdge(h);if(m!==q){if(r.length=0,!this.tryOptimizedInsertion_(n,i,r,h,m)){this.queryXY(h,a),s.setY(a.y);let e=m;do{const t=this.getHalfEdgeUserIndex(e,i);-1!==t&&(n.deleteNode(t),this.setHalfEdgeUserIndex(e,i,Le.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(m!==e);e=m;do{if(-1===this.getHalfEdgeUserIndex(e,i)){const t=n.addElement(e);r.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(m!==e)}for(let t=r.length-1;t>=0;t--){const s=r[t],o=n.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,i,s),this.planeSweepParentagePropagateParentage_(n,s,e)}}else if(this.getClusterChain(h)===q){null===o&&(o=new js(this)),this.queryXY(h,a),o.setPointXY(a);const e=n.searchLowerBound(o);let t=this.m_universeChain;if(-1!==e){let s=n.getElement(e);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,e)),s!==q&&(t=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(t,h)}}this.deleteUserIndexForHalfEdges(i)}planeSweepParentagePropagateParentage_(e,t,s){const n=e.getElement(t),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==q)return;const i=this.getLeftSkipPolylines_(e,t),o=this.getHalfEdgeTwin(n),a=this.getHalfEdgeChain(o);let h=this.getChainParent(r),m=this.getChainParent(a);if(i===q)h===q&&(a===r?(this.setChainParent_(a,this.m_universeChain),m=this.m_universeChain,h=m):(m===q&&(this.setChainParent_(a,this.m_universeChain),m=this.m_universeChain),this.setChainParent_(r,a),h=a));else{const e=this.getHalfEdgeChain(i);if(m===q){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(a,t),m=t}else this.setChainParent_(a,e),m=e;a===r&&(h=m)}}h===q&&(this.trySetChainParentFromTwin_(r,a),h=this.getChainParent(r)),l(h!==q),s===Zs.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,i):s===Zs.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,i,o,r,a):s===Zs.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,i,o,r,a)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===q?(i=e.getNext(i),r=this.getHalfEdgeChain(s)):r=this.getHalfEdgeChain(n);let o=null,a=this.getChainParentage(r);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(r));-1!==i;i=e.getNext(i)){const t=e.getElement(i),s=this.getHalfEdgeTwin(t);r=this.getHalfEdgeChain(t);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(n);e=new Ls({copy:e}),e.assignOr(o),this.setChainBitSet_(n,e);let s=this.getChainBitSet(r);const i=this.getLeftEdgeBitSet_(t),a=new Ls({copy:o});if(a.assignSubtract(i),a.isZero())break;s=new Ls({copy:s}),s.assignOr(a),this.setChainBitSet_(r,s),o=s}const h=this.getChainParentage(n),m=h|a;m!==h&&this.setChainParentage_(n,m);let l=this.getChainParentage(r);const g=a&~this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft);if(g&&(l|=g,this.setChainParentage_(r,l)),0===g)break;a=l}}propagateParentageWinding_(e,t,s,n,r,i,o){if(i===o)return;let a=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);a+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let h=0;const m=[],g=[];g.push(0);for(let u=e.getFirst();u!==t;u=e.getNext(u)){const t=e.getElement(u),s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeChain(t),r=this.getHalfEdgeChain(s);if(n!==r){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex),h+=e;let i=!1;0!==m.length&&m.at(-1)===r&&(g.pop(),m.pop(),i=!0),l(this.getChainParent(r)!==q),i&&this.getChainParent(r)===n||(g.push(h),m.push(n))}}if(h+=a,0!==m.length&&m.at(-1)===o&&(g.pop(),m.pop()),0!==h){if(0===g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}else if(0!==g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}propagateParentageAlternate_(e,t,s,n,r,i,o){const a=this.m_simplifiedGeometry,h=this.getGeometryID(a);if(n===q){this.setChainParentage_(o,this.m_universeGeomID);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,h):this.setChainParentage_(i,this.m_universeGeomID)}else{const e=this.getChainParentage(o);if(0===e){const e=this.getHalfEdgeChain(n),t=this.getChainParentage(e);this.setChainParentage_(o,t);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,t===h?this.m_universeGeomID:h):this.setChainParentage_(i,t)}else{1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,e===h?this.m_universeGeomID:h):this.setChainParentage_(i,e)}}}tryOptimizedInsertion_(e,t,s,n,r){let i=r,o=-1,a=q,h=0;do{if(2===h)return!1;const e=this.getHalfEdgeUserIndex(i,t);if(-1!==e){if(-1!==o)return!1;o=e}else{if(a!==q)return!1;a=i}h++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return a!==q&&-1!==o&&(this.setHalfEdgeUserIndex(e.getElement(o),t,Le.impossibleIndex2()),e.setElement(o,a),s.push(o),!0)}trySetChainParentFromTwin_(e,t){const s=this.getChainArea(e);if(0===s)return!1;const n=this.getChainArea(t);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(e,t),!0;{const s=this.getChainParent(t);if(s!==q)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=t.size();s<n;s++){const n=t.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(n),a=this.m_shape.getGeometryFromPath(o),m=this.m_shape.getGeometryType(a);if(h(m)){const t=this.m_shape.getNextVertex(n);if(t===q)continue;const s=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(r===s)continue;const o=this.newHalfEdgePair_(),h=this.getHalfEdgeTwin(o),l=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(l,0,n),this.m_clusterVertices.setField(l,1,-1),this.setHalfEdgeVertexIterator_(o,l),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,r);const g=this.getClusterHalfEdge(r);if(g===q)this.setClusterHalfEdge_(r,o),this.setHalfEdgePrev_(o,h),this.setHalfEdgeNext_(h,o);else{const e=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,h),this.setHalfEdgeNext_(h,g),this.setHalfEdgeNext_(e,o),this.setHalfEdgePrev_(o,e)}this.setHalfEdgeOrigin_(h,s);const u=this.getClusterHalfEdge(s);if(u===q)this.setClusterHalfEdge_(s,h),this.setHalfEdgeNext_(o,h),this.setHalfEdgePrev_(h,o);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,o),this.setHalfEdgeNext_(o,u),this.setHalfEdgeNext_(e,h),this.setHalfEdgePrev_(h,e)}const c=this.getGeometryID(a);if(e===Zs.enumInputModeBuildGraph){const e=m===i.enumPolygon?c:0;if(this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new Ls,t=this.m_shape.getGeometryUserIndex(a,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(o,e),this.setEdgeBitSet_(h,null),this.setLeftEdgeBitSet_(h,e),this.setLeftEdgeBitSet_(o,null)}}else if(e===Zs.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(n),s=this.m_shape.getXY(t);let r=0,i=0;e.compare(s)<0?r=1:i=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,r),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex,i)}else e===Zs.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=m===i.enumPolygon?tn.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,c|_),this.setHalfEdgeParentage_(h,c|_)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,s=t.size();e<s;e++){const s=t.read(e);if(this.m_shape.getSegment(s)){const e=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);e!==q&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{const s=this.getHalfEdgeVertexIterator(t);if(s!==q){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,q)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==q){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,q)}}if(-1!==this.m_segmentIndexHe){let r=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==r){if(-2===r){const s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,s)}if(r=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===r){const e=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){const t=[];for(let s=this.getFirstCluster();s!==q;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==q){let r=n;do{t.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(t.length>1){let r=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=ht(t[0],t[0]=t[1]):r=!1;let i=t[0],o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o),m=q;for(let s=1,n=t.length;s<n;s++){const n=t[s],r=this.getHalfEdgeTwin(n),l=this.getHalfEdgeOrigin(r);if(l!==a||n===o)this.updateVertexToHalfEdgeConnection_(m,!1),m=q,o=n,a=l,h=r;else{if(e===Zs.enumInputModeBuildGraph){const e=this.getHalfEdgeParentageMask_(o)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(o,e),this.setHalfEdgeParentage_(h,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,s;e=this.getEdgeBitSet_(o),t=this.getEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(o,s),e=this.getEdgeBitSet_(h),t=this.getEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(h,s),e=this.getLeftEdgeBitSet_(o),t=this.getLeftEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(o,s),e=this.getLeftEdgeBitSet_(h),t=this.getLeftEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(h,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(o,n),this.deleteEdgeImpl_(n),m=o,t[s]=q,n===i&&(t[0]=q,i=q)}}if(this.updateVertexToHalfEdgeConnection_(m,!1),m=q,!r){i=q;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==q){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=q;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===q)continue;if(i===q){i=s,o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o);continue}if(s===o)continue;const n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(h,s),this.setHalfEdgePrev_(s,h),o=s,a=r,h=n}this.setClusterHalfEdge_(s,i)}}}}sortHalfEdgesByAngle3D_(e){l(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,q);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){const e=this.getClusterHalfEdge(n);if(e!==q){let n=e;do{if(1!==this.getHalfEdgeUserIndex(n,s)){const e=this.newChain_();this.setChainHalfEdge_(e,n),this.setChainPrev_(e,t),this.setChainNext_(t,e);let r=null;this.m_bBuildGeometryParentageSets&&(r=new Ls),t=e;let i=0,o=n;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(i|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&r.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,e),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==n);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(e,r),this.setChainParentage_(e,i)}n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n))}while(n!==e)}}this.m_chainAreas=new ze(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new ze(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(e){l(0)}simplifyAlternate_(){l(0)}simplifyWinding_(){l(0)}setEditShapeImpl_(e,t,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let i=this.m_shape.getTotalPointCount();if(s){i=0;for(let e=0,t=s.length;e<t;e++)i+=this.m_shape.getPointCount(s[e])}const o=new be(0);let a=0,h=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==q;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,h++);for(let t=this.m_shape.getFirstPath(e);t!==q;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,n=this.m_shape.getPathSize(t);s<n;s++)o.add(e),e=this.m_shape.getNextVertex(e)}g(this.m_shape.getGeometryType(e))||(a+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:q,t++):e=this.m_shape.getNextGeometry(e)}}this.m_universeGeomID=1<<Math.min(h,31),this.m_pointCount=o.size(),this.m_shape.sortVerticesSimpleByY(o,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(n,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,a)),this.m_clusterIndex=this.m_shape.createUserIndex();const m=et.getNAN();let l=0;const u=et.getNAN();for(let g=0;g<=this.m_pointCount;g++){if(g<this.m_pointCount){const e=o.read(g);this.m_shape.queryXY(e,u)}else u.setNAN();if(!m.isEqualPoint2D(u)){if(l<g){const e=this.newCluster_();let t=q,s=-1;for(let n=l;n<g;n++){s=o.read(n),this.m_shape.setUserIndex(s,this.m_clusterIndex,e);const r=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(r,0,s),this.m_clusterVertices.setField(r,1,t),t=r;const i=this.m_shape.getPathFromVertex(s),a=this.m_shape.getGeometryFromPath(i),h=this.getGeometryID(a);this.setClusterParentage_(e,this.getClusterParentage(e)|h)}this.setClusterVertexIterator_(e,t),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(s)),this.m_lastCluster!==q&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===q&&(this.m_firstCluster=e)}l=g,m.setCoordsPoint2D(u)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){const t=o.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){const e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(n,!0);{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==q;){for(let t=this.m_shape.getFirstPath(e);t!==q;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){const e=this.m_shape.getFirstVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(t)){const e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}}null!=s?(e=t<s.length?s[t]:q,t++):e=this.m_shape.getNextGeometry(e)}}if(t===Zs.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,o),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(t),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,n),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(e,t,s,n,r){l(0)}cleanSetEditShapeImpl_(){-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){l(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){const t=this.getHalfEdgeNext(e),s=this.getHalfEdgePrev(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeNext(n),i=this.getHalfEdgePrev(n);t!==n&&(this.setHalfEdgeNext_(i,t),this.setHalfEdgePrev_(t,i)),s!==n&&(this.setHalfEdgeNext_(s,r),this.setHalfEdgePrev_(r,s));const o=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(o)===e&&(r!==e?this.setClusterHalfEdge_(o,r):this.setClusterHalfEdge_(o,q));const a=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(a)===n&&(t!==n?this.setClusterHalfEdge_(a,t):this.setClusterHalfEdge_(a,q)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(e,t){let s=t;for(;;){if(s=e.getPrev(s),-1===s)return q;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=pt(this.m_checkDirtyPlanesweepTolerance),t=new et,s=new et,n=new et,r=new et,i=new et;for(let o=this.getFirstCluster();o!==q;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==q){let o=a;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,s),n.setSub(s,t);let h=n.sqrLength();do{const a=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==a){this.getHalfEdgeToXY(o,r),i.setSub(r,t);const a=i.sqrLength(),m=i.crossProduct(n),l=m*m/(a*h);if(Math.min(a,h)*l<=e){if(i.dotProduct(n)>=0)return!1}n.assign(i),h=a,s.assign(r)}}while(o!==a)}}return!0}extractPolygonPathFromChain_(e,t,s,n,r){const i=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(s);let a=o,h=q;const m=new ye;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=q;const o=this.getHalfEdgeOrigin(a);if(n===q){const e=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==q;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===q&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let l;if(h===q&&(h=e.insertPath(t,q),e.setClosedPath(h,!0)),this.m_shape===e?l=e.addVertex(h,s):(this.m_shape.queryPoint(s,m),l=e.addPoint(h,m)),this.isHalfEdgeCurve(a)&&(this.querySegmentXY(a,r),e.setSegmentToIndex(e.getVertexIndex(l),r.get().clone())),i){const t=this.getSegmentParentage(a);e.setSegmentParentageAndBreak(l,t,this.isBreakNode(o))}}a=this.getHalfEdgeNext(a)}while(a!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;l(-1!==this.m_clusterBreakNodeIndex),l(-1===this.m_segmentParentageIndex);for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){let e=0;const t=this.getClusterHalfEdge(n);if(t!==q){let s=t;do{e++,s=this.getHalfEdgeNext(this.getHalfEdgeTwin(s))}while(s!==t&&e<3)}2!==e&&this.setBreakNode(n,!0)}let e=[],t=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==q){let n=!1,i=r;do{let r=i;for(;-1===this.getHalfEdgeUserIndex(r,s);){const i=this.getHalfEdgeNext(r),o=this.getHalfEdgeTwin(r);$s(this,r,t);const a=t.at(-1).parentage;if(!n){const t=this.getHalfEdgeOrigin(r);if(!this.isBreakNode(t)){const t=this.getHalfEdgePrev(r);r!==t&&($s(this,t,e),n=!0)}}if(n&&!Js(t,e)){const e=this.getHalfEdgeOrigin(r);this.setBreakNode(e,!0)}e=ht(t,t=e),n=!0;const h=this.getHalfEdgeOrigin(i);this.isBreakNode(h)&&(n=!1),this.setHalfEdgeUserIndex(r,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(r,s,1),this.setHalfEdgeUserIndex(o,s,1),r=i}i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==r)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(e){if(null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=en(),this.m_uniqueBitSets.add(this.getEmptySet())),null===e)return this.getEmptySet();return this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return l(t>=0),l(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const 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),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setLeftEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setChainBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(e,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=t:(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new Ls),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(e){}dbgVerifyEdgeSegment(e){}}tn.c_EdgeParentageMask=~(1<<31),tn.c_EdgeBitMask=1<<31;class sn{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){this.m_listNodes=new Le(2),this.m_listOfLists=sn.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new Le(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==sn.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!==sn.st_nullNode();){const e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==sn.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);const s=this.m_lists.getField(e,1),n=this.newNode_();return s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,n)):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,n)),this.m_listNodes.setField(n,0,t),n}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,s){t!==sn.st_nullNode()?(this.m_listNodes.setField(t,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,t)):(this.m_lists.setField(e,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,sn.st_nullNode())),this.freeNode_(s)}deleteElementSearch(e,t){let s=-1,n=this.getFirst(e);for(;n!==t;)s=n,n=this.getNext(n);this.deleteElementDirect(e,s,t)}concatenateLists(e,t){const s=this.m_lists.getField(e,1),n=this.m_lists.getField(t,0);if(n!==sn.st_nullNode()&&(s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==sn.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){l(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){const t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=sn.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 nn(e=-1){return{m_value:e,m_line:new A,m_segment:null,m_segmentInfo:new ae(-1),m_env:new at(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}const rn=67;class on extends We{constructor(e,t,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new ts,this.m_tempSimpleEdge1=nn(),this.m_tempSimpleEdge2=nn(),this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q,this.m_currentNode=-1,this.m_prevX1=Number.NaN,this.m_prevX2=Number.NaN,this.m_prevY=Number.NaN,this.m_prevX=0,this.m_sweepY=Number.NaN,this.m_sweepX=0,this.m_ptSweep=new et,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*e.getTotalPointCount()/2,rn)),r=Math.min(7,n);this.m_simpleEdgesCache.length=r}tryGetCachedEdge_(e){const t=this.m_simpleEdgesCache[(e&vt())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&vt())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[t];s&&s.m_value===e&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){const t=(e&vt())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[t];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=nn(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=e,this.m_simpleEdgesCache[t]=s,s)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=null!==e.m_segment,e.m_bCurve){const t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){const s=e.getStartXY(),n=e.getEndXY(),r=t.getStartXY(),i=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(r)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(i)<0?n:i);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-r)>this.m_tolerance)return s<r?-1:1}const o=s.compare(r)<0?r:s,a=n.compare(i)<0?n:i;let h=0,m=0;for(let l=1;l<5;l++){Ct(o,a,l/5,this.m_ptSweep);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=Math.abs(s-n);r>h&&(h=r,m=s<n?-1:1)}return 0===m?this.errorCracking():m}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);const s=this.compareNonHorizontalLowerEnd_(e,t),n=this.compareNonHorizontalUpperEnd_(e,t);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}return-1}compareHorizontal1Case3_(e,t){const s=et.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=et.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=et.getNAN();r.setSub(e.getEndXY(),t.getStartXY());const i=n.dotProduct(s),o=r.dotProduct(s),a=Math.abs(i),h=Math.abs(o);if(a<h){if(a<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(h<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return i<0&&o<0?-1:i>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let s=1;if(e.m_line.getStartY()<t.m_line.getStartY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getStartX()-r.getStartX(),o=t.m_dxdy*(n.getStartY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}compareNonHorizontalUpperEnd_(e,t){let s=1;if(t.m_line.getEndY()<e.m_line.getEndY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getEndX()-r.getStartX(),o=t.m_dxdy*(n.getEndY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}errorCoincident(){this.m_bIntersectionDetected=!0;const e=7;return this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const e=6;this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2)}else this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q;return-1}compareSegments_(e,t,s,n){if(s.m_env.vmax<n.m_env.vmin)return-1;if(n.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!n.m_bCurve){let e=s.m_bHorizontal?1:0;return e|=n.m_bHorizontal?2:0,0===e?this.compareNonHorizontal_(s,n):1===e?this.compareHorizontal1_(s.m_line,n.m_line):2===e?-1*this.compareHorizontal1_(n.m_line,s.m_line):this.compareHorizontal2_(s.m_line,n.m_line)}if(this.m_bIntersectionDetected)return-1;const r=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let i,o;if(r&&e===this.m_prev1?i=this.m_prevX1:(i=Number.NaN,this.m_prev1=q),r&&t===this.m_prev2?o=this.m_prevX2:(o=Number.NaN,this.m_prev2=q),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(i)){this.m_prev1=e;const t=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);i=t,this.m_prevX1=t}if(Number.isNaN(o)){this.m_prev2=t;const e=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX2=e}const a=K(!0,!0,s.m_segment,n.m_segment,this.m_tolerance,!0);return 0!==a?2===a?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(n.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(i-o)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):i<o?-1:i>o?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=t;return this.m_currentNode=s,this.compareSegments(r,r,n,n)}compareSegments(e,t,s,n){let r=this.tryGetCachedEdge_(e);null===r?this.m_vertex1===t?r=this.m_tempSimpleEdge1:(this.m_vertex1=t,r=this.tryCreateCachedEdge_(e),null===r&&(r=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(r,t)):this.m_vertex1=t;let i=this.tryGetCachedEdge_(s);return null===i?this.m_vertex2===n?i=this.m_tempSimpleEdge2:(this.m_vertex2=n,i=this.tryCreateCachedEdge_(s),null===i&&(i=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(i,n)):this.m_vertex2=n,this.compareSegments_(t,n,r,i)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class an{constructor(e,t){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=et.getNAN(),this.m_line1=new A,this.m_seg1=null,this.m_env=at.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){const s=e.getElement(t);return this.compareVertex(e,t,s)}compareVertex(e,t,n){let r,i=this.m_shape.getSegment(n),o=!0;if(null==i)this.m_shape.queryLineConnector(n,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),i=this.m_line1,r=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=s.constructEmpty();i.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),r=0===e.height(),o=!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(r)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let a=0;if(o){ee(this.m_line1);const e=this.m_line1.getStartXY(),t=new et;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new et;s.setSub(this.m_pointOfInterest,e),a=t.dotProduct(s),a/=t.length()}else{a=i.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x}if(a<10*-this.m_tolerance)return-1;if(a>10*this.m_tolerance)return 1;if(i.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)){Math.abs(a)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=a),this.m_bIntersectionDetected=!0}return a<0?-1:a>0?1:0}}class hn{constructor(e,t){this.m_lists=new sn(!1),this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(hn.st_nullNode()),this.m_bitFilter=new Int32Array(10*e+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=t%this.m_hashBuckets.length;let r=this.m_hashBuckets[n];r===sn.st_nullNode()&&(r=this.m_lists.createList(),this.m_hashBuckets[n]=r);return this.m_lists.addElement(r,e)}deleteElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%this.m_hashBuckets.length,r=this.m_hashBuckets[s];r===sn.st_nullNode()&&n("");let i=this.m_lists.getFirst(r),o=sn.st_nullNode();for(;i!==sn.st_nullNode();){const t=this.m_lists.getData(i),n=this.m_lists.getNext(i);t===e?(this.m_lists.deleteElementDirect(r,o,i),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[s]=sn.st_nullNode())):o=i,i=n}}getFirstInBucket(e){const t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(31&t)))return sn.st_nullNode();const s=e%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===sn.st_nullNode()?sn.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){const t=this.m_hash.getHash(e);let s=this.getFirstInBucket(t);for(;s!==sn.st_nullNode();){const t=this.m_lists.getData(s);if(this.m_hash.equal(t,e))return s;s=this.m_lists.getNext(s)}return sn.st_nullNode()}deleteNode(e){const t=this.getElement(e),s=this.m_hash.getHash(t)%this.m_hashBuckets.length,r=this.m_hashBuckets[s];r===sn.st_nullNode()&&n(""),this.m_lists.deleteElementSearch(r,e),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[s]=sn.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return sn.st_nullNode()}clear(){l(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function mn(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=n,i.m_bHasSegmentParentage=e.hasSegmentParentage(),i.clusterNonReciprocal()}function ln(e,t,s,n,r){const i=e-s,o=t-n;return i*i+o*o<=r}function gn(){return{pt:new et,weight:0,rank:0,bMerged:!1}}function un(e,t,s,n,r,i){const o=gn(),a=s+r;let h=!1,m=e.x;e.x!==t.x&&(n===i&&(m=(e.x*s+t.x*r)/a),h=!0);let l=e.y;return e.y!==t.y&&(n===i&&(l=(e.y*s+t.y*r)/a),h=!0),n!==i?n>i?(o.rank=n,o.weight=s,o.pt=e):(o.rank=i,o.weight=r,o.pt=t):(o.pt.setCoords(m,l),o.weight=a,o.rank=n),o.bMerged=h,o}function cn(e,t,s,n,r,i,o,a,h){const m=e.equals(t);if(n>i)return o.assignCopy(e),h[0]=n,a[0]=s,m;if(i>n)return o=t,h[0]=i,a[0]=r,m;o.assignCopy(e);const l=un(e.getXY(),t.getXY(),s,n,r,i);return o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank,m}function _n(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=!1,i.needsClustering()}function dn(e,t){const s=zt(e);return qt(s,t)}class pn{constructor(e,t,s,n,r){this.m_workPt=new et,this.m_shape=e,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=t.clone(),this.m_hashValues=r}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);const t=this.m_workPt.x-this.m_origin.x,s=Math.trunc(t*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return dn(s,Math.trunc(n*this.m_invCellSize+.5))}equal(e,t){return l(0),!1}}class fn{constructor(e){this.m_origin=et.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=q,this.m_bucketArray=$e(4,Number.NaN),this.m_bucketHash=$e(4,Number.NaN),this.m_dbgCandidateCheckCount=0,this.m_nsr=new ts,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new sn,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){const s=et.getNAN();this.m_shape.queryXY(e,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,r=(s.y-this.m_origin.y)*this.m_invCellSize,i=Math.trunc(n),o=Math.trunc(r);let a=0;for(let h=0;h<=1;h+=1)for(let e=0;e<=1;e+=1){const t=dn(i+h,o+e),s=this.m_hashTable.getFirstInBucket(t);s!==hn.st_nullNode()&&(this.m_bucketArray[a]=s,this.m_bucketHash[a]=t,a++)}for(let h=a-1;h>=1;h--){const e=this.m_bucketArray[h];for(let t=h-1;t>=0;t--)if(e===this.m_bucketArray[t]){this.m_bucketHash[t]=-1,a--,h!==a&&(this.m_bucketHash[h]=this.m_bucketHash[a],this.m_bucketArray[h]=this.m_bucketArray[a]);break}}for(let h=0;h<a;h++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[h],s,this.m_bucketArray[h],t)}collectNearestNeighbourCandidates(e,t,s,n,r){const i=et.getNAN();for(let o=n;o!==hn.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);e===n||-1!==t&&this.m_shape.getUserIndex(n,this.m_hashValues)!==t||(this.m_shape.queryXY(n,i),ln(s.x,s.y,i.x,i.y,this.m_sqrTolerance)&&r.push(o))}}mergeClusters(e,t,s){let n=this.m_shape.getUserIndex(e,this.m_newClusters);const r=this.m_shape.getUserIndex(t,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,e),this.m_shape.setUserIndex(e,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,t):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(t,this.m_newClusters,Le.impossibleIndex2());const i=this.mergeVertices(e,t);if(s){const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return i}mergeVertices(e,t){const s=et.getNAN();this.m_shape.queryXY(e,s);const n=et.getNAN();this.m_shape.queryXY(t,n);const r=this.m_shape.getRank(e),i=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),a=this.m_shape.getWeight(t);let h,m,l,g,u=!1;if(r===i?(h=r,m=o+a,l=s.x,s.x!==n.x&&(l=(s.x*o+n.x*a)/m,u=!0),g=s.y,s.y!==n.y&&(g=(s.y*o+n.y*a)/m,u=!0)):(r>i?(l=s.x,g=s.y,m=o,h=r):(l=n.x,g=n.y,m=a,h=i),u=!s.equals(n)),u&&(this.m_shape.setXYMonotonic(e,l,g),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,s),this.m_shape.setSegmentParentageBreakVertex(t,s)}return this.m_shape.setWeight(e,m),this.m_shape.setRank(e,h),u}needsClustering(){const s={stack:[],error:void 0,hasError:!1};try{e(s,Gt(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);const t=this.m_shape.getSelectedCount(),n=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(n.getLowerLeft());const r=Math.max(n.height(),n.width())/(Tt()-1);this.m_cellSize<r&&(this.m_cellSize=r,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(this.m_shape.getSelectedCount()/3+1),this.m_clusters.reserveNodes(this.m_shape.getSelectedCount()/3+1),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new hn(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==q;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===Le.impossibleIndex2())continue;let s;if(0===e?(s=this.m_hashFunction.calculateHashFromVertex(n),this.m_shape.setUserIndex(n,this.m_hashValues,s)):s=this.m_shape.getUserIndex(n,this.m_hashValues),this.collectClusterCandidates(n,t),0!==t.length){for(let e=0,s=t.length;e<s;e++){this.progress_();const s=t[e],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new ts(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return i}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}clusterNonReciprocal(){const e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();const s=Math.max(t.height(),t.width())/(Tt()-1);this.m_cellSize<s&&(this.m_cellSize=s,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_clusters.reserveNodes(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new hn(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==q;t=e.next()){this.progress_();const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{const e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=t.next();s!==q;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===Le.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,t);let r=!1;for(;this.collectClusterCandidates(s,e),0!==e.length;){let t=0;for(let n=0,r=e.length;n<r;n++){this.progress_();const i=e[n],o=this.m_hashTable.getElement(i);this.m_hashTable.deleteNode(i);const a=n+1===r;t|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==t,n||=0!==t,e.length=0,!t)break}r&&(t=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,t)}e.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const e=et.getNAN();for(let t=this.m_clusters.getFirstList();t!==sn.st_nullNode();t=this.m_clusters.getNextList(t)){let s=this.m_clusters.getFirst(t);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,e);const r=this.m_shape.getRank(n),i=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==sn.st_nullNode();s=this.m_clusters.getNext(s)){const t=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(n,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,i),this.m_shape.setRank(t,r)}}}}class xn{constructor(){this.m_inputParts=[],this.m_resultParts1=[],this.m_resultParts2=[],this.m_resultSegments=[],this.m_freeSegments=[],this.m_inputSegments=[],this.m_param1=[],this.m_param2=[],this.m_tolerance=0,this.m_toleranceZ=0,this.m_point=new ye,this.m_pointWeight=1,this.m_maxDensifyLimit=0,this.m_pointRank=0,this.m_changed1=!1,this.m_changed2=!1,this.m_adaptiveDensify=!1}clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(e,t,s,n,r,i,o,a,h,m){return Pn(e,t,s,n,r,i,o,a,h,m)}pushSegment(e,t,s,n,r,i,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,s,n,r,i,o,a,h,m)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?0===e?this.m_param1.length-1:this.m_param2.length-1:0===e?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return 0===e?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return 0===e?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){2!==this.m_inputSegments.length&&a(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=pt(e*xn.c_smallToleranceFactor);let n=!1;const r=this.m_inputParts[0],i=this.m_inputParts[1],o=this.m_inputSegments[r.segmentIndex],h=this.m_inputSegments[i.segmentIndex];if(t||5&B(!0,o,h,e,!0)){const t=Q(!0,o,h,null,this.m_param1,this.m_param2,e);0===t&&a("");const m=new Array(t);for(let e=0;e<t;++e)m[e]=et.getNAN();const l=new Float64Array(t),g=new Int32Array(t),u=new Array(t),c=new Array(t);for(let e=0;e<t;++e)u[e]=En(),c[e]=En();for(let e=0;e<t;e++){const t=this.m_param1[e],a=this.m_param2[e];let _,d=r.rankInterior,p=r.weightInterior;0===t?(d=r.rankStart,p=r.weightStart,_=r.u.bBreakStart):1===t?(d=r.rankEnd,p=r.weightEnd,_=r.u.bBreakEnd):(this.m_changed1=!0,_=!1);let f,x=i.rankInterior,y=i.weightInterior;0===a?(x=i.rankStart,y=i.weightStart,f=i.u.bBreakStart):1===a?(x=i.rankEnd,y=i.weightEnd,f=i.u.bBreakEnd):(this.m_changed2=!0,f=!1);const P=d,E=x;let S=1,C=0,I=et.getNAN();if(P===E){const n=o.getCoord2D(t),r=h.getCoord2D(a);S=p+y;C=d,Ct(n,r,y/S,I);const i=et.sqrDistance(I,n),m=et.sqrDistance(I,r);u[e].bBigMove=i>s,c[e].bBigMove=m>s,this.m_changed1||n.equals(I)||(this.m_changed1=!0),this.m_changed2||r.equals(I)||(this.m_changed2=!0)}else if(P>E){I=o.getCoord2D(t);const n=h.getCoord2D(a);S=p,C=d;const r=et.sqrDistance(I,n);u[e].bBigMove=!1,c[e].bBigMove=r>s,this.m_changed2||n.equals(I)||(this.m_changed2=!0)}else{I=h.getCoord2D(a),S=y,C=x;const n=o.getCoord2D(t),r=et.sqrDistance(I,n);u[e].bBigMove=r>s,c[e].bBigMove=!1,this.m_changed1||n.equals(I)||(this.m_changed1=!0)}m[e].assign(I),l[e]=S,g[e]=C,u[e].bIsBreak=_||f,c[e].bIsBreak=_||f,n||=u[e].bBigMove||c[e].bBigMove}const _=r.rankInterior,d=r.weightInterior;let p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param1[s]:1;if(n!==p){const i=this.allocResultSegment(),a=this.m_resultSegments[i];let h,c,x,y;o.queryCut(p,n,a,!1),a.get().snapControlPoints(e*e);let P=!1,E=!1,S=!1,C=!1,I=!1,b=et.getNAN(),w=et.getNAN();-1!==f?(c=g[f],h=l[f],P=u[f].bBigMove,b.assign(m[f]),S=u[f].bIsBreak,I=!0):(h=r.weightStart,c=r.rankStart,b=a.get().getStartXY(),S=r.u.bBreakStart),s<t?(y=g[s],x=l[s],E=u[s].bBigMove,w.assign(m[s]),C=u[s].bIsBreak,I=!0):(x=r.weightEnd,y=r.rankEnd,w=a.get().getEndXY(),C=r.u.bBreakEnd),I&&a.get().setCoordsForIntersector(b,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,h,c,x,y,d,_,S,C,r.segmentParentage));const v=this.m_resultParts1.at(-1);v.u.bBigMoveStart=P,v.u.bBigMoveEnd=E,p=n,f=s}else-1===f&&(f=s)}const x=$e(t,0);for(let e=0;e<t;e++)x[e]=e;t>2?(x.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:this.m_param2[e]>this.m_param2[t]?1:0),st(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=ht(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),x[1]=ht(x[0],x[0]=x[1]));const y=i.rankInterior,P=i.weightInterior;p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param2[s]:1;if(n!==p){const r=this.allocResultSegment(),o=this.m_resultSegments[r];let a,u,_,d;h.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let E=et.getNAN(),S=et.getNAN(),C=!1,I=!1,b=!1,w=!1,v=!1;if(-1!==f){const e=x[f];a=l[e],u=g[e],E.assign(m[e]),b=c[e].bBigMove,C=c[e].bIsBreak,v=!0}else a=i.weightStart,u=i.rankStart,E=o.get().getStartXY(),C=i.u.bBreakStart;if(s!==t){const e=x[s];_=l[e],d=g[e],S.assign(m[e]),w=c[e].bBigMove,I=c[e].bIsBreak,v=!0}else _=i.weightEnd,d=i.rankEnd,S=o.get().getEndXY(),I=i.u.bBreakEnd;v&&o.get().setCoordsForIntersector(E,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,a,u,_,d,P,y,C,I,i.segmentParentage));const N=this.m_resultParts2.at(-1);N.u.bBigMoveStart=b,N.u.bBigMoveEnd=w,p=n,f=s}else-1===f&&(f=s)}return n?3:2}return 0}intersectLines3D(e,t,s,n){return l(0),1}intersect2D(e,t){const s=this.m_inputParts[0],n=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[n.segmentIndex].getGeometryType();if(r!==i.enumLine||o!==i.enumLine){return new bn(this).intersectCurves(e,t)}return this.intersectLines(e,t)}intersect2DEx(e,t,s,n,r){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&a(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const i=pt(e*xn.c_smallToleranceFactor);let o=!1;const h=this.m_inputParts[0],m=this.m_inputSegments[h.segmentIndex];if(r||m.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=$e(16,Number.NaN);const r=m.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let a=h.rankInterior,l=h.weightInterior;0===r?(a=h.rankStart,l=h.weightStart):1===r?(a=h.rankEnd,l=h.weightEnd):this.m_changed1=!0;let g=a;const u=s,c=n;g===u&&m.isCurve()&&(g=u+1);let _=1,d=0;const p=new et;if(g===u){const e=m.getCoord2D(r),s=t.getXY();_=l+c,d=a;Ct(e,s,c/_,p),this.m_changed1||e.equals(p)||(this.m_changed1=!0),this.m_changed2||s.equals(p)||(this.m_changed2=!0);o=et.sqrDistance(p,e)>i}else if(g>u)p.assign(m.getCoord2D(r)),_=l,d=a,this.m_changed2||p.equals(t.getXY())||(this.m_changed2=!0);else{p.assign(m.getCoord2D(r)),_=c,d=u,this.m_changed1||p.equals(t.getXY())||(this.m_changed1=!0);o=et.sqrDistance(p,t.getXY())>i}let f=0,x=-1;const y=1;for(let t=0;t<=y;t++){const s=t<y?this.m_param1[0]:1;if(s!==f){const n=this.allocResultSegment(),r=this.m_resultSegments[n];m.queryCut(f,s,r),r.get().snapControlPoints(e*e);let i=h.weightStart,o=h.weightEnd,a=h.rankStart,l=h.rankEnd;const g=h.rankInterior,u=h.weightInterior;let c=h.u.bBreakStart,P=h.u.bBreakEnd;-1!==x&&(i=_,a=d,c=!0,r.get().setCoordsForIntersector(p,r.get().getEndXY(),!0)),t!==y&&(o=_,l=d,P=!0,r.get().setCoordsForIntersector(r.get().getStartXY(),p,!0)),f=s,this.m_resultParts1.push(this.newIntersectionPart_(n,i,a,o,l,u,g,c,P,h.segmentParentage))}x=t}return this.m_point.setXY(p),this.m_pointWeight=_,this.m_pointRank=d,o?3:2}return 0}intersect3D(e,t,s,n){return l(0),1}intersect3DEx(e,t,s,n,r,i,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()}const e=new k,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new k({copy:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new k({segment:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}}function yn(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function Pn(e,t,s,n,r,i,o,a,h,m){return{segmentIndex:e,weightStart:t,rankStart:s,weightEnd:n,rankEnd:r,weightInterior:i,rankInterior:o,segmentParentage:m,u:yn(a,h)}}function En(){return{bBigMove:!1,bIsBreak:!1}}xn.maxWeight=.1*Number.MAX_VALUE,xn.c_smallToleranceFactor=.01,xn.c_maxGeometryTypeToRankDelta=8;let Sn=class{constructor(){this.start=null,this.end=null,this.equalEdge=null,this.segmentIndex=-1,this.segmentParentage=-1,this.weight=0,this.rank=0}hasSegment(){return this.segmentIndex>=0}transferAttributes(e,t,s){if(1===t.getDescription().getAttributeCount())return;const n=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),i=new ye;t.queryStart(i),s?(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i)):(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)),t.queryEnd(i),s?(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)):(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i))}copyFromWhenOverlap(e,t,s){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,s?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class Cn{constructor(){this.hash=0,this.pt=new et,this.prevInChain=null,this.nextInChain=null,this.prevInHash=null,this.nextInHash=null,this.prevEqual=null,this.nextEqual=null,this.weight=0,this.rank=0,this.bBigMove=!1,this.bIsBreak=!1}copyFrom(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;null!==e.prevEqual;e=e.prevEqual);return e}}function In(e,t,s,n){return{edge1:e,edge2:t,recursion:s,bIsIntersecting:n}}class bn{constructor(e){this.m_pairs=[],this.m_chainOrigin1=null,this.m_chainOrigin2=null,this.m_newNodes=[],this.m_hashTableOfEquals=[],this.m_hashTableOfEqualsSize=0,this.m_origin=new et,this.m_cell=new et,this.parent=e}addSegment(e,t,s,n,r,i,o,a,h,m,g){const u=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,h),c=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,i,m);this.newEdge(u,c,e,o,a,g),null===this.m_chainOrigin1?this.m_chainOrigin1=u:null===this.m_chainOrigin2?this.m_chainOrigin2=u:l(0)}intersectCurvesHelper(e,t,s,n,r){const o=this.getSegment(e).get(),h=this.getSegment(t).get();if(o.isDegenerate(0)||h.isDegenerate(0))return 0;const m=this.tryOverlapIntersectCurves(e,t,s,n);if(0!==m)return m;const g=pt(.01*s);let u=!1,c=this.processSharpCorners(o,h,s,r>4);const _=c>0;if(!_){if(!(n||5&K(!0,!1,o,h,s,!0)))return 0;c=Q(!0,o,h,null,this.parent.m_param1,this.parent.m_param2,s)}0===c&&a("");const d=o.getGeometryType(),p=h.getGeometryType(),f=gt(et,c),x=gt(et,c),y=$e(c,Number.NaN),P=$e(c,Number.NaN),E=$e(c,Number.NaN),S=$e(c,Number.NaN),C=Dt(En,c),I=Dt(En,c);let b=!1,w=!1;for(let i=0;i<c;i++){const n=this.parent.m_param1[i],r=this.parent.m_param2[i];let a=e.rank,m=e.weight,l=!0,c=!1;0===n?(a=e.start.rank,m=e.start.weight,c=e.start.bIsBreak):1===n?(a=e.end.rank,m=e.end.weight,c=e.end.bIsBreak):(b=!0,l=!1);let v=t.rank,N=t.weight,T=!1,G=!0;0===r?(v=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===r?(v=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(w=!0,G=!1);let D=a,V=v;if(D===V&&(D*=xn.c_maxGeometryTypeToRankDelta,V*=xn.c_maxGeometryTypeToRankDelta,D+=wn(d,o,!1),V+=wn(p,h,!1)),l&&G&&V===D){const e=o.getCoord2D(n),t=h.getCoord2D(r);e.equals(t)&&(V=D-1)}let F=1,H=0,k=1,A=0;const M=new et,U=new et,q=o.getCoord2D(n),B=h.getCoord2D(r);if(_&&et.distance(q,B)>s)M.setCoordsPoint2D(q),U.setCoordsPoint2D(B),F=m,k=N,H=a,A=v,C[i].bBigMove=!1,I[i].bBigMove=!1,c=!0,T=!0;else if(D===V){k=F=m+N,A=H=a;Ct(q,B,N/F,M),U.setCoordsPoint2D(M);const e=et.sqrDistance(M,q),t=et.sqrDistance(M,B);C[i].bBigMove=e>g,I[i].bBigMove=t>g,b||q.equals(M)||(b=!0),w||B.equals(U)||(w=!0)}else if(D>V){M.setCoordsPoint2D(q),U.setCoordsPoint2D(M),k=F=m,A=H=a;const e=et.sqrDistance(M,B);C[i].bBigMove=!1,I[i].bBigMove=e>g,w||B.equals(U)||(w=!0)}else{U.setCoordsPoint2D(B),M.setCoordsPoint2D(U),k=F=N,A=H=v;const e=et.sqrDistance(M,q);C[i].bBigMove=e>g,I[i].bBigMove=!1,b||q.equals(M)||(b=!0)}f[i].assign(M),x[i].assign(U),y[i]=F,P[i]=k,E[i]=H,S[i]=A,C[i].bIsBreak=c||T,I[i].bIsBreak=c||T,u||=C[i].bBigMove||I[i].bBigMove,i>0&&(n!==this.parent.m_param1[i-1]&&r!==this.parent.m_param2[i-1]||(E[i]<=E[i-1]?(f[i].assign(x[i-1]),y[i]=P[i-1],E[i]=S[i-1],x[i].assign(x[i-1]),P[i]=P[i-1],S[i]=S[i-1],C[i].bBigMove||=C[i-1].bBigMove,I[i].bBigMove||=I[i-1].bBigMove,C[i].bIsBreak||=C[i-1].bIsBreak,I[i].bIsBreak||=I[i-1].bIsBreak):(f[i-1].assign(f[i]),y[i-1]=y[i],E[i-1]=E[i],x[i-1].assign(x[i]),P[i-1]=P[i],S[i-1]=S[i],C[i-1].bBigMove||=C[i].bBigMove,I[i-1].bBigMove||=I[i].bBigMove,C[i-1].bIsBreak||=C[i].bIsBreak,I[i-1].bIsBreak||=I[i].bIsBreak)))}if(!(b||w||2!==c||d===i.enumLine&&p===i.enumLine)){if(this.processDoublyConnectedEdges(e,t,r+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;l(0)}this.parent.m_changed1||=b,this.parent.m_changed2||=w;let v=e,N=e.end.weight,T=e.end.rank,G=e.end.bBigMove,D=e.end.bIsBreak,V=0,F=-1;for(let i=0;i<=c;i++){const t=i<c?this.parent.m_param1[i]:1;if(t!==V){const n=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[n];let a,h,m,l;o.queryCut(V,t,r,!1),r.get().snapControlPoints(s*s);let g=!1,u=!1,_=!1,d=!1;const p=new et,x=new et;-1!==F?(h=E[F],a=y[F],_=C[F].bBigMove,g=C[F].bIsBreak,p.assign(f[F])):(a=e.start.weight,h=e.start.rank,_=e.start.bBigMove,g=e.start.bIsBreak,p.assign(r.get().getStartXY())),i<c?(l=E[i],m=y[i],d=C[i].bBigMove,u=C[i].bIsBreak,x.assign(f[i])):(m=N,l=T,d=G,u=D,x.assign(r.get().getEndXY()));let P=v;t<1&&(this.splitEdgeInPlace(v),P=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(p)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(x)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(p),v.end.pt.assign(x),v.start.bBigMove||=_,v.end.bBigMove||=d,v.start.bIsBreak||=g,v.end.bIsBreak||=u,v.start.weight=a,v.start.rank=h,v.end.weight=m,v.end.rank=l,v=P,V=t,F=i}else-1===F&&(F=i)}const H=v.getNextInChain(),k=[];k.length=c;for(let i=0;i<c;i++)k[i]=i;c>2?(k.sort((e,t)=>Vt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Vt)):2===c&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=ht(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),k[1]=ht(k[0],k[0]=k[1])),v=t,N=t.end.weight,T=t.end.rank,G=t.end.bBigMove,D=t.end.bIsBreak,V=0,F=-1;for(let i=0;i<=c;i++){const e=i<c?this.parent.m_param2[i]:1;if(e!==V){const n=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[n];let o,a,m,l;h.queryCut(V,e,r,!1),r.get().snapControlPoints(s*s);const g=new et,u=new et;let _=!1,d=!1,p=!1,f=!1;if(-1!==F){const e=k[F];o=P[e],a=S[e],g.assign(x[e]),p=I[e].bBigMove,_=I[e].bIsBreak}else o=t.start.weight,a=t.start.rank,p=t.start.bBigMove,_=t.start.bIsBreak,g.assign(r.get().getStartXY());if(i!==c){const e=k[i];m=P[e],l=S[e],u.assign(x[e]),f=I[e].bBigMove,d=I[e].bIsBreak}else m=N,l=T,f=G,d=D,u.assign(r.get().getEndXY());let y=v;e<1&&(this.splitEdgeInPlace(v),y=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(g)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(u)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(g),v.end.pt.assign(u),v.start.bBigMove||=p,v.end.bBigMove||=f,v.start.bIsBreak||=_,v.end.bIsBreak||=d,v.start.weight=o,v.start.rank=a,v.end.weight=m,v.end.rank=l,v=y,V=e,F=i}else-1===F&&(F=i)}const A=v.getNextInChain();return this.postProcessResultPartsForCurves(e,H,t,A,r+1),u?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&a(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=tt(16);const n=s.constructEmpty();for(let o=0;o<2;o++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[o].segmentIndex]),t=s.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[o].segmentIndex].queryLooseEnvelope(t),n.mergeEnvelope2D(t);const r=this.parent.m_inputParts[o];this.addSegment(e,0,r.weightStart,r.rankStart,r.weightEnd,r.rankEnd,r.weightInterior,r.rankInterior,r.u.bBreakStart,r.u.bBreakEnd,r.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(In(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let r=0,i=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),l(t.recursion>=0),l(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,r=s)}for(let s=0;s<2;s++){const e=0===s?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let t=(0===s?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=t;t=t.getNextInChain())e.push(this.parent.newIntersectionPart_(t.segmentIndex,t.start.weight,t.start.rank,t.end.weight,t.end.rank,t.weight,t.rank,t.start.bIsBreak,t.end.bIsBreak,t.segmentParentage)),e.at(-1).u.bBigMoveStart=t.start.bBigMove,e.at(-1).u.bBigMoveEnd=t.end.bBigMove}return r}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),i=this.parent.m_resultSegments[t.segmentIndex].get(),o=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY()),a=r.getStartXY().equals(i.getEndXY())&&r.getEndXY().equals(i.getStartXY());if(!o&&!a)return 0;const h=te(r,i,!0);if(0!==h&&se(r,i)&&e.segmentParentage===t.segmentParentage){let e=!1;if(h>0)e=r.equals(i);else{l(-1===h);const t=new k({segment:i});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const m=s*xn.c_smallToleranceFactor;let g=!1;if(0===h){const e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new et;r.queryCoord2D(n,o);const a=i.getClosestCoordinate(o,!1),h=new et;i.queryCoord2D(a,h);const l=et.distance(o,h);if(l>s)return 0;g||=l>m}for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new et;i.queryCoord2D(n,o);const a=r.getClosestCoordinate(o,!1),h=new et;r.queryCoord2D(a,h);const l=et.distance(o,h);if(l>s)return 0;g||=l>m}}let u=e.rank,c=t.rank;return u===c&&(u*=xn.c_maxGeometryTypeToRankDelta,c*=xn.c_maxGeometryTypeToRankDelta,u+=wn(r.getGeometryType(),r,!0),c+=wn(i.getGeometryType(),i,!0)),u>c?(t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):c>u?(e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)),g?3:2}postProcessResultPartsForCurves(e,t,s,n,r){r===Ft()&&a("curve_helper");for(let i=e;i!==t;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=s;i!==n;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=e;i!==t;i=i.getNextInChain()){const e=i.end.pt.sub(i.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(i.start.pt.equals(t.start.pt)&&i.end.pt.equals(t.end.pt)?s=1:i.start.pt.equals(t.end.pt)&&i.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=i.start.pt.equals(t.start.pt)?1:0;if(s||(s=i.end.pt.equals(t.end.pt)?2:0,s||(s=i.end.pt.equals(t.start.pt)?3:0,s||(s=i.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),o=e.dotProduct(n);let h;switch(s){case 1:case 2:h=o>0;break;case 3:case 4:h=o<0;break;default:a("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(In(i,t,r,!1))}continue}const n=this.parent.m_resultSegments[i.segmentIndex],o=this.parent.m_resultSegments[t.segmentIndex],h=[.5,.25,.75];for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new et;n.get().queryCoord2D(t,r);const i=o.get().getClosestCoordinate(r,!1),a=new et;o.get().queryCoord2D(i,a);if(et.distance(r,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new et;o.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),a=new et;n.get().queryCoord2D(i,a);if(et.distance(r,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}i.equalEdge=t,t.equalEdge=i;let m=i.rank,l=t.rank;m===l&&(m*=xn.c_maxGeometryTypeToRankDelta,l*=xn.c_maxGeometryTypeToRankDelta,m+=wn(n.get().getGeometryType(),n.get(),!0),l+=wn(o.get().getGeometryType(),o.get(),!0)),m>l||m===l&&i.segmentParentage<=t.segmentParentage?(n.copyTo(o,!1),t.segmentParentage=i.segmentParentage,-1===s&&o.get().reverse()):(o.copyTo(n,!1),i.segmentParentage=t.segmentParentage,-1===s&&n.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(s.start),n&&this.updateAttachedEdgesAfterNodeChange(n.start)}processDoublyConnectedEdges(e,t,s,n){s===Ft()&&a("curve_helper");const r=this.getSegment(e).get(),i=this.getSegment(t).get(),o=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY())?1:r.getEndXY().equals(i.getStartXY())&&r.getStartXY().equals(i.getEndXY())?-1:0;if(0!==o){const a=new k;r.queryCut(0,.5,a),a.get().snapControlPoints(n*n);const h=new k;r.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=a.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(a),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let m=i.getClosestCoordinate(e.end.pt,!1);return Math.abs(m-.5)>.2&&(m=.5),i.queryCut(0,m,a),a.get().snapControlPoints(n*n),i.queryCut(m,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=a.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(a),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),o>0?(this.m_pairs.push(In(e,t,s,!1)),this.m_pairs.push(In(e.getNextInChain(),t.getNextInChain(),s,!1))):(this.m_pairs.push(In(e,t.getNextInChain(),s,!1)),this.m_pairs.push(In(e.getNextInChain(),t,s,!1))),!0}return!1}newNode(e,t,s,n){const r=new Cn;return this.m_newNodes.push(r),r.pt=e,r.rank=s,r.weight=t,r.bIsBreak=n,r}newEdge(e,t,s,n,r,i){const o=new Sn;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=s,o.segmentParentage=i,o.rank=r,o.weight=n,o}splitEdgeInPlace(e){e.segmentIndex=-1;const t=new Sn,s=new Cn;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=t,s.prevInChain=e,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=e.weight,s.rank=e.rank,s.bIsBreak=!1,s.bBigMove=!1,t.start=s,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=s,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();null!==t;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){const t=e.prevInChain;if(t&&t.hasSegment()){const s=this.getSegment(t).get();e.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(t.start.pt,t.end.pt,!1),s.ensureXYMonotone())}const s=e.nextInChain;if(s&&s.hasSegment()){const t=this.getSegment(s).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(s.start.pt,s.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){const t=this.getSegment(e).get();e.start.pt.equals(t.getStartXY())&&e.end.pt.equals(t.getEndXY())||(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1;const s=[],n=[],r=[];for(let i=0,o=this.m_newNodes.length;i<o;i++){const e=this.m_newNodes[i];if(null===e)continue;let t=e;for(let s=i+1;s<o;s++){const n=this.m_newNodes[s];null!==n&&(e.pt.equals(n.pt)&&(t.nextInHash=n,n.prevInHash=t,t=n,this.m_newNodes[s]=null))}}for(let i=0,o=this.m_newNodes.length;i<o;i++){const o=this.m_newNodes[i];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const i=tt(4),a=this.hashTableBinsToCheck(o,i);for(let t=0;t<a;t++)if(null!==i[t])for(let a=i[t];null!==a;){const t=a.nextInHash;et.distance(o.pt,a.pt)<=e&&(s.push(a),this.removeNodeFromHash(a),a.hash=0,r.push(a),n.push(a)),a=t}let h=!1;for(const e of s)if(!o.pt.equals(e.pt)){const s=un(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,h=!0,t=!0}if(s.length=0,!h)break;o.hash=this.calculateHash(o.pt)}r.push(o),n.push(o);for(let e=o.nextInHash;null!==e;){e.prevInHash=null;const t=e.nextInHash;e.nextInHash=null,r.push(e),n.push(e),e=t}const a=o.hash;let h=null,m=null;for(const e of n)o!==e&&(e.hash=a,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=h,h&&(h.nextInHash=e),e.prevEqual=m,e.nextEqual=null,m&&(m.nextEqual=e),m=e,h=e;const l=a%this.m_hashTableOfEquals.length;h.nextInHash=this.m_hashTableOfEquals[l],null!==this.m_hashTableOfEquals[l]&&(this.m_hashTableOfEquals[l].prevInHash=h),this.m_hashTableOfEquals[l]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(const i of r)this.updateAttachedEdgesAfterNodeChange(i)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=tt(2*e.length),this.m_hashTableOfEqualsSize=0;for(const t of e){let e=t;for(;e;){const t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){const t=e.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[t];e.nextInHash=s,null!==s&&(s.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){const t=e.hash%this.m_hashTableOfEquals.length,s=e.prevInHash,n=e.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[t]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){const s=(e.pt.x-this.m_origin.x)/this.m_cell.x,n=(e.pt.y-this.m_origin.y)/this.m_cell.y,r=Tt()-1,i=Math.round(Pt(s,-r,r)),o=Math.round(Pt(n,-r,r));let a=i|o<<32;a=Qe(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let h=i+1|o<<32;h=Qe(h);let m=1;t[1]=this.m_hashTableOfEquals[h%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(m=2);let l=i+1|o+1<<32;l=Qe(l),t[m]=this.m_hashTableOfEquals[l%this.m_hashTableOfEquals.length];for(let u=0;u<m;u++)if(t[m]===t[u]){m--;break}m++;let g=i|o+1<<32;g=Qe(g),t[m]=this.m_hashTableOfEquals[g%this.m_hashTableOfEquals.length];for(let u=0;u<m;u++)if(t[m]===t[u]){m--;break}return m++,m}calculateHash(e){const t=(e.x-this.m_origin.x)/this.m_cell.x,s=(e.y-this.m_origin.y)/this.m_cell.y,n=Tt()-1;let r=Math.round(Pt(t,-n,n))|Math.round(Pt(s,-n,n))<<32;return r=Qe(r),0===r&&(r=1),r}processSharpCorners(e,t,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=ne(e,t,0,0,s,2,r,i,n);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(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=ne(e,t,1,1,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),o+1}}if(e.getStartXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=ne(e,t,0,1,s,2,r,i,n);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(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=ne(e,t,1,0,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),o+1}}return 0}}function wn(e,t,s){let n=0;switch(e){case i.enumLine:n=0;break;case i.enumBezier:n=2;break;case i.enumRationalBezier2:n=3;break;case i.enumBezier2:n=1;break;case i.enumEllipticArc:n=0===t.projectionBehavior()?5:4;break;default:a("")}return s?5-n:n}class vn extends on{constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=this.m_parent.getEdgeOriginVertices(t),i=this.m_parent.m_edgeVertices.getFirstElement(r),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(t,i,n,a)}}class Nn extends an{constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;const s=e.getElement(t),n=this.m_parent.getEdgeOriginVertices(s),r=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=t,this.compareVertex(e,t,r)}}class Tn extends We{constructor(e){super(),this.pt1=et.getNAN(),this.pt2=et.getNAN(),this.m_shape=e}compare(e,t,s){this.m_shape.queryXY(t,this.pt1);const n=e.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class Gn{constructor(e){this.m_point=et.getNAN(),this.m_pt=et.getNAN(),this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){const s=e.getElement(t);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Dn{constructor(e,t){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new Le(8),this.m_clusters=new Le(5),this.m_clusterVertices=new sn(!1),this.m_edgeVertices=new sn(!1),this.m_helperPoint=new ye,this.m_eventQ=new Ce,this.m_sweepStructure=new Ce,this.m_bComplications=!1,this.m_sweepComparator=null,this.m_tempEdgeBuffer=[],this.m_modifiedClusters=[],this.m_edgesToInsertInSweepStructure=[],this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1,this.m_progressCounter=0,this.m_segmentIntersector=new xn,this.m_segBuf1=new k,this.m_segBuf2=new k,this.m_sweepPoint=new et(0,0),this.m_tolerance=0,this.m_toleranceSqr=0,this.m_sweepPointCluster=-1,this.m_vertexClusterIndex=-1,this.m_bCracked=!1,this.m_bSweepPointClusterWasModified=!1,this.m_progressTracker=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){const s=new jt;s.setSwapCoordinates(),e.applyTransformation(s),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let n=this.sweepImpl_();return e.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,q);this.m_bComplications=1===n,s||=1===n}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,s){this.m_edges.setField(e,0+t,s)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,s){this.m_edges.setField(e,3+t,s)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+s)}setNextEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+n,s)}getPrevEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+s)}setPrevEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+n,s)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){const t=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(t,s),e!==q&&(this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){const s=this.getClusterVertices(e);this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){const t=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,s),-1!==e&&this.m_edgeVertices.addElement(s,e),t}addVertexToEdge_(e,t){const s=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(s,t)}deleteEdge_(e){this.m_edges.deleteElement(e);const t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&xt(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){-1===this.getEdgeCluster(e,0)?this.setEdgeCluster_(e,0,t):-1===this.getEdgeCluster(e,1)?this.setEdgeCluster_(e,1,t):a(""),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){const s=this.getClusterFirstEdge(t);if(-1!==s){const n=this.getNextEdge(s,t);this.setPrevEdge_(n,t,e),this.setNextEdge_(e,t,n),this.setNextEdge_(s,t,e),this.setPrevEdge_(e,t,s)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);const s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1));let n=this.getClusterFirstEdge(e),r=this.getClusterFirstEdge(t);if(-1!==r){let s=r,i=r,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,t),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===e){this.disconnectEdge_(s);const e=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(s),s===a){r=-1;break}r===s&&(r=this.getClusterFirstEdge(t),i=a,o=!0)}s=a}while(s!==i||o);if(-1!==r){do{const n=this.getEdgeEnd(s,t),r=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,e),s=r}while(s!==i);if(n=this.getClusterFirstEdge(e),-1!==n){const t=this.getNextEdge(n,e),s=this.getNextEdge(r,e);t===n?(this.setClusterFirstEdge_(e,r),this.addEdgeToClusterImpl_(n,e),this.setClusterFirstEdge_(e,n)):s===r&&this.addEdgeToClusterImpl_(r,e),this.setNextEdge_(r,e,t),this.setPrevEdge_(t,e,r),this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n)}else this.setClusterFirstEdge_(e,r)}}const i=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let a=this.m_clusterVertices.getFirst(o);-1!==a;a=this.m_clusterVertices.getNext(a)){const t=this.m_clusterVertices.getElement(a);this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(i,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);const s=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),a=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,a),t===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,e),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(s===r&&n===i||n===r&&s===i)){const e=this.getClusterXY(s),t=this.getClusterXY(r);e.isEqualPoint2D(t)?(s!==r&&this.mergeClusters_(s,r),n!==i&&this.mergeClusters_(n,i)):(n!==r&&this.mergeClusters_(n,r),s!==i&&this.mergeClusters_(s,i))}this.dbgCheckEdge_(e)}disconnectEdge_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,s)}disconnectEdgeFromCluster_(e,t){const s=this.getNextEdge(e,t),n=this.getPrevEdge(e,t),r=this.getClusterFirstEdge(t);s!==e?(this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n),r===e&&this.setClusterFirstEdge_(t,s)):this.setClusterFirstEdge_(t,-1)}applyIntersectorToEditShape_(e,t,s){let n=this.m_edgeVertices.getFirst(e);const r=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(r),o=this.m_shape.getNextVertex(r),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(r),m=this.m_shape.getXY(o);let l=!1,g=!1;const u=t.getResultSegment(s,0).getStartXY(),c=t.getResultSegment(s,t.getResultSegmentCount(s)-1).getEndXY();h.equals(u)||(l=!0),m.equals(c)||(g=!0),this.m_shape.splitSegmentWithIntersector(r,t,s,!0,!0);const _=this.m_bTrackChanges&&t.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(r,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const e=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(e)===i;this.m_shape.splitSegmentWithIntersector(e,t,s,r,!0),_&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(l&&this.updateClusterXY(!0,i,u,t.getResultSegmentStartPointWeight(s,0),t.getResultSegmentStartPointRank(s,0)),g){const e=t.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,c,t.getResultSegmentEndPointWeight(s,e),t.getResultSegmentEndPointRank(s,e))}}createEdgesAndClustersFromSplitEdge_(e,t,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(e),r=this.getEdgeCluster(e,0),i=this.getEdgeCluster(e,1);let o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);const a=Le.impossibleIndex3();this.setEdgeSweepNode_(o,a),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,r);const h=t.getResultSegmentCount(s);for(let m=1;m<h;m++){const e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);const t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,a),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,i);for(let m=this.m_edgeVertices.getFirst(n);-1!==m;m=this.m_edgeVertices.getNext(m)){let e=this.m_edgeVertices.getElement(m);if(this.getClusterFromVertex(e)===r){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,s){const n=this.getEdgeCluster(t,0),r=this.getClusterXY(n),i=this.getEdgeCluster(t,1),o=this.getClusterXY(i),a=s.getResultSegmentCount(e);let h=s.getResultSegment(e,0);const m=h.getStartXY();if(!r.isEqualPoint2D(m)){if(!this.m_bComplications){r.compare(this.m_sweepPoint)*m.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)}if(!this.m_bComplications&&a>1){const e=r.compare(o),t=h.getEndXY();(r.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}h=s.getResultSegment(e,a-1);const l=h.getEndXY();if(!o.isEqualPoint2D(l)){if(!this.m_bComplications){o.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(i,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(i)}this.m_tempEdgeBuffer.push(t);for(let g=0,u=this.m_tempEdgeBuffer.length;g<u;g++){const e=this.m_tempEdgeBuffer[g],s=this.getEdgeSweepNode(e);Le.isValidElement(s)&&(this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(e,-1));const n=Le.impossibleIndex3();e!==t&&this.getEdgeSweepNode(e)!==n&&(this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,n))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){const s=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,s,t),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0)}fixIntersection_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e),n=this.m_sweepStructure.getElement(t);let r=null,i=null;const o=this.getEdgeOriginVertices(s),a=this.m_edgeVertices.getFirstElement(o),h=this.getEdgeOriginVertices(n),m=this.m_edgeVertices.getFirstElement(h);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),g=this.m_shape.getWeight(a),u=this.m_shape.getSegmentParentageBreakVertex(a),c=this.m_shape.getWeight(l),_=this.m_shape.getSegmentParentageBreakVertex(l),d=this.m_shape.getSegmentWeight(a),p=this.m_shape.getRank(a),f=this.m_shape.getRank(l),x=this.m_shape.getSegmentRank(a),y=this.m_shape.getSegmentParentage(a);this.m_shape.querySegment(m,this.m_segBuf2,!1,!1),i=this.m_segBuf2.get();const P=this.m_shape.getNextVertex(m),E=this.m_shape.getWeight(m),S=this.m_shape.getSegmentParentageBreakVertex(m),C=this.m_shape.getWeight(P),I=this.m_shape.getSegmentParentageBreakVertex(P),b=this.m_shape.getSegmentWeight(m),w=this.m_shape.getRank(m),v=this.m_shape.getRank(P),N=this.m_shape.getSegmentRank(m),T=this.m_shape.getSegmentParentage(m);this.m_segmentIntersector.pushSegment(r,g,p,c,f,d,x,u,_,y),this.m_segmentIntersector.pushSegment(i,E,w,C,v,b,N,S,I,T),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,n,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t);let n=null;const r=this.getEdgeOriginVertices(s),i=this.m_edgeVertices.getFirstElement(r);this.m_shape.querySegment(i,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(i),a=this.m_shape.getWeight(i),h=this.m_shape.getSegmentParentageBreakVertex(i),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),g=this.m_shape.getSegmentWeight(i),u=this.m_shape.getRank(i),c=this.m_shape.getRank(o),_=this.m_shape.getSegmentRank(i),d=this.m_shape.getSegmentParentage(i),p=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(n,a,u,m,c,g,_,h,l,d),this.m_shape.queryPoint(p,this.m_helperPoint);const f=this.m_shape.getWeight(p),x=this.m_shape.getRank(p);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||t>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);Le.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==Le.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(e),-1===s){const t=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(t);return this.mergeEdges_(s,e),!1}if(this.setEdgeSweepNode_(e,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,s),!0}return!1}isEdgeOnSweepLine_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1),n=this.getClusterXY(t),r=this.getClusterXY(s);if(et.sqrDistance(n,r)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const i=n.compare(this.m_sweepPoint),o=r.compare(this.m_sweepPoint);return i<=0&&o>0?s:o<=0&&i>0?t:i>0&&o>0?Le.impossibleIndex2():-1}fillEventQueue(){const e=new be(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let r=t.next();r!==q;r=t.next())-1!==this.m_shape.getUserIndex(r,this.m_vertexClusterIndex)&&e.add(r);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 Tn(this.m_shape));const s=et.getNAN();s.setNAN();let n=-1;for(let r=0,i=e.size();r<i;r++){const t=e.read(r);if(this.m_shape.getXY(t).isEqualPoint2D(s)){const e=this.m_shape.getUserIndex(t,this.m_vertexClusterIndex);this.mergeClusters_(n,e);continue}n=this.getClusterFromVertex(t),this.m_shape.queryXY(t,s);const i=this.m_eventQ.addBiggestElement(t);this.setClusterEventQNode_(n,i)}}fillEventQueuePass2(){const e=new be(0);for(let t=this.m_eventQ.getFirst();-1!==t;t=this.m_eventQ.getNext(t)){const s=this.m_eventQ.getElement(t);e.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,s=e.size();t<s;t++){const s=e.read(t),n=this.getClusterFromVertex(s),r=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,r)}}getAffectedEdges(e,t){const s=this.getClusterFirstEdge(e);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);Le.isValidElement(s)&&t.push(n),n=this.getNextEdge(n,e)}while(n!==s)}updateClusterXY(e,t,s,n,r){const i=this.getClusterVertices(t);for(let o=this.m_clusterVertices.getFirst(i);-1!==o;o=this.m_clusterVertices.getNext(o)){const t=this.m_clusterVertices.getElement(o);this.m_shape.setXYMonotonicPoint2D(t,s),this.m_shape.setWeight(t,n),this.m_shape.setRank(t,r),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_shape.setSegmentParentageBreakVertex(t,!0)}}splitEdge_(e,t,s,n){this.dbgCheckEdge_(e),-1!==t&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),-1!==t&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,n),-1!==t&&this.processSplitHelper1_(1,t,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o],t=this.getClusterEventQNode(e);-1!==t&&(this.m_eventQ.deleteNode(t),this.setClusterEventQNode_(e,-1))}const r=this.getEdgeOriginVertices(e),i=-1!==t?this.getEdgeOriginVertices(t):-1;if(this.applyIntersectorToEditShape_(r,n,0),-1!==i)this.applyIntersectorToEditShape_(i,n,1);else{const e=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,e,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,n,0),-1!==t&&this.createEdgesAndClustersFromSplitEdge_(t,n,1),this.m_edgeVertices.deleteList(r),this.deleteEdge_(e),-1!==t&&(this.m_edgeVertices.deleteList(i),this.deleteEdge_(t));for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let t=this.getClusterEventQNode(e);if(-1===t){const s=this.getClusterFirstVertex(e);if(t=this.m_eventQ.addUniqueElement(s),-1===t){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),n=this.getClusterFromVertex(s);this.mergeClusters_(n,e)}else this.setClusterEventQNode_(e,t)}}this.m_modifiedClusters.length=0}getClusterXY(e){const t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new vn(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const e=[];let t=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=Le.impossibleIndex2(),r=Le.impossibleIndex3();for(let i=this.m_eventQ.getFirst();-1!==i;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(i);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===t,!a){let s=t;do{const t=this.getEdgeSweepNode(s);-1===t?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):t!==r&&e.push(t),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=1===e.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let r=0,i=e.length;r<i;r++){const t=this.m_sweepStructure.getElement(e[r]);this.setEdgeSweepNode_(t,n)}let t=n,s=n;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(t===n){const e=this.m_sweepStructure.getPrev(i);if(-1!==e){const s=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(s)!==n&&(t=e)}else t=-1}if(s===n){const e=this.m_sweepStructure.getNext(i);if(-1!==e){const t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==n&&(s=e)}else s=-1}if(t!==n&&s!==n)break}for(let n=0,r=e.length;n<r;n++){const t=e[n],s=this.m_sweepStructure.getElement(t);this.m_sweepStructure.deleteNode(t),this.setEdgeSweepNode_(s,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=s,-1!==t&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,s):-1===t&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===t&&(t=new Nn(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.getCurrentNode())));const h=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&h&&-1!==this.m_prevNeighbour&&-1!==this.m_nextNeighbour&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,null===s&&(s=new Gn(this.m_shape)),s.setPoint(this.m_sweepPoint),i=this.m_eventQ.searchUpperBound(s)):i=this.m_eventQ.getNext(i)}return this.m_bCracked}setEditShape_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==q;t=this.m_shape.getNextGeometry(t)){if(h(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==q;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===q)continue;let r=this.m_shape.getNextVertex(n);if(r===q||r===n)continue;let i=-1;e.selected(n)&&(i=this.newCluster_(n));let o=-1;-1!==i&&e.selected(r)&&(o=this.newEdge_(n),this.addEdgeToCluster(o,i));let a=o;for(let e=0,s=t-2;e<s;e++){const e=this.m_shape.getNextVertex(r);let t=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==a&&this.addEdgeToCluster(a,s),this.m_shape.selected(e)&&(t=this.newEdge_(r),this.addEdgeToCluster(t,s))}a=t,r=e}if(this.m_shape.isClosedPath(s)){const e=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const t=this.newCluster_(r);if(-1!==a&&this.addEdgeToCluster(a,t),this.m_shape.selected(e)){const e=this.newEdge_(r);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,i)}}}else{let e=-1;this.m_shape.selected(r)&&(e=this.newCluster_(r),-1!==a&&this.addEdgeToCluster(a,e))}}else for(let e=this.m_shape.getFirstPath(t);e!==q;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n;s++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function Vn(e,t,s,n){s>0&&mn(e,s,t,!1,n);new Hn(n).executeImpl_(e,t)}function Fn(e,t,s){return{vertex0:e,vertex1:t,dir:s}}class Hn{constructor(e){this.m_shape=null,this.m_spikes=[],this.m_points=new be(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let l=e.getFirstPath(t);l!==q;l=e.getNextPath(l)){let t=e.getFirstVertex(l);for(let s=0,n=e.getPathSize(l);s<n;s++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let l=0,g=this.m_points.size();l<g;++l)e.setUserIndex(this.m_points.read(l),this.m_pointsIndex,l);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const n=e.getXY(s);let r=1,i=0;const o=[];for(let l=1;l<this.m_points.size();l++){const t=this.m_points.read(l);if(t===q)continue;if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const a=e.getXY(t);if(a.isEqualPoint2D(n))r++;else{if(r>1){for(let t=i;t<l;t++){const s=this.m_points.read(t);if(-1===e.getUserIndex(s,this.m_pointsIndex))continue;const r=e.getNextVertex(s),i=e.getPrevVertex(s);if(s!==r&&!e.isEqualXYPoint2D(r,n)){const e=Fn(s,r,1);o.push(e)}if(s!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=Fn(s,i,-1);o.push(e)}}o.length>0&&this.processBunch_(o,n)}s=t,n.assign(a),r=1,i=l}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let a=e.getPointCount(t);for(let l=0;l<this.m_points.size();l++){const t=this.m_points.read(l);if(t===q)continue;if(-1!==e.getUserIndex(t,this.m_pointsIndex)){e.setUserIndex(t,this.m_pointsIndex,-1);continue}const s=e.getPathFromVertex(t);e.getFirstVertex(s)===t&&e.setFirstVertex(s,q),e.freeVertex(t),this.m_points.write(l,q),a--}const h=e.createPathUserIndex();let m=e.getPathCount(t);for(let g=0,u=this.m_points.size();g<u;++g){if(this.m_points.read(g)===q)continue;let s=this.m_points.read(g);if(-1!==e.getUserIndex(s,this.m_pointsIndex))continue;let n=e.getPathFromVertex(s),r=-1;if(2===e.getPathUserIndex(n,h)){n=q;for(let t=e.getNextVertex(s);t!==s;t=e.getNextVertex(t)){const r=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(r,h)){n=r,s=t;break}}n===q&&(n=e.insertPath(t,q),e.setClosedPath(n,!0),m++),l(n!==q)}e.setPathUserIndex(n,h,2),r=e.getFirstVertex(n);let i=0,o=!1,a=s;do{r===a&&(o=!0),e.setUserIndex(a,this.m_pointsIndex,1);const t=e.getPathFromVertex(a);t!==n&&(2!==e.getPathUserIndex(t,h)&&(e.setPathUserIndex(t,h,1),e.setFirstVertex(t,q)),e.setPathToVertex(a,n)),i++,a=e.getNextVertex(a)}while(a!==s);o||e.setFirstVertex(n,s),e.setPathSize(n,i)}for(let l=e.getFirstPath(t);l!==q;){const t=e.getNextPath(l);1!==e.getPathUserIndex(l,h)&&e.getFirstVertex(l)!==q||(e.removePathOnly(l),m--),l=t}e.setGeometryVertexCount(t,a),e.setGeometryPathCount(t,m),e.removePathUserIndex(h),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,s)=>{const n=this.m_shape.getXY(e.vertex1).sub(t),r=this.m_shape.getXY(s.vertex1).sub(t),i=et.compareVectors(n,r);return 0===i?e.dir<s.dir?-1:1:i});let s=0;const n=this.m_shape.getXY(e[0].vertex1);let r=1;const i=this.m_shape.hasCurves();for(let o=1,a=e.length;o<a;o++){const t=this.m_shape.getXY(e[o].vertex1);if(!(t.isEqualPoint2D(n)&&(r++,o+1<a))){if(2===r){const t=e[s],n=e[s+1],r=t.dir;if(r!==n.dir){let e=!0;if(i&&(e=!this.m_shape.isCurve(1===t.dir?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),e){if(1===r){const e=t.vertex0,s=n.vertex0;this.m_shape.setNextVertex(e,s),this.m_shape.setPrevVertex(s,e),this.m_shape.getPrevVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setPrevVertex(r,i),this.m_shape.setNextVertex(i,r),this.m_shape.getNextVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}else{const e=t.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(s,e),this.m_shape.getNextVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setNextVertex(r,i),this.m_shape.setPrevVertex(i,r),this.m_shape.getPrevVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(t),s=o,r=1}}e.length=0}}function kn(e){for(let t=e.getFirstGeometry();t!==q;t=e.getNextGeometry(t))if(h(e.getGeometryType(t)))return!0;return!1}function An(e,t,s,n){if(!kn(e))return!1;const r=new Bn(n);r.m_shape=e,r.m_tolerance=t,r.m_bTrackChanges=s;let i=!1;const o=e.hasCurves()?5:15;return i=e.getTotalPointCount()<o?r.crackBruteForce_():r.crackerPlaneSweep_(),i}function Mn(e,t,s,n,r){if(!kn(t))return!1;let i=new Bn(r);if(i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n,i.needsCrackingImpl_())return n&&n.assign(i.m_nonSimpleResult),!0;const o=new jt;o.setSwapCoordinates(),t.applyTransformation(o),i=new Bn(r),i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n;const a=i.needsCrackingImpl_();return t.applyTransformation(o),!!a&&(n&&n.assign(i.m_nonSimpleResult),!0)}function Un(e,t,s,n){const r=t.getGeometryType();if(h(r)){return new Bn(n).crackAWithBMultiPath_(e,t,s)}d("crack_A_with_B")}function qn(e,t){return{t:e,index:t}}class Bn{crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){const t=new jt;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1;const t=new k,n=new k,r=s.constructEmpty(),i=s.constructEmpty(),o=!1,a=new ye,h=new xn,m=this.m_shape.getTotalPointCount(),u=m*m*2,c=this.m_shape.queryVertexIteratorOnSelection();for(let s=c.next();s!==q;s=c.next()){const m=this.m_shape.getGeometryType(c.currentGeometry());let _=1,d=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(s);let E=!1,S=!1,C=null,I=!1;if(g(m))_=this.m_shape.getWeight(s),f=this.m_shape.getRank(s);else{if(C=this.getSegment_(s,t),null===C)continue;const e=this.m_shape.getVertexIndex(s);_=this.m_shape.getWeightWithIndex(e),f=this.m_shape.getRankWithIndex(e),p=this.m_shape.getSegmentWeightWithIndex(e),y=this.m_shape.getSegmentRankWithIndex(e),E=this.m_shape.getSegmentParentageBreakVertex(s);{const e=this.m_shape.getNextVertex(s);d=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const b=new Z({copy:c});let w=b.next();w!==q&&(w=b.next());let v=0;for(;w!==q;w=b.next()){if(0!==v){v--;continue}if(this.m_shape.getTotalPointCount()>u)return e;this.progress_();const m=this.m_shape.getGeometryType(b.currentGeometry());let N=null,T=!1,G=0,D=0,V=0,F=0,H=0,k=0,A=!1,M=!1;const U=this.m_shape.getSegmentParentage(w);if(g(m))G=this.m_shape.getWeight(w),F=this.m_shape.getRank(w);else{if(N=this.getSegment_(w,n),null===N)continue;const e=this.m_shape.getVertexIndex(w);G=this.m_shape.getWeightWithIndex(e),F=this.m_shape.getRankWithIndex(e),V=this.m_shape.getSegmentWeightWithIndex(e),k=this.m_shape.getSegmentRankWithIndex(e),A=this.m_shape.getSegmentParentageBreakVertex(w);{const e=this.m_shape.getNextVertex(w);D=this.m_shape.getWeight(e),H=this.m_shape.getRank(e),M=this.m_shape.getSegmentParentageBreakVertex(e)}if(N.queryLooseEnvelope(i),N.isDegenerate(this.m_tolerance)){if(!N.isDegenerate(0))continue;T=!0,N=null}}let B=0,O=0;if(null!==C&&null!==N){if(r.isIntersectingNe(i)){0!==K(!0,!0,C,N,this.m_tolerance,!0)&&(h.pushSegment(C,_,f,d,x,p,y,E,S,P),h.pushSegment(N,G,F,D,H,V,k,A,M,U),h.intersect2D(this.m_tolerance,!0),e||=h.getSegmentChanged(0)||h.getSegmentChanged(1),B=h.getResultSegmentCount(0),O=h.getResultSegmentCount(1),B+O>0&&(this.m_shape.splitSegmentWithIntersector(s,h,0,!0,!0),this.m_shape.splitSegmentWithIntersector(w,h,1,!0,!0),this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0))),O>1&&(v+=O-1),h.clear())}}else if(null!==C){const t=this.m_shape.getXY(w);if(r.contains(t)){if(h.pushSegment(C,_,f,d,x,p,y,E,S,P),this.m_shape.queryPoint(w,a),h.intersect2DEx(this.m_tolerance,a,F,G,o),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),B=h.getResultSegmentCount(0),B>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0)),this.m_shape.splitSegmentWithIntersector(s,h,0,!0,!0),T){let e=q;for(let t=this.m_shape.getNextVertex(w);t!==q&&t!==w&&(N=this.getSegment_(t,n),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=w;t!==q&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(w,h.getResultPoint(),!0);h.clear()}}else{if(null===N)continue;{const t=this.m_shape.getXY(s);if(i.inflateCoords(this.m_tolerance,this.m_tolerance),i.contains(t)){if(h.pushSegment(N,G,F,D,H,V,k,A,M,U),this.m_shape.queryPoint(s,a),h.intersect2DEx(this.m_tolerance,a,f,_,o),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),O=h.getResultSegmentCount(0),O>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(w,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(s,!0)),this.m_shape.splitSegmentWithIntersector(w,h,0,!0,!0),v+=O-1,I){let e=q;for(let t=this.m_shape.getNextVertex(s);t!==q&&t!==s&&(N=this.getSegment_(t,n),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=s;t!==q&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(s,h.getResultPoint(),!0);h.clear()}}}if(B+O!==0&&0!==B){let e=!1;for(;C=this.getSegment_(s,t),null!=C&&(C.queryEnvelope(r),C.isDegenerate(this.m_tolerance));){if(!(B>1)){e=!0;break}s=c.next(),B--,l(s!==q)}if(e)break}}}return e}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Dn(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1;const t=new be(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let a=0,g=s.next();g!==q;++a,g=s.next())t.write(a,g);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(q);const n=this.m_shape.createUserIndex(),r=this.m_shape.createUserIndex();this.m_sweepComparator=new on(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let i=null;const o=[],h=[];let m=0;const l=new et;for(let g=t.read(m++);g!==q;){this.m_shape.queryXY(g,l);let s=!1;do{let e=this.m_shape.getNextVertex(g),i=this.m_shape.getPrevVertex(g);s||=e!==q||i!==q,e===q||this.m_shape.selected(e)||(e=q),i===q||this.m_shape.selected(i)||(i=q),e!==q&&this.m_shape.compareVerticesSimpleY(g,e)<0&&(h.push(g),h.push(e)),i!==q&&this.m_shape.compareVerticesSimpleY(g,i)<0&&(h.push(i),h.push(i));const a=this.m_shape.getUserIndex(g,n);-1!==a&&(o.push(a),this.m_shape.setUserIndex(g,n,-1));const l=this.m_shape.getUserIndex(g,r);-1!==l&&(o.push(l),this.m_shape.setUserIndex(g,r,-1)),g=t.read(m++)}while(g!==q&&this.m_shape.isEqualXYPoint2D(g,l));if(!s&&(null===i&&(i=new an(this.m_shape,this.m_tolerance)),i.setPoint(l),this.m_sweepStructure.searchUpperBound(i),i.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(a("needsCrackingIMpl_"),this.m_nonSimpleResult=new ts(6,-1,-1));break}let u=1===o.length&&2===h.length;const c=32;o.length>c&&st(o);let _=-1,d=-1;if(!u)for(let t=0,n=o.length;t<n;t++){const s=o[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===o.indexOf(n))if(-1===_)_=n;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}const r=this.m_sweepStructure.getNext(s);if(-1!==r&&-1===o.indexOf(r))if(-1===d)d=r;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}if(-1!==_&&-1!==d)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(l.y,l.x),!u){for(let e=0,t=o.length;e<t;e++){const t=o[e];this.m_sweepStructure.deleteNode(t)}o.length=0}if(!u&&-1!==_&&-1!==d&&this.checkForIntersections_(_,d)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,i=h.length;t<i;t+=2){const s=h[t],i=h[t+1];let a;if(u?(a=this.m_sweepStructure.replaceElementAtPosition(o[0],s,!0,!0),o.length=0,u=!1):a=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}-1===this.m_shape.getUserIndex(i,n)?this.m_shape.setUserIndex(i,n,a):this.m_shape.setUserIndex(i,r,a)}if(e)break;h.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(r),e}checkForIntersections_(e,t){const s=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,s,t);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(e,t){return Bn.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,s){return e.querySegment(t,s,!1,!1)?s.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,n){const r=s.constructEmpty();e.queryLooseEnvelope(r);const o=s.constructEmpty();if(t.queryLooseEnvelope(o),o.inflateCoords(n,n),!o.isIntersecting(r))return e;const a=e.getImpl(),h=a.getAccelerators();let m=null,g=null;h&&(g=h.getQuadTree()),On(e,c(t))&&(m=He(a,o),g=m);const u=g?g.getIteratorForQT():null,_=t.querySegmentIterator(),d=e.querySegmentIterator(),p=$e(15,Number.NaN),f=[];for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment();if(g){u.resetIterator(e,n);for(let t=u.next();-1!==t;t=u.next()){this.progress_();const s=g.getElement(t);if(d.resetToVertex(s,-1),d.hasNextSegment()){const t=d.nextSegment().intersect(e,null,p,null,n);for(let e=0;e<t;e++){const t=p[e];if(0===t||1===t)continue;const s=qn(t,d.getStartPointIndex());f.push(s)}}}}else{const t=s.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(d.resetToFirstPath();d.nextPath();)for(;d.hasNextSegment();){const r=d.nextSegment(),i=s.constructEmpty();if(r.queryLooseEnvelope(i),!i.isIntersecting(t))continue;const o=r.intersect(e,null,p,null,n);for(let e=0;e<o;e++){const t=p[e];if(0===t||1===t)continue;const s=qn(t,d.getStartPointIndex());f.push(s)}}}}if(0===f.length)return e;f.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:e.t>t.t?1:0);const x=e.createInstance();if(x.getGeometryType()===i.enumPolygon){x.setFillRule(e.getFillRule())}for(d.resetToFirstPath();d.nextPath()&&!d.hasNextSegment(););l(d.hasNextSegment());let y=d.nextSegment();const P=new k;let E=-1;for(let s=0,i=f.length;s<i;){const e=f[s].index;let t=s+1;for(;t<i&&f[t].index===e;)++t;for(;d.getStartPointIndex()<e;){this.progress_();const e=d.hasNextSegment(),t=d.getPathIndex();if((e||!d.isClosingSegment()||d.isCurve())&&(l(null!==y),x.addSegment(y,E!==t)),E=t,!e){for(d.isPathClosed();d.nextPath()&&!d.hasNextSegment(););l(d.hasNextSegment())}y=d.nextSegment()}let n=0;for(let i=s;i<t;i++){const e=f[i].t;if(e===n)continue;l(null!==y),y.queryCut(n,e,P),n=e;const t=d.getPathIndex();x.addSegment(P.get(),E!==t),E=t}const r=d.hasNextSegment();if((r||!d.isClosingSegment()||d.isCurve())&&(l(null!=y),y.queryCut(n,1,P),x.addSegment(P.get(),!1)),r)y=d.nextSegment();else{for(;d.nextPath()&&!d.hasNextSegment(););y=d.hasNextSegment()?d.nextSegment():null}s=t}if(null!==y){const e=d.getPathIndex();(d.hasNextSegment()||!d.isClosingSegment()||d.isCurve())&&x.addSegment(y,E!==e),E=e}let S=d.hasNextSegment();for(;;){if(!S){for(;d.nextPath()&&(S=d.hasNextSegment(),!S););if(!S)break}y=d.nextSegment();const e=d.getPathIndex();S=d.hasNextSegment();(S||!d.isClosingSegment()||d.isCurve())&&x.addSegment(y,E!==e),E=e}return x}constructor(e){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new ts,this.m_tolerance=0,this.m_sweepComparator=null,this.m_progressCounter=0,this.m_bTrackChanges=!1,this.m_bNeedsNonSimpleResult=!1,this.m_bAllowCoincident=!0,this.m_sweepStructure=new Ce,this.m_progressTracker=e}}function On(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}Bn.s_bForceBruteForce=!0;class Yn{constructor(e,t){this.m_monotoneParts=gt(k,16),this.m_xOrds=$e(16,Number.NaN),this.m_inputPoint=et.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY())))return void(this.m_bBreak=!0);if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const t=Math.min(e.getStartX(),e.getEndX()),s=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let t=!1;const s=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>s)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){const n=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);t=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){const t=e.getClosestCoordinate(this.m_inputPoint,!1),s=e.getCoord2D(t);return et.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){const t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let s=0;if(e.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=e.getMonotonicParts(this.m_monotoneParts,!0),l(this.m_monotoneParts.length>=s)),s>0)for(let n=0;n<s;n++){const e=this.m_monotoneParts[n].get(),t=at.construct(e.getStartY(),e.getEndY());if(!(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return l(0),2}}function Rn(e,t,n,r){const i=new s;e.queryLooseEnvelope(i),i.inflateCoords(r,r);const o=0===e.getFillRule(),a=new Yn(o,r);a.setInputPoint(n);const h=i.clone();h.xmax=n.x+r,h.ymin=n.y-r,h.ymax=n.y+r;const m=e.getImpl().querySegmentIterator(),l=t.getIterator(h,r);for(let s=l.next();-1!==s;s=l.next())if(m.resetToVertex(t.getElement(s),-1),m.hasNextSegment()){const e=m.nextSegment();if(a.processSegment(e))return-1}return a._Result()?1:0}function Xn(e,t,s){const n=0===e.getFillRule(),r=new Yn(n,s);r.setInputPoint(t);const i=e.getImpl().querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(r.processSegment(e))return-1}return r._Result()?1:0}function Ln(e,t,s){return t.isEmpty()?0:zn(e,t.getXY(),s)}function zn(e,t,n){if(e.isEmpty())return 0;const r=s.constructEmpty();if(e.queryLooseEnvelope(r),r.inflateCoords(n,n),!r.contains(t))return 0;const i=e.getImpl().getAccelerators();if(i){i.getRasterizedGeometry()&&l(0);const s=i.getQuadTree();if(s)return Rn(e,s,t,n)}return Xn(e,t,n)}function Wn(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}function jn(e,t,s,n,r){const i=new $n(r);return i.m_shape=e,i.m_geometry=t,i.m_sortedVertices=s,i.m_bFixSelfTangency=n,i.fixRingOrientation_()}function Zn(e,t,s){const n=new $n(s);return n.m_shape=e,n.m_geometry=t,n.m_sortedVertices=null,n.m_bFixSelfTangency=!1,n.fixRingOrientationForMp2sp_()}class Kn{getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?s:t}constructor(e){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),s=this.getEnd2(e);this.m_shape.getPrevVertex(t)===s&&(s=ht(t,t=s));const n=et.getNAN(),r=et.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),l(!n.equals(r)),n.y<r.y}getStart(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?t:s}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(-1!==this.m_firstFree){const t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}const t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let Qn=class extends We{constructor(e){super(),this.m_line1=new A,this.m_line2=new A,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges;let i;if(this.m_leftElm===t)i=this.m_leftx;else{if(this.m_seg1=r.getSegment(t),this.m_seg1)i=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,i=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}this.m_leftx=i,this.m_leftElm=t}let o,a=r.getSegment(n);if(a)o=a.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(n),this.m_line2,!0),a=this.m_line2,o=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}if(i===o){const e=r.isBottomUp(t),s=r.isBottomUp(n),h=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),m=s?a.getEndY():a.getStartY(),l=Math.min(h,m);let g=.5*(l+this.m_helper.m_yScanline);g===this.m_helper.m_yScanline&&(g=l),i=this.m_seg1.intersectionOfYMonotonicWithAxisX(g,0),o=a.intersectionOfYMonotonicWithAxisX(g,0),i===o&&S("")}return i<o?-1:i>o?1:0}reset(){this.m_leftElm=-1}};class Jn{constructor(e){this.m_node=-1,this.m_index=0,this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const e=this.m_node;if(-1===e)return q;const t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){const e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return q}}class $n{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new Ce,this.m_yScanline=0,this.m_geometry=q,this.m_unknownRingOrientationCount=-1,this.m_sortedVertices=null,this.m_sortedVerticesArray=null,this.m_unknownNodes=[],this.m_node1UserIndex=-1,this.m_node2UserIndex=-1,this.m_pathOrientationIndex=-1,this.m_pathParentageIndex=-1,this.m_pathParentsIndex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_progressTracker=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new Qn(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const e=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||(this.m_edges=new Kn(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let s=0,n=e.length;s<n;s++){-1!==e[s]&&t++}(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let s=0,n=e.length;s<n;s++){const t=e[s];t!==q&&this.insertEdge_(t,-1)}for(let s=0;s<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;s++){const e=this.m_unknownNodes[s],n=this.m_AET.getElement(e),r=this.m_edges.getPath(n),i=this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex);let o=q;if(0===i){let s=this.m_AET.getPrev(e),n=e,r=!1;for(;s!==Ce.st_nullNode();){const e=this.m_AET.getElement(s),t=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){o=t;break}n=s,s=this.m_AET.getPrev(s)}if(s===Ce.st_nullNode())r=!0,s=n;else{const e=this.m_AET.getElement(s);r=this.m_edges.isBottomUp(e),s=this.m_AET.getNext(s),r=!r}do{const e=this.m_AET.getElement(s),i=this.m_edges.getPath(e);if(0===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(e)){const e=this.m_shape.getFirstVertex(i);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(i,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(i,this.m_pathOrientationIndex,r?3:2),!r){let e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);2===e?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),l(3===e)):l(3===e);const t=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,i),this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(i,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}o=i,n=s,s=this.m_AET.getNext(s),r=!r}while(n!==e)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),r=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const e=this.m_AET.getElement(n);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==r){const e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let i=-1;-1!==n&&-1!==r?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(r),e[t]=q):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=q)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=et.getNAN(),n=et.getNAN();this.m_shape.queryXY(e,s);const r=this.m_shape.getNextVertex(e);this.m_shape.queryXY(r,n);let i=!1;if(s.y<n.y){i=!0;const s=this.m_edges.newEdge(e);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(r,this.m_node1UserIndex)?this.m_shape.setUserIndex(r,this.m_node1UserIndex,n):this.m_shape.setUserIndex(r,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,n),s.y<n.y){i=!0;const s=this.m_edges.newEdge(o);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,n):this.m_shape.setUserIndex(o,this.m_node2UserIndex,n);const r=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return i}fixRingSelfTangency_(){const e=[],t=[];let s=-1,n=-1;const r=new et;let i=q,o=q,a=-1;const h=new Jn(this);for(let m=h.next();m!==q;m=h.next()){const h=new et;this.m_shape.queryXY(m,h);const l=this.m_shape.getPathFromVertex(m);if(r.equals(h)&&o===l){if(-1===n&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),n=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,n,-1)),-1===a){a=t.length,this.m_shape.setUserIndex(i,n,a),t.push(1);-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,i),e.push(l))}this.m_shape.setUserIndex(m,n,a),t[t.length-1]++}else a=-1,r.assign(h);i=m,o=l}if(0===e.length)return!1;l(-1!==s);for(let m=0,l=e.length;m<l;m++){const r=e[m];let i=this.m_shape.getPathUserIndex(r,s);const o=this.m_shape.getUserIndex(i,n),a=[],h=[];a.push(i),h.push(o);for(let e=this.m_shape.getNextVertex(i);e!==i;e=this.m_shape.getNextVertex(e)){const s=e,r=this.m_shape.getUserIndex(s,n);if(-1!==r){if(0===h.length){h.push(r),a.push(s);continue}if(h.at(-1)===r){const o=a.at(-1);this.m_shape.peelALoopIntoAPath(o,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,h.pop(),a.pop()),i=o,e=o}else a.push(e),h.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const s={stack:[],error:void 0,hasError:!1};try{let t,n=!1;const r=e(s,Gt(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new be(0);for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==q;s=this.m_shape.getNextPath(s)){let e=this.m_shape.getFirstVertex(s);for(let n=0,r=this.m_shape.getPathSize(s);n<r;n++)t.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(t,0,e),this.progress_(!0),this.m_sortedVerticesArray=t}else r.bForget=!0;if(this.m_bFixSelfTangency&&(n=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){const t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==q;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const o=et.getNAN();this.m_unknownRingOrientationCount=this.m_shape.getPathCount(this.m_geometry),this.m_node1UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node1UserIndex,-1),this.m_node2UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node2UserIndex,-1);const a=new Jn(this);for(let e=a.next();e!==q&&(this.progress_(),this.m_shape.queryXY(e,o),o.y!==this.m_yScanline&&i.length&&(n=this.processBunchForRingOrientationTest_(i)||n,this.m_sweepComparator.reset(),i.length=0),i.push(e),this.m_yScanline=o.y,0!==this.m_unknownRingOrientationCount);e=a.next());return this.m_unknownRingOrientationCount>0&&(n=this.processBunchForRingOrientationTest_(i)||n,i.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),n}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==q;)if(this.progress_(),3===this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){this.m_shape.setExterior(t,!0);for(let r=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);r!==q;){const s=this.m_shape.getPathUserIndex(r,this.m_pathParentageIndex);e.push(r),this.m_shape.setExterior(r,!1),this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,t),r=s}let s=t,n=e.length;for(let e=this.m_shape.getNextPath(t);n>0&&e!==q;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=q;break}s=e}if(0!==n){s=t;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,je),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}e.length=0,t=this.m_shape.getNextPath(s)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const e=this.m_shape.createPathUserIndex();let t=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==q;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,e,t),t++;for(let e=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e!==q;){const t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,n),e=t}let r=n,i=s.length,o=t;for(let t=this.m_shape.getNextPath(n);i>0&&t!==q;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=q;break}r=t,this.m_shape.setPathUserIndex(t,e,-o),o++}if(0!==i){r=n,o=t;for(let t=0,n=s.length;t<n;t++){const n=s[t];this.m_shape.setPathUserIndex(n,e,-o),o++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,je)}r=n}t=o,s.length=0,n=this.m_shape.getNextPath(r)}else n=this.m_shape.getNextPath(n);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function er(e,t,s,n,r,i){const o=new tr(i);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=r,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class tr{constructor(e){this.m_shape=null,this.m_geometry=q,this.m_sortedVertices=new Se,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_sorterSegmentBuffer1=null,this.m_sorterSegmentBuffer2=null,this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=q,this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_bHasSegmentParentage=!1,this.m_bHasSegments=!1,this.m_progressTracker=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=new et;this.m_shape.queryXY(s,n);const r=new et,i=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(i,r),n.equals(r))return 0;const o=this.m_bunchEdgeCenterPoints[e],a=new et;this.m_shape.queryXY(o,a);const h=this.m_bunchEdgeCenterPoints[t],m=new et;this.m_shape.queryXY(h,m);const l=new et;l.setSub(n,a);const g=new et;g.setSub(r,m),(l.isZero()||g.isZero())&&S("");return et.compareVectors(l,g)}compareAnglesCurves_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeEndPoints[t],r=this.m_bunchEdgeCenterPoints[e],i=this.m_bunchEdgeCenterPoints[t],o=this.m_shape.getNextVertex(r)===s,a=this.m_shape.getNextVertex(i)===n,h=o?this.m_shape.isCurve(r):this.m_shape.isCurve(s),m=a?this.m_shape.isCurve(i):this.m_shape.isCurve(n);if(!h&&!m)return this.compareAnglesLines_(e,t);this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new k),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new k),o?this.m_shape.querySegment(r,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(s,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),a?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse());return O(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())}beforeRemoveVertex_(e,t){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(e),t){const t=this.m_shape.getPathFromVertex(e);if(t!==q){if(this.m_shape.getFirstVertex(t)===e){const s=this.m_shape.getNextVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s);{const s=this.m_shape.getPrevVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s)}}}this.m_shape.setFirstVertex(t,q),this.m_shape.setLastVertex(t,q)}}}}processBunch_(){let e=!1;const t=new et(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,n=0,r=!0;for(;s!==this.m_nextVertexToProcess;){const e=this.m_sortedVertices.getData(s);r&&(this.m_shape.queryXY(e,t),r=!1);const i=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex)!==je&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,je),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++));this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==je&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,je),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),s=this.m_sortedVertices.getNext(s)}if(this.m_bunchEdgeEndPoints.length<2){1===this.m_bunchEdgeEndPoints.length&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e],s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,e)}const i=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e];if(-1===t)continue;const s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!i)break;e=!0}return e}processCrossOvers_(e){let t=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,o=this.m_bunchEdgeIndices.length;i<o&&-1!==n&&-1!==r&&n!==r;i++){const i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[r],a=this.m_bunchEdgeEndPoints[i],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a),l=!0);let g=this.m_shape.getNextVertex(h),u=!1;this.m_shape.isEqualXYPoint2D(g,e)||(g=this.m_shape.getPrevVertex(h),u=!0);const c=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=u?this.m_shape.getPrevVertex(g):this.m_shape.getNextVertex(g);let d=!1;(this.removeSpike_(m)||this.removeSpike_(g)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(c)||this.removeSpike_(_))&&(d=!0),m!==g&&(!d&&this.m_shape.isEqualXY(a,h)&&(d=this.resolveOverlap_(l,u,m,a,g,h)),!d&&this.m_shape.isEqualXY(c,_)&&(d=this.resolveOverlap_(!l,!u,m,c,g,_)),!d&&this.m_shape.isEqualXY(a,_)&&(d=this.resolveOverlap_(l,!u,m,a,g,_)),!d&&this.m_shape.isEqualXY(c,h)&&(d=this.resolveOverlap_(!l,u,m,c,g,h))),d&&(t=!0),s||=d,n=d?this.getNextEdgeIndex_(n):r,r=this.getNextEdgeIndex_(n)}}if(!t){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let r=0,i=this.m_bunchEdgeIndices.length;r<i&&-1!==s&&-1!==n&&s!==n;r++){const r=this.m_bunchEdgeIndices[s],i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[r],a=this.m_bunchEdgeEndPoints[i];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),g=this.getDirection_(m,a),u=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),c=g?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,g,o,h,u,a,m,c);1!==_?0===_?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):t=!0}}return t}simplify_(){if(this.m_shape.getGeometryType(this.m_geometry)===i.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)){new Ka(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0)}let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const t=this.m_shape.getPointCount(this.m_geometry),s=new be(0);this.m_shape.dbgVerifyMonotone();for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==q;i=this.m_shape.getNextPath(i)){let e=this.m_shape.getFirstVertex(i);for(let t=0,n=this.m_shape.getPathSize(i);t<n;t++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let i=0;i<t;i++){const e=s.read(i),t=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,t)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let n=0,r=!1;do{r=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new et(0,0);this.m_firstCoincidentVertex!==Se.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,i=this.m_firstCoincidentVertex;for(;i!==Se.st_nullNode()&&(i=this.m_sortedVertices.getNext(i),i!==Se.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(i),n=et.getNAN();if(this.m_shape.queryXY(e,n),t.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=i;const e=this.processBunch_();i=this.m_nextVertexToProcess,i!==Se.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(i),n),e&&(r=!0)}t.setCoordsPoint2D(n),this.m_firstCoincidentVertex=i,s=0}}if(this.m_nextVertexToProcess=-1,s>0){this.processBunch_()&&(r=!0)}n++>10&&a(""),r&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(r=!0),e||=r}while(r);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=jn(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,s,n,r,i,o,a){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(i),-1;const h=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),m=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),g=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),u=$e(8,Number.NaN),c=$e(4,Number.NaN);u[0]=0,c[0]=h,u[1]=0,c[1]=m,u[2]=1,c[2]=l,u[3]=1,c[3]=g;for(let d=1;d<4;d++){const e=c[d],t=u[d];let s=d-1;for(;s>=0&&c[s]>e;)c[s+1]=c[s],u[s+1]=u[s],s--;c[s+1]=e,u[s+1]=t}let _=0;if(u[0]&&(_|=1),u[1]&&(_|=2),u[2]&&(_|=4),u[3]&&(_|=8),5!==_&&10!==_)return 0;if(e!==t&&(a=ht(i,i=a)),e)this.m_shape.setNextVertex(a,n),this.m_shape.setPrevVertex(n,a),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,n),this.m_shape.setNextVertex(n,a),this.m_shape.setPrevVertex(r,o),this.m_shape.setNextVertex(o,r),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const r=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,r),this.m_shape.setSegmentToIndex(t,s)}}return 1}resolveOverlap_(e,t,s,n,r,i){return this.resolveOverlapOddEven_(e,t,s,n,r,i)}resolveOverlapOddEven_(e,t,s,n,r,i){if(e!==t){e||(r=ht(s,s=r),i=ht(n,n=i));const t=this.m_shape.getNextVertex(r),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,t),this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(s),t=this.m_shape.getVertexIndex(r),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(s),t=this.m_shape.getSegmentParentage(r);this.m_shape.setSegmentParentageAndBreak(s,t,!0),this.m_shape.setSegmentParentageAndBreak(r,e,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}this.removeSpike_(r)}else{const o=e?s:n,a=t?r:i,h=e?n:s,m=t?i:r;let l=null;if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);const t=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(t,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let g=-1;this.m_bHasSegmentParentage&&(g=this.m_shape.getSegmentParentage(m));let u=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(h,m),this.m_shape.setPrevVertex(m,h);let c=m;for(;c!==a;){const e=this.m_shape.getPrevVertex(c),t=this.m_shape.getNextVertex(c);if(this.m_shape.setPrevVertex(c,t),this.m_shape.setNextVertex(c,e),u||=c===o,this.m_bHasSegments&&c!==o){const e=this.m_shape.getVertexIndex(t),s=l;l=this.m_shape.getSegmentFromIndex(e),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(e,s)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,g),g=e}c=t}let _=null;if(!u){const e=this.m_shape.getPrevVertex(a),t=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,t),this.m_shape.setNextVertex(a,e),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let d=-1,p=-1;if(this.m_bHasSegmentParentage&&(d=u?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(h)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(m,h),this.beforeRemoveVertex_(m,!0),this.m_shape.removeVertexInternal(m,!0),this.removeAngleSortInfo_(h),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,d,!0),this.m_shape.setSegmentParentageAndBreak(h,p,!0)),_){const e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,_)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==q;){const s=this.m_shape.getNextPath(t);let n=this.m_shape.getFirstVertex(t);for(let r=0,i=this.m_shape.getPathSize(t);r<i&&i>1;){this.progress_();const{v:s,bModified:o}=this.checkAndCleanupSpike_(t,n);if(s===q)break;o?(e=!0,n=s,r=0,i=this.m_shape.getPathSize(t)):(n=s,r++)}t=s}return e}checkAndCleanupSpike_(e,t){const s={v:q,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=q,o=q;for(;this.m_shape.isEqualXY(n,r)&&(i=n,o=r,r!==t);)n=this.m_shape.getPrevVertex(n),r=this.m_shape.getNextVertex(r);if(i===q)return s.v=r,s;s.bModified=!0;for(let a=this.m_shape.getNextVertex(i);this.beforeRemoveVertex_(a,!1),a!==o;a=this.m_shape.getNextVertex(a));if(i===t)return this.m_polylineDegeneracies!==q?this.m_shape.movePath(this.m_polylineDegeneracies,q,e):this.m_shape.removePath(e),s.v=q,s;{const e=this.m_shape.peelALoopIntoAPath(i,o);this.m_polylineDegeneracies!==q?this.m_shape.movePath(this.m_polylineDegeneracies,q,e):this.m_shape.removePath(e)}return s.v=i,s}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(e),n=q,r=q;for(;this.m_shape.isEqualXY(t,s)&&(n=t,r=s,s!==e);)t=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(s);if(n===q)return!1;if(this.m_shape.peelALoop(n,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===q)for(let i=this.m_shape.getNextVertex(r);;){const e=this.m_shape.getNextVertex(i);if(this.removeAngleSortInfo_(i),this.beforeRemoveVertex_(i,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(i),null),this.m_shape.removeVertexInternal(i,!1),i===r)break;i=e}else{for(let t=r;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===r)break}const e=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,q,r,r,e)}return!0}fixOrphanVertices_(){let e=0;for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const e=this.m_sortedVertices.getData(n);this.m_shape.setPathToVertex(e,q)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==q;){const s=this.m_shape.getFirstVertex(n);if(s===q||this.m_shape.getPathFromVertex(s)!==q){const e=n;n=this.m_shape.getNextPath(n),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(s,n);let r=1;for(let e=this.m_shape.getNextVertex(s);e!==s;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,n),r++;this.m_shape.setRingAreaValid(n,!1),this.m_shape.setPathSize(n,r),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(s)),t+=r,e++,n=this.m_shape.getNextPath(n)}for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const s=this.m_sortedVertices.getData(n);if(this.m_shape.getPathFromVertex(s)!==q)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,q,s,s,r);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let s=0;for(let n=this.m_shape.getFirstGeometry();n!==q;n=this.m_shape.getNextGeometry(n))s+=this.m_shape.getPointCount(n);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}getPrevEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}transferVertexData_(e,t){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(e){const t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);-1!==t&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function sr(e,t,r,o,a,h=!0){switch(ir(o)){case 0:break;case 1:n("relation string length has to be 9 characters");break;default:n("relation string")}if(h){const s=xr(o,e.getDimension(),t.getDimension());if(0!==s)return kr(e,t,r,s,a)}let m=0;if("number"==typeof r)m=r;else{const n=s.constructEmpty();e.queryEnvelope(n);const i=s.constructEmpty();t.queryEnvelope(i);const o=s.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(i),m=ue(r,o,!1)}const l=Tr(e,m),g=Tr(t,m);if(l.isEmpty()||g.isEmpty())return fr(l,g,o);const u=l.getGeometryType(),c=g.getGeometryType();let _=!1;switch(u){case i.enumPolygon:switch(c){case i.enumPolygon:_=or(l,g,m,o,a);break;case i.enumPolyline:_=ar(l,g,m,o,a);break;case i.enumPoint:_=ur(l,g,m,o);break;case i.enumMultiPoint:_=hr(l,g,m,o,a)}break;case i.enumPolyline:switch(c){case i.enumPolygon:_=ar(g,l,m,Gr(o),a);break;case i.enumPolyline:_=mr(l,g,m,o,a);break;case i.enumPoint:_=cr(l,g,m,o,a);break;case i.enumMultiPoint:_=lr(l,g,m,o,a)}break;case i.enumPoint:switch(c){case i.enumPolygon:_=ur(g,l,m,Gr(o));break;case i.enumPolyline:_=cr(g,l,m,Gr(o),a);break;case i.enumPoint:_=dr(l,g,m,o);break;case i.enumMultiPoint:_=_r(g,l,m,Gr(o))}break;case i.enumMultiPoint:switch(c){case i.enumPolygon:_=hr(g,l,m,Gr(o),a);break;case i.enumPolyline:_=lr(g,l,m,Gr(o),a);break;case i.enumMultiPoint:_=gr(l,g,m,o,a);break;case i.enumPoint:_=_r(l,g,m,o)}break;default:_=!1}return _}function nr(e,t,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaAreaPredicates_();const o=s.constructEmpty(),a=s.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,n)&&(i.areaAreaDisjointPredicates_(e,t),h=!0),h||Br(e,t),h){return pr(i.m_matrix,i.m_scl)}let m=new V,l=m.addGeometry(e),g=m.addGeometry(t),u=null,c=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){u=new fa;const e=_a(n,m.getEnvelope2D(r));c=pa(e,0),aa(m,e,n,12e3,u,null,r)}ya(m,new Pe(n,0).add(c),r,!1,!1);const _=m.getGeometry(g).getBoundary();if(m.filterClosePoints(0,!0,!0,!1,q),er(m,l,-1,!1,q,r),0===m.getPointCount(l))return!1;er(m,g,-1,!1,q,r),i.setEditShape_(m,r);const d=0===m.getPointCount(g);if(!d){i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();const e=pr(i.m_matrix,i.m_scl);if(!e)return e}const p=m.getGeometry(l);m=new V,l=m.addGeometry(p),g=m.addGeometry(_),i.setEditShape_(m,r),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(d?"T*****F**":"******F**"),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();return pr(i.m_matrix,i.m_scl)}function rr(e,t,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaLinePredicates_();const o=s.constructEmpty(),a=s.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,n)&&(i.areaLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),h){return pr(i.m_matrix,i.m_scl)}const m=new V,l=m.addGeometry(e),g=m.addGeometry(t);if(i.setEditShapeCrackAndCluster_(m,new Pe(n,0),r),0===m.getPointCount(l))return!1;i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();return pr(i.m_matrix,i.m_scl)}function ir(e){if(9!==e.length)return 1;for(let t=0;t<9;t++){const s=e[t];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function or(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaAreaPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaAreaDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function ar(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaLinePredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),wr(a,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function hr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaPointPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaPointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function mr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLineLinePredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.lineLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),wr(r,o.m_topoGraph,o.m_clusterIndexA),wr(a,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function lr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLinePointPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.linePointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),wr(r,o.m_topoGraph,o.m_clusterIndexA),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function gr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setPointPointPredicates_();const a=new s,h=new s;e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.pointPointDisjointPredicates_(),m=!0),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function ur(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaPointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);const h=t.getXY();let m=!1;if(Or(h,a,n)&&(o.areaPointDisjointPredicates_(e),m=!0),!m){const t=Lo(e,h,n);if(1===t)o.m_matrix[0]=0,o.m_matrix[2]=2,o.m_matrix[3]=-1,o.m_matrix[5]=1,o.m_matrix[6]=-1;else if(2===t){o.m_matrix[6]=-1;if(0!==e.calculateArea2D())o.m_matrix[0]=-1,o.m_matrix[3]=0,o.m_matrix[2]=2,o.m_matrix[5]=1;else{o.m_matrix[0]=0,o.m_matrix[3]=-1,o.m_matrix[5]=-1;const t=s.constructEmpty();e.queryEnvelope(t),o.m_matrix[2]=t.height()||t.width()?1:-1}}else o.areaPointDisjointPredicates_(e)}return pr(o.m_matrix,r)}function cr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLinePointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);let h=!1;if(Or(t.getXY(),a,n)&&(o.linePointDisjointPredicates_(e),h=!0),!h){let s=null,r=!1,a=!1;if(o.m_performPredicates[0]||o.m_performPredicates[6]){!kr(e,t,n,4,i)?(o.m_performPredicates[0]&&(s=F(e),a=!kr(s,t,n,4,i),r=!0,o.m_matrix[0]=a?-1:0),o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[6]=0)}if(o.m_performPredicates[3]&&(null!==s&&s.isEmpty()?o.m_matrix[3]=-1:(r||(null==s&&(s=F(e)),a=!kr(s,t,n,4,i),r=!0),o.m_matrix[3]=a?0:-1)),o.m_performPredicates[5])if(null!==s&&s.isEmpty())o.m_matrix[5]=-1;else if(r&&!a)o.m_matrix[5]=0;else{null===s&&(s=F(e));const r=kr(s,t,n,3,i);o.m_matrix[5]=r?-1:0}if(o.m_performPredicates[2]){if(0!==e.calculateLength2D())o.m_matrix[2]=1;else{const s=new G({vd:e.getDescription()});s.addPoints(e,0,e.getPointCount());const r=kr(s,t,n,3,i);o.m_matrix[2]=r?-1:0}}}return pr(o.m_matrix,o.m_scl)}function _r(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setPointPointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);const h=t.getXY(),m=new et;let l=!1;if(Or(h,a,n)&&(o.pointPointDisjointPredicates_(),l=!0),!l){let t=!1,s=!0;const r=n*n;for(let n=0;n<e.getPointCount()&&(e.queryXY(n,m),et.sqrDistance(m,h)<=r?t=!0:s=!1,!t||s);n++);t?(o.m_matrix[0]=0,o.m_matrix[2]=s?-1:0,o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[2]=0,o.m_matrix[6]=0)}return pr(o.m_matrix,r)}function dr(e,t,s,n,r){const i=e.getXY(),o=t.getXY(),a=$e(9,-1);et.sqrDistance(i,o)<=s*s?a[0]=0:(a[2]=0,a[6]=0),a[8]=2;return pr(a,n)}function pr(e,t){for(let s=0;s<9;s++)switch(t[s]){case"T":if(-1===e[s])return!1;break;case"F":if(-1!==e[s])return!1;break;case"0":if(0!==e[s])return!1;break;case"1":if(1!==e[s])return!1;break;case"2":if(2!==e[s])return!1}return!0}function fr(e,t,n){const r=$e(9,-1);if(e.isEmpty()&&t.isEmpty())return pr(r,n);let o,a=!1;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;const m=o.getGeometryType();if(h(m))if(m===i.enumPolygon){if(0!==o.calculateArea2D())r[2]=2,r[5]=1;else{r[5]=-1;const e=s.constructEmpty();o.queryEnvelope(e),r[2]=e.height()||e.width()?1:0}}else{const e=0!==o.calculateLength2D();r[2]=e?1:0,r[5]=D(o)?0:-1}else r[2]=0,r[5]=-1;return a&&Nr(r),pr(r,n)}function xr(e,t,s){return yr(e)?3:Pr(e)?4:Er(e,t,s)?8:Sr(e,t,s)?16:Ir(e)?64:Cr(e)?1:br(e,t,s)?32:0}function yr(e){return"T*F**FFF*"===e}function Pr(e){return"FF*FF****"===e}function Er(e,t,s){return(0!==t||0!==s)&&(2===t&&2===s?"F***T****"===e:(2===t||1===t)&&0===s&&"F**T*****"===e)}function Sr(e,t,s){return t>s?"T*****T**"===e:1===t&&1===s&&"0********"===e}function Cr(e){return"T*****FF*"===e}function Ir(e){return"T**FF*FF*"===e}function br(e,t,s){return t===s&&(1!==t?"T*T***T**"===e:"1*T***T**"===e)}function wr(e,t,s){const n=t.getGeometryID(e);for(let r=t.getFirstCluster();r!==q;r=t.getNextCluster(r)){if(0===(t.getClusterParentage(r)&n))continue;const e=t.getClusterHalfEdge(r);if(e===q){t.setClusterUserIndex(r,s,0);continue}let i=e,o=0;do{const e=i;0!==(t.getHalfEdgeParentage(e)&n)&&o++,i=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(i!==e);t.setClusterUserIndex(r,s,o)}}class vr{nullFunc(){return a("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new tn,this.m_matrix=$e(9,0),this.m_maxDim=$e(9,0),this.m_performPredicates=$e(9,!1),this.m_scl="",this.m_predicateCount=0,this.m_predicatesHalfEdge=this.nullFunc,this.m_predicatesCluster=this.nullFunc}resetMatrix_(){this.m_matrix.fill(-2),this.m_maxDim.fill(-2)}setPredicates_(e){this.m_scl=e;for(let t=0;t<9;t++)"*"!==this.m_scl[t]?(this.m_performPredicates[t]=!0,this.m_predicateCount++):this.m_performPredicates[t]=!1}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&-2===this.m_matrix[e]&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return-2!==this.m_matrix[e]&&(-1===this.m_matrix[e]?(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):"T"!==this.m_scl[e]&&"F"!==this.m_scl[e]?!(this.m_matrix[e]<this.m_maxDim[e])&&(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):(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){const o=-1!==t,a=-1!==r;if(o||a){if(!("T"!==n&&"F"!==n&&o||"T"!==i&&"F"!==i&&a)||0!==e.calculateArea2D())o&&(this.m_matrix[t]=2),a&&(this.m_matrix[r]=1);else if(a&&(this.m_matrix[r]=-1),o){const n=s.constructEmpty();e.queryEnvelope(n),this.m_matrix[t]=n.height()||n.width()?1:0}}}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),Nr(this.m_matrix)}areaLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=D(t);this.m_matrix[7]=e?0:-1}this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){const e=this.m_scl[0],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const e=D(t);this.m_matrix[1]=e?0:-1}this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=D(e);this.m_matrix[5]=t?0:-1}if(this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=D(t);this.m_matrix[7]=e?0:-1}}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=D(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,s,3);const t=this.isPredicateKnown_(3);n&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,s);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,s,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,s,t,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(7);n&&=r}return n}lineLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,s,t,this.m_clusterIndexB,this.m_clusterIndexA,3);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,s,this.m_clusterIndexA,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,s,t,this.m_clusterIndexB,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(6);n&&=r}return n}pointPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}return n}interiorAreaInteriorArea_(e,t,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(n&t)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(e,t,s,n){if(2===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(n&t)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(e),r=this.m_topoGraph.getClusterParentage(n);if(0!==(r&t)&&0!==(r&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(r&s)&&0===(i&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(e,t,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0!==(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[1]=0)}}}}interiorAreaExteriorLine_(e,t,s){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getHalfEdgeParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,s,n){if(1===this.m_matrix[3])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(r&t)||0===(r&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(e,t,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);0!==(n&t)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(e),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(s&t)&&0===(n&t)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0===(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[7]=0)}}}}interiorLineInteriorLine_(e,t,s,n,r){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(i&t)||0===(i&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2==0&&t%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(e,t,s,n,r,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&t)&&0!==(a&s)){const e=this.m_topoGraph.getClusterUserIndex(o,n),t=this.m_topoGraph.getClusterUserIndex(o,r);if(e%2==0&&t%2!=0)return void(this.m_matrix[i]=0)}}}interiorLineExteriorLine_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(e,t,s,n,r){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2!=0&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(e,t,s,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const t=this.m_topoGraph.getHalfEdgeTo(e);if(0===(this.m_topoGraph.getClusterParentage(t)&s)){if(this.m_topoGraph.getClusterUserIndex(t,n)%2!=0)return void(this.m_matrix[r]=0)}}}interiorAreaInteriorPoint_(e,t){if(0===this.m_matrix[0])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0!==(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(e,t){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(e,t){if(1===this.m_matrix[5])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(0===this.m_matrix[6])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0===(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[0])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2==0)return void(this.m_matrix[0]=0)}}interiorLineExteriorPoint_(e,t,s,n){if(1===this.m_matrix[2])return;if(-1===this.m_topoGraph.getClusterHalfEdge(e)){if(0!==this.m_matrix[2]){if(0===(this.m_topoGraph.getClusterParentage(e)&s))return void(this.m_matrix[2]=0)}}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[3])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[3]=0)}}boundaryLineExteriorPoint_(e,t,s,n){if(0===this.m_matrix[5])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0===(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[5]=0)}}exteriorLineInteriorPoint_(e,t,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(e);0!==(n&t)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(e,t,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(e,t,s,n){if(0===this.m_matrix[n])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===q){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(i,n,r),s))break;continue}let t=e;do{let e=t;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(e,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==t&&!s);if(s)break;t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(t!==e);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);for(let i=this.m_topoGraph.getFirstCluster();i!==q&&(s=this.m_predicatesCluster(i,n,r),!s);i=this.m_topoGraph.getNextCluster(i));s||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,s){let n=0;if(e.hasCurves()){const r=new fa,i=e.getEnvelope2D(s),o=_a(t.total(),i);n=pa(o,0),aa(e,o,t.total(),12e3,r,null,s),r.clearStitcher(e)}ya(e,t.add(n),s,!1,!1),e.filterClosePoints(0,!0,!0,!1,q);for(let r=e.getFirstGeometry();r!==q;r=e.getNextGeometry(r))e.getGeometryType(r)===i.enumPolygon&&er(e,r,-1,!1,q,s);this.setEditShape_(e,s)}}function Nr(e){const t=e[1],s=e[2],n=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=s,e[7]=n}function Tr(e,t,n){const r=e.getGeometryType();if(o(r)){const t=new w({vd:e.getDescription()});return t.addSegment(e,!0),t}if(r===i.enumEnvelope){const n=e,r=s.constructEmpty();if(e.queryEnvelope(r),r.height()<=t&&r.width()<=t){const t=new ye({vd:e.getDescription()});return n.getCenter(t),t}if(r.height()<=t||r.width()<=t){const t=new w({vd:e.getDescription()}),s=new ye;return n.queryCornerByVal(0,s),t.startPathPoint(s),n.queryCornerByVal(2,s),t.lineToPoint(s),t}const i=new T({vd:e.getDescription()});return i.addEnvelope(n,!1),i}return e}function Gr(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Dr{nullFunc(){return a("should not be called"),!1}constructor(e,t,n,r=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=s.constructEmpty(),this.m_envInter=s.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const i=e.getAccelerators();let o=null;null!=i&&(o=r?i.getQuadTreeForPaths():i.getQuadTree());const a=t.getAccelerators();let m=null;if(null!=a&&(m=r?a.getQuadTreeForPaths():a.getQuadTree()),null===o&&null===m&&!r){const r=e.getPointCount(),i=t.getPointCount();if(r>10&&i>10){const a=s.constructEmpty(),l=s.constructEmpty(),g=s.constructEmpty();e.queryLooseEnvelope(a),t.queryLooseEnvelope(l),a.inflateCoords(n,n),l.inflateCoords(n,n),g.setCoords({env2D:a}),g.intersect(l),r>=i?o=h(e.getGeometryType())?He(e,g):ke(e,g):m=h(t.getGeometryType())?He(t,g):ke(t,g)}}this.construct_(e,o,t,m,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()}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):h(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_bSwapElements?this.m_intersector.getBlueElement(this.m_intersector.getHandleB()):this.m_intersector.getRedElement(this.m_intersector.getHandleA())}getBlueElement(){return this.m_bQuadTree?this.m_bSwapElements?h(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_quadTree.getElement(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedElement(this.m_intersector.getHandleA()):this.m_intersector.getBlueElement(this.m_intersector.getHandleB())}getRedEnvelope(){return this.m_bPaths||p(""),this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_query:this.m_bSwapElements?this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB()):this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA())}getBlueEnvelope(){return this.m_bPaths||p(""),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(e,t,n,r,o,a){const m=s.constructEmpty(),l=s.constructEmpty();e.queryLooseEnvelope(m),n.queryLooseEnvelope(l),m.inflateCoords(o,o),l.inflateCoords(o,o),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;const g=e.getGeometryType(),u=n.getGeometryType();this.m_bPaths=a,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.enumUnknown,this.m_bQuadTree=!1,null!==t&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,h(u)?(this.m_queryType=u,this.m_function=this.nextPath_,a?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=n.getPointCount())),this.m_bQuadTree||null!==r&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=r,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,h(g)?(this.m_queryType=g,this.m_function=this.nextPath_,a?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=g,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(a&&h(g)&&h(u)?this.m_intersector=qe(e,n,o):h(g)&&h(u)?(this.m_intersector=Ae(e,n,o),this.m_bSwapElements=!1):h(g)&&!h(u)?(this.m_intersector=Me(e,n,o),this.m_bSwapElements=!1):!h(g)&&h(u)?(this.m_intersector=Me(n,e,o),this.m_bSwapElements=!0):(this.m_intersector=Ue(e,n,o),this.m_bSwapElements=!1))}nextPath_(){return this.m_bPaths?-1===--this.m_pathIndex?(this.m_bDone=!0,!1):(this.m_bSwapElements?this.m_multiVertexImplB.queryPathEnvelope(this.m_pathIndex,this.m_query):this.m_multiVertexImplA.queryPathEnvelope(this.m_pathIndex,this.m_query),this.m_qtIter.resetIterator(this.m_query,this.m_tolerance),this.m_function=this.iterate_,!0):this.m_segIter.nextPath()?(this.m_function=this.nextSegment_,!0):(this.m_bDone=!0,!1)}nextSegment_(){if(!this.m_segIter.hasNextSegment())return this.m_function=this.nextPath_,!0;const e=this.m_segIter.nextSegment(),t=new s;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const e=new et;if(this.m_bSwapElements){const t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{const t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(s.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&(h(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Vr(e){return 2===e?1:1===e?2:128===e?64:64===e?128:e}function Fr(e,t,n){let r;if(e instanceof oc||null===e){const i=s.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(n),r=ue(e,i,!1)}else r=e;return r}function Hr(e,t,n){let r;if(e instanceof oc||null===e){const i=s.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(n),r=ue(e,i,!1)}else r=e;return r}function kr(e,t,n,a,h){if(e.isEmpty()||t.isEmpty())return 4===a;r(e),r(t);let m=e.getGeometryType(),l=t.getGeometryType();if(m===i.enumEnvelope){if(l===i.enumEnvelope)return Ar(e,t,n,a);if(l===i.enumPoint)return Mr(t,e,n,Vr(a))}else if(m===i.enumPoint){if(l===i.enumEnvelope)return Mr(e,t,n,a);if(l===i.enumPoint)return Ur(e,t,n,a)}const g=s.constructEmpty();e.queryEnvelope(g);const u=s.constructEmpty();t.queryEnvelope(u);const c=Hr(n,g,u);if(qr(g,u,c))return 4===a;let _=!1,d=null,p=null,f=null,x=null;switch(o(m)?(d=new w({vd:e.getDescription()}),d.addSegment(e,!0),f=d,m=i.enumPolyline):f=e,o(l)?(p=new w({vd:t.getDescription()}),p.addSegment(t,!0),x=p,l=i.enumPolyline):x=t,m!==i.enumEnvelope&&l!==i.enumEnvelope?(f.getDimension()<x.getDimension()||m===i.enumPoint&&l===i.enumMultiPoint)&&(a=Vr(a)):m!==i.enumPolygon&&l!==i.enumEnvelope&&(a=Vr(a)),m){case i.enumPolygon:switch(l){case i.enumPolygon:_=Yr(f,x,c,a,h);break;case i.enumPolyline:_=Rr(f,x,c,a,h);break;case i.enumPoint:_=Xr(f,x,c,a);break;case i.enumMultiPoint:_=Lr(f,x,c,a);break;case i.enumEnvelope:_=zr(f,x,c,a,h)}break;case i.enumPolyline:switch(l){case i.enumPolygon:_=Rr(x,f,c,a,h);break;case i.enumPolyline:_=Wr(f,x,c,a,h);break;case i.enumPoint:_=jr(f,x,c,a);break;case i.enumMultiPoint:_=Zr(f,x,c,a);break;case i.enumEnvelope:_=Kr(f,x,c,a,h)}break;case i.enumPoint:switch(l){case i.enumPolygon:_=Xr(x,f,c,a);break;case i.enumPolyline:_=jr(x,f,c,a);break;case i.enumMultiPoint:_=Jr(x,f,c,a)}break;case i.enumMultiPoint:switch(l){case i.enumPolygon:_=Lr(x,f,c,a);break;case i.enumPolyline:_=Zr(x,f,c,a);break;case i.enumMultiPoint:_=Qr(f,x,c,a);break;case i.enumPoint:_=Jr(f,x,c,a);break;case i.enumEnvelope:_=$r(f,x,c,a)}break;case i.enumEnvelope:switch(l){case i.enumPolygon:_=zr(x,f,c,a,h);break;case i.enumPolyline:_=Kr(x,f,c,a,h);break;case i.enumMultiPoint:_=$r(x,f,c,a)}}return _}function Ar(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=s.constructEmpty();e.queryEnvelope(o);const a=s.constructEmpty();t.queryEnvelope(a);const h=Hr(n,o,a);switch(r){case 4:return qr(o,a,h);case 2:return go(a,o,h,!1);case 128:return go(a,o,h,!0);case 1:return go(o,a,h,!1);case 64:return go(o,a,h,!0);case 3:return ho(o,a,h);case 8:return mo(o,a,h);case 32:return lo(o,a,h);case 16:return!1}return!1}function Mr(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=e.getXY(),a=s.constructEmpty();t.queryEnvelope(a);const h=Fr(n,o,a);switch(r){case 4:return Or(o,a,h);case 2:case 128:return ao(o,a,h);case 1:case 64:return!1;case 3:return io(o,a,h);case 8:return oo(o,a,h)}return!1}function Ur(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=e.getXY(),a=t.getXY();let h;if(n instanceof oc||null===n){const e=s.constructEmpty();e.setCoords({pt:o}),e.merge(a),h=ue(n,e,!1)}else h=n;switch(r){case 4:return no(o,a,h);case 2:case 128:return ro(a,o,h);case 1:case 64:return ro(o,a,h);case 3:return so(o,a,h)}return!1}function qr(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!e.isIntersecting(r)}function Br(e,t,s,n=!1){const r=e.getGeometryType(),i=t.getGeometryType();if(x(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();l(null===e)}}if(x(i)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();l(null===t)}}return 0}function Or(e,t,n,r){const i=s.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(n,n),!i.contains(e)}function Yr(e,t,s,n,r){switch(n){case 4:return ti(e,t,s);case 2:return ri(t,e,s,r);case 128:return ii(t,e,s);case 1:return ri(e,t,s,r);case 64:return ii(e,t,s);case 3:return ei(e,t,s,r);case 8:return si(e,t,s);case 32:return ni(e,t,s,r)}return!1}function Rr(e,t,s,n,r){switch(n){case 4:return oi(e,t,s);case 1:return mi(e,t,s,r);case 64:return li(e,t,s);case 8:return ai(e,t,s,r);case 16:return hi(e,t,s)}return!1}function Xr(e,t,s,n,r){switch(n){case 4:return gi(e,t,s);case 1:case 64:return ci(e,t,s);case 8:return ui(e,t,s)}return!1}function Lr(e,t,s,n,r){switch(n){case 4:return _i(e,t,s);case 1:return fi(e,t,s,!1);case 64:return fi(e,t,s,!0);case 8:return di(e,t,s);case 16:return pi(e,t,s)}return!1}function zr(e,t,s,n,r){if(yi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Si(e,t,s,!1);case 128:return Si(e,t,s,!0);case 1:return Ci(e,t,s,!1,r);case 64:return Ci(e,t,s,!0,r);case 3:return xi(e,t,s,r);case 8:return Pi(e,t,s,r);case 32:return Ei(e,t,s,r);case 16:return!1}return!1}function Wr(e,t,s,n,r){switch(n){case 4:return bi(e,t,s);case 2:return Ti(t,e,s,r);case 128:return Gi(t,e,s,r);case 1:return Ti(e,t,s,r);case 64:return Gi(e,t,s,r);case 3:return Ii(e,t,s,r);case 8:return wi(e,t,s,r);case 32:return Ni(e,t,s,r);case 16:return vi(e,t,s,r)}return!1}function jr(e,t,s,n,r){switch(n){case 4:return Di(e,t,s);case 1:case 64:return Fi(e,t,s);case 8:return Vi(e,t,s)}return!1}function Zr(e,t,s,n,r){switch(n){case 4:return Hi(e,t,s);case 1:case 64:return Mi(e,t,s);case 8:return ki(e,t,s);case 16:return Ai(e,t,s)}return!1}function Kr(e,t,s,n,r){if(qi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Oi(e,t,s,!1);case 128:return Oi(e,t,s,!0);case 1:case 64:case 32:return!1;case 3:return Ui(e,t,s);case 8:return Bi(e,t,s,r);case 16:return Yi(e,t,s)}return!1}function Qr(e,t,s,n,r){switch(n){case 4:return Xi(e,t,s);case 2:case 128:return zi(t,e,s);case 1:case 64:return zi(e,t,s);case 3:return Ri(e,t,s);case 32:return Li(e,t,s)}return!1}function Jr(e,t,s,n,r){switch(n){case 4:return ji(e,t,s);case 2:case 128:return Zi(e,t,s);case 1:case 64:return Ki(e,t,s);case 3:return Wi(e,t,s)}return!1}function $r(e,t,s,n,r){switch(n){case 4:return Ji(e,t,s);case 2:return eo(e,t,s,!1);case 128:return eo(e,t,s,!0);case 1:case 64:return!1;case 3:return Qi(e,t,s);case 8:return $i(e,t,s);case 16:return to(e,t,s)}return!1}function ei(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;if(Br(e,t),yo(e,t,n))return!0;const a=e.calculateLength2D(),h=t.calculateLength2D(),m=Math.max(e.getPointCount(),t.getPointCount());if(Math.abs(a-h)>4*m*n)return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"**F**FFF*",r,!1)}return So(e,t,n,!0)}function ti(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function si(e,t,s,n){return Br(e,t),Go(e,t,s,null)}function ni(e,t,s,n){return Br(e,t),Do(e,t,s,n)}function ri(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),Vo(e,t,n,r))}function ii(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),2===uo(e,t,n,!1))}function oi(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function ai(e,t,s,n){return Br(e,t),Fo(e,t,s,n)}function hi(e,t,s,n){return Br(e,t),Ho(e,t,s,null)}function mi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),ko(e,t,n,r))}function li(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),2===uo(e,t,n,!1))}function gi(e,t,s,n){return 0===Xo(e,t,s)}function ui(e,t,s,n){return Mo(e,t.getXY(),s)}function ci(e,t,s,n){return Ao(e,t.getXY(),s)}function _i(e,t,s,n,r){Br(e,t);return 1===co(e,t,s)}function di(e,t,n,r){Br(e,t);const i=s.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);const o=new et;let a=!1;const h=e.getImpl(),m=new T;let l=e,g=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,o),i.contains(o)){const e=Lo(l,o,n);if(2===e)a=!0;else if(1===e)return!1}g||(!Wn(e,t.getPointCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return!!a}function pi(e,t,n,r){Br(e,t);const i=new s,o=new s,a=new s;e.queryEnvelope(i),t.queryEnvelope(a),o.setCoords({env2D:i}),o.inflateCoords(n,n);let h=!1,m=!1;const l=new et,g=e.getImpl(),u=new T;let c=e,_=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,l),o.contains(l)){const e=Lo(c,l,n);0===e?m=!0:1===e&&(h=!0)}else m=!0;if(h&&m)return!0;_||(!Wn(e,t.getPointCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?c=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),c=u),_=!0)}return!1}function fi(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);let h=!1;const m=new et,l=e.getImpl(),g=new T;let u=e,c=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,m),!o.contains(m))return!1;const i=Lo(u,m,n);if(1===i)h=!0;else if(0===i)return!1;if(r&&2===i)return!1;c||(!Wn(e,t.getPointCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?u=e:(e.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),u=g),c=!0)}return h}function xi(e,t,n,r){const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;const a=new T;return a.addEnvelope(t,!1),ei(e,a,n,r)}function yi(e,t,n,r){Br(e,t);const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;return 0===Lo(e,o.getLowerLeft(),0)&&(!o.contains(e.getXY(0))&&!To(e,o,n))}function Pi(e,t,n,r){Br(e,t);const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new T;return a.addEnvelope(t,!1),Go(e,a,n,r)}function Ei(e,t,n,r){Br(e,t);const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new T;return a.addEnvelope(t,!1),Do(e,a,n,r)}function Si(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();return e.queryEnvelope(o),t.queryEnvelope(a),r?fo(a,o,n):po(a,o,n)}function Ci(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);const h=new T;return h.addEnvelope(t,!1),r?2===uo(e,h,n,!1):Vo(e,h,n,i)}function Ii(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;if(Br(e,t),yo(e,t,n))return!0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"**F**FFF*",r,!1)}return So(e,t,n,!1)}function bi(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl();return!new Dr(r,i,s,!0).next()||!Io(e,t,s)}function wi(e,t,n,r){Br(e,t);const i=[],o=bo(e,t,n,i);if(-2===o){const i=s.constructEmpty(),o=s.constructEmpty(),a=s.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*n,1e3*n),o.inflateCoords(1e3*n,1e3*n),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=Zt(t,a,n,0,r),m.isEmpty())return!1}else m=t;return sr(h,m,n,"F********",r,!1)}if(0!==o)return!1;const a=new G;for(let s=0;s<i.length;s+=2){const e=i[s],t=i[s+1];a.addXY(e,t)}const h=e.getBoundary(),m=t.getBoundary();return h.addPoints(m,0,m.getPointCount()),!h.isEmpty()&&zi(h,a,n)}function vi(e,t,n,r){Br(e,t);const i=[],o=bo(e,t,n,i);if(-2===o){const i=s.constructEmpty(),o=s.constructEmpty(),a=s.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*n,1e3*n),o.inflateCoords(1e3*n,1e3*n),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=Zt(t,a,n,0,r),m.isEmpty())return!1}else m=t;return sr(h,m,n,"0********",r,!1)}if(0!==o)return!1;const a=new G;for(let s=0;s<i.length;s+=2){const e=i[s],t=i[s+1];a.addXY(e,t)}const h=e.getBoundary(),m=t.getBoundary();return h.addPoints(m,0,m.getPointCount()),!!h.isEmpty()||!zi(h,a,n)}function Ni(e,t,n,r){Br(e,t);const i=s.constructEmpty(),o=s.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=xo(i,o,n),h=xo(o,i,n),m=e.hasNonLinearSegments(),l=t.hasNonLinearSegments(),g=bo(e,t,n,null);if(-1===g)return!1;if(1===g){if(a&&h)return!0;if(!m&&!l)return a&&!h?!Co(t,e,n,!1):h&&!a?!Co(e,t,n,!1):!Co(e,t,n,!1)&&!Co(t,e,n,!1)}const u=s.constructEmpty(),c=s.constructEmpty(),_=s.constructEmpty();let d,p;u.setCoords({env2D:i}),u.inflateCoords(1e3*n,1e3*n),c.setCoords({env2D:o}),c.inflateCoords(1e3*n,1e3*n),_.setCoords({env2D:u}),_.intersect(c);let f="";if(f+="1*",a){if(t.getPointCount()>10){if(p=Zt(t,_,n,0,r),p.isEmpty())return!1}else p=t;f+="****"}else p=t,f+="T***";if(h){if(e.getPointCount()>10){if(d=Zt(e,_,n,0,r),d.isEmpty())return!1}else d=e;f+="***"}else d=e,f+="T**";return sr(d,p,n,f,r,!1)}function Ti(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,n))return!1;if(Br(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"******FF*",r,!1)}return Co(t,e,n,!1)}function Gi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,n))return!1;Br(e,t);return sr(e,t,n,"T**FF*FF*",r,!1)}function Di(e,t,s,n){Br(e,t);return!vo(e,t.getXY(),s)}function Vi(e,t,s,n){Br(e,t);return qo(e,t.getXY(),s)}function Fi(e,t,s,n){Br(e,t);return No(e,t.getXY(),s)}function Hi(e,t,s,n){return Br(e,t),!wo(e,t,s,!1)}function ki(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=new G,a=new Dr(r,i,s,!1),h=r.querySegmentIterator();let m=!1;for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();h.resetToVertex(e,-1);const n=h.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(m=!0,o.addPoint2D(r))}if(!m)return!1;const l=e.getBoundary();return!l.isEmpty()&&zi(l,o,s)}function Ai(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=i.getPointCount(),a=$e(o,!1),h=new Dr(r,i,s,!1),m=r.querySegmentIterator();let l=!1;for(;h.next();){const e=h.getRedElement(),t=h.getBlueElement();m.resetToVertex(e,-1);const n=m.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(l=!0,a[t]=!0)}if(!l)return!1;let g=!1;for(let _=0;_<o;_++)if(!a[_]){g=!0;break}if(!g)return!1;const u=e.getBoundary();if(u.isEmpty())return!0;const c=new G;for(let _=0;_<o;_++)a[_]&&c.addPoint2D(i.getXY(_));return!zi(u,c,s)}function Mi(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);const h=wo(e,t,n,!0);if(!h)return h;const m=e.getBoundary();return m.isEmpty()?h:!zi(m,t,n)}function Ui(e,t,n,r){const i=new s,o=new s;return e.queryEnvelope(i),t.queryEnvelope(o),!(o.height()>n&&o.width()>n)&&ho(i,o,n)}function qi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=Bo(o,i,n);return 0===a?!To(e,o,n):4===a}function Bi(e,t,n,r){const o=new s,h=new s;if(e.queryEnvelope(o),t.queryEnvelope(h),h.height()<=n||h.width()<=n)return!1;const m=new s,l=new s;if(m.setCoords({env2D:h}),l.setCoords({env2D:h}),m.inflateCoords(n,n),l.inflateCoords(-n,-n),l.containsEnvelope(o)||!o.isIntersecting(m))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const u=e.getImpl().getAccelerators();let c=null,_=null;null!==u&&(c=u.getQuadTree(),null!==c&&(_=c.getIterator(h,n))),_||g.nextPath()||a("relational_operations");let d=!1,p=null;const f=new et,x=new et,y=e.hasNonLinearSegments();let P=!1;for(;;){if(null!==_){const e=_.next();if(-1===e)break;g.resetToVertex(c.getElement(e),-1),p=g.nextSegment()}else{for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;p=g.nextSegment()}if(y&&p.getGeometryType()!==i.enumLine){const e=new s;if(p.queryEnvelope(e),l.containsEnvelope(e))return!1;if(m.isIntersecting(e)){P=!0;break}}else{f.assign(p.getStartXY()),x.assign(p.getEndXY());let e=l.clipLine(f,x);if(0!==e)return!1;d||(e=m.clipLine(f,x),0!==e&&(d=!0))}}if(!P)return d;const E=new T;return E.addEnvelope(h,!1),ai(E,e,n,r)}function Oi(e,t,n,r,o){const h=s.constructEmpty(),m=s.constructEmpty();if(e.queryEnvelope(h),t.queryEnvelope(m),m.height()<=n||m.width()<=n)return!1;if(r)return fo(m,h,n);if(!po(m,h,n))return!1;const l=s.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-n,-n);const g=s.constructEmpty();if(g.setCoords({env2D:m}),g.inflateCoords(n,n),l.containsEnvelope(h))return!0;const u=e.getImpl().querySegmentIterator();u.stripAttributes(),u.nextPath()||a("relational_operations");let c,_,d,p,f,x,y=!1;const P=e.hasNonLinearSegments();for(P&&(d=new A,p=new A,f=new A,x=new A,l.querySide(0,d),l.querySide(1,p),l.querySide(2,f),l.querySide(3,x));;){for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;const e=u.nextSegment();if(P&&e.getGeometryType()!==i.enumLine){if(e.isIntersecting(d,n)){y=!0;break}if(e.isIntersecting(p,n)){y=!0;break}if(e.isIntersecting(f,n)){y=!0;break}if(e.isIntersecting(x,n)){y=!0;break}}else{c=e.getStartXY(),_=e.getEndXY();if(0!==l.clipLine(c,_)){y=!0;break}}}return y}function Yi(e,t,n,r){const o=new s,a=new s;if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new s;if(h.setCoords({env2D:a}),h.inflateCoords(n,n),h.containsEnvelope(o))return!1;const m=!0,g=new s;if(g.setCoords({env2D:a}),g.inflateCoords(-n,-n),!g.isIntersecting(o))return!1;const u=e.getImpl().querySegmentIterator();u.stripAttributes();const c=e.getImpl().getAccelerators();let _=null,d=null;if(null!==c&&(_=c.getQuadTree(),null!==_&&(d=_.getIterator(a,n))),!d){const e=u.nextPath();l(e)}let p=!1,f=null;const x=new et,y=new et;let P=null,E=null,S=null,C=null;for(e.hasNonLinearSegments()&&(P=new A,E=new A,S=new A,C=new A,g.querySide(0,P),g.querySide(1,E),g.querySide(2,S),g.querySide(3,C));;){if(null!==d){const e=d.next();if(-1===e)break;u.resetToVertex(_.getElement(e),-1),f=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;f=u.nextSegment()}if(f.getGeometryType()===i.enumLine){x.assign(f.getStartXY()),y.assign(f.getEndXY());if(0!==g.clipLine(x,y)){p=!0;break}}else{if(P.isIntersecting(f,n)){p=!0;break}if(E.isIntersecting(f,n)){p=!0;break}if(S.isIntersecting(f,n)){p=!0;break}if(C.isIntersecting(f,n)){p=!0;break}}}return p&&m}function Ri(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!ho(i,o,n)&&(!!Po(e,t,n)||Eo(e,t,n,!1,!0,!1))}function Xi(e,t,s,n){const r=e,i=t,o=new Dr(r,i,s,!1),a=s*s,h=new et,m=new et;for(;o.next();){const e=o.getRedElement(),t=o.getBlueElement();if(r.queryXY(e,h),i.queryXY(t,m),et.sqrDistance(h,m)<=a)return!1}return!0}function Li(e,t,s,n){return Eo(e,t,s,!1,!1,!0)}function zi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&Eo(t,e,n,!0,!1,!1)}function Wi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),ho(i,o,n)}function ji(e,t,s,n){return Uo(e,t.getXY(),s)}function Zi(e,t,s,n){return Wi(e,t,s)}function Ki(e,t,s,n){return!ji(e,t,s)}function Qi(e,t,n,r){const i=new s,o=new s;return e.queryEnvelope(i),t.queryEnvelope(o),!(o.height()>n||o.width()>n)&&ho(i,o,n)}function Ji(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;const a=s.constructEmpty();a.setCoords({env2D:o}),a.inflateCoords(n,n);const h=new et;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,h),a.contains(h))return!1;return!0}function $i(e,t,n,r){const i=new s,o=new s,a=new s;if(t.queryEnvelope(i),i.height()<=n||i.width()<=n)return!1;o.setCoords({env2D:i}),a.setCoords({env2D:i}),o.inflateCoords(n,n),a.inflateCoords(-n,-n);const h=new et;let m=!1;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,h),o.contains(h)){if(a.containsExclusive(h))return!1;m=!0}return m}function eo(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;if(r)return fo(a,o,n);if(!po(a,o,n))return!1;let h=!1;const m=s.constructEmpty(),l=s.constructEmpty();m.setCoords({env2D:a}),l.setCoords({env2D:a}),m.inflateCoords(-n,-n),l.inflateCoords(n,n);const g=new et;for(let s=0;s<e.getPointCount();s++){if(e.queryXY(s,g),!l.contains(g))return!1;m.containsExclusive(g)&&(h=!0)}return h}function to(e,t,n,r){const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new s,h=new s;a.setCoords({env2D:o}),a.inflateCoords(-n,-n),h.setCoords({env2D:o}),h.inflateCoords(n,n);const m=new et;let l=!1,g=!1;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,m),!l&&a.containsExclusive(m)&&(l=!0),g||h.contains(m)||(g=!0),l&&g)return!0;return!1}function so(e,t,s,n){return et.sqrDistance(e,t)<=s*s}function no(e,t,s,n){return et.sqrDistance(e,t)>s*s}function ro(e,t,s,n){return so(e,t,s)}function io(e,t,n,r){const i=new s;return i.setCoords({pt:e}),ho(i,t,n)}function oo(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;const i=new s,o=new s;return i.setCoords({env2D:t}),i.inflateCoords(n,n),!!i.contains(e)&&(o.setCoords({env2D:t}),o.inflateCoords(-n,-n),!o.containsExclusive(e))}function ao(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;const i=s.constructEmpty();i.setCoords({env2D:t}),i.inflateCoords(-n,-n);return i.containsExclusive(e)}function ho(e,t,s,n){return po(e,t,s)&&po(t,e,s)}function mo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;const i=new s;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!(!i.isEmpty()&&i.height()>n&&i.width()>n)&&(i.setCoords({env2D:e}),i.inflateCoords(n,n),i.intersect(t),!i.isEmpty())}function lo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;if(po(e,t,n))return!1;if(po(t,e,n))return!1;const i=new s;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&(i.height()>n||i.width()>n)}function go(e,t,n,r,i){if(e.height()<=n||e.width()<=n)return!1;if(r)return fo(e,t,n);if(!po(e,t,n))return!1;const o=s.constructEmpty();return o.setCoords({env2D:e}),o.inflateCoords(-n,-n),o.intersect(t),!o.isEmpty()}function uo(e,t,n,r,o){const a=new et,h=new et,m=s.constructEmpty(),l=s.constructEmpty(),g=e.getImpl(),u=t.getImpl(),c=u.getGeometryType(),_=new Dr(g,u,n,!0);if(!_.next())return 1;if(Io(e,t,n))return r?4:0;const d=new T;let p=e;const f=new T;let x=null;c===i.enumPolygon&&(x=t);const y=c===i.enumPolygon?$e(g.getPathCount(),!1):[],P=$e(u.getPathCount(),!1);let E=!1,S=!1,C=!1,I=!1,b=!1,w=!1;do{if(C&&b||I&&w)break;if(C&&I)break;const s=_.getRedElement(),o=_.getBlueElement();if(!P[o]&&(h.assign(t.getXY(t.getPathStart(o))),m.setCoords({env2D:_.getRedEnvelope()}),m.inflateCoords(n,n),m.contains(h))){if(0!==Lo(p,h,0)){if(I=!0,r)return 4}else w=!0;P[o]=!0}if(c===i.enumPolygon&&!y[s]&&(a.assign(e.getXY(e.getPathStart(s))),l.setCoords({env2D:_.getBlueEnvelope()}),l.inflateCoords(n,n),l.contains(a))){if(0!==Lo(x,a,0)){if(C=!0,r)return 4}else b=!0;y[s]=!0}if(E||(!Wn(e,t.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?p=e:(e.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),p=d),E=!0),c===i.enumPolygon&&!S){const s=t;!Wn(s,e.getPathCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?x=t:(s.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),S=!0}}while(_.next());if(!C&&!I)return 1;if(!b||!w){if(c===i.enumPolygon)for(let e=0,t=g.getPathCount();e<t;e++)if(!y[e]){b=!0;break}for(let e=0,t=u.getPathCount();e<t;e++)if(!P[e]){w=!0;break}}return C&&b||I&&w||C&&I?4:I?2:3}function co(e,t,n,r,i){const o=s.constructEmpty();e.queryEnvelope(o),o.inflateCoords(n,n);const a=new et,h=e.getImpl(),m=new T;let l=e,g=!1,u=!1,c=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,a),o.contains(a)){const e=Lo(l,a,n);if(1===e)return u=!0,4;if(2===e)return 4;c=!0}else c=!0;g||(!Wn(e,t.getPointCount()-1)||null!==h.getAccelerators()&&null!=h.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return u?c?4:2:1}function _o(e,t,n,r,o){r[0]=!1;const a=e.getImpl(),h=t.getImpl(),m=a.querySegmentIterator(),g=h.querySegmentIterator(),u=[0,0],c=[0,0],_=new Dr(a,h,n);let d=!1;for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement();m.resetToVertex(e,-1),g.resetToVertex(t,-1);const s=m.nextSegment(),i=g.nextSegment();let o=0;if(Oo(s,i)?!d&&i.isIntersecting(s,n)&&(d=!0):o=i.intersect(s,null,c,u,n),0!==o&&(d=!0,1===o)){const e=u[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!d){r[0]=!0;const o=s.constructEmpty();e.queryEnvelope(o),o.inflateCoords(n,n);const m=new T;let g=e,u=!1;for(let n=0,r=t.getPathCount();n<r;n++)if(t.getPathSize(n)>0){const r=s.constructEmpty();if(t.queryPathEnvelope(n,r),!o.isIntersecting(r))return!1;{const e=zn(g,t.getXY(t.getPathStart(n)),0);if(l(-1!==e),0===e)return!1}u||(!Wn(e,t.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?g=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),g=m),u=!0)}if(1===e.getPathCount()||t.getGeometryType()===i.enumPolyline)return!0;const c=t,_=s.constructEmpty();c.queryEnvelope(_),_.inflateCoords(n,n);const d=new T;let p=c,f=!1;for(let t=0,n=e.getPathCount();t<n;t++)if(e.getPathSize(t)>0){const n=s.constructEmpty();if(e.queryPathEnvelope(t,n),_.isIntersecting(n)){const s=zn(p,e.getXY(e.getPathStart(t)),0);if(l(-1!==s),1===s)return!1}f||(!Wn(c,e.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?p=c:(c.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),p=d),f=!0)}return!0}return!1}function po(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)}function fo(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),e.containsExclusiveEnvelope(r)}function xo(e,t,n){const r=s.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 yo(e,t,s,n){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);const r=new et,i=new et;let o=!0;const a=s*s;for(let h=0;h<e.getPathCount();h++){if(e.getPathEnd(h)!==t.getPathEnd(h)){o=!1;break}for(let s=e.getPathStart(h);s<t.getPathEnd(h);s++)if(e.queryXY(s,r),t.queryXY(s,i),et.sqrDistance(r,i)>a){o=!1;break}if(!o)break}return!!o}function Po(e,t,s,n){if(e.getPointCount()!==t.getPointCount())return!1;const r=new et,i=new et;let o=!0;const a=s*s;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,r),t.queryXY(h,i),et.sqrDistance(r,i)>a){o=!1;break}return!!o}function Eo(e,t,s,n,r,i,o){const a=e.getImpl(),h=t.getImpl(),m=a.getPointCount(),l=h.getPointCount(),g=$e(m,!1),u=r||i?$e(l,!1):[],c=s*s,_=new Dr(a,h,s);for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement(),s=a.getXY(e),n=h.getXY(t);et.sqrDistance(s,n)<=c&&(g[e]=!0,(r||i)&&(u[t]=!0))}let d=!1,p=!1;for(let y=0;y<m;y++){const e=g[y];if(d||=!e,p||=e,(r||n)&&d)return!1}if(n)return!0;let f=!1,x=!1;for(let y=0;y<l;y++){const e=u[y];if(f||=!e,x||=e,r&&f)return!1}return!!r||d&&p&&f&&x}function So(e,t,s,n){return Co(e,t,s,n)&&Co(t,e,s,n)}function Co(e,t,n,r){if(y(e),y(t),t.isEmpty())return!1;let i=!0;const o=$e(2,Number.NaN),h=$e(2,Number.NaN),m=[],l=new Ro;let g;const u=s.constructEmpty(),c=s.constructEmpty(),_=s.constructEmpty();e.queryEnvelope(u),t.queryEnvelope(c),u.inflateCoords(n,n),c.inflateCoords(n,n),_.setCoords({env2D:u}),_.intersect(c);const d=e.getImpl().querySegmentIterator(),p=t.getImpl().querySegmentIterator(),f=t.getImpl().getAccelerators();let x=null,P=null,E=null,S=null;if(null!==f&&(x=f.getQuadTree(),P=f.getQuadTreeForPaths(),null!==P&&(S=P.getIteratorForQT())),null===x){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(x=He(t.getImpl(),_))}for(null!==x&&(E=x.getIteratorForQT());d.nextPath();)for(;d.hasNextSegment();){let e=d.nextSegment();if(e.queryEnvelope(u),!u.isIntersecting(_))return i=!1,!1;if(null!==S&&(S.resetIterator(u,n),-1===S.next()))continue;let t=0,s=null;if(null!=E)E.resetIterator(e,n);else if(p.resetToFirstPath(),!p.nextPath())return i=!1,!1;do{if(t=0,null!==E){const r=E.next();if(-1===r)return i=!1,!1;p.resetToVertex(x.getElement(r),-1),s=p.nextSegment(),t=e.intersect(s,null,o,h,n)}else{for(;!p.hasNextSegment();)if(!p.nextPath())return i=!1,!1;s=p.nextSegment(),s.queryEnvelope(c),c.inflateCoords(n,n),u.isIntersecting(c)&&(t=e.intersect(s,null,o,h,n))}}while(2!==t||0!==o[0]||r&&!(h[0]<=h[1]));let f=Number.NaN,y=!1;do{let r=!1;if(1===o[1]){if(!d.hasNextSegment()){y=!0;break}e=d.nextSegment(),r=!0}if(1===h[1]&&h[0]<=h[1]){if(-1===f)break;if(f=1,!p.hasNextSegment())break;s=p.nextSegment(),r=!0}if(0===h[1]&&h[0]>h[1]){if(1===f)break;if(Number.isNaN(f)){if(!p.hasPreviousSegment())break;p.previousSegment(),f=-1}if(!p.hasPreviousSegment())break;s=p.previousSegment(),r=!0}if(!r)break;t=e.intersect(s,null,o,h,n)}while(2===t&&(!r||h[0]<=h[1]));if(y)continue;const P=e.calculateLength2D();e.queryEnvelope(u),m.length=0,l.m_overlapEvents.length=0;let C=!1,I=!1,b=0;const w=ue(null,u,!0);for(null!==E?E.resetIterator(e,n):(p.resetToFirstPath(),p.nextPath()||a("relational_operations"));;){if(t=0,null!==E){const r=E.next();if(-1===r)break;p.resetToVertex(x.getElement(r),-1),s=p.nextSegment(),t=e.intersect(s,null,o,h,n)}else{for(;!p.hasNextSegment()&&p.nextPath(););if(!p.hasNextSegment())break;s=p.nextSegment(),s.queryEnvelope(c),c.inflateCoords(n,n),u.isIntersecting(c)&&(t=e.intersect(s,null,o,h,n))}if(2===t&&(!r||h[0]<=h[1])){const e=d.getStartPointIndex(),t=d.getPathIndex(),s=p.getStartPointIndex(),r=p.getPathIndex();if(g=Yo(e,t,o[0],o[1],s,r,h[0],h[1]),l.m_overlapEvents.push(g),m.push(m.length),!(C||g.m_scalarA0<b&&g.m_scalarA1<b))if(0===b&&P*(g.m_scalarA0-b)>n)C=!0;else if(0!==b&&P*(g.m_scalarA0-b)>w)C=!0;else if(b=g.m_scalarA1,P*(1-b)<=n||1===b){I=!0;break}}}if(!I){if(!C)return i=!1,!1;m.length>1&&m.sort((e,t)=>l.compareOverlapEvents(e,t)),b=0;for(let e=0;e<l.m_overlapEvents.length;e++)if(g=l.m_overlapEvents[m[e]],!(g.m_scalarA0<b&&g.m_scalarA1<b)){if(0===b&&P*(g.m_scalarA0-b)>n)return i=!1,!1;if(0!==b&&P*(g.m_scalarA0-b)>w)return i=!1,!1;if(b=g.m_scalarA1,P*(1-b)<=n||1===b)break}if(P*(1-b)>n)return i=!1,!1;m.length=0,l.m_overlapEvents.length=0}}return i}function Io(e,t,s){const n=e.getImpl(),r=t.getImpl(),i=n.querySegmentIterator(),o=r.querySegmentIterator(),a=new Dr(n,r,s);for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();i.resetToVertex(e,-1),o.resetToVertex(t,-1);const n=i.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function bo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=$e(2,Number.NaN),m=new Dr(r,i,s);let l=!1,g=-1;for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const r=o.nextSegment(),i=a.nextSegment();let u=0;if(Oo(r,i)){if(i.isIntersecting(r,s))return-2}else u=r.intersect(i,null,h,null,s);if(u)if(2===u){const e=r.calculateLength2D(),t=h[0];if(e*(h[1]-t)>s)return g=1,g;l=!0}else if(g=0,n){const e=h[0],t=new et;r.queryCoord2D(e,t),n.push(t.x),n.push(t.y)}}return l?-2:g}function wo(e,t,s,n){const r=e.getImpl(),i=t,o=i.getPointCount(),a=n?$e(o,!1):[],h=new Dr(r,i,s,!1),m=r.querySegmentIterator();for(;h.next();){const e=h.getRedElement(),t=h.getBlueElement();m.resetToVertex(e,-1);const r=m.nextSegment(),o=i.getXY(t);if(r.isIntersectingPoint(o,s)){if(!n)return!0;a[t]=!0}}if(!n)return!1;for(let l=0;l<o;l++)if(!a[l])return!1;return!0}function vo(e,t,n){const r=new et,i=n*n,o=e.querySegmentIterator(),a=e.getImpl().getAccelerators();if(null!==a){const e=a.getQuadTree();if(null!==e){const a=s.constructEmpty();a.setCoords({pt:t});const h=e.getIterator(a,n);for(let s=h.next();-1!==s;s=h.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,r),et.sqrDistance(t,r)<=i)return!0}return!1}}const h=s.constructEmpty();for(;o.nextPath();)for(;o.hasNextSegment();){const e=o.nextSegment();if(e.queryEnvelope(h),h.inflateCoords(n,n),!h.contains(t))continue;const s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,r),et.sqrDistance(t,r)<=i)return!0}return!1}function No(e,t,s){return vo(e,t,s)&&!qo(e,t,s)}function To(e,t,n,r){const o=e.querySegmentIterator(),a=e.getImpl().getAccelerators(),h=e.hasNonLinearSegments();let m=null,l=null,g=null,u=null;if(null!==a){const e=a.getQuadTree();if(null!==e){const r=e.getIterator(t,n);h&&(m=new A,l=new A,g=new A,u=new A,t.querySide(0,m),t.querySide(1,l),t.querySide(2,g),t.querySide(3,u));const a=s.constructEmpty();a.setCoords({env2D:t}),a.inflateCoords(n,n);for(let s=r.next();-1!==s;s=r.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment();if(e.getGeometryType()===i.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(a.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0;if(e.isIntersecting(u,n))return!0}return!1}}if(h){m=new A,l=new A,g=new A,u=new A,t.querySide(0,m),t.querySide(1,l),t.querySide(2,g),t.querySide(3,u);const s=e.querySegmentIterator();for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0;if(e.isIntersecting(u,n))return!0}}else{const r=s.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(n,n);const i=e.getImpl(),o=i.getAttributeStreamRef(0),a=new et;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0;const s=new et,n=new et,h=new et,m=i.getPathStart(e),l=new et;for(let g=m,u=i.getPathEnd(e);g<u;g++)if(t)o.queryPoint2D(2*g,s),l.assign(s),t=!1;else{if(o.queryPoint2D(2*g,a),n.setCoordsPoint2D(s),h.setCoordsPoint2D(a),r.clipLine(n,h))return!0;s.assign(a)}if(i.isClosedPath(e)&&!t&&(n.setCoordsPoint2D(s),h.setCoordsPoint2D(l),r.clipLine(n,h)))return!0}}return!1}function Go(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=[0],h=De(i.getIsSimple(0,a))&&De(o.getIsSimple(0,a)),m=i.querySegmentIterator(),l=o.querySegmentIterator(),g=$e(2,0),u=$e(2,0),c=new Dr(i,o,n);let _=!1;for(;c.next();){const e=c.getRedElement(),t=c.getBlueElement();m.resetToVertex(e,-1),l.resetToVertex(t,-1);const s=m.nextSegment(),r=l.nextSegment();let i=0;if(Oo(s,r)){if(r.isIntersecting(s,n)){_=!0;break}}else i=r.intersect(s,null,u,g,n);if(2===i){const e=g[0],t=g[1],r=s.calculateLength2D();if(h&&(t-e)*r>n)return!1;_=!0}else if(i){const e=g[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return!1;_=!0}}if(!_)return!1;const d=s.constructEmpty(),p=s.constructEmpty(),f=s.constructEmpty();let x,y;if(e.queryEnvelope(d),t.queryEnvelope(p),d.inflateCoords(1e3*n,1e3*n),p.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:d}),f.intersect(p),e.getPointCount()>10){if(x=Zt(e,f,n,0,r),x.isEmpty())return!1}else x=e;if(t.getPointCount()>10){if(y=Zt(t,f,n,0,r),y.isEmpty())return!1}else y=t;return sr(x,y,n,"F********",r,!1)}function Do(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=[0],h=De(i.getIsSimple(0,a))&&De(o.getIsSimple(0,a)),m=s.constructEmpty(),l=s.constructEmpty(),g=s.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let u=!1;const c=xo(m,l,n),_=xo(l,m,n),d=i.querySegmentIterator(),p=o.querySegmentIterator(),f=$e(2,Number.NaN),x=$e(2,Number.NaN),y=new Dr(i,o,n);for(;y.next();){const e=y.getRedElement(),t=y.getBlueElement();d.resetToVertex(e,-1),p.resetToVertex(t,-1);const s=d.nextSegment(),r=p.nextSegment();let i=0;if(Oo(s,r)){if(r.isIntersecting(s,n))break}else i=r.intersect(s,null,x,f,n);if(2===i){const e=f[0],t=f[1],r=s.calculateLength2D();if(h&&(t-e)*r>n&&(u=!0,c&&_))return!0}else if(i){const e=f[0],t=x[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const P=s.constructEmpty(),E=s.constructEmpty();let S,C;P.setCoords({env2D:m}),P.inflateCoords(1e3*n,1e3*n),E.setCoords({env2D:l}),E.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:P}),g.intersect(E);let I="";if(I+=u?"**":"T*",c){if(t.getPointCount()>10){if(C=Zt(t,g,n,0,r),C.isEmpty())return!1}else C=t;I+="****"}else C=t,I+="T***";if(_){if(e.getPointCount()>10){if(S=Zt(e,g,n,0,r),S.isEmpty())return!1}else S=e;I+="***"}else S=e,I+="T**";return sr(S,C,n,I,r,!1)}function Vo(e,t,n,r){const i=[!1],o=_o(e,t,n,i);if(i[0])return o;const a=s.constructEmpty();let h;if(t.queryEnvelope(a),a.inflateCoords(1e3*n,1e3*n),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;return nr(h,t,n,r)}function Fo(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),h=o.querySegmentIterator(),m=$e(2,Number.NaN),l=$e(2,Number.NaN),g=new Dr(i,o,n);let u=!1;for(;g.next();){const e=g.getRedElement(),t=g.getBlueElement();a.resetToVertex(e,-1),h.resetToVertex(t,-1);const s=a.nextSegment(),r=h.nextSegment();let i=0;if(Oo(s,r)?!u&&r.isIntersecting(s,n)&&(u=!0):i=r.intersect(s,null,l,m,n),2===i)u=!0;else if(i){const e=m[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!1;u=!0}}if(!u)return!1;const c=s.constructEmpty(),_=s.constructEmpty(),d=s.constructEmpty();let p,f;if(e.queryEnvelope(c),t.queryEnvelope(_),c.inflateCoords(1e3*n,1e3*n),_.inflateCoords(1e3*n,1e3*n),d.setCoords({env2D:c}),d.intersect(_),e.getPointCount()>10){if(p=Zt(e,d,n,0,r),p.isEmpty())return!1}else p=e;if(t.getPointCount()>10){if(f=Zt(t,d,n,0,r),f.isEmpty())return!1}else f=t;return sr(p,f,n,"F********",r,!1)}function Ho(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),h=o.querySegmentIterator(),m=$e(2,Number.NaN),l=$e(2,Number.NaN),g=new Dr(i,o,n);let u=!1;for(;g.next();){const e=g.getRedElement(),t=g.getBlueElement();a.resetToVertex(e,-1),h.resetToVertex(t,-1);const s=a.nextSegment(),r=h.nextSegment();let i=0;if(Oo(s,r)?!u&&r.isIntersecting(s,n)&&(u=!0):i=r.intersect(s,null,l,m,n),2===i)u=!0;else if(i){const e=m[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!0;u=!0}}if(!u)return!1;const c=s.constructEmpty(),_=s.constructEmpty(),d=s.constructEmpty(),p=s.constructEmpty(),f=s.constructEmpty();if(e.queryEnvelope(c),t.queryEnvelope(_),xo(_,c,n)){let s,i;if(d.setCoords({env2D:c}),d.inflateCoords(1e3*n,1e3*n),p.setCoords({env2D:_}),p.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:d}),f.intersect(p),e.getPointCount()>10){if(s=Zt(e,f,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(i=Zt(t,f,n,0,r),i.isEmpty())return!1}else i=t;return sr(s,i,n,"T********",r,!1)}return sr(e,t,n,"T*****T**",r,!1)}function ko(e,t,n,r){const i=[!1],o=_o(e,t,n,i);if(i[0])return o;const a=s.constructEmpty();let h;if(t.queryEnvelope(a),a.inflateCoords(1e3*n,1e3*n),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;return rr(h,t,n,r)}function Ao(e,t,s,n){return 1===Lo(e,t,s)}function Mo(e,t,s,n){return 2===Lo(e,t,s)}function Uo(e,t,s,n){const r=new et,i=s*s;for(let o=0;o<e.getPointCount();o++)if(e.queryXY(o,r),et.sqrDistance(r,t)<=i)return!1;return!0}function qo(e,t,s){const n=e.getBoundary();return!n.isEmpty()&&!Uo(n,t,s)}function Bo(e,t,n){const r=s.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 Oo(e,t){return e.getGeometryType()!==i.enumLine||t.getGeometryType()!==i.enumLine}function Yo(e,t,s,n,r,i,o,a){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:s,m_scalarA1:n,m_ivertexB:r,m_ipathB:i,m_scalarB0:o,m_scalarB1:a}}class Ro{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(e,t){const s=this.m_overlapEvents[e],n=this.m_overlapEvents[t];if(s.m_ipathA<n.m_ipathA)return-1;if(s.m_ipathA===n.m_ipathA){if(s.m_ivertexA<n.m_ivertexA)return-1;if(s.m_ivertexA===n.m_ivertexA){if(s.m_scalarA0<n.m_scalarA0)return-1;if(s.m_scalarA0===n.m_scalarA0){if(s.m_scalarA1<n.m_scalarA1)return-1;if(s.m_scalarA1===n.m_scalarA1&&s.m_ivertexB<n.m_ivertexB)return-1}}}return 1}}function Xo(e,t,s){const n=Ln(e,t,s);return n?1===n?1:2:0}function Lo(e,t,s){const n=zn(e,t,s);return n?1===n?1:2:0}function zo(e,t,s,n,r){for(let i=0;i<s;i++)r[i]=Lo(e,t[i],n)}function Wo(e,t,n,r,o){if(e.getGeometryType()===i.enumPolygon)zo(e,t,n,r,o);else if(e.getGeometryType()===i.enumEnvelope){const i=s.constructEmpty();e.queryEnvelope(i),Zo(i,t,n,r,o)}else p("")}function jo(e,t,s,n,r){const a=e.getGeometryType();a===i.enumPolyline?$o(e,t,s,n,r):o(a)?Jo():p("")}function Zo(e,t,s,n,r){if(e.isEmpty()){for(let e=0;e<s;e++)r[e]=0;return}const i=e.clone();i.inflateCoords(.5*-n,.5*-n);const o=e.clone();o.inflateCoords(.5*n,.5*n);for(let a=0;a<s;a++)i.contains(t[a])?r[a]=1:o.contains(t[a])?r[a]=2:r[a]=0}function Ko(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 Qo(e,t,s){if(s.reset(),t<3)return;const n=e[0].clone(),r=n.x,i=n.y,o=e[1].clone(),a=new et;for(let h=2;h<t;h++)a.assign(e[h]),s.pe((a.x-n.x)*(o.y-i)),n.assign(o),o.assign(a);s.pe((r-n.x)*(o.y-i))}function Jo(e,t,s,n,r){l(0)}function $o(e,t,n,r,i){const o=e.getImpl(),a=o.getAccelerators();let h=null;a&&(h=a.getRasterizedGeometry());let m=n;for(let s=0;s<n;s++)i[s]=1,h&&l(0);if(m){if(a){let e=null;null!==a&&null!==a.getQuadTree()&&(e=a.getQuadTree());const h=o.getPointCount();if(null===e&&h>20&&h*n>4*h+Math.log(h)*n&&(e=He(o)),e){let a=null;const h=o.querySegmentIterator(),l=new s;for(let s=0;s<n&&m;s++)if(1===i[s]){l.setCoords(t[s]),null===a?a=e.getIterator(l,r):a.resetIterator(l,r);let n=-1;for(let o=a.next();-1!==o;o=a.next()){h.resetToVertex(e.getElement(o),n),n=h.getPathIndex();if(h.nextSegment().isIntersectingPoint(t[s],r)){i[s]=2,m--;break}i[s]=0}}return}}const e=o.querySegmentIterator();for(;e.nextPath()&&m;)for(;e.hasNextSegment()&&m;){const s=e.nextSegment();for(let e=0;e<n&&m;e++)1===i[e]&&s.isIntersectingPoint(t[e],r)&&(i[e]=2,m--)}}for(let s=0;s<n;s++)1===i[s]&&(i[s]=0)}function ea(e,t,s,n,r){const i=$(t),o=Math.max(4*i,s);return new oa(t,null,o,Number.NaN,r).approximateWithCirclesImpl(e,n)}function ta(){return Number.isNaN(this.radius.value())}function sa(){return{ptStart:new et,ptEnd:new et,center:new J,radius:new At,fcenter:new ie,fradius2:new Mt,maxError:Number.NaN,isLine:ta}}const na=5,ra=1/8;function ia(e,t,s,n){return{pt:e.clone(),t,err:s,checkCount:n}}class oa{constructor(e,t,s,n,r){this.m_left=e,this.m_tracker=r,this.m_eps=s,this.m_trackerCounter=0,this.m_tolerance=n,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc=sa()}closeToCircularArc(e,t,s,n,r,i){if(this.m_circleCheckCounter++,i.maxError=0,!oa.checkSweepAngle(e,t))return!1;if(i.ptStart.setCoordsPoint2D(s),i.ptEnd.setCoordsPoint2D(r),e.isCircular()){const t=e;return i.fradius2=Mt.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),i.radius.set(t.getSemiMajorAxis()),i.fcenter.assignPoint2D(t.getCenter()),i.center.set(t.getCenter()),!0}const o=i.ptEnd.sub(i.ptStart).clone();o.leftPerpendicularThis(),o.normalize();if(Math.abs(o.dotProduct(n.sub(i.ptStart)))<=this.m_eps)return!!this.confirmIsLine(i,o)&&(i.radius.set(Number.NaN),i.center.setCoords(0,0),!0);{const s=i.ptEnd.sub(i.ptStart),r=n.sub(i.ptStart),o=s.crossProduct(r);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*r.sqrLength();let m=a*r.y-h*s.y;m/=o;let l=s.x*h-r.x*a;l/=o;const g=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*g>this.m_eps)return!1;const u=m+i.ptStart.x,c=l+i.ptStart.y;i.radius.set(g),i.center.setCoords(u,c);const _=this.maxCircleApproximationError(e,t,i);if(_>this.m_eps)return i.maxError=_,!1}const a=(new ie).assignPoint2D(i.ptStart),h=(new ie).assignPoint2D(i.ptEnd).sub(a),m=(new ie).assignPoint2D(n).sub(a),l=h.crossProduct(m);if(l.isZero())return!1;const g=h.sqrLength().mulDouble(.5),u=m.sqrLength().mulDouble(.5),c=g.mul(m.y).sub(u.mul(h.y)),_=h.x.mul(u).sub(m.x.mul(g)),d=c.mul(c).add(_.mul(_)),p=l.clone();p.invertThis(),i.fradius2=d.mul(p).mul(p),i.fcenter.setCoords(c.mul(p).add(a.x),_.mul(p).add(a.y)),i.center.setWithEps(i.fcenter.asPoint2D()),i.radius.setWithEps(Math.sqrt(i.fradius2.toDouble()));const f=J.constructPoint2D(i.ptStart).subE(i.center),x=J.constructPoint2D(i.ptEnd).subE(i.center);if(!f.dotProduct(x).gt(Ut))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.enumEllipticArc){const s=e,n=oe(s,t.vmin),r=oe(s,t.vmax);return!(Math.abs(r-n)>.5*yt)}return!0}confirmIsLine(e,t){const s=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(s.mul(.25)))>this.m_eps)&&!(Math.abs(t.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,s){const n=[.25,.75],r=[.1,.25,.75,.9];let o,a;e.getGeometryType()===i.enumEllipticArc?(o=n,a=n.length):(o=r,a=r.length);let h=0;for(let i=0;i<a;++i){const n=new et;e.queryCoord2D(ct(t.vmin,t.vmax,o[i]),n);const r=n.sub(s.center.value()).length(),a=Math.abs(r-s.radius.value());a>h&&(h=a)}return h}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=$e(9,Number.NaN);let r;e?r=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,r=2);const i=[],o=[],a=new et(0,0);for(let h=1;h<r;h++){const e=new at(n[h-1],n[h]);for(this.m_bReversedLeft=!oa.goodOrientation(this.m_left,e),this.m_bReversedLeft?(i.push(ia(a,e.vmin,0,0)),i.push(ia(a,e.vmax,0,0))):(i.push(ia(a,e.vmax,0,0)),i.push(ia(a,e.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t);i.length>1;){this.progress_();const e=i.at(-1);let n=e.checkCount,r=e.err;const a=e.pt.clone(),h=e.t,m=i[i.length-2].t,l=.5*(h+m),g=this.m_left.getCoord2D(l);if(r<=this.m_eps||n>=na){const e=new at;if(e.setCoords(h,m),this.closeToCircularArc(this.m_left,e,a,g,i[i.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(h):t.push(m)),s++,i.pop();continue}n=0,r=this.m_leftArc.maxError}e.t=l,e.pt.setCoordsPoint2D(g),r*=ra,n++,e.err=r,e.checkCount=n,i.push(ia(a,h,r,n))}this.m_bReversedLeft&&t&&(t.length=t.length+o.length,Nt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new w,s=[];if(!this.approximateWithCirclesImpl(!0,s))return t;let n=0;const r=this.m_left.getStartXY();t.startPath(r);for(let i=1;i<s.length;++i)if(e)t.lineTo(this.m_left.getCoord2D(s[i]));else{const e=new et;this.m_left.queryCoord2D(s[i],e);const o=new et;this.m_left.queryCoord2D(.5*(s[i]+n),o);const a=new L;a.constructCircularArcThreePoint(r,e,o),t.addSegment(a,!1),r.assign(e),n=s[i]}return t}static goodOrientation(e,t){const s=e.getCoord2D(t.vmin),n=e.getCoord2D(t.vmax);return s.compare(n)<0}progress_(e=!1){}}function aa(e,t,s,n,r,i,o){ma(e,t,s,r,i,o),Ca(e,s,o)}function ha(e,t,s,n){if(!h(e.getGeometryType()))return e;const r=e.getImpl();if(!r.hasNonLinearSegments())return e;const o=e.createInstance();if(o.getGeometryType()===i.enumPolygon){o.setFillRule(e.getFillRule())}new V;const a=new ye,m=new k,l=[],g=[],u=[],c=e.getDescription().getAttributeCount()>1,_=r.querySegmentIterator();for(;_.nextPath();){let e=!0;for(;_.hasNextSegment();){const n=_.isClosingSegment(),r=_.nextSegment();if(!r.isCurve()){o.addSegment(r,e,n),e=!1;continue}let h,d=!1;const p=!0,f=!0;switch(r.getGeometryType()){case i.enumEllipticArc:case i.enumRationalBezier2:h=U(r,t,s,p,f,g,u,l),d=!0;break;default:h=M(r,t,s,!0,p,g,l)}const x=d?2:3;g[1].isNAN()?(m.createLine(),m.get().construct(g[0],g[x])):d?(m.createQuadraticRationalBezier(),m.get().constructArrayWeights(g,u)):(m.createCubicBezier(),m.get().constructPoints(g)),c&&e&&(r.queryCoord(l[0],a),m.get().setStart(a)),c&&(r.queryCoord(l[1],a),m.get().setEnd(a)),o.addSegment(m.get(),e,n&&1===h),e=!1;for(let e=1,t=h,s=x;e<t;++e,s+=x)g[s+1].isNAN()?(m.createLine(),m.get().construct(g[s],g[s+x])):d?(m.createQuadraticRationalBezier(),m.get().constructArrayWeights(g.slice(s),u.slice(s))):(m.createCubicBezier(),m.get().constructPoints(g.slice(s))),c&&(r.queryCoord(l[e+1],a),m.get().setEnd(a)),o.addSegment(m.get(),!1,n&&e+1===t)}}return o}function ma(e,t,s,n,r,i){e.hasCurves()?(e.setCurveStitcherPointer(n),n.m_impl=new xa(i,!1,null),n.m_impl.buildMonotonicCurveParentage(e,t,s,r)):n.m_impl=null}function la(e,t,s,n,r,i,o,a){e.hasCurves()?(e.setCurveStitcherPointer(i),i.m_impl=new xa(a,!0,r),i.m_impl.buildMonotonicCurveParentage(e,t,s,o),Ca(e,s,a)):i.m_impl=null}function ga(e){if(!e.hasSegmentParentage())return;const t=e.queryVertexIteratorOnSelection();for(let s=t.next();s!==q;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==q?e.getSegmentParentage(t):-1,r=e.getSegmentParentage(s);-1!==r&&-1!==n&&r!==n&&e.setSegmentParentageBreakVertex(s,!0)}}function ua(e){if(!e.hasSegmentParentage())return;ga(e);const t=new be(0),s=e.queryVertexIteratorOnSelection();for(let o=s.next();o!==q;o=s.next())t.add(o);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(q);const n=et.getNAN();e.queryXY(t.read(0),n);let r=0;const i=et.getNAN();for(let o=1,a=t.size();o<a;o++){{const s=t.read(o);s!==q?e.queryXY(s,i):i.setNAN()}if(!i.isEqualPoint2D(n)){if(o-r>1){let s=!1;for(let n=r;n<o;++n){const r=t.read(n);if(e.getSegmentParentageBreakVertex(r)){s=!0;break}}if(!s){const n=(t,s,n)=>{const r=e.getPrevVertex(t),i=e.getNextVertex(t);r!==q?s.assign(e.getXY(r)):s.setNAN(),i!==q?n.assign(e.getXY(i)):n.setNAN()},i=new et,a=new et;n(t.read(r),i,a);for(let e=r+1;e<o;++e){const r=t.read(e);if(r===q)continue;const o=new et,h=new et;n(r,o,h);const m=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if(!(m(o,i)&&m(h,a)||m(h,i)&&m(o,a))){s=!0;break}}}if(s)for(let n=r;n<o;++n)e.setSegmentParentageBreakVertex(t.read(n),!0)}n.setCoordsPoint2D(i),r=o}}}function ca(e,t){let s=t.isEmpty()?e:fe(null,t,!0).total();return s>e&&(s=e),.125*s}function _a(e,t){return t||(t=s.constructEmpty()),ca(e,t)}function da(e,t){return.125*e}function pa(e,t){return 3*e+3*t}class fa{constructor(){this.m_impl=null}stitchCurves(e,t,s,n){this.m_impl&&(this.m_impl.stitchCurves(e,t,s),n&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&(this.m_impl.clearStitcher(e),this.m_impl=null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class xa{constructor(e,t,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=e,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,s,n){const r=!1,o=!0;if(!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=s;const a=new ye,h=new k,m=[],g=[],u=[];for(let c=e.getFirstGeometry();c!==q;c=e.getNextGeometry(c))for(let n=e.getFirstPath(c);n!==q;n=e.getNextPath(n)){let c=e.getPathSize(n),_=e.getFirstVertex(n),d=0,p=-1;for(let f=0;f<c;f++){let x=e.getNextVertex(_);if(!e.querySegment(_,h,!0,!1)){_=x;continue}if(0===d){p=e.getVertexIndex(_);const t=xa.regularizeCurve(e,h.get(),_,s);if(t>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new ts(13,p,-1)),d=t,c=e.getPathSize(n),x=e.getNextVertex(_);const s=e.querySegment(_,h,!0,!1);l(s)}}else d--;const y=e.getVertexIndex(_);let P;-1!==this.m_originalVertexIndex&&e.setUserIndex(_,this.m_originalVertexIndex,p),e.setSegmentToIndex(y,null);let E=!1;switch(h.get().getGeometryType()){case i.enumEllipticArc:case i.enumRationalBezier2:P=U(h.get(),t,s,r,o,g,u,m),E=!0;break;default:{const e=!this.m_bIsSimple||!h.get().isMonotoneQuickAndDirty();P=M(h.get(),t,s,e,r,g,m)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(_,S,!0),!g[1].isNAN()){let t=null;t=E?new R({points:g,weights:u}):new Y({cp:g}),t.snapControlPoints(s*s),e.setSegmentToIndex(y,t)}const C=E?2:3;for(let t=1,r=P,i=C;t<r;++t,i+=C){h.get().queryCoord(m[t],a);const r=e.insertVertex(n,x,a);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,p),!g[i+1].isNAN())if(E){const t=new R({points:g.slice(i),weights:u.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}else{const t=new Y({cp:g.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}e.setSegmentParentageAndBreak(r,S,!1)}P>1&&(f+=P-1,c=e.getPathSize(n)),this.m_originalPlanarSegments.push(h.releaseSegment()),_=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const i=new ye,o=new k,a=new X(0,t,0,this.m_progressTracker,!1,n),h=[];for(let m=e.getFirstGeometry();m!==q;m=e.getNextGeometry(m))for(let t=e.getFirstPath(m);t!==q;t=e.getNextPath(t)){let n=e.getPathSize(t),r=e.getFirstVertex(t);for(let m=0;m<n;m++){let m=e.getNextVertex(r);if(!e.querySegment(r,o,!0,!1)){r=m;continue}if(xa.regularizeCurve(e,o.get(),r,s)>=0){n=e.getPathSize(t),m=e.getNextVertex(r);const s=e.querySegment(r,o,!0,!1);l(s)}const g=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,g),e.setSegmentToIndex(g,null),h.length=0,a.densifySegment(o.get(),h),this.progress_();const u=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,u,!0);for(let s=1,n=h.length-1;s<n;++s){o.get().queryCoord(h[s],i);const n=e.insertVertex(t,m,i);e.setSegmentParentageAndBreak(n,u,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,g)}this.m_originalPlanarSegments.push(o.releaseSegment()),r=m}}e.clearSegments()}stitchCurves(e,t,s){xa.st_stitchCurvesImpl(this,e,t,s,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){xa.st_stitchCurvesImpl(null,e,q,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==q?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case i.enumBezier:return 2;case i.enumBezier2:return 3;case i.enumLine:return-1;case i.enumRationalBezier2:return 4;default:d("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,i,o){if(t===s&&0===n)return l(e.getNextVertex(t)===q),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t),h=e.getXY(t),m=e.getXY(s);let g,u=0;{let t=2,r=h;for(let n=a;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);u+=et.distance(s,r),r=s,t++}u+=et.distance(m,r),l(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const c=o;let _=r.getClosestCoordinate(h,!1),d=r.getClosestCoordinate(m,!1);const p=r.calculateLength2D();let f=r.tToLength(_),x=r.tToLength(d);const y=Math.abs(f)>10*c&&Math.abs(f-p)>10*c,P=Math.abs(x)>10*c&&Math.abs(x-p)>10*c,E=e=>{const t=e.calculateLength2D();return Math.abs(t-u)>Math.max(.2*u,4*c)?null:e};let S=r.isClosed();if(!S){const e=et.distance(r.getStartXY(),r.getEndXY());e<=c&&p>5*e&&(S=!0)}if(S){let i,o,a=new et;if(2===n)a=et.lerp(h,m,.5),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);else{let s=e.getNextNthVertex(t,(n-1)/2);a=e.getXY(s),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);let h=Math.abs(o)>10*c&&Math.abs(o-p)>10*c;if(!h&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i),h=Math.abs(o)>10*c&&Math.abs(o-p)>10*c),!h))return}let u=!1;const S=f===x;if(S){const s=0;let i=2,o=4;n-1<=4&&(i=s+1,o=s+2);const a=h,m=e.getXY(e.getNextNthVertex(t,i)),l=e.getXY(e.getNextNthVertex(t,o));u=-et.orientationNonRobust(a,m,l)*mt(r.calculateArea2DHelper())>0}else P?y?u=o>f:o<x?(f=0,_=0):(f=p,_=1):o>f?(x=p,d=1):(x=0,d=0);if(S)g=r.clone(),g.dropAllAttributes(),u||g.reverse(),l(h.equals(m));else{let e=!1;_>d&&(e=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.getDescription().getAttributeCount(),e&&g.reverse()}g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else if(y||P){if(!y||!P){if(et.distance(r.getStartXY(),r.getEndXY())<10*c){const n=[ot(_,d),ot(_,d),ot(_,d)];y?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],o=[0,0,0];let a=Number.MAX_VALUE,l=0;for(let e=0;e<3;e++){let t=!1;if(n[e].first>n[e].second){t=!0;const s=n[e].first;n[e].first=n[e].second,n[e].second=s}i[e]=r.cut(n[e].first,n[e].second,!0),i[e].dropAllAttributes(),t&&i[e].reverse(),i[e].setCoordsForIntersector(h,m,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(u-o[e]);s<a&&(a=s,l=e)}return g=i[l],g=E(g),void(g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g)))}}let n=!1;_>d&&(n=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.dropAllAttributes(),n&&g.reverse(),g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else{if(g=r.clone(),g.dropAllAttributes(),f>x&&g.reverse(),u<Math.max(.75*p,p-this.m_densificationDeviation*(n-1))){const e=_>d?d:_,t=g.tToLength(e)+u;let s=g.lengthToT(t);s=Pt(s,e,1),g=g.cut(e,s,!0)}g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}}processSpanCurves_(e,t,s,n,r,i,o){if(t===s&&0===n)return l(e.getNextVertex(t)===q),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t);{let t=2;for(let n=a;n!==s;n=e.getNextVertex(n))t++;l(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const h=e.getXY(t),m=e.getXY(s);if(r.isClosed()){if(h.isEqualPoint2D(m)&&h.isEqualPoint2D(r.getStartXY())){let a;if(a=this.verifySegmentFitnessCurves(e,t,s,n,r,i,o)){const n=r.clone();return n.dropAllAttributes(),a<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(h.isEqualPoint2D(r.getStartXY())){if(m.isEqualPoint2D(r.getEndXY())){const a=r.clone();a.dropAllAttributes();const h=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(h)return l(h>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}}else if(m.isEqualPoint2D(r.getStartXY())&&h.isEqualPoint2D(r.getEndXY())){const a=r.getReversed();a.dropAllAttributes();const h=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(h)return l(h>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}this.processSpanSplitSegmentCurves(e,t,s,n,r,i,o)}processSpan_(e,t,s,n,r,i,o){return 0===this.m_type?void this.processSpanSmartTe_(e,t,s,n,r,i,o):void this.processSpanCurves_(e,t,s,n,r,i,o)}processSpanSplitSegmentCurves(e,t,s,n,r,i,o){if(r.isLine())return;if(this.fitSegmentToSpanCurves(e,t,s,n,r,i,o))return;const a=o*o;let h=n,m=t;const l=e.getXY(t);let g=r.getClosestCoordinate(l,!1);const u=r.getCoord2D(g);let c=!1;const _=et.sqrDistance(l,u);if(_>a){const n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),n===s)return;m=n,c=!0,h-=1}let d=s;const p=e.getXY(s);g=r.getClosestCoordinate(p,!1);const f=r.getCoord2D(g);let x=!1;const y=et.sqrDistance(p,f);if(y>a){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===m)return;d=t,x=!0,h-=1}if((c||x)&&this.fitSegmentToSpanCurves(e,m,d,h,r,i,o))return;let P=!1;if(!c&&_>0){const s=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),s===d)return;m=s,c=!0,P=!0,h-=1}if(!x&&y>0){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===m)return;d=t,x=!0,P=!0,h-=1}if(P&&this.fitSegmentToSpanCurves(e,m,d,h,r,i,o))return;let E=m;for(;;){const t=e.getNextVertex(E);if(this.approximateSpanSectionCurves(e,E,r,i,o),E=t,E===d)return}}fitSegmentToSpanCurves(e,t,s,n,r,i,o){const a=[];a.push(e.getXY(t));let h=t;const m=new k;for(;;){e.querySegment(h,m,!1,!0);const t=[.1,.25,.4,.5,.6,.75,.9,1];let r=0;for(const e of t){(2===n||1&r)&&a.push(m.get().getCoord2D(e)),r++}if(h=e.getNextVertex(h),h===s)break}const l=(()=>{let e=a[0].compare(a.at(-1));if(0===e){const t=new dt(0);Qo(a,a.length,t),e=t.getResult()>=0?-1:1}return e>0})();l&&a.reverse();const g=r.clone();if(g.dropAllAttributes(),l&&g.reverse(),g.setSegmentFromCoordsForStitcher(a,a.length),l&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,s,n,g,i,o)){this.removeSpanBetween(e,t,s);const n=e.getVertexIndex(t);return e.setSegmentToIndex(n,g),!0}return!1}approximateSpanSectionCurves(e,t,s,n,r){const o=new k;if(!e.querySegment(t,o,!0,!1))return;const h=s.getGeometryType();if(h!==o.get().getGeometryType()){if(h===i.enumEllipticArc){if(o.get().getGeometryType()!==i.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];ea(!1,o.get(),r,s,this.m_progressTracker);const n=e.getNextVertex(t),i=e.getPathFromVertex(t),a=new ye;let h=t;for(let t=1,r=s.length;t<r;t++){const r=s[t],m=o.get().getCoord2D(s[t-1]),l=o.get().getCoord2D(ct(s[t-1],r,.5));o.get().queryCoord(r,a);const g=a.getXY(),u=new L;u.constructCircularArcThreePoint(m,g,l);let c=q;r<1&&(c=e.insertVertex(i,n,a)),e.setSegmentToIndex(e.getVertexIndex(h),u),h=c}return}{const s=gt(et,3);o.get().queryControlPoints(s);const n=[0,0,0];o.get().queryWeights(n);const r=z(n),i=new L;return W(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}a("approximate_span_section_")}}verifySegmentFitnessCurves(e,t,s,n,r,i,o){const a=e.getXY(t),h=e.getXY(s);if(!a.isEqualPoint2D(r.getStartXY())||!h.isEqualPoint2D(r.getEndXY()))return 0;let m=0;if(r.isClosed()){const e=r.getCoord2D(.1).sub(a);m=r.getCoord2D(.7).sub(a).crossProduct(e)>=0?1:-1}const l=$e(j.s_maxMonotonicPartParams,Number.NaN);let g=r.getMonotonicPartParams(l.length,l);g--;const u=new A,c=[1,.5,.75,.25];let _=0,d=t;const p=a.clone();for(;;){const t=e.getNextVertex(d);let n=e.getSegment(d);null===n&&(e.queryLineConnector(d,u,!0),n=u);for(let e=t===s?1:0;e<c.length;e++){const t=n.getCoord2D(c[e]);if(!r.isCloserThanDistance(t,at.unit(),o))return 0}if(g>1)for(let e=1;e<g;){const t=r.getCoord2D(l[e]);n.isCloserThanDistance(t,at.unit(),o)?(l[g-1]=ht(l[e],l[e]=l[g-1]),g--):e++}if(m){const e=n.getCoord2D(.25);_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e),e.assign(n.getCoord2D(.75)),_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e)}if(d=t,d===s)return g>1?0:m?_<0?-m:m:1}}removeSpanBetween(e,t,s){e.setSegmentToIndex(e.getVertexIndex(t),null);const n=e.getNextVertex(t);n!==s&&e.removeVertices(n,s)}static st_stitchCurvesImpl(e,t,s,n,r){if(!t.hasSegmentParentage())return;ga(t);let i=s===q?t.getFirstGeometry():s;for(;i!==q;)if(C(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);const h=t.getSegmentParentage(a);if(o){if(-1!==h&&!t.getSegmentParentageBreakVertex(a)){let e=t.getPrevVertex(a);const s=a;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(h!==r){l(-1===r);break}if(a=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){a=s,t.setSegmentParentageBreakVertex(a,!0);break}e=t.getPrevVertex(e),l(n<i)}}}else l(-1===h||t.getSegmentParentageBreakVertex(a));let m=a;for(let s=0;s<i&&m!==q;){const o=t.getSegmentParentage(m);if(-1===o){if(s++,m=t.getNextVertex(m),m===a)break;continue}let h=0,g=q;const u=m;h=1;let c=t.getNextVertex(u);for(;s<i&&c!==q;){s++,g=c,h++;const e=t.getSegmentParentage(c);if(-1===e||t.getSegmentParentageBreakVertex(c))break;l(e===o),c=t.getNextVertex(c)}if(g===q){l(0);break}if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,u,g,h,s,o,n)}if(m=g,m===a)break}}if(s!==q)break;i=t.getNextGeometry(i)}else i=s===q?t.getNextGeometry(i):q}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let i=s===q?t.getFirstGeometry():s;for(;i!==q;){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);t.isClosedPath(s)&&(i+=1);let o=!0,a=!1;const h=t.getFirstVertex(s);let m=h;for(let s=0;s<i&&m!==q;){let g=t.getSegmentParentage(m);if(-1===g||o){o=!1,s++,m=t.getNextVertex(m),a=!0;continue}let u,c,_=0;if(a?(u=t.getPrevVertex(m),c=m,l(u!==q),l(c!==u),l(-1===t.getSegmentParentage(u)||h===u)):(u=m,c=t.getNextVertex(u),s++,l(c!==q),l(c!==u),g=t.getSegmentParentage(c)),_=2,a=!1,-1===g||t.getSegmentParentageBreakVertex(c)){m=c;continue}let d=t.getNextVertex(c);for(s++;s<i&&d!==q;){c=d,_++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;l(e===g),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[g];e.processSpan_(t,u,c,_,s,g,n)}m=c}}if(s!==q)break;i=t.getNextGeometry(i)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let i=s===q?t.getFirstGeometry():s;for(;i!==q;)if(C(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);if(o){if(-1!==t.getSegmentParentage(a)){let e=a;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===i){a=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else l(-1===t.getSegmentParentage(a)||t.getSegmentParentageBreakVertex(a));let h=a;for(let s=0;s<i&&h!==q;){const o=t.getSegmentParentage(h);if(-1===o){s++,h=t.getNextVertex(h);continue}let a=0,m=q;const g=h;a=1;let u=t.getNextVertex(g);for(;s<i&&u!==q;){s++,m=u,a++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;l(e===o),u=t.getNextVertex(u)}if(m===q)break;if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,g,m,a,s,o,n)}h=m}}if(s!==q)break;i=t.getNextGeometry(i)}else i=s===q?t.getNextGeometry(i):q}static regularizeCurve(e,t,s,n){let r=t.snapControlPoints(n*n);if(r){const n=e.getVertexIndex(s),r=t.clone();e.setSegmentToIndex(n,r)}if(t.getGeometryType()===Y.type){const i=[],o=t.calculateSpecialPointsForCracking(n,i);if(o>0){const a=[];if(o>1)for(let e=0;e<o;e++)if(a.push(t.getCoord2D(i[e])),e>0){const t=(Math.abs(a[e].x)+Math.abs(a[e].y))*St(),s=et.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new et;Ct(a[e-1],a[e],.5,t),a[e-1]=t,a[e]=t}}e.splitSegment(s,i,o),r=e.snapControlPoints(s,o+1,n*n)||r;for(let t=0;t<o;t++)s=e.getNextVertex(s),e.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function ya(e,t,s,n,r){return new ba(e,s,t,n,r).do_()}function Pa(e,t,s){const n=Ee(e);return ln(t.getX(),t.getY(),s.getX(),s.getY(),pt(n))}function Ea(e,t,s=1,n=1,r=1,i=1){if(n>i)return e;if(i>n)return t;const o=[0],a=[0],h=new ye;return cn(e,t,s,n,r,i,h,a,o),h}function Sa(e,t,s){const n=Ee(t),r=Ie(t);return!!_n(e,n,q,null,s)||Mn(!0,e,r,null,s)}function Ca(e,t,s){return ba.fixCurveTwoPointLoops(e,t,s)}function Ia(e){return Ee(e)}class ba{constructor(e,t,s,n,r){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=r,this.m_progressCounter=0}do_(){const e=new Pe(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=1e-5,s=1e-6,n=Ia(e);let r=Ie(e);const i=r*(1+t);r*=1+s;let o=!1;const h=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),m=this.m_shape.hasPointFeatures();for(let l=0;;l++){this.m_shape.dbgCheckSelection(),l>h&&a("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let e=-1;0===l&&(e=this.firstCrack_(),o||=e>0);const t=this.cluster_(n);if(this.m_shape.dbgVerifyMonotone(),o||=t,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(n,!0,!1,this.m_bTrackChanges,q);o||=e,this.m_shape.dbgVerifyMonotone()}const s=this.m_shape.snapControlPointsOnSelection(i*i);o||=s,this.m_shape.dbgCheckSelection();let g=!1;if((0===l&&-1===e||m||Mn(!0,this.m_shape,r,null,this.m_progressTracker))&&(g=this.crack_(i),o||=g,this.m_shape.dbgVerifyMonotone()),!g&&!ba.fixCurveTwoPointLoops(this.m_shape,n,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return o&&ua(this.m_shape),o}cluster_(e){return mn(this.m_shape,e,q,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return An(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,s){if(!e.hasCurves())return!1;e.dbgVerifyCurves();const n=e.createUserIndexUninitialized(),r=new be(0),i=e.queryVertexIteratorOnSelection();for(let l=i.next();l!==q;l=i.next())r.add(l),e.setUserIndex(l,n,-1);if(0===r.size())return!1;r.add(q),e.sortVerticesSimpleByY(r,0,r.size()-1);let o=0;const a=e.getXY(r.read(o)),h=new et(Number.NaN,Number.NaN),m=[];for(let l=1,g=r.size();l<g;++l){const t=r.read(l),s=t!==q?e.getXY(t):h;if(s.equals(a))continue;const i=[];for(let h=o;h<l;h++){const t=r.read(h),s=e.getPrevVertex(t);if(s!==q&&-1===e.getUserIndex(s,n)){const t=wa(e.getXY(s),e.getSegment(s));0!==et.sqrDistance(a,t.otherPt)&&(t.vert=s,t.dir=-1,i.push(t)),e.setUserIndex(s,n,1)}const o=e.getNextVertex(t);if(o!==q&&-1===e.getUserIndex(t,n)){const s=wa(e.getXY(o),e.getSegment(t));0!==et.sqrDistance(a,s.otherPt)&&(s.vert=t,s.dir=1,i.push(s)),e.setUserIndex(t,n,1)}}if(i.length>1){i.sort((e,t)=>Ta(e,t));const e=wa(h.clone(),null);i.push(e);let t=0;for(let s=1,n=i.length;s<n;s++)if(!i[s].otherPt.equals(i[s-1].otherPt)){if(s-t>1&&null!==i[t].seg){let e=!1;const n=t;for(let r=t+1;r<s;r++)if(!va(i[n],i[r])){e=!0;break}if(e)for(let r=t;r<s&&null!==i[r].seg;r++)m.push(i[r].vert)}t=s}}o=l,a.setCoordsPoint2D(s)}for(const g of m){const s=e.getSegment(g);l(null!==s);const n=e.getXY(g),r=e.getXY(e.getNextVertex(g));if(et.distance(n,r)<3*t)e.setSegmentToIndex(e.getVertexIndex(g),null);else{const t=s.lengthToT(.5*s.calculateLength2D());e.splitSegment(g,[t],1)}}return e.removeUserIndex(n),m.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=fe(null,e,!0).total();if(4*t<this.m_tolerance.total()){let e=!1;const s=1.1*t,n=t,r=this.cluster_(s);e||=r;let i=0;this.m_bFilterDegenerateSegments&&(i=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,q));const o=this.crack_(n);return e||=o,e?1:i?2:0}return-1}progress_(e=!1){this.m_progressCounter++,!e&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function wa(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function va(e,t){if(l(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const s=e.seg.getGeometryType();if(s!==t.seg.getGeometryType())return!1;if(s===i.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=ht(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=ht(o,o=a)),r.equals(o)&&i.equals(a)}if(s===i.enumRationalBezier2){const s=e.seg,n=t.seg,r=s.getControlPoint1(),i=n.getControlPoint1();if(!r.equals(i))return!1;const o=[0,0,0];s.queryWeights(o),-1===e.dir&&(o[2]=ht(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=ht(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}a("")}function Na(e,t){if(null===e.seg||null===t.seg)return null!==e.seg?-1:null!==t.seg?1:0;const s=e.seg.getGeometryType(),n=t.seg.getGeometryType();return s<n?-1:s>n?1:0}function Ta(e,t){const s=e.otherPt.compare(t.otherPt);return 0!==s?s:Na(e,t)}var Ga=h,Da=o,Va=u;function Fa(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 Ha(){return{unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1}}function ka(e,t,s,n){return new Ka(n).autoCompleteImpl(e,t,s)}function Aa(e,t,s,n,r,o,a){const h=new Ka(r);h.m_bOGCOutput=!0;const m=e.getGeometryType()===i.enumPolygon&&1===e.getFillRule()&&!De(n);return h.planarSimplifyImpl_(e,t,m,s,n,r,o,a)}function Ma(e,t,s,n,r,i,o,a){return new Ka(i).planarSimplifyImpl_(e,t,s,n,r,i,o,a)}function Ua(e,t,s,n){const r=new Ka(n),i=new V,o=i.addGeometry(t),a=r.planarSimplifyNoCrackingAndCluster(e,i,o,s);l(a,"planar_simplify_no_cracking_and_cluster");return i.getGeometry(o)}function qa(e,t,s,n,r,i,o){return l(0),{}}function Ba(e,t,s,n){return l(0),{}}function Oa(e,t,s){return Ja(e,t,s)}function Ya(e,t,n,r){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return $a(eh(e),e,t,"-");const o=new s;e.queryEnvelope(o);const a=new s;t.queryEnvelope(a);const h=new s;h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=a.clone(),g=Ee(m);if(l.inflateCoords(g,g),!o.isIntersecting(l))return $a(eh(e),e,t,"-");const u=new Ka(r),c=new V,_=c.addGeometry(eh(e)),d=c.addGeometry(eh(t));let p=0,f=0,x=null;if(c.hasCurves()){x=new fa;const e=c.getEnvelope2D(r);f=da(m.total());const t=_a(m.total(),e);p=pa(t,f),aa(c,t,m.total(),12e3,x,null,r)}u.setEditShapeCrackAndCluster(c,m.add(p));const y=u.difference(_,d);null!==x&&x.stitchCurves(c,y,f,!0);const P=$a(c.getGeometry(y),e,t,"-");return Ga(P.getGeometryType())&&(P.getImpl().setIsSimple(4,m.total()),P.getGeometryType()===i.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Ra(e,t,n,r){if(e.getDimension()>t.getDimension())return $a(eh(e),e,t,"^");if(e.getDimension()<t.getDimension())return $a(eh(t),e,t,"^");if(e.isEmpty())return $a(eh(t),e,t,"^");if(t.isEmpty())return $a(eh(e),e,t,"^");const o=new s;e.queryEnvelope(o);const a=new s;t.queryEnvelope(a);const h=new s;h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=new Ka(r),g=new V,u=g.addGeometry(eh(e)),c=g.addGeometry(eh(t));let _=0,d=null;if(g.hasCurves()){d=new fa;const e=g.getEnvelope2D(r);_=da(m.total());aa(g,_a(m.total(),e),m.total(),12e3,d,null,r)}l.setEditShapeCrackAndCluster(g,m);const p=l.symmetricDifference(u,c);null!==d&&d.stitchCurves(g,p,_,!0);const f=$a(g.getGeometry(p),e,t,"^");return Ga(f.getGeometryType())&&(f.getImpl().setIsSimple(4,m.total()),f.getGeometryType()===i.enumPolygon&&f.getImpl().updateOGCFlagsProtected()),f}function Xa(e,t,s){return Qa(e,t,s,!0)}function La(e,t,s){return e.isEmpty()||t.isEmpty()?e.createInstance():Pa(s,e,t)?new ye({copy:Ea(e,t)}):e.createInstance()}function za(e,t,n,r){const o=s.constructEmpty();e.queryEnvelope(o);const a=s.constructEmpty();t.queryEnvelope(a);const h=s.constructEmpty();h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=new s(a),g=Ee(m);if(l.inflateCoords(g,g),!o.isIntersecting(l)){if(e.getDimension()<=t.getDimension())return $a(eh(e.createInstance()),e,t,"&");if(e.getDimension()>t.getDimension())return $a(eh(t.createInstance()),e,t,"&")}const u=new Ka(r),c=new V,_=c.addGeometry(eh(e)),d=c.addGeometry(eh(t));let p=0,f=0,x=null;if(c.hasCurves()){x=new fa;const e=c.getEnvelope2D(r);f=da(m.total());const t=_a(m.total(),e);p=pa(t,f),aa(c,t,m.total(),12e3,x,null,r)}u.setEditShapeCrackAndCluster(c,m.add(p));const y=u.intersection(_,d);null!==x&&x.stitchCurves(c,y,f,!0);const P=$a(c.getGeometry(y),e,t,"&");return Ga(P.getGeometryType())&&(P.getImpl().setIsSimple(4,m.total()),P.getGeometryType()===i.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Wa(e,t,n,r){const o=new Array(3),a=s.constructEmpty();e.queryEnvelope(a);const h=s.constructEmpty();t.queryEnvelope(h);const m=s.constructEmpty();m.setCoords({env2D:a}),m.mergeEnvelope2D(h);const l=fe(n,m,!0),g=new s(h),u=Ee(l);if(g.inflateCoords(u,u),!a.isIntersecting(g)){if(e.getDimension()<=t.getDimension()){const s=$a(eh(e.createInstance()),e,t,"&");return o[s.getDimension()]=s,o}if(e.getDimension()>t.getDimension()){const s=$a(eh(t.createInstance()),e,t,"&");return o[s.getDimension()]=s,o}}const c=new Ka(r),_=new V,d=_.addGeometry(eh(e)),p=_.addGeometry(eh(t));let f=0,x=0,y=null;if(_.hasCurves()){y=new fa;const e=_.getEnvelope2D(r);x=da(l.total());const t=_a(l.total(),e);f=pa(t,x),aa(_,t,l.total(),12e3,y,null,r)}c.setEditShapeCrackAndCluster(_,l.add(f)),_.dbgVerifyCurves();const P=c.intersectionEx(d,p);for(const s of P){null!==y&&y.stitchCurves(_,s,x,!1);const n=$a(_.getGeometry(s),e,t,"&");Ga(n.getGeometryType())&&(n.getImpl().setIsSimple(4,l.total()),n.getGeometryType()===i.enumPolygon&&n.getImpl().updateOGCFlagsProtected()),o[n.getDimension()]=n}return null!==y&&y.clearStitcher(_),o}function ja(e,t,s,r,i,o=!1){0===t&&n("not enough geometries to dissolve");let a=0;for(let n=0,d=t;n<d;n++)a=Math.max(e[n].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!1,e,t,s,i,o);let h=0,m=-1;for(let n=0,d=t;n<d;n++)e[n].getDimension()===a&&(-1===m&&(m=n),e[n].isEmpty()||(m=n,h++));if(h<2)return eh(e[m]);const l=Ve.constructEmpty(),g=new V;let u=q;for(let n=0,d=t;n<d;n++)if(e[n].getDimension()===a&&!e[n].isEmpty()){u===q?u=g.addGeometry(eh(e[n])):g.appendGeometry(u,eh(e[n]));const t=Ve.constructEmpty();e[n].queryLooseEnvelope(t),l.mergeEnv3D(t)}const c=fe(s,l.getEnvelope2D(),!0),_=new Ka(r);if(o){const e=Fe(s,l.getEnvelopeZs(),!0);return _.planarSimplify3DImpl_(g,c,e,0,!0)}return _.m_bOGCOutput=!0,_.planarSimplifyMultiPoints(g,c,!1,-1)}function Za(e,t,s,r,i,o=!1){t<2&&n("not enough geometries to dissolve");let a=0;for(let n=0,p=t;n<p;n++)a=Math.max(e[n].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!0,e,t,s,i,o);const h=Ve.constructEmpty(),m=new V;let l=q,g=0,u=-1;for(let n=0,p=t;n<p;n++)if(e[n].getDimension()===a&&(-1===u&&(u=n),!e[n].isEmpty())){u=n,l===q?l=m.addGeometry(eh(e[n])):m.appendGeometry(l,eh(e[n]));const t=Ve.constructEmpty();e[n].queryLooseEnvelope(t),h.mergeEnv3D(t),g++}if(g<2)return eh(e[u]);const c=0===a?s:null,_=fe(c,h.getEnvelope2D(),!0),d=new Ka(r);if(o){const e=Fe(c,h.getEnvelopeZs(),!0);return d.m_bOGCOutput=!0,d.planarSimplify3DImpl_(m,_,e,0,!0)}return d.planarSimplifyMultiPoints(m,_,!0,-1)}class Ka{constructor(e){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=et.getNAN(),this.m_dummyPt2=et.getNAN(),this.m_fromEdgeForPolylines=q,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=e}linesToPolygonsImpl(e,t){let s=0,n=0,r=null;if(e.hasCurves()){r=new fa;const i=e.getEnvelope2D(this.m_progressTracker);n=da(t.total());const o=_a(t.total(),i);s=pa(o,n),aa(e,o,t.total(),12e3,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(s));const i=this.m_topoGraph.createUserIndexForChains(),o=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(o,i,1);for(let h=this.m_topoGraph.getChainFirstIsland(o);h!==q;h=this.m_topoGraph.getChainNextInParent(h))this.m_topoGraph.setChainUserIndex(h,i,1);const a=[];for(let h=this.m_topoGraph.getFirstChain();h!==q;h=this.m_topoGraph.getChainNext(h)){if(1===this.m_topoGraph.getChainUserIndex(h,i))continue;this.m_topoGraph.setChainUserIndex(h,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(h);e!==q;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);if(0===this.m_topoGraph.getChainArea(h))continue;const t=this.m_topoGraph.extractPolygonFromChainAndIslands(e,q,h,q);null!=r&&r.stitchCurves(e,t,n,!1);const s=e.getGeometry(t);a.push(s)}return new es(a)}autoCompleteImpl(e,t,s){let n=0,r=0,i=null;if(e.hasCurves()){i=new fa;const t=e.getEnvelope2D(this.m_progressTracker);r=da(s.total());const o=_a(s.total(),t);n=pa(o,r),aa(e,o,s.total(),12e3,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,s.add(n));const o=this.m_topoGraph.getGeometryID(t),a=this.m_topoGraph.createUserIndexForChains(),h=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(h,a,1);for(let l=this.m_topoGraph.getChainFirstIsland(h);l!==q;l=this.m_topoGraph.getChainNextInParent(l))this.m_topoGraph.setChainUserIndex(l,a,1);const m=[];for(let l=this.m_topoGraph.getFirstChain();l!==q;l=this.m_topoGraph.getChainNext(l)){if(1===this.m_topoGraph.getChainUserIndex(l,a))continue;this.m_topoGraph.setChainUserIndex(l,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(l);e!==q;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);if(0!==this.m_topoGraph.getChainParentage(l))continue;const t=this.m_topoGraph.getChainHalfEdge(l);let s=t,n=!1;do{const e=this.m_topoGraph.getHalfEdgeTwin(s);if(this.m_topoGraph.getHalfEdgeChain(e)!==l&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){n=!0;break}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==t);if(!n)continue;if(0===this.m_topoGraph.getChainArea(l))continue;const h=this.m_topoGraph.extractPolygonFromChainAndIslands(e,q,l,q);null!==i&&i.stitchCurves(e,h,r,!1);const g=e.getGeometry(h);m.push(g)}return new es(m)}setEditShape(e,t=!1){null===this.m_topoGraph&&(this.m_topoGraph=new tn),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){ya(e,t,this.m_progressTracker,!0,!1);for(let s=e.getFirstGeometry();s!==q;s=e.getNextGeometry(s))e.getGeometryType(s)===i.enumPolygon&&er(e,s,-1,this.m_bOGCOutput,q,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==q;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==q;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===q)continue;let r=s.getNextVertex(n);for(;r!==q;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),o=this.m_topoGraph.getHalfEdgeConnector(t,i);if(o!==q){const t=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}n=r,r=s.getNextVertex(n)}}}flushVertices_(e,t){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),r=new k,i=s.insertPath(e,q);t.push(t[0]);const o=t.length;let a=q;for(let h=0;h<o;h++){const e=t[h];if(a=s.addVertex(i,e),!n)continue;const m=this.m_topoGraph.getClusterFromVertex(e);if(h>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(a,!0),h<o-1){const e=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(t[h+1])),n=this.m_topoGraph.getSegmentParentage(e);s.setSegmentParentageAndBreak(a,n,h>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,r),s.setSegmentToIndex(s.getVertexIndex(a),r.get().clone()))}}if(n){const e=this.m_topoGraph.getClusterFromVertex(t[o-1]);this.m_topoGraph.isBreakNode(e)&&s.setSegmentParentageBreakVertex(a,!0)}s.setClosedPath(i,!0)}processPolygonCuts_(e,t,s,n){const r=this.m_topoGraph.getGeometryID(s),o=this.m_topoGraph.getGeometryID(n),a=[],h=this.m_topoGraph.getShape(),m=this.m_topoGraph.createUserIndexForHalfEdges();for(let l=this.m_topoGraph.getFirstCluster();l!==q;l=this.m_topoGraph.getNextCluster(l)){const s=this.m_topoGraph.getClusterHalfEdge(l);if(s===q)continue;let n=s;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(n,m)){let s=n,l=n,g=!1,u=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,m,1),!g){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&r)&&(l=s,g=!0)}}if(g){const t=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(n);if(a.push(r),-1!==e){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){u|=this.m_topoGraph.getHalfEdgeUserIndex(s,e)}}}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==l);if(g&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(l))>0){const e=h.createGeometry(i.enumPolygon);this.flushVertices_(e,a),-1!==t&&h.setGeometryUserIndex(e,t,u)}a.length=0}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==s)}this.m_topoGraph.deleteUserIndexForHalfEdges(m)}cutPolygonPolyline_(e,t,s,n){this.m_topoGraph.removeSpikes_();let r=-1;-1!==e&&(r=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(r,s)),this.processPolygonCuts_(r,e,t,s),-1!==r&&(this.m_topoGraph.deleteUserIndexForHalfEdges(r),r=-1);const i=this.m_topoGraph.getShape();for(let o=i.getFirstGeometry();o!==q;o=i.getNextGeometry(o))o!==t&&o!==s&&n.push(o);n.sort((e,t)=>{const s=i.getFirstPath(e),n=i.getRingArea(s),r=i.getFirstPath(t),o=i.getRingArea(r);return n<o?-1:n>o?1:0})}cut(e,t,s,n,r){const i=this.m_topoGraph.getShape().getGeometryType(s),o=this.m_topoGraph.getShape().getGeometryType(n),h=u(i),m=u(o);if(2!==h||1!==m){if(1===h&&1===m){return void new sh(this,e,t,s,n,r).Do()}a("")}else this.cutPolygonPolyline_(t,s,n,r)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){const t=e.getGeometryType();if(t===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(o(t)){const t=new w({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,s,n){l(t>0);const r=new V;let i=0,o=-1;for(let a=0,h=t;a<h;a++)2===e[a].getDimension()&&(-1===o&&(o=a),e[a].isEmpty()||(i++,r.addGeometry(e[a])));return 0===i?(l(o>=0),this.normalizeInputGeometry(e[o])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,n,r,a,m,g){l(e>=1&&e<=2),l(r>0);const u=8&m?1:2,_=Ve.constructEmpty();let d=0,p=-1,f=!0;for(let s=0,o=r;s<o;s++)if(n[s].getDimension()===e&&(-1===p&&(p=s),!n[s].isEmpty())){p=s,d++;const t=Ve.constructEmpty();if(n[s].queryLooseEnvelope(t),_.mergeEnv3D(t),2===e&&f&&n[s].getGeometryType()===i.enumPolygon)if(16&m){const e=[0],t=n[s].getImpl().getIsSimple(0,e),r=this.m_bOGCOutput?5===t:de(t);f&&=r}else{const e=Be(n[s],0);f&&=e}}if(d<2&&(l(p>=0),0===d||!(16&m)))return this.normalizeInputGeometry(n[p]);if(!f){const e=fe(t?null:a,_.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(n,r,e,m)}const x=n.slice(0,r),y=fe(a,_.getEnvelope2D(),!0),P=10*Ee(y);let E=new Pe(0,0);if(g&&(E=Fe(a,_.getEnvelopeZs(),!0)),1===d&&1===e&&2===u&&!t)return g?qa():this.m_bOGCOutput?Aa(x[p],y,!1,-1,this.m_progressTracker,u,!1):Ma(x[p],y,!1,!1,-1,this.m_progressTracker,u,!1);const S=new Oe;S.startConstruction();let C=2===e?3:4,I=0;for(let c=0,w=r;c<w;c++){if(x[c].getDimension()!==e||x[c].isEmpty())continue;let n=x[c].getGeometryType();if(n!==i.enumEnvelope){if(o(n)?(x[c]=this.normalizeInputGeometry(x[c]),n=i.enumPolyline):l(h(n)),1===e){l(n===i.enumPolyline);let e=-1;if(g)l(0,"3d not implemented yet");else{const t=[0];e=x[c].getImpl().getIsSimple(y.total(),t)}if(this.m_bOGCOutput?5!==e:!de(e))if(t)C=-1;else{g?l(0,"3d not implemented yet"):this.m_bOGCOutput?x[c]=Aa(x[c],y,!1,-1,this.m_progressTracker,u,!1):x[c]=Ma(x[c],y,!1,!1,-1,this.m_progressTracker,u,!1);const e=[0];l(de(x[c].getImpl().getIsSimple(y.total(),e)))}}else{l(n===i.enumPolygon);const e=[0],t=x[c].getImpl().getIsSimple(0,e);l(De(t))}const r=x[c].getImpl();for(let e=0,t=r.getPathCount();e<t;e++){const t=s.constructEmpty();r.queryLoosePathEnvelope(e,t),t.inflateCoords(P,P),S.addEnvelope(I,t),I++}}else{l(n===i.enumEnvelope);const e=s.constructEmpty();x[c].queryLooseEnvelope(e),e.inflateCoords(P,P),S.addEnvelope(I,e),I++,C=-1}}S.endConstruction();const b=I,v=$e(b,-2147483647),N=$e(b,-1);let G=0;p=-1,I=0;for(let s=0,o=r;s<o;s++){if(x[s].getDimension()!==e)continue;if(-1===p&&(p=s),x[s].isEmpty())continue;p=s,G++;const t=x[s].getGeometryType();if(h(t)){for(let e=0,t=x[s].getPathCount();e<t;e++)N[I]=s,v[I]=-e-1,I++}else l(t===i.enumEnvelope),N[I]=s,v[I]=-1,I++}if(G<2&&2===e)return l(p>=0),this.normalizeInputGeometry(x[p]);let D=b;for(;S.next()&&D>0;){this.progress_();const e=S.getHandleA(),t=S.getHandleB(),s=S.getElement(e),n=S.getElement(t);N[s]!==N[n]&&(v[s]<0&&(D--,v[s]=-(v[s]+1)),v[n]<0&&(D--,v[n]=-(v[n]+1)))}const F=new V;let H=!1,k=0;for(let s=0,o=r;s<o;s++){if(x[s].getDimension()!==e||x[s].isEmpty())continue;const t=x[s].getGeometryType(),n=k;let r=0,o=0;const a=h(t)?x[s]:null;for(let e=n,i=v.length;e<i&&N[e]===s;e++)v[e]>=0&&(r++,o+=a?a.getPathSize(v[e]):c(x[s])),k++;if(o>.95*c(x[s])){F.addGeometry(this.normalizeInputGeometry(x[s]));for(let e=n;e<k;e++)v[e]<0&&(v[e]=-(v[e]+1))}else{if(0===r){H=!0;continue}{H=!0,l(h(t)),l(null!=a);const e=new T({vd:x[s].getDescription()}),r=new w({vd:x[s].getDescription()}),o=t===i.enumPolygon?e:r;for(let t=n;t<k;t++)v[t]>=0&&o.addPath(a,v[t],!0);F.addGeometry(o)}}}let A;if(F.getFirstGeometry()!==q){const s=2===e,n=t?fe(null,_.getEnvelope2D(),!0):y;let r=new Pe(0,0);if(g&&(r=t?Fe(null,_.getEnvelopeZs(),!0):E),2===e&&!(2&m)){F.collapseAllGeometriesToFirst();let e=0,t=null;if(F.hasCurves()&&!F.hasSegmentParentage()){t=new fa;const s=F.getEnvelope2D(this.m_progressTracker);e=da(n.total());aa(F,_a(n.total(),s),n.total(),12e3,t,null,this.m_progressTracker)}Vn(F,F.getFirstGeometry(),n.total(),this.m_progressTracker),null!==t&&t.stitchCurves(F,q,e,!0)}if(g)A=this.planarSimplify3DImpl_(F,n,r,u,!0);else if(2===e)A=this.planarSimplifyPolygons(F,n,s,t,-1,!1);else{const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=u,A=this.planarSimplifyPolylines(F,n,t,e,-1)}if(!H){const e=[0];C=A.getImpl().getIsSimple(n.total(),e)}}else l(H),l(p>=0),A=2===e?new T({vd:x[p].getDescription()}):new w({vd:x[p].getDescription()});if(H){let e=0;for(let t=0,s=v.length;t<s;t++){const s=N[t];if(!(s<0)&&v[t]<0){const n=x[s].getGeometryType(),r=h(n)?x[s]:null;if(r){const s=-(v[t]+1);e+=r.getPathSize(s)}else e+=4}}A.reserve(A.getPointCount()+e);for(let t=0,s=v.length;t<s;t++){const e=N[t];if(!(e<0)&&v[t]<0){const s=x[e].getGeometryType(),n=h(s)?x[e]:null;if(n){const e=-(v[t]+1);A.addPath(n,e,!0)}else s===i.enumEnvelope?A.addEnvelope(x[e],!1):(l(o(s)),A.addSegment(x[e],!0))}}}let M=0;if(2===e?-1!==C&&(C=3,M=t?0:y.total()):(l(1===e),t||-1===C||(M=y.total())),g||A.getImpl().setIsSimple(C,M),!t&&H)if(2===e){if(!g)return(new Eh).execute(A,a,!1,this.m_progressTracker);l(0,"3d not yet implemented")}else 1===e&&1!==u&&(A=g?Ba():Ua(this.m_bOGCOutput,A,u,this.m_progressTracker),A.getImpl().setIsSimple(C,M));return A}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==q;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==q)do{this.progress_();if(1!==this.m_topoGraph.getHalfEdgeUserIndex(r,e)){const s=this.m_topoGraph.getHalfEdgeTwin(r);this.m_topoGraph.setHalfEdgeUserIndex(s,e,1),this.m_topoGraph.setHalfEdgeUserIndex(r,e,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(r);if(this.isGoodParentage(n)){const e=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(e)&&t.push(r)}}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,s,n){let r=vt(),i=q;for(let a=this.m_topoGraph.getClusterVertexIterator(e);a!==q;a=this.m_topoGraph.incrementVertexIterator(a)){const e=this.m_topoGraph.getVertexFromVertexIterator(a),n=t.getUserIndex(e,s);n>=0&&n<r&&(r=n,i=e)}l(i!==q);let o=t.getUserIndex(i,n);return o>0&&(t.setUserIndex(i,n,--o),0===o&&t.setUserIndex(i,s,-1)),i}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,s,n,r){const o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==i.enumPolygon)return;const a=o.hasSegmentParentage(),h=new k;for(let i=o.getFirstPath(e);i!==q;i=o.getNextPath(i)){const e=o.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);const m=this.m_topoGraph.getHalfEdgeFromVertex(e);if(m===q)continue;const l=this.m_topoGraph.getHalfEdgeUserIndex(m,s);if(1===l||2===l)continue;const g=this.m_topoGraph.getHalfEdgeFaceParentage(m);if(!this.isGoodParentage(g)){this.m_topoGraph.setHalfEdgeUserIndex(m,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(m,s,1);const u=o.insertPath(t,q);o.setClosedPath(u,!0);let c=m,_=e,d=this.m_topoGraph.getClusterFromVertex(_),p=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(_,r),t=o.addVertex(u,e);if(this.m_topoGraph.isHalfEdgeCurve(c)&&(this.m_topoGraph.querySegmentXY(c,h),o.setSegmentToIndex(o.getVertexIndex(t),h.get().clone())),a){const e=this.m_topoGraph.getSegmentParentage(c);o.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(d))}let i,m;-1!==n&&this.m_topoGraph.setClusterUserIndex(d,n,1),this.m_topoGraph.setHalfEdgeUserIndex(c,s,1),c=this.m_topoGraph.getHalfEdgeNext(c);do{i=1===p?o.getNextVertex(_):o.getPrevVertex(_),m=i!==q?this.m_topoGraph.getClusterFromVertex(i):q}while(m===d);const l=this.m_topoGraph.getHalfEdgeOrigin(c);if(l!==m){do{i=1===p?o.getPrevVertex(_):o.getNextVertex(_),m=i!==q?this.m_topoGraph.getClusterFromVertex(i):q}while(m===d);if(l!==m){m=l;const e=this.m_topoGraph.getClusterVertexIterator(m);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else p=-p}d=m,_=i}while(c!==m)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==q&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==q&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const o=new k,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const h=a.hasSegmentParentage();for(let m=this.m_topoGraph.getFirstCluster();m!==q;m=this.m_topoGraph.getNextCluster(m)){const e=this.m_topoGraph.getClusterHalfEdge(m);if(e===q)continue;let t=e;do{this.progress_();const e=this.m_topoGraph.getHalfEdgeUserIndex(t,r);if(1!==e&&2!==e){const e=this.m_topoGraph.getHalfEdgeFaceParentage(t);if(this.isGoodParentage(e)){const e=a.insertPath(s,q);a.setClosedPath(e,!0);let m=t;do{const t=this.m_topoGraph.getHalfEdgeVertexIterator(m);let s=q;if(t!==q)s=this.m_topoGraph.getVertexFromVertexIterator(t);else{const e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(m));s=this.m_topoGraph.getVertexFromVertexIterator(e),s=a.getNextVertex(s)}const l=this.chooseVertexFromVertexCluster_(s,n),g=a.addVertex(e,l);if(h){const e=this.m_topoGraph.getSegmentParentage(m),t=this.m_topoGraph.getHalfEdgeOrigin(m);a.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.isHalfEdgeCurve(m)&&(this.m_topoGraph.querySegmentXY(m,o),a.setSegmentToIndex(a.getVertexIndex(g),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(m,r,1),-1!==i){const e=this.m_topoGraph.getClusterFromVertex(l);this.m_topoGraph.setClusterUserIndex(e,i,1)}m=this.m_topoGraph.getHalfEdgeNext(m)}while(m!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,r,2)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}}topoOperationPolygonPolygon_(e,t,s,n=!1){this.dissolveTopoGraphCommonEdges_();const r=this.m_topoGraph.getShape(),o=r.createGeometry(i.enumPolygon),a=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,s,a,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(a),n||er(r,o,3,this.m_bOGCOutput,q,this.m_progressTracker),o}topoOperationPolyline_(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(q,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),s=e.insertPath(t,q);for(let n=this.m_topoGraph.getFirstCluster();n!==q;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=q;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==q;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===q&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=u(s),i=u(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o|h]=!0;let m=q;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(m=e),2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,m):1===r&&i>0||1===i&&r>0?this.topoOperationPolyline_(m,this.m_bOGCOutput):0===r||0===i?this.topoOperationMultiPoint_():void a("")}topoOperationPolygonPolygonEx(e,t,s){const n=this.m_topoGraph.getShape(),r=n.createGeometry(i.enumPolygon),o=n.createGeometry(i.enumPolyline),a=n.createGeometry(i.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let h=q;const m=this.m_topoGraph.createUserIndexForHalfEdges(),l=this.m_topoGraph.createUserIndexForClusters();n.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,r,s,m,l),n.dbgVerifyCurves();const g=n.hasSegmentParentage(),u=new k;for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===q)continue;let t=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(t,m),r=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m),a=e|r;if(2===a){let h=this.m_topoGraph.getHalfEdgeParentage(t);if(this.isGoodParentage(h)){const c=n.insertPath(o,q);let _=t;const d=this.chooseVertexFromCluster_(i,s);let p=n.addVertex(c,d);if(g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone())),this.m_topoGraph.setClusterUserIndex(i,l,1);do{this.progress_();const i=this.m_topoGraph.getHalfEdgeTo(_),o=this.chooseVertexFromCluster_(i,s);if(p=n.addVertex(c,o),g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.setHalfEdgeUserIndex(_,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m,1),this.m_topoGraph.setClusterUserIndex(i,l,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,m),r=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m),a=e|r,2!==a)break;if(h=this.m_topoGraph.getHalfEdgeParentage(_),!this.isGoodParentage(h)){this.m_topoGraph.setHalfEdgeUserIndex(_,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m,1);break}this.m_topoGraph.isHalfEdgeCurve(t)&&_!==t&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone()))}while(_!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m,1)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){this.progress_();if(1===this.m_topoGraph.getClusterUserIndex(i,l))continue;const e=this.m_topoGraph.getClusterParentage(i);if(this.isGoodParentage(e)){h===q&&(h=n.insertPath(a,q));const e=this.m_topoGraph.getClusterVertexIterator(i);let t=q;if(e!==q){t=this.m_topoGraph.getVertexFromVertexIterator(e);const r=this.chooseVertexFromVertexCluster_(t,s);n.addVertex(h,r)}}}this.m_topoGraph.deleteUserIndexForClusters(l),this.m_topoGraph.deleteUserIndexForHalfEdges(m),n.dbgVerifyCurves(),er(n,r,3,this.m_bOGCOutput,q,this.m_progressTracker);const c=[q,q,q];return c[0]=a,c[1]=o,c[2]=r,c}topoOperationPolylinePolylineOrPolygonEx(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(q,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),s=e.insertPath(t,q);for(let n=this.m_topoGraph.getFirstCluster();n!==q;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=q;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==q;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===q&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o|h]=!0;let m=q;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(m=e),2===r&&2===i)return this.topoOperationPolygonPolygonEx(e,t,m);if(1===r&&i>0||1===i&&r>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(m,this.m_bOGCOutput);return[t,e]}if(0===r||0===i){const e=[];return e.push(this.topoOperationMultiPoint()),e}a("")}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){const s=this.getCombinedHalfEdgeParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t),r=this.m_topoGraph.getHalfEdgeTo(t);let i=0,o=0;for(let a=this.m_topoGraph.getClusterVertexIterator(n);a!==q;a=this.m_topoGraph.incrementVertexIterator(a)){const n=this.m_topoGraph.getVertexFromVertexIterator(a),h=e.getPathFromVertex(n),m=e.getGeometryFromPath(h),l=this.m_topoGraph.getGeometryID(m),g=e.getFirstVertex(h),u=0!==(l&s);u&&g===n&&(this.m_fromEdgeForPolylines=t);const c=e.getNextVertex(n);if(c!==q&&this.m_topoGraph.getClusterFromVertex(c)===r){if(i++,u){if(this.m_fromEdgeForPolylines===q&&g===c){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o++}}else{const s=e.getPrevVertex(n);if(s!==q&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===q&&g===s){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o--}}}this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(r,this.m_dummyPt2);return(0!==o?o:i)*et.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(e,t){const s=this.m_topoGraph.getHalfEdgePrev(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return q;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=q;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==q)return q;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(r))}return i}tryMoveThroughCrossroadForward(e,t){const s=this.m_topoGraph.getHalfEdgeNext(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){const t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return q;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=q;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==q)return q;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(r))}return i}isOnALoop(e,t){let s=e;const n=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let r=0;r<n;r++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,t))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===e)return!0}a("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,i,o,a,h,m){l(r===q&&i>=0&&o>=0||-1===i&&-1===o),l(-1===a&&1!==m.unsplitBehavior||-1!==a&&1===m.unsplitBehavior);const g=m.ogcRule,u=m.allCrossRoadsImpassable,c=1===m.unsplitBehavior,_=0===m.unsplitBehavior,d=this.m_topoGraph.getShape(),p=d.hasSegmentParentage();let f=e,x=this.m_topoGraph.getHalfEdgeTwin(f);const y=new k;this.m_fromEdgeForPolylines=q;let P=this.prevailingDirection(d,f),E=f,S=q,C=!1,I=!1,b=!1;if(!c)for(;;){const t=this.m_topoGraph.getHalfEdgePrev(f);if(t===x){b=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(x);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){C=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(u){C=!0;break}if(f=this.tryMoveThroughCrossroadBackwards(f,!0),f===q){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=t,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}if(f===e){S=e,I=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;E=f,P+=this.prevailingDirection(d,f)}if(S===q){for(f=e,x=this.m_topoGraph.getHalfEdgeTwin(f),S=f;;){const e=this.m_topoGraph.getHalfEdgeNext(f),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){C=!0;break}if(e===x){b=!0;break}if(-1!==a){const e=this.m_topoGraph.getHalfEdgeOrigin(x);if(1===this.m_topoGraph.getClusterUserIndex(e,a)){C=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(x);if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(t||u){C=!0;break}if(f=this.tryMoveThroughCrossroadForward(f,!0),f===q){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=e,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;S=f,P+=this.prevailingDirection(d,f)}const t=this.m_topoGraph.getHalfEdgeOrigin(E);I=this.m_topoGraph.getHalfEdgeTo(S)===t}else if(this.m_fromEdgeForPolylines!==q){E=e,S=this.tryMoveThroughCrossroadBackwards(E,!1),l(S!==q);const t=this.m_topoGraph.getHalfEdgeTwin(E);this.m_topoGraph.getHalfEdgeNext(t)}let w=I;I||b||h&&(w=this.isOnALoop(e,s),w||(w=this.isOnALoop(x,s)));const v=P>=0;let N=!1;w&&C&&(I?(N=g,v&&(N||c||_)&&E!==e&&(l(!c),E=e,N=!1)):(c||v&&_)&&(E=e));let T=0;for(f=E;x=this.m_topoGraph.getHalfEdgeTwin(f),this.m_topoGraph.setHalfEdgeUserIndex(f,s,1),this.m_topoGraph.setHalfEdgeUserIndex(x,s,1),T++,f!==S;)f=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1);v||(S=ht(E,E=S),S=this.m_topoGraph.getHalfEdgeTwin(S),E=this.m_topoGraph.getHalfEdgeTwin(E));let G=d.insertPath(t,q);f=E;const D=this.m_topoGraph.getHalfEdgeOrigin(E);let V;V=-1!==i?this.chooseVertexByOrder(D,d,i,o):this.chooseVertexFromCluster_(D,r),this.m_topoGraph.isStrongPathNode(D)&&d.setStrongPathStart(G,!0);let F=d.addVertex(G,V),H=F;-1!==n&&this.m_topoGraph.setClusterUserIndex(D,n,1);let A=0;const M=N?Math.trunc((T+1)/2):-1;let U=q,B=!0,O=q;for(;;){if(p){const e=this.m_topoGraph.getSegmentParentage(f),t=this.m_topoGraph.getHalfEdgeOrigin(f);d.setSegmentParentageAndBreak(H,e,B||this.m_topoGraph.isBreakNode(t))}B=!1,this.m_topoGraph.isHalfEdgeCurve(f)&&(this.m_topoGraph.querySegmentXY(f,y),d.setSegmentToIndex(d.getVertexIndex(H),y.get().clone())),U!==q&&-1!==o&&d.addToUserIndex(U,o,-1);const e=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1),s=this.m_topoGraph.getHalfEdgeTo(f);let a;if(a=-1!==i?this.chooseVertexByOrder(s,d,i,o):this.chooseVertexFromCluster_(s,r),F=d.addVertex(G,a),O=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),p&&this.m_topoGraph.isBreakNode(s)&&d.setSegmentParentageBreakVertex(F,!0),U=a,A++,N&&A===M&&(G=d.insertPath(t,q),F=d.addVertex(G,a),B=!0,-1!==o&&d.addToUserIndex(a,o,-1),U=q),f===S)break;f=e,H=F}O!==q&&this.m_topoGraph.isStrongPathNode(O)&&d.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,s,n){l(t===q||e===q);const r=this.m_topoGraph.getShape(),o=t=>t=e===q?t===q?r.getFirstGeometry():r.getNextGeometry(t):t===q?e:q,a=r.createGeometry(i.enumPolyline);let h=-1;s&&(h=this.m_topoGraph.createUserIndexForClusters());const m=this.m_topoGraph.createUserIndexForHalfEdges(),g=t===q?r.createUserIndex():-1,u=t===q?r.createUserIndex():-1;let c=-1;if(1===n.unsplitBehavior){c=this.m_topoGraph.createUserIndexForClusters();for(let e=o(q);e!==q;e=o(e))for(let t=r.getFirstPath(e);t!==q;t=r.getNextPath(t)){{const e=r.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}if(!r.isClosedPath(t)){const e=r.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}}}if(t===q){let e=0;for(let t=o(q);t!==q;t=o(t))for(let s=r.getFirstPath(t);s!==q;s=r.getNextPath(s)){if(r.isClosedPath(s)){let t=r.getFirstVertex(s);for(let n=0,i=r.getPathSize(s);n<i;n++,t=r.getNextVertex(t))r.setUserIndex(t,g,e++),r.setUserIndex(t,u,2)}else{const t=r.getFirstVertex(s);r.setUserIndex(t,g,e++),r.setUserIndex(t,u,1);let n=r.getNextVertex(t);for(let i=1,o=r.getPathSize(s)-1;i<o;++i)r.setUserIndex(n,g,e++),r.setUserIndex(n,u,2),n=r.getNextVertex(n);r.setUserIndex(n,g,e++),r.setUserIndex(n,u,1)}}}for(let i=o(q);i!==q;i=o(i))for(let e=r.getFirstPath(i);e!==q;e=r.getNextPath(e)){let s=r.getFirstVertex(e);for(let i=0,o=r.getPathSize(e);i<o;i++,s=r.getNextVertex(s)){const e=this.m_topoGraph.getHalfEdgeFromVertex(s);if(e===q)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(e,m))continue;const r=this.getCombinedHalfEdgeParentage(e);if(this.isGoodParentage(r)){const s=0===i;this.restorePolylineParts(e,a,m,h,t,g,u,c,s,n)}}}let _=q;if(s){_=r.createGeometry(i.enumMultiPoint);let e=q;for(let s=this.m_topoGraph.getFirstCluster();s!==q;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1!==this.m_topoGraph.getClusterUserIndex(s,h)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===q&&(e=r.insertPath(_,q));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==q){let i;this.m_topoGraph.getVertexFromVertexIterator(n),i=-1!==g?this.chooseVertexByOrder(s,r,g,u):this.chooseVertexFromCluster_(s,t),r.addVertex(e,i)}}}}}return-1!==u&&r.removeUserIndex(u),-1!==g&&r.removeUserIndex(g),-1!==h&&r.removeUserIndex(h),this.m_topoGraph.deleteUserIndexForHalfEdges(m),ot(a,_)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=u(s),i=u(n);if(r>i)return e;const o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o]=!0,2===r&&2===i){let s=q;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===r&&2===i){const t=Ha();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}if(1===r&&1===i){const t=Ha();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}if(0===r)return this.topoOperationMultiPoint_();a("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);return l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o]=!0,this.m_maskLookup[o]=!0,this.m_maskLookup[h]=!0,2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,q):1===r&&1===i?this.topoOperationPolyline_(q,this.m_bOGCOutput):0===r&&0===i?this.topoOperationMultiPoint():void a("")}planarSimplifyNoCrackingAndCluster(e,t,s,n){this.m_bOGCOutput=e,this.m_topoGraph=new tn;const r=t.getFillRule(s),o=t.getGeometryType(s);if(1!==r||o===i.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const h=this.m_topoGraph.getGeometryID(s);if(l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=h+1,this.m_maskLookup[h]=!0,t.getGeometryType(s)===i.enumPolygon||1===r&&t.getGeometryType(s)!==i.enumMultiPoint){t.setFillRule(s,0);const i=this.topoOperationPolygonPolygon_(s,q,q);if(t.swapGeometry(i,s),t.removeGeometry(i),1===r&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,s,n)}else if(t.getGeometryType(s)===i.enumPolyline){const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=n;const r=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(r,s),t.removeGeometry(r)}else if(t.getGeometryType(s)===i.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,s),t.removeGeometry(e)}else a("");return!0}unsplitPolylineExact(e){return l(0),new w}planarSimplifyPolylines(e,t,s,n,r){for(let _=e.getFirstGeometry();_!==q;_=e.getNextGeometry(_)){const t=e.getGeometryType(_);l(t===i.enumPolyline)}let o=0,a=0,h=null;if(e.hasCurves()&&!e.hasSegmentParentage()){h=new fa;const s=e.getEnvelope2D(this.m_progressTracker);a=da(t.total());const n=_a(t.total(),s);o=pa(n,a),aa(e,n,t.total(),12e3,h,null,this.m_progressTracker)}{const s=Ia(t.add(o));e.filterClosePoints(s,!1,!1,!1,q)}if(this.m_topoGraph=new tn,4!==r&&5!==r)if(null===h&&s){const n=new Dn(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(o),this.m_progressTracker,!0,!1),s=!1;else s=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const m=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,m,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(s&&null===h),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,n,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(m);l(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const u=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),n);null!==h&&h.stitchCurves(e,u,a,!0);const c=e.getGeometry(u);return s||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyMultiPoints(e,t,s,n){for(let m=e.getFirstGeometry();m!==q;m=e.getNextGeometry(m)){const t=e.getGeometryType(m);l(t===i.enumMultiPoint)}this.m_topoGraph=new tn,4!==n&&5!==n?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):s=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const r=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,r,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const o=this.m_topoGraph.getGeometryID(r);l(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0;const a=this.topoOperationMultiPoint(),h=e.getGeometry(a);return s||h.getImpl().setIsSimple(4,t.total()),h}planarSimplifyPolygons(e,t,s,n,r,o){for(let f=e.getFirstGeometry();f!==q;f=e.getNextGeometry(f)){const t=e.getGeometryType(f);l(t===i.enumPolygon||t===i.enumPolyline&&s)}let a=0,h=0,m=null;if(e.hasCurves()&&!e.hasSegmentParentage()){m=new fa;const s=e.getEnvelope2D(this.m_progressTracker);h=da(t.total());const n=_a(t.total(),s);a=pa(n,h),aa(e,n,t.total(),12e3,m,null,this.m_progressTracker)}if(o){ya(e,t.add(a),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==q;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&er(e,t,-1,!1,q,this.m_progressTracker)}if(this.m_topoGraph=new tn,o||4===r||5===r)n=!1;else if(null===m&&n){const s=new Dn(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(a),this.m_progressTracker,!0,!1),n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(g);l(u>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=u+1,this.m_maskLookup[u]=!0,e.setFillRule(g,0);const c=this.m_bOGCOutput&&s,_=c;let d=this.topoOperationPolygonPolygon_(g,q,q,_);if(c){this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(g),this.m_topoGraph=new tn,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,d,this.m_progressTracker);d=this.topoOperationPolygonPolygon_(d,q,q,!1)}null!==m&&m.stitchCurves(e,d,h,!0);const p=e.getGeometry(d);return p.setFillRule(0),n?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,t.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(e,t,s,n,r){return l(0),{}}planarSimplifyImpl_(e,t,s,n,r,o,h,m){if(e.isEmpty())return e.clone();const l=e.getGeometryType(),g=new V,u=g.addGeometry(e);if(De(r)&&l===i.enumPolygon&&(s=!1,g.setFillRule(u,0)),m&&(e.hasAttribute(1)&&g.replaceNaNs(1,0),g.removeNaNVertices()),l===i.enumPolygon||l===i.enumPolyline&&s)return this.planarSimplifyPolygons(g,t,s,n,r,!1);if(l===w.type){const e=Ha();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=h,this.planarSimplifyPolylines(g,t,n,e,r)}if(l===i.enumMultiPoint)return this.planarSimplifyMultiPoints(g,t,n,r);a("what else?")}}function Qa(e,t,s,n){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return n?e.createInstance():new ye({copy:e});const r=[new et],i=[0],o=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&a(""),r[0]=e.getXY(),o?Wo(t,r,1,s.total(),i):jo(t,r,1,s.total(),i),0===i[0]?e.createInstance():e}function Ja(e,t,s,n){const r=e.createInstance(),i=gt(et,100),o=new Array(100),h=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&a("");for(let a=0;a<h;){const n=e.queryCoordinates(i,i.length,a,-1)-a;l?Wo(t,i,n,s.total(),o):jo(t,i,n,s.total(),o);let h=0;for(let t=0;t<n;t++){0===o[t]&&(m&&(m=!1,r.addPoints(e,0,a)),h!==t&&r.addPoints(e,a+h,a+t),h=t+1)}m||h===n||r.addPoints(e,a+h,a+n),a+=n}return m?e:r}function $a(e,t,s,n){const r=e.getGeometryType();if(r===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(r===i.enumPoint&&("|"===n||"^"===n)){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(r===i.enumLine){const t=new w({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(r===i.enumMultiPoint&&"-"===n&&t.getGeometryType()===i.enumPoint){const t=new ye({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(r===i.enumMultiPoint&&"&"===n&&t.getGeometryType()===i.enumPoint){const t=new ye({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function eh(e){const t=e.getGeometryType();if(t===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(Da(t)){const t=new w({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 th(e,t,s,n){const r=s===q?e.getClusterHalfEdge(t):s;let i=r;l(e.getHalfEdgeOrigin(r)===t);do{n(i),i=e.getHalfEdgeNext(e.getHalfEdgeTwin(i))}while(i!==r)}class sh{constructor(e,t,s,n,r,i){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(r),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=r,this.m_rCutHandles=i,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let o=this.m_rShape.getFirstPath(this.m_cuttee);o!==q;o=this.m_rShape.getNextPath(o)){let e=0;const t=this.m_rShape.getPathSize(o);for(let s=this.m_rShape.getFirstVertex(o);e<t;e++,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(s)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return 8|e}classifyStandardCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));let l=1,g=32,u=32;if(th(this.m_rTopoGraph,t,m,e=>{e===h&&(l=2),e===o&&(g=l),e===a&&(u=l)}),this.m_bConsiderTouch)32!==g&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),32!==u&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u);else{if(32===g||32===u)return 1;if(g===u&&!(o===h||o===m||a===h||a===m))return 1;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u)}return 0}classifyTouchCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=s===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=n===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let t;return(t=h===o||m===o)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=h===a||m===a)&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),t?0:1}if(o===q)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===q)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;if(o===a)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(m!==q){if(o===m)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===m)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=1;th(this.m_rTopoGraph,t,m,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=2}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=2}})}else{if(o===h)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=2;th(this.m_rTopoGraph,t,h,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=1}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=1}})}return 0}classifyCutVertex(e,t){let s=0,n=0;for(let r=this.m_rTopoGraph.getClusterVertexIterator(t);r!==q;r=this.m_rTopoGraph.incrementVertexIterator(r)){const i=this.m_rTopoGraph.getVertexFromVertexIterator(r);if(this.m_rShape.getGeometryFromVertex(i)===this.m_cutter){n++;const r=this.m_rShape.getPrevVertex(i),o=this.m_rShape.getNextVertex(i);s+=r===q||o===q?this.classifyTouchCut(e,t,r,o):this.classifyStandardCut(e,t,r,o)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let i=this.m_rShape.getFirstPath(this.m_cuttee);i!==q;i=this.m_rShape.getNextPath(i)){const e=this.m_rShape.getPathSize(i);let t=this.m_rShape.getFirstVertex(i);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t))this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,0);t=this.m_rShape.getFirstVertex(i);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t)){const e=this.m_rTopoGraph.getClusterFromVertex(t);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(t,e)}}const e=(e,t)=>{let s=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let i=this.m_rShape.getFirstPath(this.m_cuttee);i!==q;i=this.m_rShape.getNextPath(i)){let t=this.m_rShape.getFirstVertex(i);const s=this.m_rShape.isClosedPath(i),n=this.m_rShape.getPathSize(i)+(s?1:0);let r=1,o=32;for(let i=this.m_rShape.getNextVertex(t);r<n;++r,t=i,i=this.m_rShape.getNextVertex(i)){const s=e(t,i);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=s),32!==o&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,o|s)}t=this.m_rShape.getLastVertex(i);let a=32;r=1;for(let i=this.m_rShape.getPrevVertex(t);r<n;++r,t=i,i=this.m_rShape.getPrevVertex(i)){const s=e(i,t);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=s),32!==a&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,a|s)}}let t=q,s=q,n=32;const r=this.m_rShape.hasSegmentParentage(),o=new k;for(let a=this.m_rShape.getFirstPath(this.m_cuttee);a!==q;a=this.m_rShape.getNextPath(a)){const e=this.m_rShape.isClosedPath(a),h=this.m_rShape.getPathSize(a)+(e?1:0);let m=1,l=this.m_rShape.getFirstVertex(a),g=q,u=!0;for(let a=this.m_rShape.getNextVertex(l);m<h;++m,a=this.m_rShape.getNextVertex(a)){let e=this.m_rShape.getUserIndex(l,this.m_cutteeBreadcrumbsIndex);8===e?e=3:(e&=-9,4&e?e=4:3&~e||(e=3)),e!==n?(t!==q&&(g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n)),t=this.m_rShape.createGeometry(i.enumPolyline),s=this.m_rShape.insertPath(t,q),n=e,u=!0):this.m_rShape.getUserIndex(l,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==e&&(g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),s=this.m_rShape.insertPath(t,q),u=!0),g=this.m_rShape.addVertex(s,l);const h=this.m_rTopoGraph.getClusterFromVertex(l);!u&&r&&this.m_rTopoGraph.isBreakNode(h)&&this.m_rShape.setSegmentParentageBreakVertex(g,!0);const m=this.m_rTopoGraph.getHalfEdgeFromVertex(l);if(r){const e=this.m_rTopoGraph.getSegmentParentage(m);this.m_rShape.setSegmentParentageAndBreak(g,e,u||this.m_rTopoGraph.isBreakNode(h))}this.m_rTopoGraph.isHalfEdgeCurve(m)&&(this.m_rTopoGraph.querySegmentXY(m,o),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(g),o.get().clone())),l=a,u=!1}g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n),t=q,s=q,n=32}}}function nh(e,t,s){return new Ka(s).linesToPolygonsImpl(e,t)}function rh(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=new s;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),oh(i,t,n,r,h)}const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(de(c)||0===c)return c;const _=new Ph(e,t,c,h,!1);m===i.enumMultiPoint||m===i.enumPolyline||m===i.enumPolygon?c=_.isSimplePlanarImpl():a("");return e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function ih(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=new s;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),ih(i,t,n,r,h)}P(m),x(m)||d("OGC simplify is not implemented for this geometry type");const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(5===c||0===c)return c;const _=new Ph(e,t,c,h,!0);m===i.enumMultiPoint||m===i.enumPolyline||m===i.enumPolygon?(c=_.isSimplePlanarImpl(),de(c)&&(c=5)):a("");return e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function oh(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=s.constructEmpty();return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),oh(i,t,n,r,h)}const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(-1!==c)return c;const _=new Ph(e,t,c,h,!1);return m===i.enumMultiPoint?c=_.multipointIsSimpleAsFeature():m===i.enumPolyline?c=_.polylineIsSimpleAsFeature():m===i.enumPolygon?c=_.polygonIsSimpleAsFeature():a(""),e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function ah(e,t,n,r){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.enumPoint){const t=new ts;if(mh(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.enumEnvelope){const n=ge(t,e,!0).total(),r=e,i=s.constructEmpty();return r.queryEnvelope(i),i.isDegenerate(n)?r.createInstance():e}if(o(h)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),ah(i,t,n,r)}P(h);const m=ge(t,e,!1).total(),l=[0],g=e.getImpl().getIsSimple(m,l),u=n?-1:g;if(de(u)){if(h===i.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((h===i.enumMultiPoint||h===i.enumPolyline)&&u>=1)return e;const c=new Ph(e,t,u,r,!1);let _;return h===i.enumMultiPoint?_=c.multipointSimplifyAsFeature():h===i.enumPolyline?_=c.polylineSimplifyAsFeature():h===i.enumPolygon?_=c.polygonSimplifyAsFeature():a(""),_}function hh(e,t,n,r){if(e.isEmpty())return e;const a=e.getGeometryType();if(a===i.enumPoint){const t=new ts;if(mh(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(a===i.enumEnvelope){const n=e,r=new s;n.queryEnvelope(r);const i=ge(t,e,!0).total();return r.isDegenerate(i)?n.createInstance():e}if(o(a)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),hh(i,t,n,r)}P(a),x(a)||d("OGC simplify is not implemented for this geometry type");const h=ge(t,e,!1).total(),m=[0],l=e.getImpl().getIsSimple(h,m),g=n?-1:l;if(5===g){if(a===i.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return Aa(e,ge(t,e,!0),!1,g,r,0,!0)}function mh(e,t){const s=e.getX(),n=e.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){const s=e.getZ();if(!Number.isFinite(s))return t&&(t.m_reason=Number.isNaN(s)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class lh{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(e){this.m_flags&=-2,this.m_flags=this.m_flags|(e?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function gh(){return{x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1}}function uh(e,t,s,n,r){return{x:e,y:t,ipath:s,ivertex:n,ipolygon:r}}function ch(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function _h(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function dh(){return{x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1}}function ph(e,t,s,n,r,i){return{x:e,y:t,ipath:s,ivertex:n,bBoundary:r,bEndPoint:i}}function fh(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 xh extends We{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*n);return r<0?-1:r>0?1:0}}class yh extends We{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges[t],i=this.m_helper.m_edges[n],o=r.getReversed(),a=i.getReversed();let h=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const e=o?r.m_segment.getStartY():r.m_segment.getEndY(),t=a?i.m_segment.getStartY():i.m_segment.getEndY(),s=Math.min(e,t);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),h=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return h<m?-1:h>m?1:0}}class Ph{constructor(e,t,s,n,r){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new Se,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new Ce,this.m_xyToNode1=null,this.m_xyToNode2=null,this.m_pathOrientations=null,this.m_pathParentage=null,this.m_xy=null,this.m_pairs=[],this.m_pairIndices=null,this.m_pathsForOGCTests=[],this.m_curveStitcher=null,this.m_editShape=null,this.m_multiPathStitcher=null,this.m_nonSimpleResult=new ts,this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=e,this.m_knownSimpleResult=s,this.m_sr=t;const i=ge(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=Ee(i),this.m_toleranceIsSimpleCracking=Ie(i),this.m_toleranceSimplify=ge(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=r,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const e=this.m_geometry.getGeometryType();return h(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?h(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return l(0),7}generateSortedPairs(e){let t=null;h(e.getGeometryType())&&(t=e);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==t,n=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new be(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let a=0;a<n;a++)if(this.m_pairs.push(2*a),this.m_pairs.push(2*a+1),this.m_pairIndices.add(2*a),this.m_pairIndices.add(2*a+1),s){for(;a>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const i=new we,o={parent:this,workPt:new et,userSort(e,t,n){n.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,s))},getValue(e){const t=this.parent.m_pairs[e],s=t>>1;this.parent.m_xy.queryPoint2D(2*s,this.workPt);return this.workPt.y+(1&t?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};i.sort(this.m_pairIndices,0,2*n,o)}_TestToleranceDistancePlanar(e,t){const s=this.m_xy.read(2*e),n=this.m_xy.read(2*e+1),r=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1);if(!!ln(s,n,r,i,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)){if(0===this.m_geometry.getDimension())return!1;return s===r&&n===i}return!0}checkStructure(){const e=this.m_geometry.getGeometryType();if(h(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.enumPolygon?3:2;for(let s=0,n=e.getPathCount();s<n;s++)if(e.getPathSize(s)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(s)&&e.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new ts(1,s,0),!1}}if(x(e)){const e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let s=0,n=e.getPointCount();s<n;s++){if(!t.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new ts(2,s,0),!1}if(this.m_geometry.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(!Number.isFinite(e))return Number.isNaN(e)?this.m_nonSimpleResult=new ts(3,s,0):this.m_nonSimpleResult=new ts(2,s,0),!1}}}return!0}checkDegenerateSegments(e){const t=this.m_geometry.getImpl(),s=t.querySegmentIterator(),n=t.hasAttribute(1),r=n?ve(this.m_sr,t,!1).total():0,i=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment();let a=t.calculateLowerLength2D();if(!(a>o)&&!(i&&t.isCurve()&&(a=t.calculateLength2D(),a>o))){if(e&&n){const e=t.getStartAttributeAsDbl(1,0),s=t.getEndAttributeAsDbl(1,0);if(Math.abs(s-e)>r)continue}return this.m_nonSimpleResult=new ts(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return l(0),!1}_CheckClustering(){const e=this.m_geometry.getImpl();this.generateSortedPairs(e);const t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new xh(this)),this.m_AET.setCapacity(t);for(let s=0,n=2*t;s<n;s++){this.progress_();const e=this.m_pairIndices.read(s),t=this.m_pairs[e],n=t>>1;if(1&t){const e=this.m_AET.search(n),t=this.m_AET.getPrev(e),s=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==Ce.st_nullNode()&&s!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new ts(5,this.m_AET.getElement(t),this.m_AET.getElement(s)),!1}else{const e=this.m_AET.addElement(n),t=this.m_AET.getPrev(e);if(t!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(t)),!1;const s=this.m_AET.getNext(e);if(s!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new V,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new fa;const e=s.constructEmpty();this.m_geometry.queryEnvelope(e);const t=_a(this.m_toleranceSimplify.total(),e),n=new ts;if(la(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,n,this.m_curveStitcher,null,this.m_progressTracker),0!==n.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(n),!1}const e=new ts;return Mn(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(null!=this.m_curveStitcher?(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null):(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){s.resetTo(t);do{for(;s.hasNextSegment();){const n=s.nextSegment(),r=B(!0,e,n,this.m_toleranceIsSimpleCracking,!0);if(r){const e=2===r?7:6;return this.m_nonSimpleResult=new ts(e,t.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const t=[],s=e.getPointCount();let n=Number.NaN,r=0;for(let i=0,o=2*s;i<o;i++){this.progress_();const e=this.m_pairIndices.read(i),s=this.m_pairs[e];if(1&s)continue;const o=s>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(t.length&&(a!==n||h!==r)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),n=a,r=h}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){const e=this.m_geometry.getImpl(),t=[];for(let o=0,a=e.getPathCount();o<a;o++)t.push(e.isClosedPathInXYPlane(o));const s=dh();let n,r,i;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,h=this.m_xy.readPoint2D(2*a),m=this.m_pathsForOGCTests[a];n=t[m],r=e.getPathStart(m),i=e.getPathEnd(m)-1,s.bEndPoint=a===r||a===i,this.m_bOGCRestrictions?s.bBoundary=!n&&s.bEndPoint:s.bBoundary=s.bEndPoint,s.ipath=m,s.x=h.x,s.y=h.y,s.ivertex=a}for(let o=1,a=this.m_pairIndices.size();o<a;o++){const a=this.m_pairIndices.read(o),h=this.m_pairs[a];if(1&h)continue;const m=h>>1,l=this.m_xy.readPoint2D(2*m),g=this.m_pathsForOGCTests[m];let u;g!==s.ipath&&(n=t[g],r=e.getPathStart(g),i=e.getPathEnd(g)-1);const c=m===r||m===i;u=this.m_bOGCRestrictions?!n&&c:c;const _=ph(l.x,l.y,g,m,u,c);if(_.x===s.x&&_.y===s.y)if(this.m_bOGCRestrictions){if(!(_.bBoundary&&s.bBoundary||_.ipath===s.ipath&&_.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new ts(10,_.ivertex,s.ivertex),!1}else if(!_.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new ts(7,_.ivertex,s.ivertex),!1;fh(s,_)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return l(0),!1}checkSelfIntersectionsPolygonsOGC(){const e=this.m_geometry.getImpl(),t=[];let s=-1,n=!1;for(let l=0,g=e.getPathCount();l<g;l++)e.isExteriorRingOGC(l)&&(n=!1,s++,l<g-1&&(e.isExteriorRingOGC(l+1)||(n=!0))),t.push(n?s:-1);const r=gh();{const e=this.m_pairIndices.read(0),s=this.m_pairs[e]>>1,n=this.m_xy.readPoint2D(2*s),i=this.m_pathsForOGCTests[s];r.ipath=i,r.x=n.x,r.y=n.y,r.ivertex=s,r.ipolygon=t[i]}const i=[];for(let l=1,g=this.m_pairIndices.size();l<g;l++){const e=this.m_pairIndices.read(l),s=this.m_pairs[e];if(1&s)continue;const n=s>>1,o=this.m_xy.readPoint2D(2*n),a=this.m_pathsForOGCTests[n],h=uh(o.x,o.y,a,n,t[a]);if(h.x===r.x&&h.y===r.y){if(h.ipath===r.ipath)return this.m_nonSimpleResult=new ts(11,h.ivertex,r.ivertex),!1;t[h.ipath]>=0&&t[h.ipath]===t[r.ipath]&&(0!==i.length&&ch(i.at(-1),r)||i.push({...r}),i.push(h))}_h(r,h)}if(0===i.length)return!0;const o=new Se(!0);t.fill(-1);let a=-1;const h=new et;for(let l=0,g=i.length;l<g;l++){const e=i[l];e.x===h.x&&e.y===h.y||(a=o.createList(0),h.x=e.x,h.y=e.y);let s=t[e.ipath];-1===s&&(s=o.createList(2),t[e.ipath]=s),o.addElement(s,a),o.addElement(a,s)}const m=[];for(let l=o.getFirstList();-1!==l;l=o.getNextList(l)){const e=o.getListData(l);if(1&e||!(2&e))continue;let s=-1;for(m.push(l),m.push(-1);m.length;){const e=m.at(-1);m.pop();const t=m.at(-1);m.pop();const n=o.getListData(t);if(1&n){s=2&n?t:e;break}o.setListData(t,1|n);for(let s=o.getFirst(t);-1!==s;s=o.getNext(s)){const n=o.getData(s);n!==e&&(m.push(n),m.push(t))}}if(-1!==s){const e=t.indexOf(s);return this.m_nonSimpleResult=new ts(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){const e=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new ts(8,1===e.getPathCount()?1:-1,-1),0;if(1===e.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new Ne(e.getPathCount(),0),this.m_pathParentage=new be(e.getPathCount(),-1);let t=-1,s=0;for(let i=0,o=e.getPathCount();i<o;i++){const n=e.calculateRingArea2D(i);if(this.m_pathOrientations.write(i,n<0?0:8),n>0)t=i,s=n;else{if(0===n)return this.m_nonSimpleResult=new ts(8,i,-1),0;if((t<0||s<Math.abs(n))&&(this.m_nonSimpleResult=new ts(9,i,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(i,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;const n=e.getPointCount();this.m_yScanline=Number.NaN;const r=[];this.m_xyToNode1=new be(n,Ce.st_nullNode()),this.m_xyToNode2=new be(n,Ce.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new yh(this));for(let i=0,o=2*n;this.m_unknownOrientationPathCount>0&&i<o;i++){const e=this.m_pairIndices.read(i),t=this.m_pairs[e];if(1&t)continue;const s=t>>1,n=this.m_xy.read(2*s+1);if(n!==this.m_yScanline&&r.length){if(!this.processBunchForRingOrientationTest(r))return 0;r.length=0}r.push(s),this.m_yScanline=n}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(r)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(e){if(1===e.length)return!0;for(let o=0,a=e.length;o<a;o++){const t=e[o];this.m_recycledSegIter.resetToVertex(t,-1);const s=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(s,t,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(n,t,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();-1===t&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let o=0,a=this.m_edges.length;o<a;o++)this.m_crossOverHelperList.addElement(t,o);let s=!0,n=-1,r=-1;for(;s;){s=!1;let e=this.m_crossOverHelperList.getFirst(t);if(-1===e)break;let i=this.m_crossOverHelperList.getNext(e);for(;-1!==i;){const o=this.m_crossOverHelperList.getData(e),a=this.m_crossOverHelperList.getData(i);if(n=this.m_edges[o].m_vertexIndex,r=this.m_edges[a].m_vertexIndex,n!==r)e=i,i=this.m_crossOverHelperList.getNext(e);else if(s=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(i),i=this.m_crossOverHelperList.deleteElement(t,i),-1===i||-1===e)break}}const i=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),i>0)return this.m_nonSimpleResult=new ts(7,n,r),!1;for(let o=0,a=e.length;o<a;o++)this.recycleEdge(this.m_edges[o]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,s=e.length;t<s;t++){const s=e[t];let n=this.m_xyToNode1.read(s);if(n!==Ce.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(s,Ce.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==Ce.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(s,Ce.st_nullNode())}}for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===Ce.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();if(r.getStartY()<r.getEndY()){const e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=t):(n=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(n);this.m_xyToNode1.read(e)===Ce.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}}for(let t=0,s=this.m_newEdges.length;t<s&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let t=-1,s=this.m_AET.getPrev(e),n=e,r=0;{let e=-1,i=null,o=-1,a=0;for(;s!==Ce.st_nullNode()&&(e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex,a=this.m_pathOrientations.read(o),!(3&a));)n=s,s=this.m_AET.getPrev(s);s===Ce.st_nullNode()?(r=1,s=n):(t=1==(3&a)?o:this.m_pathParentage.read(o),r=i.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(r!==i.getRightSide())return this.m_nonSimpleResult=new ts(8,o,-1),!1;const e=r&&!i.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new ts(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),r=r?0:1}while(n!==e)}}return this.m_newEdges.length=0,!0}createEdge(e,t,s,n){let r;return e.getGeometryType()===i.enumLine?r=this.createEdgeLine(e):(r=new lh,r.m_segment=e.clone()),r.m_vertexIndex=t,r.m_pathIndex=s,r.m_flags=0,r.setReversed(n),r}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new lh,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,s,n){let r=e.calculateLowerLength2D();if(r<=s){let i=!0;if(e.isCurve()&&(r=e.calculateLength2D(),i=r<=s),i){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let s=e.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-t)<=n}return!0}return!1}return!1}static isShortSegmentPoints(e,t,s,n,r){if(s){const s=e.getXYZ(),i=t.getXYZ();return Te(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return et.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),i=e.querySegmentIterator();i.resetToPath(t),l(i.nextPath());const o=this.m_toleranceSimplify.total();let a=!1,h=!0;const m=new ye,g=new ye,u=new et;for(;i.hasNextSegment();){this.progress_();const e=i.nextSegment();if(Ph.isShortSegment(e,r,o,s))if(a){if(e.queryEnd(g),Ph.isShortSegmentPoints(m,g,r,o,s))continue;h&&(n.startPathPoint(m),h=!1),e.queryEnd(m),n.lineToPoint(m),a=!1}else u.assign(e.getStartXY()),e.queryStart(m),a=!0;else if(a)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(u,e.getEndXY(),!1),t.setStart(m),Ph.isShortSegment(t,r,o,s))continue;n.addSegment(t,h),h=!1,a=!1}else{if(e.queryEnd(g),Ph.isShortSegmentPoints(m,g,r,o,s))continue;h&&(n.startPathPoint(m),h=!1),n.lineToPoint(g),a=!1}else n.addSegment(e,h),h=!1}if(h)return;if(!a)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),m):e.getPointByVal(e.getPathEnd(t)-1,m);const c=n.querySegmentIterator();c.resetToLastPath(),c.resetToLastSegment();const _=n.getDescription().getAttributeCount()>1;for(l(c.previousPath());c.hasPreviousSegment();){const e=c.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),m.getXY(),!1),!Ph.isShortSegment(t,r,o,s)){_&&t.setEnd(m);const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.addSegment(t,!1)}}else if(e.queryStart(g),!Ph.isShortSegmentPoints(g,m,r,o,s)){const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(m)}}n.removePath(n.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;const t=e.getPointCount(),s=$e(t,0);for(let n=0;n<t;n++)s[n]=n;s.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let n=1;n<t;n++)if(0===this.compareVerticesMultiPoint(s[n-1],s[n]))return this.m_nonSimpleResult=new ts(5,s[n-1],s[n]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl();const t=Ph.hasNanZs(e);let s,n=this.m_geometry;t&&(s=this.m_geometry.clone(),e=s.getImpl(),s.replaceNaNs(1,Ge.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=$e(r,0);for(let g=0;g<r;g++)i[g]=g;i.sort((e,t)=>this.compareVerticesMultiPoint(e,t));const o=new Array(r);o.fill(!1);let a=-1;for(let g=0;g<r;g++){const t=i[g];e.getXY(t).isFinite()&&((a<0||0!==this.compareVerticesMultiPoint(a,t))&&(o[t]=!0),a=t)}const h=this.m_geometry.createInstance();let m=0,l=0;for(let g=0;g<r;g++)o[g]?l=g+1:(m<l&&h.addPoints(n,m,l),m=g+1);return m<l&&h.addPoints(n,m,l),h.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),h}polylineSimplifyAsFeature(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator(),n=this.m_geometry.createInstance(),r=this.m_geometry,i=e.hasAttribute(1),o=i?ve(this.m_sr,e,!0).total():0,a=[],h=[];let m=null;i&&(m=e.getAttributeStreamRef(1));const l=new ye,g=e.hasNonLinearSegments(),u=this.m_toleranceSimplify.total();for(;t.nextPath();){if(s.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(g&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,n);continue}s.resetToLastSegment();let c=0,_=0,d=!0,p=!0;for(;t.hasNextSegment();){this.progress_();const n=t.nextSegment(),r=s.previousSegment();if(t.getStartPointIndex()>s.getStartPointIndex())break;if(d){const s=t.getStartPointIndex();e.getXY(s).isNAN()||(d=!1,a.push(s))}if(p){const t=s.getEndPointIndex();e.getXY(t).isNAN()||(h.push(t),p=!1)}if(!d){const s=a.at(-1),r=t.getEndPointIndex();if(r-s>1){const t=new et;t.setSub(e.getXY(s),e.getXY(r)),c=t.length()}else c=n.calculateLength2D();if(c>u)a.push(r),c=0;else if(i){let e=m.read(s);Number.isNaN(e)&&(e=0);let t=m.read(r);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(a.push(r),c=0)}}if(!p){const t=h.at(-1),n=s.getStartPointIndex();if(n-t>1){const s=new et;s.setSub(e.getXY(t),e.getXY(n)),_=s.length()}else _=r.calculateLength2D();if(_>u)h.push(n),_=0;else if(i){let e=m.read(t);Number.isNaN(e)&&(e=0);let s=m.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-e)>o&&(h.push(n),_=0)}}}if(a.length>0&&h.length>0&&(a.at(-1)<h.at(-1)?a.length>h.length?a.pop():h.pop():(a.at(-1)===h.at(-1)||h.pop(),h.pop())),h.length+a.length>=2){let e=!1;for(let t=0,s=a.length;t<s;t++)r.getPointByVal(a[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);for(let t=h.length-1;t>0;t--)r.getPointByVal(h[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);r.isClosedPath(t.getPathIndex())?n.closePathWithLine():h.length>0&&(r.getPointByVal(h[0],l),n.lineToPoint(l))}a.length=0,h.length=0}return i&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,u),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!De(this.m_knownSimpleResult))return Ma(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new V;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),0!==e.getTotalPointCount()){let t=null,n=0,r=0;if(e.hasCurves()){t=new fa;const i=s.constructEmpty();this.m_geometry.queryEnvelope(i);const o=_a(this.m_toleranceSimplify.total(),i);n=da(this.m_toleranceSimplify.total()),r=pa(o,n),aa(e,o,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}if(!De(this.m_knownSimpleResult)){ya(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===i.enumPolygon&&er(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==t&&t.stitchCurves(e,e.getFirstGeometry(),n,!0)}const 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)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,s){if(e===t)return 0;const n=this.m_pairs[e],r=this.m_pairs[t],i=n>>1,o=r>>1,a=this.m_xy.readPoint2D(2*i);a.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const h=this.m_xy.readPoint2D(2*o);h.y+=1&r?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=a.compare(h);if(0===m&&s){const e=this.m_pathsForOGCTests[i]-this.m_pathsForOGCTests[o];return mt(e)}return m}compareVerticesMultiPoint(e,t){if(e===t)return 0;const s=this.m_multiVertexGeom.getXY(e),n=this.m_multiVertexGeom.getXY(t),r=!s.isFinite(),i=!n.isFinite();if(r||i)return r<i?-1:r>i?1:0;if(s.y<n.y)return-1;if(s.y>n.y)return 1;if(s.x<n.x)return-1;if(s.x>n.x)return 1;for(let o=1;o<this.m_attributeCount;o++){const s=this.m_description.getSemantics(o),n=Ge.getComponentCount(s);for(let r=0;r<n;r++){const n=this.m_multiVertexGeom.getAttributeAsDbl(s,e,r),i=this.m_multiVertexGeom.getAttributeAsDbl(s,t,r),o=ft(n,i);if(0!==o)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;const s=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&s.negateThis();const n=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&n.negateThis();const r=s.getQuarter(),i=n.getQuarter();if(i===r){const e=s.crossProduct(n);return e<0?1:e>0?-1:0}return r<i?-1:1}}class Eh{getOperatorType(){return 10103}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,s,n,r){const i=oh(e,t,s,n,r);return _e(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,r){const i=rh(e,t,s,n,r);return de(i)}executeMany(e,t,s,n){return new Sh(e,t,s,n)}execute(e,t,s,n){const r=new es([e]),i=this.executeMany(r,t,s,n).next();return i||a("null geometry"),i}}class Sh extends $t{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||n(""),e.getGeometryType()===i.enumGeometryCollection){const t=H(e,-1),s=(new Eh).executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=e.createInstance();for(let e=s.next();null!=e;e=s.next())n.addGeometry(e);return n}return ah(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Ch(e,t,n){const r=new s;e.queryEnvelope(r);const o=new s;t.queryEnvelope(o);const a=new s(o);if(a.inflate(2*n),!a.isIntersecting(r))return 4;const h=e.getGeometryType(),m=t.getGeometryType();if(h===i.enumEnvelope&&r.containsEnvelope(a))return 1;if(m===i.enumEnvelope){const e=new s(r);if(e.inflate(2*n),o.containsEnvelope(e))return 2}return 0}class Ih{constructor(e,t,s,n){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=i.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const n=pe(this.m_intersectorGeom,e),r=fe(this.m_sr,n,!0).total(),i=s.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);const o=s.constructEmpty();e.queryEnvelope(o),i.inflateCoords(2*r,2*r),i.intersect(o),i.inflateCoords(100*r,100*r);const a=0;let h=Zt(this.m_intersectorGeom,i,a,0,this.m_progressTracker),m=Zt(e,i,a,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(h=ht(m,m=h)),za(m,h,this.m_sr,this.m_progressTracker)}intersectEx(e){const t=this.tryFastImplementation(e);if(null!==t){const s=[];return s.length=3,s[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,s)}const n=pe(this.m_intersectorGeom,e),r=fe(this.m_sr,n,!0).total(),i=s.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);const o=s.constructEmpty();e.queryEnvelope(o),i.inflateCoords(2*r,2*r),i.intersect(o),i.inflateCoords(100*r,100*r);const a=0;let h=Zt(this.m_intersectorGeom,i,a,0,this.m_progressTracker),m=Zt(e,i,a,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(h=ht(m,m=h));const l=Wa(m,h,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,l)}init(e,t,s,n=null){l(0)}static intersectPoints(e,t,s){const n=pe(e,t);return La(e,t,fe(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===i.enumPoint&&t===i.enumPoint){const t=Ih.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new G({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.enumEnvelope&&this.m_intersectorGeomType===i.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new xe({copy:t});return n.intersect(s),n}const n=pe(e,this.m_intersectorGeom),r=fe(this.m_sr,n,!0),o=e.isEmpty(),h=this.m_intersectorGeom.isEmpty();let m=o||h;if(!m){const t=Ch(this.m_intersectorGeom,e,r.total());if(4===t)m=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(m){const s=u(t),n=u(this.m_intersectorGeomType);return s<n?Ih.ReturnEmpty(e,o):s>n||0===s&&t===i.enumMultiPoint&&this.m_intersectorGeomType===i.enumPoint?this.ReturnEmptyIntersector():Ih.ReturnEmpty(e,o)}if(t===i.enumEnvelope&&0===u(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.enumEnvelope&&0===u(t)){const n=t===i.enumEnvelope?e:this.m_intersectorGeom,o=t===i.enumEnvelope?this.m_intersectorGeom:e,a=s.constructEmpty();return n.queryEnvelope(a),Zt(o,a,r.total(),0,this.m_progressTracker)}if(0===u(t)&&u(this.m_intersectorGeomType)>0||u(t)>0&&0===u(this.m_intersectorGeomType)){if(t===i.enumMultiPoint)return Oa(e,this.m_intersectorGeom,r);if(t===i.enumPoint)return Xa(e,this.m_intersectorGeom,r);if(this.m_intersectorGeomType===i.enumMultiPoint)return Oa(this.m_intersectorGeom,e,r);if(this.m_intersectorGeomType===i.enumPoint)return Xa(this.m_intersectorGeom,e,r);a("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,s){let n=0;return 1&t?(s[0]||(s[0]=new G({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new w({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new T({vd:e})):s.splice(n,1),new es(s)}}class bh extends $t{constructor(e,t,s,r,i){super(),this.m_smallCursor=null,this.m_progressTracker=r,this.m_geomIntersector=t.next(),this.m_intersector=new Ih(this.m_geomIntersector,s,i,r),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=i,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&n("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let e;if(null!==this.m_smallCursor){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();){if(r(e),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask){return this.m_intersector.intersect(e)}this.m_smallCursor=this.m_intersector.intersectEx(e);return this.m_smallCursor.next()}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class wh{getOperatorType(){return 1e4}accelerateGeometry(e,t,s){if(!this.canAccelerateGeometry(e))return!1;ge(t,e,!0);let n=0;return e.getGeometryType()!==i.enumPolygon&&e.getGeometryType()!==i.enumPolyline||!v(e)||0===s||(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),!!n}canAccelerateGeometry(e){return v(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new bh(e,t,s,n,r)}execute(e,t,s,n){if(e.getGeometryType()===i.enumPoint&&t.getGeometryType()===i.enumPoint)return Ih.intersectPoints(e,t,s);const r=new es([e]),o=new es([t]),h=this.executeMany(r,o,s,n,-1).next();return h||a("null output"),h}}function vh(e,t,s){return t.m_projector.project(e,s)}function Nh(e,t,s,n,r){e.m_projector.transformInPlaceZ(t,null,s,n,null,r);const i=n.slice(0,s).filter(e=>!e.isNAN());for(let o=0,a=i.length;o<a;++o)n[o].assign(i[o]);return i.length}function Th(e,t,s,n,r){return e.m_projector.transformInPlaceZ(t,null,s,n,null,r)}function Gh(e,t,r,a){if(e&&t&&t.isPannable()||n("fold_into_360_range_geodetic"),e.isEmpty())return e;if(4===r)return Dh(e,t,a);let m=e;const l=m.getGeometryType();if(h(l)){m=Al(e,t);const n=new s;m.queryEnvelope(n);const i=fe(t,n,!1).total(),o=t.getPannableExtent();let a=Math.floor((n.xmin-o.xmin)/o.width())*o.width()+o.xmin,h=m;for(;a<n.xmax;)a>n.xmin+i&&a<n.xmax-i&&(h=Hl(h,t,r,!0,a)),a+=o.width();m=h}else{if(l===i.enumEnvelope){const e=new T({vd:m.getDescription()});return e.addEnvelope(m,!1),Gh(e,t,r,a)}if(o(l)){const e=new w({vd:m.getDescription()});return e.addSegment(m,!0),Gh(e,t,r,a)}}return Dh(m,t,a)}function Dh(e,t,s){if(e&&t&&t.isPannable()||n(""),e.isEmpty())return e;let r;const a=e.getGeometryType();if(a===i.enumEnvelope){const t=new T({vd:e.getDescription()});t.addEnvelope(e,!1),r=t}else if(o(a)){const t=new w({vd:e.getDescription()});t.addSegment(e,!0),r=t}else r=e;const h=Al(r,t);return h.isEmpty()?h:vl(h,t,0,h!==e,0,s)}function Vh(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,i=e.queryInterval(0,0);if(i.width()<r||!x(e.getGeometryType())){if(Number.isNaN(s))return e;const t=i.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new jt,i=it((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const o=e.getGeometryType(),a=e,m=a.getAttributeStreamRef(0),l=e.clone(),g=l.getAttributeStreamRef(0);let u=0,c=0,_=0,d=h(o)?0:-1;const p=at.constructEmpty();let f=!1;for(let x=0,y=a.getPointCount();x<y;x++){const e=m.read(2*x);x===c&&(h(o)?(0===d&&Number.isNaN(s)&&(f=!0),d>0&&Number.isNaN(s)&&(s=p.getCenter(),f=!1),c=a.getPathEnd(d),d++):c=a.getPointCount(),Number.isNaN(s)?_=e:(_=s,u=0));let t=e-_;Math.abs(t)>r&&(t=it(t/n)*n,u-=t,Math.abs(u)<.1*n&&(u=0));const i=e+u;g.write(2*x,i),f&&p.mergeCoordinate(i),_=e}return l.notifyModified(),l}const Fh="missing implementation";function Hh(e,t,n,r){const i=t.getCoordinateSystemType();if(0===i){const s=new ac;return t.queryPrecisionDescriptor(s),kh(e,s,t,n)}let o=e;2!==r&&3!==r||!t.isPannable()||(o=Dh(o,t,n));const h=new ac;if(t.queryPrecisionDescriptor(h),o=kh(o,h,t,n),0===r||o.isEmpty())return o;if(1===i){if(1===r){const e=new s;o.queryLooseEnvelope(e);const r=t.getPannableExtent(),i=.01*r.width();return r.xmin=e.xmin-i,r.xmax=e.xmax+i,(new Kt).execute(o,r,t,n)}return o}if(2===i){const e=t.getPCSHorizon();if(1===r||2===r){const s=(new wh).execute(o,e,t,n);return s===e?s.clone():s}return o}if(3===i)return o;a(Fh)}function kh(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let a=new at,h=new at;i&&(a=t.getZGridRange()),o&&(h=t.getMGridRange());let m=(new Kt).execute(e,r,s,n);if(i){const t=m.queryInterval(1,0);a.contains(t)||(e===m&&(m=m.clone()),Xe(m,a,1,0))}if(o){const t=m.queryInterval(2,0);h.contains(t)||(e===m&&(m=m.clone()),Xe(m,h,2,0))}return m}class Ah{constructor(e){this.m_inputPCSHorizonClipOption=0,this.m_outputPCSHorizonClipOption=0,this.m_bDontGeonormalizePolygon=!1,this.m_bClipOutCurvedPoles=!1,this.m_bNormalizeOutputGeometry=!1,this.m_bDontHackPolesInGeogToGeog=!1,this.m_centralMeridianOfOutputGCS=0,this.m_densificationStepInput=0,e||n(""),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;const t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.densificationStep;const s=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=s.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=s.hasFlag(1073741824),this.m_bClipOutCurvedPoles=s.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const s=e.getGeometryType();if(s===i.enumPoint)return this.projectPoint(e,t);const n=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),h=this.m_projTransform.getOutputSR();if(0===n&&n===r){const t=Uh(o,h),s=e.clone();return s.applyTransformation(t),s}switch(s){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:a("")}}projectPoint(e,t){const s=[e.getXY()];let n,r=null;(n=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(s,r,1,s,r,null);const i=e.clone();return i.setXY(s[0]),n&&i.setZ(r[0]),i}projectMultiPoint(e,t){let s=new G({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),o=r.getCoordinateSystemType();if(3===i&&l(0),s=Xl(s,n,this.m_inputPCSHorizonClipOption,t),s.isEmpty())return s;2===i&&$l(n,0,s),gg(this.m_projTransform,s,!1);let a=0;3===o&&l(0);const h=2===o;return h?a=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(a=this.m_centralMeridianOfOutputGCS),h&&0!==this.m_outputPCSHorizonClipOption||(s=vl(s,Zu(r),a,!1,0,t)),h&&(s=Sl(s,r,this.m_outputPCSHorizonClipOption,t),Kl(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const s=e.getGeometryType();return s===i.enumPolygon?this.projectPolygon(e,t):s===i.enumPolyline?this.projectPolyline(e,t):void a("project_multi_path_")}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&e.hasAttribute(1);let n=at.constructEmpty();if(s&&(n=e.queryInterval(1,0)),n.width()>0){const s=e.clone();s.setInterval(1,0,n.vmin,n.vmin);const r=this.projectEnvelopeHelper(s,t);s.setInterval(1,0,n.vmax,n.vmax);const i=this.projectEnvelopeHelper(s,t);return r.merge(i),r}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){l(e.getGeometryType()===i.enumPolygon),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),o=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new T({copy:e});3===o&&l(0),3===a&&l(0);const m=2===o,g=2===a,u=m?n.getGCS():n,c=g?r.getGCS():r,_=!g&&!this.m_bDontHackPolesInGeogToGeog;let d=!1,p=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(p.isEmpty())return p;let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let y;x&&(p=(new Jt).execute(p,f,0,0,t));let P=g?r.getPCSInfo():null,E=Number.NaN;m&&(E=n.getCentralMeridian());const S=null!==r.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=p;if(m&&(hg(n,E,e),x)){const e=n.getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,_),x){const e=n.getGCS().getUnitsPerMillimeter();f*=r.getGCS().getUnitsPerMillimeter()/e}y=e}else{let e=new w({vd:p.getDescription()});if(e.addAndExplicitlyOpenAllPaths(p,!1),m){if(hg(n,E,e),x){const e=n.getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const r=n.getPCSInfo(),i=r.getSouthPoleGeometry()===Nc.PE_POLE_LINE_CURVED,o=r.getNorthPoleGeometry()===Nc.PE_POLE_LINE_CURVED;if(i||o){const n=s.constructEmpty();e.queryLooseEnvelope(n),n.inflateCoords(1,1);const r=89.9999*u.getOneDegreeGCSUnit();i&&(n.ymin=-r),o&&(n.ymax=r),e=Qt(e,n,u,0,0,t)}}}if(cg(this.m_projTransform,e,_),x){const e=Zu(n).getUnitsPerMillimeter();f*=Zu(r).getUnitsPerMillimeter()/e}let i=Number.NaN;g?(P=r.getPCSInfo(),i=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let o=Mh(n)|Mh(r),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,a=10*c.getTolerance(0)),y=Vl(p,n,e,c,i,t,o,a,this.m_bNormalizeOutputGeometry),o=0}if(S&&(l(!r.isPannable()),y=cl(y,r,t)),g){if(!d){const e=c.getPannableExtent().width();if(y.queryInterval(0,0).width()>=e-10*c.getTolerance(0)){const e=P.getNorthPoleLocation(),t=P.getSouthPoleLocation(),s=P.getNorthPoleGeometry(),n=P.getSouthPoleGeometry();let r=0;s===Nc.PE_POLE_POINT&&e!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r=1),n===Nc.PE_POLE_POINT&&t!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r|=2),d||=0!==r}}y=Sl(y,r,this.m_outputPCSHorizonClipOption,t),x&&(y=(new Jt).execute(y,f,0,0,t)),Jl(r,y,this.m_bNormalizeOutputGeometry)}return y.isEmpty()||d&&(y=(new Eh).execute(y,r,!1,t)),y}projectPolyline(e,t){l(e.getGeometryType()===i.enumPolyline),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),r=s.getCoordinateSystemType(),o=n.getCoordinateSystemType(),a=new w({copy:e});3===r&&l(0),3===o&&l(0);const h=2===r,m=2===o;h&&s.getGCS();const g=m?n.getGCS():n,u=!m&&!this.m_bDontHackPolesInGeogToGeog;let c=Xl(a,s,this.m_inputPCSHorizonClipOption,t);if(c.isEmpty())return c;let _=Number.NaN;h&&(_=s.getCentralMeridian());const d=null!==n.getGCSSplitLines();let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;if(f&&(c=(new Jt).execute(c,p,0,0,t)),this.m_bDontGeonormalizePolygon){if(h&&(hg(s,_,c),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,c,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}x=c}else{const e=new w({vd:c.getDescription()});if(e.addAndExplicitlyOpenAllPaths(c,!1),h&&(hg(s,_,e),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}let r=Number.NaN;m?r=n.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=Mh(s)|Mh(n),o=10*g.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=0),x=Fl(c,s,e,g,r,t,i,o,this.m_bNormalizeOutputGeometry),i=0}return d&&(l(!n.isPannable()),x=cl(x,n,t)),m&&(x=Sl(x,n,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(n,x,this.m_bNormalizeOutputGeometry)),x.isEmpty(),x}projectGeometryCollection(e,t){return l(0),{}}projectEnvelopeHelper(e,t){const n=(e.height()+e.width())/400;if(0!==n){const r=(new Jt).execute(e,n,0,0,t),i=this.projectMultiPath(r,t),o=new xe({vd:e.getDescription()});if(i.isEmpty()){const n=Math.min(e.height(),e.width()),i=ge(this.m_projTransform.getInputSR(),e,!0).total();if(n>100*i){const e=s.constructEmpty(),t=fe(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 o}const a=new w;a.addAndExplicitlyOpenAllPaths(r,!1);this.projectMultiPath(a,t).queryEnvelope(o);const h=new G({vd:e.getDescription()});h.reserve(4);const m=new ye;for(let t=0;t<4;t++)e.queryCornerByVal(t,m),h.add(m);const l=this.projectMultiPoint(h,t),g=new xe;return l.queryEnvelope(g),o.merge(g),o}return i.queryEnvelope(o),o}{const s=e.getCenterXY(),n=new ye(s),r=this.projectPoint(n,t),i=new xe({vd:e.getDescription()});if(r.isEmpty())i.setEmpty();else{e.copyTo(i);const t=r.getXY();i.setCoords(t.x,t.y,t.x,t.y)}return i}}transformInPlace(e,t,s,n){return l(0),0}transformInPlaceZ(e,t,s,n,r,i){if(this.m_projTransform.isIdentity())return e!==n&&nt(n,e,s),t!==r&&Nt(r,t,0,0,s),s;const o=this.m_projTransform,a=o.getInputSR(),h=o.getOutputSR(),m=a.getCoordinateSystemType(),g=h.getCoordinateSystemType();if(0===m&&m===g){return Uh(a,h).transformPoints2D(e,s,n),o.isVertical()&&l(0),s}3===m&&d("image: transform_in_place_"),3===g&&d("image: transform_in_place_"),Ll(e,s,n,a,this.m_inputPCSHorizonClipOption),r!==t&&Nt(r,t,0,0,s),2===m&&mg(a,0,n,s),fg(this.m_projTransform,n,r,s,!1);let u=0;const c=2===g;c?u=h.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(u=this.m_centralMeridianOfOutputGCS),c&&0!==this.m_outputPCSHorizonClipOption||Nl(n,s,h.getGCS(),u),c&&(wl(n,s,h,this.m_outputPCSHorizonClipOption),Wl(h,n,s,!1));let _=s;for(let l=0;l<s;++l)n[l].isNAN()&&(r&&(r[l]=Number.NaN),_--);return _}}function Mh(e){if(2!==e.getCoordinateSystemType())return 0;let t=0;const s=e.getPCSInfo(),n=s.getNorthPoleLocation(),r=s.getSouthPoleLocation(),i=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return i===Nc.PE_POLE_POINT&&n!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===Nc.PE_POLE_POINT&&r!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function Uh(e,t){const s=e.getHorzUnitFactor(),n=t.getHorzUnitFactor();let r=1,i=1;const o=20015077/180;1===e.getUnit().getUnitType()&&(r=o),1===t.getUnit().getUnitType()&&(i=o);const a=s/n*(r!==i?r/i:1),h=new jt;return h.setScaleCoords(a,a),h}class qh{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s){return!t||t.isIdentity()?e:new Bh(e,t,s)}execute(e,t,s){return t.isIdentity()?e:vh(e,t,s)}transform(e,t,s,n,r=!0){return r?Nh(e,t,s,n,null):Th(e,t,s,n,null)}transform3D(e,t,s,n,r=!0){return l(0),0}foldInto360Range(e,t){return Dh(e,t,null)}foldInto360RangeGeodetic(e,t,s){return Gh(e,t,s,null)}normalizeGeometryEx(e,t,s,n,r=0){return Tm(e,t,s,n,r)}normalizeGeometry(e,t,s){return Vh(e,t,s)}clipToSpatialReference(e,t,s,n=0){return Hh(e,t,s,n)}}class Bh extends $t{constructor(e,t,s){super(),this.m_projTrans=t,this.m_progressTracker=s,this.m_index=-1,e||n(""),this.m_inputGeoms=e}next(){const e=this.m_inputGeoms.next();return null!=e?(y(e),r(e),this.m_index=this.m_inputGeoms.getGeometryID(),vh(e,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Oh(e,t,s,a,m,u,c=!1){e||n("Geometry.Geodetic_densify.densify");let _=e.getGeometryType();if(r(e),e.isEmpty()||g(_))return e;const d=new Wh;d.m_sr=t,d.m_gcs=t.getGCS(),d.m_transform=d.m_gcs!==t?t.getSRToGCSTransform():null,d.m_progressTracker=u;const p=Hu();let f,x,y;if(d.m_gcs.querySpheroidData(p),d.m_a=p.majorSemiAxis,d.m_eSquared=p.e2,d.m_rpu=d.m_gcs.getUnit().getUnitToBaseFactor(),d.m_gcsTolerance=d.m_gcs.getTolerance(0),d.m_radTolerance=d.m_gcsTolerance*d.m_rpu,d.m_maxLength=a,d.m_maxDeviation=m,d.m_curveType=s,_===i.enumEnvelope){const t=new T({vd:e.getDescription()});t.addEnvelope(e,!1),f=t,_=i.enumPolygon}else if(o(_)){const t=new w({vd:e.getDescription()});t.addSegment(e,!0),f=t,_=i.enumPolyline}else f=e;if(4!==d.m_curveType){if(l(h(_)),x=d.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(f),x.isEmpty())return x;x=Yh(d.m_rpu,x);let e=d.geodeticDensify(x);c||(e=(new qh).foldInto360RangeGeodetic(e,d.m_gcs,d.m_curveType)),y=d.m_transform&&!d.m_transform.isIdentity()?(new qh).execute(e,d.m_transform.getInverse(),u):e}else{let e;if(l(h(_)),t.isPannable())e=Al(f,t);else{const s=t.getPCSHorizon();e=(new wh).execute(f,s,t,u),e===s&&(e=s.clone())}if(x=e,x.isEmpty())return x;y=d.shapePreservingDensify(x)}return y}function Yh(e,t){const n=new s;if(t.queryLooseEnvelope(n),n.width()*e<Math.PI)return t;let r=!1;const i=t.querySegmentIterator(),o=new et,a=new et;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment();if(o.setCoordsPoint2D(t.getStartXY()),a.setCoordsPoint2D(t.getEndXY()),o.scale(e),a.scale(e),Math.abs(o.x-a.x)>Math.PI){if(!Xh(o,a)){r=!0;break}if(Math.abs(o.x-a.x)>2*Math.PI){r=!0;break}}}if(!r)return t;const h=t.createInstance();h.reserve(t.getPointCount());const m=t.getDescription().getAttributeCount()>1,l=new et,g=new et,u=new et(0,0),c=new et(0,0),_=new ye;for(i.resetToFirstPath();i.nextPath();){let t=Number.NaN,s=0;for(;i.hasNextSegment();){const n=i.nextSegment();o.setCoordsPoint2D(n.getStartXY()),a.setCoordsPoint2D(n.getEndXY()),o.scale(e),a.scale(e),Number.isNaN(t)?(s=im(o.x,Number.NaN,s),u.setCoordsPoint2D(o)):u.setCoordsPoint2D(c),t=u.x;if(Xh(o,a)){if(a.x-o.x>2*Math.PI)for(;a.x-o.x>2*Math.PI;)a.x-=2*Math.PI;else if(a.x-o.x<2*-Math.PI)for(;a.x-o.x<2*-Math.PI;)a.x+=2*Math.PI;s=im(a.x,Number.NaN,s),c.setCoordsPoint2D(a)}else l.setCoordsPoint2D(a),gm(l),s=im(l.x,t,s),c.setCoords(s+l.x,l.y);if(Math.abs(c.x-a.x)<.5&&c.setCoordsPoint2D(a),m){n.queryCoord(0,_),g.setCoordsPoint2D(u),g.scale(1/e),_.setXY(g);i.isFirstSegmentInPath()?h.startPathPoint(_):h.lineToPoint(_),i.isLastSegmentInPath()&&!i.isPathClosed()&&(n.queryCoord(1,_),g.setCoordsPoint2D(c),g.scale(1/e),_.setXY(g),h.lineToPoint(_))}else{i.isFirstSegmentInPath()&&h.insertPath2D(-1,null,0,0,!0);const t=h.getPathCount()-1;g.setCoordsPoint2D(u),g.scale(1/e),h.insertPoint2D(t,-1,g),i.isLastSegmentInPath()&&!i.isPathClosed()&&(g.setCoordsPoint2D(c),g.scale(1/e),h.insertPoint2D(t,-1,g))}}}return h}function Rh(e,t,s,n,r,i,o,a,h,m,l,g){const u=new et,c=new et,_=n.compare(r)>0;nm(_,n,r,u,c);const d=Kh(e,t,s,u,c,i,o,a,h,m,null,l,g);return _&&sm(h,m,null,l),d}function Xh(e,t){return!(!Pc(e.y,yt)||!Pc(t.y,yt))||!(!Pc(e.y,-yt)||!Pc(t.y,-yt))}function Lh(e,t){return!(!Pc(e.y,yt)||Pc(t.y,yt))||!(!Pc(e.y,-yt)||Pc(t.y,-yt))}function zh(e,t){return!(!Pc(t.y,yt)||Pc(e.y,yt))||!(!Pc(t.y,-yt)||Pc(e.y,-yt))}class Wh{constructor(){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_progressTracker=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_gcsTolerance=0,this.m_radTolerance=0,this.m_maxLength=0,this.m_maxDeviation=0,this.m_curveType=0}geodeticDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new k,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();){const e=[0];for(;s.hasNextSegment();){const a=s.nextSegment(),h=a.getStartXY(),m=a.getEndXY();h.scale(this.m_rpu),m.scale(this.m_rpu);const l=new et,g=new et,u=h.compare(m)>0;nm(u,h,m,l,g),n.length=0,r.length=0,this.m_maxLength>0?Kh(this.m_a,this.m_eSquared,this.m_curveType,l,g,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,o?r:null,n,e):Qh(),u&&sm(null,null,o?r:null,n),n[0].setCoordsPoint2D(a.getStartXY()),n.at(-1).setCoordsPoint2D(a.getEndXY());const c=1/this.m_rpu;for(let e=1,t=n.length-1;e<t;e++)n[e].scale(c);if(o){const e=rm(u,a,i);Zh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),a,e,r,n,t)}else jh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}}return t}shapePreservingDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new k,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment(),a=e.getStartXY(),h=e.getEndXY(),m=a.compare(h)>0,l=rm(m,e,i);n.length=0,r.length=0,tm(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,o?r:null,n),m&&sm(null,null,o?r:null,n),o?Zh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),e,l,r,n,t):jh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){const t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Al(e,this.m_gcs),!t))return e;const s=e.createInstance();s.reserveParts(e.getPointCount(),e.getPathCount());for(let n=0,r=e.getPathCount();n<r;++n){let t=new G;const r=e.getPathStart(n),i=e.getPathEnd(n);t.addPoints(e,r,i);const o=e.isClosedPath(n);let a=!1;if(o&&i-r===1&&e.hasNonLinearSegmentsPath(n)){const s=new ye;e.getPointByVal(r,s),t.add(s),a=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!a){const s=new ye;e.getPointByVal(r,s),t.add(s)}if(t=(new qh).execute(t,this.m_transform,this.m_progressTracker),o&&t.getPointCount()>1){const e=t.getXY(0),s=t.getXY(t.getPointCount()-1);e.equals(s)&&t.removePoint(t.getPointCount()-1)}}t.getPointCount()>1&&(s.addPathMultiPoint(t,0,-1,!0),o&&s.closePathWithLine())}return s}}function jh(e,t,s,n){e&&n.insertPath2D(-1,null,0,0,!0);const r=n.getPathCount()-1;n.insertPointsFromPoints(r,-1,s,0,s.length-1,!0),t&&n.insertPoint2D(r,-1,s.at(-1))}function Zh(e,t,s,n,r,i,o){o.reserve(o.getPointCount()+i.length-1);const a=new ye;if(s.queryStart(a),e?o.startPathPoint(a):o.lineToPoint(a),i.length>2){const e=n.calculateLength2D();for(let t=1;t<i.length-1;t++){const s=n.lengthToT(r[t]*e);n.queryCoord(s,a),a.setXY(i[t]),o.lineToPoint(a)}}t&&(s.queryEnd(a),o.lineToPoint(a))}function Kh(s,n,r,i,o,a,h,m,l,g,u,c,_){const d={stack:[],error:void 0,hasError:!1};try{const t=e(d,new Cc,!1),p=e(d,new Cc,!1),f=e(d,new Cc,!1);Dc.geodeticDistance(s,n,i.x,i.y,o.x,o.y,f,t,p,r);const x=f.val,y=t.val,P=p.val;let E=y,S=P;E<0&&(E+=2*Math.PI),S<0&&(S+=2*Math.PI),l&&(l[0]=E),g&&(g[0]=S);let C=Number.NaN,I=Number.NaN;if(null!==u){const e=Vc.q90(s,n),t=Vc.q(s,n,i.y);C=(e-t)/x,I=(e+t)/x}const b=Lh(i,o),w=zh(i,o),v=b||w,N=mm(i,o,m),T=e(d,new ut(new Cc,new Cc),!1),G=new et,D=new et,V=new et;_[0]=im(i.x,Number.NaN,_[0]);let F=_[0];if(x<=a)return c.push(i.clone()),_[0]=im(o.x,Number.NaN,_[0]),null!=u&&u.push(0),v?(b&&om(i,o,u,c),w&&am(i,o,u,c)):N?hm(i,o,y,C,I,u,c):h>0&&(D.setCoords(i.x-F,i.y),G.setCoords(o.x-_[0],o.y),F=Jh()),c.push(o.clone()),x;const H=1+Math.ceil(x/a),k=x/(H-1),A=new et;c.push(i.clone()),A.setCoordsPoint2D(i),D.setCoords(i.x-_[0],i.y),null!==u&&u.push(0);for(let e=1;e<H;e++){let t;if(e<H-1){const o=e*k;Dc.geodeticCoordinate(s,n,i.x,i.y,o,y,T.at(0),T.at(1),r),G.setCoords(T.at(0).val,T.at(1).val),_[0]=im(G.x,A.x,_[0]),V.setCoords(_[0]+G.x,G.y),t=e/(H-1)}else _[0]=im(o.x,Number.NaN,_[0]),G.setCoords(o.x-_[0],o.y),V.setCoordsPoint2D(o),t=1;v?(1===e&&b&&om(i,V,u,c),e===H-1&&w&&am(A,o,u,c)):N?lm(A,V,m)&&(i.x<o.x?A.x>V.x&&(_[0]+=2*Math.PI,V.setCoords(_[0]+G.x,G.y)):A.x<V.x&&(_[0]-=2*Math.PI,V.setCoords(_[0]+G.x,G.y)),hm(A,V,y,C,I,u,c)):h>0&&Jh(),c.push(V.clone()),null!=u&&u.push(t),A.setCoordsPoint2D(V),D.setCoordsPoint2D(G),F=_[0]}return x}catch(p){d.error=p,d.hasError=!0}finally{t(d)}}function Qh(e,t,s,n,r,i,o,a,h,m){l(0)}function Jh(e,t,s,n,r,i,o,a,h,m,g,u,c,_,d){return l(0),0}function $h(e,t,s,n){const r=ds(e,t,s),i=ds(e,t,n);return Ye.distance(r,i)}function em(e,t,s,n,r,i,o,a){const h=new Array,m=gt(Array,8);let g=2,u=r.getCoord2D(i);m[0][0]=u.x,m[0][1]=u.y,u=r.getCoord2D(o),m[1][0]=u.x,m[1][1]=u.y;const c=e=>{if(null!==s){const t=wc.projToGeog(s,e,m);l(t===e)}for(const t of m)t[0]*=n,t[1]*=n};c(2),h.push(ds(e,t,new et(m[0][0],m[0][1]))),h.push(ds(e,t,new et(m[1][0],m[1][1])));let _=Ye.distance(h[0],h[1]);if(_>a)return _;let d=0;for(g=3;g<=17;){const s=1/(g-1);let n=0;for(let e=1;e<g;++e)if(1&e){const t=ct(i,o,e*s);r.queryCoord2D(t,u),m[n][0]=u.x,m[n][1]=u.y,n++}c(n);let p=1;for(let r=0;r<n;++r)h.splice(p,0,ds(e,t,new et(m[r][0],m[r][1]))),p++;p=0;let f=h[p];p++;let x=0;for(;p!==h.length;++p){const e=h[p];x+=Ye.distance(f,e),f=e}if(x>a)return x;if(d=x-_,l(d>=0||Math.abs(d)<1e-14*x),d<0&&(d=0),_=x,x+d<=a)return x+d;g=2*g-1}return _+d}function tm(e,t,s,n,r,i,o,a,h){const m=n.isCurve(),g=Fs(e,t)*Math.PI*179/180;let u=i;i>0&&!(i>g)||(u=g);const c=o,_=c>0;let d=Number.NaN;_&&(d=Bs(e,t,c));const p=1===r.getCoordinateSystemType();let f=null;p||(f=r.getPECoordSys());const x=r.getTolerance(0),y=n.getStartXY(),P=n.getEndXY(),E=new et,S=new et;if(p)E.setCoordsPoint2D(y),E.scale(s),S.setCoordsPoint2D(P),S.scale(s);else{const e=[y.x,y.y,P.x,P.y];wc.projToGeog(f,2,e),E.setCoords(e[0],e[1]),E.scale(s),S.setCoords(e[2],e[3]),S.scale(s)}let C=0,I=0;const b=[],w=[],v=[];b.push(P.clone()),w.push(S.clone()),v.push(1),h.push(y.clone()),null!==a&&a.push(I);const N=r.isPannable(),T=y.clone(),G=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let D=5;m||(_?(G[0]=.5,G[1]=.25,G[2]=.75,D=3):D=1),l(u>0);const V=e=>{if(e=e.clone(),null!==f){const t=[e.x,e.y];wc.projToGeog(f,1,t),e.setCoords(t[0],t[1])}return e.scale(s),e};for(;w.length>0;){const i=b.at(-1).clone();S.assign(w.at(-1));const o=v.at(-1);let g=!1,c=Number.NaN;const y=em(e,t,f,s,n,I,o,u);let P=u>=y&&Math.abs(E.y-S.y)<.9*Math.PI;p&&P&&(P=Math.abs(E.x-S.x)<.9*Math.PI);const F=new et,H=new et;let k=!1;if(!_&&P&&P&&(k=!0),n.calculateSubLength(I,o)<=x&&(k=!0),!k)for(let a=0;a<D;a++){const h=ct(I,o,G[a]),u=new et;n.queryCoord2D(h,u);const f=V(u);if(0===a&&(c=h,F.setCoordsPoint2D(u),H.setCoordsPoint2D(f),!P)){g=!0;break}if(l(_),p&&Math.abs(E.x-f.x)>=Math.PI){g=!0;break}let x=new et,y=new et;m?(x=et.lerp(T,i,G[a]),y=V(x)):(x=u.clone(),y=f.clone());const C=Ss(e,t,E,S,G[a]),b=C.clone();if(p?(b.x/=s,b.y/=s):(b.x/=s,b.y/=s,Th(r.getGCSToSRTransform(),[b],1,[b],null)),b.isNAN()){const s=ds(e,t,f),n=ds(e,t,E),r=ds(e,t,S),{second:i}=vs(e,t,s,n,r,2,null);if(i>d){g=!0;break}}else{if(N){const e=r.getPannableExtent().width(),t=ct(n.getStartX(),n.getEndX(),.5);for(;b.x<t-.5*e;)b.x+=e;for(;b.x>=t+.5*e;)b.x-=e}const s=n.getClosestCoordinateOnInterval(b,new at(I,o),-1);let i=n.getCoord2D(s);i=V(i);let a=$h(e,t,i,C);if(a>d){if(a<4*d){const s=ds(e,t,i),n=ds(e,t,E),r=ds(e,t,S),{second:o}=vs(e,t,s,n,r,2,null);a=o}if(a>d){g=!0;break}}else if(m){let s=ds(e,t,f);const n=ds(e,t,E),r=ds(e,t,S);let{second:i}=vs(e,t,s,n,r,3,null);if(i<=d){s=ds(e,t,y);const{second:o}=vs(e,t,s,n,r,3,null);i=o}if(i>d){g=!0;break}}}}g?(b.push(F.clone()),w.push(H.clone()),v.push(c)):(b.pop(),w.pop(),v.pop(),h.push(i.clone()),C+=y,null!==a&&a.push(C),T.setCoordsPoint2D(i),E.setCoordsPoint2D(S),I=o)}if(null!==a){const e=1/C;for(let t=0;t<a.length;t++)a[t]*=e}}function sm(e,t,s,n){if(n.reverse(),null!==s&&s.reverse(),e){const s=e[0],n=t[0];e[0]=n,t[0]=s}}function nm(e,t,s,n,r){e?(n.setCoordsPoint2D(s),r.setCoordsPoint2D(t)):(n.setCoordsPoint2D(t),r.setCoordsPoint2D(s))}function rm(e,t,s){return e?(s.create(t.getGeometryType()),t.copyTo(s.get()),s.get().reverse(),s.get()):t}function im(e,t,s){if(Number.isNaN(t)){for(;s-e>Math.PI;)s-=2*Math.PI;for(;e-s>Math.PI;)s+=2*Math.PI;return s}return s+e-t>Math.PI?s-=2*Math.PI:t-(s+e)>Math.PI&&(s+=2*Math.PI),s}function om(e,t,s,n){if(e.y>0){const r=new et;r.setCoords(t.x,yt),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new et;r.setCoords(t.x,-yt),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}}function am(e,t,s,n){if(t.y>0){const r=new et;r.setCoords(e.x,yt),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new et;r.setCoords(e.x,-yt),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}}function hm(e,t,s,n,r,i,o){if(Sc(s)){if(yt-e.y>0){const t=new et;t.setCoords(e.x,yt),o.push(t),null!==i&&i.push(n)}if(yt-t.y>0){const e=new et;e.setCoords(t.x,yt),o.push(e),null!==i&&i.push(n)}}else{if(yt+e.y>0){const t=new et;t.setCoords(e.x,-yt),o.push(t),null!==i&&i.push(r)}if(yt+t.y>0){const e=new et;e.setCoords(t.x,-yt),o.push(e),null!==i&&i.push(r)}}}function mm(e,t,s){return!(!lm(e,t,s)||Pc(e.y,yt)||Pc(e.y,-yt)||Pc(t.y,yt)||Pc(t.y,-yt))}function lm(e,t,s){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=s}function gm(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=2*Math.PI;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=2*Math.PI}function um(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=[r.x],a=[r.y-i],h=[r.x],m=[r.y+i];Vs(t,a),Vs(h,m);const l=e(o,new Cc,!1),g=e(o,new Cc,!1);Dc.greatEllipticDistance(s,n,r.x,r.y,t[0],a[0],l,null,null),Dc.greatEllipticDistance(s,n,r.x,r.y,h[0],m[0],g,null,null);return Math.min(l.val,g.val)}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function cm(e,t,n,r,i){const o=new s;n.queryEnvelope(o);const a=ge(null,n,!0).total();if(t.xmin-o.xmin<=a&&o.xmax-t.xmax<=a)return n;const h=t.width();let m=0;for(;t.xmin+m*h<o.xmin;)m++;for(;t.xmin+m*h>o.xmin;)m--;const l=m*h,g=new jt;g.setShiftCoords(-l,0);const u=n;u.applyTransformation(g);const c=new s;u.queryEnvelope(c);let _=null;if(c.xmax>t.xmax){let n=0;const r=new s;r.setCoords({env2D:t}),r.ymin-=1,r.ymax+=1;let o=u;for(;r.xmin<c.xmax;){c.xmax>r.xmax&&(o=Hl(o,e,2,!0,r.xmax));const s=Ze(o,r),a=fe(null,s,!0).total(),m=Zt(o,r,a,Number.NaN,i);null===_?_=m===o?m.clone():m:(g.setShiftCoords(-n*h,0),m.applyTransformation(g),_.add(m,!1)),n++,r.xmin=r.xmax,r.xmax=t.xmax+n*h}}else _=u;return _}class _m{constructor(e,t){this.m_basisX=new Ye,this.m_basisY=new Ye,this.m_normal=new Ye,l(1===e.getCoordinateSystemType()),this.m_gcs=e;const s=Hu();e.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);const n=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,i=Math.cos(n),o=Math.sin(n),a=Math.cos(r),h=Math.sin(r);this.m_cartCenter3D=fs(this.m_a,this.m_e2,i,o,a,h),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),Ye.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(et.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(et.construct(0,.5*-Math.PI/this.m_rpu))}project(e){const t=e.getGeometryType();if(x(t)){y(e);const t=e;return this.projectMultiVertex(t)}n("Gnomonic.project")}unproject(e,t,s){const r=e.getGeometryType();if(x(r)){y(e);let n=e;const o=[];if(r===i.enumPolygon){const e=n.getPathCount();for(let t=0;t<e;t++){const e=n.calculateRingArea2D(t);o.push(e)}}return this.unprojectMultiVertex(t,n),h(r)?(Cm(this.m_gcs,0,n),dm(o,this.m_gcs,0,n,s)):n=vl(n,this.m_gcs,0,!0,0,s),n}n("Gnomonic.unproject")}projectPoint(e){const t=e.mul(this.m_rpu),s=ds(this.m_a,this.m_e2,t),n=this.m_normal.dotProduct(s);if(n<=0)return et.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new et;return o.x=this.m_basisX.dotProduct(i),o.y=this.m_basisY.dotProduct(i),o}unprojectPoint(e){const t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return Ps(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){const t=e.getImpl();let s=!0;const n=new et,r=new et;for(let i=0,o=t.getPointCount();i<o;i++)t.queryXY(i,n),n.y*this.m_rpu>.5*Math.PI?r.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?r.assign(this.m_southPolePcs):r.assign(this.projectPoint(n)),t.setXYNoCurves(i,r),r.isNAN()&&(s=!1);return t.notifyModifiedFlags(2001),s}unprojectMultiVertex(e,t){const s=t.getImpl(),n=e*e,r=!this.m_northPolePcs.isNAN(),i=!this.m_southPolePcs.isNAN();for(let o=0,a=s.getPointCount();o<a;o++){const e=s.getXY(o);let t=new et;r&&et.sqrDistance(e,this.m_northPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*Math.PI),t.scale(1/this.m_rpu)):i&&et.sqrDistance(e,this.m_southPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),t.scale(1/this.m_rpu)):t=this.unprojectPoint(e),s.setXYNoCurves(o,t)}s.notifyModifiedFlags(2001)}}function dm(e,t,n,r,o){const a=r.getGeometryType(),h=t.getPannableExtent();let m=r,l=!1,g=!1;if(a===i.enumPolygon){const r=new s,i=et.construct(n,0);r.setCoords({env2D:h}),r.centerAt(i),l=pm(e,t,r,m,o);const a=Sm(t,r,m,o);a!==m&&(g=!0),m=a}else m=(new qh).foldInto360RangeGeodetic(m,t,2);a===i.enumPolygon&&(l||g)&&(m=(new Eh).execute(m,t,!1,o)),m!==r&&(r.setEmpty(),r.add(m,!1))}function pm(e,t,s,n,r){const i=fm(s,n),o=xm(e,t,s,n,r);return i||o}function fm(e,t){const n=new s;t.queryEnvelope(n);const r=Pc(e.ymax,n.ymax),i=Pc(e.ymin,n.ymin),o=r||i;return!!o&&(ym(e,t),o)}function xm(e,t,s,n,r){const i=[],o=[],a=.5*s.width();for(let g=0;g<n.getPathCount();g++){const h=n.getXY(n.getPathStart(g)),m=n.getXY(n.getPathEnd(g)-1),l=e[g]<0;if(Math.abs(h.x-m.x)>a){const e=Pm(l,t,s,g,n,r);i.push(e),o.push(g)}else if(!l){if(n.calculateRingArea2D(g)<0){const e=Em(t,s,g,n,r);i.push(e),o.push(g)}}}if(0===i.length)return!1;const h=new T({vd:n.getDescription()});let m=0,l=o[m];for(let g=0;g<n.getPathCount();g++)g===l?(h.add(i[m],!1),m++,m<o.length&&(l=o[m])):h.addPath(n,g,!0);return n.setEmpty(),n.add(h,!1),!0}function ym(e,t){const n=new T,r=new s;for(let s=0;s<t.getPathCount();s++){t.queryPathEnvelope(s,r);let i=Pc(e.ymax,r.ymax),o=Pc(e.ymin,r.ymin);if(!(i||o)){n.addPath(t,s,!0);continue}n.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(s),h=t.getPathEnd(s),m=h-a;let l=-1;for(l=a;l<h;l++){const s=t.getXY(l);if(i=Pc(e.ymax,s.y),o=Pc(e.ymin,s.y),!i&&!o)break}let g=l,u=!1,c=Number.NaN;do{const r=t.getXY(g);i=Pc(e.ymax,r.y),o=Pc(e.ymin,r.y);const h=a+(g+1-a)%m;if(i||o){let i=et.construct(c,r.y);n.insertPoint2D(s,-1,i);const o=t.getXY(h),a=Pc(e.ymax,o.y),m=Pc(e.ymin,o.y);a||m||(i=et.construct(o.x,r.y),u?n.setXYNoCurves(n.getPointCount()-1,i):n.insertPoint2D(s,-1,i)),u=!0}else n.insertPoint2D(s,-1,r),c=r.x,u=!1;g=h}while(g!==l)}t.setEmpty(),t.add(n,!1)}function Pm(e,t,n,r,i,o){const a=new T,h=new T,m=new jt,l=i.getXY(i.getPathStart(r)),g=i.getXY(i.getPathEnd(r)-1),u=n.width(),c=.5*u,_=new s;i.queryEnvelope(_);const d=Math.ceil(_.width()/u)+1;let p,f;l.x>g.x?(p=-u,f=e?n.ymin:n.ymax):(p=u,f=e?n.ymax:n.ymin),m.setShiftCoords(p,0),a.addPath(i,r,!0),h.add(a,!1);const x=new ye;for(let s=0;s<d;s++)h.applyTransformation(m),h.getPointByVal(0,x),a.lineToPoint(x),a.addSegmentsFromPath(h,0,0,h.getSegmentCount()-1,!1);const y=a.getXY(0),P=a.getXY(a.getPointCount()-1);y.y=f,P.y=f,a.lineTo(P);const E=new et;for(E.setCoordsPoint2D(P),E.x-=.5*p;Math.abs(E.x-y.x)>c;)a.lineTo(E),E.x-=.5*p;a.lineTo(y);const S=n.getCenter().x,C=new s;a.queryEnvelope(C);let I=0;const b=C.getCenter().x;b-S>c?I=-Math.ceil((b-S-c)/u):S-b>c&&(I=Math.ceil((S-b-c)/u)),0!==I&&(m.setShiftCoords(I*u,0),a.applyTransformation(m));const w=new V,v=w.addGeometry(a);kl(w,v,t,0,2,!0,n.xmin),kl(w,v,t,0,2,!0,n.xmax);const N=w.getGeometry(v),G=Ze(N,n);G.inflateCoords(0,1);const D=fe(null,G,!0);return Zt(N,n,D.total(),Number.NaN,o)}function Em(e,t,n,r,i){const o=t.width(),a=.5*o,h=t.getCenter().x,m=new s;r.queryPathEnvelope(n,m);let l,g=0,u=m.getCenter().x;if(u-h>a?g=-Math.ceil((u-h-a)/o):h-u>a&&(g=Math.ceil((h-u-a)/o)),0!==g){const e=new jt;e.setShiftCoords(g*o,0),r.getImpl().applyTransformationToPath(e,n),r.queryPathEnvelope(n,m),u=m.getCenter().x}const c=new s;t.containsExclusiveEnvelope(m)?(l=!1,c.setCoords({env2D:t})):(l=!0,c.setCoords({env2D:t}),c.xmin-=o,c.xmax+=o);let _=r.createInstance();_.addPathPoint2D(null,0,!0);const d=new et;if(d.setCoords(c.xmin,c.ymin),_.insertPoint2D(0,-1,d),d.setCoords(c.xmin,c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(.5*(c.xmin+c.xmax),c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(c.xmax,c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(c.xmax,c.ymin),_.insertPoint2D(0,-1,d),d.setCoords(.5*(c.xmin+c.xmax),c.ymin),_.insertPoint2D(0,-1,d),l){_.addPath(r,n,!0);const s=new jt;u<h?s.setShiftCoords(o,0):s.setShiftCoords(-o,0),r.getImpl().applyTransformationToPath(s,n),_.addPath(r,n,!0);const a=new V,m=a.addGeometry(_);kl(a,m,e,0,2,!0,t.xmin),kl(a,m,e,0,2,!0,t.xmax),_=a.getGeometry(m);const l=Ze(_,t);l.inflateCoords(0,1);const g=fe(null,l,!0).total();_=Zt(_,t,g,Number.NaN,i)}else _.addPath(r,n,!0);return _}function Sm(e,t,n,r){const i=new s;n.queryEnvelope(i);const o=ge(null,n,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return n;const a=n.createInstance();let h=n.createInstance();const m=new s,l=n.getPathCount();for(let s=0;s<l;s++)n.queryPathEnvelope(s,m),t.xmin-m.xmin<=o&&m.xmax-t.xmax<=o?a.addPath(n,s,!0):(h.setEmpty(),h.addPath(n,s,!0),h=cm(e,t,h,!0,r),a.add(h,!0));return a}function Cm(e,t,s){const n=e.getPannableExtent(),r=et.construct(t,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new et;a.setNAN();let h=Number.NaN;for(let m=0;m<s.getPathCount();m++)for(let e=s.getPathStart(m);e<s.getPathEnd(m);e++){const t=s.getXY(e),r=Pc(t.y,n.ymax)||Pc(n.ymin,t.y);e===s.getPathStart(m)?(a.setNAN(),h=0):a.isNAN()||r||(h=Im(t.x,a.x,o,i,h)),t.x+=h,s.setXYNoCurves(e,t),r||a.setCoordsPoint2D(t)}s.getImpl().notifyModifiedFlags(2001)}function Im(e,t,s,n,r){return r+e-t>s?r-=n:t-(r+e)>s&&(r+=n),r}function bm(e,t,s,n,r,i){const o=t.getAttributeStreamRef(0),a=t.getPointCount();let h=!1;const m=new et;for(let P=0;P<a;++P){if(o.queryPoint2D(2*P,m),1&i&&m.y>=s){h=!0;break}if(2&i&&m.y<=-s){h=!0;break}}if(!h)return!1;let l=!1;e&&(l=t.getImpl().isClosedPathInXYPlane(0));const g=new V,u=g.addGeometry(t),c=g.getFirstPath(u);let _=-1,d=!0;const p=new et,f=new ye;let x=q;const y=Gm*r/360;for(let P=g.getFirstVertex(c);P!==q;P=g.getNextVertex(P)){g.queryXY(P,m);let e=1&i&&m.y>=s?1:0;if(e|=2&i&&m.y<=-s?2:0,_>0&&_!==e){if(p.x!==m.x){const e=g.getPrevVertex(P);g.queryPoint(e,f);const t=g.insertVertex(c,P,f);p.x=m.x,g.setXY(t,p)}if(l){let e=x!==q?g.getNextVertex(x):g.getFirstVertex(c);const t=g.getPrevVertex(P);for(;e!==t;)e=g.removeVertex(e,!1);if(x!==q){const e=g.getXY(x),s=g.getXY(t);if(Math.abs(e.x-s.x)>y){g.queryPoint(x,f);const n=g.insertVertex(c,t,f);e.x=ct(e.x,s.x,.5),g.setXY(n,e)}}}x=q}if(e&&(m.y=_t(n,m.y),g.setXY(P,m),!d&&_!==e))if(m.x!==p.x){g.queryPoint(P,f);const e=g.insertVertex(c,P,f);g.setXYCoords(e,p.x,m.y),x=e}else x=P;_=e,p.assign(m),d=!1}if(l){if(x!==q){let e=g.getNextVertex(x);for(;e!==q;)e=g.removeVertex(e,!1)}const e=g.getFirstVertex(c);let t=g.getLastVertex(c);const s=g.getXY(e),n=g.getXY(t);if(!s.equals(n)&&(g.queryPoint(e,f),t=g.insertVertex(c,q,f),Math.abs(s.x-n.x)>y)){const e=g.insertVertex(c,t,f);s.x=ct(s.x,n.x,.5),g.setXY(e,s)}}return t.assignCopy(g.getGeometry(u)),!0}function wm(e,t){let s=new T({vd:e});s.addEnvelope(t,!1);const n=t.width()/180;return s=(new Jt).execute(s,n,0,0,null),s}function vm(e,t){const s=e.getPannableExtent();return Number.isNaN(t)||s.centerAtCoords(t,0),s}function Nm(e,t,s){const n=Hu();t.querySpheroidData(n);const r=t.getGCS()!==t?t.getSRToGCSTransform():null,i=gt(et,100),o=new Ye(0,0,0),a=e.getPointCount(),h=t.getGCS().getUnit().getUnitToBaseFactor();for(let u=0,c=a;u<c;){const t=Math.min(100,c-u);e.queryCoordinates(i,t,u,u+t),r&&(new qh).transform(r,i,t,i,!1);for(let e=0;e<t;e++){if(i[e].isNAN())continue;i[e].scale(h);const t=ds(n.majorSemiAxis,n.e2,i[e]);o.addThis(t)}u+=t}const m=Ps(n.majorSemiAxis,n.e2,o);m.scale(1/h);const l=e;if(!new _m(t.getGCS(),m).project(l))return 0;s.length=e.getPathCount();const g=l.calculateArea2D()<0;for(let u=0,c=e.getPathCount();u<c;u++){const e=l.calculateRingArea2D(u),t=g?e<0:e>0;s[u]=t}return g?-1:1}function Tm(e,t,s,n,r){if(!t.isPannable()||e.isEmpty())return e;const o=e.getGeometryType();o===i.enumGeometryCollection&&d("not yet impl for geometry collection");const h=t.getPannableExtent();Number.isNaN(s)&&(s=h.getCenterX());const m=h.width(),l=.5*m,g=r>0,u=e.queryInterval(0,0);if(!g&&u.width()<l||!x(e.getGeometryType())){const t=u.getCenter();if(Math.abs(t-s)<=l)return e;{const n=new jt,r=it((s-t)/m)*m;n.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(n),i}}if(o===i.enumPolygon){let i=new w({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),g&&(i=Oh(i,t,2,r,Number.NaN,null,!0));const o=[];if(!n){{let s=e;g&&(s=new T,s.add(i,!1));const n=Nm(e,t,o);if(n)n<0&&i.reverseAllPaths();else{const e=s.getPathCount();for(let t=0;t<e;t++)o.push(s.calculateRingArea2D(t)>0)}}n=o}return new Dm(null,n,i,null,t,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(o===i.enumPolyline){let n=new w({vd:e.getDescription()});n.addAndExplicitlyOpenAllPaths(e,!1),g&&(n=Oh(n,t,2,r,Number.NaN,null,!0));return new Dm(null,null,n,null,t,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(o===i.enumMultiPoint){const t=e,n=t.getAttributeStreamRef(0);let r,i=null,o=s,a=0;const h=.1*m;for(let s=0,g=t.getPointCount();s<g;s++){const t=n.read(2*s);let g=t-o;if(Math.abs(g)>l&&(g=it(g/m)*m,a-=g,Math.abs(a)<h&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const n=t+a;i.write(2*s,n)}o=t}return i?(r.notifyModified(),r):e}a("")}const Gm=210;class Dm{constructor(e,t,s,n,r,i,o,a,h){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=h,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=a,this.m_poleFlags=o,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=vm(this.m_pannableSR,i),this.m_centralLongitude=Number.isNaN(i)?this.m_pannableExtent.getCenterX():i,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=Gm*this.m_degree,l(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,r,i,o){let h=s;const m=new w({vd:this.m_inputPoly.getDescription()});m.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(!0,m,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(h=!1));let g=-1;h&&(g=this.m_originalGeometry.getPathStart(e));const u=m.getAttributeStreamRef(0),c=m.getPointCount();let _=0,d=u.read(0),p=0;const f=3*this.m_pannableSR.getTolerance(0);let x=!1;const y=new et,P=new et;let E=!1;const S=m.hasNonLinearSegments(),C=new et;for(let l=1;l<c;++l){u.queryPoint2D(2*l,C);const e=C.x;let t=e+_;const s=t-d;if(C.x=t,Math.abs(s)>this.m_GCSLargeDelta){if(h){const e=g+l-1,t=g+(l+1<c?l:0),r=i.read(2*e),o=(i.read(2*t)-r)*n;Math.abs(s-o)>1*this.m_degree&&(h=!1)}if(!h){_-=_t(this.m_width360,t-d),t=e+_,++p,E=0!==_,C.x=t}}else x||Re(y,P,C,f)&&(x=!0);E&&(S&&a("error in geonormalize_ring_ for curves"),u.write(2*l,t)),d=t,y.setCoordsPoint2D(P),P.setCoordsPoint2D(C)}p&&m.notifyModified();const I=m.getXY(0),b=m.getXY(c-1);if(et.distance(I,b)<f){const e=this.finalizeGeoNormalizeClosedRing(m,x,r);o.add(e,!1)}else{if(t<0)if(null!==this.m_originalGeometry){l(null!==this.m_originalGeometry);t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0}else t=1;const s=this.finalizeGeoNormalizeOpenedRing(t>0,m);o.add(s,!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=Number.NaN;const 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;const i=new T({vd:this.m_inputPoly.getDescription()});for(let s=0,l=this.m_inputPoly.getPathCount();s<l;++s){const o=this.m_polygonRingFlags?this.m_polygonRingFlags[s]?1:0:-1;this.geonormalizeRing(s,o,r,n,e,t,i)}const o=this.m_pannableSR.getTolerance(0),a=this.m_pannableExtent.width()/180;Ol(i,this.m_pannableExtent,.1*o,!1);const h=s.constructEmpty();if(h.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=s.constructEmpty();for(let s=0,n=i.getPathCount();s<n;s++)if(i.queryPathEnvelope(s,t),!(h.xmin<=t.xmin&&h.xmax>=t.xmax||t.xmin>=h.xmax||t.xmax<=h.xmin)){e=!1;break}if(e)break;h.move(.5*this.m_width360,0)}e||h.setCoords({env2D:this.m_pannableExtent})}let m=Zt(i,h,o,a,this.m_progressTracker),g=i!==m;const u=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,c=m.calculateArea2D();let _=0;if(c>0&&u<0)_=1;else if(c<=0&&u>0)if(0===c){if(this.m_originalSR){let e=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?e=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(e=this.m_originalSR.getPannableExtent().getArea()),u>.99*e&&(_=-1)}}else _=-1;if(0!==_){const e=wm(m.getDescription(),h);e.add(m,!1),g=!0,m=e}return g&&(m=(new Eh).execute(m,this.m_pannableSR,!1,this.m_progressTracker)),m}geoNormalizePolylineGeometry(e){l(this.m_pannableSR.isPannable());let t=null;const n=this.m_originalSR&&this.m_originalSR.isPannable();let r=1;n&&(l(this.m_originalGeometry),r=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const i=this.m_pannableExtent.width(),o=i*lt()*4;let h=e,m=Number.NaN;const g=at.constructEmpty();this.m_bAdjustedAtPoles=0;let u=new w({vd:this.m_inputPoly.getDescription()});for(let d=0,p=this.m_inputPoly.getPathCount();d<p;++d){let e=n;const c=new w({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,d,!0);const _=this.m_inputPoly.isClosedPath(d);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(_,c,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(e=!1));let p=-1;const f=c.getPointCount();let x=!1;e&&(p=this.m_originalGeometry.getPathStart(d),x=this.m_originalGeometry.isClosedPath(d));const y=c.getAttributeStreamRef(0);let P=0,E=y.read(0),S=0;const C=new et,I=new et;let b=!1;const v=c.hasNonLinearSegments(),N=new et;for(let s=1;s<f;++s){y.queryPoint2D(2*s,N);const n=N.x;let i=n+P;const o=i-E;if(N.x=i,Math.abs(o)>this.m_GCSLargeDelta){if(e){const n=p+s-1;let i=p;(!x||s+1<f)&&(i+=s);const a=t.read(2*n),h=(t.read(2*i)-a)*r;Math.abs(o-h)>1*this.m_degree&&(e=!1)}if(!e){P-=_t(this.m_width360,i-E),i=n+P,++S,b=0!==P,N.x=i}}b&&(v&&a("error in geonormalize_ring_ for curves"),y.write(2*s,i)),E=i,C.setCoordsPoint2D(I),I.setCoordsPoint2D(N)}if(S&&c.notifyModified(),h){let e=!1;if(!c.isEmpty()){const t=s.constructEmpty();if(c.queryEnvelope(t),t.width()>=i||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(m)){const e=this.m_centralLongitude-.5*i;m=t.xmin,m+=Math.round((e-t.xmin)/i)*i,m>e&&(m-=i),l(m<=e),m<e&&(m+=i),l(m>=e)}let s=Math.round((m-t.xmin)/i)*i;if(t.xmin+s>m+o&&(s-=i),t.xmin+s<m-o&&(s+=i),g.mergeCoordinate(t.xmin+s),g.mergeCoordinate(t.xmax+s),e=g.width()>=i,!e){const e=new jt;e.setShiftCoords(s,0),c.applyTransformation(e)}}}u.add(c,!1),e&&(u=(()=>{const e=new w({vd:u.getDescription()});for(let t=0,s=u.getPathCount();t<s;++t){const s=new w({vd:u.getDescription()});s.addPath(u,t,!0);const n=vl(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(n,!1)}return e})(),h=!1)}else{const e=vl(c,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);u.add(e,!1)}}if(h)return u;const c=this.m_pannableSR.getTolerance(0),_=this.m_pannableExtent.width()/180;Ol(u,this.m_pannableExtent,.1*c,!1);return Zt(u,this.m_pannableExtent,c,_,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const n=t.getPointCount(),r=t.getXY(0),i=t.getXY(n-1);{const 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))}const o=mt(i.x-r.x),a=s.constructEmpty();t.queryLooseEnvelope(a);const h=this.m_pannableExtent.getCenterX();let m=0,g=h-this.m_width360,u=h+this.m_width360;if(o>=0){let e=Math.ceil((g-a.xmin)/this.m_width360);for(e*=this.m_width360;g>a.xmin+e;)e+=this.m_width360;for(;g<a.xmax+e;)e-=this.m_width360;for(m=e,a.width()>720&&(u=g+360*Math.ceil(a.width()/360));u<a.xmax;)u+=this.m_width360}else{let e=Math.ceil((u-a.xmax)/this.m_width360);for(e*=this.m_width360;u<a.xmax+e;)e-=this.m_width360;for(;u>a.xmin+e;)e+=this.m_width360;for(m=e,a.width()>720&&(g=u-360*Math.ceil(a.width()/360));g>a.xmin;)g-=this.m_width360}const c=Math.round(Math.abs(i.x-r.x)/this.m_width360)*this.m_width360,_=o*c,d=a.clone();d.move(m,0);const p=new et(0,0),f=new jt;f.setShiftCoords(m,0),t.applyTransformation(f);const x=new w({vd:t.getDescription()});x.add(t,!1),p.assign(t.getXY(n-1));let y=0,P=x.getXY(0).x;for(;o>0?d.xmax<u:d.xmin>g;)d.move(_,0),f.xd=_,t.applyTransformation(f),P+=_,this.m_pannableExtent.xmin<=P&&this.m_pannableExtent.xmax>=P&&(y=x.getPointCount()-1),t.setXY(0,p),p.assign(t.getXY(n-1)),x.addSegmentsFromPath(t,0,0,n-1,!1);const E=new T({vd:x.getDescription()});E.add(x,!1);const S=x.getXY(0),C=x.getXY(x.getPointCount()-1),I=o<0?e:!e,b=E.getPointCount()-1;if(I){const e=new et(C.x,this.m_pannableExtent.ymax);E.lineTo(e);const t=new et(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);E.lineTo(t);const s=new et(S.x,this.m_pannableExtent.ymax);E.lineTo(s)}else{const e=new et(C.x,this.m_pannableExtent.ymin);E.lineTo(e);const t=new et(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);E.lineTo(t);const s=new et(S.x,this.m_pannableExtent.ymin);E.lineTo(s)}if(E.interpolateAttributesPath(0,b,0),E.getImpl().changeRingStartPoint(y),c>this.m_width360){const e=new T({copy:E});f.setShiftCoords(this.m_width360,0),e.applyTransformation(f),E.add(e,!1)}return E}finalizeGeoNormalizeClosedRing(e,t,n){const r=new T({vd:e.getDescription()});r.add(e,!1);const o=()=>{const e=r.getPointCount()-2;return r.getSegmentType(e)!==i.enumLine};if(r.hasNonLinearSegments()&&o()){const e=new k,t=r.getPointCount()-2;r.getSegmentBuffer(t,e,!1),r.removePointFromPath(0,t+1),r.closeLastPathWithSegment(e.get())}else r.removePointFromPath(0,r.getPointCount()-1);const a=s.constructEmpty();r.queryLooseEnvelope(a);let h=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(h*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+h;)h+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+h;)h-=this.m_width360;if(h+=this.m_width360,0!==h){a.move(h,0);const e=new jt;e.setShiftCoords(h,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){const e=r.calculateArea2D(),t=(new Eh).execute(r,this.m_pannableSR,!0,this.m_progressTracker);if(t!==r){const s=t.calculateArea2D();mt(e)!==mt(s)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=new T(n?{copy:r}:{move:r}),n)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const t=new jt;t.setShiftCoords(this.m_width360,0),r.applyTransformation(t),e.add(r,!1)}return e}let m=new T({vd:e.getDescription()});m.add(r,!1);const l=t||a.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const e=new jt;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),m.add(r,!1)}if(l){const e=m.calculateArea2D();m.setFillRule(1),m=(new Eh).execute(m,this.m_pannableSR,!0,this.m_progressTracker);const t=m.calculateArea2D();mt(e)!==mt(t)&&m.reverseAllPaths()}return m}geonormalize_ring_(e,t,s,n,r,i,o){l(0)}}function Vm(e){l(0);const t=ou(e),s=new km;return s.setVertProj_(t),s}function Fm(e,t=!0){return l(0),{}}function Hm(e){return Su()}class km{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new bu,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.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()}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Am(e,t,s,n,r){if(e.equals(t))return!1;if(n){let s=1,i=0,o=1,a=1,h=0,m=1;Number.isNaN(e.m_heightMetersPerUnit)||(s=e.m_heightMetersPerUnit,i=e.m_heightZ0,o=e.m_heightSign,a=t.m_heightMetersPerUnit,h=t.m_heightZ0,m=t.m_heightSign);const l=o*m*s/a;for(let e=0;e<r;e++)n[e]=(n[e]-i)*l+h}let i=1,o=0;if(Number.isNaN(e.m_XYToRadians)||(i=e.m_XYToRadians/t.m_XYToRadians,o=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,0!==o&&(o=le(o),o/=t.m_XYToRadians)),Array.isArray(s)){const e=s;for(let t=0;t<r;t++)e[t][0]=e[t][0]*i+o,e[t][1]=e[t][1]*i}else{const e=s;for(let t=0;t<r;t++){const s=t<<1;e[s]=e[s]*i+o,e[s+1]=e[s+1]*i}}return!0}function Mm(){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 rt(this.m_heightSign,e.m_heightSign)&&rt(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&rt(this.m_heightZ0,e.m_heightZ0)&&rt(this.m_XYToRadians,e.m_XYToRadians)&&rt(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,t&&l(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){const s=e?e.getPECoordSys():null,n=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Um{constructor(e){this.m_constantsLoaded=-1,this.m_isUsable=-1,this.m_inputSR=null,this.m_outputSR=null,this.m_inputSRHorz=null,this.m_outputSRHorz=null,this.m_inputVCS=null,this.m_outputVCS=null,this.m_hashCode=0,this.m_areaOfUse=new xe,this.m_inputUnitParams=Mm(),this.m_outputUnitParams=Mm(),l(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=Ic.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const t=this.m_geogTran.getGeogcs1();Ic.getCode(t);const s=this.m_geogTran.getGeogcs2();Ic.getCode(s),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(-1===t){if(!e){this.m_geogTran||a("vcs not impl");const t=this.m_geogTran.getParameters();null!==t[bc.PE_PARM_ND]&&(e=0===t[bc.PE_PARM_ND].getValue())}t=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=t}return 0!==t}isUsable(){let e=this.m_isUsable;return-1===e&&(this.m_geogTran?this.m_isUsable=e=this.m_geogTran?1:0:this.m_isUsable=e=this.m_vertTran?1:0),1===e}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return 0===e&&(e=this.m_latestID>0?Qe(this.m_latestID):It(this.getText()),0===e&&(e=345),this.m_hashCode=e),e}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():(d("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,s,n,r,i;if(this.m_geogTran){const o=this.m_geogTran.getGeogcs1(),a=ru(o),h=this.m_geogTran.getGeogcs2(),m=ru(h);let l=-1,g=-1;l=a.getVcsCode(),g=m.getVcsCode(),s=Ru(o,null,null,1),n=Ru(h,null,null,1),l>0&&g>0?(r=Vm(l),i=Vm(g),e=zu(),t=zu()):(e=s,t=n)}else l(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=s,this.m_outputSRHorz=n,this.m_inputVCS=r,this.m_outputVCS=i)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=Number.NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_outputUnitParams.m_XYToRadians=Number.NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_vertTran)l(0);else if(this.m_geogTran){const e=this.m_geogTran;let t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function qm(e,t,s,n,r,i,o){let a=null;if(t){a=t.getPEVerticalCoordSys()}let h=null;if(e){h=e.getPECoordSys()}let m=null;if(n){m=n.getPEVerticalCoordSys()}let l=null;if(s){l=s.getPECoordSys()}if(!(h||a||l||m))return!1;const g=Mm();g.initFromGcsAndVcsPe(h,a);const u=Mm();return u.initFromGcsAndVcsPe(l,m),Am(g,u,r,i,o)}function Bm(e,t,s,n,r,i,o,a){const h=t,m=e,l=Mm();l.initFromGcsAndVcsPe(m,h),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Am(l,a,r,i,o)}function Om(e,t,s,n,r,i,o,a){const h=Mm();h.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),h.processUnitParams(e);let m=null,l=null;if(n){l=n.getPECoordSys()}const g=Mm();g.initFromGcsAndVcsPe(l,m),g.processUnitParams(h),h.processUnitParams(g),a>0&&Am(h,g,i,o,a)}function Ym(e,t,s,n,r,i,o,a,h){const m=Mm(),l=Mm();m.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),l.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),m.processUnitParams(e),l.processUnitParams(m),m.processUnitParams(l),a>0&&Am(m,l,i,o,a),h.assign(l)}function Rm(e,t,s,n,r,i,o){const a=t.getVerttran(),h=t.getGeogtran();if(o.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),i>0){t.prepareOrThrow();const e=s?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;a?dg():pg(h,i,n,r,e)}}function Xm(e,t,s,n,r){const i=e.getVerttran(),o=e.getGeogtran();if(r>0){e.prepareOrThrow();const a=t?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;i?dg():pg(o,r,s,n,a)}}class Lm{supportsCurves(){return!0}accelerateGeometry(e,t,s){return zm(e,t,s)}canAccelerateGeometry(e){return Wm(e)}}function zm(e,t,s){if(!Wm(e))return!1;ce(t,e,!1);let n=0;const r=e.getGeometryType();return h(r)&&v(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),h(r)&&N(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function Wm(e){return v(e)||N(e)}class jm extends Lm{getOperatorType(){return 8}execute(e,t,s,n){return kr(e,t,s,1,n)}}function Zm(e,t,r,a){if(e.isEmpty()||t.isEmpty())return e;const h=e.getDimension(),m=t.getDimension();if(h>m)return e;const l=e.getGeometryType(),g=t.getGeometryType(),u=new s,c=new s,_=new s;e.queryEnvelope(u),t.queryEnvelope(c),_.setCoords({env2D:u}),_.mergeEnvelope2D(c);const d=fe(r,_,!0),p=Ee(d),f=new s;if(f.setCoords({env2D:u}),f.inflateCoords(p,p),!f.isIntersecting(c))return e;if(1===h&&2===m){const s=ol(e,t,g,r,a);if(s)return s}if(l===i.enumPoint){let s;switch(o(g)?(s=new w({vd:t.getDescription()}),s.addSegment(t,!0)):s=t,g){case i.enumPolygon:return Jm(e,s,d);case i.enumPolyline:return $m(e,s,d);case i.enumMultiPoint:return el(e,s,d);case i.enumEnvelope:return tl(e,s,d);case i.enumPoint:return sl(e,s,d);default:n("invalid shape type")}}else if(l===i.enumMultiPoint)switch(g){case i.enumPolygon:return nl(e,t,d);case i.enumEnvelope:return rl(e,t,d);case i.enumPoint:return il(e,t,d)}const x=new s(u);x.inflate(100*d.total());return Ya(e,Zt(t,x,0,0,a),r,a)}class Km{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new Qm(e,t,s,n)}execute(e,t,s,n){return this.executeMany(new es([e]),new es([t]),s,n).next()}}class Qm extends $t{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=s;const r=t.next();this.m_geomSubtractor=r||new T}next(){const e=this.m_inputGeoms.next();return e?(r(e),m(e),this.m_index=this.m_inputGeoms.getGeometryID(),Zm(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Jm(e,t,s,n){return 0===Xo(t,e,s.total())?e:e.createInstance()}function $m(e,t,n,r){const i=e.getXY(),o=t.querySegmentIterator(),a=Ee(n),h=a*a;for(;o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),r=new s;if(t.queryEnvelope(r),r.inflateCoords(a,a),!r.contains(i))continue;if(t.isIntersectingPoint(i,n.total()))return e.createInstance();let m=t.getStartXY();if(et.sqrDistance(i,m)<=h)return e.createInstance();if(m=t.getEndXY(),et.sqrDistance(i,m)<=h)return e.createInstance()}return e}function el(e,t,s,n){const r=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),o=e.getXY(),a=Ee(s),h=a*a,m=new et;for(let l=0;l<i;l++){r.queryPoint2D(2*l,m);if(et.sqrDistance(m,o)<=h)return e.createInstance()}return e}function tl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getXY();return i.contains(o)?e.createInstance():e}function sl(e,t,s,n){const r=Ee(s),i=r*r,o=e.getXY(),a=t.getXY();return et.sqrDistance(o,a)<=i?e.createInstance():e}function nl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getPointCount();let a=!1;const h=$e(o,!1),m=new et;for(let s=0;s<o;s++){if(e.queryXY(s,m),!i.contains(m))continue;0!==Lo(t,m,n.total())&&(a=!0,h[s]=!0)}if(!a)return e;const l=e.createInstance();for(let s=0;s<o;s++)h[s]||l.addPoints(e,s,s+1);return l}function rl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getPointCount();let a=!1;const h=$e(o,!1),m=new et;for(let s=0;s<o;s++)e.queryXY(s,m),i.contains(m)&&(a=!0,h[s]=!0);if(!a)return e;const l=e.createInstance();for(let s=0;s<o;s++)h[s]||l.addPoints(e,s,s+1);return l}function il(e,t,s,n){const r=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),o=t.getXY();let a=!1;const h=$e(i,!1),m=Ee(s),l=m*m,g=new et;for(let c=0;c<i;c++){r.queryPoint2D(2*c,g);et.sqrDistance(g,o)<=l&&(a=!0,h[c]=!0)}if(!a)return e;const u=e.createInstance();for(let c=0;c<i;c++)h[c]||u.addPoints(e,c,c+1);return u}function ol(e,t,n,r,o){const a=new xe;e.queryEnvelope(a);const h=new s;t.queryEnvelope(h),a.merge(h);const m=.1*a.width(),l=.1*a.height();a.inflateCoords(m,l);const g=new T;g.addEnvelope(a,!1);const u=g.getImpl();if(n===i.enumPolygon){const e=t.getImpl();u.add(e,!0)}else u.addEnvelope(t,!0);return new Ih(g,r,-1,o).tryFastImplementation(e)}class al{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n=0){return new gl(e,t,s,n)}execute(e,t,s,n){const r=new es([e,t]),i=new gl(r,s,n,0).next();return i||a("null output"),i}}function hl(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new et}}function ml(e,t){return et.compareZorder(e.location,t.location)?-1:e.location.equals(t.location)?0:1}class ll{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>ml(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class gl extends $t{constructor(e,t,s,n,r=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=tt(4),this.m_dimGeomCounts=$e(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=$e(4,!1),this.m_complexUnionGeoms=tt(4),this.m_totalNonEmptyGeomCounters=$e(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=n,this.m_bIs3D=r}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?l(0):this.m_complexUnionGeoms[e]=(new Km).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)&&a(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.enumPoint){const e=new G({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(e){return this.m_readyGeoms[e]}finishDim(e,t,s){let n=t;if(!s)return 16&this.m_options?(n=ja([n],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),n):n;if(1&this.m_options)return n;if(1===e){if(!(8&this.m_options)&&(!!(16&this.m_options)||this.m_totalNonEmptyGeomCounters[e]>1)){n=ja([n],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=n.getImpl().getIsSimple(0,e);l(this.m_bIs3D||de(t))}else 1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?l(0):n=(new Eh).execute(n,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?l(0):n=(new Eh).execute(n,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&n.getGeometryType()===i.enumPoint){const e=new G({vd:n.getDescription()});n.isEmpty()||e.add(n),n=e}return n}static getLevel(e){const t=4,s=c(e);let n=s>0?(Math.log(s)-Math.log(32))/Math.log(t):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(),null===e?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,null!==e){const t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?ja(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Za(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&(l(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,n=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,n)}}return this.m_bDone}addGeom(e,t,n){const r=hl();r.geom=n;const i=c(n);r.vertexCount=i;const o=s.constructEmpty();n.queryEnvelope(o),r.location=i>0?o.getCenter():new et(0,0);const a=gl.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 h=null;const m=this.m_unionBins[e].get(a);m&&(h=m),null===h&&(h=new ll,this.m_unionBins[e].set(a,h)),r.bUnioned=t,h.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(1&this.m_options&&!this.m_bDone)return null;let t=null;const s=[];for(const n of this.m_unionBins[e].keys())s.push(n);st(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const r=this.m_unionBins[e].get(s[n]);{const i=5e3,o=4,a=r.getBinVertexCount()>i&&r.geomCount()>=o;if(this.m_bDone||a){for(let r=0;r<n;r++){if(-1===s[r])continue;const n=this.m_unionBins[e].get(s[r]);n.sort(),this.m_dimGeomCounts[e]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const e of n.geomPairs())t||(t=new Array),t.push(e.geom);n.clear(),this.m_unionBins[e].delete(s[r]),s[r]=-1}r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(const e of r.geomPairs())t||(t=new Array),t.push(e.geom);if(r.clear(),this.m_unionBins[e].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&_(),e.hasAttribute(1)||n("Geometry must have Zs")),r(e)}}class ul extends Lm{getOperatorType(){return 3}execute(e,t,s,n=null){return kr(e,t,s,4,n)}}function cl(e,t,n){const r=t.getGCSSplitLines();if(null===r)return e;const i=t.getGCS(),o=i.getPannableExtent().width(),a=s.constructEmpty();e.queryLooseEnvelope(a);const h=at.constructEmpty();a.queryIntervalX(h);const m=r.querySegmentIterator();let l=null;const g=new jt;for(;m.nextPath();)for(;m.hasNextSegment();){const e=m.nextSegment(),t=e.queryInterval(0,0),s=at.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>h.vmin;)s.move(-o),n--;for(;s.vmin<=h.vmax;){if(s.isIntersecting(h)){null===l&&(l=new w);const t=new A({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(g.setShiftCoords(n*o,0),t.applyTransformation(g)),l.addSegment(t,!0)}s.move(o),++n}}if(null!==l){const t=ge(i,l,!0);return Un(e,l,Ee(t),n)}return e}function _l(e,t,s){let n=e.getName();return sc(n)||(s||t>0?(n=e.toString(bc.PE_STR_NAME_CANON|bc.PE_STR_AUTH_NONE),n=yl(n)):n=e.toString(bc.PE_STR_AUTH_TOP)),n}function dl(e,t,s,n){return l(0),""}function pl(e,t=-1){if((t>1||t<-1)&&n("verbosity"),-1===t)return e.toString();{const s=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return e.toString(s)}}function fl(e,t){(t>1||t<-1)&&n("verbosity");let s=bc.PE_STR_FMT_WKT2;return-1!==t&&(s|=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),e.toString(s)}function xl(e){return l(0),""}function yl(e){return e.toLocaleUpperCase("en-US")}function Pl(e,t,s){const r=e.getPCSHorizon();if(r.getGeometryType()===i.enumPolygon){const n=e.getDefaultPrecisionSR().getTolerance(0),i=r;for(let e=0;e<s;e++)1!==Lo(i,t[e],n)&&t[e].setNAN();return}if(r.getGeometryType()===i.enumEnvelope){const e=r;for(let n=0;n<s;n++)e.contains(t[n])||t[n].setNAN();return}n("")}function El(e,t,s,n){for(let r=0;r<t;r++){if(e[r].y<s.ymin||e[r].y>s.ymax){e[r].setNAN();continue}const t=e[r].x;e[r].x=Gl(t,s,n)}}function Sl(e,t,n,r){if(e.isEmpty()||1===n)return e;const o=e.getGeometryType();if(o===i.enumPoint){const s=e,r=s.getXY();return 0===wl([r],1,t,n)||r.isNAN()?s.setEmpty():s.setXY(r),e}if(o===i.enumMultiPoint){const s=e,r=e.createInstance(),i=s.getPointCount();r.reserve(i);const o=s.getAttributeStreamRef(0),a=s.getDescription().getAttributeCount()>1,h=new ye,m=Float64Array.from(o.getArray());if(wl(m,i,t,n)>0)for(let e=0,t=2*i;e<t;e+=2)Number.isNaN(m[e])||(a?(s.getPointByVal(e>>1,h),h.setXYCoords(m[e],m[e+1]),r.add(h)):r.addXY(m[e],m[e+1]));return r}let m=e;const l=t.getOneDegreeGCSUnit(),g=90*l,u=180*l,c=360*l,_=t.getCentralMeridian(),d=.5*l,p=s.constructEmpty();m.queryEnvelope(p);const f=t.getGCSHorizon(),x=t.getGCSHorisonIsInclusive(),y=f.getGeometryType()===i.enumEnvelope,P=s.constructEmpty();f.queryEnvelope(P);const E=t.getGCS();if(2!==n&&4!==n||(P.xmin=_-u,P.xmax=P.xmin+c),4===n){if(!(p.width()>c-l)){const e=s.constructEmpty();e.setCoords({xmin:p.xmin-l,ymin:P.ymin,xmax:p.xmax+l,ymax:P.ymax}),m=(new Kt).execute(m,e,E,r);let t=Math.floor((_-p.getCenterX())/c);for(p.move(t*c,0);p.xmin>P.xmax;)t-=1,p.move(-c,0);for(;p.xmin<P.xmin;)t+=1,p.move(c,0);if(0!==t){const e=new jt;e.setShiftCoords(t*c,0),m.applyTransformation(e)}return m}n=2}if(2===n&&(P.xmin=_-u,P.xmax=P.xmin+c),p.ymin<-g||p.ymax>g){const e=s.constructEmpty();if(e.setCoords({xmin:p.xmin-l,ymin:-g,xmax:p.xmax+l,ymax:g}),m=(new Kt).execute(m,e,E,r),m.isEmpty())return m;m.queryEnvelope(p)}if(x&&(P.ymax<p.ymin||P.ymin>p.ymax))return m.createInstance();p.width()>c&&(m=ql(m,_-u,c,E,!0,0,!0,r),m.queryEnvelope(p));let S=Ul(p.xmin,p.xmax,P.xmin,P.xmax,c);if(0!==S&&p.move(S,0),p.xmax>P.xmax||p.xmin<P.xmin){if(p.xmax>P.xmax)for(;p.xmin>=P.xmax;)p.move(-c,0),S-=c;for(;p.xmin<P.xmax-c;)p.move(c,0),S+=c}const C=ce(E,f,!1);if(0!==S){const e=new jt;e.setShiftCoords(S,0),m.applyTransformation(e),S=0}if(x){if(y&&P.containsEnvelope(p))return m;const e=new Array(2);for(let t=0;t<2;t++){let s;if(y?s=h(o)?Zt(m,P,C,d,r):Zt(m,P,C,0,r):(s=(new wh).execute(m,f,E,r),s===f&&(s=s.clone())),P.xmin<=p.xmin&&P.xmax>=p.xmax)return s;if(P.xmin>=p.xmin&&P.xmax<=p.xmax)return s;if(e[t]=s,0===t){p.move(-c,0);const e=new jt;e.setShiftCoords(-c,0),m.applyTransformation(e)}}return h(o)?e[0].add(e[1],!1):a("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(P.ymax<p.ymin||P.ymin>p.ymax)return m;let e=0;for(;!m.isEmpty()&&p.xmax>P.xmin;){if(0!==e){const t=new jt;t.setShiftCoords(e,0),m.applyTransformation(t)}if(!(new ul).execute(m,f,E,r)){m=(new Km).execute(m,f,E,r),f===m&&(m=m.clone())}if(0!==e){const t=new jt;t.setShiftCoords(-e,0),m.applyTransformation(t)}e-=c,p.move(-c,0)}return m}}function Cl(s,n,r,i,o,a){const h={stack:[],error:void 0,hasError:!1};try{if(2===a){return Gs(s,n,r,i,o)}if(Math.abs(r.x-i.x)>=Math.PI||!Fg(r.x,i.x,o))return Number.NaN;r.x>i.x&&(i=ht(r,r=i));const t=e(h,new Cc,!1),m=e(h,new Cc,!1),l=e(h,new Cc,!1),g=r.clone();Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,m,t,null,a);const u=m.val;let c=0,_=1;for(;u*(_-c)>1e-12*s;){const e=.5*(c+_);if(Dc.geodeticCoordinate(s,n,r.x,r.y,u*e,t.val,m,l,a),g.x=m.val,g.y=l.val,g.x===o)return g.y;if(Fg(r.x,g.x,o))_=e;else{if(!Fg(i.x,g.x,o))return Number.NaN;c=e}}return g.y}catch(m){h.error=m,h.hasError=!0}finally{t(h)}}function Il(e,t){let s;if(Array.isArray(e)){const n=e;s=new Float64Array(2*t);for(let e=0,r=0;e<t;e++,r+=2)s[r]=n[e].x,s[r+1]=n[e].y}else s=e;return s}function bl(e,t,s,n){for(let r=0,i=0;r<n;r++,i+=2)t[s+r].x=e[i],t[s+r].y=e[i+1]}function wl(e,t,n,r){if(0===t||1===r)return t;const o=Il(e,t);if(2===r){const s=n.getPannableExtentInGCS();let r=t;for(let e=0,n=2*t;e<n;e+=2)(o[e+1]>s.ymax||o[e+1]<s.ymin)&&(o[e]=Number.NaN,r--);return r?(Bl(o,t,s.xmin,s.width(),!0),e!==o&&bl(o,e,0,t),r):(e!==o&&bl(o,e,0,t),0)}const a=n.getOneDegreeGCSUnit(),h=90*a,m=180*a,l=360*a;let g=t;for(let s=0,i=2*t;s<i;s+=2)(o[s+1]>h||o[s+1]<-h)&&(o[s]=Number.NaN,g--);if(!g)return e!==o&&bl(o,e,0,t),0;const u=s.constructEmpty();u.setFromPoints(o,t);const c=n.getGCSHorizon(),_=n.getGCSHorisonIsInclusive(),d=c.getGeometryType()===i.enumEnvelope,p=s.constructEmpty();if(c.queryEnvelope(p),_&&(p.ymax<u.ymin||p.ymin>u.ymax))return e!==o&&bl(o,e,0,t),0;if(_){if(Bl(o,t,p.getCenterX()-m,l,!0),g=t,d)for(let e=0,s=2*t;e<s;e+=2)p.containsCoords(o[e],o[e+1])||(o[e]=Number.NaN,g--);else{const e=ce(n.getGCS(),c,!1),s=new et;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(o[n],o[n+1]);0!==Lo(c,s,e)||(o[n]=Number.NaN,g--)}}}else{Bl(o,t,-m,l,!0),g=t;const e=ce(n.getGCS(),c,!1),s=new et;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(o[n],o[n+1]),s.isNAN()&&g--;const t=Ml(s.x,p.xmin,p.xmax,l);s.x+=t;0!==Lo(c,s,e)&&(o[n]=Number.NaN,g--)}}return e!==o&&bl(o,e,0,t),g}function vl(e,t,s,r,i,o){if(t.isPannable()||n("fold_into_360_degree_range"),e.isEmpty())return e;let a,h;if(2===t.getCoordinateSystemType()){const e=t.getPannableExtent();h=e.xmin,a=e.width()}else{const e=t.getOneDegreeGCSUnit();a=360*e,h=s-180*e}return ql(e,h,a,t,r,i,!0,o)}function Nl(e,t,s,n){let r,i;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();r=e.xmin,i=e.width()}else{const e=s.getOneDegreeGCSUnit();i=360*e,r=n-180*e}Bl(e,t,r,i)}function Tl(e,t){const s=t.width();let n=Je(e-t.vmin,s);n<0&&(n+=s);return t.snapClip(n+t.vmin)}function Gl(e,t,s){return e>t.xmax&&e-t.xmax<s?t.xmax:e<t.xmin&&t.xmin-e<s?t.xmin:e}function Dl(e,t,s){if(e[0]<t.vmin||e[0]>t.vmax||s&&e[0]===t.vmax){const s=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/s)*s,e[0]=t.snapClip(e[0]),!0}return!1}function Vl(e,t,s,n,r,i,o,a,h){return new Dm(e,null,s,t,n,r,o,a,i).geoNormalizePolygonGeometry(h)}function Fl(e,t,s,n,r,i,o,a,h){return new Dm(e,null,s,t,n,r,o,a,i).geoNormalizePolylineGeometry(h)}function Hl(e,t,s,n,r){const i=new V,o=i.addGeometry(e);return kl(i,o,t,ce(t,e,!1),s,n,r),i.getGeometry(o)}function kl(s,n,r,i,o,a,h){const m={stack:[],error:void 0,hasError:!1};try{l(Uu()),r.isPannable()||p("insert_geodetic_points");const t=r.getPannableExtent(),g=r.getGCS(),u=Hu();g.querySpheroidData(u);const c=g.getUnit().getUnitToBaseFactor(),_=u.majorSemiAxis,d=u.e2;let f=0;const x=new at;t.queryIntervalX(x);let y=null;const P=$e(4,Number.NaN);2===r.getCoordinateSystemType()?(y=r.getPECoordSys(),a?(P[0]=Tl(h,x),P[1]=t.getCenterY(),wc.projToGeog(y,1,P),f=P[0]*c):(P[0]=t.getCenterX(),P[1]=h,wc.projToGeog(y,1,P),f=P[1]*c)):f=h*c,a||0===f||2===o||p("insert_geodetic_points: 1");const E=e(m,new Cc,!1),S=new et,C=new et,I=new et,b=new et,w=new et,v=new et;for(let e=s.getFirstPath(n);e!==q;e=s.getNextPath(e)){const t=s.getFirstVertex(e);s.queryXY(t,I);let n=!1;const m=s.getNextVertex(t);for(let e=m;e!==q;e=s.getNextVertex(e)){if(e===m){if(n)break;n=!0}if(s.queryXY(e,b),a&&(i<h-I.x&&b.x-h>i||i<h-b.x&&I.x-h>i)||!a&&(0!==h||i<-I.y&&b.y>i||i<-b.y&&I.y>i))do{if(Math.abs(I.x-b.x)>=.5*x.width())break;2===r.getCoordinateSystemType()?(P[0]=Tl(I.x,x),P[1]=I.y,P[2]=Tl(b.x,x),P[3]=b.y,ag(y,2,P,0),w.x=P[0]*c,w.y=P[1]*c,v.y=P[3]*c):(w.x=I.x*c,w.y=I.y*c,v.y=b.y*c),v.x=(b.x-I.x)*Math.PI*2/x.width()+w.x;let t=0;const n=gt(et,2);if(a){if(C.x=f,C.y=Cl(_,d,w,v,f,o),Number.isNaN(C.y))break;n[0]=C,t=1}else if(2===o){const e=[0,0];if(t=Ds(_,d,w,v,f,e),!t)break;n[0].x=e[0],n[0].y=f,2===t&&(n[1].x=e[1],n[1].y=f)}else{if(C.x=Hg(_,d,w,v,o),Number.isNaN(C.x))break;C.y=0,n[0]=C,t=1}let i=-1;for(let m=0;m<t;m++){Dc.geodeticDistance(_,d,w.x,w.y,v.x,v.y,E,null,null,o);const t=E.val;Dc.geodeticDistance(_,d,w.x,w.y,n[m].x,n[m].y,E,null,null,o);const l=E.val;2===r.getCoordinateSystemType()?(P[0]=n[m].x/c,P[1]=n[m].y/c,wc.geogToProj(y,1,P),a?(S.y=P[1],S.x=h):(S.x=kg(P[0],I.x,b.x,x),S.y=h)):a?(S.x=h,S.y=n[m].y/c):(S.x=kg(n[m].x/c,I.x,b.x,x),S.y=h);const g=t>0?Pt(l/t,0,1):.5;if(0===g||1===g)continue;if(i>g)continue;const u=s.getPrevVertex(e);s.splitSegment(u,[g],1);const p=s.getNextVertex(u);s.setXYCoords(p,S.x,S.y),i=g}}while(0);I.setCoordsPoint2D(b)}}}catch(g){m.error=g,m.hasError=!0}finally{t(m)}}function Al(e,t){l(t.isPannable());const n=t.getPannableExtent();if(e.getGeometryType()===i.enumPoint){const t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}const r=s.constructEmpty();e.queryEnvelope(r);const o=s.constructEmpty();o.setCoords({env2D:n}),o.xmin=r.xmin,o.xmax=r.xmax,o.inflateCoords(.01*o.height(),0);const a=ue(t,r,!1);let h;return h=o.containsEnvelope(r)?e:Zt(e,o,a,0,null),h}function Ml(e,t,s,n){return it((.5*(s+t)-e)/n)*n}function Ul(e,t,s,n,r){if(e>=s&&t<=n)return 0;return Ml(.5*(t+e),s,n,r)}function ql(e,t,n,r,o,a,h,m){const l=e.getGeometryType(),g=at.constructEmpty();g.setCoords(t,t+n);const u=[0];if(l===i.enumPoint){const t=e;if(u[0]=t.getX(),Dl(u,g,h)){const t=o?e:e.clone();return t.setX(u[0]),t}return e}const c=s.constructEmpty();if(e.queryEnvelope(c),c.isEmpty())return e;if(l===i.enumMultiPoint){const t=o?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let i=!1;for(let e=0;e<r;e+=2)u[0]=n.read(e),Dl(u,g,h)&&(n.write(e,u[0]),i=!0);return i&&s.notifyModifiedFlags(2001),t}const _=at.constructEmpty();if(c.queryIntervalX(_),g.contains(_))return g.vmax,_.vmax,e;const d=s.constructEmpty();if(d.setCoords({env2D:c}),0===_.width()){let t=_.vmin;t+=Math.ceil((g.vmin-t)/n)*n,t=g.snapClip(t);const s=o?e:e.clone();return s.setAttributeBasic(0,0,t),s}if(l===i.enumEnvelope){const t=o?e:e.clone();return c.intersect(d),t.setEnvelope(c),t}const p=.1*Math.max(c.height(),c.width())*1;d.inflateCoords(0,p);let f=e;const x=r.getTolerance(0),y=new jt;for(;;){const e=Math.floor((_.vmin-t)/n),s=Math.ceil((_.vmax-t)/n);if(!(s-e>3))break;{const o=Math.floor(.5*(s+e));d.xmin=c.xmin-p,d.xmax=t+n*o;const h=Zt(f,d,x,a,m);d.xmin=d.xmax,d.xmax=c.xmax+p;const g=Zt(f,d,x,a,m);y.setShiftCoords((o-s)*n,0),g.applyTransformation(y),l===i.enumPolygon?f=(new al).execute(h,g,r,m):(f=h,f.add(g,!1)),f.queryEnvelope(c),c.queryIntervalX(_)}}d.xmin=t,d.xmax=t+n;const P=s.constructEmpty();P.setCoords({env2D:d}),P.inflateCoords(x,0);const E=Math.floor((c.xmin-d.xmin)/n)*n;let S;E?(d.move(E,0),y.setShiftCoords(-E,0)):y.setIdentity(),S=l===i.enumPolyline?new w({vd:f.getDescription()}):new T({vd:f.getDescription()});const C=s.constructEmpty(),I=s.constructEmpty();for(;c.xmax>d.xmin;){const e=Zt(f,d,x,0,m);e.queryEnvelope(I);let t=!1;t=l===i.enumPolyline?!e.isEmpty()&&(I.width()>x||I.height()>x):!e.isEmpty()&&(l!==i.enumPolygon||I.width()>x),t&&(e.applyTransformation(y),e.queryEnvelope(I),S.queryEnvelope(C),C.inflateCoords(x,x),C.isIntersecting(I)&&l===i.enumPolygon?S=(new al).execute(S,e,r,m):S.add(e,!1)),d.move(n,0),y.shiftCoords(-n,0)}return S}function Bl(e,t,s,n,r=!0){const i=new at;i.setCoords(s,s+n);const o=[0];if(Array.isArray(e)){const s=e;for(let e=0;e<t;e++)i.containsRightExclusive(s[e].x)||(o[0]=s[e].x,Dl(o,i,r),s[e].x=o[0])}else{const s=e;for(let e=0;e<t;e++){const t=e<<1;i.containsRightExclusive(s[t])||(o[0]=s[t],Dl(o,i,r),s[t]=o[0])}}}function Ol(e,t,n,r=!0){if(e.isEmpty())return;const o=e.getGeometryType();if(!r||o!==i.enumPolygon)if(x(o)){let s=!1;if(h(o)&&e.hasNonLinearSegments()){const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=r.getSegmentFlagsStreamRef();l(null!==o);for(let e=0,a=r.getPathCount();e<a;e++){let a=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);if(h&&r.getPathSize(e)>0){a=1===(31&o.read(m-1))}for(let l=r.getPathStart(e);l<m;l++){if(1===(31&o.read(l))){if(a){const e=i.read(2*l),r=Gl(e,t,n);r!==e&&(s=!0,i.write(2*l,r))}a=!0}else a=!1}}}else{const r=e.getImpl(),i=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){const r=i.read(2*e),o=Gl(r,t,n);o!==r&&(s=!0,i.write(2*e,o))}}s&&e.getImpl().notifyModifiedFlags(2001)}else if(o===i.enumEnvelope){const r=e,i=s.constructEmpty();r.queryEnvelope(i),i.xmin=Gl(i.xmin,t,n),i.xmax=Gl(i.xmax,t,n),r.setEnvelope(i)}else if(o===i.enumPoint){const s=e;s.setX(Gl(s.getX(),t,n))}else a("")}function Yl(e,t,s){const n=new et;return n.x=Gl(e.x,t,s),n.y=e.y,n}function Rl(e,t){if(t.isEmpty())return 0;const n=e.getPECoordSys();if(n.getProjection().getCode()===bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const r=Hu();e.querySpheroidData(r);const i=n.getParameters();if(null===i[bc.PE_PARM_LAM0])return 0;if(null===i[bc.PE_PARM_PHI0])return 0;const o=[i[bc.PE_PARM_LAM0].getValue(),i[bc.PE_PARM_PHI0].getValue()];wc.geogToProj(n,1,o);const a=new et(o[0],o[1]),h=s.constructEmpty();t.queryEnvelope(h);const m=gt(et,4);h.queryCorners(m);let l=0;const g=e.getOneMeter();let u=Math.max(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,c=Math.min(r.majorSemiAxis,r.minorSemiAxis)*Math.PI;c-=u/180,u*=g,c*=g;for(let e=0;e<4;e++){const t=et.distance(m[e],a);if(t>u)l++;else if(t>c)return-1}if(0===l)return 1;if(4===l){const e=s.constructEmpty();return e.setCoords({center:a,width:u,height:u}),h.isIntersectingNe(e)?-1:0}return-1}return-1}function Xl(e,t,n,r){const o=e.getGeometryType();l(o===i.enumPolygon||o===i.enumPolyline||o===i.enumMultiPoint);const a=t.getCoordinateSystemType();if(2===a){let a=e;if(0===n){const n=Rl(t,e);if(0===n)return e.createInstance();if(1===n)return e;const o=t.getPCSHorizon(),h=o.getGeometryType(),m=t.getDefaultPrecisionSR();if(h===i.enumEnvelope){const n=s.constructEmpty();o.queryEnvelope(n);const i=ue(m,n,!1);a=Zt(e,n,i,5e4*t.getOneMeterPCSUnit(),r)}else(new jm).execute(o,e,m,r)||(a=(new wh).execute(a,o,m,r),a===o&&(a=a.clone()))}else if(t.isPannable()){const e=s.constructEmpty();a.queryEnvelope(e);const h=t.getPannableExtent();h.containsEnvelope(e)||(Ol(a,h,t.getTolerance(0)),2!==n&&4!==n||(a=Al(a,t)),4!==n?a=vl(a,t,0,!0,1e5*t.getOneMeterPCSUnit(),r):o===i.enumPolygon&&e.width()>2*h.width()&&(a=ql(a,-2*h.width(),2*h.width(),t,!0,0,!0,r)))}return a}if(l(1===a),o===i.enumMultiPoint)return Ol(e,t.getPannableExtent(),t.getTolerance(0)),e;{const n=s.constructEmpty();e.queryEnvelope(n);let a=e;const h=t.getPannableExtent();if(n.ymin<h.ymin||n.ymax>h.ymax){const e=Math.max(1,n.calculateToleranceFromEnvelope()),i=new s(n.xmin-e,h.ymin,n.xmax+e,h.ymax);if(a=(new Kt).execute(a,i,t,r),a.isEmpty())return a}return o===i.enumPolygon&&n.width()>2*h.width()&&(a=ql(a,-2*h.width(),2*h.width(),t,!0,0,!0,r)),a}}function Ll(e,t,s,n,r,i){const o=n.getCoordinateSystemType();if(2===o){if(0===r)s!==e&&nt(s,e,t),Pl(n,s,t);else if(s!==e&&nt(s,e,t),n.isPannable()){const e=n.getTolerance(0);El(s,t,n.getPannableExtent(),e),Nl(s,t,n,0)}}else{l(1===o);const r=n.getTolerance(0),i=n.getPannableExtent();for(let n=0;n<t;n++)s[n].assign(Yl(e[n],i,r))}}function zl(e,t){const s=t.getPointCount();if(!s)return;const n=t.getImpl(),r=n.getAttributeStreamRef(0),i=e;wc.geogToProj(i,s,r.getArray()),n.notifyModifiedFlags(2001)}function Wl(e,t,s,n){if(!s)return;const r=e.getPECoordSys();if(1===s){if(t[0].isNAN())return;const s=[t[0].x,t[0].y];if(wc.geogToProj(r,1,s),n){const{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(t[0].x-e.getCentralMeridian())+r}return void t[0].setCoords(s[0],s[1])}const i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let h=0;i&&(h=e.getCentralMeridian());const m=256,l=new Float64Array(2*m);for(let g=0;g<s;){for(let e=g;e<s&&t[e].isNAN();++e)g++;let u=Math.min(m,s-g);if(u>0){for(let e=1,s=g+1;e<u;++e,++s)if(t[s].isNAN()){u=e;break}for(let e=0;e<u;++e){const s=e<<1;l[s]=t[g+e].x,l[s+1]=t[g+e].y}if(wc.geogToProj(r,u,l),n){const{first:s,second:n}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<u;++e){l[e<<1]=s*(t[g+e].x-h)+n}}if(i)for(let e=0,s=g;e<u;e++,s++){const n=e<<1,r=l[n],i=mt(r),m=t[s].x-h;i*mt(m)<0&&Math.abs(r)>a&&(l[n]-=i*o)}bl(l,t,g,u),g+=u}}}function jl(e,t,s,n){const r=e.getSRToGCSTransform();return(new qh).transform(r,t,s,n,!1)}function Zl(e,t,n,r){const i=new G({vd:t.getDescription()});let o;i.addPoints(t,0,-1),o=(new qh).execute(i,e,r);const a=t.getPointCount();if(n.setEmpty(),e.getInputSR().isPannable()){if(a!==o.getPointCount())return!1;const r=new s;t.queryEnvelope(r);const i=new s;o.queryEnvelope(i);const h=r.width(),m=i.width();if(0!==h&&0!==m){const t=m/h,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==h||0!==m)return!1;n.add(t,!1);for(let e=0;e<a;e++){const t=o.getXY(e);n.setXY(e,t)}return!0}return!1}function Kl(e,t,s){l(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),i=r.getAttributeStreamRef(0),o=e.getPECoordSys();let a=0;const h=i.readRange(0,2*n);let m=()=>{wc.geogToProj(o,n,h)};const g=e.isPannable()&&!s,u=g?e.getPannableExtent().width():0,c=179*u/360;if(e.isPannable()&&(a=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;m=()=>{wc.geogToProj(o,n,h);for(let e=0;e<n;e++){const t=e<<1,n=i.read(t),o=s*(n-a)+r;h[t]=o}}}if(m(),g)for(let l=0;l<n;l++){const e=l<<1,t=h[e],s=mt(t),n=i.read(e)-a;s*mt(n)<0&&Math.abs(t)>c&&(h[e]+=-s*u)}i.writeRangeFromArray(0,2*n,h,!0,1),r.notifyModifiedFlags(2001)}function Ql(e,t,s){switch(t.getGeometryType()){case i.enumLine:return void Ig(e,t,s);case i.enumBezier:return void Gg(e,t,s);case i.enumEllipticArc:return void wg(e,t,s);case i.enumBezier2:return void Dg();case i.enumRationalBezier2:return void Vg();default:a("")}}function Jl(e,t,s){if(!t.hasNonLinearSegments())return void Kl(e,t,s);if(l(!s||e.isPannable()),t.isEmpty())return;const n=0,r=e.getPECoordSys(),i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let h=0;i&&(h=e.getCentralMeridian());const m=t.createInstance();m.reserveParts(t.getPointCount(),t.getPathCount());const g=t.getImpl(),u=new k;for(let l=0,c=t.getPathCount();l<c;++l)if(g.hasNonLinearSegmentsPath(l)){let t=!0,n=-1;const r=g.getPathStart(l),i=r+g.getSegmentCountPath(l);g.isClosedPath(l)&&(n=i-1);const o=new et;for(let a=r;a<i;++a){if(g.getSegmentBuffer(a,u,!1),Ql(e,u.get(),s),!t){u.get().getStartXY().equals(o)||u.get().moveTo(o)}if(a!==n)m.addSegment(u.get(),t);else{if(t){const e=new ye;u.get().queryStart(e),m.startPathPoint(e)}m.closeLastPathWithSegment(u.get())}o.assign(u.get().getEndXY()),t=!1}}else{const e=1024;let s,u=g.getPathSize(l),c=Math.min(u,e);m.insertPath(-1,t,l,!0);const _=g.getAttributeStreamRef(0),d=m.getAttributeStreamRef(0);for(let t=g.getPathStart(l),m=g.getPathEnd(l);t<m;){if(s=_.readRange(t,c),wc.geogToProj(r,c,s),i)for(let e=0;e<c;e++){const t=e<<1,r=s[t],i=mt(r),m=_.read(2*(n+e))-h;i*mt(m)<0&&Math.abs(r)>a&&(s[t]+=-i*o)}d.writeRangeFromArray(t,c,s,!0,1),t+=c,u-=c,c=Math.min(u,e)}}t.assignMove(m)}function $l(e,t,s){const n=1e3;let r=s.getPointCount();if(!r)return;const i=s.getImpl(),o=i.getAttributeStreamRef(0);let a=Math.min(r,n),h=0;const m=e.getPECoordSys();Number.isNaN(t)&&(t=0);const l=e.isPannable(),g=e.getOneDegreeGCSUnit(),u=360*g,c=179*g;let _;for(;r;){if(_=o.readRange(2*h,2*a),ag(m,a,_,t),l)for(let e=0;e<a;e++){const s=e<<1,n=_[s]-t,r=mt(n),i=o.read(2*(h+e));r*mt(i)<0&&Math.abs(n)>c&&(_[s]+=-r*u)}o.writeRangeFromArray(2*h,2*a,_,!0,1),h+=a,r-=a,a=Math.min(r,n)}i.notifyModifiedFlags(2001)}function eg(e,t,s){switch(s.getGeometryType()){case i.enumLine:return void tg(e,t,s);case i.enumBezier:return void rg(e,t,s);case i.enumEllipticArc:return void sg(e,t,s);case i.enumBezier2:return void ig();case i.enumRationalBezier2:return void og();default:a("")}}function tg(e,t,s){const n=[s.getStartXY(),s.getEndXY()];mg(e,t,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}function sg(e,t,s){if(0===s.projectionBehavior())ng(e,t,s);else{const n=s.isClosed()&&s.isMajor(),r=[s.getStartXY(),n?s.getCenter():s.getEndXY()],i=[r[0].clone(),r[1].clone()];vg(e,t,i,2);const o=new jt;o.initializeFromTwoPointsArray(r,i),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(i[0],i[a],!1)}}function ng(e,t,s){Ng(!1,e,t,s,!1)}function rg(e,t,s){const n=gt(et,4);s.queryControlPoints(n),vg(e,t,n,4),s.setControlPoints(n)}function ig(e,t,s){l(0)}function og(e,t,s){l(0)}function ag(e,t,s,n){const r=wc.projToGeogCenter(e,t,s,n);for(let i=0;i<t;++i){const e=i<<1;l(Number.isFinite(s[e]+s[e+1]))}return r}function hg(e,t,s){if(!s.hasNonLinearSegments())return void $l(e,t,s);if(s.isEmpty())return;const n=e.getPECoordSys();Number.isNaN(t)&&(t=0);const r=e.isPannable(),i=e.getOneDegreeGCSUnit(),o=360*i,a=179*i,h=s.createInstance();h.reserveParts(s.getPointCount(),s.getPathCount());const m=s.getImpl(),l=new k;for(let g=0,u=s.getPathCount();g<u;++g)if(m.hasNonLinearSegmentsPath(g)){let s=!0,n=-1;const r=m.getPathStart(g),i=r+m.getSegmentCountPath(g);m.isClosedPath(g)&&(n=i-1);const o=new et;for(let a=r;a<i;++a){if(m.getSegmentBuffer(a,l,!1),eg(e,t,l.get()),!s){l.get().getStartXY().equals(o)||l.get().moveTo(o)}if(a!==n)h.addSegment(l.get(),s);else{if(s){const e=new ye;l.get().queryStart(e),h.startPathPoint(e)}h.closeLastPathWithSegment(l.get())}o.assign(l.get().getEndXY()),s=!1}}else{const e=1e3;let i,l=m.getPathSize(g),u=Math.min(l,e);h.insertPath(-1,s,g,!0);const c=m.getAttributeStreamRef(0),_=h.getAttributeStreamRef(0);for(let s=m.getPathStart(g),h=m.getPathEnd(g);s<h;){if(i=c.readRange(2*s,2*u),ag(n,u,i,t),r)for(let e=0;e<u;e++){const n=e<<1,r=i[n]-t,h=mt(r),m=c.read(2*s);h*mt(m)<0&&Math.abs(r)>a&&(i[n]+=-h*o)}_.writeRangeFromArray(2*s,2*u,i,!0,1),s+=u,l-=u,u=Math.min(l,e)}}s.assignMove(h)}function mg(e,t,s,n){const r=e.getPECoordSys();Number.isNaN(t)&&(t=0);const i=e.isPannable(),o=e.getOneDegreeGCSUnit(),a=360*o,h=179*o,m=256,l=new Float64Array(2*m);for(let g=0;g<n;){for(let t=g;t<n&&s[t].isNAN();++t)g++;let e=Math.min(m,n-g);if(e>0){for(let t=1,n=g+1;t<e;++t,++n)if(s[n].isNAN()){e=t;break}for(let t=0;t<e;t++){const e=t<<1;l[e]=s[g+t].x,l[e+1]=s[g+t].y}if(ag(r,e,l,t),i)for(let n=0,r=g;n<e;++n,++r){const e=n<<1,i=s[r].x,o=l[e]-t,m=mt(o);m*mt(i)<0&&Math.abs(o)>h&&(l[e]-=m*a)}for(let t=0;t<e;t++){const e=t<<1;s[g+t].x=l[e],s[g+t].y=l[e+1]}g+=e}}}function lg(e,t,s,n){l(0)}function gg(e,t,s){let n=t.getPointCount();if(!n)return!1;const r=t.getImpl(),i=r.getAttributeStreamRef(0);let o=null;const a=e.getInputSR(),h=e.getOutputSR();a.getVCS(),h.getVCS();const m=a.getOneDegreeGCSUnit(),l=h.getOneDegreeGCSUnit(),g=e.isVertical();g&&t.hasAttribute(1)&&(o=r.getAttributeStreamRef(1));const u=e.getDatumTransformation(),c=!!u&&1===u.getType();if(c||null===o||(lg(o.getArray()),o=null),!u||0===u.count()){const e=a.getGcsUnitFactor()/h.getGcsUnitFactor(),t=(a.getPrimeMeridian()-h.getPrimeMeridian())*l,s=-90*m,o=90*m;let g=0;const u=i.getArray(),c=[0];for(let r=1,i=2*n;r<i;)c[0]=u[r],g|=Ht(c,s,o)?1:0,u[r]=c[0],r+=2;if(0!==t||1!==e){g=1;const s=i.getArray();for(let r=0,i=2*n;r<i;){let n=s[r];n*=e,n+=t,s[r]=n,s[r+1]*=e,r+=2}}return 0!==g&&r.notifyModifiedFlags(2001),!!g}const _=1e3;let d=Math.min(n,_);const p=$e(d,Number.NaN),f=$e(d,Number.NaN);let x=null;null!==o&&(x=new Float64Array(d));let y=0,P=Number.NaN,E=Number.NaN;const S=360*l,C=l/m;s&&(E=90*l,P=89.9*m,f.fill(0));let I=!0,b=0;for(;n;){let e=!1;const t=i.readRange(2*y,2*d);for(let s=0;s<d;s++)p[s]=t[s<<1];if(s)for(let s=0;s<d;s++){const n=1+(s<<1),r=Math.abs(t[n])-P;if(r>0){const i=t[n];t[n]=_t(P,i),f[s]=_t(r,i),e=!0}}const r=t[0];if(c){const e=u;x&&o.queryRange(y,d,x,!0,1),e.transform(!1,t,x,d),x&&o.writeRangeFromArray(y,d,x,!0,1)}else{u.transform(!1,t,d)}I&&(b=t[0]-C*r,I=!1);for(let s=0;s<d;s++){const e=s<<1,n=t[e]-p[s]*C-b;Math.abs(n)>200&&(t[e]+=n>0?-S:S)}if(e){for(let e=0;e<d;e++)if(f[e]){const s=1+(e<<1);t[s]+=C*f[e],t[s]>E?t[s]=E:t[s]<-E&&(t[s]=-E)}f.fill(0)}i.writeRangeFromArray(2*y,2*d,t,!0,1),g&&o&&o.writeRangeFromArray(y,d,x,!0,1),y+=d,n-=d,d=Math.min(n,_)}return r.notifyModifiedFlags(2001),!0}function ug(e,t,s){switch(t.getGeometryType()){case i.enumLine:return xg(e,t,s);case i.enumBezier:return Eg(e,t,s);case i.enumEllipticArc:return yg(e,t,s);case i.enumBezier2:return Sg();case i.enumRationalBezier2:return Cg();default:a("")}}function cg(e,t,s){if(!t.hasNonLinearSegments())return gg(e,t,s);if(t.isEmpty())return!1;const n=t.createInstance();n.reserveParts(t.getPointCount(),t.getPathCount());const r=t.getImpl(),i=new k;for(let o=0,a=t.getPathCount();o<a;++o){let t=!0,a=-1;const h=r.getPathStart(o),m=h+r.getSegmentCountPath(o);r.isClosedPath(o)&&(a=m-1);const l=new et;for(let o=h;o<m;++o){if(r.getSegmentBuffer(o,i,!1),ug(e,i.get(),s),!t){i.get().getStartXY().equals(l)||i.get().moveTo(l)}if(o!==a)n.addSegment(i.get(),t);else{if(t){const e=new ye;i.get().queryStart(e),n.startPathPoint(e)}n.closeLastPathWithSegment(i.get())}l.assign(i.get().getEndXY()),t=!1}}return t.assignMove(n),!0}function _g(e,t,s,n,r,i){if(e.isIdentityGeogToGeog()){const s=90*e.getInputSR().getOneDegreeGCSUnit();let r=0;const i=[0];for(let e=0;e<n;e++)i[0]=t[e].y,r|=Ht(i,-s,s)?1:0,t[e].y=i[0];return r}const o=e.getInputSR(),a=e.getOutputSR(),h=o.getVCS(),m=a.getVCS(),l=o.getOneDegreeGCSUnit(),g=90*l,u=a.getOneDegreeGCSUnit(),c=e.isVertical(),_=e.getDatumTransformation(),d=!!_&&1===_.getType();if(c||(s=null),!_||0===_.count()){let e=0;const r=[0];for(let s=0;s<n;s++)r[0]=t[s].y,e|=Ht(r,-g,g)?1:0,t[s].y=r[0];return e|=qm(o.getGCS(),h,a.getGCS(),m,t,s,n)?1:0,e}d||null===s||lg();const p=1024;let f=Math.min(n,p);const x=$e(f,Number.NaN),y=$e(f,Number.NaN);let P=0,E=Number.NaN,S=Number.NaN;const C=360*u,I=u/l;r&&(S=90*u,E=89.9*l);let b=!0,w=0,v=n;for(;v;){let e=!1;for(let s=0;s<f;s++)x[s]=t[s+P].x;if(r)for(let s=0;s<f;s++){const n=Math.abs(t[s+P].y)-E;if(n>0){const r=t[s+P].y;t[s+P].y=_t(E,r),y[s]=_t(n,r),e=!0}}const n=t[0].x;if(d){_.transform(!1,t,s,f)}else{_.transform(!1,t,f)}b&&(w=t[0].x-I*n,b=!1);for(let s=0;s<f;s++){const e=t[P+s].x-x[s]*I-w;Math.abs(e)>200&&(e>0?t[P+s].x-=C:t[P+s].x+=C)}if(e){for(let e=0;e<f;e++)y[e]&&(t[P+e].y+=I*y[e],t[P+e].y>S?t[P+e].y=S:t[P+e].y<-S&&(t[P+e].y=-S));y.fill(0,0,f)}P+=f,v-=f,f=Math.min(v,p)}return 1}function dg(e,t,s,n,r){return l(0),0}function pg(e,t,s,n,r){l(null===n),l(t<2147483647);const i=Array.isArray(s);let o;o=i?Bt(s):s;const a=vc.geogToGeog(e,t,o,null,r);return i&&Ot(o,s),a}function fg(e,t,s,n,r,i){let o=0,a=!0,h=0;for(let m=0;m<n;++m)t[m].isNAN()?a||(o|=_g(e,t.slice(h,m-h),s?s.slice(h,m-h):null,m-h,r),h=m,a=!0):a&&(h=m,a=!1);return a||(o|=_g(e,0===h?t:t.slice(h),s?0===h?s:s.slice(h):null,n-h,r)),0!==o}function xg(e,t,s){const n=[t.getStartXY(),t.getEndXY()],r=[0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[1]=t.getAttributeAsDbl(1,1,0));const o=fg(e,n,i,2,s);return t.setStartXY(n[0]),t.setEndXY(n[1]),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[1])),t.normalizeAfterEndpointChange(),o}function yg(e,t,s){if(0===t.projectionBehavior())return Pg(e,t,s);const n=t.getStartXY().equals(t.getEndXY()),r=gt(et,3),i=gt(et,3),o=[0,0,0];let a=null;r[0].assign(t.getStartXY()),r[1].assign(n?t.getCenter():t.getEndXY());let h=!1;t.hasAttribute(1)&&(a=o,a[0]=t.getAttributeAsDbl(0,1,0),a[1]=t.getAttributeAsDbl(1,1,0),a[2]=ct(a[0],a[1],.5),n&&(a[1]=a[2])),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]);const m=new jt;if(n||t.isDegenerateToLine())h=fg(e,i,a,2,s),m.initializeFromTwoPoints(r[0],r[1],i[0],i[1]);else{const n=new et;t.queryCoord2D(.5,n),r[2].setCoordsPoint2D(n),i[2].setCoordsPoint2D(n),h=fg(e,i,a,3,s),m.setFromTwoTriangles(r,i)}return m.isIdentity()||(t.applyTransformation(m),t.setStartXY(i[0]),t.setEndXY(n?i[0]:i[1]),t.normalizeAfterEndpointChange()),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,n?a[0]:a[1])),h}function Pg(e,t,s){const n=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()];let r=4;t.isDegenerateToLine()&&(r=2);const i=[0,0,0,0];let o=null;if(t.hasAttribute(1)){o=i,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);const e=ct(o[0],o[1],.5);o[2]=e,o[3]=e}const a=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),h=fg(e,n,o,r,s);return a?t.constructCircleCenterAndPoint(n[3],n[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(n[0],n[1]):t.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),h}function Eg(e,t,s){const n=gt(et,4);t.queryControlPoints(n);const r=[0,0,0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[3]=t.getAttributeAsDbl(1,1,0),i[1]=ct(i[0],i[3],.5),i[2]=i[1]);const o=fg(e,n,i||null,n.length,s);return t.setControlPoints(n),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[3])),t.normalizeAfterEndpointChange(),o}function Sg(e,t,s){return l(0),!1}function Cg(e,t,s){return l(0),!1}function Ig(e,t,s){const n=[t.getStartXY(),t.getEndXY()];Wl(e,n,2,s),t.setStartXY(n[0]),t.setEndXY(n[1]),t.normalizeAfterEndpointChange()}function bg(e,t,s,n){Wl(e,t,s,n)}function wg(e,t,s){if(0===t.projectionBehavior())Tg(e,t,s);else{const n=t.isClosed()&&t.isMajor(),r=[t.getStartXY(),n?t.getCenter():t.getEndXY()],i=[r[0].clone(),r[1].clone()];bg(e,i,2,s);const o=new jt;o.initializeFromTwoPointsArray(r,i),t.applyTransformation(o);const a=n?0:1;t.setCoordsForIntersector(i[0],i[a],!1)}}function vg(e,t,n,r){mg(e,t,n,r);const i=new s;i.setFromPoints(n,r);const o=e.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(i.width()>h){for(let e=0;e<r;e++)for(;n[e].x<t;)n[e].x+=a;if(i.setFromPoints(n,r),i.xmax>h+t)for(let e=0;e<r;e++)n[e].x-=a}}function Ng(e,t,s,n,r){const i=gt(et,3);let o=0,a=!1,h=!1;const m=n.isDegenerateToLine();m?(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(a=!0,h=!n.isClockwise(),i[0].assign(n.getStartXY()),i[1].assign(n.getCenter()),i[2].setCoords(0,0),o=2):(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].assign(n.getInteriorPoint()),o=3),e?bg(t,i,o,r):vg(t,s,i,o),m?n.constructLineCircularArc(i[0],i[1]):a?n.constructCircleCenterAndPoint(i[1],i[0],h):n.constructCircularArcThreePoint(i[0],i[1],i[2])}function Tg(e,t,s){Ng(!0,e,0,t,s)}function Gg(e,t,s){const n=gt(et,4);t.queryControlPoints(n),bg(e,n,4,s),t.setControlPoints(n)}function Dg(e,t,s){l(0)}function Vg(e,t,s){l(0)}function Fg(e,t,s){const n=me(e),r=me(t),i=re(n,r),o=re(n,me(s));return 0===o||(i>0&&o>0&&o<=i||i<0&&o<0&&o>=i)}function Hg(s,n,r,i,o){const a={stack:[],error:void 0,hasError:!1};try{const t=r.clone(),h=i.clone();if(2===o){const e=[0,0];return Ds(s,n,t,h,0,e),e[0]}if(t.y>h.y){const e=new et;e.assign(t),t.assign(h),h.assign(e)}const m=e(a,new Cc,!1),g=e(a,new Cc,!1),u=e(a,new Cc,!1),c=new at;if(c.setCoords(t.y,h.y),!c.containsCoordinate(0)||Math.abs(t.x-h.x)>=Math.PI)return Number.NaN;if(t.x===h.x)return t.x;Dc.geodeticDistance(s,n,t.x,t.y,h.x,h.y,g,m,null,o);const _=g.val;let d=0,p=1;const f=t.clone();for(;_*(p-d)>1e-12*s;){const e=.5*(d+p);if(Dc.geodeticCoordinate(s,n,t.x,t.y,_*e,m.val,g,u,o),f.x=g.val,f.y=u.val,c.setCoords(t.y,f.y),0===f.y)return f.x;if(c.containsCoordinate(0))p=e;else{if(c.setCoords(h.y,f.y),!c.containsCoordinate(0))return l(!1),Number.NaN;d=e}}return f.x}catch(h){a.error=h,a.hasError=!0}finally{t(a)}}function kg(e,t,s,n){const r=new at;r.setCoords(t,s);const i=n.width();let o=Math.floor((e-t)/i)*i+e;const a=r.getCenter();for(;Math.abs(o-a)>Math.abs(o+i-a);)o+=i;return o}class Ag extends $t{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}function Mg(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID))}function Ug(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?1===e.m_csType?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID))}class qg{constructor(e,t=!0){this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_bGCSHorisonIsInclusive=!1,this.m_oneMeterPCS=0,this.m_oneDegreeGCS=0,this.m_gcsUnitFactor=0,this.m_northPole=et.getNAN(),this.m_southPole=et.getNAN(),this.m_polesUpdated=0,this.m_domain=s.constructEmpty(),this.m_primeMeridian=Number.NaN,this.m_geogToProjFactor=1,this.m_geogToProjOffset=0,this.m_geogToProjFactorsUpdated=0,this.m_oneMillimeter=0,this.m_centralMeridian=0,this.m_pPCSInfoNoDomain=null,this.m_oldWKID=-1973,this.m_vcsWKID=-1,this.m_bIsPannable=!1,this.m_bCached=!1,this.m_pannableExtent=s.constructEmpty(),this.m_pannableExtentGCS=s.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=e,this.m_WKID=Ic.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_l(e,0,!0),this.m_hashCode=It(this.m_canonicalWkt)):this.m_hashCode=bt(this.m_WKID);const r=this.m_peCoordSys.getType();this.m_csType=r===bc.PE_TYPE_PROJCS?2:1,l(r===bc.PE_TYPE_PROJCS||r===bc.PE_TYPE_GEOGCS),r===bc.PE_TYPE_PROJCS&&(e.loadConstants()||n("PeProjcs.loadConstants failed"));const i=r===bc.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();r!==bc.PE_TYPE_GEOGCS&&Ic.getCode(i),this.m_unit=ms(e),this.m_primeMeridian=i.getPrimem().getLongitude();{const 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===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=Nc.generate(e,Nc.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||a("cannot create pcs info"),this.m_bIsPannable=this.m_pPCSInfoNoDomain.isPannableRectangle(),this.m_centralMeridian=this.m_pPCSInfoNoDomain.getCentralMeridian()}else{this.m_bIsPannable=!0,this.m_polesUpdated=1,this.m_oneMeterPCS=0;const e=1/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()!==bc.PE_TYPE_PROJCS)return;let e=!0;const t=this.m_peCoordSys,n=t.getGeogcs(),r=t.horizonGcsGenerate();if(!r)return;l(r.length>0);const i=r[0].getNump(),o=r[0].getKind();let a,h;e=r[0].getInclusive()>0;const m=this.getOneDegreeGCSUnit(),g=90*m,u=360*m,c=370*m,_=180*m*bc.PE_HORIZON_DELTA/Math.PI,d=s.constructEmpty();let p=null;if(i>1)for(let s=1;s<i;s++)if(r[s].getKind()===bc.PE_HORIZON_LINE){p||(p=new w);const e=r[s].getCoord();p.startPathCoords(e[0][0],e[0][1]),p.lineToCoords(e[1][0],e[1][1])}if(o===bc.PE_HORIZON_RECT){const t=r[0].getCoord();if(d.setFromPoints([new et(t[0][0],t[0][1]),new et(t[1][0],t[1][1])],2),Math.abs(d.ymax-g)<1e-7*_&&(d.ymax=g),Math.abs(d.ymin+g)<1e-7*_&&(d.ymin=-g),d.width()>c){const e=-400*m,t=e+5*u;d.setCoords({xmin:e,ymin:d.ymin,xmax:t,ymax:d.ymax})}const s=new xe({env2D:d});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const o=Ru(n,null,null,1),c=[],_=new at;for(let e=0;e<i;e++){if(r[e].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[e].getSize();const t=r[e].getCoord(),n=s.constructEmpty();n.setFromPoints(wt(t),a),c.push(new at(n.xmin,n.xmax)),n.width(),_.merge(c.at(-1))}let d=!1;const f=new at;_.width()>u&&c.length>1?(f.vmin=this.getCentralMeridian()-u,f.vmax=f.vmin+2*u,d=!0,t=!0):(f.vmin=_.vmin,f.vmax=f.vmin+u);const x=e=>{let t=0;for(;c[e].vmin+t<f.vmin;)t+=u;for(;c[e].vmax+t-u>f.vmin;)t-=u;return t};let y=new T;if(t){const e=new Ag,t=(new al).executeMany(e,o,null);for(let s=0;s<i;s++){if(r[s].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[s].getSize();const n=r[s].getCoord();h=r[s].getInclusive()>0;const i=new T;if(i.addPathPoint2D(wt(n),a-1,!0),d){const t=x(s),n=c[s].clone();n.move(t);let r=t;const o=new jt;do{o.setShiftCoords(r,0);const t=i.clone();t.applyTransformation(o),e.tick(t),e.tock(),r+=u,n.move(u)}while(n.vmin<f.vmax)}else e.tick(i),t.tock()}y=t.next()}else{y=new T;for(let t=0;t<i;t++){if(r[t].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[t].getSize();const s=r[t].getCoord();if(h=r[t].getInclusive()>0,l(h===e),d){const e=new T;e.addPathPoint2D(wt(s),a-1,!0);const n=x(t),r=c[t].clone();r.move(n);let i=n;const o=new jt;do{if(0!==i){o.setShiftCoords(i,0);const t=new T({copy:e});t.applyTransformation(o),y.addPath(t,0,!0)}else y.addPath(e,0,!0);i+=u,r.move(u)}while(r.vmin<f.vmax)}else y.addPathPoint2D(wt(s),a-1,!0)}}d&&(y=(new Kt).execute(y,new s(f.vmin,-g-m,f.vmax,g+m),o,null)),e?(new wh).accelerateGeometry(y,o,1):(new Km).accelerateGeometry(y,o,1),(new ul).accelerateGeometry(y,o,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=y,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=p)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==bc.PE_TYPE_PROJCS)return;const e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();const n=e[0].getKind();e[0].getInclusive();const r=s.constructEmpty(),i=e[0].getNump();let o=!1;if(n===bc.PE_HORIZON_RECT){const s=e[0].getCoord();r.setFromPoints(wt(s),2),t=new xe({env2D:r})}else{let s=-1;for(let t=0;t<i;t++)e[t].getKind()===bc.PE_HORIZON_POLY&&(s=t);l(s>=0);const n=e[s].getSize()-1,r=e[s].getCoord(),a=new T;t=a,a.addPathPoint2D(wt(r),n,!0),o=!0}if(this.getPCSInfo().isDensificationNeeded()){l(n!==bc.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new Jt).execute(t,e,0,0,null)}if(o){{const e=new xe;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}(new wh).accelerateGeometry(t,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=t)}updatePannableExtent(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),n=e.getGeogcs();n||a("");const r=[t+1/n.getUnit().getUnitFactor()*Math.PI,0];wc.geogToProj(e,1,r);const i=r[0],o=e.getParameters()[bc.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=s.constructEmpty();h.queryEnvelope(m);const l=Math.abs(i-o),g=l+o,u=-1*l+o,c=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:u,ymin:_,xmax:g,ymax:c})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else a("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,n=e.getGeogcs();n||a("");const r=1/n.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),o=s.constructEmpty();i.queryEnvelope(o),this.m_pannableExtentGCS.setCoords({xmin:t-r,ymin:o.ymin,xmax:t+r,ymax:o.ymax})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else a("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=s.construct(-e,-e,e,e)}else{l(2===this.m_csType);const e=Nc.generate(this.m_peCoordSys,Nc.PE_PCSINFO_OPTION_DOMAIN);e||a("generate pcs info failed");const t=new s(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];wc.geogToProj(this.m_peCoordSys,2,t);const s=this.getPCSInfo().getNorthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(t[0][0],t[0][1]),n&&this.m_southPole.setCoords(t[1][0],t[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=t,s[1]=0,s[2]=t+e,s[3]=0;const n=wc.geogToProj(this.m_peCoordSys,2,s);l(2===n);const r=(s[2]-s[0])/e,i=s[0];0===this.m_geogToProjFactorsUpdated&&(this.m_geogToProjFactor=r,this.m_geogToProjOffset=i,this.m_geogToProjFactorsUpdated=1)}else this.m_geogToProjFactorsUpdated=1}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return this.m_gcsUnitFactor}getUnitsPerMillimeter(){return this.m_oneMillimeter}getGCSSplitLines(){return this.m_bIsPannable?null:(this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSSplitLines)}getGCSHorizon(){return this.m_bIsPannable?this.getGCSHorizonPannable():(null!==this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(null!==this.m_PCSHorizon||this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(e){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),ot(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){const t=[0],s=[0];qc(this.m_peCoordSys.getType(),this.m_WKID,t,s)||a("query_code_change"),e=t[0]}this.m_oldWKID=e}return e}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return null!==this.m_areaOfUse?this.m_areaOfUse:this.updateAreaOfUse()}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}class Bg{constructor(e,t=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new bu,this.m_cached=!1}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function Og(e,t,n){return Yg(e,t,s.constructEmpty())}function Yg(e,t,s,n){return Xg(!0,e,t,s)}function Rg(e,t,s,n){return Lg(!0,e,t,s,n)}function Xg(e,t,s,n,r){Uu()||f("cannot create projection transformation");return t.hasVCS()&&s.hasVCS()?jg():Zg(t,s,n)}function Lg(e,t,s,n,r,i){return Uu()||f("cannot create projection transformation"),new eu(e?2:1,t,s,n,r,i)}function zg(e,t,s,r,i,o=!1){t&&s||n(""),Uu()||f("cannot obtain geotransformation list");if(1===e&&t.hasVCS()&&s.hasVCS())return d("hv xform not impl"),[];{const e=Qc(t,s,r,i,o),n=[];for(const t of e)n.push(t);return n}}function Wg(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return rt(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&rt(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function jg(e,t,s,n){return l(0),{}}function Zg(e,t,r,i){e&&t||n("!inputSR || !outputSR");const o=e.getLatestID(),a=t.getLatestID();if(3857===o&&4326===a){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return pu()}else if(4326===o&&3857===a&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return fu();const h=s.constructEmpty();h.setCoords({env2D:r});const m=e.getCoordinateSystemType(),l=t.getCoordinateSystemType();if(0===m||0===l)return Kg(e,t);const g=e.getGCS().getLatestID(),u=t.getGCS().getLatestID();if(g>0&&g===u)return Kg(e,t);const c=new mu(e,t,r);{const e=gu(c);if(e)return e}const _=zg(0,e,t,h,1,!0);return uu(c,Kg(e,t,_.length?_[0]:void 0))}function Kg(e,t,s,n,r){return new eu(1,e,t,s,n,r)}function Qg(){return{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return 0!==(this.flagsMask&e)}}}function Jg(){return{m_extendedParams:Wg(),m_extendedParamsInternal:Qg()}}function $g(){return Jg()}class eu{constructor(e,t,s,r,i,o){let a,h;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,t&&s||n("!inputSR || !outputSR"),r&&0===r.getType()&&(r.m_bReadOnly=!0),this.m_bNormalize=!1,1!==e&&(a=t.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=t,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,l(!this.m_params),i&&(this.m_params=Jg(),this.m_params.m_extendedParams=i),o&&(this.m_params||(this.m_params=Jg()),this.m_params.m_extendedParamsInternal=o);let m=!1;const g=null!=r,u=t.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==u&&i){const e=i.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&s.isPannable()){const t=s.getPannableExtent(),n=t.getCenterX();if(n!==e){const s=Math.ceil(t.width());e+s!==n+s&&(m=!0)}}}const _=i&&i.normalizeResultGeometry;if(t.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!g&&t.equalForProjection(s,this.m_bVertical);this.m_bIdentity=d&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(_&&this.m_outputSR.isPannable()&&(this.m_bNormalize=_),this.m_datumTran=r||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const e=new eu(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:$g().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:$g().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:$g().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new Ah(this)}}const tu=new Map,su=new Map,nu=new Map;function ru(e){let t=e.getCode();if(t>0){const e=Iu(t);return e||Cu(Ic.coordsys(t))}const s=e.getName();if(su.has(s)){const t=su.get(s);if(t&&t.deref()){const s=t.deref();if(s.m_peCoordSys.isEqual(e))return s}}return t=Ic.getCode(e),Cu(t>0?Ic.coordsys(t):e)}function iu(e){e<=0&&I(e);{const t=Iu(e);if(t)return t}const t=Hc(Ic.coordsys(e));t.get()||I(e);const s=Cu(t.release());return s.getLatestID()!==e&&tu.set(e,new WeakRef(s)),s}function ou(e){const t=new Bg({},!0);return t.m_WKID=e,t}function au(e){const t=Hc(Ic.fromString(bc.PE_TYPE_COORDSYS,e));return t.get()||E(e),ru(t.release())}function hu(e){su.delete(e.m_peCoordSys.getName()),nu.delete(_l(e.m_peCoordSys,0,!1))}class mu{constructor(e,t,s){this.m_hashCode=-1,e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=Ke(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=Ke(this.m_hashCode,Yt(this.m_env.xmin)),this.m_hashCode=Ke(this.m_hashCode,Yt(this.m_env.xmax)),this.m_hashCode=Ke(this.m_hashCode,Yt(this.m_env.ymin)),this.m_hashCode=Ke(this.m_hashCode,Yt(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return!(this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR)&&(this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR))}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const lu=new Map;function gu(e){if(lu.has(e.getHashCode()))return lu.get(e.getHashCode())}function uu(e,t){return lu.set(e.getHashCode(),t),t}let cu,_u,du;function pu(){return cu||(cu=Rg(hc(),lc())),cu}function fu(){return _u||(_u=pu().getInverse()),_u}function xu(){return du||(du=Ic.unit(9001)),du}function yu(e){return null!==Hc(Ic.coordsys(e)).get()}const Pu=new Map;function Eu(e){if(Pu.has(e))return Pu.get(e);{const t=yu(e);return Pu.set(e,t),t}}function Su(e){return!1}function Cu(e){const t=Hc(e),s=e.getCode();if(s>0){const e=Iu(s);if(e)return e}const n=e.getName();let r=su.get(n);if(r){const t=r.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}const i=new qg(t.release());if(s>0)return i.setCached(),tu.set(s,new WeakRef(i)),su.set(n,new WeakRef(i)),i;const o=_l(e,0,!1);if(r=nu.get(o),r){const e=r.deref();if(e)return e}return i.setCached(),nu.set(o,new WeakRef(i)),i}function Iu(e){const t=tu.get(e);if(t)return t.deref()}class bu extends ns{constructor(e){return void 0===e?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof e?(super(),this.m_factor=e,void(this.m_wkid=0)):(super(e),void(e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=xu())))}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const wu=["0","1","2","3","4","5","6","7","8","9","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"];function vu(e,t,s){const n=$e(t,"R");let r=0,i=0;for(let o=0;o<t;o++){let s=e[r]>>i&31;if(i+=5,i>31){const t=37-i;s&=(1<<t)-1,i-=32,r++,s|=(e[r]&(1<<i)-1)<<t}const a=wu[s];n[t-1-o]=a}return s>t?n.push(..."0".repeat(s-t)):s<t&&(n.length=s),n.join("")}function Nu(e,t,s,n,r){l(n>>5<r.length);let i=t,o=s;for(let a=n;a>=0;a-=2){const t=31&a,s=.5*(o+i);e>=s?(r[a>>5]|=1<<t,i=s):o=s}}let Tu=new Set;const Gu=2147483645n,Du=9007199254740990n,Vu="operation is not supported for unknown coordinate systems";var Fu;function Hu(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function ku(e,t,s){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-s),e.e2=s*(2-s),e.flattening=s}function Au(e){if(Ic)return;Uc(e);const t=Tu;Tu=null,t.forEach(e=>{const t=e.deref();t&&t.attachToPe()})}function Mu(e){Mc(e)}function Uu(){return!!Ic}function qu(){return!!kc}function Bu(){return!!Ic||!!kc}function Ou(e,t,s){return l(Bu()),dc(e,void 0===t?0:t,null,!1)}function Yu(e,t){l(Bu());const s=new oc;let n;return Uu()?(n=au(e),s.setHorzProj_(n),s.m_vertcs=null,s.m_userWKID=n.getLatestID()):(n=Ac(e),s.m_unit=n.isPCS?new bu(n.metersOrRadiansPerUnit):new os(n.metersOrRadiansPerUnit)),uc(s.m_precisionDescriptor,n,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=e,s.calculateHashCode(),s.initDbgName(),s}function Ru(e,t,s,n,r=!0){let i=null;return t&&(i=Fm(t,r)),Xu(e,i,s,n,r)}function Xu(e,t,s,r,i){e||n("!PE_coord_sys");const o=new oc;let a;return a=i?ru(e):new qg(e,!1),uc(o.m_precisionDescriptor,a,t,r),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=t,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Lu(e,t,s=!1){3===e.getCoordinateSystemType()&&n("image spatial reference cannot be altered");const r=new oc,i=e;return r.m_peCoordSysVal=i.m_peCoordSysVal,r.m_vertcs=i.m_vertcs,r.m_unit=i.m_unit,r.m_precisionDescriptor.assign(t),r.m_localZToXYFactor=i.m_localZToXYFactor,(Number.isNaN(r.m_precisionDescriptor.m_falseX)||Number.isNaN(r.m_precisionDescriptor.m_falseY))&&(r.m_precisionDescriptor.m_falseX=i.m_precisionDescriptor.m_falseX,r.m_precisionDescriptor.m_falseY=i.m_precisionDescriptor.m_falseY),r.m_precisionDescriptor.snapPrecision(),r.m_precisionDescriptor.fixTolerance(),r.m_userWKID=i.m_userWKID,r.m_precisionDescriptor.equals(i.m_precisionDescriptor)?r.m_bDefaultDescriptor=i.m_bDefaultDescriptor:r.m_bDefaultDescriptor=!1,s&&(r.m_bDefaultDescriptor=!0),r.calculateHashCode(),r.initDbgName(),r}function zu(e,t,s){return{}}function Wu(e,t,s){void 0===t&&(t=1),(t<=0||!Number.isFinite(t))&&n(""),e||1===t||n("null Unit has to have z_to_xy_factor equal to 1");const r=new oc;r.m_unit=e;const i=e||new bu(9001);return _c(r.m_precisionDescriptor,i,null,1),r.m_bDefaultDescriptor=!0,Number.isNaN(r.m_precisionDescriptor.m_falseX)&&n("NAN false X/Y are not allowed here"),r.m_localZToXYFactor=t,r.calculateHashCode(),r.initDbgName(),r}function ju(e,t){return e.snapGeometry(t)}function Zu(e){const t=e.getCoordinateSystemType();return 1===t?e:(3===t&&l(0),e.getGCS())}function Ku(e){return l(Bu()),qu()?Bc(e):Eu(e)}function Qu(s){if(Uu()){const r={stack:[],error:void 0,hasError:!1};try{return null!==e(r,Ic.fromString(bc.PE_TYPE_COORDSYS,s,!0),!1)}catch(n){r.error=n,r.hasError=!0}finally{t(r)}}try{return Ac(s),!0}catch(r){}return!1}let Ju;function $u(){return Ju||(Ju=(()=>{const e=Math.trunc(Math.random()*Tt()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})()),Ju}!function(e){e[e.utmDefault=0]="utmDefault",e[e.utmNorthSouth=1]="utmNorthSouth"}(Fu||(Fu={}));let ec=0;function tc(e=""){let t=`${$u()}${ec++}`;return""!==e&&(t+=`|${e}`),t}function sc(e){return e.startsWith($u())}let nc,rc,ic,oc=class e{destroy(){hu(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():a("SpatialReference.destroy")}constructor(){this.m_vertcs=null,this.m_peCoordSysVal=null,this.m_userWKID=0,this.m_userWKT=null,this.m_geogSpatialReference=null,this.m_srToGcs=null,this.m_gcsToSr=null,this.m_defaultPrecisionSR=null,this.m_localZToXYFactor=-1,this.m_precisionDescriptor=new ac,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,gc(this.m_precisionDescriptor),Tu&&Tu.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ou(this.m_userWKID):Yu(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(1===this.getCoordinateSystemType())return Rg(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;const s=this.getGCS(),n=this;t=e?Rg(n,s,null):Rg(s,n,null);const r=t,i=e?this.m_srToGcs:this.m_gcsToSr;return i||(e?this.m_srToGcs=r:this.m_gcsToSr=r,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal();const t=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();e=Ke(e,t),this.m_hashCode=Ke(e,s)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){if(this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType())return 0;return this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const e=this.getPECoordSys();if(e){switch(e.getType()){case bc.PE_TYPE_GEOGCS:return 1;case bc.PE_TYPE_PROJCS:return 2;default:return 0}}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof bu)return 2;if(this.m_unit instanceof os)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 d("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return d("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){const e=this.getPECoordSys();return e?pl(e):this.m_userWKT??""}getTextExtended(e){const t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?dl(null,t,this.getPEVerticalCoordSys()):pl(t,e):this.m_userWKT??""}getText2(e=-1){const t=this.getPECoordSys();return t?fl(t,e):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof bu?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof os?.001/(Ac(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):(p("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?xl():""}getVerticalUnit(){return d("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(){const e=this.getCoordinateSystemType();if(0===e)p(Vu);else{if(1===e)return this;3===e&&p("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===hc()||this===mc())t=lc();else{l(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||a(""),t=Ru(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(0===e.length)return 0;e.length>t.length&&n("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&p(Vu),1===s)return nt(t,e,e.length),e.length;l(this.m_peCoordSysVal);const r=this.getSRToGCSTransform();return(new qh).transform(r,e,e.length,t)}toGeohash(e,t=8){const s=e.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=Je(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=Je(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*t,r=new Uint32Array(4);Nu(s.x,-180,180,n-1,r),Nu(s.y,-90,90,n-2,r);return vu(r,t,t)}isPannable(){const e=this.getCoordinateSystemType();return 0!==e&&3!==e&&(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(){const e=this.getCoordinateSystemType();1!==e&&2!==e&&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(Uu()||f("cannot query precision descriptor"),l(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{const t=this.getCoordinateSystemType();0===t?_c(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===t?d("image cs"):uc(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}horizontalEqual(e){return Mg(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return null!==this.m_vertcs==(null!==e.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs))}equals(e){const t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t))return!1;if(!t.m_peCoordSysVal){if(l(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==t.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(t.m_unit))return!1;if(this.m_localZToXYFactor!==t.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;l(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){const t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,s=t.ymin}let n=t.m_precisionDescriptor.m_falseX,r=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(n)){const e=t.m_peCoordSysVal.getDomainXY();n=e.xmin,r=e.ymin}return e===n&&s===r}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;const s=this.getCoordinateSystemType(),n=e.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!t||this.getZToXYFactor()===e.getZToXYFactor())&&(!this.getUnit()||!e.getUnit()||this.getUnit().equals(e.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===e.getUnit()||(!t||this.getZToXYFactor()===e.getZToXYFactor())&&this.getUnit().equals(e.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(e);if(Ug(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(null!==this.m_vertcs==(null!==e.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return l(0),!1}equalVerticalVCS(e){return l(0),!1}convergenceAngle(e){return l(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||a("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return l(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&n(Vu)}getPrimeMeridian(){return this.throwIfLocal(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return 1e3*this.getUnitsPerMillimeter()}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const e=new ac;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=Lu(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);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();ku(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&p(""),l(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.getAreaOfUse();return null===e?new ss:new ss({geom:e.clone(),sr:Ou(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())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const t=e.getGeometryType();if(x(t))return this.snapMultiVertex_(e);if(t===i.enumPoint)return this.snapPoint_(e);if(t===i.enumEnvelope)return this.snapEnvelope_(e);if(o(t))return this.snapSegment_(e);if(t===i.enumGeometryCollection){const t=e;let s=!1;for(let e=0,n=t.getGeometryCount();e<n;++e)s=this.snapGeometry(t.getGeometry(e))||s;return s}a("what else?")}snapMultiVertex_(e){if(l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision()),h(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const t=e.getImpl(),s=t.getDescription();let n=!1;for(let r=0,i=s.getAttributeCount();r<i;r++){const e=s.getSemantics(r),i=t.getAttributeStreamRef(e);n=this.snapAttributes(e,i,0,t.getPointCount())||n}return n&&t.notifyModifiedFlags(2001),n}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision());const t=new ac;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new et;n.x=pc(s.x,t.getFalseX(),t.getGridUnitsXY()),n.y=pc(s.y,t.getFalseY(),t.getGridUnitsXY());let r=!n.equals(s);const i=e.getEndXY(),o=new et;o.x=pc(i.x,t.getFalseX(),t.getGridUnitsXY()),o.y=pc(i.y,t.getFalseY(),t.getGridUnitsXY()),r||=!o.equals(i),r&&e.changeEndPoints2D(n,o);const a=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=pc(i,s,n),a=!rt(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=pc(i,s,n),a=!rt(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let h=r?1:0;return e.hasAttribute(1)&&(h|=a(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(h|=a(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!h}snapGeometryWithCurves_(e){l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new k;let n=0;for(let r=0,i=e.getPathCount();r<i;++r){const i=e.getSegmentCountPath(r);if(0===i){if(t.addPath(e,r,!0),1===t.getPathSize(r)){const e=new ye;t.getPointByVal(t.getPointCount()-1,e),n|=this.snapGeometry(e)?1:0,t.setPointByVal(t.getPointCount()-1,e)}continue}const o=e.isClosedPath(r);for(let a=0,h=o?i-1:i;a<h;++a)e.getSegmentFromPath(r,a,s,!1),n|=this.snapGeometry(s.get())?1:0,t.addSegment(s.get(),0===a);o&&(e.getSegmentFromPath(r,i-1,s,!1),n|=this.snapGeometry(s.get())?1:0,1===i?t.addPathFromClosedSegment(s.get(),!1):t.closeLastPathWithSegment(s.get()))}return n&&t.copyTo(e),!!n}snapAttributes(t,s,n,r){let i=!1;const o=new ac;if(this.queryPrecisionDescriptor(o),0===t){const t=s;for(let s=n;s<r;s++){const n=t.read(2*s),r=e.s_SnapValue(n,o.getFalseX(),o.getGridUnitsXY()),a=t.read(2*s+1),h=e.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());i=i||r!==n||h!==a,i&&(t.write(2*s,r),t.write(2*s+1,h))}}else if(1===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseZ(),o.getGridUnitsZ());i=i||!rt(r,n),i&&t.write(s,r)}}else if(2===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseM(),o.getGridUnitsM());i=i||!rt(r,n),i&&t.write(s,r)}}return i}static s_SnapValue(e,t,s){return it((e-t)*s)/s+t}};class ac{constructor(){const e=Du,t=1e-4,s=.001,n=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(e)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let e=7777,t=7777;return t=Ke(t,this.m_falseM),t=Ke(t,this.m_unitsM),e=Ke(e,this.m_unitsXY),t=Ke(t,this.m_toleranceXY),e=Ke(e,this.m_falseZ),t=Ke(t,this.m_toleranceZ),e=Ke(e,this.m_unitsZ),t=Ke(t,this.m_toleranceM),e=Ke(e,this.m_precision),Ke(e,t)}clone(){const e=new ac;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(2===this.m_precision)return 0;switch(e){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){const e=new s;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{const t=Number(ac.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(),a("")}return e}getZGridRange(){const e=new at;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{const t=Number(ac.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(),a("")}return e}getMGridRange(){const e=new at;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{const t=Number(ac.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(),a("")}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,s){Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(s)||n("grid params are not finite"),s<1&&n("grid units cannot be smaller than 1.0"),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=s}setZParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||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||rt(this.m_falseX,e.m_falseX)&&rt(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(2===this.m_precision)return;const e=(e,t,s,n)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const r=Number(e)/s;return Math.trunc((t+r-t)*s)>e&&(s=e/(t+r-t)),Math.max(1,s)},t=Number(0===this.m_precision?Gu:Du);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const e=(e,t,s,n)=>{if(s<1)return!1;if(!Number.isFinite(t)||!Number.isFinite(s))return!1;if(!n)return!0;const r=Number(e)/s;return!(BigInt((t+r-t)*s)>e)},t=0===this.m_precision?Gu:Du;return!!e(t,this.m_falseX,this.m_unitsXY,!0)&&(!!e(t,this.m_falseY,this.m_unitsXY,!0)&&(!!e(t,this.m_falseZ,this.m_unitsZ,!1)&&!!e(t,this.m_falseM,this.m_unitsM,!1)))}fixTolerance(){2!==this.m_precision&&(this.m_toleranceXY=Math.max(2/this.m_unitsXY,this.m_toleranceXY),this.m_toleranceZ=Math.max(2/this.m_unitsZ,this.m_toleranceZ),this.m_toleranceM=Math.max(2/this.m_unitsM,this.m_toleranceM),(Number.isNaN(this.m_falseX)||Number.isNaN(this.m_falseY))&&(this.m_falseX=this.m_falseY=Number.NaN))}equalsWithoutFalseXY(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,s){}setBestMDomainFromMRange(e,t,s){}}function hc(){return(!nc||Uu()&&null===nc.getPECoordSys())&&(nc=dc(3857,0,null,!0)),nc}function mc(){return(!rc||Uu()&&null===rc.getPECoordSys())&&(rc=dc(102100,0,null,!0)),rc}function lc(){return(!ic||Uu()&&null===ic.getPECoordSys())&&(ic=dc(4326,0,null,!0)),ic}function gc(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=100*lt(),e.m_toleranceZ=100*lt(),e.m_toleranceM=100*lt(),e.m_precision=2}function uc(e,t,s,r){const i=t instanceof qg;gc(e),e.m_precision=r,e.m_falseX=Number.NaN,e.m_falseY=Number.NaN;const o=1e-4,a=.001,h=i?t.m_csType:t.isPCS?2:1;if(1===h){const s=(0===r?1/18e5:1e-9)*(i?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180);e.m_unitsXY=1/s}else if(2===h){const s=(0===r?a:o)*(i?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit);e.m_unitsXY=1/s}else n("unrecognized cs type");e.m_falseM=-1e5,e.m_unitsM=1/(0===r?a:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let m=0,l=0;0!==r&&1!==r||(m=2/e.m_unitsXY,l=2/e.m_unitsM),e.m_toleranceXY=Math.max(m,i?t.getUnitsPerMillimeter():2===h?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(a,l),cc(e,s)}function cc(e,t){const s=1e-4,n=.001;if(e.m_falseZ=-1e5,t){const r=(0===e.m_precision?n:s)*t.getOneMeter();e.m_unitsZ=1/r}else e.m_unitsZ=1/(0===e.m_precision?n:s);e.m_unitsZ=Math.max(1,e.m_unitsZ);let r=0;0!==e.m_precision&&1!==e.m_precision||(r=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*n:n,r)}function _c(e,t,s,n){gc(e),e.m_precision=n;const r=0===n?Gu:Du,i=1e-4,o=.001;let a=1,h=1,m=.001;t&&(h=t.getUnitToBaseFactor()),t&&1===t.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===n?o:i)*Number(r)*.5,m=o/h),a/=h,e.m_falseX=-a,e.m_falseY=-a,e.m_unitsXY=Number(r)/(2*a),e.m_falseM=-1e5,e.m_unitsM=1/(0===n?o:i),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let l=0,g=0;0!==e.m_precision&&1!==e.m_precision||(g=2/e.m_unitsM,l=2/e.m_unitsXY),e.m_toleranceXY=Math.max(l,m),e.m_toleranceM=Math.max(o,g),cc(e,s)}function dc(e,t,s,n){if(!n&&t<=0){if(3857===e)return hc();if(102100===e)return mc();if(4326===e)return lc()}const r=new oc;let i,o=null;return Uu()?(i=iu(e),t>0?o=null:t=0,r.setHorzProj_(i),r.m_vertcs=o):(i=Ac(e),r.m_unit=i.isPCS?new bu(i.metersOrRadiansPerUnit):new os(i.metersOrRadiansPerUnit)),uc(r.m_precisionDescriptor,i,o,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=e,r.calculateHashCode(),r.initDbgName(),r}function pc(e,t,s){return it((e-t)*s)/s+t}let fc=null;const xc=3552713678800501e-30;function yc(e,t,s){return e===t||Math.abs(e-t)<=s*(1+(Math.abs(e)+Math.abs(t))/2)}function Pc(e,t){return yc(e,t,xc)}function Ec(e,t){return 0===e||Math.abs(e)<=t}function Sc(e){return Ec(e,xc)}let Cc,Ic,bc,wc,vc,Nc,Tc,Gc,Dc,Vc,Fc;function Hc(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){const e=this._this;return this._this=null,e}}}let kc=null;function Ac(e){l(kc);const t=kc(e);return t.semiMajor=t.isPCS?Number.NaN:Rc(e),t}function Mc(e){kc=e,l(kc)}function Uc(e){const t=e;Ic=t.PeFactory,l(Ic),Fc=t.PeGCSExtent,l(Fc),Dc=t.PeLineType,l(Dc),Vc=t.PeMath,l(Vc),Cc=t.PeDouble,l(Cc),bc=t.PeDefs,l(bc),wc=t.PeCSTransformations,l(wc),vc=t.PeGTTransformations,l(vc),Nc=t.PePCSInfo,l(Nc),Tc=t.PeGTlistExtended,l(Tc),Ic.initialize(),Gc=t.PeGTlistExtendedEntry,l(Gc),bc.PE_TYPE_ANGUNIT=512,bc.PE_STR_AUTH_ALL=2,Nc.PE_POLE_LINE_STRAIGHT=2,Nc.PE_POLE_LINE_CURVED=3,bc.PE_PARM_LAM0=2,bc.PE_PARM_PHI0=6,bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,bc.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,bc.PE_PRJ_ALBERS=43007,bc.PE_PRJ_CYLINDRICAL_EQAREA=43034,bc.PE_TYPE_VERTCS=8,bc.PE_LINETYPE_GEODESIC=0,bc.PE_LINETYPE_LOXODROME=1,bc.PE_LINETYPE_GREAT_ELLIPTIC=2,bc.PE_LINETYPE_NORMAL_SECTION=3,Tc.PE_GTLIST_OPTS_USABLE=1,kc=null}function qc(e,t,s,n){return t<=0?(s[0]=0,n[0]=0,!1):(s[0]=t,n[0]=t,!0)}function Bc(e){l(qu());return!!kc(e).isPCS||Oc(e)}function Oc(e){return Ic&&p("pe has been loaded. no-pe methods should not be used at this point."),fc||Xc(),fc.has(e)}const Yc=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Rc(e){if(Ic&&p("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof e){const t=e.match(Yc);t&&2===t.length||n("bad gcs wkt");const s=Number.parseFloat(t[1]);return Number.isFinite(s)||n("bad gcs wkt"),s}return fc||Xc(),fc.has(e)||p("gcs wkid not found"),fc.get(e)}function Xc(){fc=new Map;for(const e in rs){const t=Number.parseFloat(e),s=rs[e];if(Array.isArray(s))for(const e of s)fc.set(e,t);else fc.set(s,t)}is()}function Lc(e,t){const s=Ic.geogtran(e);s||I(e);return new Kc(s,t)}function zc(e,t){const s=Ic.fromString(bc.PE_TYPE_GEOGTRAN,e);s||E(e);return new Kc(s,t)}function Wc(e,t){return new Kc(e,t)}const jc=Qe(0),Zc=Qe(1);class Kc{constructor(e,t){if(e instanceof Kc)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=Ke(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc));this.m_geogTranWrapper=new Um(e),this.m_bInverted=t,this.m_hashCode=Ke(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===e)return this.m_geogTranWrapper.getGeogtran().toString();{const t=0===e?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=bc.PE_STR_FMT_WKT2;return-1!==e&&(t|=0===e?bc.PE_STR_AUTH_TOP:bc.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 Kc(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){const t=e;return t===this||this.m_bInverted===t.m_bInverted&&(this.GetPeGeogtran()===t.GetPeGeogtran()||this.getID()===t.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Qc(s,n,r,i,o){const a=s.getGCS(),h=n.getGCS(),m=a.getPECoordSys(),g=h.getPECoordSys();let u=null;if(!r.isEmpty()){const e=r.clone();if(!e.isEmpty()&&2===s.getCoordinateSystemType()){let t=new xe({env2D:e});const n=Rg(s,a,null);t=(new qh).execute(t,n,null),t.queryEnvelope(e)}if(!e.isEmpty()){const t=m.getPrimem().getLongitude(),s=m.getUnit().getUnitFactor();u=new Fc(e.xmin,e.ymin,e.xmax,e.ymax,t,s)}}let c=i;c>=Tt()&&(c=0);const _=[];let d=Tc.PE_GTLIST_OPTS_COMMON;o||(d&=~Tc.PE_GTLIST_OPTS_USABLE);for(let f=0;f<2;f++){const s={stack:[],error:void 0,hasError:!1};try{_.length=0;const t=Tc.getGTlist(m,g,2,d,u,c);if(null==t||0===t.length)break;e(s,{[Symbol.dispose](){Gc.destroy(t)}},!1);let n=!1;for(const e of t){const t=$c(e);if(l(t),o&&t.referencesMissingData())n=!0,c=0;else if(_.push(t),_.length===i)break}if(!n)break}catch(p){s.error=p,s.hasError=!0}finally{t(s)}}return u&&u.destroy(),_}function Jc(){return new e_([],null,null,null)}function $c(e){const t=new t_,s=e.getSteps();if(s){const n=e.getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection();let r;const i=n[e].getGeogtran().getCode();if(i>=0)r=Ic.geogtran(i);else{const t=n[e].getGeogtran().toString(bc.PE_STR_FMT_WKT);r=Ic.fromString(bc.PE_TYPE_GEOGTRAN,t)}if(null==r)return null;const o=Wc(r,s);t.add(o)}return t.create()}return null}class e_{constructor(e,t,s,n){this.m_bReadOnly=!0,this.m_name="",this.m_fastTrack=-1,this.m_bNameIsSet=!1,this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=s,this.m_outputSr=n}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=Ke(e,this.m_transforms[t].getHashCode());return e}equals(e){return l(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return 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())&&b(""),this.m_transforms[e]}getInverse(){const e=new t_;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,s){if(0===this.count())return;let n=this.m_inputSr,r=this.m_outputSr;if(e&&(r=ht(n,n=r)),0===this.m_transforms.length)return void qm(n,null,r,null,t,null,s);let i=this.m_fastTrack;if(1===i)return void he(e,this.m_transforms,n=>{Xm(n.getWrapper(),e!==n.isInverted(),t,null,s)});const o=Mm();-1===i&&o.initFromGcsAndVcs(n,null);const a=Mm();let h=e?this.m_transforms.length-1:0;const m=e?-1:1;for(let g=0,u=this.m_transforms.length;g<u;g++,h+=m){if(0===g){const r=this.m_transforms[h];Bm(n.getPECoordSys(),null,r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}else{const n=this.m_transforms[h-m],r=this.m_transforms[h];Ym(o,n.getWrapper(),e!==n.isInverted(),r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}const r=this.m_transforms[h];Rm(o,r.getWrapper(),e!==r.isInverted(),t,null,s,a),o.assign(a)}const l=this.m_transforms[h-m];Om(o,l.getWrapper(),e!==l.isInverted(),r,null,t,null,s),-1===i&&(a.initFromGcsAndVcs(r,null),o.equals(a)||(i=0)),this.m_fastTrack=0===i?0:1}}class t_{constructor(){this.m_transforms=[],this.m_inputGCS=null,this.m_outputGCS=null,this.m_name="",this.m_bNameIsSet=!1}getInputSpatialReference(){return null!==this.m_inputGCS?this.m_inputGCS:this.count()>0?this.m_transforms[0].getInputSpatialReference():null}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&b(""),this.m_transforms[e]}setStep(e,t){l(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let s=e.count()-1;s>=0;--s)this.add(e.getStep(s).getInverse());else for(let s=0;s<e.count();++s)this.add(e.getStep(s))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){l(0)}create(){const e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),s=new e_(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return s.m_bReadOnly=!0,this.clear(),s}}const s_=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:oc,SpatialReferencePrecisionDescriptor:ac,create:Ou,createFromWKT:Yu,createImplFromPe:Ru,createLocal:Wu,createWithNewPrecision:Lu,createWithNewVCS:zu,getGCS:Zu,getTempName:tc,hasNoPe:qu,hasPe:Uu,injectNoPe:Mu,injectPe:Au,isInitialized:Bu,isTempName:sc,isValidWkid:Ku,isValidWkt:Qu,makeSpheroidData:Hu,snapGeometry:ju,webMercator:hc,webMercator102100:mc,wgs84:lc},Symbol.toStringTag,{value:"Module"}));export{Hu as $,ih as A,hh as B,fa as C,Fa as D,Ma as E,la as F,Zn as G,Ko as H,t_ as I,Lc as J,zc as K,Jc as L,Vc as M,Oh as N,qh as O,eu as P,Al as Q,Yh as R,Wu as S,Ka as T,as as U,Ag as V,cm as W,kl as X,Pc as Y,Cc as Z,Dc as _,Rg as a,um as a0,Lh as a1,zh as a2,Rh as a3,Xh as a4,_m as a5,ds as a6,Wl as a7,mg as a8,cs as a9,tn as aA,sn as aB,Ys as aC,tc as aD,Yu as aE,Ic as aF,zl as aG,ks as aH,Qu as aI,Ku as aJ,Hm as aK,Ou as aL,ac as aM,Lu as aN,ss as aO,s_ as aP,Xl as aa,ql as ab,Wo as ac,Ps as ad,wc as ae,Tl as af,Zl as ag,qs as ah,Is as ai,vs as aj,Th as ak,Us as al,Cs as am,jl as an,bc as ao,Zu as ap,cl as aq,fg as ar,sr as as,ir as at,zm as au,Wm as av,ha as aw,Ra as ax,ka as ay,nh as az,Yg as b,Og as c,Lg as d,Qg as e,Eh as f,Lo as g,Uu as h,Mu as i,er as j,_a as k,da as l,Wg as m,aa as n,Sa as o,ya as p,zg as q,pa as r,ju as s,jm as t,ul as u,Lm as v,kr as w,Km as x,wh as y,al as z};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{a as s,c as n,G as r,m as i,d as o,n as a,y as m,g as h,j as l,z as g,v as u,A as c,t as _,q as d,e as p,i as f,p as x,B as y,C as P,w as E,k as S,D as C,r as I}from"./Geometry.js";import{av as b,aw as w,p as v,d as N,P as T,ax as G,w as D,ay as V,R as F,az as k,o as H,E as A,c as M,e as U,Q as q,m as B,S as O,r as R,f as Y,K as X,a as L,u as z,aA as W,l as j,s as Z,aB as K,g as Q,V as J,aC as $,C as ee,aD as te,j as se,b as ne,i as re,h as ie,q as oe,aa as ae,aE as me,aF as he,aG as le,I as ge,M as ue,L as ce,aH as _e,aI as de,aJ as pe,aK as fe,aL as xe,as as ye,z as Pe,aM as Ee,n as Se}from"./Point2D.js";import{a as Ce,I as Ie,J as be,P as we,M as ve,K as Ne,E as Te,c as Ge,g as De,S as Ve,L as Fe,N as ke,O as He,n as Ae,Q as Me,R as Ue,y as qe,T as Be,D as Oe,l as Re,U as Ye,V as Xe,W as Le,X as ze,Y as We,Z as je,_ as Ze,$ as Ke,a0 as Qe,a1 as Je,a2 as $e,a3 as et,a4 as tt,a5 as st,a6 as nt,a7 as rt,a8 as it,a9 as ot,b as at}from"./MultiPathImpl.js";import{e as mt,d as ht,N as lt,Q as gt,i as ut,g as ct,c as _t,E as dt,P as pt,C as ft,f as xt,R as yt,T as Pt,U as Et,a as St,B as Ct,W as It,b as bt,X as wt,V as vt,Y as Nt,p as Tt,Z as Gt,H as Dt,_ as Vt,$ as Ft,a0 as kt,a1 as Ht,a2 as At,j as Mt,a3 as Ut,k as qt,a4 as Bt,a5 as Ot,S as Rt,A as Yt,a6 as Xt,a7 as Lt,h as zt}from"./Envelope.js";import{Envelope2D as Wt}from"./Envelope2D.js";import{T as jt}from"./Transformation2D.js";import{c as Zt,O as Kt,a as Qt}from"./OperatorClip.js";import{O as Jt}from"./OperatorDensify.js";import{G as $t}from"./GeometryCursor.js";import{S as es}from"./SimpleGeometryCursor.js";import{NonSimpleResult as ts}from"./OperatorDefinitions.js";class ss{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move)return this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,void(e.move.m_sr=null);if(e.copy)return this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,void(this.m_sr=e.copy.m_sr);e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){const s=e;return!(!this.m_sr&&s.m_sr)&&(!(this.m_sr&&!s.m_sr)&&(!(!this.m_geom&&s.m_geom)&&(!(this.m_geom&&!s.m_geom)&&(!(this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr))&&!(this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,t))))))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new ss({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}m_geom;m_sr}class ns{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()&&s("unit type mismatch"),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return b(w(this.getUnitType()),w(this.getUnitToBaseFactor()))}equals(e){return!!e&&(this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName())}static isValidWkid(e){return!1}}const rs={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 is(){for(const e in rs)delete rs[e]}class os extends ns{constructor(e){if("number"==typeof e)return super(),this.m_factor=e,void(this.m_wkid=0);super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function as(e){return new bu}function ms(e){return e.getType()===bc.PE_TYPE_LINUNIT?new bu(e):e.getType()===bc.PE_TYPE_ANGUNIT?new os(e):void s("peUnit")}function hs(e){const t=kc(null);return e.getType()===bc.PE_TYPE_PROJCS||e.getType()===bc.PE_TYPE_GEOGCS?t.reset(e.getUnit()):s("PE_coord_sys"),t.get()||o("cannot create units from coord sys"),ms(t.get())}class ls{x;y;z;constructor(e,t,n){void 0===e?(this.x=new ge,this.y=new ge,this.z=new ge):e instanceof qt?(this.x=new ge(e.x),this.y=new ge(e.y),this.z=new ge(e.z)):e instanceof ge?(this.x=e.clone(),this.y=t.clone(),this.z=n.clone()):s("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 ls(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){const t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),s=e.x.mulE(this.z).subE(this.x.mulE(e.z)),n=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new ls(t,s,n)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(e,t){return e.sub(t).length()}negate(){return new ls(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new ls(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new ls(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 ls(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new ls(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 qt.construct(this.x.value(),this.y.value(),this.z.value())}}class gs{m_origin=new qt;m_normal=new qt;m_axisX=new qt;m_axisY=new qt;constructor(e){if(!e)return this.m_origin=new qt,this.m_normal=new qt(0,0,1),this.m_axisX=new qt(1,0,0),void(this.m_axisY=new qt(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):h(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return h(0),this}set(e,t,s,n){h(0)}setFromPoints(e,t,s){let n=t.sub(e);const r=s.sub(e);this.m_normal=n.crossProductVector(r);let i=!0;if(this.m_normal.isZero()){if(i=!1,n.isZero()&&(n=r),n.isZero()){const t=0,s=1;return this.m_normal.setCoords(t,t,s),this.m_axisX.setCoords(s,t,t),this.m_axisY.setCoords(t,s,t),this.m_origin=e,!1}this.m_axisX=n.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}else this.m_normal.normalizeThis(),this.m_axisX=n.getUnitVector();return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,i}getCoord(e,t){return h(0),{}}getCoord2D(e){return h(0),{}}getCoordX(e,t){return h(0),0}getCoordY(e,t){return h(0),0}getCoordZ(e,t){return h(0),0}setPreferredAxisX(e){h(0)}getOrigin(){return h(0),{}}getNormal(){return h(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){h(0)}setAxisY(e,t=!1){h(0)}recalculateAxisY(){h(0)}setOrigin(e){h(0)}setNormal(e,t){h(0)}intersect(e,t){return h(0),!1}intersectLine(e){return h(0),0}intersectLineEx(e,t){return h(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new T;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return h(0),{}}signedDistance(e){return h(0),0}distance(e){return h(0),0}}function us(e,t){return!1}function cs(e,t,s,n,r=100,i=us){let o,a,m,l,g,u,c,_,d;h(n>0);let p,f,x,y=0,P=0;const E=ye();t>s&&(s=M(t,t=s));const S=e(t),C=e(s);S<C?(o=a=m=t,l=g=u=S):(o=a=m=s,l=g=u=C);let I=0;for(;I<r&&(x=.5*(s-t),d=t+x,p=n*(Math.abs(o)+.25),f=2*p,!(i(o,l)||Math.abs(o-d)<=f-x));++I){if(Math.abs(P)>p){const e=(o-a)*(l-u);let n=(o-m)*(l-g),r=(o-m)*n-(o-a)*e;n=2*(n-e),n>0&&(r=-r),n=Math.abs(n);const i=P;P=y,Math.abs(r)>=Math.abs(n*i*.5)||r<=n*(t-o)||r>=n*(s-o)?(P=o>=d?t-o:s-o,y=ye()*P):(y=r/n,_=o+y,(_-t<f||s-_<f)&&(y=d-o<0?-Math.abs(p):Math.abs(p)))}else P=o>=d?t-o:s-o,y=P*E;_=o+y,c=e(_),c<l?(_>=o?t=o:s=o,m=a,a=o,o=_,u=g,g=l,l=c):(_<o?t=_:s=_,c<=g||a===o?(m=a,a=_,u=g,g=c):(c<=u||m===o||m===a)&&(m=_,u=c))}return H(o,l)}function _s(e,t,s){if(e>s){e-=Math.ceil((e-s)/Se)*Se}else if(e<t){e+=Math.ceil((t-e)/Se)*Se}return e}function ds(e,t,s){return ps(e,t,s,0)}function ps(e,t,s,n){const r=s.x,i=s.y;return xs(e,t,Math.cos(r),Math.sin(r),Math.cos(i),Math.sin(i),n)}function fs(e,t,s,n,r,i){return xs(e,t,s,n,r,i,0)}function xs(e,t,s,n,r,i,o){const a=e/Math.sqrt(1-t*i*i),m=a+o,h=m*r*s,l=m*r*n,g=(a*(1-t)+o)*i;return qt.construct(h,l,g)}function ys(e,t,s){const n=new ge,r=new ge,i=new ge,o=new ge;n.setCos(s.x),r.setSin(s.x),i.setCos(s.y),o.setSin(s.y);const a=o.negate().mulE(o.mul(t)).add(1).sqrt(),m=new ge(e).divE(a),h=m.mulE(i).mulE(n),l=m.mulE(i).mulE(r),g=m.mul(1-t).mulE(o);return new ls(h,l,g)}function Ps(e,t,s){const n=s.x,r=s.y,i=s.z,o=Math.atan2(r,n),a=Math.sqrt(n*n+r*r),m=Math.atan2(i,(1-t)*a);return T.construct(o,m)}function Es(e,t,s){const n=1-t,r=e/Math.sqrt(L(s.x)+L(s.y)+L(s.z)/n);return s.mul(r)}function Ss(e,t,s,n,r){const i=ds(e,t,s),o=ds(e,t,n);return Ps(e,t,qt.lerp(i,o,r))}function Cs(e,t,s){const n=new qt;return n.setCrossProductVector(t,s),Math.abs(Math.atan2(n.length(),t.dotProduct(s)))*e}function Is(e,t,s,n,r){const i=s.getUnitVector(),o=n.getUnitVector(),a=t.getUnitVector(),m=new qt;if(m.setCrossProductVector(i,o),!m.isZero()){m.normalizeThis();const t=a.sub(m.mul(m.dotProduct(a)));if(!t.isZero()){t.normalizeThis();const s=i.add(o).mul(.5);if(s.dotProduct(t)>s.dotProduct(i)){const s=Math.abs(m.dotProduct(a)),n=Math.asin(s);return r.assign(t.getUnitVector().mul(e)),n*e}}}const h=Cs(1,i,a),l=Cs(1,o,a);return h<=l?(r.assign(s),h*e):(r.assign(n),l*e)}function bs(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,t,null,null,bc.PE_LINETYPE_GEODESIC),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function ws(e,t,s,n,r){switch(h(s.isFinite()&&n.isFinite()),r){case 0:return bs(e,t,s,n);case 1:return Ts(e,t,s);case 2:case 3:{const r=ds(e,t,s),i=ds(e,t,n);return qt.distance(r,i)}default:_("")}}function vs(e,t,s,n,r,i=0,o){if(2===i||3===i)return Ns(e,t,s,n,r,3===i,o);const a=Ps(e,t,s),m=s=>{const o=Ps(e,t,qt.lerp(n,r,s));return ws(e,t,a,o,i)},h=qt.distance(n,r);if(h>0){const s=Os(e,h),{first:i,second:a}=cs(m,0,1,s);return o&&o.assign(Es(e,t,qt.lerp(n,r,i))),H(i,a)}{const e=m(0);return o&&o.assign(n),H(.5,e)}}function Ns(e,t,s,n,r,i=!1,o){const a=Es(e,t,s);if(i){const i=new gs({pt0:new qt(0,0,0),pt1:n,pt2:r}),m=i.closestCoordinate(s),h=i.closestCoordinate(n),l=i.closestCoordinate(r),g=T.getClosestCoordinate(h,l,m),u=Es(e,t,qt.lerp(n,r,g)),c=qt.distance(u,a);return o&&o.assign(u),H(g,c)}const m=s=>{const i=Es(e,t,qt.lerp(n,r,s));return qt.distance(i,a)},h=qt.distance(n,r);if(h>0){const s=Os(e,h),{first:i,second:a}=cs(m,0,1,s);return o&&o.assign(Es(e,t,qt.lerp(n,r,i))),H(i,a)}{const e=qt.distance(s,n);return o&&o.assign(s),H(.5,e)}}function Ts(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.greatEllipticDistance(s,n,r.x,r.y,r.x,r.y,t,null,null),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function Gs(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>j||Math.abs(n.y)>j)return Number.NaN;if((Math.abs(s.y)===j||Math.abs(n.y)===j)&&s.x!==n.x)return Number.NaN;const{first:i,second:o}=le(s.x,n.x);let a=r;a=_s(a,i,o);if(!A.construct(s.x,n.x).containsCoordinate(a))return Number.NaN;const m=Ze.constructPoint2D(s),h=Ze.constructPoint2D(n),l=ys(1,t,m),g=ys(1,t,h),u=l.crossProductVector(g);if(u.z.isZero()){return s.y}const c=u.x.divE(u.z.negate()),_=u.y.divE(u.z.negate()),d=c.mulE(c).addE(_.mulE(_)).sqrt();if(d.isZero()||c.isZero()&&_.isZero()){return s.y}const p=Math.atan2(_.value(),c.value());let f=Math.atan2(d.value()*Math.cos(p-a),1-t);const x=ds(1,t,T.construct(a,f)),y=qt.construct(x.x,x.y,-x.z),P=u.value().dotProduct(x),E=u.value().dotProduct(y);return Math.abs(E)<Math.abs(P)&&(f=-f),f}function Ds(e,t,s,n,r,i){if(i[0]=Number.NaN,i[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>j||Math.abs(n.y)>j)return 0;if((Math.abs(s.y)===j||Math.abs(n.y)===j)&&s.x!==n.x)return 0;if(Math.abs(r)>=j)return 0;if(s.y>0&&n.y>0&&s.y>r&&n.y>r||s.y<0&&n.y<0&&s.y<r&&n.y<r)return 0;const o=Ze.constructPoint2D(s),a=Ze.constructPoint2D(n),m=ys(1,t,o),h=ys(1,t,a),l=m.crossProductVector(h);if(l.z.isZero()){return A.construct(s.y,n.y).containsCoordinate(r)?(i[0]=s.x,1):0}const g=l.x.divE(l.z.negate()),u=l.y.divE(l.z.negate()),c=g.mulE(g).addE(u.mulE(u)).sqrt();if(c.isZero()||g.isZero()&&u.isZero())return 0===r?(i[0]=s.x,i[1]=n.x,2):0;const _=(1-t)*Math.tan(r)/c.value();if(Math.abs(_)>1)return 0;const d=Math.acos(_),p=Math.atan2(u.value(),g.value()),f=p-d;let x=p+d;const y=Math.min(s.x,n.x),P=Math.max(s.x,n.x);_s(f,y,P),0!==r?_s(x,y,P):x=f;let E=0;return y<=f&&f<=P&&(i[E]=f,E++),x!==f&&y<=x&&x<=P&&(i[E]=x,E++),E}function Vs(e,t){t[0]>.5*Math.PI?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<.5*-Math.PI&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),h(t[0]>=.5*-Math.PI&&t[0]<=.5*Math.PI)}function Fs(e,t){return e*Math.sqrt(1-t)}function ks(e){return 1-e}function Hs(e,t,s,n,r){n=Z(n,-j,j),r=Z(r,-j,j);const i=j-.03;let o;o=n>i&&r>i||n<-i&&r<-i?As(e,n,r):Ms(e,r)-Ms(e,n);return.5*(s-t)*o*ks(e)}function As(e,t,s){let n=1;if(t<0&&(n=-1,t=-t,s=-s),0!==e){const r=e*e,i=r*e,o=[1,(1+11*e)/12,(1+118*e+241*r)/360,(1+1089*e+10419*r+8651*i)/20160,(1+9836*e+318246*r+1027436*i+458881*(i*e))/1814400],a=t=>{let s=0;const n=L(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-L(t/(1-e)),s},m=a(j-t);return(a(j-s)-m)*n}{const e=j-t,r=j-s,i=-4*L(Math.sin(e/2));return(-4*L(Math.sin(r/2))-i)*n}}function Ms(e,t){if(0===t)return 0;const s=Math.sin(t);let n=s,r=s;if(0!==e){n/=1-e*s*s;const t=Math.sqrt(e);r=s*Pe(t*s)}return n+r}function Us(e,t){return e/Math.sqrt(1-t)}function qs(e,t){return(1-t)*e}function Bs(e,t,s){const n=s/(2*qs(e,t)),r=n*n;return s*(1-r*(.16666666666666666-.008333333333333333*r))}function Os(e,t){if(0!==t){const s=e*xe()/t;return Math.min(s,1e-10)}return 0}class Rs{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++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return Rs.npos();this.m_currentShift=0n,this.m_currentElt=this.m_parent.m_bits[this.m_aiSetElts[this.m_iCurrentElt]]}for(;this.m_currentShift<63n&&!(this.m_currentElt&1n<<this.m_currentShift);)this.m_currentShift++;return this.m_currentElt&1n<<this.m_currentShift?64*this.m_aiSetElts[this.m_iCurrentElt]+Number(this.m_currentShift):this.next()}static npos(){return Number.MAX_SAFE_INTEGER}}function Ys(e){return 1n<<(0x3fn&BigInt(e))}function Xs(e){return e>>6}class Ls{m_bits=[];constructor(e){void 0!==e&&e.copy&&(this.m_bits=e.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(e){const t=Ys(e),s=Xs(e);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&t)}setBit(e){const t=Ys(e),s=Xs(e);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=t}clearBit(e){}flipBit(e){const t=Ys(e),s=Xs(e);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=t,0n!==(this.m_bits[s]&t)}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(2&e)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((s,n)=>{t|=s===e.m_bits[n]?2:1}),!(1&t)&&(e.m_bits.forEach((e,s)=>{t|=e===this.m_bits[s]?2:1}),!(1&t))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>K(e,t),w(0))}getUnorderedBitIterator(){return new Rs(this)}}class zs{m_map=new Map;m_hf;m_ef;constructor(e,t){this.m_hf=e,this.m_ef=t}add(e){const t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;const s=this.m_map.get(t);return s instanceof Array?s.find(t=>this.m_ef(t,e))||s.push(e):this.m_ef(s,e)||this.m_map.set(t,[s,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){const t=this.m_hf(e);if(!this.m_map.has(t))return!1;const s=this.m_map.get(t);return s instanceof Array?void 0!==s.find(t=>this.m_ef(t,e)):this.m_ef(s,e)}get(e){const t=this.m_hf(e),s=this.m_map.get(t);if(void 0!==s)return s instanceof Array?s.find(t=>this.m_ef(t,e)):s}get size(){let e=0;for(const t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[Symbol.iterator](){return(new Set)[Symbol.iterator]()}entries(){return(new Set).entries()}keys(){return(new Set).keys()}values(){return(new Set).values()}get[Symbol.toStringTag](){return"ValueSet"}}class Ws extends Xt{m_helper;m_bufferLeft=new Ve;m_bufferRight=new Ve;m_intervalLeft=A.constructEmpty();m_intervalRight=A.constructEmpty();m_yScanline=Number.NaN;constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=t,r=e.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(r,this.m_bufferRight);const i=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(i.getStartX(),i.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=i.getStartY()===i.getEndY(),m=o.getStartY()===o.getEndY();if(a||m){if(a&&m)return 0;if(i.getStartY()===o.getStartY()&&i.getStartX()===o.getStartX())return a?1:-1;if(i.getEndY()===o.getEndY()&&i.getEndX()===o.getEndX())return a?-1:1}let h=i.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(h===l){const e=i.getEndY(),t=o.getEndY(),s=Math.min(e,t);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),h=i.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return h<l?-1:h>l?1:0}setY(e){this.m_yScanline=e}}class js{m_parent;m_segmentBuffer=new Ve;m_point=T.getNAN();constructor(e){this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){const s=e.getElement(t);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),r=new A;if(r.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<r.vmin)return-1;if(this.m_point.x>r.vmax)return 1;const i=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<i?-1:this.m_point.x>i?1:0}}var Zs,Ks;function Qs(e,t){return{parentage:e,rank:t}}function Js(e,t){const s=e.length;if(s!==t.length)return!1;const n=e[0].parentage;if(n!==t[0].parentage)return!1;if(-1===n)return!0;for(let r=1;r<s;++r)if(e[r].parentage!==t[r].parentage)return!1;return!0}function $s(e,t,s){s.length=0;let n=!1;{let r=e.getHalfEdgeVertexIterator(t);for(;r!==Ae;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}{let r=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;r!==Ae;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}n&&s.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:e.parentage>t.parentage?1:0),-1===s[0].parentage&&(s.length=1)}function en(){return new zs(e=>e.getHashCode(),(e,t)=>e.equals(t))}!function(e){e[e.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",e[e.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",e[e.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding"}(Zs||(Zs={})),function(e){e[e.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",e[e.enumPathBreakNode=2]="enumPathBreakNode"}(Ks||(Ks={}));class tn{m_shape=null;m_clusterData=new Rt(8);m_clusterVertices=new Rt(2);m_firstCluster=Ae;m_lastCluster=Ae;m_halfEdgeData=new Rt(8);m_chainData=new Rt(8);m_chainAreas=null;m_chainPerimeters=null;static c_EdgeParentageMask=~(1<<31);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=Number.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,s=!0,n=!1){n?this.setEditShapeImpl3D_(e,Zs.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,Zs.enumInputModeBuildGraph,null,t,s)}setAndSimplifyEditShapeAlternate(e,t,s=null,n=!1){const i=[];i.push(t),this.m_simplifiedGeometry=t,n?this.setEditShapeImpl3D_(e,Zs.enumInputModeSimplifyAlternate,i,s,!1):this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyAlternate,i,s,e.getGeometryType(t)===r.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,s=null){const n=[];n.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyWinding,n,s,!0)}removeShape(){null!==this.m_shape&&(-1!==this.m_geometryIDIndex&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),-1!==this.m_clusterIndex&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),-1!==this.m_halfEdgeIndex&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),-1!==this.m_segmentParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),-1!==this.m_segmentIndexHe&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),-1!==this.m_clusterBreakNodeIndex&&(this.deleteUserIndexForClusters(this.m_clusterBreakNodeIndex),this.m_clusterBreakNodeIndex=-1),this.deleteEdgeBitSets_(),this.deleteChainBitSets_(),this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_shape=null,this.m_clusterData.deleteAll(!0),this.m_clusterVertices.deleteAll(!0),this.m_firstCluster=Ae,this.m_lastCluster=Ae,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=Ae,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){const s=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(e,t){h(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){const s=this.getClusterIndex_(e),n=this.m_clusterIndices[t];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1),r.write(n,s)}hasClusterUserIndexFlags(e,t,s){if(-1===t)return!1;const n=this.getClusterUserIndex(e,t);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,s|i)}clearClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,~s&i)}createUserIndexForClusters(e=-1){const t=new St(this.m_clusterData.capacity(),e);for(let s=0,n=this.m_clusterIndices.length;s<n;s++)if(null===this.m_clusterIndices[s])return this.m_clusterIndices[s]=t,s;this.m_clusterIndices.push(t);return 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){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}getHalfEdgeFromXYZ(e,t){h(0)}getHalfEdgeToXYZ(e,t){h(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&tn.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){const s=this.getHalfEdgeIndex_(e),n=this.m_edgeIndices[t];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(e,t,s){const n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];r.size()<=n&&r.resize(this.m_halfEdgeData.size(),-1),r.write(n,s)}createUserIndexForHalfEdges(e){void 0===e&&(e=-1);const t=new St(this.m_halfEdgeData.capacity(),e);for(let n=0,r=this.m_edgeIndices.length;n<r;n++)if(null===this.m_edgeIndices[n])return this.m_edgeIndices[n]=t,n;this.m_edgeIndices.push(t);const s=this.m_edgeIndices.length-1;return h(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.getHalfEdgeChain(s),r=this.getHalfEdgeTwin(s),i=this.getHalfEdgeChain(r);this.setChainHalfEdge_(n,Ae),this.setChainHalfEdge_(i,Ae),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return h(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return h(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return h(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return h(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return h(0),!1}doesClusterBelongToAPolygonInterior(e,t){return h(0),!1}doesClusterBelongToAPolygonExterior(e,t){return h(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return h(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){const t=this.getChainIndex_(e);let s=this.m_chainAreas.read(t);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(e),s=this.m_chainAreas.read(t)),s}getChainPerimeter(e){return h(0),0}getChainUserIndex(e,t){const s=this.getChainIndex_(e),n=this.m_chainIndices[t];return n.size()<=s?-1:n.read(s)}setChainUserIndex(e,t,s){const n=this.getChainIndex_(e),r=this.m_chainIndices[t];r.size()<=n&&r.resize(this.m_chainData.size(),-1),r.write(n,s)}createUserIndexForChains(){const e=new St(this.m_chainData.capacity(),-1);for(let t=0,s=this.m_chainIndices.length;t<s;t++)if(null===this.m_chainIndices[t])return this.m_chainIndices[t]=e,t;this.m_chainIndices.push(e);return this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,s,n){const i=t===Ae?e.createGeometry(r.enumPolygon):t,o=new Ve;this.extractPolygonPathFromChain_(e,i,s,n,o);for(let r=this.getChainFirstIsland(s);r!==Ae;r=this.getChainNextInParent(r))this.extractPolygonPathFromChain_(e,i,r,n,o);return i}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return h(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(h(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);h(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){h(this.m_bBuildGeometryParentageSets);const t=new Ls,s=e=>{const s=this.getChainHalfEdge(e);let n=s;do{const e=this.getEdgeBitSet_(n);null!==e&&t.assignOr(e);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&t.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(e);for(let n=this.getChainFirstIsland(e);n!==Ae;n=this.getChainNextInParent(n))s(e);return t}getChainPolygons(e){return h(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||null===e)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==Ae;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}const t=[],s=e.getUnorderedBitIterator();for(let n=s.next();n!==Rs.npos();n=s.next())h(this.m_geometryMapID.has(n)),t.push(this.m_geometryMapID.get(n));return t}getVertexDominant(e,t){if(t===Ae)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==Ae){let s=Ae;for(let n=this.getClusterVertexIterator(e);n!==Ae;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===Ae&&(s=e);const r=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(r)===t){s=e;break}}return s}{const t=this.getClusterVertexIterator(e);if(t!==Ae){return this.getVertexFromVertexIterator(t)}return Ae}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}setBreakNode(e,t){h(-1!==this.m_clusterBreakNodeIndex),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}setStrongPathNode(e,t){if(-1===this.m_clusterBreakNodeIndex){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}getSegmentParentage(e){if(-1===this.m_segmentParentageIndex)return-1;const t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){const t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(s);return e!==this.getHalfEdgeTwin(n)}isCrossroadBehind(e){return h(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===Ae)return Ae;let n=s,r=Ae,i=Ae;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===Ae){if(r=this.getClusterHalfEdge(t),r===Ae)return Ae;i=r}if(this.getHalfEdgeTo(i)===e)return n=this.getHalfEdgeTwin(i),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(n!==s&&i!==r);return Ae}querySegmentXY(e,t){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const e=this.m_shape.getSegmentFromIndex(s);t.copyFrom(e,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);t.copyFrom(n,!0),t.get().reverse()}return}}t.createLine();const s=t.get(),n=T.getNAN();this.getHalfEdgeFromXY(e,n),s.setStartXY(n),this.getHalfEdgeToXY(e,n),s.setEndXY(n)}isCurveEdge(e){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}compareEdgeAnglesCurveHelper_(e,t,s){const n=new Ve,r=new Ve;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const i=n.get(),o=r.get();if(i.equals(o))return 0;const a=new T;this.getHalfEdgeFromXY(e,a);const m=new T;this.getHalfEdgeToXY(e,m);const l=new T;this.getHalfEdgeToXY(t,l),h(!m.isEqualPoint2D(l));return Ue(i,o)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=T.getNAN();this.getHalfEdgeToXY(e,n);const r=T.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=T.getNAN();this.getHalfEdgeFromXY(e,i);const o=T.getNAN();o.setSub(n,i);const a=T.getNAN();if(a.setSub(r,i),!s||a.y>=0&&o.y>0){return T.compareVectors(o,a)}return 0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return h(0),0}compareEdgeAnglesForPair3D_(e,t){return h(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);h(n===t),h(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=Ae));const i=this.getChainIndex_(t),o=this.m_chainAreas.read(i);Number.isNaN(o)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const a=this.getChainHalfEdge(t);a!==e&&a!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==Ae?t:this.getClusterHalfEdge(e);if(n===Ae)return Ae;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return Ae;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==Ae;s=this.getNextCluster(s)){let n=Ae;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===Ae)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));let i=r;for(;;){const s=this.getHalfEdgeNext(i),o=this.getHalfEdgePrev(i),a=this.getHalfEdgeTwin(i);if(o===a){if(this.deleteEdgeInternal_(i),e=!0,n!==i&&n!==a||(n=Ae),i===r||o===r){if(r=s,i===r||o===r)break;i=s;continue}}else this.setHalfEdgeUserIndex(i,t,1);if(i=s,i===r)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){const e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){const e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);const t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){const e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return h(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){const s=t?Ae:e;for(let n=this.getHalfEdgeVertexIterator(e);n!==Ae;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==Ae&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);const s=this.getChainFirstIsland(t);this.setChainNextInParent_(e,s),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){const s=this.getChainIndex_(e);this.m_chainAreas.write(s,t)}setChainPerimeter_(e,t){const s=this.getChainIndex_(e);this.m_chainPerimeters.write(s,t)}updateChainAreaAndPerimeter_(e){const t=this.m_shape.hasCurves(),s=new X(0),n=new X(0),r=this.getChainHalfEdge(e),i=T.getNAN(),o=T.getNAN(),a=T.getNAN();this.getHalfEdgeFromXY(r,i),o.setCoordsPoint2D(i);let m=r;do{this.getHalfEdgeToXY(m,a),t&&this.isCurveEdge(m)||n.pe(T.distance(o,a));this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==e&&s.pe((a.x-i.x-(o.x-i.x))*(a.y-i.y+(o.y-i.y))*.5),o.setCoordsPoint2D(a),m=this.getHalfEdgeNext(m)}while(m!==r);if(t){const t=new Ve;m=r;do{this.getHalfEdgeToXY(m,a);const r=this.isCurveEdge(m);r&&(this.querySegmentXY(m,t),n.pe(t.get().calculateLength2D()));if(this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==e&&r){const e=t.get().calculateArea2DHelper();s.pe(e)}m=this.getHalfEdgeNext(m)}while(m!==r)}const h=this.getChainIndex_(e);this.m_chainAreas.write(h,s.getResult()),this.m_chainPerimeters.write(h,n.getResult())}getChainTopmostEdge_(e){return h(0),0}planeSweepParentage_(e,t){const s=new Ws(this),n=new Pt;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let o=null;const a=T.getNAN();for(let m=this.getFirstCluster();m!==Ae;m=this.getNextCluster(m)){this.progress_(t);const h=this.getClusterHalfEdge(m);if(h!==Ae){if(r.length=0,!this.tryOptimizedInsertion_(n,i,r,m,h)){this.queryXY(m,a),s.setY(a.y);let e=h;do{const t=this.getHalfEdgeUserIndex(e,i);-1!==t&&(n.deleteNode(t),this.setHalfEdgeUserIndex(e,i,Rt.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(h!==e);e=h;do{if(-1===this.getHalfEdgeUserIndex(e,i)){const t=n.addElement(e);r.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(h!==e)}for(let t=r.length-1;t>=0;t--){const s=r[t],o=n.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,i,s),this.planeSweepParentagePropagateParentage_(n,s,e)}}else if(this.getClusterChain(m)===Ae){null===o&&(o=new js(this)),this.queryXY(m,a),o.setPointXY(a);const e=n.searchLowerBound(o);let t=this.m_universeChain;if(-1!==e){let s=n.getElement(e);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,e)),s!==Ae&&(t=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(t,m)}}this.deleteUserIndexForHalfEdges(i)}planeSweepParentagePropagateParentage_(e,t,s){const n=e.getElement(t),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==Ae)return;const i=this.getLeftSkipPolylines_(e,t),o=this.getHalfEdgeTwin(n),a=this.getHalfEdgeChain(o);let m=this.getChainParent(r),l=this.getChainParent(a);if(i===Ae)m===Ae&&(a===r?(this.setChainParent_(a,this.m_universeChain),l=this.m_universeChain,m=l):(l===Ae&&(this.setChainParent_(a,this.m_universeChain),l=this.m_universeChain),this.setChainParent_(r,a),m=a));else{const e=this.getHalfEdgeChain(i);if(l===Ae){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(a,t),l=t}else this.setChainParent_(a,e),l=e;a===r&&(m=l)}}m===Ae&&(this.trySetChainParentFromTwin_(r,a),m=this.getChainParent(r)),h(m!==Ae),s===Zs.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,i):s===Zs.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,i,o,r,a):s===Zs.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,i,o,r,a)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===Ae?(i=e.getNext(i),r=this.getHalfEdgeChain(s)):r=this.getHalfEdgeChain(n);let o=null,a=this.getChainParentage(r);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(r));-1!==i;i=e.getNext(i)){const t=e.getElement(i),s=this.getHalfEdgeTwin(t);r=this.getHalfEdgeChain(t);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(n);e=new Ls({copy:e}),e.assignOr(o),this.setChainBitSet_(n,e);let s=this.getChainBitSet(r);const i=this.getLeftEdgeBitSet_(t),a=new Ls({copy:o});if(a.assignSubtract(i),a.isZero())break;s=new Ls({copy:s}),s.assignOr(a),this.setChainBitSet_(r,s),o=s}const m=this.getChainParentage(n),h=m|a;h!==m&&this.setChainParentage_(n,h);let l=this.getChainParentage(r);const g=a&~this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft);if(g&&(l|=g,this.setChainParentage_(r,l)),0===g)break;a=l}}propagateParentageWinding_(e,t,s,n,r,i,o){if(i===o)return;let a=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);a+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let m=0;const l=[],g=[];g.push(0);for(let u=e.getFirst();u!==t;u=e.getNext(u)){const t=e.getElement(u),s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeChain(t),r=this.getHalfEdgeChain(s);if(n!==r){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex),m+=e;let i=!1;0!==l.length&&l.at(-1)===r&&(g.pop(),l.pop(),i=!0),h(this.getChainParent(r)!==Ae),i&&this.getChainParent(r)===n||(g.push(m),l.push(n))}}if(m+=a,0!==l.length&&l.at(-1)===o&&(g.pop(),l.pop()),0!==m){if(0===g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}else if(0!==g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}propagateParentageAlternate_(e,t,s,n,r,i,o){const a=this.m_simplifiedGeometry,m=this.getGeometryID(a);if(n===Ae){this.setChainParentage_(o,this.m_universeGeomID);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,m):this.setChainParentage_(i,this.m_universeGeomID)}else{const e=this.getChainParentage(o);if(0===e){const e=this.getHalfEdgeChain(n),t=this.getChainParentage(e);this.setChainParentage_(o,t);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,t===m?this.m_universeGeomID:m):this.setChainParentage_(i,t)}else{1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,e===m?this.m_universeGeomID:m):this.setChainParentage_(i,e)}}}tryOptimizedInsertion_(e,t,s,n,r){let i=r,o=-1,a=Ae,m=0;do{if(2===m)return!1;const e=this.getHalfEdgeUserIndex(i,t);if(-1!==e){if(-1!==o)return!1;o=e}else{if(a!==Ae)return!1;a=i}m++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return a!==Ae&&-1!==o&&(this.setHalfEdgeUserIndex(e.getElement(o),t,Rt.impossibleIndex2()),e.setElement(o,a),s.push(o),!0)}trySetChainParentFromTwin_(e,t){const s=this.getChainArea(e);if(0===s)return!1;const n=this.getChainArea(t);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(e,t),!0;{const s=this.getChainParent(t);if(s!==Ae)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=t.size();s<n;s++){const n=t.read(s),i=this.m_shape.getUserIndex(n,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(n),m=this.m_shape.getGeometryFromPath(o),h=this.m_shape.getGeometryType(m);if(a(h)){const t=this.m_shape.getNextVertex(n);if(t===Ae)continue;const s=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(i===s)continue;const o=this.newHalfEdgePair_(),a=this.getHalfEdgeTwin(o),l=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(l,0,n),this.m_clusterVertices.setField(l,1,-1),this.setHalfEdgeVertexIterator_(o,l),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,i);const g=this.getClusterHalfEdge(i);if(g===Ae)this.setClusterHalfEdge_(i,o),this.setHalfEdgePrev_(o,a),this.setHalfEdgeNext_(a,o);else{const e=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,a),this.setHalfEdgeNext_(a,g),this.setHalfEdgeNext_(e,o),this.setHalfEdgePrev_(o,e)}this.setHalfEdgeOrigin_(a,s);const u=this.getClusterHalfEdge(s);if(u===Ae)this.setClusterHalfEdge_(s,a),this.setHalfEdgeNext_(o,a),this.setHalfEdgePrev_(a,o);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,o),this.setHalfEdgeNext_(o,u),this.setHalfEdgeNext_(e,a),this.setHalfEdgePrev_(a,e)}const c=this.getGeometryID(m);if(e===Zs.enumInputModeBuildGraph){const e=h===r.enumPolygon?c:0;if(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new Ls,t=this.m_shape.getGeometryUserIndex(m,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(o,e),this.setEdgeBitSet_(a,null),this.setLeftEdgeBitSet_(a,e),this.setLeftEdgeBitSet_(o,null)}}else if(e===Zs.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(n),s=this.m_shape.getXY(t);let r=0,i=0;e.compare(s)<0?r=1:i=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,r),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,i)}else e===Zs.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=h===r.enumPolygon?tn.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,c|_),this.setHalfEdgeParentage_(a,c|_)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,s=t.size();e<s;e++){const s=t.read(e);if(this.m_shape.getSegment(s)){const e=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);e!==Ae&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{const s=this.getHalfEdgeVertexIterator(t);if(s!==Ae){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,Ae)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==Ae){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,Ae)}}if(-1!==this.m_segmentIndexHe){let r=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==r){if(-2===r){const s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,s)}if(r=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===r){const e=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){const t=[];for(let s=this.getFirstCluster();s!==Ae;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==Ae){let r=n;do{t.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(t.length>1){let r=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=M(t[0],t[0]=t[1]):r=!1;let i=t[0],o=i,a=this.getHalfEdgeTo(o),m=this.getHalfEdgeTwin(o),h=Ae;for(let s=1,n=t.length;s<n;s++){const n=t[s],r=this.getHalfEdgeTwin(n),l=this.getHalfEdgeOrigin(r);if(l!==a||n===o)this.updateVertexToHalfEdgeConnection_(h,!1),h=Ae,o=n,a=l,m=r;else{if(e===Zs.enumInputModeBuildGraph){const e=this.getHalfEdgeParentageMask_(o)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(o,e),this.setHalfEdgeParentage_(m,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(m,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(m,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(m,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(m,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,s;e=this.getEdgeBitSet_(o),t=this.getEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(o,s),e=this.getEdgeBitSet_(m),t=this.getEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(m,s),e=this.getLeftEdgeBitSet_(o),t=this.getLeftEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(o,s),e=this.getLeftEdgeBitSet_(m),t=this.getLeftEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(m,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(m,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(m,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(m,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(m,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(o,n),this.deleteEdgeImpl_(n),h=o,t[s]=Ae,n===i&&(t[0]=Ae,i=Ae)}}if(this.updateVertexToHalfEdgeConnection_(h,!1),h=Ae,!r){i=Ae;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==Ae){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=Ae;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===Ae)continue;if(i===Ae){i=s,o=i,a=this.getHalfEdgeTo(o),m=this.getHalfEdgeTwin(o);continue}if(s===o)continue;const n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(m,s),this.setHalfEdgePrev_(s,m),o=s,a=r,m=n}this.setClusterHalfEdge_(s,i)}}}}sortHalfEdgesByAngle3D_(e){h(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,Ae);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==Ae;n=this.getNextCluster(n)){const e=this.getClusterHalfEdge(n);if(e!==Ae){let n=e;do{if(1!==this.getHalfEdgeUserIndex(n,s)){const e=this.newChain_();this.setChainHalfEdge_(e,n),this.setChainPrev_(e,t),this.setChainNext_(t,e);let r=null;this.m_bBuildGeometryParentageSets&&(r=new Ls),t=e;let i=0,o=n;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(i|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&r.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,e),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==n);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(e,r),this.setChainParentage_(e,i)}n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n))}while(n!==e)}}this.m_chainAreas=new Yt(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new Yt(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(e){h(0)}simplifyAlternate_(){h(0)}simplifyWinding_(){h(0)}setEditShapeImpl_(e,t,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let i=this.m_shape.getTotalPointCount();if(s){i=0;for(let e=0,t=s.length;e<t;e++)i+=this.m_shape.getPointCount(s[e])}const o=new St(0);let a=0,m=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==Ae;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,m++);for(let t=this.m_shape.getFirstPath(e);t!==Ae;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,n=this.m_shape.getPathSize(t);s<n;s++)o.add(e),e=this.m_shape.getNextVertex(e)}l(this.m_shape.getGeometryType(e))||(a+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:Ae,t++):e=this.m_shape.getNextGeometry(e)}}this.m_universeGeomID=1<<Math.min(m,31),this.m_pointCount=o.size(),this.m_shape.sortVerticesSimpleByY(o,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(n,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,a)),this.m_clusterIndex=this.m_shape.createUserIndex();const h=T.getNAN();let g=0;const u=T.getNAN();for(let l=0;l<=this.m_pointCount;l++){if(l<this.m_pointCount){const e=o.read(l);this.m_shape.queryXY(e,u)}else u.setNAN();if(!h.isEqualPoint2D(u)){if(g<l){const e=this.newCluster_();let t=Ae,s=-1;for(let n=g;n<l;n++){s=o.read(n),this.m_shape.setUserIndex(s,this.m_clusterIndex,e);const r=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(r,0,s),this.m_clusterVertices.setField(r,1,t),t=r;const i=this.m_shape.getPathFromVertex(s),a=this.m_shape.getGeometryFromPath(i),m=this.getGeometryID(a);this.setClusterParentage_(e,this.getClusterParentage(e)|m)}this.setClusterVertexIterator_(e,t),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(s)),this.m_lastCluster!==Ae&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===Ae&&(this.m_firstCluster=e)}g=l,h.setCoordsPoint2D(u)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){const t=o.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){const e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(n,!0);{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==Ae;){for(let t=this.m_shape.getFirstPath(e);t!==Ae;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){const e=this.m_shape.getFirstVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(t)){const e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}}null!=s?(e=t<s.length?s[t]:Ae,t++):e=this.m_shape.getNextGeometry(e)}}if(t===Zs.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,o),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(t),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,n),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(e,t,s,n,r){h(0)}cleanSetEditShapeImpl_(){-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){h(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){const t=this.getHalfEdgeNext(e),s=this.getHalfEdgePrev(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeNext(n),i=this.getHalfEdgePrev(n);t!==n&&(this.setHalfEdgeNext_(i,t),this.setHalfEdgePrev_(t,i)),s!==n&&(this.setHalfEdgeNext_(s,r),this.setHalfEdgePrev_(r,s));const o=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(o)===e&&(r!==e?this.setClusterHalfEdge_(o,r):this.setClusterHalfEdge_(o,Ae));const a=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(a)===n&&(t!==n?this.setClusterHalfEdge_(a,t):this.setClusterHalfEdge_(a,Ae)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(e,t){let s=t;for(;;){if(s=e.getPrev(s),-1===s)return Ae;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=L(this.m_checkDirtyPlanesweepTolerance),t=new T,s=new T,n=new T,r=new T,i=new T;for(let o=this.getFirstCluster();o!==Ae;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==Ae){let o=a;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,s),n.setSub(s,t);let m=n.sqrLength();do{const a=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==a){this.getHalfEdgeToXY(o,r),i.setSub(r,t);const a=i.sqrLength(),h=i.crossProduct(n),l=h*h/(a*m);if(Math.min(a,m)*l<=e){if(i.dotProduct(n)>=0)return!1}n.assign(i),m=a,s.assign(r)}}while(o!==a)}}return!0}extractPolygonPathFromChain_(e,t,s,n,r){const i=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(s);let a=o,m=Ae;const h=new pt;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=Ae;const o=this.getHalfEdgeOrigin(a);if(n===Ae){const e=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==Ae;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===Ae&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let l;if(m===Ae&&(m=e.insertPath(t,Ae),e.setClosedPath(m,!0)),this.m_shape===e?l=e.addVertex(m,s):(this.m_shape.queryPoint(s,h),l=e.addPoint(m,h)),this.isHalfEdgeCurve(a)&&(this.querySegmentXY(a,r),e.setSegmentToIndex(e.getVertexIndex(l),r.get().clone())),i){const t=this.getSegmentParentage(a);e.setSegmentParentageAndBreak(l,t,this.isBreakNode(o))}}a=this.getHalfEdgeNext(a)}while(a!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;h(-1!==this.m_clusterBreakNodeIndex),h(-1===this.m_segmentParentageIndex);for(let n=this.getFirstCluster();n!==Ae;n=this.getNextCluster(n)){let e=0;const t=this.getClusterHalfEdge(n);if(t!==Ae){let s=t;do{e++,s=this.getHalfEdgeNext(this.getHalfEdgeTwin(s))}while(s!==t&&e<3)}2!==e&&this.setBreakNode(n,!0)}let e=[],t=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==Ae;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==Ae){let n=!1,i=r;do{let r=i;for(;-1===this.getHalfEdgeUserIndex(r,s);){const i=this.getHalfEdgeNext(r),o=this.getHalfEdgeTwin(r);$s(this,r,t);const a=t.at(-1).parentage;if(!n){const t=this.getHalfEdgeOrigin(r);if(!this.isBreakNode(t)){const t=this.getHalfEdgePrev(r);r!==t&&($s(this,t,e),n=!0)}}if(n&&!Js(t,e)){const e=this.getHalfEdgeOrigin(r);this.setBreakNode(e,!0)}e=M(t,t=e),n=!0;const m=this.getHalfEdgeOrigin(i);this.isBreakNode(m)&&(n=!1),this.setHalfEdgeUserIndex(r,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(r,s,1),this.setHalfEdgeUserIndex(o,s,1),r=i}i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==r)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(e){if(null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=en(),this.m_uniqueBitSets.add(this.getEmptySet())),null===e)return this.getEmptySet();return this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return h(t>=0),h(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return h(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){h(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setLeftEdgeBitSet_(e,t){h(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setChainBitSet_(e,t){h(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(e,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=t:(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new Ls),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(e){}dbgVerifyEdgeSegment(e){}}class sn{m_listNodes=new Rt(2);m_lists;m_listOfLists=sn.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){h(0)}constructor(e){void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new Rt(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==sn.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!==sn.st_nullNode();){const e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==sn.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);const s=this.m_lists.getField(e,1),n=this.newNode_();return s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,n)):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,n)),this.m_listNodes.setField(n,0,t),n}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,s){t!==sn.st_nullNode()?(this.m_listNodes.setField(t,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,t)):(this.m_lists.setField(e,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,sn.st_nullNode())),this.freeNode_(s)}deleteElementSearch(e,t){let s=-1,n=this.getFirst(e);for(;n!==t;)s=n,n=this.getNext(n);this.deleteElementDirect(e,s,t)}concatenateLists(e,t){const s=this.m_lists.getField(e,1),n=this.m_lists.getField(t,0);if(n!==sn.st_nullNode()&&(s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==sn.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){h(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){const t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=sn.st_nullNode()}isEmpty(e){return h(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 nn(e=-1){return{m_value:e,m_line:new Fe,m_segment:null,m_segmentInfo:new rt(-1),m_env:new A(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}const rn=67;class on extends Xt{m_shape;m_bIntersectionDetected=!1;m_nonSimpleResult=new ts;m_tempSimpleEdge1=nn();m_tempSimpleEdge2=nn();m_prev1=Ae;m_prev2=Ae;m_vertex1=Ae;m_vertex2=Ae;m_currentNode=-1;m_prevX1=Number.NaN;m_prevX2=Number.NaN;m_prevY=Number.NaN;m_prevX=0;m_sweepY=Number.NaN;m_sweepX=0;m_ptSweep=new T;m_tolerance;m_tolerance10;m_bIsSimple;m_bShapeHasSegments;m_simpleEdgesCache=[];m_simpleEdgesRecycle=[];m_cOutstandingConstructedEdges=0;constructor(e,t,s){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=s;const n=Math.trunc(Math.min(3*e.getTotalPointCount()/2,rn)),r=Math.min(7,n);this.m_simpleEdgesCache.length=r}tryGetCachedEdge_(e){const t=this.m_simpleEdgesCache[(e&se())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&se())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[t];s&&s.m_value===e&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){const t=(e&se())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[t];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=nn(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=e,this.m_simpleEdgesCache[t]=s,s)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=null!==e.m_segment,e.m_bCurve){const t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){const s=e.getStartXY(),n=e.getEndXY(),r=t.getStartXY(),i=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(r)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(i)<0?n:i);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-r)>this.m_tolerance)return s<r?-1:1}const o=s.compare(r)<0?r:s,a=n.compare(i)<0?n:i;let m=0,h=0;for(let l=1;l<5;l++){J(o,a,l/5,this.m_ptSweep);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=Math.abs(s-n);r>m&&(m=r,h=s<n?-1:1)}return 0===h?this.errorCracking():h}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);const s=this.compareNonHorizontalLowerEnd_(e,t),n=this.compareNonHorizontalUpperEnd_(e,t);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}return-1}compareHorizontal1Case3_(e,t){const s=T.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=T.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=T.getNAN();r.setSub(e.getEndXY(),t.getStartXY());const i=n.dotProduct(s),o=r.dotProduct(s),a=Math.abs(i),m=Math.abs(o);if(a<m){if(a<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return i<0&&o<0?-1:i>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let s=1;if(e.m_line.getStartY()<t.m_line.getStartY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getStartX()-r.getStartX(),o=t.m_dxdy*(n.getStartY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}compareNonHorizontalUpperEnd_(e,t){let s=1;if(t.m_line.getEndY()<e.m_line.getEndY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getEndX()-r.getStartX(),o=t.m_dxdy*(n.getEndY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}errorCoincident(){this.m_bIntersectionDetected=!0;const e=7;return this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const e=6;this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2)}else this.m_prev1=Ae,this.m_prev2=Ae,this.m_vertex1=Ae,this.m_vertex2=Ae;return-1}compareSegments_(e,t,s,n){if(s.m_env.vmax<n.m_env.vmin)return-1;if(n.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!n.m_bCurve){let e=s.m_bHorizontal?1:0;return e|=n.m_bHorizontal?2:0,0===e?this.compareNonHorizontal_(s,n):1===e?this.compareHorizontal1_(s.m_line,n.m_line):2===e?-1*this.compareHorizontal1_(n.m_line,s.m_line):this.compareHorizontal2_(s.m_line,n.m_line)}if(this.m_bIntersectionDetected)return-1;const r=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let i,o;if(r&&e===this.m_prev1?i=this.m_prevX1:(i=Number.NaN,this.m_prev1=Ae),r&&t===this.m_prev2?o=this.m_prevX2:(o=Number.NaN,this.m_prev2=Ae),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(i)){this.m_prev1=e;const t=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);i=t,this.m_prevX1=t}if(Number.isNaN(o)){this.m_prev2=t;const e=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX2=e}const a=We(!0,!0,s.m_segment,n.m_segment,this.m_tolerance,!0);return 0!==a?2===a?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(n.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(i-o)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):i<o?-1:i>o?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=Ae,this.m_prev2=Ae,this.m_vertex1=Ae,this.m_vertex2=Ae}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=t;return this.m_currentNode=s,this.compareSegments(r,r,n,n)}compareSegments(e,t,s,n){let r=this.tryGetCachedEdge_(e);null===r?this.m_vertex1===t?r=this.m_tempSimpleEdge1:(this.m_vertex1=t,r=this.tryCreateCachedEdge_(e),null===r&&(r=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(r,t)):this.m_vertex1=t;let i=this.tryGetCachedEdge_(s);return null===i?this.m_vertex2===n?i=this.m_tempSimpleEdge2:(this.m_vertex2=n,i=this.tryCreateCachedEdge_(s),null===i&&(i=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(i,n)):this.m_vertex2=n,this.compareSegments_(t,n,r,i)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class an{m_shape;m_bIntersectionDetected=!1;m_pointOfInterest=T.getNAN();m_line1=new Fe;m_seg1=null;m_env=A.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){const s=e.getElement(t);return this.compareVertex(e,t,s)}compareVertex(e,t,s){let n,r=this.m_shape.getSegment(s),i=!0;if(null==r)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),r=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=Wt.constructEmpty();r.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),n=0===e.height(),i=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(n)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let o=0;if(i){Qe(this.m_line1);const e=this.m_line1.getStartXY(),t=new T;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new T;s.setSub(this.m_pointOfInterest,e),o=t.dotProduct(s),o/=t.length()}else{o=r.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x}if(o<10*-this.m_tolerance)return-1;if(o>10*this.m_tolerance)return 1;if(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}return o<0?-1:o>0?1:0}}class mn{m_bitFilter;m_hashBuckets;m_lists=new sn(!1);m_hash;constructor(e,t){this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(mn.st_nullNode()),this.m_bitFilter=new Int32Array(10*e+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=t%this.m_hashBuckets.length;let r=this.m_hashBuckets[n];r===sn.st_nullNode()&&(r=this.m_lists.createList(),this.m_hashBuckets[n]=r);return this.m_lists.addElement(r,e)}deleteElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const n=t%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&s("");let i=this.m_lists.getFirst(r),o=sn.st_nullNode();for(;i!==sn.st_nullNode();){const t=this.m_lists.getData(i),s=this.m_lists.getNext(i);t===e?(this.m_lists.deleteElementDirect(r,o,i),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())):o=i,i=s}}getFirstInBucket(e){const t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(31&t)))return sn.st_nullNode();const s=e%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===sn.st_nullNode()?sn.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){const t=this.m_hash.getHash(e);let s=this.getFirstInBucket(t);for(;s!==sn.st_nullNode();){const t=this.m_lists.getData(s);if(this.m_hash.equal(t,e))return s;s=this.m_lists.getNext(s)}return sn.st_nullNode()}deleteNode(e){const t=this.getElement(e),n=this.m_hash.getHash(t)%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&s(""),this.m_lists.deleteElementSearch(r,e),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return sn.st_nullNode()}clear(){h(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function hn(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=n,i.m_bHasSegmentParentage=e.hasSegmentParentage(),i.clusterNonReciprocal()}function ln(e,t,s,n,r){const i=e-s,o=t-n;return i*i+o*o<=r}function gn(){return{pt:new T,weight:0,rank:0,bMerged:!1}}function un(e,t,s,n,r,i){const o=gn(),a=s+r;let m=!1,h=e.x;e.x!==t.x&&(n===i&&(h=(e.x*s+t.x*r)/a),m=!0);let l=e.y;return e.y!==t.y&&(n===i&&(l=(e.y*s+t.y*r)/a),m=!0),n!==i?n>i?(o.rank=n,o.weight=s,o.pt=e):(o.rank=i,o.weight=r,o.pt=t):(o.pt.setCoords(h,l),o.weight=a,o.rank=n),o.bMerged=m,o}function cn(e,t,s,n,r,i,o,a,m){const h=e.equals(t);if(n>i)return o.assignCopy(e),m[0]=n,a[0]=s,h;if(i>n)return o=t,m[0]=i,a[0]=r,h;o.assignCopy(e);const l=un(e.getXY(),t.getXY(),s,n,r,i);return o.setXY(l.pt),a[0]=l.weight,m[0]=l.rank,h}function _n(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=!1,i.needsClustering()}function dn(e,t){const s=Ee(e);return _e(s,t)}class pn{m_shape;m_sqrTolerance;m_invCellSize;m_origin;m_hashValues;m_workPt=new T;constructor(e,t,s,n,r){this.m_shape=e,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=t.clone(),this.m_hashValues=r}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);const t=this.m_workPt.x-this.m_origin.x,s=Math.trunc(t*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return dn(s,Math.trunc(n*this.m_invCellSize+.5))}equal(e,t){return h(0),!1}}class fn{m_origin=T.getNAN();m_sqrTolerance=0;m_cellSize=0;m_invCellSize=0;m_geometry=Ae;m_bucketArray=N(4,Number.NaN);m_bucketHash=N(4,Number.NaN);m_dbgCandidateCheckCount=0;m_progressTracker;m_nsr=new ts;m_hashValues=-1;m_newClusters=-1;m_bTrackChanges=!1;m_bHasSegmentParentage=!1;m_shape=null;m_clusters=new sn;m_hashFunction=null;m_hashTable=null;m_progressCounter=0;constructor(e){this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){const s=T.getNAN();this.m_shape.queryXY(e,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,r=(s.y-this.m_origin.y)*this.m_invCellSize,i=Math.trunc(n),o=Math.trunc(r);let a=0;for(let m=0;m<=1;m+=1)for(let e=0;e<=1;e+=1){const t=dn(i+m,o+e),s=this.m_hashTable.getFirstInBucket(t);s!==mn.st_nullNode()&&(this.m_bucketArray[a]=s,this.m_bucketHash[a]=t,a++)}for(let m=a-1;m>=1;m--){const e=this.m_bucketArray[m];for(let t=m-1;t>=0;t--)if(e===this.m_bucketArray[t]){this.m_bucketHash[t]=-1,a--,m!==a&&(this.m_bucketHash[m]=this.m_bucketHash[a],this.m_bucketArray[m]=this.m_bucketArray[a]);break}}for(let m=0;m<a;m++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[m],s,this.m_bucketArray[m],t)}collectNearestNeighbourCandidates(e,t,s,n,r){const i=T.getNAN();for(let o=n;o!==mn.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);e===n||-1!==t&&this.m_shape.getUserIndex(n,this.m_hashValues)!==t||(this.m_shape.queryXY(n,i),ln(s.x,s.y,i.x,i.y,this.m_sqrTolerance)&&r.push(o))}}mergeClusters(e,t,s){let n=this.m_shape.getUserIndex(e,this.m_newClusters);const r=this.m_shape.getUserIndex(t,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,e),this.m_shape.setUserIndex(e,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,t):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(t,this.m_newClusters,Rt.impossibleIndex2());const i=this.mergeVertices(e,t);if(s){const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return i}mergeVertices(e,t){const s=T.getNAN();this.m_shape.queryXY(e,s);const n=T.getNAN();this.m_shape.queryXY(t,n);const r=this.m_shape.getRank(e),i=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),a=this.m_shape.getWeight(t);let m,h,l,g,u=!1;if(r===i?(m=r,h=o+a,l=s.x,s.x!==n.x&&(l=(s.x*o+n.x*a)/h,u=!0),g=s.y,s.y!==n.y&&(g=(s.y*o+n.y*a)/h,u=!0)):(r>i?(l=s.x,g=s.y,h=o,m=r):(l=n.x,g=n.y,h=a,m=i),u=!s.equals(n)),u&&(this.m_shape.setXYMonotonic(e,l,g),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,s),this.m_shape.setSegmentParentageBreakVertex(t,s)}return this.m_shape.setWeight(e,h),this.m_shape.setRank(e,m),u}needsClustering(){const s={stack:[],error:void 0,hasError:!1};try{e(s,ie(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);const t=this.m_shape.getSelectedCount(),n=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(n.getLowerLeft());const r=Math.max(n.height(),n.width())/(re()-1);this.m_cellSize<r&&(this.m_cellSize=r,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(this.m_shape.getSelectedCount()/3+1),this.m_clusters.reserveNodes(this.m_shape.getSelectedCount()/3+1),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new mn(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==Ae;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===Rt.impossibleIndex2())continue;let s;if(0===e?(s=this.m_hashFunction.calculateHashFromVertex(n),this.m_shape.setUserIndex(n,this.m_hashValues,s)):s=this.m_shape.getUserIndex(n,this.m_hashValues),this.collectClusterCandidates(n,t),0!==t.length){for(let e=0,s=t.length;e<s;e++){this.progress_();const s=t[e],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new ts(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return i}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}clusterNonReciprocal(){const e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();const s=Math.max(t.height(),t.width())/(re()-1);this.m_cellSize<s&&(this.m_cellSize=s,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_clusters.reserveNodes(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new mn(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==Ae;t=e.next()){this.progress_();const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{const e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=t.next();s!==Ae;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===Rt.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,t);let r=!1;for(;this.collectClusterCandidates(s,e),0!==e.length;){let t=0;for(let n=0,r=e.length;n<r;n++){this.progress_();const i=e[n],o=this.m_hashTable.getElement(i);this.m_hashTable.deleteNode(i);const a=n+1===r;t|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==t,n||=0!==t,e.length=0,!t)break}r&&(t=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,t)}e.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const e=T.getNAN();for(let t=this.m_clusters.getFirstList();t!==sn.st_nullNode();t=this.m_clusters.getNextList(t)){let s=this.m_clusters.getFirst(t);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,e);const r=this.m_shape.getRank(n),i=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==sn.st_nullNode();s=this.m_clusters.getNext(s)){const t=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(n,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,i),this.m_shape.setRank(t,r)}}}}class xn{static maxWeight=.1*Number.MAX_VALUE;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 pt;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,s,n,r,i,o,a,m,h){return Pn(e,t,s,n,r,i,o,a,m,h)}pushSegment(e,t,s,n,r,i,o,a,m,h){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,s,n,r,i,o,a,m,h)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?0===e?this.m_param1.length-1:this.m_param2.length-1:0===e?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return 0===e?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return 0===e?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){2!==this.m_inputSegments.length&&o(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=L(e*xn.c_smallToleranceFactor);let n=!1;const r=this.m_inputParts[0],i=this.m_inputParts[1],a=this.m_inputSegments[r.segmentIndex],m=this.m_inputSegments[i.segmentIndex];if(t||5&Me(!0,a,m,e,!0)){const t=je(!0,a,m,null,this.m_param1,this.m_param2,e);0===t&&o("");const h=new Array(t);for(let e=0;e<t;++e)h[e]=T.getNAN();const l=new Float64Array(t),g=new Int32Array(t),u=new Array(t),c=new Array(t);for(let e=0;e<t;++e)u[e]=En(),c[e]=En();for(let e=0;e<t;e++){const t=this.m_param1[e],o=this.m_param2[e];let _,d=r.rankInterior,p=r.weightInterior;0===t?(d=r.rankStart,p=r.weightStart,_=r.u.bBreakStart):1===t?(d=r.rankEnd,p=r.weightEnd,_=r.u.bBreakEnd):(this.m_changed1=!0,_=!1);let f,x=i.rankInterior,y=i.weightInterior;0===o?(x=i.rankStart,y=i.weightStart,f=i.u.bBreakStart):1===o?(x=i.rankEnd,y=i.weightEnd,f=i.u.bBreakEnd):(this.m_changed2=!0,f=!1);const P=d,E=x;let S=1,C=0,I=T.getNAN();if(P===E){const n=a.getCoord2D(t),r=m.getCoord2D(o);S=p+y;C=d,J(n,r,y/S,I);const i=T.sqrDistance(I,n),h=T.sqrDistance(I,r);u[e].bBigMove=i>s,c[e].bBigMove=h>s,this.m_changed1||n.equals(I)||(this.m_changed1=!0),this.m_changed2||r.equals(I)||(this.m_changed2=!0)}else if(P>E){I=a.getCoord2D(t);const n=m.getCoord2D(o);S=p,C=d;const r=T.sqrDistance(I,n);u[e].bBigMove=!1,c[e].bBigMove=r>s,this.m_changed2||n.equals(I)||(this.m_changed2=!0)}else{I=m.getCoord2D(o),S=y,C=x;const n=a.getCoord2D(t),r=T.sqrDistance(I,n);u[e].bBigMove=r>s,c[e].bBigMove=!1,this.m_changed1||n.equals(I)||(this.m_changed1=!0)}h[e].assign(I),l[e]=S,g[e]=C,u[e].bIsBreak=_||f,c[e].bIsBreak=_||f,n||=u[e].bBigMove||c[e].bBigMove}const _=r.rankInterior,d=r.weightInterior;let p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param1[s]:1;if(n!==p){const i=this.allocResultSegment(),o=this.m_resultSegments[i];let m,c,x,y;a.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let P=!1,E=!1,S=!1,C=!1,I=!1,b=T.getNAN(),w=T.getNAN();-1!==f?(c=g[f],m=l[f],P=u[f].bBigMove,b.assign(h[f]),S=u[f].bIsBreak,I=!0):(m=r.weightStart,c=r.rankStart,b=o.get().getStartXY(),S=r.u.bBreakStart),s<t?(y=g[s],x=l[s],E=u[s].bBigMove,w.assign(h[s]),C=u[s].bIsBreak,I=!0):(x=r.weightEnd,y=r.rankEnd,w=o.get().getEndXY(),C=r.u.bBreakEnd),I&&o.get().setCoordsForIntersector(b,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,m,c,x,y,d,_,S,C,r.segmentParentage));const v=this.m_resultParts1.at(-1);v.u.bBigMoveStart=P,v.u.bBigMoveEnd=E,p=n,f=s}else-1===f&&(f=s)}const x=N(t,0);for(let e=0;e<t;e++)x[e]=e;t>2?(x.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:this.m_param2[e]>this.m_param2[t]?1:0),D(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=M(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),x[1]=M(x[0],x[0]=x[1]));const y=i.rankInterior,P=i.weightInterior;p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param2[s]:1;if(n!==p){const r=this.allocResultSegment(),o=this.m_resultSegments[r];let a,u,_,d;m.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let E=T.getNAN(),S=T.getNAN(),C=!1,I=!1,b=!1,w=!1,v=!1;if(-1!==f){const e=x[f];a=l[e],u=g[e],E.assign(h[e]),b=c[e].bBigMove,C=c[e].bIsBreak,v=!0}else a=i.weightStart,u=i.rankStart,E=o.get().getStartXY(),C=i.u.bBreakStart;if(s!==t){const e=x[s];_=l[e],d=g[e],S.assign(h[e]),w=c[e].bBigMove,I=c[e].bIsBreak,v=!0}else _=i.weightEnd,d=i.rankEnd,S=o.get().getEndXY(),I=i.u.bBreakEnd;v&&o.get().setCoordsForIntersector(E,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,a,u,_,d,P,y,C,I,i.segmentParentage));const N=this.m_resultParts2.at(-1);N.u.bBigMoveStart=b,N.u.bBigMoveEnd=w,p=n,f=s}else-1===f&&(f=s)}return n?3:2}return 0}intersectLines3D(e,t,s,n){return h(0),1}intersect2D(e,t){const s=this.m_inputParts[0],n=this.m_inputParts[1],i=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[n.segmentIndex].getGeometryType();if(i!==r.enumLine||o!==r.enumLine){return new bn(this).intersectCurves(e,t)}return this.intersectLines(e,t)}intersect2DEx(e,t,s,n,r){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&o(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const i=L(e*xn.c_smallToleranceFactor);let a=!1;const m=this.m_inputParts[0],h=this.m_inputSegments[m.segmentIndex];if(r||h.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=N(16,Number.NaN);const r=h.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let o=m.rankInterior,l=m.weightInterior;0===r?(o=m.rankStart,l=m.weightStart):1===r?(o=m.rankEnd,l=m.weightEnd):this.m_changed1=!0;let g=o;const u=s,c=n;g===u&&h.isCurve()&&(g=u+1);let _=1,d=0;const p=new T;if(g===u){const e=h.getCoord2D(r),s=t.getXY();_=l+c,d=o;J(e,s,c/_,p),this.m_changed1||e.equals(p)||(this.m_changed1=!0),this.m_changed2||s.equals(p)||(this.m_changed2=!0);a=T.sqrDistance(p,e)>i}else if(g>u)p.assign(h.getCoord2D(r)),_=l,d=o,this.m_changed2||p.equals(t.getXY())||(this.m_changed2=!0);else{p.assign(h.getCoord2D(r)),_=c,d=u,this.m_changed1||p.equals(t.getXY())||(this.m_changed1=!0);a=T.sqrDistance(p,t.getXY())>i}let f=0,x=-1;const y=1;for(let t=0;t<=y;t++){const s=t<y?this.m_param1[0]:1;if(s!==f){const n=this.allocResultSegment(),r=this.m_resultSegments[n];h.queryCut(f,s,r),r.get().snapControlPoints(e*e);let i=m.weightStart,o=m.weightEnd,a=m.rankStart,l=m.rankEnd;const g=m.rankInterior,u=m.weightInterior;let c=m.u.bBreakStart,P=m.u.bBreakEnd;-1!==x&&(i=_,a=d,c=!0,r.get().setCoordsForIntersector(p,r.get().getEndXY(),!0)),t!==y&&(o=_,l=d,P=!0,r.get().setCoordsForIntersector(r.get().getStartXY(),p,!0)),f=s,this.m_resultParts1.push(this.newIntersectionPart_(n,i,a,o,l,u,g,c,P,m.segmentParentage))}x=t}return this.m_point.setXY(p),this.m_pointWeight=_,this.m_pointRank=d,a?3:2}return 0}intersect3D(e,t,s,n){return h(0),1}intersect3DEx(e,t,s,n,r,i,o){return h(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const e=new Ve,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new Ve({copy:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new Ve({segment:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}}function yn(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function Pn(e,t,s,n,r,i,o,a,m,h){return{segmentIndex:e,weightStart:t,rankStart:s,weightEnd:n,rankEnd:r,weightInterior:i,rankInterior:o,segmentParentage:h,u:yn(a,m)}}function En(){return{bBigMove:!1,bIsBreak:!1}}let Sn=class{start=null;end=null;equalEdge=null;segmentIndex=-1;segmentParentage=-1;weight=0;rank=0;hasSegment(){return this.segmentIndex>=0}transferAttributes(e,t,s){if(1===t.getDescription().getAttributeCount())return;const n=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),i=new pt;t.queryStart(i),s?(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i)):(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)),t.queryEnd(i),s?(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)):(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i))}copyFromWhenOverlap(e,t,s){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,s?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class Cn{hash=0;pt=new T;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(;null!==e.prevEqual;e=e.prevEqual);return e}}function In(e,t,s,n){return{edge1:e,edge2:t,recursion:s,bIsIntersecting:n}}class bn{parent;m_pairs=[];m_chainOrigin1=null;m_chainOrigin2=null;m_newNodes=[];m_hashTableOfEquals=[];m_hashTableOfEqualsSize=0;m_origin=new T;m_cell=new T;constructor(e){this.parent=e}addSegment(e,t,s,n,r,i,o,a,m,l,g){const u=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,m),c=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,i,l);this.newEdge(u,c,e,o,a,g),null===this.m_chainOrigin1?this.m_chainOrigin1=u:null===this.m_chainOrigin2?this.m_chainOrigin2=u:h(0)}intersectCurvesHelper(e,t,s,n,i){const a=this.getSegment(e).get(),m=this.getSegment(t).get();if(a.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(e,t,s,n);if(0!==l)return l;const g=L(.01*s);let u=!1,c=this.processSharpCorners(a,m,s,i>4);const _=c>0;if(!_){if(!(n||5&We(!0,!1,a,m,s,!0)))return 0;c=je(!0,a,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===c&&o("");const d=a.getGeometryType(),p=m.getGeometryType(),f=B(T,c),x=B(T,c),y=N(c,Number.NaN),P=N(c,Number.NaN),E=N(c,Number.NaN),S=N(c,Number.NaN),C=oe(En,c),I=oe(En,c);let b=!1,w=!1;for(let r=0;r<c;r++){const n=this.parent.m_param1[r],i=this.parent.m_param2[r];let o=e.rank,h=e.weight,l=!0,c=!1;0===n?(o=e.start.rank,h=e.start.weight,c=e.start.bIsBreak):1===n?(o=e.end.rank,h=e.end.weight,c=e.end.bIsBreak):(b=!0,l=!1);let v=t.rank,N=t.weight,G=!1,D=!0;0===i?(v=t.start.rank,N=t.start.weight,G=t.start.bIsBreak):1===i?(v=t.end.rank,N=t.end.weight,G=t.end.bIsBreak):(w=!0,D=!1);let V=o,F=v;if(V===F&&(V*=xn.c_maxGeometryTypeToRankDelta,F*=xn.c_maxGeometryTypeToRankDelta,V+=wn(d,a,!1),F+=wn(p,m,!1)),l&&D&&F===V){const e=a.getCoord2D(n),t=m.getCoord2D(i);e.equals(t)&&(F=V-1)}let k=1,H=0,A=1,M=0;const U=new T,q=new T,B=a.getCoord2D(n),O=m.getCoord2D(i);if(_&&T.distance(B,O)>s)U.setCoordsPoint2D(B),q.setCoordsPoint2D(O),k=h,A=N,H=o,M=v,C[r].bBigMove=!1,I[r].bBigMove=!1,c=!0,G=!0;else if(V===F){A=k=h+N,M=H=o;J(B,O,N/k,U),q.setCoordsPoint2D(U);const e=T.sqrDistance(U,B),t=T.sqrDistance(U,O);C[r].bBigMove=e>g,I[r].bBigMove=t>g,b||B.equals(U)||(b=!0),w||O.equals(q)||(w=!0)}else if(V>F){U.setCoordsPoint2D(B),q.setCoordsPoint2D(U),A=k=h,M=H=o;const e=T.sqrDistance(U,O);C[r].bBigMove=!1,I[r].bBigMove=e>g,w||O.equals(q)||(w=!0)}else{q.setCoordsPoint2D(O),U.setCoordsPoint2D(q),A=k=N,M=H=v;const e=T.sqrDistance(U,B);C[r].bBigMove=e>g,I[r].bBigMove=!1,b||B.equals(U)||(b=!0)}f[r].assign(U),x[r].assign(q),y[r]=k,P[r]=A,E[r]=H,S[r]=M,C[r].bIsBreak=c||G,I[r].bIsBreak=c||G,u||=C[r].bBigMove||I[r].bBigMove,r>0&&(n!==this.parent.m_param1[r-1]&&i!==this.parent.m_param2[r-1]||(E[r]<=E[r-1]?(f[r].assign(x[r-1]),y[r]=P[r-1],E[r]=S[r-1],x[r].assign(x[r-1]),P[r]=P[r-1],S[r]=S[r-1],C[r].bBigMove||=C[r-1].bBigMove,I[r].bBigMove||=I[r-1].bBigMove,C[r].bIsBreak||=C[r-1].bIsBreak,I[r].bIsBreak||=I[r-1].bIsBreak):(f[r-1].assign(f[r]),y[r-1]=y[r],E[r-1]=E[r],x[r-1].assign(x[r]),P[r-1]=P[r],S[r-1]=S[r],C[r-1].bBigMove||=C[r].bBigMove,I[r-1].bBigMove||=I[r].bBigMove,C[r-1].bIsBreak||=C[r].bIsBreak,I[r-1].bIsBreak||=I[r].bIsBreak)))}if(!(b||w||2!==c||d===r.enumLine&&p===r.enumLine)){if(this.processDoublyConnectedEdges(e,t,i+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;h(0)}this.parent.m_changed1||=b,this.parent.m_changed2||=w;let v=e,G=e.end.weight,D=e.end.rank,V=e.end.bBigMove,F=e.end.bIsBreak,k=0,H=-1;for(let r=0;r<=c;r++){const t=r<c?this.parent.m_param1[r]:1;if(t!==k){const n=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[n];let o,m,h,l;a.queryCut(k,t,i,!1),i.get().snapControlPoints(s*s);let g=!1,u=!1,_=!1,d=!1;const p=new T,x=new T;-1!==H?(m=E[H],o=y[H],_=C[H].bBigMove,g=C[H].bIsBreak,p.assign(f[H])):(o=e.start.weight,m=e.start.rank,_=e.start.bBigMove,g=e.start.bIsBreak,p.assign(i.get().getStartXY())),r<c?(l=E[r],h=y[r],d=C[r].bBigMove,u=C[r].bIsBreak,x.assign(f[r])):(h=G,l=D,d=V,u=F,x.assign(i.get().getEndXY()));let P=v;t<1&&(this.splitEdgeInPlace(v),P=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(p)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(x)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(p),v.end.pt.assign(x),v.start.bBigMove||=_,v.end.bBigMove||=d,v.start.bIsBreak||=g,v.end.bIsBreak||=u,v.start.weight=o,v.start.rank=m,v.end.weight=h,v.end.rank=l,v=P,k=t,H=r}else-1===H&&(H=r)}const A=v.getNextInChain(),U=[];U.length=c;for(let r=0;r<c;r++)U[r]=r;c>2?(U.sort((e,t)=>ae(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(ae)):2===c&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=M(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),U[1]=M(U[0],U[0]=U[1])),v=t,G=t.end.weight,D=t.end.rank,V=t.end.bBigMove,F=t.end.bIsBreak,k=0,H=-1;for(let r=0;r<=c;r++){const e=r<c?this.parent.m_param2[r]:1;if(e!==k){const n=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[n];let o,a,h,l;m.queryCut(k,e,i,!1),i.get().snapControlPoints(s*s);const g=new T,u=new T;let _=!1,d=!1,p=!1,f=!1;if(-1!==H){const e=U[H];o=P[e],a=S[e],g.assign(x[e]),p=I[e].bBigMove,_=I[e].bIsBreak}else o=t.start.weight,a=t.start.rank,p=t.start.bBigMove,_=t.start.bIsBreak,g.assign(i.get().getStartXY());if(r!==c){const e=U[r];h=P[e],l=S[e],u.assign(x[e]),f=I[e].bBigMove,d=I[e].bIsBreak}else h=G,l=D,f=V,d=F,u.assign(i.get().getEndXY());let y=v;e<1&&(this.splitEdgeInPlace(v),y=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(g)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(u)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(g),v.end.pt.assign(u),v.start.bBigMove||=p,v.end.bBigMove||=f,v.start.bIsBreak||=_,v.end.bIsBreak||=d,v.start.weight=o,v.start.rank=a,v.end.weight=h,v.end.rank=l,v=y,k=e,H=r}else-1===H&&(H=r)}const q=v.getNextInChain();return this.postProcessResultPartsForCurves(e,A,t,q,i+1),u?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&o(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=G(16);const s=Wt.constructEmpty();for(let i=0;i<2;i++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[i].segmentIndex]),t=Wt.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[i].segmentIndex].queryLooseEnvelope(t),s.mergeEnvelope2D(t);const n=this.parent.m_inputParts[i];this.addSegment(e,0,n.weightStart,n.rankStart,n.weightEnd,n.rankEnd,n.weightInterior,n.rankInterior,n.u.bBreakStart,n.u.bBreakEnd,n.segmentParentage)}s.inflateCoords(100*e,100*e),this.m_origin.assign(s.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(In(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let n=0,r=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),h(t.recursion>=0),h(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);r&&(r=!1,n=s)}for(let i=0;i<2;i++){const e=0===i?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let t=(0===i?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=t;t=t.getNextInChain())e.push(this.parent.newIntersectionPart_(t.segmentIndex,t.start.weight,t.start.rank,t.end.weight,t.end.rank,t.weight,t.rank,t.start.bIsBreak,t.end.bIsBreak,t.segmentParentage)),e.at(-1).u.bBigMoveStart=t.start.bBigMove,e.at(-1).u.bBigMoveEnd=t.end.bBigMove}return n}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),i=this.parent.m_resultSegments[t.segmentIndex].get(),o=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY()),a=r.getStartXY().equals(i.getEndXY())&&r.getEndXY().equals(i.getStartXY());if(!o&&!a)return 0;const m=Je(r,i,!0);if(0!==m&&$e(r,i)&&e.segmentParentage===t.segmentParentage){let e=!1;if(m>0)e=r.equals(i);else{h(-1===m);const t=new Ve({segment:i});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const l=s*xn.c_smallToleranceFactor;let g=!1;if(0===m){const e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new T;r.queryCoord2D(n,o);const a=i.getClosestCoordinate(o,!1),m=new T;i.queryCoord2D(a,m);const h=T.distance(o,m);if(h>s)return 0;g||=h>l}for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new T;i.queryCoord2D(n,o);const a=r.getClosestCoordinate(o,!1),m=new T;r.queryCoord2D(a,m);const h=T.distance(o,m);if(h>s)return 0;g||=h>l}}let u=e.rank,c=t.rank;return u===c&&(u*=xn.c_maxGeometryTypeToRankDelta,c*=xn.c_maxGeometryTypeToRankDelta,u+=wn(r.getGeometryType(),r,!0),c+=wn(i.getGeometryType(),i,!0)),u>c?(t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):c>u?(e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)),g?3:2}postProcessResultPartsForCurves(e,t,s,n,r){r===me()&&o("curve_helper");for(let i=e;i!==t;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=s;i!==n;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=e;i!==t;i=i.getNextInChain()){const e=i.end.pt.sub(i.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(i.start.pt.equals(t.start.pt)&&i.end.pt.equals(t.end.pt)?s=1:i.start.pt.equals(t.end.pt)&&i.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=i.start.pt.equals(t.start.pt)?1:0;if(s||(s=i.end.pt.equals(t.end.pt)?2:0,s||(s=i.end.pt.equals(t.start.pt)?3:0,s||(s=i.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),a=e.dotProduct(n);let m;switch(s){case 1:case 2:m=a>0;break;case 3:case 4:m=a<0;break;default:o("post_process_result_parts_for_curves_")}m&&this.m_pairs.push(In(i,t,r,!1))}continue}const n=this.parent.m_resultSegments[i.segmentIndex],a=this.parent.m_resultSegments[t.segmentIndex],m=[.5,.25,.75];for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new T;n.get().queryCoord2D(t,r);const i=a.get().getClosestCoordinate(r,!1),o=new T;a.get().queryCoord2D(i,o);if(T.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}for(let e=0,t=m.length;e<t;++e){const t=m[e],r=new T;a.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),o=new T;n.get().queryCoord2D(i,o);if(T.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}i.equalEdge=t,t.equalEdge=i;let h=i.rank,l=t.rank;h===l&&(h*=xn.c_maxGeometryTypeToRankDelta,l*=xn.c_maxGeometryTypeToRankDelta,h+=wn(n.get().getGeometryType(),n.get(),!0),l+=wn(a.get().getGeometryType(),a.get(),!0)),h>l||h===l&&i.segmentParentage<=t.segmentParentage?(n.copyTo(a,!1),t.segmentParentage=i.segmentParentage,-1===s&&a.get().reverse()):(a.copyTo(n,!1),i.segmentParentage=t.segmentParentage,-1===s&&n.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(s.start),n&&this.updateAttachedEdgesAfterNodeChange(n.start)}processDoublyConnectedEdges(e,t,s,n){s===me()&&o("curve_helper");const r=this.getSegment(e).get(),i=this.getSegment(t).get(),a=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY())?1:r.getEndXY().equals(i.getStartXY())&&r.getStartXY().equals(i.getEndXY())?-1:0;if(0!==a){const o=new Ve;r.queryCut(0,.5,o),o.get().snapControlPoints(n*n);const m=new Ve;r.queryCut(.5,1,m),m.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=o.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(m);let h=i.getClosestCoordinate(e.end.pt,!1);return Math.abs(h-.5)>.2&&(h=.5),i.queryCut(0,h,o),o.get().snapControlPoints(n*n),i.queryCut(h,1,m),m.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=o.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(o),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(m),a>0?(this.m_pairs.push(In(e,t,s,!1)),this.m_pairs.push(In(e.getNextInChain(),t.getNextInChain(),s,!1))):(this.m_pairs.push(In(e,t.getNextInChain(),s,!1)),this.m_pairs.push(In(e.getNextInChain(),t,s,!1))),!0}return!1}newNode(e,t,s,n){const r=new Cn;return this.m_newNodes.push(r),r.pt=e,r.rank=s,r.weight=t,r.bIsBreak=n,r}newEdge(e,t,s,n,r,i){const o=new Sn;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=s,o.segmentParentage=i,o.rank=r,o.weight=n,o}splitEdgeInPlace(e){e.segmentIndex=-1;const t=new Sn,s=new Cn;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=t,s.prevInChain=e,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=e.weight,s.rank=e.rank,s.bIsBreak=!1,s.bBigMove=!1,t.start=s,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=s,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();null!==t;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){const t=e.prevInChain;if(t&&t.hasSegment()){const s=this.getSegment(t).get();e.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(t.start.pt,t.end.pt,!1),s.ensureXYMonotone())}const s=e.nextInChain;if(s&&s.hasSegment()){const t=this.getSegment(s).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(s.start.pt,s.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){const t=this.getSegment(e).get();e.start.pt.equals(t.getStartXY())&&e.end.pt.equals(t.getEndXY())||(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1;const s=[],n=[],r=[];for(let i=0,o=this.m_newNodes.length;i<o;i++){const e=this.m_newNodes[i];if(null===e)continue;let t=e;for(let s=i+1;s<o;s++){const n=this.m_newNodes[s];null!==n&&(e.pt.equals(n.pt)&&(t.nextInHash=n,n.prevInHash=t,t=n,this.m_newNodes[s]=null))}}for(let i=0,o=this.m_newNodes.length;i<o;i++){const o=this.m_newNodes[i];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const i=G(4),a=this.hashTableBinsToCheck(o,i);for(let t=0;t<a;t++)if(null!==i[t])for(let a=i[t];null!==a;){const t=a.nextInHash;T.distance(o.pt,a.pt)<=e&&(s.push(a),this.removeNodeFromHash(a),a.hash=0,r.push(a),n.push(a)),a=t}let m=!1;for(const e of s)if(!o.pt.equals(e.pt)){const s=un(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,m=!0,t=!0}if(s.length=0,!m)break;o.hash=this.calculateHash(o.pt)}r.push(o),n.push(o);for(let e=o.nextInHash;null!==e;){e.prevInHash=null;const t=e.nextInHash;e.nextInHash=null,r.push(e),n.push(e),e=t}const a=o.hash;let m=null,h=null;for(const e of n)o!==e&&(e.hash=a,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=m,m&&(m.nextInHash=e),e.prevEqual=h,e.nextEqual=null,h&&(h.nextEqual=e),h=e,m=e;const l=a%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[l],null!==this.m_hashTableOfEquals[l]&&(this.m_hashTableOfEquals[l].prevInHash=m),this.m_hashTableOfEquals[l]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(const i of r)this.updateAttachedEdgesAfterNodeChange(i)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=G(2*e.length),this.m_hashTableOfEqualsSize=0;for(const t of e){let e=t;for(;e;){const t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){const t=e.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[t];e.nextInHash=s,null!==s&&(s.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){const t=e.hash%this.m_hashTableOfEquals.length,s=e.prevInHash,n=e.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[t]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){const s=(e.pt.x-this.m_origin.x)/this.m_cell.x,n=(e.pt.y-this.m_origin.y)/this.m_cell.y,r=re()-1,i=Math.round(Z(s,-r,r)),o=Math.round(Z(n,-r,r));let a=i|o<<32;a=w(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let m=i+1|o<<32;m=w(m);let h=1;t[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(h=2);let l=i+1|o+1<<32;l=w(l),t[h]=this.m_hashTableOfEquals[l%this.m_hashTableOfEquals.length];for(let u=0;u<h;u++)if(t[h]===t[u]){h--;break}h++;let g=i|o+1<<32;g=w(g),t[h]=this.m_hashTableOfEquals[g%this.m_hashTableOfEquals.length];for(let u=0;u<h;u++)if(t[h]===t[u]){h--;break}return h++,h}calculateHash(e){const t=(e.x-this.m_origin.x)/this.m_cell.x,s=(e.y-this.m_origin.y)/this.m_cell.y,n=re()-1;let r=Math.round(Z(t,-n,n))|Math.round(Z(s,-n,n))<<32;return r=w(r),0===r&&(r=1),r}processSharpCorners(e,t,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=et(e,t,0,0,s,2,r,i,n);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(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=et(e,t,1,1,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),o+1}}if(e.getStartXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=et(e,t,0,1,s,2,r,i,n);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(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=et(e,t,1,0,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),o+1}}return 0}}function wn(e,t,s){let n=0;switch(e){case r.enumLine:n=0;break;case r.enumBezier:n=2;break;case r.enumRationalBezier2:n=3;break;case r.enumBezier2:n=1;break;case r.enumEllipticArc:n=0===t.projectionBehavior()?5:4;break;default:o("")}return s?5-n:n}class vn extends on{m_parent;constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=this.m_parent.getEdgeOriginVertices(t),i=this.m_parent.m_edgeVertices.getFirstElement(r),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(t,i,n,a)}}class Nn extends an{m_parent;constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;const s=e.getElement(t),n=this.m_parent.getEdgeOriginVertices(s),r=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=t,this.compareVertex(e,t,r)}}class Tn extends Xt{m_shape;pt1=T.getNAN();pt2=T.getNAN();constructor(e){super(),this.m_shape=e}compare(e,t,s){this.m_shape.queryXY(t,this.pt1);const n=e.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class Gn{m_shape;m_point=T.getNAN();m_pt=T.getNAN();constructor(e){this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){const s=e.getElement(t);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Dn{m_shape=null;m_progressTracker=null;m_edges=new Rt(8);m_clusters=new Rt(5);m_clusterVertices=new sn(!1);m_edgeVertices=new sn(!1);m_helperPoint=new pt;m_eventQ=new Pt;m_sweepStructure=new Pt;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 xn;m_segBuf1=new Ve;m_segBuf2=new Ve;m_sweepPoint=new T(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){const s=new jt;s.setSwapCoordinates(),e.applyTransformation(s),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let n=this.sweepImpl_();return e.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,Ae);this.m_bComplications=1===n,s||=1===n}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,s){this.m_edges.setField(e,0+t,s)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,s){this.m_edges.setField(e,3+t,s)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+s)}setNextEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+n,s)}getPrevEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+s)}setPrevEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+n,s)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){const t=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(t,s),e!==Ae&&(this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){const s=this.getClusterVertices(e);this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){const t=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,s),-1!==e&&this.m_edgeVertices.addElement(s,e),t}addVertexToEdge_(e,t){const s=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(s,t)}deleteEdge_(e){this.m_edges.deleteElement(e);const t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&W(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){-1===this.getEdgeCluster(e,0)?this.setEdgeCluster_(e,0,t):-1===this.getEdgeCluster(e,1)?this.setEdgeCluster_(e,1,t):o(""),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){const s=this.getClusterFirstEdge(t);if(-1!==s){const n=this.getNextEdge(s,t);this.setPrevEdge_(n,t,e),this.setNextEdge_(e,t,n),this.setNextEdge_(s,t,e),this.setPrevEdge_(e,t,s)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);const s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1));let n=this.getClusterFirstEdge(e),r=this.getClusterFirstEdge(t);if(-1!==r){let s=r,i=r,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,t),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===e){this.disconnectEdge_(s);const e=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(s),s===a){r=-1;break}r===s&&(r=this.getClusterFirstEdge(t),i=a,o=!0)}s=a}while(s!==i||o);if(-1!==r){do{const n=this.getEdgeEnd(s,t),r=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,e),s=r}while(s!==i);if(n=this.getClusterFirstEdge(e),-1!==n){const t=this.getNextEdge(n,e),s=this.getNextEdge(r,e);t===n?(this.setClusterFirstEdge_(e,r),this.addEdgeToClusterImpl_(n,e),this.setClusterFirstEdge_(e,n)):s===r&&this.addEdgeToClusterImpl_(r,e),this.setNextEdge_(r,e,t),this.setPrevEdge_(t,e,r),this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n)}else this.setClusterFirstEdge_(e,r)}}const i=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let a=this.m_clusterVertices.getFirst(o);-1!==a;a=this.m_clusterVertices.getNext(a)){const t=this.m_clusterVertices.getElement(a);this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(i,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);const s=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),a=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,a),t===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,e),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(s===r&&n===i||n===r&&s===i)){const e=this.getClusterXY(s),t=this.getClusterXY(r);e.isEqualPoint2D(t)?(s!==r&&this.mergeClusters_(s,r),n!==i&&this.mergeClusters_(n,i)):(n!==r&&this.mergeClusters_(n,r),s!==i&&this.mergeClusters_(s,i))}this.dbgCheckEdge_(e)}disconnectEdge_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,s)}disconnectEdgeFromCluster_(e,t){const s=this.getNextEdge(e,t),n=this.getPrevEdge(e,t),r=this.getClusterFirstEdge(t);s!==e?(this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n),r===e&&this.setClusterFirstEdge_(t,s)):this.setClusterFirstEdge_(t,-1)}applyIntersectorToEditShape_(e,t,s){let n=this.m_edgeVertices.getFirst(e);const r=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(r),o=this.m_shape.getNextVertex(r),a=this.getClusterFromVertex(o),m=this.m_shape.getXY(r),h=this.m_shape.getXY(o);let l=!1,g=!1;const u=t.getResultSegment(s,0).getStartXY(),c=t.getResultSegment(s,t.getResultSegmentCount(s)-1).getEndXY();m.equals(u)||(l=!0),h.equals(c)||(g=!0),this.m_shape.splitSegmentWithIntersector(r,t,s,!0,!0);const _=this.m_bTrackChanges&&t.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(r,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const e=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(e)===i;this.m_shape.splitSegmentWithIntersector(e,t,s,r,!0),_&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(l&&this.updateClusterXY(!0,i,u,t.getResultSegmentStartPointWeight(s,0),t.getResultSegmentStartPointRank(s,0)),g){const e=t.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,c,t.getResultSegmentEndPointWeight(s,e),t.getResultSegmentEndPointRank(s,e))}}createEdgesAndClustersFromSplitEdge_(e,t,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(e),r=this.getEdgeCluster(e,0),i=this.getEdgeCluster(e,1);let o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);const a=Rt.impossibleIndex3();this.setEdgeSweepNode_(o,a),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,r);const m=t.getResultSegmentCount(s);for(let h=1;h<m;h++){const e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);const t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,a),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,i);for(let h=this.m_edgeVertices.getFirst(n);-1!==h;h=this.m_edgeVertices.getNext(h)){let e=this.m_edgeVertices.getElement(h);if(this.getClusterFromVertex(e)===r){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,s){const n=this.getEdgeCluster(t,0),r=this.getClusterXY(n),i=this.getEdgeCluster(t,1),o=this.getClusterXY(i),a=s.getResultSegmentCount(e);let m=s.getResultSegment(e,0);const h=m.getStartXY();if(!r.isEqualPoint2D(h)){if(!this.m_bComplications){r.compare(this.m_sweepPoint)*h.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)}if(!this.m_bComplications&&a>1){const e=r.compare(o),t=m.getEndXY();(r.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(e,a-1);const l=m.getEndXY();if(!o.isEqualPoint2D(l)){if(!this.m_bComplications){o.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(i,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(i)}this.m_tempEdgeBuffer.push(t);for(let g=0,u=this.m_tempEdgeBuffer.length;g<u;g++){const e=this.m_tempEdgeBuffer[g],s=this.getEdgeSweepNode(e);Rt.isValidElement(s)&&(this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(e,-1));const n=Rt.impossibleIndex3();e!==t&&this.getEdgeSweepNode(e)!==n&&(this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,n))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){const s=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,s,t),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0)}fixIntersection_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e),n=this.m_sweepStructure.getElement(t);let r=null,i=null;const o=this.getEdgeOriginVertices(s),a=this.m_edgeVertices.getFirstElement(o),m=this.getEdgeOriginVertices(n),h=this.m_edgeVertices.getFirstElement(m);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),g=this.m_shape.getWeight(a),u=this.m_shape.getSegmentParentageBreakVertex(a),c=this.m_shape.getWeight(l),_=this.m_shape.getSegmentParentageBreakVertex(l),d=this.m_shape.getSegmentWeight(a),p=this.m_shape.getRank(a),f=this.m_shape.getRank(l),x=this.m_shape.getSegmentRank(a),y=this.m_shape.getSegmentParentage(a);this.m_shape.querySegment(h,this.m_segBuf2,!1,!1),i=this.m_segBuf2.get();const P=this.m_shape.getNextVertex(h),E=this.m_shape.getWeight(h),S=this.m_shape.getSegmentParentageBreakVertex(h),C=this.m_shape.getWeight(P),I=this.m_shape.getSegmentParentageBreakVertex(P),b=this.m_shape.getSegmentWeight(h),w=this.m_shape.getRank(h),v=this.m_shape.getRank(P),N=this.m_shape.getSegmentRank(h),T=this.m_shape.getSegmentParentage(h);this.m_segmentIntersector.pushSegment(r,g,p,c,f,d,x,u,_,y),this.m_segmentIntersector.pushSegment(i,E,w,C,v,b,N,S,I,T),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,n,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t);let n=null;const r=this.getEdgeOriginVertices(s),i=this.m_edgeVertices.getFirstElement(r);this.m_shape.querySegment(i,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(i),a=this.m_shape.getWeight(i),m=this.m_shape.getSegmentParentageBreakVertex(i),h=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),g=this.m_shape.getSegmentWeight(i),u=this.m_shape.getRank(i),c=this.m_shape.getRank(o),_=this.m_shape.getSegmentRank(i),d=this.m_shape.getSegmentParentage(i),p=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(n,a,u,h,c,g,_,m,l,d),this.m_shape.queryPoint(p,this.m_helperPoint);const f=this.m_shape.getWeight(p),x=this.m_shape.getRank(p);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||t>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);Rt.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==Rt.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(e),-1===s){const t=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(t);return this.mergeEdges_(s,e),!1}if(this.setEdgeSweepNode_(e,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,s),!0}return!1}isEdgeOnSweepLine_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1),n=this.getClusterXY(t),r=this.getClusterXY(s);if(T.sqrDistance(n,r)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const i=n.compare(this.m_sweepPoint),o=r.compare(this.m_sweepPoint);return i<=0&&o>0?s:o<=0&&i>0?t:i>0&&o>0?Rt.impossibleIndex2():-1}fillEventQueue(){const e=new St(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let r=t.next();r!==Ae;r=t.next())-1!==this.m_shape.getUserIndex(r,this.m_vertexClusterIndex)&&e.add(r);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 Tn(this.m_shape));const s=T.getNAN();s.setNAN();let n=-1;for(let r=0,i=e.size();r<i;r++){const t=e.read(r);if(this.m_shape.getXY(t).isEqualPoint2D(s)){const e=this.m_shape.getUserIndex(t,this.m_vertexClusterIndex);this.mergeClusters_(n,e);continue}n=this.getClusterFromVertex(t),this.m_shape.queryXY(t,s);const i=this.m_eventQ.addBiggestElement(t);this.setClusterEventQNode_(n,i)}}fillEventQueuePass2(){const e=new St(0);for(let t=this.m_eventQ.getFirst();-1!==t;t=this.m_eventQ.getNext(t)){const s=this.m_eventQ.getElement(t);e.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,s=e.size();t<s;t++){const s=e.read(t),n=this.getClusterFromVertex(s),r=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,r)}}getAffectedEdges(e,t){const s=this.getClusterFirstEdge(e);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);Rt.isValidElement(s)&&t.push(n),n=this.getNextEdge(n,e)}while(n!==s)}updateClusterXY(e,t,s,n,r){const i=this.getClusterVertices(t);for(let o=this.m_clusterVertices.getFirst(i);-1!==o;o=this.m_clusterVertices.getNext(o)){const t=this.m_clusterVertices.getElement(o);this.m_shape.setXYMonotonicPoint2D(t,s),this.m_shape.setWeight(t,n),this.m_shape.setRank(t,r),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_shape.setSegmentParentageBreakVertex(t,!0)}}splitEdge_(e,t,s,n){this.dbgCheckEdge_(e),-1!==t&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),-1!==t&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,n),-1!==t&&this.processSplitHelper1_(1,t,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o],t=this.getClusterEventQNode(e);-1!==t&&(this.m_eventQ.deleteNode(t),this.setClusterEventQNode_(e,-1))}const r=this.getEdgeOriginVertices(e),i=-1!==t?this.getEdgeOriginVertices(t):-1;if(this.applyIntersectorToEditShape_(r,n,0),-1!==i)this.applyIntersectorToEditShape_(i,n,1);else{const e=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,e,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,n,0),-1!==t&&this.createEdgesAndClustersFromSplitEdge_(t,n,1),this.m_edgeVertices.deleteList(r),this.deleteEdge_(e),-1!==t&&(this.m_edgeVertices.deleteList(i),this.deleteEdge_(t));for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let t=this.getClusterEventQNode(e);if(-1===t){const s=this.getClusterFirstVertex(e);if(t=this.m_eventQ.addUniqueElement(s),-1===t){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),n=this.getClusterFromVertex(s);this.mergeClusters_(n,e)}else this.setClusterEventQNode_(e,t)}}this.m_modifiedClusters.length=0}getClusterXY(e){const t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new vn(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const e=[];let t=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=Rt.impossibleIndex2(),r=Rt.impossibleIndex3();for(let i=this.m_eventQ.getFirst();-1!==i;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(i);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===t,!a){let s=t;do{const t=this.getEdgeSweepNode(s);-1===t?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):t!==r&&e.push(t),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=1===e.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let r=0,i=e.length;r<i;r++){const t=this.m_sweepStructure.getElement(e[r]);this.setEdgeSweepNode_(t,n)}let t=n,s=n;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(t===n){const e=this.m_sweepStructure.getPrev(i);if(-1!==e){const s=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(s)!==n&&(t=e)}else t=-1}if(s===n){const e=this.m_sweepStructure.getNext(i);if(-1!==e){const t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==n&&(s=e)}else s=-1}if(t!==n&&s!==n)break}for(let n=0,r=e.length;n<r;n++){const t=e[n],s=this.m_sweepStructure.getElement(t);this.m_sweepStructure.deleteNode(t),this.setEdgeSweepNode_(s,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=s,-1!==t&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,s):-1===t&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===t&&(t=new Nn(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.getCurrentNode())));const m=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&m&&-1!==this.m_prevNeighbour&&-1!==this.m_nextNeighbour&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,null===s&&(s=new Gn(this.m_shape)),s.setPoint(this.m_sweepPoint),i=this.m_eventQ.searchUpperBound(s)):i=this.m_eventQ.getNext(i)}return this.m_bCracked}setEditShape_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==Ae;t=this.m_shape.getNextGeometry(t)){if(a(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==Ae;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===Ae)continue;let r=this.m_shape.getNextVertex(n);if(r===Ae||r===n)continue;let i=-1;e.selected(n)&&(i=this.newCluster_(n));let o=-1;-1!==i&&e.selected(r)&&(o=this.newEdge_(n),this.addEdgeToCluster(o,i));let a=o;for(let e=0,s=t-2;e<s;e++){const e=this.m_shape.getNextVertex(r);let t=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==a&&this.addEdgeToCluster(a,s),this.m_shape.selected(e)&&(t=this.newEdge_(r),this.addEdgeToCluster(t,s))}a=t,r=e}if(this.m_shape.isClosedPath(s)){const e=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const t=this.newCluster_(r);if(-1!==a&&this.addEdgeToCluster(a,t),this.m_shape.selected(e)){const e=this.newEdge_(r);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,i)}}}else{let e=-1;this.m_shape.selected(r)&&(e=this.newCluster_(r),-1!==a&&this.addEdgeToCluster(a,e))}}else for(let e=this.m_shape.getFirstPath(t);e!==Ae;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n;s++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function Vn(e,t,s,n){s>0&&hn(e,s,t,!1,n);new kn(n).executeImpl_(e,t)}function Fn(e,t,s){return{vertex0:e,vertex1:t,dir:s}}class kn{m_shape=null;m_progressTracker;m_spikes=[];m_points=new St(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 h=e.getFirstPath(t);h!==Ae;h=e.getNextPath(h)){let t=e.getFirstVertex(h);for(let s=0,n=e.getPathSize(h);s<n;s++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let h=0,g=this.m_points.size();h<g;++h)e.setUserIndex(this.m_points.read(h),this.m_pointsIndex,h);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const n=e.getXY(s);let r=1,i=0;const o=[];for(let h=1;h<this.m_points.size();h++){const t=this.m_points.read(h);if(t===Ae)continue;if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const a=e.getXY(t);if(a.isEqualPoint2D(n))r++;else{if(r>1){for(let t=i;t<h;t++){const s=this.m_points.read(t);if(-1===e.getUserIndex(s,this.m_pointsIndex))continue;const r=e.getNextVertex(s),i=e.getPrevVertex(s);if(s!==r&&!e.isEqualXYPoint2D(r,n)){const e=Fn(s,r,1);o.push(e)}if(s!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=Fn(s,i,-1);o.push(e)}}o.length>0&&this.processBunch_(o,n)}s=t,n.assign(a),r=1,i=h}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let a=e.getPointCount(t);for(let h=0;h<this.m_points.size();h++){const t=this.m_points.read(h);if(t===Ae)continue;if(-1!==e.getUserIndex(t,this.m_pointsIndex)){e.setUserIndex(t,this.m_pointsIndex,-1);continue}const s=e.getPathFromVertex(t);e.getFirstVertex(s)===t&&e.setFirstVertex(s,Ae),e.freeVertex(t),this.m_points.write(h,Ae),a--}const m=e.createPathUserIndex();let l=e.getPathCount(t);for(let g=0,u=this.m_points.size();g<u;++g){if(this.m_points.read(g)===Ae)continue;let s=this.m_points.read(g);if(-1!==e.getUserIndex(s,this.m_pointsIndex))continue;let n=e.getPathFromVertex(s),r=-1;if(2===e.getPathUserIndex(n,m)){n=Ae;for(let t=e.getNextVertex(s);t!==s;t=e.getNextVertex(t)){const r=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(r,m)){n=r,s=t;break}}n===Ae&&(n=e.insertPath(t,Ae),e.setClosedPath(n,!0),l++),h(n!==Ae)}e.setPathUserIndex(n,m,2),r=e.getFirstVertex(n);let i=0,o=!1,a=s;do{r===a&&(o=!0),e.setUserIndex(a,this.m_pointsIndex,1);const t=e.getPathFromVertex(a);t!==n&&(2!==e.getPathUserIndex(t,m)&&(e.setPathUserIndex(t,m,1),e.setFirstVertex(t,Ae)),e.setPathToVertex(a,n)),i++,a=e.getNextVertex(a)}while(a!==s);o||e.setFirstVertex(n,s),e.setPathSize(n,i)}for(let h=e.getFirstPath(t);h!==Ae;){const t=e.getNextPath(h);1!==e.getPathUserIndex(h,m)&&e.getFirstVertex(h)!==Ae||(e.removePathOnly(h),l--),h=t}e.setGeometryVertexCount(t,a),e.setGeometryPathCount(t,l),e.removePathUserIndex(m),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,s)=>{const n=this.m_shape.getXY(e.vertex1).sub(t),r=this.m_shape.getXY(s.vertex1).sub(t),i=T.compareVectors(n,r);return 0===i?e.dir<s.dir?-1:1:i});let s=0;const n=this.m_shape.getXY(e[0].vertex1);let r=1;const i=this.m_shape.hasCurves();for(let o=1,a=e.length;o<a;o++){const t=this.m_shape.getXY(e[o].vertex1);if(!(t.isEqualPoint2D(n)&&(r++,o+1<a))){if(2===r){const t=e[s],n=e[s+1],r=t.dir;if(r!==n.dir){let e=!0;if(i&&(e=!this.m_shape.isCurve(1===t.dir?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),e){if(1===r){const e=t.vertex0,s=n.vertex0;this.m_shape.setNextVertex(e,s),this.m_shape.setPrevVertex(s,e),this.m_shape.getPrevVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setPrevVertex(r,i),this.m_shape.setNextVertex(i,r),this.m_shape.getNextVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}else{const e=t.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(s,e),this.m_shape.getNextVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setNextVertex(r,i),this.m_shape.setPrevVertex(i,r),this.m_shape.getPrevVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(t),s=o,r=1}}e.length=0}}function Hn(e){for(let t=e.getFirstGeometry();t!==Ae;t=e.getNextGeometry(t))if(a(e.getGeometryType(t)))return!0;return!1}function An(e,t,s,n){if(!Hn(e))return!1;const r=new Bn(n);r.m_shape=e,r.m_tolerance=t,r.m_bTrackChanges=s;let i=!1;const o=e.hasCurves()?5:15;return i=e.getTotalPointCount()<o?r.crackBruteForce_():r.crackerPlaneSweep_(),i}function Mn(e,t,s,n,r){if(!Hn(t))return!1;let i=new Bn(r);if(i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n,i.needsCrackingImpl_())return n&&n.assign(i.m_nonSimpleResult),!0;const o=new jt;o.setSwapCoordinates(),t.applyTransformation(o),i=new Bn(r),i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n;const a=i.needsCrackingImpl_();return t.applyTransformation(o),!!a&&(n&&n.assign(i.m_nonSimpleResult),!0)}function Un(e,t,s,n){const r=t.getGeometryType();if(a(r)){return new Bn(n).crackAWithBMultiPath_(e,t,s)}_("crack_A_with_B")}function qn(e,t){return{t:e,index:t}}class Bn{static s_bForceBruteForce=!0;m_shape=null;m_progressTracker=null;m_nonSimpleResult=new ts;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()){const t=new jt;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1;const t=new Ve,s=new Ve,n=Wt.constructEmpty(),r=Wt.constructEmpty(),i=!1,o=new pt,a=new xn,m=this.m_shape.getTotalPointCount(),g=m*m*2,u=this.m_shape.queryVertexIteratorOnSelection();for(let c=u.next();c!==Ae;c=u.next()){const m=this.m_shape.getGeometryType(u.currentGeometry());let _=1,d=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(c);let E=!1,S=!1,C=null,I=!1;if(l(m))_=this.m_shape.getWeight(c),f=this.m_shape.getRank(c);else{if(C=this.getSegment_(c,t),null===C)continue;const e=this.m_shape.getVertexIndex(c);_=this.m_shape.getWeightWithIndex(e),f=this.m_shape.getRankWithIndex(e),p=this.m_shape.getSegmentWeightWithIndex(e),y=this.m_shape.getSegmentRankWithIndex(e),E=this.m_shape.getSegmentParentageBreakVertex(c);{const e=this.m_shape.getNextVertex(c);d=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(n),n.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const b=new ze({copy:u});let w=b.next();w!==Ae&&(w=b.next());let v=0;for(;w!==Ae;w=b.next()){if(0!==v){v--;continue}if(this.m_shape.getTotalPointCount()>g)return e;this.progress_();const m=this.m_shape.getGeometryType(b.currentGeometry());let N=null,T=!1,G=0,D=0,V=0,F=0,k=0,H=0,A=!1,M=!1;const U=this.m_shape.getSegmentParentage(w);if(l(m))G=this.m_shape.getWeight(w),F=this.m_shape.getRank(w);else{if(N=this.getSegment_(w,s),null===N)continue;const e=this.m_shape.getVertexIndex(w);G=this.m_shape.getWeightWithIndex(e),F=this.m_shape.getRankWithIndex(e),V=this.m_shape.getSegmentWeightWithIndex(e),H=this.m_shape.getSegmentRankWithIndex(e),A=this.m_shape.getSegmentParentageBreakVertex(w);{const e=this.m_shape.getNextVertex(w);D=this.m_shape.getWeight(e),k=this.m_shape.getRank(e),M=this.m_shape.getSegmentParentageBreakVertex(e)}if(N.queryLooseEnvelope(r),N.isDegenerate(this.m_tolerance)){if(!N.isDegenerate(0))continue;T=!0,N=null}}let q=0,B=0;if(null!==C&&null!==N){if(n.isIntersectingNe(r)){0!==We(!0,!0,C,N,this.m_tolerance,!0)&&(a.pushSegment(C,_,f,d,x,p,y,E,S,P),a.pushSegment(N,G,F,D,k,V,H,A,M,U),a.intersect2D(this.m_tolerance,!0),e||=a.getSegmentChanged(0)||a.getSegmentChanged(1),q=a.getResultSegmentCount(0),B=a.getResultSegmentCount(1),q+B>0&&(this.m_shape.splitSegmentWithIntersector(c,a,0,!0,!0),this.m_shape.splitSegmentWithIntersector(w,a,1,!0,!0),this.m_bTrackChanges&&(a.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(c,!0),a.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0))),B>1&&(v+=B-1),a.clear())}}else if(null!==C){const t=this.m_shape.getXY(w);if(n.contains(t)){if(a.pushSegment(C,_,f,d,x,p,y,E,S,P),this.m_shape.queryPoint(w,o),a.intersect2DEx(this.m_tolerance,o,F,G,i),e||=a.getSegmentChanged(0)||a.getResultPointChanged(),q=a.getResultSegmentCount(0),q>0)if(this.m_bTrackChanges&&(a.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(c,!0),a.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0)),this.m_shape.splitSegmentWithIntersector(c,a,0,!0,!0),T){let e=Ae;for(let t=this.m_shape.getNextVertex(w);t!==Ae&&t!==w&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=w;t!==Ae&&(this.m_shape.setPoint(t,a.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(w,a.getResultPoint(),!0);a.clear()}}else{if(null===N)continue;{const t=this.m_shape.getXY(c);if(r.inflateCoords(this.m_tolerance,this.m_tolerance),r.contains(t)){if(a.pushSegment(N,G,F,D,k,V,H,A,M,U),this.m_shape.queryPoint(c,o),a.intersect2DEx(this.m_tolerance,o,f,_,i),e||=a.getSegmentChanged(0)||a.getResultPointChanged(),B=a.getResultSegmentCount(0),B>0)if(this.m_bTrackChanges&&(a.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(w,!0),a.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(c,!0)),this.m_shape.splitSegmentWithIntersector(w,a,0,!0,!0),v+=B-1,I){let e=Ae;for(let t=this.m_shape.getNextVertex(c);t!==Ae&&t!==c&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=c;t!==Ae&&(this.m_shape.setPoint(t,a.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(c,a.getResultPoint(),!0);a.clear()}}}if(q+B!==0&&0!==q){let e=!1;for(;C=this.getSegment_(c,t),null!=C&&(C.queryEnvelope(n),C.isDegenerate(this.m_tolerance));){if(!(q>1)){e=!0;break}c=u.next(),q--,h(c!==Ae)}if(e)break}}}return e}m_sweepStructure=new Pt;crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Dn(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1;const t=new St(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let o=0,g=s.next();g!==Ae;++o,g=s.next())t.write(o,g);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(Ae);const n=this.m_shape.createUserIndex(),r=this.m_shape.createUserIndex();this.m_sweepComparator=new on(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let i=null;const a=[],m=[];let h=0;const l=new T;for(let g=t.read(h++);g!==Ae;){this.m_shape.queryXY(g,l);let s=!1;do{let e=this.m_shape.getNextVertex(g),i=this.m_shape.getPrevVertex(g);s||=e!==Ae||i!==Ae,e===Ae||this.m_shape.selected(e)||(e=Ae),i===Ae||this.m_shape.selected(i)||(i=Ae),e!==Ae&&this.m_shape.compareVerticesSimpleY(g,e)<0&&(m.push(g),m.push(e)),i!==Ae&&this.m_shape.compareVerticesSimpleY(g,i)<0&&(m.push(i),m.push(i));const o=this.m_shape.getUserIndex(g,n);-1!==o&&(a.push(o),this.m_shape.setUserIndex(g,n,-1));const l=this.m_shape.getUserIndex(g,r);-1!==l&&(a.push(l),this.m_shape.setUserIndex(g,r,-1)),g=t.read(h++)}while(g!==Ae&&this.m_shape.isEqualXYPoint2D(g,l));if(!s&&(null===i&&(i=new an(this.m_shape,this.m_tolerance)),i.setPoint(l),this.m_sweepStructure.searchUpperBound(i),i.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(o("needsCrackingIMpl_"),this.m_nonSimpleResult=new ts(6,-1,-1));break}let u=1===a.length&&2===m.length;const c=32;a.length>c&&D(a);let _=-1,d=-1;if(!u)for(let t=0,n=a.length;t<n;t++){const s=a[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===a.indexOf(n))if(-1===_)_=n;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}const r=this.m_sweepStructure.getNext(s);if(-1!==r&&-1===a.indexOf(r))if(-1===d)d=r;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}if(-1!==_&&-1!==d)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(l.y,l.x),!u){for(let e=0,t=a.length;e<t;e++){const t=a[e];this.m_sweepStructure.deleteNode(t)}a.length=0}if(!u&&-1!==_&&-1!==d&&this.checkForIntersections_(_,d)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,i=m.length;t<i;t+=2){const s=m[t],i=m[t+1];let o;if(u?(o=this.m_sweepStructure.replaceElementAtPosition(a[0],s,!0,!0),a.length=0,u=!1):o=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}-1===this.m_shape.getUserIndex(i,n)?this.m_shape.setUserIndex(i,n,o):this.m_shape.setUserIndex(i,r,o)}if(e)break;m.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(r),e}checkForIntersections_(e,t){const s=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,s,t);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(e,t){return Bn.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,s){return e.querySegment(t,s,!1,!1)?s.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,s){const n=Wt.constructEmpty();e.queryLooseEnvelope(n);const i=Wt.constructEmpty();if(t.queryLooseEnvelope(i),i.inflateCoords(s,s),!i.isIntersecting(n))return e;const o=e.getImpl(),a=o.getAccelerators();let m=null,l=null;a&&(l=a.getQuadTree()),On(e,u(t))&&(m=Dt(o,i),l=m);const g=l?l.getIteratorForQT():null,c=t.querySegmentIterator(),_=e.querySegmentIterator(),d=N(15,Number.NaN),p=[];for(;c.nextPath();)for(;c.hasNextSegment();){const e=c.nextSegment();if(l){g.resetIterator(e,s);for(let t=g.next();-1!==t;t=g.next()){this.progress_();const n=l.getElement(t);if(_.resetToVertex(n,-1),_.hasNextSegment()){const t=_.nextSegment().intersect(e,null,d,null,s);for(let e=0;e<t;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}else{const t=Wt.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(s,s),!n.isIntersecting(t))continue;for(_.resetToFirstPath();_.nextPath();)for(;_.hasNextSegment();){const n=_.nextSegment(),r=Wt.constructEmpty();if(n.queryLooseEnvelope(r),!r.isIntersecting(t))continue;const i=n.intersect(e,null,d,null,s);for(let e=0;e<i;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}if(0===p.length)return e;p.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:e.t>t.t?1:0);const f=e.createInstance();if(f.getGeometryType()===r.enumPolygon){f.setFillRule(e.getFillRule())}for(_.resetToFirstPath();_.nextPath()&&!_.hasNextSegment(););h(_.hasNextSegment());let x=_.nextSegment();const y=new Ve;let P=-1;for(let r=0,u=p.length;r<u;){const e=p[r].index;let t=r+1;for(;t<u&&p[t].index===e;)++t;for(;_.getStartPointIndex()<e;){this.progress_();const e=_.hasNextSegment(),t=_.getPathIndex();if((e||!_.isClosingSegment()||_.isCurve())&&(h(null!==x),f.addSegment(x,P!==t)),P=t,!e){for(_.isPathClosed();_.nextPath()&&!_.hasNextSegment(););h(_.hasNextSegment())}x=_.nextSegment()}let s=0;for(let i=r;i<t;i++){const e=p[i].t;if(e===s)continue;h(null!==x),x.queryCut(s,e,y),s=e;const t=_.getPathIndex();f.addSegment(y.get(),P!==t),P=t}const n=_.hasNextSegment();if((n||!_.isClosingSegment()||_.isCurve())&&(h(null!=x),x.queryCut(s,1,y),f.addSegment(y.get(),!1)),n)x=_.nextSegment();else{for(;_.nextPath()&&!_.hasNextSegment(););x=_.hasNextSegment()?_.nextSegment():null}r=t}if(null!==x){const e=_.getPathIndex();(_.hasNextSegment()||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}let E=_.hasNextSegment();for(;;){if(!E){for(;_.nextPath()&&(E=_.hasNextSegment(),!E););if(!E)break}x=_.nextSegment();const e=_.getPathIndex();E=_.hasNextSegment();(E||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}return f}constructor(e){this.m_progressTracker=e}}function On(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}class Rn{m_inputPoint;m_windnum;m_monotoneParts=B(Ve,16);m_xOrds=N(16,Number.NaN);m_tolerance;m_toleranceSqr;m_miny;m_maxy;m_bAlternate;m_bTestBorder;m_bBreak;constructor(e,t){this.m_inputPoint=T.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY())))return void(this.m_bBreak=!0);if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const t=Math.min(e.getStartX(),e.getEndX()),s=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let t=!1;const s=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>s)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){const n=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);t=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){const t=e.getClosestCoordinate(this.m_inputPoint,!1),s=e.getCoord2D(t);return T.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){const t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let s=0;if(e.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=e.getMonotonicParts(this.m_monotoneParts,!0),h(this.m_monotoneParts.length>=s)),s>0)for(let n=0;n<s;n++){const e=this.m_monotoneParts[n].get(),t=A.construct(e.getStartY(),e.getEndY());if(!(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return h(0),2}}function Yn(e,t,s,n){const r=new Wt;e.queryLooseEnvelope(r),r.inflateCoords(n,n);const i=0===e.getFillRule(),o=new Rn(i,n);o.setInputPoint(s);const a=r.clone();a.xmax=s.x+n,a.ymin=s.y-n,a.ymax=s.y+n;const m=e.getImpl().querySegmentIterator(),h=t.getIterator(a,n);for(let l=h.next();-1!==l;l=h.next())if(m.resetToVertex(t.getElement(l),-1),m.hasNextSegment()){const e=m.nextSegment();if(o.processSegment(e))return-1}return o._Result()?1:0}function Xn(e,t,s){const n=0===e.getFillRule(),r=new Rn(n,s);r.setInputPoint(t);const i=e.getImpl().querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(r.processSegment(e))return-1}return r._Result()?1:0}function Ln(e,t,s){return t.isEmpty()?0:zn(e,t.getXY(),s)}function zn(e,t,s){if(e.isEmpty())return 0;const n=Wt.constructEmpty();if(e.queryLooseEnvelope(n),n.inflateCoords(s,s),!n.contains(t))return 0;const r=e.getImpl().getAccelerators();if(r){r.getRasterizedGeometry()&&h(0);const n=r.getQuadTree();if(n)return Yn(e,n,t,s)}return Xn(e,t,s)}function Wn(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}function jn(e,t,s,n,r){const i=new $n(r);return i.m_shape=e,i.m_geometry=t,i.m_sortedVertices=s,i.m_bFixSelfTangency=n,i.fixRingOrientation_()}function Zn(e,t,s){const n=new $n(s);return n.m_shape=e,n.m_geometry=t,n.m_sortedVertices=null,n.m_bFixSelfTangency=!1,n.fixRingOrientationForMp2sp_()}class Kn{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){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?s: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),s=this.getEnd2(e);this.m_shape.getPrevVertex(t)===s&&(s=M(t,t=s));const n=T.getNAN(),r=T.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),h(!n.equals(r)),n.y<r.y}getStart(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?t:s}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(-1!==this.m_firstFree){const t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}const t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let Qn=class extends Xt{m_helper;m_line1=new Fe;m_line2=new Fe;m_leftElm=-1;m_leftx=0;m_seg1=null;constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges;let i;if(this.m_leftElm===t)i=this.m_leftx;else{if(this.m_seg1=r.getSegment(t),this.m_seg1)i=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,i=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}this.m_leftx=i,this.m_leftElm=t}let o,a=r.getSegment(n);if(a)o=a.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(n),this.m_line2,!0),a=this.m_line2,o=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}if(i===o){const e=r.isBottomUp(t),s=r.isBottomUp(n),m=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),h=s?a.getEndY():a.getStartY(),l=Math.min(m,h);let g=.5*(l+this.m_helper.m_yScanline);g===this.m_helper.m_yScanline&&(g=l),i=this.m_seg1.intersectionOfYMonotonicWithAxisX(g,0),o=a.intersectionOfYMonotonicWithAxisX(g,0),i===o&&E("")}return i<o?-1:i>o?1:0}reset(){this.m_leftElm=-1}};class Jn{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){const e=this.m_node;if(-1===e)return Ae;const t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){const e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return Ae}}class $n{m_edges=null;m_sweepComparator;m_shape=null;m_AET=new Pt;m_yScanline=0;m_geometry=Ae;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 Qn(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const e=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||(this.m_edges=new Kn(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let s=0,n=e.length;s<n;s++){-1!==e[s]&&t++}(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let s=0,n=e.length;s<n;s++){const t=e[s];t!==Ae&&this.insertEdge_(t,-1)}for(let s=0;s<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;s++){const e=this.m_unknownNodes[s],n=this.m_AET.getElement(e),r=this.m_edges.getPath(n),i=this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex);let o=Ae;if(0===i){let s=this.m_AET.getPrev(e),n=e,r=!1;for(;s!==Pt.st_nullNode();){const e=this.m_AET.getElement(s),t=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){o=t;break}n=s,s=this.m_AET.getPrev(s)}if(s===Pt.st_nullNode())r=!0,s=n;else{const e=this.m_AET.getElement(s);r=this.m_edges.isBottomUp(e),s=this.m_AET.getNext(s),r=!r}do{const e=this.m_AET.getElement(s),i=this.m_edges.getPath(e);if(0===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(e)){const e=this.m_shape.getFirstVertex(i);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(i,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(i,this.m_pathOrientationIndex,r?3:2),!r){let e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);2===e?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),h(3===e)):h(3===e);const t=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,i),this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(i,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}o=i,n=s,s=this.m_AET.getNext(s),r=!r}while(n!==e)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),r=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const e=this.m_AET.getElement(n);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==r){const e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let i=-1;-1!==n&&-1!==r?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(r),e[t]=Ae):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=Ae)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=T.getNAN(),n=T.getNAN();this.m_shape.queryXY(e,s);const r=this.m_shape.getNextVertex(e);this.m_shape.queryXY(r,n);let i=!1;if(s.y<n.y){i=!0;const s=this.m_edges.newEdge(e);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(r,this.m_node1UserIndex)?this.m_shape.setUserIndex(r,this.m_node1UserIndex,n):this.m_shape.setUserIndex(r,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,n),s.y<n.y){i=!0;const s=this.m_edges.newEdge(o);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,n):this.m_shape.setUserIndex(o,this.m_node2UserIndex,n);const r=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return i}fixRingSelfTangency_(){const e=[],t=[];let s=-1,n=-1;const r=new T;let i=Ae,o=Ae,a=-1;const m=new Jn(this);for(let h=m.next();h!==Ae;h=m.next()){const m=new T;this.m_shape.queryXY(h,m);const l=this.m_shape.getPathFromVertex(h);if(r.equals(m)&&o===l){if(-1===n&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),n=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,n,-1)),-1===a){a=t.length,this.m_shape.setUserIndex(i,n,a),t.push(1);-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,i),e.push(l))}this.m_shape.setUserIndex(h,n,a),t[t.length-1]++}else a=-1,r.assign(m);i=h,o=l}if(0===e.length)return!1;h(-1!==s);for(let h=0,l=e.length;h<l;h++){const r=e[h];let i=this.m_shape.getPathUserIndex(r,s);const o=this.m_shape.getUserIndex(i,n),a=[],m=[];a.push(i),m.push(o);for(let e=this.m_shape.getNextVertex(i);e!==i;e=this.m_shape.getNextVertex(e)){const s=e,r=this.m_shape.getUserIndex(s,n);if(-1!==r){if(0===m.length){m.push(r),a.push(s);continue}if(m.at(-1)===r){const o=a.at(-1);this.m_shape.peelALoopIntoAPath(o,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,m.pop(),a.pop()),i=o,e=o}else a.push(e),m.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const s={stack:[],error:void 0,hasError:!1};try{let t,n=!1;const r=e(s,ie(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new St(0);for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==Ae;s=this.m_shape.getNextPath(s)){let e=this.m_shape.getFirstVertex(s);for(let n=0,r=this.m_shape.getPathSize(s);n<r;n++)t.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(t,0,e),this.progress_(!0),this.m_sortedVerticesArray=t}else r.bForget=!0;if(this.m_bFixSelfTangency&&(n=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){const t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==Ae;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const o=T.getNAN();this.m_unknownRingOrientationCount=this.m_shape.getPathCount(this.m_geometry),this.m_node1UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node1UserIndex,-1),this.m_node2UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node2UserIndex,-1);const a=new Jn(this);for(let e=a.next();e!==Ae&&(this.progress_(),this.m_shape.queryXY(e,o),o.y!==this.m_yScanline&&i.length&&(n=this.processBunchForRingOrientationTest_(i)||n,this.m_sweepComparator.reset(),i.length=0),i.push(e),this.m_yScanline=o.y,0!==this.m_unknownRingOrientationCount);e=a.next());return this.m_unknownRingOrientationCount>0&&(n=this.processBunchForRingOrientationTest_(i)||n,i.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),n}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==Ae;)if(this.progress_(),3===this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){this.m_shape.setExterior(t,!0);for(let r=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);r!==Ae;){const s=this.m_shape.getPathUserIndex(r,this.m_pathParentageIndex);e.push(r),this.m_shape.setExterior(r,!1),this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,t),r=s}let s=t,n=e.length;for(let e=this.m_shape.getNextPath(t);n>0&&e!==Ae;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=Ae;break}s=e}if(0!==n){s=t;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,Lt),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}e.length=0,t=this.m_shape.getNextPath(s)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const e=this.m_shape.createPathUserIndex();let t=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==Ae;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,e,t),t++;for(let e=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e!==Ae;){const t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,n),e=t}let r=n,i=s.length,o=t;for(let t=this.m_shape.getNextPath(n);i>0&&t!==Ae;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=Ae;break}r=t,this.m_shape.setPathUserIndex(t,e,-o),o++}if(0!==i){r=n,o=t;for(let t=0,n=s.length;t<n;t++){const n=s[t];this.m_shape.setPathUserIndex(n,e,-o),o++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,Lt)}r=n}t=o,s.length=0,n=this.m_shape.getNextPath(r)}else n=this.m_shape.getNextPath(n);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function er(e,t,s,n,r,i){const o=new tr(i);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=r,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class tr{m_shape=null;m_progressTracker;m_geometry=Ae;m_sortedVertices=new yt;m_bunchEdgeEndPoints=[];m_bunchEdgeCenterPoints=[];m_bunchEdgeIndices=[];m_sorterSegmentBuffer1=null;m_sorterSegmentBuffer2=null;m_knownSimpleResult=-1;m_sortedVerticesListIndex=-1;m_polylineDegeneracies=Ae;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){const s=this.m_bunchEdgeEndPoints[e],n=new T;this.m_shape.queryXY(s,n);const r=new T,i=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(i,r),n.equals(r))return 0;const o=this.m_bunchEdgeCenterPoints[e],a=new T;this.m_shape.queryXY(o,a);const m=this.m_bunchEdgeCenterPoints[t],h=new T;this.m_shape.queryXY(m,h);const l=new T;l.setSub(n,a);const g=new T;g.setSub(r,h),(l.isZero()||g.isZero())&&E("");return T.compareVectors(l,g)}compareAnglesCurves_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeEndPoints[t],r=this.m_bunchEdgeCenterPoints[e],i=this.m_bunchEdgeCenterPoints[t],o=this.m_shape.getNextVertex(r)===s,a=this.m_shape.getNextVertex(i)===n,m=o?this.m_shape.isCurve(r):this.m_shape.isCurve(s),h=a?this.m_shape.isCurve(i):this.m_shape.isCurve(n);if(!m&&!h)return this.compareAnglesLines_(e,t);this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new Ve),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new Ve),o?this.m_shape.querySegment(r,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(s,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),a?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse());return Ue(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())}beforeRemoveVertex_(e,t){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(e),t){const t=this.m_shape.getPathFromVertex(e);if(t!==Ae){if(this.m_shape.getFirstVertex(t)===e){const s=this.m_shape.getNextVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s);{const s=this.m_shape.getPrevVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s)}}}this.m_shape.setFirstVertex(t,Ae),this.m_shape.setLastVertex(t,Ae)}}}}processBunch_(){let e=!1;const t=new T(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,n=0,r=!0;for(;s!==this.m_nextVertexToProcess;){const e=this.m_sortedVertices.getData(s);r&&(this.m_shape.queryXY(e,t),r=!1);const i=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex)!==Lt&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,Lt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++));this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==Lt&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,Lt),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),s=this.m_sortedVertices.getNext(s)}if(this.m_bunchEdgeEndPoints.length<2){1===this.m_bunchEdgeEndPoints.length&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e],s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,e)}const i=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e];if(-1===t)continue;const s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!i)break;e=!0}return e}processCrossOvers_(e){let t=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,o=this.m_bunchEdgeIndices.length;i<o&&-1!==n&&-1!==r&&n!==r;i++){const i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[r],a=this.m_bunchEdgeEndPoints[i],m=this.m_bunchEdgeEndPoints[o];let h=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(a),l=!0);let g=this.m_shape.getNextVertex(m),u=!1;this.m_shape.isEqualXYPoint2D(g,e)||(g=this.m_shape.getPrevVertex(m),u=!0);const c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),_=u?this.m_shape.getPrevVertex(g):this.m_shape.getNextVertex(g);let d=!1;(this.removeSpike_(h)||this.removeSpike_(g)||this.removeSpike_(a)||this.removeSpike_(m)||this.removeSpike_(c)||this.removeSpike_(_))&&(d=!0),h!==g&&(!d&&this.m_shape.isEqualXY(a,m)&&(d=this.resolveOverlap_(l,u,h,a,g,m)),!d&&this.m_shape.isEqualXY(c,_)&&(d=this.resolveOverlap_(!l,!u,h,c,g,_)),!d&&this.m_shape.isEqualXY(a,_)&&(d=this.resolveOverlap_(l,!u,h,a,g,_)),!d&&this.m_shape.isEqualXY(c,m)&&(d=this.resolveOverlap_(!l,u,h,c,g,m))),d&&(t=!0),s||=d,n=d?this.getNextEdgeIndex_(n):r,r=this.getNextEdgeIndex_(n)}}if(!t){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let r=0,i=this.m_bunchEdgeIndices.length;r<i&&-1!==s&&-1!==n&&s!==n;r++){const r=this.m_bunchEdgeIndices[s],i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[r],a=this.m_bunchEdgeEndPoints[i];let m=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(o));let h=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(a));const l=this.getDirection_(m,o),g=this.getDirection_(h,a),u=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),c=g?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),_=this.detectAndResolveCrossOver_(l,g,o,m,u,a,h,c);1!==_?0===_?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):t=!0}}return t}simplify_(){if(this.m_shape.getGeometryType(this.m_geometry)===r.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)){new Ka(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0)}let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const t=this.m_shape.getPointCount(this.m_geometry),s=new St(0);this.m_shape.dbgVerifyMonotone();for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==Ae;r=this.m_shape.getNextPath(r)){let e=this.m_shape.getFirstVertex(r);for(let t=0,n=this.m_shape.getPathSize(r);t<n;t++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let r=0;r<t;r++){const e=s.read(r),t=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,t)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let n=0,i=!1;do{i=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new T(0,0);this.m_firstCoincidentVertex!==yt.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,r=this.m_firstCoincidentVertex;for(;r!==yt.st_nullNode()&&(r=this.m_sortedVertices.getNext(r),r!==yt.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(r),n=T.getNAN();if(this.m_shape.queryXY(e,n),t.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=r;const e=this.processBunch_();r=this.m_nextVertexToProcess,r!==yt.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(r),n),e&&(i=!0)}t.setCoordsPoint2D(n),this.m_firstCoincidentVertex=r,s=0}}if(this.m_nextVertexToProcess=-1,s>0){this.processBunch_()&&(i=!0)}n++>10&&o(""),i&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(i=!0),e||=i}while(i);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=jn(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,s,n,r,i,o,a){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(i),-1;const m=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),h=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),g=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),u=N(8,Number.NaN),c=N(4,Number.NaN);u[0]=0,c[0]=m,u[1]=0,c[1]=h,u[2]=1,c[2]=l,u[3]=1,c[3]=g;for(let d=1;d<4;d++){const e=c[d],t=u[d];let s=d-1;for(;s>=0&&c[s]>e;)c[s+1]=c[s],u[s+1]=u[s],s--;c[s+1]=e,u[s+1]=t}let _=0;if(u[0]&&(_|=1),u[1]&&(_|=2),u[2]&&(_|=4),u[3]&&(_|=8),5!==_&&10!==_)return 0;if(e!==t&&(a=M(i,i=a)),e)this.m_shape.setNextVertex(a,n),this.m_shape.setPrevVertex(n,a),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,n),this.m_shape.setNextVertex(n,a),this.m_shape.setPrevVertex(r,o),this.m_shape.setNextVertex(o,r),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const r=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,r),this.m_shape.setSegmentToIndex(t,s)}}return 1}resolveOverlap_(e,t,s,n,r,i){return this.resolveOverlapOddEven_(e,t,s,n,r,i)}resolveOverlapOddEven_(e,t,s,n,r,i){if(e!==t){e||(r=M(s,s=r),i=M(n,n=i));const t=this.m_shape.getNextVertex(r),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,t),this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(s),t=this.m_shape.getVertexIndex(r),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(s),t=this.m_shape.getSegmentParentage(r);this.m_shape.setSegmentParentageAndBreak(s,t,!0),this.m_shape.setSegmentParentageAndBreak(r,e,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}this.removeSpike_(r)}else{const o=e?s:n,a=t?r:i,m=e?n:s,h=t?i:r;let l=null;if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(h);l=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);const t=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(t,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let g=-1;this.m_bHasSegmentParentage&&(g=this.m_shape.getSegmentParentage(h));let u=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(m,h),this.m_shape.setPrevVertex(h,m);let c=h;for(;c!==a;){const e=this.m_shape.getPrevVertex(c),t=this.m_shape.getNextVertex(c);if(this.m_shape.setPrevVertex(c,t),this.m_shape.setNextVertex(c,e),u||=c===o,this.m_bHasSegments&&c!==o){const e=this.m_shape.getVertexIndex(t),s=l;l=this.m_shape.getSegmentFromIndex(e),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(e,s)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,g),g=e}c=t}let _=null;if(!u){const e=this.m_shape.getPrevVertex(a),t=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,t),this.m_shape.setNextVertex(a,e),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let d=-1,p=-1;if(this.m_bHasSegmentParentage&&(d=u?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(m)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(h,m),this.beforeRemoveVertex_(h,!0),this.m_shape.removeVertexInternal(h,!0),this.removeAngleSortInfo_(m),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,d,!0),this.m_shape.setSegmentParentageAndBreak(m,p,!0)),_){const e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,_)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==Ae;){const s=this.m_shape.getNextPath(t);let n=this.m_shape.getFirstVertex(t);for(let r=0,i=this.m_shape.getPathSize(t);r<i&&i>1;){this.progress_();const{v:s,bModified:o}=this.checkAndCleanupSpike_(t,n);if(s===Ae)break;o?(e=!0,n=s,r=0,i=this.m_shape.getPathSize(t)):(n=s,r++)}t=s}return e}checkAndCleanupSpike_(e,t){const s={v:Ae,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=Ae,o=Ae;for(;this.m_shape.isEqualXY(n,r)&&(i=n,o=r,r!==t);)n=this.m_shape.getPrevVertex(n),r=this.m_shape.getNextVertex(r);if(i===Ae)return s.v=r,s;s.bModified=!0;for(let a=this.m_shape.getNextVertex(i);this.beforeRemoveVertex_(a,!1),a!==o;a=this.m_shape.getNextVertex(a));if(i===t)return this.m_polylineDegeneracies!==Ae?this.m_shape.movePath(this.m_polylineDegeneracies,Ae,e):this.m_shape.removePath(e),s.v=Ae,s;{const e=this.m_shape.peelALoopIntoAPath(i,o);this.m_polylineDegeneracies!==Ae?this.m_shape.movePath(this.m_polylineDegeneracies,Ae,e):this.m_shape.removePath(e)}return s.v=i,s}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(e),n=Ae,r=Ae;for(;this.m_shape.isEqualXY(t,s)&&(n=t,r=s,s!==e);)t=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(s);if(n===Ae)return!1;if(this.m_shape.peelALoop(n,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===Ae)for(let i=this.m_shape.getNextVertex(r);;){const e=this.m_shape.getNextVertex(i);if(this.removeAngleSortInfo_(i),this.beforeRemoveVertex_(i,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(i),null),this.m_shape.removeVertexInternal(i,!1),i===r)break;i=e}else{for(let t=r;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===r)break}const e=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,Ae,r,r,e)}return!0}fixOrphanVertices_(){let e=0;for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const e=this.m_sortedVertices.getData(n);this.m_shape.setPathToVertex(e,Ae)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==Ae;){const s=this.m_shape.getFirstVertex(n);if(s===Ae||this.m_shape.getPathFromVertex(s)!==Ae){const e=n;n=this.m_shape.getNextPath(n),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(s,n);let r=1;for(let e=this.m_shape.getNextVertex(s);e!==s;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,n),r++;this.m_shape.setRingAreaValid(n,!1),this.m_shape.setPathSize(n,r),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(s)),t+=r,e++,n=this.m_shape.getNextPath(n)}for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const s=this.m_sortedVertices.getData(n);if(this.m_shape.getPathFromVertex(s)!==Ae)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,Ae,s,s,r);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let s=0;for(let n=this.m_shape.getFirstGeometry();n!==Ae;n=this.m_shape.getNextGeometry(n))s+=this.m_shape.getPointCount(n);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}getPrevEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}transferVertexData_(e,t){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(e){const t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);-1!==t&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function sr(e,t,n,i,o,a=!0){switch(ir(i)){case 0:break;case 1:s("relation string length has to be 9 characters");break;default:s("relation string")}if(a){const s=xr(i,e.getDimension(),t.getDimension());if(0!==s)return Hr(e,t,n,s,o)}let m=0;if("number"==typeof n)m=n;else{const s=Wt.constructEmpty();e.queryEnvelope(s);const r=Wt.constructEmpty();t.queryEnvelope(r);const i=Wt.constructEmpty();i.setCoords({env2D:s}),i.mergeEnvelope2D(r),m=ht(n,i,!1)}const h=Tr(e,m),l=Tr(t,m);if(h.isEmpty()||l.isEmpty())return fr(h,l,i);const g=h.getGeometryType(),u=l.getGeometryType();let c=!1;switch(g){case r.enumPolygon:switch(u){case r.enumPolygon:c=or(h,l,m,i,o);break;case r.enumPolyline:c=ar(h,l,m,i,o);break;case r.enumPoint:c=ur(h,l,m,i);break;case r.enumMultiPoint:c=mr(h,l,m,i,o)}break;case r.enumPolyline:switch(u){case r.enumPolygon:c=ar(l,h,m,Gr(i),o);break;case r.enumPolyline:c=hr(h,l,m,i,o);break;case r.enumPoint:c=cr(h,l,m,i,o);break;case r.enumMultiPoint:c=lr(h,l,m,i,o)}break;case r.enumPoint:switch(u){case r.enumPolygon:c=ur(l,h,m,Gr(i));break;case r.enumPolyline:c=cr(l,h,m,Gr(i),o);break;case r.enumPoint:c=dr(h,l,m,i);break;case r.enumMultiPoint:c=_r(l,h,m,Gr(i))}break;case r.enumMultiPoint:switch(u){case r.enumPolygon:c=mr(l,h,m,Gr(i),o);break;case r.enumPolyline:c=lr(l,h,m,Gr(i),o);break;case r.enumMultiPoint:c=gr(h,l,m,i,o);break;case r.enumPoint:c=_r(h,l,m,i)}break;default:c=!1}return c}function nr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaAreaPredicates_();const i=Wt.constructEmpty(),o=Wt.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaAreaDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}let m=new Te,h=m.addGeometry(e),l=m.addGeometry(t),g=null,u=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){g=new fa;const e=_a(s,m.getEnvelope2D(n));u=pa(e,0),aa(m,e,s,12e3,g,null,n)}ya(m,new ft(s,0).add(u),n,!1,!1);const c=m.getGeometry(l).getBoundary();if(m.filterClosePoints(0,!0,!0,!1,Ae),er(m,h,-1,!1,Ae,n),0===m.getPointCount(h))return!1;er(m,l,-1,!1,Ae,n),r.setEditShape_(m,n);const _=0===m.getPointCount(l);if(!_){r.computeMatrixTopoGraphHalfEdges_(h,l),r.m_topoGraph.removeShape();const e=pr(r.m_matrix,r.m_scl);if(!e)return e}const d=m.getGeometry(h);m=new Te,h=m.addGeometry(d),l=m.addGeometry(c),r.setEditShape_(m,n),r.m_predicateCount=0,r.resetMatrix_(),r.setPredicates_(_?"T*****F**":"******F**"),r.setAreaLinePredicates_(),r.computeMatrixTopoGraphHalfEdges_(h,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.m_scl)}function rr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaLinePredicates_();const i=Wt.constructEmpty(),o=Wt.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaLineDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}const m=new Te,h=m.addGeometry(e),l=m.addGeometry(t);if(r.setEditShapeCrackAndCluster_(m,new ft(s,0),n),0===m.getPointCount(h))return!1;r.computeMatrixTopoGraphHalfEdges_(h,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.m_scl)}function ir(e){if(9!==e.length)return 1;for(let t=0;t<9;t++){const s=e[t];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function or(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaAreaPredicates_();const o=Wt.constructEmpty(),a=Wt.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.areaAreaDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ar(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaLinePredicates_();const o=Wt.constructEmpty(),a=Wt.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.areaLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function mr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=Wt.constructEmpty(),a=Wt.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.areaPointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function hr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLineLinePredicates_();const o=Wt.constructEmpty(),a=Wt.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.lineLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function lr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=Wt.constructEmpty(),a=Wt.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.linePointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function gr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=new Wt,a=new Wt;e.queryEnvelope(o),t.queryEnvelope(a);let m=!1;if(qr(o,a,s)&&(i.pointPointDisjointPredicates_(),m=!0),!m){const n=new Te,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new ft(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ur(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=Wt.constructEmpty();e.queryEnvelope(o);const a=t.getXY();let m=!1;if(Or(a,o,s)&&(i.areaPointDisjointPredicates_(e),m=!0),!m){const t=Lo(e,a,s);if(1===t)i.m_matrix[0]=0,i.m_matrix[2]=2,i.m_matrix[3]=-1,i.m_matrix[5]=1,i.m_matrix[6]=-1;else if(2===t){i.m_matrix[6]=-1;if(0!==e.calculateArea2D())i.m_matrix[0]=-1,i.m_matrix[3]=0,i.m_matrix[2]=2,i.m_matrix[5]=1;else{i.m_matrix[0]=0,i.m_matrix[3]=-1,i.m_matrix[5]=-1;const t=Wt.constructEmpty();e.queryEnvelope(t),i.m_matrix[2]=t.height()||t.width()?1:-1}}else i.areaPointDisjointPredicates_(e)}return pr(i.m_matrix,n)}function cr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=Wt.constructEmpty();e.queryEnvelope(o);let a=!1;if(Or(t.getXY(),o,s)&&(i.linePointDisjointPredicates_(e),a=!0),!a){let n=null,o=!1,a=!1;if(i.m_performPredicates[0]||i.m_performPredicates[6]){!Hr(e,t,s,4,r)?(i.m_performPredicates[0]&&(n=Ge(e),a=!Hr(n,t,s,4,r),o=!0,i.m_matrix[0]=a?-1:0),i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[6]=0)}if(i.m_performPredicates[3]&&(null!==n&&n.isEmpty()?i.m_matrix[3]=-1:(o||(null==n&&(n=Ge(e)),a=!Hr(n,t,s,4,r),o=!0),i.m_matrix[3]=a?0:-1)),i.m_performPredicates[5])if(null!==n&&n.isEmpty())i.m_matrix[5]=-1;else if(o&&!a)i.m_matrix[5]=0;else{null===n&&(n=Ge(e));const o=Hr(n,t,s,3,r);i.m_matrix[5]=o?-1:0}if(i.m_performPredicates[2]){if(0!==e.calculateLength2D())i.m_matrix[2]=1;else{const n=new ve({vd:e.getDescription()});n.addPoints(e,0,e.getPointCount());const o=Hr(n,t,s,3,r);i.m_matrix[2]=o?-1:0}}}return pr(i.m_matrix,i.m_scl)}function _r(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=Wt.constructEmpty();e.queryEnvelope(o);const a=t.getXY(),m=new T;let h=!1;if(Or(a,o,s)&&(i.pointPointDisjointPredicates_(),h=!0),!h){let t=!1,n=!0;const r=s*s;for(let s=0;s<e.getPointCount()&&(e.queryXY(s,m),T.sqrDistance(m,a)<=r?t=!0:n=!1,!t||n);s++);t?(i.m_matrix[0]=0,i.m_matrix[2]=n?-1:0,i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[2]=0,i.m_matrix[6]=0)}return pr(i.m_matrix,n)}function dr(e,t,s,n,r){const i=e.getXY(),o=t.getXY(),a=N(9,-1);T.sqrDistance(i,o)<=s*s?a[0]=0:(a[2]=0,a[6]=0),a[8]=2;return pr(a,n)}function pr(e,t){for(let s=0;s<9;s++)switch(t[s]){case"T":if(-1===e[s])return!1;break;case"F":if(-1!==e[s])return!1;break;case"0":if(0!==e[s])return!1;break;case"1":if(1!==e[s])return!1;break;case"2":if(2!==e[s])return!1}return!0}function fr(e,t,s){const n=N(9,-1);if(e.isEmpty()&&t.isEmpty())return pr(n,s);let i,o=!1;e.isEmpty()?(i=t,o=!0):i=e,n[0]=-1,n[1]=-1,n[3]=-1,n[4]=-1,n[6]=-1,n[7]=-1,n[8]=2;const m=i.getGeometryType();if(a(m))if(m===r.enumPolygon){if(0!==i.calculateArea2D())n[2]=2,n[5]=1;else{n[5]=-1;const e=Wt.constructEmpty();i.queryEnvelope(e),n[2]=e.height()||e.width()?1:0}}else{const e=0!==i.calculateLength2D();n[2]=e?1:0,n[5]=Ne(i)?0:-1}else n[2]=0,n[5]=-1;return o&&Nr(n),pr(n,s)}function xr(e,t,s){return yr(e)?3:Pr(e)?4:Er(e,t,s)?8:Sr(e,t,s)?16:Ir(e)?64:Cr(e)?1:br(e,t,s)?32:0}function yr(e){return"T*F**FFF*"===e}function Pr(e){return"FF*FF****"===e}function Er(e,t,s){return(0!==t||0!==s)&&(2===t&&2===s?"F***T****"===e:(2===t||1===t)&&0===s&&"F**T*****"===e)}function Sr(e,t,s){return t>s?"T*****T**"===e:1===t&&1===s&&"0********"===e}function Cr(e){return"T*****FF*"===e}function Ir(e){return"T**FF*FF*"===e}function br(e,t,s){return t===s&&(1!==t?"T*T***T**"===e:"1*T***T**"===e)}function wr(e,t,s){const n=t.getGeometryID(e);for(let r=t.getFirstCluster();r!==Ae;r=t.getNextCluster(r)){if(0===(t.getClusterParentage(r)&n))continue;const e=t.getClusterHalfEdge(r);if(e===Ae){t.setClusterUserIndex(r,s,0);continue}let i=e,o=0;do{const e=i;0!==(t.getHalfEdgeParentage(e)&n)&&o++,i=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(i!==e);t.setClusterUserIndex(r,s,o)}}class vr{m_clusterIndexA=-1;m_clusterIndexB=-1;m_visitedIndex=-1;m_topoGraph=new tn;m_matrix=N(9,0);m_maxDim=N(9,0);m_performPredicates=N(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 t=0;t<9;t++)"*"!==this.m_scl[t]?(this.m_performPredicates[t]=!0,this.m_predicateCount++):this.m_performPredicates[t]=!1}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&-2===this.m_matrix[e]&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return-2!==this.m_matrix[e]&&(-1===this.m_matrix[e]?(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):"T"!==this.m_scl[e]&&"F"!==this.m_scl[e]?!(this.m_matrix[e]<this.m_maxDim[e])&&(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0))}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,s,n,r){const i=-1!==t,o=-1!==n;if(i||o){if(!("T"!==s&&"F"!==s&&i||"T"!==r&&"F"!==r&&o)||0!==e.calculateArea2D())i&&(this.m_matrix[t]=2),o&&(this.m_matrix[n]=1);else if(o&&(this.m_matrix[n]=-1),i){const s=Wt.constructEmpty();e.queryEnvelope(s),this.m_matrix[t]=s.height()||s.width()?1:0}}}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),Nr(this.m_matrix)}areaLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=Ne(t);this.m_matrix[7]=e?0:-1}this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){const e=this.m_scl[0],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const e=Ne(t);this.m_matrix[1]=e?0:-1}this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=Ne(e);this.m_matrix[5]=t?0:-1}if(this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=Ne(t);this.m_matrix[7]=e?0:-1}}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=Ne(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,s,3);const t=this.isPredicateKnown_(3);n&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,s);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,s,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,s,t,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(7);n&&=r}return n}lineLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,s,t,this.m_clusterIndexB,this.m_clusterIndexA,3);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,s,this.m_clusterIndexA,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,s,t,this.m_clusterIndexB,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(6);n&&=r}return n}pointPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}return n}interiorAreaInteriorArea_(e,t,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(n&t)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(e,t,s,n){if(2===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(n&t)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(e),r=this.m_topoGraph.getClusterParentage(n);if(0!==(r&t)&&0!==(r&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(r&s)&&0===(i&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(e,t,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0!==(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[1]=0)}}}}interiorAreaExteriorLine_(e,t,s){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getHalfEdgeParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,s,n){if(1===this.m_matrix[3])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(r&t)||0===(r&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(e,t,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);0!==(n&t)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(e),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(s&t)&&0===(n&t)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0===(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[7]=0)}}}}interiorLineInteriorLine_(e,t,s,n,r){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(i&t)||0===(i&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2==0&&t%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(e,t,s,n,r,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&t)&&0!==(a&s)){const e=this.m_topoGraph.getClusterUserIndex(o,n),t=this.m_topoGraph.getClusterUserIndex(o,r);if(e%2==0&&t%2!=0)return void(this.m_matrix[i]=0)}}}interiorLineExteriorLine_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(e,t,s,n,r){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2!=0&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(e,t,s,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const t=this.m_topoGraph.getHalfEdgeTo(e);if(0===(this.m_topoGraph.getClusterParentage(t)&s)){if(this.m_topoGraph.getClusterUserIndex(t,n)%2!=0)return void(this.m_matrix[r]=0)}}}interiorAreaInteriorPoint_(e,t){if(0===this.m_matrix[0])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0!==(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(e,t){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(e,t){if(1===this.m_matrix[5])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(0===this.m_matrix[6])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0===(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[0])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2==0)return void(this.m_matrix[0]=0)}}interiorLineExteriorPoint_(e,t,s,n){if(1===this.m_matrix[2])return;if(-1===this.m_topoGraph.getClusterHalfEdge(e)){if(0!==this.m_matrix[2]){if(0===(this.m_topoGraph.getClusterParentage(e)&s))return void(this.m_matrix[2]=0)}}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[3])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[3]=0)}}boundaryLineExteriorPoint_(e,t,s,n){if(0===this.m_matrix[5])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0===(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[5]=0)}}exteriorLineInteriorPoint_(e,t,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(e);0!==(n&t)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(e,t,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(e,t,s,n){if(0===this.m_matrix[n])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let i=this.m_topoGraph.getFirstCluster();i!==Ae;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===Ae){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(i,n,r),s))break;continue}let t=e;do{let e=t;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(e,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==t&&!s);if(s)break;t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(t!==e);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);for(let i=this.m_topoGraph.getFirstCluster();i!==Ae&&(s=this.m_predicatesCluster(i,n,r),!s);i=this.m_topoGraph.getNextCluster(i));s||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,s){let n=0;if(e.hasCurves()){const r=new fa,i=e.getEnvelope2D(s),o=_a(t.total(),i);n=pa(o,0),aa(e,o,t.total(),12e3,r,null,s),r.clearStitcher(e)}ya(e,t.add(n),s,!1,!1),e.filterClosePoints(0,!0,!0,!1,Ae);for(let i=e.getFirstGeometry();i!==Ae;i=e.getNextGeometry(i))e.getGeometryType(i)===r.enumPolygon&&er(e,i,-1,!1,Ae,s);this.setEditShape_(e,s)}}function Nr(e){const t=e[1],s=e[2],n=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=s,e[7]=n}function Tr(e,t,s){const n=e.getGeometryType();if(i(n)){const t=new Ce({vd:e.getDescription()});return t.addSegment(e,!0),t}if(n===r.enumEnvelope){const s=e,n=Wt.constructEmpty();if(e.queryEnvelope(n),n.height()<=t&&n.width()<=t){const t=new pt({vd:e.getDescription()});return s.getCenter(t),t}if(n.height()<=t||n.width()<=t){const t=new Ce({vd:e.getDescription()}),n=new pt;return s.queryCornerByVal(0,n),t.startPathPoint(n),s.queryCornerByVal(2,n),t.lineToPoint(n),t}const r=new we({vd:e.getDescription()});return r.addEnvelope(s,!1),r}return e}function Gr(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Dr{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=Wt.constructEmpty();m_envInter=Wt.constructEmpty();m_quadTree=null;m_qtIter;m_segIter;m_function;m_intersector=null;nullFunc(){return o("should not be called"),!1}constructor(e,t,s,n=!1){this.m_function=this.nullFunc;const r=e.getAccelerators();let i=null;null!=r&&(i=n?r.getQuadTreeForPaths():r.getQuadTree());const o=t.getAccelerators();let m=null;if(null!=o&&(m=n?o.getQuadTreeForPaths():o.getQuadTree()),null===i&&null===m&&!n){const n=e.getPointCount(),r=t.getPointCount();if(n>10&&r>10){const o=Wt.constructEmpty(),h=Wt.constructEmpty(),l=Wt.constructEmpty();e.queryLooseEnvelope(o),t.queryLooseEnvelope(h),o.inflateCoords(s,s),h.inflateCoords(s,s),l.setCoords({env2D:o}),l.intersect(h),n>=r?i=a(e.getGeometryType())?Dt(e,l):Vt(e,l):m=a(t.getGeometryType())?Dt(t,l):Vt(t,l)}}this.construct_(e,i,t,m,s,n)}next(){if(this.m_bQuadTree){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}return!!this.m_intersector&&this.m_intersector.next()}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):a(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?a(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||d(""),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||d(""),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(e,t,s,n,i,o){const m=Wt.constructEmpty(),h=Wt.constructEmpty();e.queryLooseEnvelope(m),s.queryLooseEnvelope(h),m.inflateCoords(i,i),h.inflateCoords(i,i),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(h),this.m_multiVertexImplA=e,this.m_multiVertexImplB=s;const l=e.getGeometryType(),g=s.getGeometryType();this.m_bPaths=o,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=r.enumUnknown,this.m_bQuadTree=!1,null!==t&&(this.m_bDone=!1,this.m_tolerance=i,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,a(g)?(this.m_queryType=g,this.m_function=this.nextPath_,o?this.m_pathIndex=s.getPathCount():this.m_segIter=s.querySegmentIterator()):(this.m_queryType=g,this.m_function=this.nextPoint_,this.m_pointIndex=s.getPointCount())),this.m_bQuadTree||null!==n&&(this.m_bDone=!1,this.m_tolerance=i,this.m_quadTree=n,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,a(l)?(this.m_queryType=l,this.m_function=this.nextPath_,o?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=l,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(o&&a(l)&&a(g)?this.m_intersector=At(e,s,i):a(l)&&a(g)?(this.m_intersector=Ft(e,s,i),this.m_bSwapElements=!1):a(l)&&!a(g)?(this.m_intersector=kt(e,s,i),this.m_bSwapElements=!1):!a(l)&&a(g)?(this.m_intersector=kt(s,e,i),this.m_bSwapElements=!0):(this.m_intersector=Ht(e,s,i),this.m_bSwapElements=!1))}nextPath_(){return this.m_bPaths?-1===--this.m_pathIndex?(this.m_bDone=!0,!1):(this.m_bSwapElements?this.m_multiVertexImplB.queryPathEnvelope(this.m_pathIndex,this.m_query):this.m_multiVertexImplA.queryPathEnvelope(this.m_pathIndex,this.m_query),this.m_qtIter.resetIterator(this.m_query,this.m_tolerance),this.m_function=this.iterate_,!0):this.m_segIter.nextPath()?(this.m_function=this.nextSegment_,!0):(this.m_bDone=!0,!1)}nextSegment_(){if(!this.m_segIter.hasNextSegment())return this.m_function=this.nextPath_,!0;const e=this.m_segIter.nextSegment(),t=new Wt;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const e=new T;if(this.m_bSwapElements){const t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{const t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(Wt.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&(a(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Vr(e){return 2===e?1:1===e?2:128===e?64:64===e?128:e}function Fr(e,t,s){let n;if(e instanceof oc||null===e){const r=Wt.constructEmpty();r.setCoords({pt:t}),r.mergeEnvelope2D(s),n=ht(e,r,!1)}else n=e;return n}function kr(e,t,s){let n;if(e instanceof oc||null===e){const r=Wt.constructEmpty();r.setCoords({env2D:t}),r.mergeEnvelope2D(s),n=ht(e,r,!1)}else n=e;return n}function Hr(e,t,s,o,a){if(e.isEmpty()||t.isEmpty())return 4===o;n(e),n(t);let m=e.getGeometryType(),h=t.getGeometryType();if(m===r.enumEnvelope){if(h===r.enumEnvelope)return Ar(e,t,s,o);if(h===r.enumPoint)return Mr(t,e,s,Vr(o))}else if(m===r.enumPoint){if(h===r.enumEnvelope)return Mr(e,t,s,o);if(h===r.enumPoint)return Ur(e,t,s,o)}const l=Wt.constructEmpty();e.queryEnvelope(l);const g=Wt.constructEmpty();t.queryEnvelope(g);const u=kr(s,l,g);if(qr(l,g,u))return 4===o;let c=!1,_=null,d=null,p=null,f=null;switch(i(m)?(_=new Ce({vd:e.getDescription()}),_.addSegment(e,!0),p=_,m=r.enumPolyline):p=e,i(h)?(d=new Ce({vd:t.getDescription()}),d.addSegment(t,!0),f=d,h=r.enumPolyline):f=t,m!==r.enumEnvelope&&h!==r.enumEnvelope?(p.getDimension()<f.getDimension()||m===r.enumPoint&&h===r.enumMultiPoint)&&(o=Vr(o)):m!==r.enumPolygon&&h!==r.enumEnvelope&&(o=Vr(o)),m){case r.enumPolygon:switch(h){case r.enumPolygon:c=Rr(p,f,u,o,a);break;case r.enumPolyline:c=Yr(p,f,u,o,a);break;case r.enumPoint:c=Xr(p,f,u,o);break;case r.enumMultiPoint:c=Lr(p,f,u,o);break;case r.enumEnvelope:c=zr(p,f,u,o,a)}break;case r.enumPolyline:switch(h){case r.enumPolygon:c=Yr(f,p,u,o,a);break;case r.enumPolyline:c=Wr(p,f,u,o,a);break;case r.enumPoint:c=jr(p,f,u,o);break;case r.enumMultiPoint:c=Zr(p,f,u,o);break;case r.enumEnvelope:c=Kr(p,f,u,o,a)}break;case r.enumPoint:switch(h){case r.enumPolygon:c=Xr(f,p,u,o);break;case r.enumPolyline:c=jr(f,p,u,o);break;case r.enumMultiPoint:c=Jr(f,p,u,o)}break;case r.enumMultiPoint:switch(h){case r.enumPolygon:c=Lr(f,p,u,o);break;case r.enumPolyline:c=Zr(f,p,u,o);break;case r.enumMultiPoint:c=Qr(p,f,u,o);break;case r.enumPoint:c=Jr(p,f,u,o);break;case r.enumEnvelope:c=$r(p,f,u,o)}break;case r.enumEnvelope:switch(h){case r.enumPolygon:c=zr(f,p,u,o,a);break;case r.enumPolyline:c=Kr(f,p,u,o,a);break;case r.enumMultiPoint:c=$r(f,p,u,o)}}return c}function Ar(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=Wt.constructEmpty();e.queryEnvelope(i);const o=Wt.constructEmpty();t.queryEnvelope(o);const a=kr(s,i,o);switch(n){case 4:return qr(i,o,a);case 2:return go(o,i,a,!1);case 128:return go(o,i,a,!0);case 1:return go(i,o,a,!1);case 64:return go(i,o,a,!0);case 3:return mo(i,o,a);case 8:return ho(i,o,a);case 32:return lo(i,o,a);case 16:return!1}return!1}function Mr(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=Wt.constructEmpty();t.queryEnvelope(o);const a=Fr(s,i,o);switch(n){case 4:return Or(i,o,a);case 2:case 128:return ao(i,o,a);case 1:case 64:return!1;case 3:return io(i,o,a);case 8:return oo(i,o,a)}return!1}function Ur(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=t.getXY();let a;if(s instanceof oc||null===s){const e=Wt.constructEmpty();e.setCoords({pt:i}),e.merge(o),a=ht(s,e,!1)}else a=s;switch(n){case 4:return no(i,o,a);case 2:case 128:return ro(o,i,a);case 1:case 64:return ro(i,o,a);case 3:return so(i,o,a)}return!1}function qr(e,t,s){const n=Wt.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!e.isIntersecting(n)}function Br(e,t,s,n=!1){const r=e.getGeometryType(),i=t.getGeometryType();if(f(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();h(null===e)}}if(f(i)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();h(null===t)}}return 0}function Or(e,t,s,n){const r=Wt.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(s,s),!r.contains(e)}function Rr(e,t,s,n,r){switch(n){case 4:return ti(e,t,s);case 2:return ri(t,e,s,r);case 128:return ii(t,e,s);case 1:return ri(e,t,s,r);case 64:return ii(e,t,s);case 3:return ei(e,t,s,r);case 8:return si(e,t,s);case 32:return ni(e,t,s,r)}return!1}function Yr(e,t,s,n,r){switch(n){case 4:return oi(e,t,s);case 1:return hi(e,t,s,r);case 64:return li(e,t,s);case 8:return ai(e,t,s,r);case 16:return mi(e,t,s)}return!1}function Xr(e,t,s,n,r){switch(n){case 4:return gi(e,t,s);case 1:case 64:return ci(e,t,s);case 8:return ui(e,t,s)}return!1}function Lr(e,t,s,n,r){switch(n){case 4:return _i(e,t,s);case 1:return fi(e,t,s,!1);case 64:return fi(e,t,s,!0);case 8:return di(e,t,s);case 16:return pi(e,t,s)}return!1}function zr(e,t,s,n,r){if(yi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Si(e,t,s,!1);case 128:return Si(e,t,s,!0);case 1:return Ci(e,t,s,!1,r);case 64:return Ci(e,t,s,!0,r);case 3:return xi(e,t,s,r);case 8:return Pi(e,t,s,r);case 32:return Ei(e,t,s,r);case 16:return!1}return!1}function Wr(e,t,s,n,r){switch(n){case 4:return bi(e,t,s);case 2:return Ti(t,e,s,r);case 128:return Gi(t,e,s,r);case 1:return Ti(e,t,s,r);case 64:return Gi(e,t,s,r);case 3:return Ii(e,t,s,r);case 8:return wi(e,t,s,r);case 32:return Ni(e,t,s,r);case 16:return vi(e,t,s,r)}return!1}function jr(e,t,s,n,r){switch(n){case 4:return Di(e,t,s);case 1:case 64:return Fi(e,t,s);case 8:return Vi(e,t,s)}return!1}function Zr(e,t,s,n,r){switch(n){case 4:return ki(e,t,s);case 1:case 64:return Mi(e,t,s);case 8:return Hi(e,t,s);case 16:return Ai(e,t,s)}return!1}function Kr(e,t,s,n,r){if(qi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Oi(e,t,s,!1);case 128:return Oi(e,t,s,!0);case 1:case 64:case 32:return!1;case 3:return Ui(e,t,s);case 8:return Bi(e,t,s,r);case 16:return Ri(e,t,s)}return!1}function Qr(e,t,s,n,r){switch(n){case 4:return Xi(e,t,s);case 2:case 128:return zi(t,e,s);case 1:case 64:return zi(e,t,s);case 3:return Yi(e,t,s);case 32:return Li(e,t,s)}return!1}function Jr(e,t,s,n,r){switch(n){case 4:return ji(e,t,s);case 2:case 128:return Zi(e,t,s);case 1:case 64:return Ki(e,t,s);case 3:return Wi(e,t,s)}return!1}function $r(e,t,s,n,r){switch(n){case 4:return Ji(e,t,s);case 2:return eo(e,t,s,!1);case 128:return eo(e,t,s,!0);case 1:case 64:return!1;case 3:return Qi(e,t,s);case 8:return $i(e,t,s);case 16:return to(e,t,s)}return!1}function ei(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!mo(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;const o=e.calculateLength2D(),a=t.calculateLength2D(),m=Math.max(e.getPointCount(),t.getPointCount());if(Math.abs(o-a)>4*m*s)return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!0)}function ti(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function si(e,t,s,n){return Br(e,t),Go(e,t,s,null)}function ni(e,t,s,n){return Br(e,t),Do(e,t,s,n)}function ri(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),Vo(e,t,s,n))}function ii(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!1))}function oi(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function ai(e,t,s,n){return Br(e,t),Fo(e,t,s,n)}function mi(e,t,s,n){return Br(e,t),ko(e,t,s,null)}function hi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),Ho(e,t,s,n))}function li(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!1))}function gi(e,t,s,n){return 0===Xo(e,t,s)}function ui(e,t,s,n){return Mo(e,t.getXY(),s)}function ci(e,t,s,n){return Ao(e,t.getXY(),s)}function _i(e,t,s,n,r){Br(e,t);return 1===co(e,t,s)}function di(e,t,s,n){Br(e,t);const r=Wt.constructEmpty();e.queryEnvelope(r),r.inflateCoords(s,s);const i=new T;let o=!1;const a=e.getImpl(),m=new we;let h=e,l=!1;for(let g=0;g<t.getPointCount();g++){if(t.queryXY(g,i),r.contains(i)){const e=Lo(h,i,s);if(2===e)o=!0;else if(1===e)return!1}l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?h=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m),l=!0)}return!!o}function pi(e,t,s,n){Br(e,t);const r=new Wt,i=new Wt,o=new Wt;e.queryEnvelope(r),t.queryEnvelope(o),i.setCoords({env2D:r}),i.inflateCoords(s,s);let a=!1,m=!1;const h=new T,l=e.getImpl(),g=new we;let u=e,c=!1;for(let _=0;_<t.getPointCount();_++){if(t.queryXY(_,h),i.contains(h)){const e=Lo(u,h,s);0===e?m=!0:1===e&&(a=!0)}else m=!0;if(a&&m)return!0;c||(!Wn(e,t.getPointCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?u=e:(e.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),u=g),c=!0)}return!1}function fi(e,t,s,n,r){const i=Wt.constructEmpty(),o=Wt.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);let a=!1;const m=new T,h=e.getImpl(),l=new we;let g=e,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,m),!i.contains(m))return!1;const r=Lo(g,m,s);if(1===r)a=!0;else if(0===r)return!1;if(n&&2===r)return!1;u||(!Wn(e,t.getPointCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),u=!0)}return a}function xi(e,t,s,n){const r=new Wt,i=new Wt;if(e.queryEnvelope(r),t.queryEnvelope(i),!mo(r,i,s))return!1;const o=new we;return o.addEnvelope(t,!1),ei(e,o,s,n)}function yi(e,t,s,n){Br(e,t);const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;return 0===Lo(e,i.getLowerLeft(),0)&&(!i.contains(e.getXY(0))&&!To(e,i,s))}function Pi(e,t,s,n){Br(e,t);const r=new Wt,i=new Wt;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new we;return o.addEnvelope(t,!1),Go(e,o,s,n)}function Ei(e,t,s,n){Br(e,t);const r=new Wt,i=new Wt;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new we;return o.addEnvelope(t,!1),Do(e,o,s,n)}function Si(e,t,s,n,r){const i=Wt.constructEmpty(),o=Wt.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),n?fo(o,i,s):po(o,i,s)}function Ci(e,t,s,n,r){const i=Wt.constructEmpty(),o=Wt.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=new we;return a.addEnvelope(t,!1),n?2===uo(e,a,s,!1):Vo(e,a,s,r)}function Ii(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!mo(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!1)}function bi(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl();return!new Dr(r,i,s,!0).next()||!Io(e,t,s)}function wi(e,t,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=Wt.constructEmpty(),i=Wt.constructEmpty(),o=Wt.constructEmpty();let a,m;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(m=Zt(t,o,s,0,n),m.isEmpty())return!1}else m=t;return sr(a,m,s,"F********",n,!1)}if(0!==i)return!1;const o=new ve;for(let h=0;h<r.length;h+=2){const e=r[h],t=r[h+1];o.addXY(e,t)}const a=e.getBoundary(),m=t.getBoundary();return a.addPoints(m,0,m.getPointCount()),!a.isEmpty()&&zi(a,o,s)}function vi(e,t,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=Wt.constructEmpty(),i=Wt.constructEmpty(),o=Wt.constructEmpty();let a,m;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(m=Zt(t,o,s,0,n),m.isEmpty())return!1}else m=t;return sr(a,m,s,"0********",n,!1)}if(0!==i)return!1;const o=new ve;for(let h=0;h<r.length;h+=2){const e=r[h],t=r[h+1];o.addXY(e,t)}const a=e.getBoundary(),m=t.getBoundary();return a.addPoints(m,0,m.getPointCount()),!!a.isEmpty()||!zi(a,o,s)}function Ni(e,t,s,n){Br(e,t);const r=Wt.constructEmpty(),i=Wt.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=xo(r,i,s),a=xo(i,r,s),m=e.hasNonLinearSegments(),h=t.hasNonLinearSegments(),l=bo(e,t,s,null);if(-1===l)return!1;if(1===l){if(o&&a)return!0;if(!m&&!h)return o&&!a?!Co(t,e,s,!1):a&&!o?!Co(e,t,s,!1):!Co(e,t,s,!1)&&!Co(t,e,s,!1)}const g=Wt.constructEmpty(),u=Wt.constructEmpty(),c=Wt.constructEmpty();let _,d;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),u.setCoords({env2D:i}),u.inflateCoords(1e3*s,1e3*s),c.setCoords({env2D:g}),c.intersect(u);let p="";if(p+="1*",o){if(t.getPointCount()>10){if(d=Zt(t,c,s,0,n),d.isEmpty())return!1}else d=t;p+="****"}else d=t,p+="T***";if(a){if(e.getPointCount()>10){if(_=Zt(e,c,s,0,n),_.isEmpty())return!1}else _=e;p+="***"}else _=e,p+="T**";return sr(_,d,s,p,n,!1)}function Ti(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;if(Br(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"******FF*",n,!1)}return Co(t,e,s,!1)}function Gi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;Br(e,t);return sr(e,t,s,"T**FF*FF*",n,!1)}function Di(e,t,s,n){Br(e,t);return!vo(e,t.getXY(),s)}function Vi(e,t,s,n){Br(e,t);return qo(e,t.getXY(),s)}function Fi(e,t,s,n){Br(e,t);return No(e,t.getXY(),s)}function ki(e,t,s,n){return Br(e,t),!wo(e,t,s,!1)}function Hi(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=new ve,a=new Dr(r,i,s,!1),m=r.querySegmentIterator();let h=!1;for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();m.resetToVertex(e,-1);const n=m.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(h=!0,o.addPoint2D(r))}if(!h)return!1;const l=e.getBoundary();return!l.isEmpty()&&zi(l,o,s)}function Ai(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=i.getPointCount(),a=N(o,!1),m=new Dr(r,i,s,!1),h=r.querySegmentIterator();let l=!1;for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();h.resetToVertex(e,-1);const n=h.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(l=!0,a[t]=!0)}if(!l)return!1;let g=!1;for(let _=0;_<o;_++)if(!a[_]){g=!0;break}if(!g)return!1;const u=e.getBoundary();if(u.isEmpty())return!0;const c=new ve;for(let _=0;_<o;_++)a[_]&&c.addPoint2D(i.getXY(_));return!zi(u,c,s)}function Mi(e,t,s,n,r){const i=Wt.constructEmpty(),o=Wt.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=wo(e,t,s,!0);if(!a)return a;const m=e.getBoundary();return m.isEmpty()?a:!zi(m,t,s)}function Ui(e,t,s,n){const r=new Wt,i=new Wt;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s&&i.width()>s)&&mo(r,i,s)}function qi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=Bo(i,r,s);return 0===o?!To(e,i,s):4===o}function Bi(e,t,s,n){const i=new Wt,a=new Wt;if(e.queryEnvelope(i),t.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;const m=new Wt,h=new Wt;if(m.setCoords({env2D:a}),h.setCoords({env2D:a}),m.inflateCoords(s,s),h.inflateCoords(-s,-s),h.containsEnvelope(i)||!i.isIntersecting(m))return!1;const l=e.getImpl().querySegmentIterator();l.stripAttributes();const g=e.getImpl().getAccelerators();let u=null,c=null;null!==g&&(u=g.getQuadTree(),null!==u&&(c=u.getIterator(a,s))),c||l.nextPath()||o("relational_operations");let _=!1,d=null;const p=new T,f=new T,x=e.hasNonLinearSegments();let y=!1;for(;;){if(null!==c){const e=c.next();if(-1===e)break;l.resetToVertex(u.getElement(e),-1),d=l.nextSegment()}else{for(;!l.hasNextSegment()&&l.nextPath(););if(!l.hasNextSegment())break;d=l.nextSegment()}if(x&&d.getGeometryType()!==r.enumLine){const e=new Wt;if(d.queryEnvelope(e),h.containsEnvelope(e))return!1;if(m.isIntersecting(e)){y=!0;break}}else{p.assign(d.getStartXY()),f.assign(d.getEndXY());let e=h.clipLine(p,f);if(0!==e)return!1;_||(e=m.clipLine(p,f),0!==e&&(_=!0))}}if(!y)return _;const P=new we;return P.addEnvelope(a,!1),ai(P,e,s,n)}function Oi(e,t,s,n,i){const a=Wt.constructEmpty(),m=Wt.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(m),m.height()<=s||m.width()<=s)return!1;if(n)return fo(m,a,s);if(!po(m,a,s))return!1;const h=Wt.constructEmpty();h.setCoords({env2D:m}),h.inflateCoords(-s,-s);const l=Wt.constructEmpty();if(l.setCoords({env2D:m}),l.inflateCoords(s,s),h.containsEnvelope(a))return!0;const g=e.getImpl().querySegmentIterator();g.stripAttributes(),g.nextPath()||o("relational_operations");let u,c,_,d,p,f,x=!1;const y=e.hasNonLinearSegments();for(y&&(_=new Fe,d=new Fe,p=new Fe,f=new Fe,h.querySide(0,_),h.querySide(1,d),h.querySide(2,p),h.querySide(3,f));;){for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;const e=g.nextSegment();if(y&&e.getGeometryType()!==r.enumLine){if(e.isIntersecting(_,s)){x=!0;break}if(e.isIntersecting(d,s)){x=!0;break}if(e.isIntersecting(p,s)){x=!0;break}if(e.isIntersecting(f,s)){x=!0;break}}else{u=e.getStartXY(),c=e.getEndXY();if(0!==h.clipLine(u,c)){x=!0;break}}}return x}function Ri(e,t,s,n){const i=new Wt,o=new Wt;if(e.queryEnvelope(i),t.queryEnvelope(o),o.height()<=s||o.width()<=s)return!1;const a=new Wt;if(a.setCoords({env2D:o}),a.inflateCoords(s,s),a.containsEnvelope(i))return!1;const m=!0,l=new Wt;if(l.setCoords({env2D:o}),l.inflateCoords(-s,-s),!l.isIntersecting(i))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const u=e.getImpl().getAccelerators();let c=null,_=null;if(null!==u&&(c=u.getQuadTree(),null!==c&&(_=c.getIterator(o,s))),!_){const e=g.nextPath();h(e)}let d=!1,p=null;const f=new T,x=new T;let y=null,P=null,E=null,S=null;for(e.hasNonLinearSegments()&&(y=new Fe,P=new Fe,E=new Fe,S=new Fe,l.querySide(0,y),l.querySide(1,P),l.querySide(2,E),l.querySide(3,S));;){if(null!==_){const e=_.next();if(-1===e)break;g.resetToVertex(c.getElement(e),-1),p=g.nextSegment()}else{for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;p=g.nextSegment()}if(p.getGeometryType()===r.enumLine){f.assign(p.getStartXY()),x.assign(p.getEndXY());if(0!==l.clipLine(f,x)){d=!0;break}}else{if(y.isIntersecting(p,s)){d=!0;break}if(P.isIntersecting(p,s)){d=!0;break}if(E.isIntersecting(p,s)){d=!0;break}if(S.isIntersecting(p,s)){d=!0;break}}}return d&&m}function Yi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!mo(r,i,s)&&(!!Po(e,t,s)||Eo(e,t,s,!1,!0,!1))}function Xi(e,t,s,n){const r=e,i=t,o=new Dr(r,i,s,!1),a=s*s,m=new T,h=new T;for(;o.next();){const e=o.getRedElement(),t=o.getBlueElement();if(r.queryXY(e,m),i.queryXY(t,h),T.sqrDistance(m,h)<=a)return!1}return!0}function Li(e,t,s,n){return Eo(e,t,s,!1,!1,!0)}function zi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&Eo(t,e,s,!0,!1,!1)}function Wi(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),mo(r,i,s)}function ji(e,t,s,n){return Uo(e,t.getXY(),s)}function Zi(e,t,s,n){return Wi(e,t,s)}function Ki(e,t,s,n){return!ji(e,t,s)}function Qi(e,t,s,n){const r=new Wt,i=new Wt;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s||i.width()>s)&&mo(r,i,s)}function Ji(e,t,s,n){const r=Wt.constructEmpty(),i=Wt.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;const o=Wt.constructEmpty();o.setCoords({env2D:i}),o.inflateCoords(s,s);const a=new T;for(let m=0;m<e.getPointCount();m++)if(e.queryXY(m,a),o.contains(a))return!1;return!0}function $i(e,t,s,n){const r=new Wt,i=new Wt,o=new Wt;if(t.queryEnvelope(r),r.height()<=s||r.width()<=s)return!1;i.setCoords({env2D:r}),o.setCoords({env2D:r}),i.inflateCoords(s,s),o.inflateCoords(-s,-s);const a=new T;let m=!1;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,a),i.contains(a)){if(o.containsExclusive(a))return!1;m=!0}return m}function eo(e,t,s,n,r){const i=Wt.constructEmpty(),o=Wt.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),o.height()<=s||o.width()<=s)return!1;if(n)return fo(o,i,s);if(!po(o,i,s))return!1;let a=!1;const m=Wt.constructEmpty(),h=Wt.constructEmpty();m.setCoords({env2D:o}),h.setCoords({env2D:o}),m.inflateCoords(-s,-s),h.inflateCoords(s,s);const l=new T;for(let g=0;g<e.getPointCount();g++){if(e.queryXY(g,l),!h.contains(l))return!1;m.containsExclusive(l)&&(a=!0)}return a}function to(e,t,s,n){const r=new Wt,i=new Wt;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new Wt,a=new Wt;o.setCoords({env2D:i}),o.inflateCoords(-s,-s),a.setCoords({env2D:i}),a.inflateCoords(s,s);const m=new T;let h=!1,l=!1;for(let g=0;g<e.getPointCount();g++)if(e.queryXY(g,m),!h&&o.containsExclusive(m)&&(h=!0),l||a.contains(m)||(l=!0),h&&l)return!0;return!1}function so(e,t,s,n){return T.sqrDistance(e,t)<=s*s}function no(e,t,s,n){return T.sqrDistance(e,t)>s*s}function ro(e,t,s,n){return so(e,t,s)}function io(e,t,s,n){const r=new Wt;return r.setCoords({pt:e}),mo(r,t,s)}function oo(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=new Wt,i=new Wt;return r.setCoords({env2D:t}),r.inflateCoords(s,s),!!r.contains(e)&&(i.setCoords({env2D:t}),i.inflateCoords(-s,-s),!i.containsExclusive(e))}function ao(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=Wt.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(-s,-s);return r.containsExclusive(e)}function mo(e,t,s,n){return po(e,t,s)&&po(t,e,s)}function ho(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;const r=new Wt;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!(!r.isEmpty()&&r.height()>s&&r.width()>s)&&(r.setCoords({env2D:e}),r.inflateCoords(s,s),r.intersect(t),!r.isEmpty())}function lo(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;if(po(e,t,s))return!1;if(po(t,e,s))return!1;const r=new Wt;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!r.isEmpty()&&(r.height()>s||r.width()>s)}function go(e,t,s,n,r){if(e.height()<=s||e.width()<=s)return!1;if(n)return fo(e,t,s);if(!po(e,t,s))return!1;const i=Wt.constructEmpty();return i.setCoords({env2D:e}),i.inflateCoords(-s,-s),i.intersect(t),!i.isEmpty()}function uo(e,t,s,n,i){const o=new T,a=new T,m=Wt.constructEmpty(),h=Wt.constructEmpty(),l=e.getImpl(),g=t.getImpl(),u=g.getGeometryType(),c=new Dr(l,g,s,!0);if(!c.next())return 1;if(Io(e,t,s))return n?4:0;const _=new we;let d=e;const p=new we;let f=null;u===r.enumPolygon&&(f=t);const x=u===r.enumPolygon?N(l.getPathCount(),!1):[],y=N(g.getPathCount(),!1);let P=!1,E=!1,S=!1,C=!1,I=!1,b=!1;do{if(S&&I||C&&b)break;if(S&&C)break;const i=c.getRedElement(),w=c.getBlueElement();if(!y[w]&&(a.assign(t.getXY(t.getPathStart(w))),m.setCoords({env2D:c.getRedEnvelope()}),m.inflateCoords(s,s),m.contains(a))){if(0!==Lo(d,a,0)){if(C=!0,n)return 4}else b=!0;y[w]=!0}if(u===r.enumPolygon&&!x[i]&&(o.assign(e.getXY(e.getPathStart(i))),h.setCoords({env2D:c.getBlueEnvelope()}),h.inflateCoords(s,s),h.contains(o))){if(0!==Lo(f,o,0)){if(S=!0,n)return 4}else I=!0;x[i]=!0}if(P||(!Wn(e,t.getPathCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?d=e:(e.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),P=!0),u===r.enumPolygon&&!E){const s=t;!Wn(s,e.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?f=t:(s.copyTo(p),p.getImpl().buildQuadTreeAccelerator(1),f=p),E=!0}}while(c.next());if(!S&&!C)return 1;if(!I||!b){if(u===r.enumPolygon)for(let e=0,t=l.getPathCount();e<t;e++)if(!x[e]){I=!0;break}for(let e=0,t=g.getPathCount();e<t;e++)if(!y[e]){b=!0;break}}return S&&I||C&&b||S&&C?4:C?2:3}function co(e,t,s,n,r){const i=Wt.constructEmpty();e.queryEnvelope(i),i.inflateCoords(s,s);const o=new T,a=e.getImpl(),m=new we;let h=e,l=!1,g=!1,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,o),i.contains(o)){const e=Lo(h,o,s);if(1===e)return g=!0,4;if(2===e)return 4;u=!0}else u=!0;l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?h=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),h=m),l=!0)}return g?u?4:2:1}function _o(e,t,s,n,i){n[0]=!1;const o=e.getImpl(),a=t.getImpl(),m=o.querySegmentIterator(),l=a.querySegmentIterator(),g=[0,0],u=[0,0],c=new Dr(o,a,s);let _=!1;for(;c.next();){const e=c.getRedElement(),t=c.getBlueElement();m.resetToVertex(e,-1),l.resetToVertex(t,-1);const r=m.nextSegment(),i=l.nextSegment();let o=0;if(Oo(r,i)?!_&&i.isIntersecting(r,s)&&(_=!0):o=i.intersect(r,null,u,g,s),0!==o&&(_=!0,1===o)){const e=g[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return n[0]=!0,!1}}if(!_){n[0]=!0;const i=Wt.constructEmpty();e.queryEnvelope(i),i.inflateCoords(s,s);const m=new we;let l=e,g=!1;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)>0){const n=Wt.constructEmpty();if(t.queryPathEnvelope(s,n),!i.isIntersecting(n))return!1;{const e=zn(l,t.getXY(t.getPathStart(s)),0);if(h(-1!==e),0===e)return!1}g||(!Wn(e,t.getPathCount()-1)||null!==o.getAccelerators()&&null!==o.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}if(1===e.getPathCount()||t.getGeometryType()===r.enumPolyline)return!0;const u=t,c=Wt.constructEmpty();u.queryEnvelope(c),c.inflateCoords(s,s);const _=new we;let d=u,p=!1;for(let t=0,s=e.getPathCount();t<s;t++)if(e.getPathSize(t)>0){const s=Wt.constructEmpty();if(e.queryPathEnvelope(t,s),c.isIntersecting(s)){const s=zn(d,e.getXY(e.getPathStart(t)),0);if(h(-1!==s),1===s)return!1}p||(!Wn(u,e.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?d=u:(u.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),p=!0)}return!0}return!1}function po(e,t,s){const n=Wt.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)}function fo(e,t,s){const n=Wt.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),e.containsExclusiveEnvelope(n)}function xo(e,t,s){const n=Wt.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!n.contains(e.getLowerLeft())||(!n.contains(e.getLowerRight())||(!n.contains(e.getUpperLeft())||!n.contains(e.getUpperRight())))}function yo(e,t,s,n){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);const r=new T,i=new T;let o=!0;const a=s*s;for(let m=0;m<e.getPathCount();m++){if(e.getPathEnd(m)!==t.getPathEnd(m)){o=!1;break}for(let s=e.getPathStart(m);s<t.getPathEnd(m);s++)if(e.queryXY(s,r),t.queryXY(s,i),T.sqrDistance(r,i)>a){o=!1;break}if(!o)break}return!!o}function Po(e,t,s,n){if(e.getPointCount()!==t.getPointCount())return!1;const r=new T,i=new T;let o=!0;const a=s*s;for(let m=0;m<e.getPointCount();m++)if(e.queryXY(m,r),t.queryXY(m,i),T.sqrDistance(r,i)>a){o=!1;break}return!!o}function Eo(e,t,s,n,r,i,o){const a=e.getImpl(),m=t.getImpl(),h=a.getPointCount(),l=m.getPointCount(),g=N(h,!1),u=r||i?N(l,!1):[],c=s*s,_=new Dr(a,m,s);for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement(),s=a.getXY(e),n=m.getXY(t);T.sqrDistance(s,n)<=c&&(g[e]=!0,(r||i)&&(u[t]=!0))}let d=!1,p=!1;for(let y=0;y<h;y++){const e=g[y];if(d||=!e,p||=e,(r||n)&&d)return!1}if(n)return!0;let f=!1,x=!1;for(let y=0;y<l;y++){const e=u[y];if(f||=!e,x||=e,r&&f)return!1}return!!r||d&&p&&f&&x}function So(e,t,s,n){return Co(e,t,s,n)&&Co(t,e,s,n)}function Co(e,t,s,n){if(x(e),x(t),t.isEmpty())return!1;let r=!0;const i=N(2,Number.NaN),a=N(2,Number.NaN),m=[],h=new Yo;let l;const g=Wt.constructEmpty(),u=Wt.constructEmpty(),c=Wt.constructEmpty();e.queryEnvelope(g),t.queryEnvelope(u),g.inflateCoords(s,s),u.inflateCoords(s,s),c.setCoords({env2D:g}),c.intersect(u);const _=e.getImpl().querySegmentIterator(),d=t.getImpl().querySegmentIterator(),p=t.getImpl().getAccelerators();let f=null,y=null,P=null,E=null;if(null!==p&&(f=p.getQuadTree(),y=p.getQuadTreeForPaths(),null!==y&&(E=y.getIteratorForQT())),null===f){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(f=Dt(t.getImpl(),c))}for(null!==f&&(P=f.getIteratorForQT());_.nextPath();)for(;_.hasNextSegment();){let e=_.nextSegment();if(e.queryEnvelope(g),!g.isIntersecting(c))return r=!1,!1;if(null!==E&&(E.resetIterator(g,s),-1===E.next()))continue;let t=0,p=null;if(null!=P)P.resetIterator(e,s);else if(d.resetToFirstPath(),!d.nextPath())return r=!1,!1;do{if(t=0,null!==P){const n=P.next();if(-1===n)return r=!1,!1;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,i,a,s)}else{for(;!d.hasNextSegment();)if(!d.nextPath())return r=!1,!1;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,i,a,s))}}while(2!==t||0!==i[0]||n&&!(a[0]<=a[1]));let x=Number.NaN,y=!1;do{let n=!1;if(1===i[1]){if(!_.hasNextSegment()){y=!0;break}e=_.nextSegment(),n=!0}if(1===a[1]&&a[0]<=a[1]){if(-1===x)break;if(x=1,!d.hasNextSegment())break;p=d.nextSegment(),n=!0}if(0===a[1]&&a[0]>a[1]){if(1===x)break;if(Number.isNaN(x)){if(!d.hasPreviousSegment())break;d.previousSegment(),x=-1}if(!d.hasPreviousSegment())break;p=d.previousSegment(),n=!0}if(!n)break;t=e.intersect(p,null,i,a,s)}while(2===t&&(!n||a[0]<=a[1]));if(y)continue;const S=e.calculateLength2D();e.queryEnvelope(g),m.length=0,h.m_overlapEvents.length=0;let C=!1,I=!1,b=0;const w=ht(null,g,!0);for(null!==P?P.resetIterator(e,s):(d.resetToFirstPath(),d.nextPath()||o("relational_operations"));;){if(t=0,null!==P){const n=P.next();if(-1===n)break;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,i,a,s)}else{for(;!d.hasNextSegment()&&d.nextPath(););if(!d.hasNextSegment())break;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,i,a,s))}if(2===t&&(!n||a[0]<=a[1])){const e=_.getStartPointIndex(),t=_.getPathIndex(),n=d.getStartPointIndex(),r=d.getPathIndex();if(l=Ro(e,t,i[0],i[1],n,r,a[0],a[1]),h.m_overlapEvents.push(l),m.push(m.length),!(C||l.m_scalarA0<b&&l.m_scalarA1<b))if(0===b&&S*(l.m_scalarA0-b)>s)C=!0;else if(0!==b&&S*(l.m_scalarA0-b)>w)C=!0;else if(b=l.m_scalarA1,S*(1-b)<=s||1===b){I=!0;break}}}if(!I){if(!C)return r=!1,!1;m.length>1&&m.sort((e,t)=>h.compareOverlapEvents(e,t)),b=0;for(let e=0;e<h.m_overlapEvents.length;e++)if(l=h.m_overlapEvents[m[e]],!(l.m_scalarA0<b&&l.m_scalarA1<b)){if(0===b&&S*(l.m_scalarA0-b)>s)return r=!1,!1;if(0!==b&&S*(l.m_scalarA0-b)>w)return r=!1,!1;if(b=l.m_scalarA1,S*(1-b)<=s||1===b)break}if(S*(1-b)>s)return r=!1,!1;m.length=0,h.m_overlapEvents.length=0}}return r}function Io(e,t,s){const n=e.getImpl(),r=t.getImpl(),i=n.querySegmentIterator(),o=r.querySegmentIterator(),a=new Dr(n,r,s);for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();i.resetToVertex(e,-1),o.resetToVertex(t,-1);const n=i.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function bo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),m=N(2,Number.NaN),h=new Dr(r,i,s);let l=!1,g=-1;for(;h.next();){const e=h.getRedElement(),t=h.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const r=o.nextSegment(),i=a.nextSegment();let u=0;if(Oo(r,i)){if(i.isIntersecting(r,s))return-2}else u=r.intersect(i,null,m,null,s);if(u)if(2===u){const e=r.calculateLength2D(),t=m[0];if(e*(m[1]-t)>s)return g=1,g;l=!0}else if(g=0,n){const e=m[0],t=new T;r.queryCoord2D(e,t),n.push(t.x),n.push(t.y)}}return l?-2:g}function wo(e,t,s,n){const r=e.getImpl(),i=t,o=i.getPointCount(),a=n?N(o,!1):[],m=new Dr(r,i,s,!1),h=r.querySegmentIterator();for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();h.resetToVertex(e,-1);const r=h.nextSegment(),o=i.getXY(t);if(r.isIntersectingPoint(o,s)){if(!n)return!0;a[t]=!0}}if(!n)return!1;for(let l=0;l<o;l++)if(!a[l])return!1;return!0}function vo(e,t,s){const n=new T,r=s*s,i=e.querySegmentIterator(),o=e.getImpl().getAccelerators();if(null!==o){const e=o.getQuadTree();if(null!==e){const o=Wt.constructEmpty();o.setCoords({pt:t});const a=e.getIterator(o,s);for(let s=a.next();-1!==s;s=a.next())if(i.resetToVertex(e.getElement(s),-1),i.hasNextSegment()){const e=i.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,n),T.sqrDistance(t,n)<=r)return!0}return!1}}const a=Wt.constructEmpty();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(e.queryEnvelope(a),a.inflateCoords(s,s),!a.contains(t))continue;const o=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(o,n),T.sqrDistance(t,n)<=r)return!0}return!1}function No(e,t,s){return vo(e,t,s)&&!qo(e,t,s)}function To(e,t,s,n){const i=e.querySegmentIterator(),o=e.getImpl().getAccelerators(),a=e.hasNonLinearSegments();let m=null,h=null,l=null,g=null;if(null!==o){const e=o.getQuadTree();if(null!==e){const n=e.getIterator(t,s);a&&(m=new Fe,h=new Fe,l=new Fe,g=new Fe,t.querySide(0,m),t.querySide(1,h),t.querySide(2,l),t.querySide(3,g));const o=Wt.constructEmpty();o.setCoords({env2D:t}),o.inflateCoords(s,s);for(let a=n.next();-1!==a;a=n.next())if(i.resetToVertex(e.getElement(a),-1),i.hasNextSegment()){const e=i.nextSegment();if(e.getGeometryType()===r.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(o.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,s))return!0;if(e.isIntersecting(h,s))return!0;if(e.isIntersecting(l,s))return!0;if(e.isIntersecting(g,s))return!0}return!1}}if(a){m=new Fe,h=new Fe,l=new Fe,g=new Fe,t.querySide(0,m),t.querySide(1,h),t.querySide(2,l),t.querySide(3,g);const n=e.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const e=n.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,s))return!0;if(e.isIntersecting(h,s))return!0;if(e.isIntersecting(l,s))return!0;if(e.isIntersecting(g,s))return!0}}else{const n=Wt.constructEmpty();n.setCoords({env2D:t}),n.inflateCoords(s,s);const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=new T;for(let e=0,t=r.getPathCount();e<t;e++){let t=!0;const s=new T,a=new T,m=new T,h=r.getPathStart(e),l=new T;for(let g=h,u=r.getPathEnd(e);g<u;g++)if(t)i.queryPoint2D(2*g,s),l.assign(s),t=!1;else{if(i.queryPoint2D(2*g,o),a.setCoordsPoint2D(s),m.setCoordsPoint2D(o),n.clipLine(a,m))return!0;s.assign(o)}if(r.isClosedPath(e)&&!t&&(a.setCoordsPoint2D(s),m.setCoordsPoint2D(l),n.clipLine(a,m)))return!0}}return!1}function Go(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Nt(r.getIsSimple(0,o))&&Nt(i.getIsSimple(0,o)),m=r.querySegmentIterator(),h=i.querySegmentIterator(),l=N(2,0),g=N(2,0),u=new Dr(r,i,s);let c=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();m.resetToVertex(e,-1),h.resetToVertex(t,-1);const n=m.nextSegment(),r=h.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s)){c=!0;break}}else i=r.intersect(n,null,g,l,s);if(2===i){const e=l[0],t=l[1],r=n.calculateLength2D();if(a&&(t-e)*r>s)return!1;c=!0}else if(i){const e=l[0],t=g[0];if(e>0&&e<1&&t>0&&t<1)return!1;c=!0}}if(!c)return!1;const _=Wt.constructEmpty(),d=Wt.constructEmpty(),p=Wt.constructEmpty();let f,x;if(e.queryEnvelope(_),t.queryEnvelope(d),_.inflateCoords(1e3*s,1e3*s),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(f=Zt(e,p,s,0,n),f.isEmpty())return!1}else f=e;if(t.getPointCount()>10){if(x=Zt(t,p,s,0,n),x.isEmpty())return!1}else x=t;return sr(f,x,s,"F********",n,!1)}function Do(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Nt(r.getIsSimple(0,o))&&Nt(i.getIsSimple(0,o)),m=Wt.constructEmpty(),h=Wt.constructEmpty(),l=Wt.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(h);let g=!1;const u=xo(m,h,s),c=xo(h,m,s),_=r.querySegmentIterator(),d=i.querySegmentIterator(),p=N(2,Number.NaN),f=N(2,Number.NaN),x=new Dr(r,i,s);for(;x.next();){const e=x.getRedElement(),t=x.getBlueElement();_.resetToVertex(e,-1),d.resetToVertex(t,-1);const n=_.nextSegment(),r=d.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s))break}else i=r.intersect(n,null,f,p,s);if(2===i){const e=p[0],t=p[1],r=n.calculateLength2D();if(a&&(t-e)*r>s&&(g=!0,u&&c))return!0}else if(i){const e=p[0],t=f[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const y=Wt.constructEmpty(),P=Wt.constructEmpty();let E,S;y.setCoords({env2D:m}),y.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:h}),P.inflateCoords(1e3*s,1e3*s),l.setCoords({env2D:y}),l.intersect(P);let C="";if(C+=g?"**":"T*",u){if(t.getPointCount()>10){if(S=Zt(t,l,s,0,n),S.isEmpty())return!1}else S=t;C+="****"}else S=t,C+="T***";if(c){if(e.getPointCount()>10){if(E=Zt(e,l,s,0,n),E.isEmpty())return!1}else E=e;C+="***"}else E=e,C+="T**";return sr(E,S,s,C,n,!1)}function Vo(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=Wt.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return nr(a,t,s,n)}function Fo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),m=N(2,Number.NaN),h=N(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,h,m,s),2===i)g=!0;else if(i){const e=m[0],t=h[0];if(e>0&&e<1&&t>0&&t<1)return!1;g=!0}}if(!g)return!1;const u=Wt.constructEmpty(),c=Wt.constructEmpty(),_=Wt.constructEmpty();let d,p;if(e.queryEnvelope(u),t.queryEnvelope(c),u.inflateCoords(1e3*s,1e3*s),c.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:u}),_.intersect(c),e.getPointCount()>10){if(d=Zt(e,_,s,0,n),d.isEmpty())return!1}else d=e;if(t.getPointCount()>10){if(p=Zt(t,_,s,0,n),p.isEmpty())return!1}else p=t;return sr(d,p,s,"F********",n,!1)}function ko(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),m=N(2,Number.NaN),h=N(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,h,m,s),2===i)g=!0;else if(i){const e=m[0],t=h[0];if(e>0&&e<1&&t>0&&t<1)return!0;g=!0}}if(!g)return!1;const u=Wt.constructEmpty(),c=Wt.constructEmpty(),_=Wt.constructEmpty(),d=Wt.constructEmpty(),p=Wt.constructEmpty();if(e.queryEnvelope(u),t.queryEnvelope(c),xo(c,u,s)){let r,i;if(_.setCoords({env2D:u}),_.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:c}),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(r=Zt(e,p,s,0,n),r.isEmpty())return!1}else r=e;if(t.getPointCount()>10){if(i=Zt(t,p,s,0,n),i.isEmpty())return!1}else i=t;return sr(r,i,s,"T********",n,!1)}return sr(e,t,s,"T*****T**",n,!1)}function Ho(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=Wt.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return rr(a,t,s,n)}function Ao(e,t,s,n){return 1===Lo(e,t,s)}function Mo(e,t,s,n){return 2===Lo(e,t,s)}function Uo(e,t,s,n){const r=new T,i=s*s;for(let o=0;o<e.getPointCount();o++)if(e.queryXY(o,r),T.sqrDistance(r,t)<=i)return!1;return!0}function qo(e,t,s){const n=e.getBoundary();return!n.isEmpty()&&!Uo(n,t,s)}function Bo(e,t,s){const n=Wt.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)?1073741824:n.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}function Oo(e,t){return e.getGeometryType()!==r.enumLine||t.getGeometryType()!==r.enumLine}function Ro(e,t,s,n,r,i,o,a){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:s,m_scalarA1:n,m_ivertexB:r,m_ipathB:i,m_scalarB0:o,m_scalarB1:a}}class Yo{m_overlapEvents=[];compareOverlapEvents(e,t){const s=this.m_overlapEvents[e],n=this.m_overlapEvents[t];if(s.m_ipathA<n.m_ipathA)return-1;if(s.m_ipathA===n.m_ipathA){if(s.m_ivertexA<n.m_ivertexA)return-1;if(s.m_ivertexA===n.m_ivertexA){if(s.m_scalarA0<n.m_scalarA0)return-1;if(s.m_scalarA0===n.m_scalarA0){if(s.m_scalarA1<n.m_scalarA1)return-1;if(s.m_scalarA1===n.m_scalarA1&&s.m_ivertexB<n.m_ivertexB)return-1}}}return 1}}function Xo(e,t,s){const n=Ln(e,t,s);return n?1===n?1:2:0}function Lo(e,t,s){const n=zn(e,t,s);return n?1===n?1:2:0}function zo(e,t,s,n,r){for(let i=0;i<s;i++)r[i]=Lo(e,t[i],n)}function Wo(e,t,s,n,i){if(e.getGeometryType()===r.enumPolygon)zo(e,t,s,n,i);else if(e.getGeometryType()===r.enumEnvelope){const r=Wt.constructEmpty();e.queryEnvelope(r),Zo(r,t,s,n,i)}else d("")}function jo(e,t,s,n,o){const a=e.getGeometryType();a===r.enumPolyline?$o(e,t,s,n,o):i(a)?Jo():d("")}function Zo(e,t,s,n,r){if(e.isEmpty()){for(let e=0;e<s;e++)r[e]=0;return}const i=e.clone();i.inflateCoords(.5*-n,.5*-n);const o=e.clone();o.inflateCoords(.5*n,.5*n);for(let a=0;a<s;a++)i.contains(t[a])?r[a]=1:o.contains(t[a])?r[a]=2:r[a]=0}function Ko(e){if(e.isEmpty())return 0;switch(e.getGeometryType()){case r.enumMultiPoint:return e.getImpl().getPointCount();case r.enumPolyline:return e.getImpl().getPathCount();case r.enumPolygon:return e.getImpl().getOGCPolygonCount();case r.enumGeometryCollection:return e.getGeometryCount()}return 1}function Qo(e,t,s){if(s.reset(),t<3)return;const n=e[0].clone(),r=n.x,i=n.y,o=e[1].clone(),a=new T;for(let m=2;m<t;m++)a.assign(e[m]),s.pe((a.x-n.x)*(o.y-i)),n.assign(o),o.assign(a);s.pe((r-n.x)*(o.y-i))}function Jo(e,t,s,n,r){h(0)}function $o(e,t,s,n,r){const i=e.getImpl(),o=i.getAccelerators();let a=null;o&&(a=o.getRasterizedGeometry());let m=s;for(let l=0;l<s;l++)r[l]=1,a&&h(0);if(m){if(o){let e=null;null!==o&&null!==o.getQuadTree()&&(e=o.getQuadTree());const a=i.getPointCount();if(null===e&&a>20&&a*s>4*a+Math.log(a)*s&&(e=Dt(i)),e){let o=null;const a=i.querySegmentIterator(),h=new Wt;for(let i=0;i<s&&m;i++)if(1===r[i]){h.setCoords(t[i]),null===o?o=e.getIterator(h,n):o.resetIterator(h,n);let s=-1;for(let h=o.next();-1!==h;h=o.next()){a.resetToVertex(e.getElement(h),s),s=a.getPathIndex();if(a.nextSegment().isIntersectingPoint(t[i],n)){r[i]=2,m--;break}r[i]=0}}return}}const e=i.querySegmentIterator();for(;e.nextPath()&&m;)for(;e.hasNextSegment()&&m;){const i=e.nextSegment();for(let e=0;e<s&&m;e++)1===r[e]&&i.isIntersectingPoint(t[e],n)&&(r[e]=2,m--)}}for(let h=0;h<s;h++)1===r[h]&&(r[h]=0)}function ea(e,t,s,n,r){const i=Ke(t),o=Math.max(4*i,s);return new oa(t,null,o,Number.NaN,r).approximateWithCirclesImpl(e,n)}function ta(){return Number.isNaN(this.radius.value())}function sa(){return{ptStart:new T,ptEnd:new T,center:new Ze,radius:new ge,fcenter:new st,fradius2:new ue,maxError:Number.NaN,isLine:ta}}const na=5,ra=1/8;function ia(e,t,s,n){return{pt:e.clone(),t,err:s,checkCount:n}}class oa{m_left;m_eps;m_tolerance;m_circleCheckCounter;m_bReversedLeft;m_leftArc;m_tracker;m_trackerCounter;constructor(e,t,s,n,r){this.m_left=e,this.m_tracker=r,this.m_eps=s,this.m_trackerCounter=0,this.m_tolerance=n,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc=sa()}closeToCircularArc(e,t,s,n,r,i){if(this.m_circleCheckCounter++,i.maxError=0,!oa.checkSweepAngle(e,t))return!1;if(i.ptStart.setCoordsPoint2D(s),i.ptEnd.setCoordsPoint2D(r),e.isCircular()){const t=e;return i.fradius2=ue.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),i.radius.set(t.getSemiMajorAxis()),i.fcenter.assignPoint2D(t.getCenter()),i.center.set(t.getCenter()),!0}const o=i.ptEnd.sub(i.ptStart).clone();o.leftPerpendicularThis(),o.normalize();if(Math.abs(o.dotProduct(n.sub(i.ptStart)))<=this.m_eps)return!!this.confirmIsLine(i,o)&&(i.radius.set(Number.NaN),i.center.setCoords(0,0),!0);{const s=i.ptEnd.sub(i.ptStart),r=n.sub(i.ptStart),o=s.crossProduct(r);if(0===o)return!1;const a=.5*s.sqrLength(),m=.5*r.sqrLength();let h=a*r.y-m*s.y;h/=o;let l=s.x*m-r.x*a;l/=o;const g=Math.sqrt(h*h+l*l);if(4*Number.EPSILON*g>this.m_eps)return!1;const u=h+i.ptStart.x,c=l+i.ptStart.y;i.radius.set(g),i.center.setCoords(u,c);const _=this.maxCircleApproximationError(e,t,i);if(_>this.m_eps)return i.maxError=_,!1}const a=(new st).assignPoint2D(i.ptStart),m=(new st).assignPoint2D(i.ptEnd).sub(a),h=(new st).assignPoint2D(n).sub(a),l=m.crossProduct(h);if(l.isZero())return!1;const g=m.sqrLength().mulDouble(.5),u=h.sqrLength().mulDouble(.5),c=g.mul(h.y).sub(u.mul(m.y)),_=m.x.mul(u).sub(h.x.mul(g)),d=c.mul(c).add(_.mul(_)),p=l.clone();p.invertThis(),i.fradius2=d.mul(p).mul(p),i.fcenter.setCoords(c.mul(p).add(a.x),_.mul(p).add(a.y)),i.center.setWithEps(i.fcenter.asPoint2D()),i.radius.setWithEps(Math.sqrt(i.fradius2.toDouble()));const f=Ze.constructPoint2D(i.ptStart).subE(i.center),x=Ze.constructPoint2D(i.ptEnd).subE(i.center);if(!f.dotProduct(x).gt(ce))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===r.enumEllipticArc){const s=e,n=nt(s,t.vmin),r=nt(s,t.vmax);return!(Math.abs(r-n)>.5*j)}return!0}confirmIsLine(e,t){const s=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(s.mul(.25)))>this.m_eps)&&!(Math.abs(t.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,s){const n=[.25,.75],i=[.1,.25,.75,.9];let o,a;e.getGeometryType()===r.enumEllipticArc?(o=n,a=n.length):(o=i,a=i.length);let m=0;for(let r=0;r<a;++r){const n=new T;e.queryCoord2D(R(t.vmin,t.vmax,o[r]),n);const i=n.sub(s.center.value()).length(),a=Math.abs(i-s.radius.value());a>m&&(m=a)}return m}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=N(9,Number.NaN);let r;e?r=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,r=2);const i=[],o=[],a=new T(0,0);for(let m=1;m<r;m++){const e=new A(n[m-1],n[m]);for(this.m_bReversedLeft=!oa.goodOrientation(this.m_left,e),this.m_bReversedLeft?(i.push(ia(a,e.vmin,0,0)),i.push(ia(a,e.vmax,0,0))):(i.push(ia(a,e.vmax,0,0)),i.push(ia(a,e.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t);i.length>1;){this.progress_();const e=i.at(-1);let n=e.checkCount,r=e.err;const a=e.pt.clone(),m=e.t,h=i[i.length-2].t,l=.5*(m+h),g=this.m_left.getCoord2D(l);if(r<=this.m_eps||n>=na){const e=new A;if(e.setCoords(m,h),this.closeToCircularArc(this.m_left,e,a,g,i[i.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(m):t.push(h)),s++,i.pop();continue}n=0,r=this.m_leftArc.maxError}e.t=l,e.pt.setCoordsPoint2D(g),r*=ra,n++,e.err=r,e.checkCount=n,i.push(ia(a,m,r,n))}this.m_bReversedLeft&&t&&(t.length=t.length+o.length,ne(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new Ce,s=[];if(!this.approximateWithCirclesImpl(!0,s))return t;let n=0;const r=this.m_left.getStartXY();t.startPath(r);for(let i=1;i<s.length;++i)if(e)t.lineTo(this.m_left.getCoord2D(s[i]));else{const e=new T;this.m_left.queryCoord2D(s[i],e);const o=new T;this.m_left.queryCoord2D(.5*(s[i]+n),o);const a=new Re;a.constructCircularArcThreePoint(r,e,o),t.addSegment(a,!1),r.assign(e),n=s[i]}return t}static goodOrientation(e,t){const s=e.getCoord2D(t.vmin),n=e.getCoord2D(t.vmax);return s.compare(n)<0}progress_(e=!1){}}function aa(e,t,s,n,r,i,o){ha(e,t,s,r,i,o),Ca(e,s,o)}function ma(e,t,s,n){if(!a(e.getGeometryType()))return e;const i=e.getImpl();if(!i.hasNonLinearSegments())return e;const o=e.createInstance();if(o.getGeometryType()===r.enumPolygon){o.setFillRule(e.getFillRule())}new Te;const m=new pt,h=new Ve,l=[],g=[],u=[],c=e.getDescription().getAttributeCount()>1,_=i.querySegmentIterator();for(;_.nextPath();){let e=!0;for(;_.hasNextSegment();){const n=_.isClosingSegment(),i=_.nextSegment();if(!i.isCurve()){o.addSegment(i,e,n),e=!1;continue}let a,d=!1;const p=!0,f=!0;switch(i.getGeometryType()){case r.enumEllipticArc:case r.enumRationalBezier2:a=He(i,t,s,p,f,g,u,l),d=!0;break;default:a=ke(i,t,s,!0,p,g,l)}const x=d?2:3;g[1].isNAN()?(h.createLine(),h.get().construct(g[0],g[x])):d?(h.createQuadraticRationalBezier(),h.get().constructArrayWeights(g,u)):(h.createCubicBezier(),h.get().constructPoints(g)),c&&e&&(i.queryCoord(l[0],m),h.get().setStart(m)),c&&(i.queryCoord(l[1],m),h.get().setEnd(m)),o.addSegment(h.get(),e,n&&1===a),e=!1;for(let e=1,t=a,s=x;e<t;++e,s+=x)g[s+1].isNAN()?(h.createLine(),h.get().construct(g[s],g[s+x])):d?(h.createQuadraticRationalBezier(),h.get().constructArrayWeights(g.slice(s),u.slice(s))):(h.createCubicBezier(),h.get().constructPoints(g.slice(s))),c&&(i.queryCoord(l[e+1],m),h.get().setEnd(m)),o.addSegment(h.get(),!1,n&&e+1===t)}}return o}function ha(e,t,s,n,r,i){e.hasCurves()?(e.setCurveStitcherPointer(n),n.m_impl=new xa(i,!1,null),n.m_impl.buildMonotonicCurveParentage(e,t,s,r)):n.m_impl=null}function la(e,t,s,n,r,i,o,a){e.hasCurves()?(e.setCurveStitcherPointer(i),i.m_impl=new xa(a,!0,r),i.m_impl.buildMonotonicCurveParentage(e,t,s,o),Ca(e,s,a)):i.m_impl=null}function ga(e){if(!e.hasSegmentParentage())return;const t=e.queryVertexIteratorOnSelection();for(let s=t.next();s!==Ae;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==Ae?e.getSegmentParentage(t):-1,r=e.getSegmentParentage(s);-1!==r&&-1!==n&&r!==n&&e.setSegmentParentageBreakVertex(s,!0)}}function ua(e){if(!e.hasSegmentParentage())return;ga(e);const t=new St(0),s=e.queryVertexIteratorOnSelection();for(let o=s.next();o!==Ae;o=s.next())t.add(o);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(Ae);const n=T.getNAN();e.queryXY(t.read(0),n);let r=0;const i=T.getNAN();for(let o=1,a=t.size();o<a;o++){{const s=t.read(o);s!==Ae?e.queryXY(s,i):i.setNAN()}if(!i.isEqualPoint2D(n)){if(o-r>1){let s=!1;for(let n=r;n<o;++n){const r=t.read(n);if(e.getSegmentParentageBreakVertex(r)){s=!0;break}}if(!s){const n=(t,s,n)=>{const r=e.getPrevVertex(t),i=e.getNextVertex(t);r!==Ae?s.assign(e.getXY(r)):s.setNAN(),i!==Ae?n.assign(e.getXY(i)):n.setNAN()},i=new T,a=new T;n(t.read(r),i,a);for(let e=r+1;e<o;++e){const r=t.read(e);if(r===Ae)continue;const o=new T,m=new T;n(r,o,m);const h=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if(!(h(o,i)&&h(m,a)||h(m,i)&&h(o,a))){s=!0;break}}}if(s)for(let n=r;n<o;++n)e.setSegmentParentageBreakVertex(t.read(n),!0)}n.setCoordsPoint2D(i),r=o}}}function ca(e,t){let s=t.isEmpty()?e:_t(null,t,!0).total();return s>e&&(s=e),.125*s}function _a(e,t){return t||(t=Wt.constructEmpty()),ca(e,t)}function da(e,t){return.125*e}function pa(e,t){return 3*e+3*t}class fa{m_impl=null;stitchCurves(e,t,s,n){this.m_impl&&(this.m_impl.stitchCurves(e,t,s),n&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&(this.m_impl.clearStitcher(e),this.m_impl=null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class xa{constructor(e,t,s){this.m_progressTracker=e,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,s,n){const i=!1,o=!0;if(!e.hasCurves())return;h(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=s;const a=new pt,m=new Ve,l=[],g=[],u=[];for(let c=e.getFirstGeometry();c!==Ae;c=e.getNextGeometry(c))for(let n=e.getFirstPath(c);n!==Ae;n=e.getNextPath(n)){let c=e.getPathSize(n),_=e.getFirstVertex(n),d=0,p=-1;for(let f=0;f<c;f++){let x=e.getNextVertex(_);if(!e.querySegment(_,m,!0,!1)){_=x;continue}if(0===d){p=e.getVertexIndex(_);const t=xa.regularizeCurve(e,m.get(),_,s);if(t>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new ts(13,p,-1)),d=t,c=e.getPathSize(n),x=e.getNextVertex(_);const s=e.querySegment(_,m,!0,!1);h(s)}}else d--;const y=e.getVertexIndex(_);let P;-1!==this.m_originalVertexIndex&&e.setUserIndex(_,this.m_originalVertexIndex,p),e.setSegmentToIndex(y,null);let E=!1;switch(m.get().getGeometryType()){case r.enumEllipticArc:case r.enumRationalBezier2:P=He(m.get(),t,s,i,o,g,u,l),E=!0;break;default:{const e=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();P=ke(m.get(),t,s,e,i,g,l)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(_,S,!0),!g[1].isNAN()){let t=null;t=E?new Be({points:g,weights:u}):new qe({cp:g}),t.snapControlPoints(s*s),e.setSegmentToIndex(y,t)}const C=E?2:3;for(let t=1,r=P,i=C;t<r;++t,i+=C){m.get().queryCoord(l[t],a);const r=e.insertVertex(n,x,a);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,p),!g[i+1].isNAN())if(E){const t=new Be({points:g.slice(i),weights:u.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}else{const t=new qe({cp:g.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}e.setSegmentParentageAndBreak(r,S,!1)}P>1&&(f+=P-1,c=e.getPathSize(n)),this.m_originalPlanarSegments.push(m.releaseSegment()),_=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;h(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const i=new pt,o=new Ve,a=new Oe(0,t,0,this.m_progressTracker,!1,n),m=[];for(let l=e.getFirstGeometry();l!==Ae;l=e.getNextGeometry(l))for(let t=e.getFirstPath(l);t!==Ae;t=e.getNextPath(t)){let n=e.getPathSize(t),r=e.getFirstVertex(t);for(let l=0;l<n;l++){let l=e.getNextVertex(r);if(!e.querySegment(r,o,!0,!1)){r=l;continue}if(xa.regularizeCurve(e,o.get(),r,s)>=0){n=e.getPathSize(t),l=e.getNextVertex(r);const s=e.querySegment(r,o,!0,!1);h(s)}const g=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,g),e.setSegmentToIndex(g,null),m.length=0,a.densifySegment(o.get(),m),this.progress_();const u=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,u,!0);for(let s=1,n=m.length-1;s<n;++s){o.get().queryCoord(m[s],i);const n=e.insertVertex(t,l,i);e.setSegmentParentageAndBreak(n,u,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,g)}this.m_originalPlanarSegments.push(o.releaseSegment()),r=l}}e.clearSegments()}stitchCurves(e,t,s){xa.st_stitchCurvesImpl(this,e,t,s,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){xa.st_stitchCurvesImpl(null,e,Ae,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==Ae?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case r.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case r.enumBezier:return 2;case r.enumBezier2:return 3;case r.enumLine:return-1;case r.enumRationalBezier2:return 4;default:_("")}}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,s,n,r,i,o){if(t===s&&0===n)return h(e.getNextVertex(t)===Ae),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t),m=e.getXY(t),l=e.getXY(s);let g,u=0;{let t=2,r=m;for(let n=a;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);u+=T.distance(s,r),r=s,t++}u+=T.distance(l,r),h(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const c=o;let _=r.getClosestCoordinate(m,!1),d=r.getClosestCoordinate(l,!1);const p=r.calculateLength2D();let f=r.tToLength(_),x=r.tToLength(d);const y=Math.abs(f)>10*c&&Math.abs(f-p)>10*c,P=Math.abs(x)>10*c&&Math.abs(x-p)>10*c,E=e=>{const t=e.calculateLength2D();return Math.abs(t-u)>Math.max(.2*u,4*c)?null:e};let S=r.isClosed();if(!S){const e=T.distance(r.getStartXY(),r.getEndXY());e<=c&&p>5*e&&(S=!0)}if(S){let i,o,a=new T;if(2===n)a=T.lerp(m,l,.5),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);else{let s=e.getNextNthVertex(t,(n-1)/2);a=e.getXY(s),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);let m=Math.abs(o)>10*c&&Math.abs(o-p)>10*c;if(!m&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i),m=Math.abs(o)>10*c&&Math.abs(o-p)>10*c),!m))return}let u=!1;const S=f===x;if(S){const s=0;let i=2,o=4;n-1<=4&&(i=s+1,o=s+2);const a=m,h=e.getXY(e.getNextNthVertex(t,i)),l=e.getXY(e.getNextNthVertex(t,o));u=-T.orientationNonRobust(a,h,l)*U(r.calculateArea2DHelper())>0}else P?y?u=o>f:o<x?(f=0,_=0):(f=p,_=1):o>f?(x=p,d=1):(x=0,d=0);if(S)g=r.clone(),g.dropAllAttributes(),u||g.reverse(),h(m.equals(l));else{let e=!1;_>d&&(e=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.getDescription().getAttributeCount(),e&&g.reverse()}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else if(y||P){if(!y||!P){if(T.distance(r.getStartXY(),r.getEndXY())<10*c){const n=[H(_,d),H(_,d),H(_,d)];y?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],o=[0,0,0];let a=Number.MAX_VALUE,h=0;for(let e=0;e<3;e++){let t=!1;if(n[e].first>n[e].second){t=!0;const s=n[e].first;n[e].first=n[e].second,n[e].second=s}i[e]=r.cut(n[e].first,n[e].second,!0),i[e].dropAllAttributes(),t&&i[e].reverse(),i[e].setCoordsForIntersector(m,l,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(u-o[e]);s<a&&(a=s,h=e)}return g=i[h],g=E(g),void(g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g)))}}let n=!1;_>d&&(n=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.dropAllAttributes(),n&&g.reverse(),g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else{if(g=r.clone(),g.dropAllAttributes(),f>x&&g.reverse(),u<Math.max(.75*p,p-this.m_densificationDeviation*(n-1))){const e=_>d?d:_,t=g.tToLength(e)+u;let s=g.lengthToT(t);s=Z(s,e,1),g=g.cut(e,s,!0)}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}}processSpanCurves_(e,t,s,n,r,i,o){if(t===s&&0===n)return h(e.getNextVertex(t)===Ae),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t);{let t=2;for(let n=a;n!==s;n=e.getNextVertex(n))t++;h(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const m=e.getXY(t),l=e.getXY(s);if(r.isClosed()){if(m.isEqualPoint2D(l)&&m.isEqualPoint2D(r.getStartXY())){let a;if(a=this.verifySegmentFitnessCurves(e,t,s,n,r,i,o)){const n=r.clone();return n.dropAllAttributes(),a<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(m.isEqualPoint2D(r.getStartXY())){if(l.isEqualPoint2D(r.getEndXY())){const a=r.clone();a.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(m)return h(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}}else if(l.isEqualPoint2D(r.getStartXY())&&m.isEqualPoint2D(r.getEndXY())){const a=r.getReversed();a.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(m)return h(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}this.processSpanSplitSegmentCurves(e,t,s,n,r,i,o)}processSpan_(e,t,s,n,r,i,o){return 0===this.m_type?void this.processSpanSmartTe_(e,t,s,n,r,i,o):void this.processSpanCurves_(e,t,s,n,r,i,o)}processSpanSplitSegmentCurves(e,t,s,n,r,i,o){if(r.isLine())return;if(this.fitSegmentToSpanCurves(e,t,s,n,r,i,o))return;const a=o*o;let m=n,h=t;const l=e.getXY(t);let g=r.getClosestCoordinate(l,!1);const u=r.getCoord2D(g);let c=!1;const _=T.sqrDistance(l,u);if(_>a){const n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),n===s)return;h=n,c=!0,m-=1}let d=s;const p=e.getXY(s);g=r.getClosestCoordinate(p,!1);const f=r.getCoord2D(g);let x=!1;const y=T.sqrDistance(p,f);if(y>a){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===h)return;d=t,x=!0,m-=1}if((c||x)&&this.fitSegmentToSpanCurves(e,h,d,m,r,i,o))return;let P=!1;if(!c&&_>0){const s=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),s===d)return;h=s,c=!0,P=!0,m-=1}if(!x&&y>0){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===h)return;d=t,x=!0,P=!0,m-=1}if(P&&this.fitSegmentToSpanCurves(e,h,d,m,r,i,o))return;let E=h;for(;;){const t=e.getNextVertex(E);if(this.approximateSpanSectionCurves(e,E,r,i,o),E=t,E===d)return}}fitSegmentToSpanCurves(e,t,s,n,r,i,o){const a=[];a.push(e.getXY(t));let m=t;const h=new Ve;for(;;){e.querySegment(m,h,!1,!0);const t=[.1,.25,.4,.5,.6,.75,.9,1];let r=0;for(const e of t){(2===n||1&r)&&a.push(h.get().getCoord2D(e)),r++}if(m=e.getNextVertex(m),m===s)break}const l=(()=>{let e=a[0].compare(a.at(-1));if(0===e){const t=new X(0);Qo(a,a.length,t),e=t.getResult()>=0?-1:1}return e>0})();l&&a.reverse();const g=r.clone();if(g.dropAllAttributes(),l&&g.reverse(),g.setSegmentFromCoordsForStitcher(a,a.length),l&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,s,n,g,i,o)){this.removeSpanBetween(e,t,s);const n=e.getVertexIndex(t);return e.setSegmentToIndex(n,g),!0}return!1}approximateSpanSectionCurves(e,t,s,n,i){const a=new Ve;if(!e.querySegment(t,a,!0,!1))return;const m=s.getGeometryType();if(m!==a.get().getGeometryType()){if(m===r.enumEllipticArc){if(a.get().getGeometryType()!==r.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];ea(!1,a.get(),i,s,this.m_progressTracker);const n=e.getNextVertex(t),r=e.getPathFromVertex(t),o=new pt;let m=t;for(let t=1,i=s.length;t<i;t++){const i=s[t],h=a.get().getCoord2D(s[t-1]),l=a.get().getCoord2D(R(s[t-1],i,.5));a.get().queryCoord(i,o);const g=o.getXY(),u=new Re;u.constructCircularArcThreePoint(h,g,l);let c=Ae;i<1&&(c=e.insertVertex(r,n,o)),e.setSegmentToIndex(e.getVertexIndex(m),u),m=c}return}{const s=B(T,3);a.get().queryControlPoints(s);const n=[0,0,0];a.get().queryWeights(n);const r=Ye(n),i=new Re;return Xe(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}o("approximate_span_section_")}}verifySegmentFitnessCurves(e,t,s,n,r,i,o){const a=e.getXY(t),m=e.getXY(s);if(!a.isEqualPoint2D(r.getStartXY())||!m.isEqualPoint2D(r.getEndXY()))return 0;let h=0;if(r.isClosed()){const e=r.getCoord2D(.1).sub(a);h=r.getCoord2D(.7).sub(a).crossProduct(e)>=0?1:-1}const l=N(Le.s_maxMonotonicPartParams,Number.NaN);let g=r.getMonotonicPartParams(l.length,l);g--;const u=new Fe,c=[1,.5,.75,.25];let _=0,d=t;const p=a.clone();for(;;){const t=e.getNextVertex(d);let n=e.getSegment(d);null===n&&(e.queryLineConnector(d,u,!0),n=u);for(let e=t===s?1:0;e<c.length;e++){const t=n.getCoord2D(c[e]);if(!r.isCloserThanDistance(t,A.unit(),o))return 0}if(g>1)for(let e=1;e<g;){const t=r.getCoord2D(l[e]);n.isCloserThanDistance(t,A.unit(),o)?(l[g-1]=M(l[e],l[e]=l[g-1]),g--):e++}if(h){const e=n.getCoord2D(.25);_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e),e.assign(n.getCoord2D(.75)),_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e)}if(d=t,d===s)return g>1?0:h?_<0?-h:h:1}}removeSpanBetween(e,t,s){e.setSegmentToIndex(e.getVertexIndex(t),null);const n=e.getNextVertex(t);n!==s&&e.removeVertices(n,s)}static st_stitchCurvesImpl(e,t,s,n,r){if(!t.hasSegmentParentage())return;ga(t);let i=s===Ae?t.getFirstGeometry():s;for(;i!==Ae;)if(S(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==Ae;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);const m=t.getSegmentParentage(a);if(o){if(-1!==m&&!t.getSegmentParentageBreakVertex(a)){let e=t.getPrevVertex(a);const s=a;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(m!==r){h(-1===r);break}if(a=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){a=s,t.setSegmentParentageBreakVertex(a,!0);break}e=t.getPrevVertex(e),h(n<i)}}}else h(-1===m||t.getSegmentParentageBreakVertex(a));let l=a;for(let s=0;s<i&&l!==Ae;){const o=t.getSegmentParentage(l);if(-1===o){if(s++,l=t.getNextVertex(l),l===a)break;continue}let m=0,g=Ae;const u=l;m=1;let c=t.getNextVertex(u);for(;s<i&&c!==Ae;){s++,g=c,m++;const e=t.getSegmentParentage(c);if(-1===e||t.getSegmentParentageBreakVertex(c))break;h(e===o),c=t.getNextVertex(c)}if(g===Ae){h(0);break}if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,u,g,m,s,o,n)}if(l=g,l===a)break}}if(s!==Ae)break;i=t.getNextGeometry(i)}else i=s===Ae?t.getNextGeometry(i):Ae}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let i=s===Ae?t.getFirstGeometry():s;for(;i!==Ae;){for(let s=t.getFirstPath(i);s!==Ae;s=t.getNextPath(s)){let i=t.getPathSize(s);t.isClosedPath(s)&&(i+=1);let o=!0,a=!1;const m=t.getFirstVertex(s);let l=m;for(let s=0;s<i&&l!==Ae;){let g=t.getSegmentParentage(l);if(-1===g||o){o=!1,s++,l=t.getNextVertex(l),a=!0;continue}let u,c,_=0;if(a?(u=t.getPrevVertex(l),c=l,h(u!==Ae),h(c!==u),h(-1===t.getSegmentParentage(u)||m===u)):(u=l,c=t.getNextVertex(u),s++,h(c!==Ae),h(c!==u),g=t.getSegmentParentage(c)),_=2,a=!1,-1===g||t.getSegmentParentageBreakVertex(c)){l=c;continue}let d=t.getNextVertex(c);for(s++;s<i&&d!==Ae;){c=d,_++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;h(e===g),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[g];e.processSpan_(t,u,c,_,s,g,n)}l=c}}if(s!==Ae)break;i=t.getNextGeometry(i)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let i=s===Ae?t.getFirstGeometry():s;for(;i!==Ae;)if(S(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==Ae;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);if(o){if(-1!==t.getSegmentParentage(a)){let e=a;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===i){a=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else h(-1===t.getSegmentParentage(a)||t.getSegmentParentageBreakVertex(a));let m=a;for(let s=0;s<i&&m!==Ae;){const o=t.getSegmentParentage(m);if(-1===o){s++,m=t.getNextVertex(m);continue}let a=0,l=Ae;const g=m;a=1;let u=t.getNextVertex(g);for(;s<i&&u!==Ae;){s++,l=u,a++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;h(e===o),u=t.getNextVertex(u)}if(l===Ae)break;if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,g,l,a,s,o,n)}m=l}}if(s!==Ae)break;i=t.getNextGeometry(i)}else i=s===Ae?t.getNextGeometry(i):Ae}static regularizeCurve(e,t,s,n){let r=t.snapControlPoints(n*n);if(r){const n=e.getVertexIndex(s),r=t.clone();e.setSegmentToIndex(n,r)}if(t.getGeometryType()===qe.type){const i=[],o=t.calculateSpecialPointsForCracking(n,i);if(o>0){const a=[];if(o>1)for(let e=0;e<o;e++)if(a.push(t.getCoord2D(i[e])),e>0){const t=(Math.abs(a[e].x)+Math.abs(a[e].y))*Q(),s=T.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new T;J(a[e-1],a[e],.5,t),a[e-1]=t,a[e]=t}}e.splitSegment(s,i,o),r=e.snapControlPoints(s,o+1,n*n)||r;for(let t=0;t<o;t++)s=e.getNextVertex(s),e.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function ya(e,t,s,n,r){return new ba(e,s,t,n,r).do_()}function Pa(e,t,s){const n=xt(e);return ln(t.getX(),t.getY(),s.getX(),s.getY(),L(n))}function Ea(e,t,s=1,n=1,r=1,i=1){if(n>i)return e;if(i>n)return t;const o=[0],a=[0],m=new pt;return cn(e,t,s,n,r,i,m,a,o),m}function Sa(e,t,s){const n=xt(t),r=Et(t);return!!_n(e,n,Ae,null,s)||Mn(!0,e,r,null,s)}function Ca(e,t,s){return ba.fixCurveTwoPointLoops(e,t,s)}function Ia(e){return xt(e)}class ba{m_shape;m_progressTracker;m_tolerance;m_bFilterDegenerateSegments;m_bTrackChanges;m_progressCounter;constructor(e,t,s,n,r){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=r,this.m_progressCounter=0}do_(){const e=new ft(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=1e-5,s=1e-6,n=Ia(e);let r=Et(e);const i=r*(1+t);r*=1+s;let a=!1;const m=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),h=this.m_shape.hasPointFeatures();for(let l=0;;l++){this.m_shape.dbgCheckSelection(),l>m&&o("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let e=-1;0===l&&(e=this.firstCrack_(),a||=e>0);const t=this.cluster_(n);if(this.m_shape.dbgVerifyMonotone(),a||=t,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(n,!0,!1,this.m_bTrackChanges,Ae);a||=e,this.m_shape.dbgVerifyMonotone()}const s=this.m_shape.snapControlPointsOnSelection(i*i);a||=s,this.m_shape.dbgCheckSelection();let g=!1;if((0===l&&-1===e||h||Mn(!0,this.m_shape,r,null,this.m_progressTracker))&&(g=this.crack_(i),a||=g,this.m_shape.dbgVerifyMonotone()),!g&&!ba.fixCurveTwoPointLoops(this.m_shape,n,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return a&&ua(this.m_shape),a}cluster_(e){return hn(this.m_shape,e,Ae,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return An(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,s){if(!e.hasCurves())return!1;e.dbgVerifyCurves();const n=e.createUserIndexUninitialized(),r=new St(0),i=e.queryVertexIteratorOnSelection();for(let h=i.next();h!==Ae;h=i.next())r.add(h),e.setUserIndex(h,n,-1);if(0===r.size())return!1;r.add(Ae),e.sortVerticesSimpleByY(r,0,r.size()-1);let o=0;const a=e.getXY(r.read(o)),m=new T(Number.NaN,Number.NaN),l=[];for(let h=1,g=r.size();h<g;++h){const t=r.read(h),s=t!==Ae?e.getXY(t):m;if(s.equals(a))continue;const i=[];for(let m=o;m<h;m++){const t=r.read(m),s=e.getPrevVertex(t);if(s!==Ae&&-1===e.getUserIndex(s,n)){const t=wa(e.getXY(s),e.getSegment(s));0!==T.sqrDistance(a,t.otherPt)&&(t.vert=s,t.dir=-1,i.push(t)),e.setUserIndex(s,n,1)}const o=e.getNextVertex(t);if(o!==Ae&&-1===e.getUserIndex(t,n)){const s=wa(e.getXY(o),e.getSegment(t));0!==T.sqrDistance(a,s.otherPt)&&(s.vert=t,s.dir=1,i.push(s)),e.setUserIndex(t,n,1)}}if(i.length>1){i.sort((e,t)=>Ta(e,t));const e=wa(m.clone(),null);i.push(e);let t=0;for(let s=1,n=i.length;s<n;s++)if(!i[s].otherPt.equals(i[s-1].otherPt)){if(s-t>1&&null!==i[t].seg){let e=!1;const n=t;for(let r=t+1;r<s;r++)if(!va(i[n],i[r])){e=!0;break}if(e)for(let r=t;r<s&&null!==i[r].seg;r++)l.push(i[r].vert)}t=s}}o=h,a.setCoordsPoint2D(s)}for(const g of l){const s=e.getSegment(g);h(null!==s);const n=e.getXY(g),r=e.getXY(e.getNextVertex(g));if(T.distance(n,r)<3*t)e.setSegmentToIndex(e.getVertexIndex(g),null);else{const t=s.lengthToT(.5*s.calculateLength2D());e.splitSegment(g,[t],1)}}return e.removeUserIndex(n),l.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=_t(null,e,!0).total();if(4*t<this.m_tolerance.total()){let e=!1;const s=1.1*t,n=t,r=this.cluster_(s);e||=r;let i=0;this.m_bFilterDegenerateSegments&&(i=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,Ae));const o=this.crack_(n);return e||=o,e?1:i?2:0}return-1}progress_(e=!1){this.m_progressCounter++,!e&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function wa(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function va(e,t){if(h(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const s=e.seg.getGeometryType();if(s!==t.seg.getGeometryType())return!1;if(s===r.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=M(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=M(o,o=a)),r.equals(o)&&i.equals(a)}if(s===r.enumRationalBezier2){const s=e.seg,n=t.seg,r=s.getControlPoint1(),i=n.getControlPoint1();if(!r.equals(i))return!1;const o=[0,0,0];s.queryWeights(o),-1===e.dir&&(o[2]=M(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=M(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}o("")}function Na(e,t){if(null===e.seg||null===t.seg)return null!==e.seg?-1:null!==t.seg?1:0;const s=e.seg.getGeometryType(),n=t.seg.getGeometryType();return s<n?-1:s>n?1:0}function Ta(e,t){const s=e.otherPt.compare(t.otherPt);return 0!==s?s:Na(e,t)}var Ga=a,Da=i,Va=g;function Fa(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:h(0,"unrecognized cut side")}return 3}function ka(){return{unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1}}function Ha(e,t,s,n){return new Ka(n).autoCompleteImpl(e,t,s)}function Aa(e,t,s,n,i,o,a){const m=new Ka(i);m.m_bOGCOutput=!0;const h=e.getGeometryType()===r.enumPolygon&&1===e.getFillRule()&&!Nt(n);return m.planarSimplifyImpl_(e,t,h,s,n,i,o,a)}function Ma(e,t,s,n,r,i,o,a){return new Ka(i).planarSimplifyImpl_(e,t,s,n,r,i,o,a)}function Ua(e,t,s,n){const r=new Ka(n),i=new Te,o=i.addGeometry(t),a=r.planarSimplifyNoCrackingAndCluster(e,i,o,s);h(a,"planar_simplify_no_cracking_and_cluster");return i.getGeometry(o)}function qa(e,t,s,n,r,i,o){return h(0),{}}function Ba(e,t,s,n){return h(0),{}}function Oa(e,t,s){return Ja(e,t,s)}function Ra(e,t,s,n){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return $a(em(e),e,t,"-");const i=new Wt;e.queryEnvelope(i);const o=new Wt;t.queryEnvelope(o);const a=new Wt;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const m=_t(s,a,!0),h=o.clone(),l=xt(m);if(h.inflateCoords(l,l),!i.isIntersecting(h))return $a(em(e),e,t,"-");const g=new Ka(n),u=new Te,c=u.addGeometry(em(e)),_=u.addGeometry(em(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(n);p=da(m.total());const t=_a(m.total(),e);d=pa(t,p),aa(u,t,m.total(),12e3,f,null,n)}g.setEditShapeCrackAndCluster(u,m.add(d));const x=g.difference(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"-");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,m.total()),y.getGeometryType()===r.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Ya(e,t,s,n){if(e.getDimension()>t.getDimension())return $a(em(e),e,t,"^");if(e.getDimension()<t.getDimension())return $a(em(t),e,t,"^");if(e.isEmpty())return $a(em(t),e,t,"^");if(t.isEmpty())return $a(em(e),e,t,"^");const i=new Wt;e.queryEnvelope(i);const o=new Wt;t.queryEnvelope(o);const a=new Wt;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const m=_t(s,a,!0),h=new Ka(n),l=new Te,g=l.addGeometry(em(e)),u=l.addGeometry(em(t));let c=0,_=null;if(l.hasCurves()){_=new fa;const e=l.getEnvelope2D(n);c=da(m.total());aa(l,_a(m.total(),e),m.total(),12e3,_,null,n)}h.setEditShapeCrackAndCluster(l,m);const d=h.symmetricDifference(g,u);null!==_&&_.stitchCurves(l,d,c,!0);const p=$a(l.getGeometry(d),e,t,"^");return Ga(p.getGeometryType())&&(p.getImpl().setIsSimple(4,m.total()),p.getGeometryType()===r.enumPolygon&&p.getImpl().updateOGCFlagsProtected()),p}function Xa(e,t,s){return Qa(e,t,s,!0)}function La(e,t,s){return e.isEmpty()||t.isEmpty()?e.createInstance():Pa(s,e,t)?new pt({copy:Ea(e,t)}):e.createInstance()}function za(e,t,s,n){const i=Wt.constructEmpty();e.queryEnvelope(i);const o=Wt.constructEmpty();t.queryEnvelope(o);const a=Wt.constructEmpty();a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const m=_t(s,a,!0),h=new Wt(o),l=xt(m);if(h.inflateCoords(l,l),!i.isIntersecting(h)){if(e.getDimension()<=t.getDimension())return $a(em(e.createInstance()),e,t,"&");if(e.getDimension()>t.getDimension())return $a(em(t.createInstance()),e,t,"&")}const g=new Ka(n),u=new Te,c=u.addGeometry(em(e)),_=u.addGeometry(em(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(n);p=da(m.total());const t=_a(m.total(),e);d=pa(t,p),aa(u,t,m.total(),12e3,f,null,n)}g.setEditShapeCrackAndCluster(u,m.add(d));const x=g.intersection(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"&");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,m.total()),y.getGeometryType()===r.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Wa(e,t,s,n){const i=new Array(3),o=Wt.constructEmpty();e.queryEnvelope(o);const a=Wt.constructEmpty();t.queryEnvelope(a);const m=Wt.constructEmpty();m.setCoords({env2D:o}),m.mergeEnvelope2D(a);const h=_t(s,m,!0),l=new Wt(a),g=xt(h);if(l.inflateCoords(g,g),!o.isIntersecting(l)){if(e.getDimension()<=t.getDimension()){const s=$a(em(e.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}if(e.getDimension()>t.getDimension()){const s=$a(em(t.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}}const u=new Ka(n),c=new Te,_=c.addGeometry(em(e)),d=c.addGeometry(em(t));let p=0,f=0,x=null;if(c.hasCurves()){x=new fa;const e=c.getEnvelope2D(n);f=da(h.total());const t=_a(h.total(),e);p=pa(t,f),aa(c,t,h.total(),12e3,x,null,n)}u.setEditShapeCrackAndCluster(c,h.add(p)),c.dbgVerifyCurves();const y=u.intersectionEx(_,d);for(const P of y){null!==x&&x.stitchCurves(c,P,f,!1);const s=$a(c.getGeometry(P),e,t,"&");Ga(s.getGeometryType())&&(s.getImpl().setIsSimple(4,h.total()),s.getGeometryType()===r.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),i[s.getDimension()]=s}return null!==x&&x.clearStitcher(c),i}function ja(e,t,n,r,i,o=!1){0===t&&s("not enough geometries to dissolve");let a=0;for(let s=0,d=t;s<d;s++)a=Math.max(e[s].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!1,e,t,n,i,o);let m=0,h=-1;for(let s=0,d=t;s<d;s++)e[s].getDimension()===a&&(-1===h&&(h=s),e[s].isEmpty()||(h=s,m++));if(m<2)return em(e[h]);const l=Tt.constructEmpty(),g=new Te;let u=Ae;for(let s=0,d=t;s<d;s++)if(e[s].getDimension()===a&&!e[s].isEmpty()){u===Ae?u=g.addGeometry(em(e[s])):g.appendGeometry(u,em(e[s]));const t=Tt.constructEmpty();e[s].queryLooseEnvelope(t),l.mergeEnv3D(t)}const c=_t(n,l.getEnvelope2D(),!0),_=new Ka(r);if(o){const e=Gt(n,l.getEnvelopeZs(),!0);return _.planarSimplify3DImpl_(g,c,e,0,!0)}return _.m_bOGCOutput=!0,_.planarSimplifyMultiPoints(g,c,!1,-1)}function Za(e,t,n,r,i,o=!1){t<2&&s("not enough geometries to dissolve");let a=0;for(let s=0,p=t;s<p;s++)a=Math.max(e[s].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!0,e,t,n,i,o);const m=Tt.constructEmpty(),h=new Te;let l=Ae,g=0,u=-1;for(let s=0,p=t;s<p;s++)if(e[s].getDimension()===a&&(-1===u&&(u=s),!e[s].isEmpty())){u=s,l===Ae?l=h.addGeometry(em(e[s])):h.appendGeometry(l,em(e[s]));const t=Tt.constructEmpty();e[s].queryLooseEnvelope(t),m.mergeEnv3D(t),g++}if(g<2)return em(e[u]);const c=0===a?n:null,_=_t(c,m.getEnvelope2D(),!0),d=new Ka(r);if(o){const e=Gt(c,m.getEnvelopeZs(),!0);return d.m_bOGCOutput=!0,d.planarSimplify3DImpl_(h,_,e,0,!0)}return d.planarSimplifyMultiPoints(h,_,!0,-1)}class Ka{m_progressTracker;m_topoGraph=null;m_maskLookup=[];m_dummyPt1=T.getNAN();m_dummyPt2=T.getNAN();m_fromEdgeForPolylines=Ae;m_progressCounter=0;m_bOGCOutput=!1;constructor(e){this.m_progressTracker=e}linesToPolygonsImpl(e,t){let s=0,n=0,r=null;if(e.hasCurves()){r=new fa;const i=e.getEnvelope2D(this.m_progressTracker);n=da(t.total());const o=_a(t.total(),i);s=pa(o,n),aa(e,o,t.total(),12e3,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(s));const i=this.m_topoGraph.createUserIndexForChains(),o=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(o,i,1);for(let m=this.m_topoGraph.getChainFirstIsland(o);m!==Ae;m=this.m_topoGraph.getChainNextInParent(m))this.m_topoGraph.setChainUserIndex(m,i,1);const a=[];for(let m=this.m_topoGraph.getFirstChain();m!==Ae;m=this.m_topoGraph.getChainNext(m)){if(1===this.m_topoGraph.getChainUserIndex(m,i))continue;this.m_topoGraph.setChainUserIndex(m,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(m);e!==Ae;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);if(0===this.m_topoGraph.getChainArea(m))continue;const t=this.m_topoGraph.extractPolygonFromChainAndIslands(e,Ae,m,Ae);null!=r&&r.stitchCurves(e,t,n,!1);const s=e.getGeometry(t);a.push(s)}return new es(a)}autoCompleteImpl(e,t,s){let n=0,r=0,i=null;if(e.hasCurves()){i=new fa;const t=e.getEnvelope2D(this.m_progressTracker);r=da(s.total());const o=_a(s.total(),t);n=pa(o,r),aa(e,o,s.total(),12e3,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,s.add(n));const o=this.m_topoGraph.getGeometryID(t),a=this.m_topoGraph.createUserIndexForChains(),m=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(m,a,1);for(let l=this.m_topoGraph.getChainFirstIsland(m);l!==Ae;l=this.m_topoGraph.getChainNextInParent(l))this.m_topoGraph.setChainUserIndex(l,a,1);const h=[];for(let l=this.m_topoGraph.getFirstChain();l!==Ae;l=this.m_topoGraph.getChainNext(l)){if(1===this.m_topoGraph.getChainUserIndex(l,a))continue;this.m_topoGraph.setChainUserIndex(l,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(l);e!==Ae;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);if(0!==this.m_topoGraph.getChainParentage(l))continue;const t=this.m_topoGraph.getChainHalfEdge(l);let s=t,n=!1;do{const e=this.m_topoGraph.getHalfEdgeTwin(s);if(this.m_topoGraph.getHalfEdgeChain(e)!==l&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){n=!0;break}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==t);if(!n)continue;if(0===this.m_topoGraph.getChainArea(l))continue;const m=this.m_topoGraph.extractPolygonFromChainAndIslands(e,Ae,l,Ae);null!==i&&i.stitchCurves(e,m,r,!1);const g=e.getGeometry(m);h.push(g)}return new es(h)}setEditShape(e,t=!1){null===this.m_topoGraph&&(this.m_topoGraph=new tn),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){ya(e,t,this.m_progressTracker,!0,!1);for(let s=e.getFirstGeometry();s!==Ae;s=e.getNextGeometry(s))e.getGeometryType(s)===r.enumPolygon&&er(e,s,-1,this.m_bOGCOutput,Ae,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==Ae;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==Ae;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===Ae)continue;let r=s.getNextVertex(n);for(;r!==Ae;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),o=this.m_topoGraph.getHalfEdgeConnector(t,i);if(o!==Ae){const t=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}n=r,r=s.getNextVertex(n)}}}flushVertices_(e,t){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),r=new Ve,i=s.insertPath(e,Ae);t.push(t[0]);const o=t.length;let a=Ae;for(let m=0;m<o;m++){const e=t[m];if(a=s.addVertex(i,e),!n)continue;const h=this.m_topoGraph.getClusterFromVertex(e);if(m>0&&this.m_topoGraph.isBreakNode(h)&&s.setSegmentParentageBreakVertex(a,!0),m<o-1){const e=this.m_topoGraph.getHalfEdgeConnector(h,this.m_topoGraph.getClusterFromVertex(t[m+1])),n=this.m_topoGraph.getSegmentParentage(e);s.setSegmentParentageAndBreak(a,n,m>0||this.m_topoGraph.isBreakNode(h)),this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,r),s.setSegmentToIndex(s.getVertexIndex(a),r.get().clone()))}}if(n){const e=this.m_topoGraph.getClusterFromVertex(t[o-1]);this.m_topoGraph.isBreakNode(e)&&s.setSegmentParentageBreakVertex(a,!0)}s.setClosedPath(i,!0)}processPolygonCuts_(e,t,s,n){const i=this.m_topoGraph.getGeometryID(s),o=this.m_topoGraph.getGeometryID(n),a=[],m=this.m_topoGraph.getShape(),h=this.m_topoGraph.createUserIndexForHalfEdges();for(let l=this.m_topoGraph.getFirstCluster();l!==Ae;l=this.m_topoGraph.getNextCluster(l)){const s=this.m_topoGraph.getClusterHalfEdge(l);if(s===Ae)continue;let n=s;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(n,h)){let s=n,l=n,g=!1,u=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,h,1),!g){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&i)&&(l=s,g=!0)}}if(g){const t=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(n);if(a.push(r),-1!==e){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){u|=this.m_topoGraph.getHalfEdgeUserIndex(s,e)}}}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==l);if(g&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(l))>0){const e=m.createGeometry(r.enumPolygon);this.flushVertices_(e,a),-1!==t&&m.setGeometryUserIndex(e,t,u)}a.length=0}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==s)}this.m_topoGraph.deleteUserIndexForHalfEdges(h)}cutPolygonPolyline_(e,t,s,n){this.m_topoGraph.removeSpikes_();let r=-1;-1!==e&&(r=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(r,s)),this.processPolygonCuts_(r,e,t,s),-1!==r&&(this.m_topoGraph.deleteUserIndexForHalfEdges(r),r=-1);const i=this.m_topoGraph.getShape();for(let o=i.getFirstGeometry();o!==Ae;o=i.getNextGeometry(o))o!==t&&o!==s&&n.push(o);n.sort((e,t)=>{const s=i.getFirstPath(e),n=i.getRingArea(s),r=i.getFirstPath(t),o=i.getRingArea(r);return n<o?-1:n>o?1:0})}cut(e,t,s,n,r){const i=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(n),m=g(i),h=g(a);if(2!==m||1!==h){if(1===m&&1===h){return void new sm(this,e,t,s,n,r).Do()}o("")}else this.cutPolygonPolyline_(t,s,n,r)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){const t=e.getGeometryType();if(t===r.enumEnvelope){const t=new we({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===r.enumPoint){const t=new ve({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(i(t)){const t=new Ce({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==r.enumMultiPoint&&t!==r.enumPolyline&&t!==r.enumPolygon&&s("Unexpected geometry type"),e}dissolveNonSimplePolygons(e,t,s,n){h(t>0);const r=new Te;let i=0,o=-1;for(let a=0,m=t;a<m;a++)2===e[a].getDimension()&&(-1===o&&(o=a),e[a].isEmpty()||(i++,r.addGeometry(e[a])));return 0===i?(h(o>=0),this.normalizeInputGeometry(e[o])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,s,n,o,m,l){h(e>=1&&e<=2),h(n>0);const g=8&m?1:2,c=Tt.constructEmpty();let _=0,d=-1,p=!0;for(let i=0,a=n;i<a;i++)if(s[i].getDimension()===e&&(-1===d&&(d=i),!s[i].isEmpty())){d=i,_++;const t=Tt.constructEmpty();if(s[i].queryLooseEnvelope(t),c.mergeEnv3D(t),2===e&&p&&s[i].getGeometryType()===r.enumPolygon)if(16&m){const e=[0],t=s[i].getImpl().getIsSimple(0,e),n=this.m_bOGCOutput?5===t:ut(t);p&&=n}else{const e=Mt(s[i],0);p&&=e}}if(_<2&&(h(d>=0),0===_||!(16&m)))return this.normalizeInputGeometry(s[d]);if(!p){const e=_t(t?null:o,c.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,n,e,m)}const f=s.slice(0,n),x=_t(o,c.getEnvelope2D(),!0),y=10*xt(x);let P=new ft(0,0);if(l&&(P=Gt(o,c.getEnvelopeZs(),!0)),1===_&&1===e&&2===g&&!t)return l?qa():this.m_bOGCOutput?Aa(f[d],x,!1,-1,this.m_progressTracker,g,!1):Ma(f[d],x,!1,!1,-1,this.m_progressTracker,g,!1);const E=new Ut;E.startConstruction();let S=2===e?3:4,C=0;for(let u=0,N=n;u<N;u++){if(f[u].getDimension()!==e||f[u].isEmpty())continue;let s=f[u].getGeometryType();if(s!==r.enumEnvelope){if(i(s)?(f[u]=this.normalizeInputGeometry(f[u]),s=r.enumPolyline):h(a(s)),1===e){h(s===r.enumPolyline);let e=-1;if(l)h(0,"3d not implemented yet");else{const t=[0];e=f[u].getImpl().getIsSimple(x.total(),t)}if(this.m_bOGCOutput?5!==e:!ut(e))if(t)S=-1;else{l?h(0,"3d not implemented yet"):this.m_bOGCOutput?f[u]=Aa(f[u],x,!1,-1,this.m_progressTracker,g,!1):f[u]=Ma(f[u],x,!1,!1,-1,this.m_progressTracker,g,!1);const e=[0];h(ut(f[u].getImpl().getIsSimple(x.total(),e)))}}else{h(s===r.enumPolygon);const e=[0],t=f[u].getImpl().getIsSimple(0,e);h(Nt(t))}const n=f[u].getImpl();for(let e=0,t=n.getPathCount();e<t;e++){const t=Wt.constructEmpty();n.queryLoosePathEnvelope(e,t),t.inflateCoords(y,y),E.addEnvelope(C,t),C++}}else{h(s===r.enumEnvelope);const e=Wt.constructEmpty();f[u].queryLooseEnvelope(e),e.inflateCoords(y,y),E.addEnvelope(C,e),C++,S=-1}}E.endConstruction();const I=C,b=N(I,-2147483647),w=N(I,-1);let v=0;d=-1,C=0;for(let i=0,u=n;i<u;i++){if(f[i].getDimension()!==e)continue;if(-1===d&&(d=i),f[i].isEmpty())continue;d=i,v++;const t=f[i].getGeometryType();if(a(t)){for(let e=0,t=f[i].getPathCount();e<t;e++)w[C]=i,b[C]=-e-1,C++}else h(t===r.enumEnvelope),w[C]=i,b[C]=-1,C++}if(v<2&&2===e)return h(d>=0),this.normalizeInputGeometry(f[d]);let T=I;for(;E.next()&&T>0;){this.progress_();const e=E.getHandleA(),t=E.getHandleB(),s=E.getElement(e),n=E.getElement(t);w[s]!==w[n]&&(b[s]<0&&(T--,b[s]=-(b[s]+1)),b[n]<0&&(T--,b[n]=-(b[n]+1)))}const G=new Te;let D=!1,V=0;for(let i=0,N=n;i<N;i++){if(f[i].getDimension()!==e||f[i].isEmpty())continue;const t=f[i].getGeometryType(),s=V;let n=0,o=0;const m=a(t)?f[i]:null;for(let e=s,r=b.length;e<r&&w[e]===i;e++)b[e]>=0&&(n++,o+=m?m.getPathSize(b[e]):u(f[i])),V++;if(o>.95*u(f[i])){G.addGeometry(this.normalizeInputGeometry(f[i]));for(let e=s;e<V;e++)b[e]<0&&(b[e]=-(b[e]+1))}else{if(0===n){D=!0;continue}{D=!0,h(a(t)),h(null!=m);const e=new we({vd:f[i].getDescription()}),n=new Ce({vd:f[i].getDescription()}),o=t===r.enumPolygon?e:n;for(let t=s;t<V;t++)b[t]>=0&&o.addPath(m,b[t],!0);G.addGeometry(o)}}}let F;if(G.getFirstGeometry()!==Ae){const s=2===e,n=t?_t(null,c.getEnvelope2D(),!0):x;let r=new ft(0,0);if(l&&(r=t?Gt(null,c.getEnvelopeZs(),!0):P),2===e&&!(2&m)){G.collapseAllGeometriesToFirst();let e=0,t=null;if(G.hasCurves()&&!G.hasSegmentParentage()){t=new fa;const s=G.getEnvelope2D(this.m_progressTracker);e=da(n.total());aa(G,_a(n.total(),s),n.total(),12e3,t,null,this.m_progressTracker)}Vn(G,G.getFirstGeometry(),n.total(),this.m_progressTracker),null!==t&&t.stitchCurves(G,Ae,e,!0)}if(l)F=this.planarSimplify3DImpl_(G,n,r,g,!0);else if(2===e)F=this.planarSimplifyPolygons(G,n,s,t,-1,!1);else{const e=ka();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=g,F=this.planarSimplifyPolylines(G,n,t,e,-1)}if(!D){const e=[0];S=F.getImpl().getIsSimple(n.total(),e)}}else h(D),h(d>=0),F=2===e?new we({vd:f[d].getDescription()}):new Ce({vd:f[d].getDescription()});if(D){let e=0;for(let t=0,s=b.length;t<s;t++){const s=w[t];if(!(s<0)&&b[t]<0){const n=f[s].getGeometryType(),r=a(n)?f[s]:null;if(r){const s=-(b[t]+1);e+=r.getPathSize(s)}else e+=4}}F.reserve(F.getPointCount()+e);for(let t=0,s=b.length;t<s;t++){const e=w[t];if(!(e<0)&&b[t]<0){const s=f[e].getGeometryType(),n=a(s)?f[e]:null;if(n){const e=-(b[t]+1);F.addPath(n,e,!0)}else s===r.enumEnvelope?F.addEnvelope(f[e],!1):(h(i(s)),F.addSegment(f[e],!0))}}}let k=0;if(2===e?-1!==S&&(S=3,k=t?0:x.total()):(h(1===e),t||-1===S||(k=x.total())),l||F.getImpl().setIsSimple(S,k),!t&&D)if(2===e){if(!l)return(new Em).execute(F,o,!1,this.m_progressTracker);h(0,"3d not yet implemented")}else 1===e&&1!==g&&(F=l?Ba():Ua(this.m_bOGCOutput,F,g,this.m_progressTracker),F.getImpl().setIsSimple(S,k));return F}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==Ae;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==Ae)do{this.progress_();if(1!==this.m_topoGraph.getHalfEdgeUserIndex(r,e)){const s=this.m_topoGraph.getHalfEdgeTwin(r);this.m_topoGraph.setHalfEdgeUserIndex(s,e,1),this.m_topoGraph.setHalfEdgeUserIndex(r,e,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(r);if(this.isGoodParentage(n)){const e=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(e)&&t.push(r)}}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,s,n){let r=se(),i=Ae;for(let a=this.m_topoGraph.getClusterVertexIterator(e);a!==Ae;a=this.m_topoGraph.incrementVertexIterator(a)){const e=this.m_topoGraph.getVertexFromVertexIterator(a),n=t.getUserIndex(e,s);n>=0&&n<r&&(r=n,i=e)}h(i!==Ae);let o=t.getUserIndex(i,n);return o>0&&(t.setUserIndex(i,n,--o),0===o&&t.setUserIndex(i,s,-1)),i}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,s,n,i){const o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==r.enumPolygon)return;const a=o.hasSegmentParentage(),m=new Ve;for(let r=o.getFirstPath(e);r!==Ae;r=o.getNextPath(r)){const e=o.getFirstVertex(r);this.m_topoGraph.getClusterFromVertex(e);const h=this.m_topoGraph.getHalfEdgeFromVertex(e);if(h===Ae)continue;const l=this.m_topoGraph.getHalfEdgeUserIndex(h,s);if(1===l||2===l)continue;const g=this.m_topoGraph.getHalfEdgeFaceParentage(h);if(!this.isGoodParentage(g)){this.m_topoGraph.setHalfEdgeUserIndex(h,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(h,s,1);const u=o.insertPath(t,Ae);o.setClosedPath(u,!0);let c=h,_=e,d=this.m_topoGraph.getClusterFromVertex(_),p=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(_,i),t=o.addVertex(u,e);if(this.m_topoGraph.isHalfEdgeCurve(c)&&(this.m_topoGraph.querySegmentXY(c,m),o.setSegmentToIndex(o.getVertexIndex(t),m.get().clone())),a){const e=this.m_topoGraph.getSegmentParentage(c);o.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(d))}let r,h;-1!==n&&this.m_topoGraph.setClusterUserIndex(d,n,1),this.m_topoGraph.setHalfEdgeUserIndex(c,s,1),c=this.m_topoGraph.getHalfEdgeNext(c);do{r=1===p?o.getNextVertex(_):o.getPrevVertex(_),h=r!==Ae?this.m_topoGraph.getClusterFromVertex(r):Ae}while(h===d);const l=this.m_topoGraph.getHalfEdgeOrigin(c);if(l!==h){do{r=1===p?o.getPrevVertex(_):o.getNextVertex(_),h=r!==Ae?this.m_topoGraph.getClusterFromVertex(r):Ae}while(h===d);if(l!==h){h=l;const e=this.m_topoGraph.getClusterVertexIterator(h);r=this.m_topoGraph.getVertexFromVertexIterator(e)}else p=-p}d=h,_=r}while(c!==h)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==Ae&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==Ae&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const o=new Ve,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const m=a.hasSegmentParentage();for(let h=this.m_topoGraph.getFirstCluster();h!==Ae;h=this.m_topoGraph.getNextCluster(h)){const e=this.m_topoGraph.getClusterHalfEdge(h);if(e===Ae)continue;let t=e;do{this.progress_();const e=this.m_topoGraph.getHalfEdgeUserIndex(t,r);if(1!==e&&2!==e){const e=this.m_topoGraph.getHalfEdgeFaceParentage(t);if(this.isGoodParentage(e)){const e=a.insertPath(s,Ae);a.setClosedPath(e,!0);let h=t;do{const t=this.m_topoGraph.getHalfEdgeVertexIterator(h);let s=Ae;if(t!==Ae)s=this.m_topoGraph.getVertexFromVertexIterator(t);else{const e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(h));s=this.m_topoGraph.getVertexFromVertexIterator(e),s=a.getNextVertex(s)}const l=this.chooseVertexFromVertexCluster_(s,n),g=a.addVertex(e,l);if(m){const e=this.m_topoGraph.getSegmentParentage(h),t=this.m_topoGraph.getHalfEdgeOrigin(h);a.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.isHalfEdgeCurve(h)&&(this.m_topoGraph.querySegmentXY(h,o),a.setSegmentToIndex(a.getVertexIndex(g),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(h,r,1),-1!==i){const e=this.m_topoGraph.getClusterFromVertex(l);this.m_topoGraph.setClusterUserIndex(e,i,1)}h=this.m_topoGraph.getHalfEdgeNext(h)}while(h!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,r,2)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}}topoOperationPolygonPolygon_(e,t,s,n=!1){this.dissolveTopoGraphCommonEdges_();const i=this.m_topoGraph.getShape(),o=i.createGeometry(r.enumPolygon),a=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,s,a,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(a),n||er(i,o,3,this.m_bOGCOutput,Ae,this.m_progressTracker),o}topoOperationPolyline_(e,t){const s=ka();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(Ae,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(r.enumMultiPoint),s=e.insertPath(t,Ae);for(let n=this.m_topoGraph.getFirstCluster();n!==Ae;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=Ae;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==Ae;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===Ae&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=g(s),i=g(n),a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);h(a>=0),h(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a|m]=!0;let l=Ae;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,l):1===r&&i>0||1===i&&r>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===r||0===i?this.topoOperationMultiPoint_():void o("")}topoOperationPolygonPolygonEx(e,t,s){const n=this.m_topoGraph.getShape(),i=n.createGeometry(r.enumPolygon),o=n.createGeometry(r.enumPolyline),a=n.createGeometry(r.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=Ae;const h=this.m_topoGraph.createUserIndexForHalfEdges(),l=this.m_topoGraph.createUserIndexForClusters();n.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,i,s,h,l),n.dbgVerifyCurves();const g=n.hasSegmentParentage(),u=new Ve;for(let r=this.m_topoGraph.getFirstCluster();r!==Ae;r=this.m_topoGraph.getNextCluster(r)){const e=this.m_topoGraph.getClusterHalfEdge(r);if(e===Ae)continue;let t=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(t,h),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),h),a=e|i;if(2===a){let m=this.m_topoGraph.getHalfEdgeParentage(t);if(this.isGoodParentage(m)){const c=n.insertPath(o,Ae);let _=t;const d=this.chooseVertexFromCluster_(r,s);let p=n.addVertex(c,d);if(g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone())),this.m_topoGraph.setClusterUserIndex(r,l,1);do{this.progress_();const r=this.m_topoGraph.getHalfEdgeTo(_),o=this.chooseVertexFromCluster_(r,s);if(p=n.addVertex(c,o),g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.setHalfEdgeUserIndex(_,h,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),h,1),this.m_topoGraph.setClusterUserIndex(r,l,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,h),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),h),a=e|i,2!==a)break;if(m=this.m_topoGraph.getHalfEdgeParentage(_),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(_,h,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),h,1);break}this.m_topoGraph.isHalfEdgeCurve(t)&&_!==t&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone()))}while(_!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,h,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),h,1)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}for(let r=this.m_topoGraph.getFirstCluster();r!==Ae;r=this.m_topoGraph.getNextCluster(r)){this.progress_();if(1===this.m_topoGraph.getClusterUserIndex(r,l))continue;const e=this.m_topoGraph.getClusterParentage(r);if(this.isGoodParentage(e)){m===Ae&&(m=n.insertPath(a,Ae));const e=this.m_topoGraph.getClusterVertexIterator(r);let t=Ae;if(e!==Ae){t=this.m_topoGraph.getVertexFromVertexIterator(e);const r=this.chooseVertexFromVertexCluster_(t,s);n.addVertex(m,r)}}}this.m_topoGraph.deleteUserIndexForClusters(l),this.m_topoGraph.deleteUserIndexForHalfEdges(h),n.dbgVerifyCurves(),er(n,i,3,this.m_bOGCOutput,Ae,this.m_progressTracker);const c=[Ae,Ae,Ae];return c[0]=a,c[1]=o,c[2]=i,c}topoOperationPolylinePolylineOrPolygonEx(e,t){const s=ka();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(Ae,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(r.enumMultiPoint),s=e.insertPath(t,Ae);for(let n=this.m_topoGraph.getFirstCluster();n!==Ae;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=Ae;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==Ae;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===Ae&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);h(a>=0),h(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a|m]=!0;let l=Ae;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===r&&2===i)return this.topoOperationPolygonPolygonEx(e,t,l);if(1===r&&i>0||1===i&&r>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[t,e]}if(0===r||0===i){const 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){const s=this.getCombinedHalfEdgeParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t),r=this.m_topoGraph.getHalfEdgeTo(t);let i=0,o=0;for(let a=this.m_topoGraph.getClusterVertexIterator(n);a!==Ae;a=this.m_topoGraph.incrementVertexIterator(a)){const n=this.m_topoGraph.getVertexFromVertexIterator(a),m=e.getPathFromVertex(n),h=e.getGeometryFromPath(m),l=this.m_topoGraph.getGeometryID(h),g=e.getFirstVertex(m),u=0!==(l&s);u&&g===n&&(this.m_fromEdgeForPolylines=t);const c=e.getNextVertex(n);if(c!==Ae&&this.m_topoGraph.getClusterFromVertex(c)===r){if(i++,u){if(this.m_fromEdgeForPolylines===Ae&&g===c){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o++}}else{const s=e.getPrevVertex(n);if(s!==Ae&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===Ae&&g===s){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o--}}}this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(r,this.m_dummyPt2);return(0!==o?o:i)*T.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(e,t){const s=this.m_topoGraph.getHalfEdgePrev(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return Ae;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=Ae;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==Ae)return Ae;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(r))}return i}tryMoveThroughCrossroadForward(e,t){const s=this.m_topoGraph.getHalfEdgeNext(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){const t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return Ae;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=Ae;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==Ae)return Ae;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(r))}return i}isOnALoop(e,t){let s=e;const n=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let r=0;r<n;r++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,t))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===e)return!0}o("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,i,o,a,m,l){h(r===Ae&&i>=0&&o>=0||-1===i&&-1===o),h(-1===a&&1!==l.unsplitBehavior||-1!==a&&1===l.unsplitBehavior);const g=l.ogcRule,u=l.allCrossRoadsImpassable,c=1===l.unsplitBehavior,_=0===l.unsplitBehavior,d=this.m_topoGraph.getShape(),p=d.hasSegmentParentage();let f=e,x=this.m_topoGraph.getHalfEdgeTwin(f);const y=new Ve;this.m_fromEdgeForPolylines=Ae;let P=this.prevailingDirection(d,f),E=f,S=Ae,C=!1,I=!1,b=!1;if(!c)for(;;){const t=this.m_topoGraph.getHalfEdgePrev(f);if(t===x){b=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(x);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){C=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(u){C=!0;break}if(f=this.tryMoveThroughCrossroadBackwards(f,!0),f===Ae){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=t,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}if(f===e){S=e,I=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;E=f,P+=this.prevailingDirection(d,f)}if(S===Ae){for(f=e,x=this.m_topoGraph.getHalfEdgeTwin(f),S=f;;){const e=this.m_topoGraph.getHalfEdgeNext(f),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){C=!0;break}if(e===x){b=!0;break}if(-1!==a){const e=this.m_topoGraph.getHalfEdgeOrigin(x);if(1===this.m_topoGraph.getClusterUserIndex(e,a)){C=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(x);if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(t||u){C=!0;break}if(f=this.tryMoveThroughCrossroadForward(f,!0),f===Ae){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=e,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;S=f,P+=this.prevailingDirection(d,f)}const t=this.m_topoGraph.getHalfEdgeOrigin(E);I=this.m_topoGraph.getHalfEdgeTo(S)===t}else if(this.m_fromEdgeForPolylines!==Ae){E=e,S=this.tryMoveThroughCrossroadBackwards(E,!1),h(S!==Ae);const t=this.m_topoGraph.getHalfEdgeTwin(E);this.m_topoGraph.getHalfEdgeNext(t)}let w=I;I||b||m&&(w=this.isOnALoop(e,s),w||(w=this.isOnALoop(x,s)));const v=P>=0;let N=!1;w&&C&&(I?(N=g,v&&(N||c||_)&&E!==e&&(h(!c),E=e,N=!1)):(c||v&&_)&&(E=e));let T=0;for(f=E;x=this.m_topoGraph.getHalfEdgeTwin(f),this.m_topoGraph.setHalfEdgeUserIndex(f,s,1),this.m_topoGraph.setHalfEdgeUserIndex(x,s,1),T++,f!==S;)f=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1);v||(S=M(E,E=S),S=this.m_topoGraph.getHalfEdgeTwin(S),E=this.m_topoGraph.getHalfEdgeTwin(E));let G=d.insertPath(t,Ae);f=E;const D=this.m_topoGraph.getHalfEdgeOrigin(E);let V;V=-1!==i?this.chooseVertexByOrder(D,d,i,o):this.chooseVertexFromCluster_(D,r),this.m_topoGraph.isStrongPathNode(D)&&d.setStrongPathStart(G,!0);let F=d.addVertex(G,V),k=F;-1!==n&&this.m_topoGraph.setClusterUserIndex(D,n,1);let H=0;const A=N?Math.trunc((T+1)/2):-1;let U=Ae,q=!0,B=Ae;for(;;){if(p){const e=this.m_topoGraph.getSegmentParentage(f),t=this.m_topoGraph.getHalfEdgeOrigin(f);d.setSegmentParentageAndBreak(k,e,q||this.m_topoGraph.isBreakNode(t))}q=!1,this.m_topoGraph.isHalfEdgeCurve(f)&&(this.m_topoGraph.querySegmentXY(f,y),d.setSegmentToIndex(d.getVertexIndex(k),y.get().clone())),U!==Ae&&-1!==o&&d.addToUserIndex(U,o,-1);const e=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1),s=this.m_topoGraph.getHalfEdgeTo(f);let a;if(a=-1!==i?this.chooseVertexByOrder(s,d,i,o):this.chooseVertexFromCluster_(s,r),F=d.addVertex(G,a),B=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),p&&this.m_topoGraph.isBreakNode(s)&&d.setSegmentParentageBreakVertex(F,!0),U=a,H++,N&&H===A&&(G=d.insertPath(t,Ae),F=d.addVertex(G,a),q=!0,-1!==o&&d.addToUserIndex(a,o,-1),U=Ae),f===S)break;f=e,k=F}B!==Ae&&this.m_topoGraph.isStrongPathNode(B)&&d.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,Ae,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,s,n){h(t===Ae||e===Ae);const i=this.m_topoGraph.getShape(),o=t=>t=e===Ae?t===Ae?i.getFirstGeometry():i.getNextGeometry(t):t===Ae?e:Ae,a=i.createGeometry(r.enumPolyline);let m=-1;s&&(m=this.m_topoGraph.createUserIndexForClusters());const l=this.m_topoGraph.createUserIndexForHalfEdges(),g=t===Ae?i.createUserIndex():-1,u=t===Ae?i.createUserIndex():-1;let c=-1;if(1===n.unsplitBehavior){c=this.m_topoGraph.createUserIndexForClusters();for(let e=o(Ae);e!==Ae;e=o(e))for(let t=i.getFirstPath(e);t!==Ae;t=i.getNextPath(t)){{const e=i.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}if(!i.isClosedPath(t)){const e=i.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}}}if(t===Ae){let e=0;for(let t=o(Ae);t!==Ae;t=o(t))for(let s=i.getFirstPath(t);s!==Ae;s=i.getNextPath(s)){if(i.isClosedPath(s)){let t=i.getFirstVertex(s);for(let n=0,r=i.getPathSize(s);n<r;n++,t=i.getNextVertex(t))i.setUserIndex(t,g,e++),i.setUserIndex(t,u,2)}else{const t=i.getFirstVertex(s);i.setUserIndex(t,g,e++),i.setUserIndex(t,u,1);let n=i.getNextVertex(t);for(let r=1,o=i.getPathSize(s)-1;r<o;++r)i.setUserIndex(n,g,e++),i.setUserIndex(n,u,2),n=i.getNextVertex(n);i.setUserIndex(n,g,e++),i.setUserIndex(n,u,1)}}}for(let r=o(Ae);r!==Ae;r=o(r))for(let e=i.getFirstPath(r);e!==Ae;e=i.getNextPath(e)){let s=i.getFirstVertex(e);for(let r=0,o=i.getPathSize(e);r<o;r++,s=i.getNextVertex(s)){const e=this.m_topoGraph.getHalfEdgeFromVertex(s);if(e===Ae)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(e,l))continue;const i=this.getCombinedHalfEdgeParentage(e);if(this.isGoodParentage(i)){const s=0===r;this.restorePolylineParts(e,a,l,m,t,g,u,c,s,n)}}}let _=Ae;if(s){_=i.createGeometry(r.enumMultiPoint);let e=Ae;for(let s=this.m_topoGraph.getFirstCluster();s!==Ae;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1!==this.m_topoGraph.getClusterUserIndex(s,m)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===Ae&&(e=i.insertPath(_,Ae));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==Ae){let r;this.m_topoGraph.getVertexFromVertexIterator(n),r=-1!==g?this.chooseVertexByOrder(s,i,g,u):this.chooseVertexFromCluster_(s,t),i.addVertex(e,r)}}}}}return-1!==u&&i.removeUserIndex(u),-1!==g&&i.removeUserIndex(g),-1!==m&&i.removeUserIndex(m),this.m_topoGraph.deleteUserIndexForHalfEdges(l),H(a,_)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=g(s),i=g(n);if(r>i)return e;const a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a]=!0,2===r&&2===i){let s=Ae;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===r&&2===i){const t=ka();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,Ae,!1,t).first}if(1===r&&1===i){const t=ka();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,Ae,!1,t).first}if(0===r)return this.topoOperationMultiPoint_();o("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);return h(a>=0),h(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a]=!0,this.m_maskLookup[a]=!0,this.m_maskLookup[m]=!0,2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,Ae):1===r&&1===i?this.topoOperationPolyline_(Ae,this.m_bOGCOutput):0===r&&0===i?this.topoOperationMultiPoint():void o("")}planarSimplifyNoCrackingAndCluster(e,t,s,n){this.m_bOGCOutput=e,this.m_topoGraph=new tn;const i=t.getFillRule(s),a=t.getGeometryType(s);if(1!==i||a===r.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const m=this.m_topoGraph.getGeometryID(s);if(h(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=m+1,this.m_maskLookup[m]=!0,t.getGeometryType(s)===r.enumPolygon||1===i&&t.getGeometryType(s)!==r.enumMultiPoint){t.setFillRule(s,0);const r=this.topoOperationPolygonPolygon_(s,Ae,Ae);if(t.swapGeometry(r,s),t.removeGeometry(r),1===i&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,s,n)}else if(t.getGeometryType(s)===r.enumPolyline){const e=ka();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=n;const r=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(r,s),t.removeGeometry(r)}else if(t.getGeometryType(s)===r.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,s),t.removeGeometry(e)}else o("");return!0}unsplitPolylineExact(e){return h(0),new Ce}planarSimplifyPolylines(e,t,s,n,i){for(let _=e.getFirstGeometry();_!==Ae;_=e.getNextGeometry(_)){const t=e.getGeometryType(_);h(t===r.enumPolyline)}let o=0,a=0,m=null;if(e.hasCurves()&&!e.hasSegmentParentage()){m=new fa;const s=e.getEnvelope2D(this.m_progressTracker);a=da(t.total());const n=_a(t.total(),s);o=pa(n,a),aa(e,n,t.total(),12e3,m,null,this.m_progressTracker)}{const s=Ia(t.add(o));e.filterClosePoints(s,!1,!1,!1,Ae)}if(this.m_topoGraph=new tn,4!==i&&5!==i)if(null===m&&s){const n=new Dn(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(o),this.m_progressTracker,!0,!1),s=!1;else s=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const l=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return h(s&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,n,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(l);h(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const u=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),n);null!==m&&m.stitchCurves(e,u,a,!0);const c=e.getGeometry(u);return s||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyMultiPoints(e,t,s,n){for(let l=e.getFirstGeometry();l!==Ae;l=e.getNextGeometry(l)){const t=e.getGeometryType(l);h(t===r.enumMultiPoint)}this.m_topoGraph=new tn,4!==n&&5!==n?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):s=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const i=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,i,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return h(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const o=this.m_topoGraph.getGeometryID(i);h(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0;const a=this.topoOperationMultiPoint(),m=e.getGeometry(a);return s||m.getImpl().setIsSimple(4,t.total()),m}planarSimplifyPolygons(e,t,s,n,i,o){for(let f=e.getFirstGeometry();f!==Ae;f=e.getNextGeometry(f)){const t=e.getGeometryType(f);h(t===r.enumPolygon||t===r.enumPolyline&&s)}let a=0,m=0,l=null;if(e.hasCurves()&&!e.hasSegmentParentage()){l=new fa;const s=e.getEnvelope2D(this.m_progressTracker);m=da(t.total());const n=_a(t.total(),s);a=pa(n,m),aa(e,n,t.total(),12e3,l,null,this.m_progressTracker)}if(o){ya(e,t.add(a),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==Ae;t=e.getNextGeometry(t))e.getGeometryType(t)===r.enumPolygon&&er(e,t,-1,!1,Ae,this.m_progressTracker)}if(this.m_topoGraph=new tn,o||4===i||5===i)n=!1;else if(null===l&&n){const s=new Dn(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(a),this.m_progressTracker,!0,!1),n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return h(n&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(g);h(u>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=u+1,this.m_maskLookup[u]=!0,e.setFillRule(g,0);const c=this.m_bOGCOutput&&s,_=c;let d=this.topoOperationPolygonPolygon_(g,Ae,Ae,_);if(c){this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(g),this.m_topoGraph=new tn,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,d,this.m_progressTracker);d=this.topoOperationPolygonPolygon_(d,Ae,Ae,!1)}null!==l&&l.stitchCurves(e,d,m,!0);const p=e.getGeometry(d);return p.setFillRule(0),n?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,t.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(e,t,s,n,r){return h(0),{}}planarSimplifyImpl_(e,t,s,n,i,a,m,h){if(e.isEmpty())return e.clone();const l=e.getGeometryType(),g=new Te,u=g.addGeometry(e);if(Nt(i)&&l===r.enumPolygon&&(s=!1,g.setFillRule(u,0)),h&&(e.hasAttribute(1)&&g.replaceNaNs(1,0),g.removeNaNVertices()),l===r.enumPolygon||l===r.enumPolyline&&s)return this.planarSimplifyPolygons(g,t,s,n,i,!1);if(l===Ce.type){const e=ka();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=m,this.planarSimplifyPolylines(g,t,n,e,i)}if(l===r.enumMultiPoint)return this.planarSimplifyMultiPoints(g,t,n,i);o("what else?")}}function Qa(e,t,s,n){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return n?e.createInstance():new pt({copy:e});const r=[new T],i=[0],a=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&o(""),r[0]=e.getXY(),a?Wo(t,r,1,s.total(),i):jo(t,r,1,s.total(),i),0===i[0]?e.createInstance():e}function Ja(e,t,s,n){const r=e.createInstance(),i=B(T,100),a=new Array(100),m=e.getPointCount();let h=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&o("");for(let o=0;o<m;){const n=e.queryCoordinates(i,i.length,o,-1)-o;l?Wo(t,i,n,s.total(),a):jo(t,i,n,s.total(),a);let m=0;for(let t=0;t<n;t++){0===a[t]&&(h&&(h=!1,r.addPoints(e,0,o)),m!==t&&r.addPoints(e,o+m,o+t),m=t+1)}h||m===n||r.addPoints(e,o+m,o+n),o+=n}return h?e:r}function $a(e,t,s,n){const i=e.getGeometryType();if(i===r.enumEnvelope){const t=new we({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(i===r.enumPoint&&("|"===n||"^"===n)){const t=new ve({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(i===r.enumLine){const t=new Ce({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(i===r.enumMultiPoint&&"-"===n&&t.getGeometryType()===r.enumPoint){const t=new pt({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(i===r.enumMultiPoint&&"&"===n&&t.getGeometryType()===r.enumPoint){const t=new pt({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function em(e){const t=e.getGeometryType();if(t===r.enumEnvelope){const t=new we({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===r.enumPoint){const t=new ve({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(Da(t)){const t=new Ce({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==r.enumMultiPoint&&t!==r.enumPolyline&&t!==r.enumPolygon&&s("Unexpected geometry type"),e}function tm(e,t,s,n){const r=s===Ae?e.getClusterHalfEdge(t):s;let i=r;h(e.getHalfEdgeOrigin(r)===t);do{n(i),i=e.getHalfEdgeNext(e.getHalfEdgeTwin(i))}while(i!==r)}class sm{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,s,n,r,i){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(r),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=r,this.m_rCutHandles=i,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let o=this.m_rShape.getFirstPath(this.m_cuttee);o!==Ae;o=this.m_rShape.getNextPath(o)){let e=0;const t=this.m_rShape.getPathSize(o);for(let s=this.m_rShape.getFirstVertex(o);e<t;e++,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(s)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return 8|e}classifyStandardCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),h=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));let l=1,g=32,u=32;if(tm(this.m_rTopoGraph,t,h,e=>{e===m&&(l=2),e===o&&(g=l),e===a&&(u=l)}),this.m_bConsiderTouch)32!==g&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),32!==u&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u);else{if(32===g||32===u)return 1;if(g===u&&!(o===m||o===h||a===m||a===h))return 1;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u)}return 0}classifyTouchCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),m=s===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),h=n===Ae?Ae:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let t;return(t=m===o||h===o)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=m===a||h===a)&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),t?0:1}if(o===Ae)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===Ae)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;if(o===a)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(h!==Ae){if(o===h)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=1;tm(this.m_rTopoGraph,t,h,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=2}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=2}})}else{if(o===m)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===m)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=2;tm(this.m_rTopoGraph,t,m,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=1}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=1}})}return 0}classifyCutVertex(e,t){let s=0,n=0;for(let r=this.m_rTopoGraph.getClusterVertexIterator(t);r!==Ae;r=this.m_rTopoGraph.incrementVertexIterator(r)){const i=this.m_rTopoGraph.getVertexFromVertexIterator(r);if(this.m_rShape.getGeometryFromVertex(i)===this.m_cutter){n++;const r=this.m_rShape.getPrevVertex(i),o=this.m_rShape.getNextVertex(i);s+=r===Ae||o===Ae?this.classifyTouchCut(e,t,r,o):this.classifyStandardCut(e,t,r,o)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let r=this.m_rShape.getFirstPath(this.m_cuttee);r!==Ae;r=this.m_rShape.getNextPath(r)){const e=this.m_rShape.getPathSize(r);let t=this.m_rShape.getFirstVertex(r);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t))this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,0);t=this.m_rShape.getFirstVertex(r);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t)){const e=this.m_rTopoGraph.getClusterFromVertex(t);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(t,e)}}const e=(e,t)=>{let s=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let r=this.m_rShape.getFirstPath(this.m_cuttee);r!==Ae;r=this.m_rShape.getNextPath(r)){let t=this.m_rShape.getFirstVertex(r);const s=this.m_rShape.isClosedPath(r),n=this.m_rShape.getPathSize(r)+(s?1:0);let i=1,o=32;for(let r=this.m_rShape.getNextVertex(t);i<n;++i,t=r,r=this.m_rShape.getNextVertex(r)){const s=e(t,r);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=s),32!==o&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,o|s)}t=this.m_rShape.getLastVertex(r);let a=32;i=1;for(let r=this.m_rShape.getPrevVertex(t);i<n;++i,t=r,r=this.m_rShape.getPrevVertex(r)){const s=e(r,t);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=s),32!==a&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,a|s)}}let t=Ae,s=Ae,n=32;const i=this.m_rShape.hasSegmentParentage(),o=new Ve;for(let a=this.m_rShape.getFirstPath(this.m_cuttee);a!==Ae;a=this.m_rShape.getNextPath(a)){const e=this.m_rShape.isClosedPath(a),m=this.m_rShape.getPathSize(a)+(e?1:0);let h=1,l=this.m_rShape.getFirstVertex(a),g=Ae,u=!0;for(let a=this.m_rShape.getNextVertex(l);h<m;++h,a=this.m_rShape.getNextVertex(a)){let e=this.m_rShape.getUserIndex(l,this.m_cutteeBreadcrumbsIndex);8===e?e=3:(e&=-9,4&e?e=4:3&~e||(e=3)),e!==n?(t!==Ae&&(g=this.m_rShape.addVertex(s,l),i&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n)),t=this.m_rShape.createGeometry(r.enumPolyline),s=this.m_rShape.insertPath(t,Ae),n=e,u=!0):this.m_rShape.getUserIndex(l,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==e&&(g=this.m_rShape.addVertex(s,l),i&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),s=this.m_rShape.insertPath(t,Ae),u=!0),g=this.m_rShape.addVertex(s,l);const m=this.m_rTopoGraph.getClusterFromVertex(l);!u&&i&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(g,!0);const h=this.m_rTopoGraph.getHalfEdgeFromVertex(l);if(i){const e=this.m_rTopoGraph.getSegmentParentage(h);this.m_rShape.setSegmentParentageAndBreak(g,e,u||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(h)&&(this.m_rTopoGraph.querySegmentXY(h,o),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(g),o.get().clone())),l=a,u=!1}g=this.m_rShape.addVertex(s,l),i&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n),t=Ae,s=Ae,n=32}}}function nm(e,t,s){return new Ka(s).linesToPolygonsImpl(e,t)}function rm(e,t,s,n,a){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===r.enumPoint)return hm(e,n);const h=mt(t,e,!1).total();if(m===r.enumEnvelope){const t=e,s=new Wt;return t.queryEnvelope(s),s.isDegenerate(h)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if(i(m)){const r=e,i=new Ce({vd:r.getDescription()});return i.addSegment(r,!0),om(i,t,s,n,a)}const l=[0],g=e.getImpl().getIsSimple(h,l);let u=s?-1:g;if(ut(u)||0===u)return u;const c=new Pm(e,t,u,a,!1);m===r.enumMultiPoint||m===r.enumPolyline||m===r.enumPolygon?u=c.isSimplePlanarImpl():o("");return e.getImpl().setIsSimple(u,h),n&&n.assign(c.m_nonSimpleResult),u}function im(e,t,s,n,a){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===r.enumPoint)return hm(e,n);const h=mt(t,e,!1).total();if(m===r.enumEnvelope){const t=e,s=new Wt;return t.queryEnvelope(s),s.isDegenerate(h)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if(i(m)){const r=e,i=new Ce({vd:r.getDescription()});return i.addSegment(r,!0),im(i,t,s,n,a)}y(m),f(m)||_("OGC simplify is not implemented for this geometry type");const l=[0],g=e.getImpl().getIsSimple(h,l);let u=s?-1:g;if(5===u||0===u)return u;const c=new Pm(e,t,u,a,!0);m===r.enumMultiPoint||m===r.enumPolyline||m===r.enumPolygon?(u=c.isSimplePlanarImpl(),ut(u)&&(u=5)):o("");return e.getImpl().setIsSimple(u,h),n&&n.assign(c.m_nonSimpleResult),u}function om(e,t,s,n,a){if(n&&(n.m_reason=0,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===r.enumPoint)return hm(e,n);const h=mt(t,e,!1).total();if(m===r.enumEnvelope){const t=e,s=Wt.constructEmpty();return t.queryEnvelope(s),s.isDegenerate(h)?(n&&(n.m_reason=4,n.m_vertexIndex1=-1,n.m_vertexIndex2=-1),0):5}if(i(m)){const r=e,i=new Ce({vd:r.getDescription()});return i.addSegment(r,!0),om(i,t,s,n,a)}const l=[0],g=e.getImpl().getIsSimple(h,l);let u=s?-1:g;if(-1!==u)return u;const c=new Pm(e,t,u,a,!1);return m===r.enumMultiPoint?u=c.multipointIsSimpleAsFeature():m===r.enumPolyline?u=c.polylineIsSimpleAsFeature():m===r.enumPolygon?u=c.polygonIsSimpleAsFeature():o(""),e.getImpl().setIsSimple(u,h),n&&n.assign(c.m_nonSimpleResult),u}function am(e,t,s,n){if(e.isEmpty())return e;const a=e.getGeometryType();if(a===r.enumPoint){const t=new ts;if(hm(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(a===r.enumEnvelope){const s=mt(t,e,!0).total(),n=e,r=Wt.constructEmpty();return n.queryEnvelope(r),r.isDegenerate(s)?n.createInstance():e}if(i(a)){const r=e,i=new Ce({vd:r.getDescription()});return i.addSegment(r,!0),am(i,t,s,n)}y(a);const m=mt(t,e,!1).total(),h=[0],l=e.getImpl().getIsSimple(m,h),g=s?-1:l;if(ut(g)){if(a===r.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((a===r.enumMultiPoint||a===r.enumPolyline)&&g>=1)return e;const u=new Pm(e,t,g,n,!1);let c;return a===r.enumMultiPoint?c=u.multipointSimplifyAsFeature():a===r.enumPolyline?c=u.polylineSimplifyAsFeature():a===r.enumPolygon?c=u.polygonSimplifyAsFeature():o(""),c}function mm(e,t,s,n){if(e.isEmpty())return e;const o=e.getGeometryType();if(o===r.enumPoint){const t=new ts;if(hm(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(o===r.enumEnvelope){const s=e,n=new Wt;s.queryEnvelope(n);const r=mt(t,e,!0).total();return n.isDegenerate(r)?s.createInstance():e}if(i(o)){const r=e,i=new Ce({vd:r.getDescription()});return i.addSegment(r,!0),mm(i,t,s,n)}y(o),f(o)||_("OGC simplify is not implemented for this geometry type");const a=mt(t,e,!1).total(),m=[0],h=e.getImpl().getIsSimple(a,m),l=s?-1:h;if(5===l){if(o===r.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return Aa(e,mt(t,e,!0),!1,l,n,0,!0)}function hm(e,t){const s=e.getX(),n=e.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){const s=e.getZ();if(!Number.isFinite(s))return t&&(t.m_reason=Number.isNaN(s)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class lm{m_segment=null;m_vertexIndex=-1;m_pathIndex=-1;m_flags=0;setReversed(e){this.m_flags&=-2,this.m_flags=this.m_flags|(e?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function gm(){return{x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1}}function um(e,t,s,n,r){return{x:e,y:t,ipath:s,ivertex:n,ipolygon:r}}function cm(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function _m(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function dm(){return{x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1}}function pm(e,t,s,n,r,i){return{x:e,y:t,ipath:s,ivertex:n,bBoundary:r,bEndPoint:i}}function fm(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 xm extends Xt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*n);return r<0?-1:r>0?1:0}}class ym extends Xt{m_helper;constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges[t],i=this.m_helper.m_edges[n],o=r.getReversed(),a=i.getReversed();let m=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),h=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(m===h){const e=o?r.m_segment.getStartY():r.m_segment.getEndY(),t=a?i.m_segment.getStartY():i.m_segment.getEndY(),s=Math.min(e,t);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),m=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0),h=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return m<h?-1:m>h?1:0}}class Pm{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 yt;m_progressTracker=null;m_progressCounter=0;m_AET=new Pt;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 ts;constructor(e,t,s,n,r){this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=e,this.m_knownSimpleResult=s,this.m_sr=t;const i=mt(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=xt(i),this.m_toleranceIsSimpleCracking=Et(i),this.m_toleranceSimplify=mt(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=r,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const e=this.m_geometry.getGeometryType();return a(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?a(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===r.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return h(0),7}generateSortedPairs(e){let t=null;a(e.getGeometryType())&&(t=e);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==t,n=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new St(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let a=0;a<n;a++)if(this.m_pairs.push(2*a),this.m_pairs.push(2*a+1),this.m_pairIndices.add(2*a),this.m_pairIndices.add(2*a+1),s){for(;a>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const i=new Ct,o={parent:this,workPt:new T,userSort(e,t,n){n.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,s))},getValue(e){const t=this.parent.m_pairs[e],s=t>>1;this.parent.m_xy.queryPoint2D(2*s,this.workPt);return this.workPt.y+(1&t?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};i.sort(this.m_pairIndices,0,2*n,o)}_TestToleranceDistancePlanar(e,t){const s=this.m_xy.read(2*e),n=this.m_xy.read(2*e+1),r=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1);if(!!ln(s,n,r,i,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)){if(0===this.m_geometry.getDimension())return!1;return s===r&&n===i}return!0}checkStructure(){const e=this.m_geometry.getGeometryType();if(a(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===r.enumPolygon?3:2;for(let s=0,n=e.getPathCount();s<n;s++)if(e.getPathSize(s)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(s)&&e.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new ts(1,s,0),!1}}if(f(e)){const e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let s=0,n=e.getPointCount();s<n;s++){if(!t.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new ts(2,s,0),!1}if(this.m_geometry.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(!Number.isFinite(e))return Number.isNaN(e)?this.m_nonSimpleResult=new ts(3,s,0):this.m_nonSimpleResult=new ts(2,s,0),!1}}}return!0}checkDegenerateSegments(e){const t=this.m_geometry.getImpl(),s=t.querySegmentIterator(),n=t.hasAttribute(1),r=n?It(this.m_sr,t,!1).total():0,i=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment();let a=t.calculateLowerLength2D();if(!(a>o)&&!(i&&t.isCurve()&&(a=t.calculateLength2D(),a>o))){if(e&&n){const e=t.getStartAttributeAsDbl(1,0),s=t.getEndAttributeAsDbl(1,0);if(Math.abs(s-e)>r)continue}return this.m_nonSimpleResult=new ts(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return h(0),!1}_CheckClustering(){const e=this.m_geometry.getImpl();this.generateSortedPairs(e);const t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new xm(this)),this.m_AET.setCapacity(t);for(let s=0,n=2*t;s<n;s++){this.progress_();const e=this.m_pairIndices.read(s),t=this.m_pairs[e],n=t>>1;if(1&t){const e=this.m_AET.search(n),t=this.m_AET.getPrev(e),s=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==Pt.st_nullNode()&&s!==Pt.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new ts(5,this.m_AET.getElement(t),this.m_AET.getElement(s)),!1}else{const e=this.m_AET.addElement(n),t=this.m_AET.getPrev(e);if(t!==Pt.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(t)),!1;const s=this.m_AET.getNext(e);if(s!==Pt.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new Te,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new fa;const e=Wt.constructEmpty();this.m_geometry.queryEnvelope(e);const t=_a(this.m_toleranceSimplify.total(),e),s=new ts;if(la(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,s,this.m_curveStitcher,null,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!1}const e=new ts;return Mn(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(null!=this.m_curveStitcher?(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null):(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){s.resetTo(t);do{for(;s.hasNextSegment();){const n=s.nextSegment(),r=Me(!0,e,n,this.m_toleranceIsSimpleCracking,!0);if(r){const e=2===r?7:6;return this.m_nonSimpleResult=new ts(e,t.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const t=[],s=e.getPointCount();let n=Number.NaN,r=0;for(let i=0,o=2*s;i<o;i++){this.progress_();const e=this.m_pairIndices.read(i),s=this.m_pairs[e];if(1&s)continue;const o=s>>1,a=this.m_xy.read(2*o),m=this.m_xy.read(2*o+1);if(t.length&&(a!==n||m!==r)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),n=a,r=m}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){const e=this.m_geometry.getImpl(),t=[];for(let o=0,a=e.getPathCount();o<a;o++)t.push(e.isClosedPathInXYPlane(o));const s=dm();let n,r,i;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,m=this.m_xy.readPoint2D(2*a),h=this.m_pathsForOGCTests[a];n=t[h],r=e.getPathStart(h),i=e.getPathEnd(h)-1,s.bEndPoint=a===r||a===i,this.m_bOGCRestrictions?s.bBoundary=!n&&s.bEndPoint:s.bBoundary=s.bEndPoint,s.ipath=h,s.x=m.x,s.y=m.y,s.ivertex=a}for(let o=1,a=this.m_pairIndices.size();o<a;o++){const a=this.m_pairIndices.read(o),m=this.m_pairs[a];if(1&m)continue;const h=m>>1,l=this.m_xy.readPoint2D(2*h),g=this.m_pathsForOGCTests[h];let u;g!==s.ipath&&(n=t[g],r=e.getPathStart(g),i=e.getPathEnd(g)-1);const c=h===r||h===i;u=this.m_bOGCRestrictions?!n&&c:c;const _=pm(l.x,l.y,g,h,u,c);if(_.x===s.x&&_.y===s.y)if(this.m_bOGCRestrictions){if(!(_.bBoundary&&s.bBoundary||_.ipath===s.ipath&&_.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new ts(10,_.ivertex,s.ivertex),!1}else if(!_.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new ts(7,_.ivertex,s.ivertex),!1;fm(s,_)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return h(0),!1}checkSelfIntersectionsPolygonsOGC(){const e=this.m_geometry.getImpl(),t=[];let s=-1,n=!1;for(let l=0,g=e.getPathCount();l<g;l++)e.isExteriorRingOGC(l)&&(n=!1,s++,l<g-1&&(e.isExteriorRingOGC(l+1)||(n=!0))),t.push(n?s:-1);const r=gm();{const e=this.m_pairIndices.read(0),s=this.m_pairs[e]>>1,n=this.m_xy.readPoint2D(2*s),i=this.m_pathsForOGCTests[s];r.ipath=i,r.x=n.x,r.y=n.y,r.ivertex=s,r.ipolygon=t[i]}const i=[];for(let l=1,g=this.m_pairIndices.size();l<g;l++){const e=this.m_pairIndices.read(l),s=this.m_pairs[e];if(1&s)continue;const n=s>>1,o=this.m_xy.readPoint2D(2*n),a=this.m_pathsForOGCTests[n],m=um(o.x,o.y,a,n,t[a]);if(m.x===r.x&&m.y===r.y){if(m.ipath===r.ipath)return this.m_nonSimpleResult=new ts(11,m.ivertex,r.ivertex),!1;t[m.ipath]>=0&&t[m.ipath]===t[r.ipath]&&(0!==i.length&&cm(i.at(-1),r)||i.push({...r}),i.push(m))}_m(r,m)}if(0===i.length)return!0;const o=new yt(!0);t.fill(-1);let a=-1;const m=new T;for(let l=0,g=i.length;l<g;l++){const e=i[l];e.x===m.x&&e.y===m.y||(a=o.createList(0),m.x=e.x,m.y=e.y);let s=t[e.ipath];-1===s&&(s=o.createList(2),t[e.ipath]=s),o.addElement(s,a),o.addElement(a,s)}const h=[];for(let l=o.getFirstList();-1!==l;l=o.getNextList(l)){const e=o.getListData(l);if(1&e||!(2&e))continue;let s=-1;for(h.push(l),h.push(-1);h.length;){const e=h.at(-1);h.pop();const t=h.at(-1);h.pop();const n=o.getListData(t);if(1&n){s=2&n?t:e;break}o.setListData(t,1|n);for(let s=o.getFirst(t);-1!==s;s=o.getNext(s)){const n=o.getData(s);n!==e&&(h.push(n),h.push(t))}}if(-1!==s){const e=t.indexOf(s);return this.m_nonSimpleResult=new ts(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){const e=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new ts(8,1===e.getPathCount()?1:-1,-1),0;if(1===e.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new bt(e.getPathCount(),0),this.m_pathParentage=new St(e.getPathCount(),-1);let t=-1,s=0;for(let i=0,o=e.getPathCount();i<o;i++){const n=e.calculateRingArea2D(i);if(this.m_pathOrientations.write(i,n<0?0:8),n>0)t=i,s=n;else{if(0===n)return this.m_nonSimpleResult=new ts(8,i,-1),0;if((t<0||s<Math.abs(n))&&(this.m_nonSimpleResult=new ts(9,i,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(i,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;const n=e.getPointCount();this.m_yScanline=Number.NaN;const r=[];this.m_xyToNode1=new St(n,Pt.st_nullNode()),this.m_xyToNode2=new St(n,Pt.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new ym(this));for(let i=0,o=2*n;this.m_unknownOrientationPathCount>0&&i<o;i++){const e=this.m_pairIndices.read(i),t=this.m_pairs[e];if(1&t)continue;const s=t>>1,n=this.m_xy.read(2*s+1);if(n!==this.m_yScanline&&r.length){if(!this.processBunchForRingOrientationTest(r))return 0;r.length=0}r.push(s),this.m_yScanline=n}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(r)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(e){if(1===e.length)return!0;for(let o=0,a=e.length;o<a;o++){const t=e[o];this.m_recycledSegIter.resetToVertex(t,-1);const s=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(s,t,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(n,t,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();-1===t&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let o=0,a=this.m_edges.length;o<a;o++)this.m_crossOverHelperList.addElement(t,o);let s=!0,n=-1,r=-1;for(;s;){s=!1;let e=this.m_crossOverHelperList.getFirst(t);if(-1===e)break;let i=this.m_crossOverHelperList.getNext(e);for(;-1!==i;){const o=this.m_crossOverHelperList.getData(e),a=this.m_crossOverHelperList.getData(i);if(n=this.m_edges[o].m_vertexIndex,r=this.m_edges[a].m_vertexIndex,n!==r)e=i,i=this.m_crossOverHelperList.getNext(e);else if(s=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(i),i=this.m_crossOverHelperList.deleteElement(t,i),-1===i||-1===e)break}}const i=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),i>0)return this.m_nonSimpleResult=new ts(7,n,r),!1;for(let o=0,a=e.length;o<a;o++)this.recycleEdge(this.m_edges[o]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,s=e.length;t<s;t++){const s=e[t];let n=this.m_xyToNode1.read(s);if(n!==Pt.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(s,Pt.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==Pt.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(s,Pt.st_nullNode())}}for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===Pt.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();if(r.getStartY()<r.getEndY()){const e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=t):(n=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(n);this.m_xyToNode1.read(e)===Pt.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}}for(let t=0,s=this.m_newEdges.length;t<s&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let t=-1,s=this.m_AET.getPrev(e),n=e,r=0;{let e=-1,i=null,o=-1,a=0;for(;s!==Pt.st_nullNode()&&(e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex,a=this.m_pathOrientations.read(o),!(3&a));)n=s,s=this.m_AET.getPrev(s);s===Pt.st_nullNode()?(r=1,s=n):(t=1==(3&a)?o:this.m_pathParentage.read(o),r=i.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(r!==i.getRightSide())return this.m_nonSimpleResult=new ts(8,o,-1),!1;const e=r&&!i.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new ts(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),r=r?0:1}while(n!==e)}}return this.m_newEdges.length=0,!0}createEdge(e,t,s,n){let i;return e.getGeometryType()===r.enumLine?i=this.createEdgeLine(e):(i=new lm,i.m_segment=e.clone()),i.m_vertexIndex=t,i.m_pathIndex=s,i.m_flags=0,i.setReversed(n),i}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 lm,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===r.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,s,n){let r=e.calculateLowerLength2D();if(r<=s){let i=!0;if(e.isCurve()&&(r=e.calculateLength2D(),i=r<=s),i){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let s=e.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-t)<=n}return!0}return!1}return!1}static isShortSegmentPoints(e,t,s,n,r){if(s){const s=e.getXYZ(),i=t.getXYZ();return wt(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return T.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),i=e.querySegmentIterator();i.resetToPath(t),h(i.nextPath());const o=this.m_toleranceSimplify.total();let a=!1,m=!0;const l=new pt,g=new pt,u=new T;for(;i.hasNextSegment();){this.progress_();const e=i.nextSegment();if(Pm.isShortSegment(e,r,o,s))if(a){if(e.queryEnd(g),Pm.isShortSegmentPoints(l,g,r,o,s))continue;m&&(n.startPathPoint(l),m=!1),e.queryEnd(l),n.lineToPoint(l),a=!1}else u.assign(e.getStartXY()),e.queryStart(l),a=!0;else if(a)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(u,e.getEndXY(),!1),t.setStart(l),Pm.isShortSegment(t,r,o,s))continue;n.addSegment(t,m),m=!1,a=!1}else{if(e.queryEnd(g),Pm.isShortSegmentPoints(l,g,r,o,s))continue;m&&(n.startPathPoint(l),m=!1),n.lineToPoint(g),a=!1}else n.addSegment(e,m),m=!1}if(m)return;if(!a)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),l):e.getPointByVal(e.getPathEnd(t)-1,l);const c=n.querySegmentIterator();c.resetToLastPath(),c.resetToLastSegment();const _=n.getDescription().getAttributeCount()>1;for(h(c.previousPath());c.hasPreviousSegment();){const e=c.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),l.getXY(),!1),!Pm.isShortSegment(t,r,o,s)){_&&t.setEnd(l);const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.addSegment(t,!1)}}else if(e.queryStart(g),!Pm.isShortSegmentPoints(g,l,r,o,s)){const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(l)}}n.removePath(n.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;const t=e.getPointCount(),s=N(t,0);for(let n=0;n<t;n++)s[n]=n;s.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let n=1;n<t;n++)if(0===this.compareVerticesMultiPoint(s[n-1],s[n]))return this.m_nonSimpleResult=new ts(5,s[n-1],s[n]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl();const t=Pm.hasNanZs(e);let s,n=this.m_geometry;t&&(s=this.m_geometry.clone(),e=s.getImpl(),s.replaceNaNs(1,vt.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=N(r,0);for(let g=0;g<r;g++)i[g]=g;i.sort((e,t)=>this.compareVerticesMultiPoint(e,t));const o=new Array(r);o.fill(!1);let a=-1;for(let g=0;g<r;g++){const t=i[g];e.getXY(t).isFinite()&&((a<0||0!==this.compareVerticesMultiPoint(a,t))&&(o[t]=!0),a=t)}const m=this.m_geometry.createInstance();let h=0,l=0;for(let g=0;g<r;g++)o[g]?l=g+1:(h<l&&m.addPoints(n,h,l),h=g+1);return h<l&&m.addPoints(n,h,l),m.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),m}polylineSimplifyAsFeature(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator(),n=this.m_geometry.createInstance(),r=this.m_geometry,i=e.hasAttribute(1),o=i?It(this.m_sr,e,!0).total():0,a=[],m=[];let h=null;i&&(h=e.getAttributeStreamRef(1));const l=new pt,g=e.hasNonLinearSegments(),u=this.m_toleranceSimplify.total();for(;t.nextPath();){if(s.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(g&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,n);continue}s.resetToLastSegment();let c=0,_=0,d=!0,p=!0;for(;t.hasNextSegment();){this.progress_();const n=t.nextSegment(),r=s.previousSegment();if(t.getStartPointIndex()>s.getStartPointIndex())break;if(d){const s=t.getStartPointIndex();e.getXY(s).isNAN()||(d=!1,a.push(s))}if(p){const t=s.getEndPointIndex();e.getXY(t).isNAN()||(m.push(t),p=!1)}if(!d){const s=a.at(-1),r=t.getEndPointIndex();if(r-s>1){const t=new T;t.setSub(e.getXY(s),e.getXY(r)),c=t.length()}else c=n.calculateLength2D();if(c>u)a.push(r),c=0;else if(i){let e=h.read(s);Number.isNaN(e)&&(e=0);let t=h.read(r);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(a.push(r),c=0)}}if(!p){const t=m.at(-1),n=s.getStartPointIndex();if(n-t>1){const s=new T;s.setSub(e.getXY(t),e.getXY(n)),_=s.length()}else _=r.calculateLength2D();if(_>u)m.push(n),_=0;else if(i){let e=h.read(t);Number.isNaN(e)&&(e=0);let s=h.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-e)>o&&(m.push(n),_=0)}}}if(a.length>0&&m.length>0&&(a.at(-1)<m.at(-1)?a.length>m.length?a.pop():m.pop():(a.at(-1)===m.at(-1)||m.pop(),m.pop())),m.length+a.length>=2){let e=!1;for(let t=0,s=a.length;t<s;t++)r.getPointByVal(a[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);for(let t=m.length-1;t>0;t--)r.getPointByVal(m[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);r.isClosedPath(t.getPathIndex())?n.closePathWithLine():m.length>0&&(r.getPointByVal(m[0],l),n.lineToPoint(l))}a.length=0,m.length=0}return i&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,u),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!Nt(this.m_knownSimpleResult))return Ma(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new Te;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),0!==e.getTotalPointCount()){let t=null,s=0,n=0;if(e.hasCurves()){t=new fa;const r=Wt.constructEmpty();this.m_geometry.queryEnvelope(r);const i=_a(this.m_toleranceSimplify.total(),r);s=da(this.m_toleranceSimplify.total()),n=pa(i,s),aa(e,i,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}if(!Nt(this.m_knownSimpleResult)){ya(e,this.m_toleranceSimplify.add(n),this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===r.enumPolygon&&er(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==t&&t.stitchCurves(e,e.getFirstGeometry(),s,!0)}const t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===r.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,s){if(e===t)return 0;const n=this.m_pairs[e],r=this.m_pairs[t],i=n>>1,o=r>>1,a=this.m_xy.readPoint2D(2*i);a.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=this.m_xy.readPoint2D(2*o);m.y+=1&r?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const h=a.compare(m);if(0===h&&s){const e=this.m_pathsForOGCTests[i]-this.m_pathsForOGCTests[o];return U(e)}return h}compareVerticesMultiPoint(e,t){if(e===t)return 0;const s=this.m_multiVertexGeom.getXY(e),n=this.m_multiVertexGeom.getXY(t),r=!s.isFinite(),i=!n.isFinite();if(r||i)return r<i?-1:r>i?1:0;if(s.y<n.y)return-1;if(s.y>n.y)return 1;if(s.x<n.x)return-1;if(s.x>n.x)return 1;for(let o=1;o<this.m_attributeCount;o++){const s=this.m_description.getSemantics(o),n=vt.getComponentCount(s);for(let r=0;r<n;r++){const n=this.m_multiVertexGeom.getAttributeAsDbl(s,e,r),i=this.m_multiVertexGeom.getAttributeAsDbl(s,t,r),o=z(n,i);if(0!==o)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;const s=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&s.negateThis();const n=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&n.negateThis();const r=s.getQuarter(),i=n.getQuarter();if(i===r){const e=s.crossProduct(n);return e<0?1:e>0?-1:0}return r<i?-1:1}}class Em{getOperatorType(){return 10103}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,s,n,r){const i=om(e,t,s,n,r);return gt(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,r){const i=rm(e,t,s,n,r);return ut(i)}executeMany(e,t,s,n){return new Sm(e,t,s,n)}execute(e,t,s,n){const r=new es([e]),i=this.executeMany(r,t,s,n).next();return i||o("null geometry"),i}}class Sm extends $t{m_inputGeometryCursor;m_spatialReference;m_progressTracker;m_index;m_bForceSimplify;constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||s(""),e.getGeometryType()===r.enumGeometryCollection){const t=De(e,-1),s=(new Em).executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=e.createInstance();for(let e=s.next();null!=e;e=s.next())n.addGeometry(e);return n}return am(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Cm(e,t,s){const n=new Wt;e.queryEnvelope(n);const i=new Wt;t.queryEnvelope(i);const o=new Wt(i);if(o.inflate(2*s),!o.isIntersecting(n))return 4;const a=e.getGeometryType(),m=t.getGeometryType();if(a===r.enumEnvelope&&n.containsEnvelope(o))return 1;if(m===r.enumEnvelope){const e=new Wt(n);if(e.inflate(2*s),i.containsEnvelope(e))return 2}return 0}class Im{m_intersectorGeom=null;m_sr=null;m_dimensionMask=-1;m_progressTracker=null;m_intersectorGeomType=r.enumUnknown;m_geomIntersectorEmptyGeom=null;constructor(e,t,s,n){this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const s=ct(this.m_intersectorGeom,e),n=_t(this.m_sr,s,!0).total(),r=Wt.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=Wt.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),m=Zt(e,r,o,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=M(m,m=a)),za(m,a,this.m_sr,this.m_progressTracker)}intersectEx(e){const t=this.tryFastImplementation(e);if(null!==t){const s=[];return s.length=3,s[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,s)}const s=ct(this.m_intersectorGeom,e),n=_t(this.m_sr,s,!0).total(),r=Wt.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=Wt.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),m=Zt(e,r,o,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=M(m,m=a));const h=Wa(m,a,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,h)}init(e,t,s,n=null){h(0)}static intersectPoints(e,t,s){const n=ct(e,t);return La(e,t,_t(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===r.enumPoint&&t===r.enumPoint){const t=Im.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new ve({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===r.enumEnvelope&&this.m_intersectorGeomType===r.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new dt({copy:t});return n.intersect(s),n}const s=ct(e,this.m_intersectorGeom),n=_t(this.m_sr,s,!0),i=e.isEmpty(),a=this.m_intersectorGeom.isEmpty();let m=i||a;if(!m){const t=Cm(this.m_intersectorGeom,e,n.total());if(4===t)m=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(m){const s=g(t),n=g(this.m_intersectorGeomType);return s<n?Im.ReturnEmpty(e,i):s>n||0===s&&t===r.enumMultiPoint&&this.m_intersectorGeomType===r.enumPoint?this.ReturnEmptyIntersector():Im.ReturnEmpty(e,i)}if(t===r.enumEnvelope&&0===g(this.m_intersectorGeomType)||this.m_intersectorGeomType===r.enumEnvelope&&0===g(t)){const s=t===r.enumEnvelope?e:this.m_intersectorGeom,i=t===r.enumEnvelope?this.m_intersectorGeom:e,o=Wt.constructEmpty();return s.queryEnvelope(o),Zt(i,o,n.total(),0,this.m_progressTracker)}if(0===g(t)&&g(this.m_intersectorGeomType)>0||g(t)>0&&0===g(this.m_intersectorGeomType)){if(t===r.enumMultiPoint)return Oa(e,this.m_intersectorGeom,n);if(t===r.enumPoint)return Xa(e,this.m_intersectorGeom,n);if(this.m_intersectorGeomType===r.enumMultiPoint)return Oa(this.m_intersectorGeom,e,n);if(this.m_intersectorGeomType===r.enumPoint)return Xa(this.m_intersectorGeom,e,n);o("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,s){let n=0;return 1&t?(s[0]||(s[0]=new ve({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new Ce({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new we({vd:e})):s.splice(n,1),new es(s)}}class bm extends $t{m_inputGeoms;m_smallCursor=null;m_progressTracker;m_geomIntersector;m_index;m_dimensionMask;m_intersector;constructor(e,t,n,r,i){super(),this.m_progressTracker=r,this.m_geomIntersector=t.next(),this.m_intersector=new Im(this.m_geomIntersector,n,i,r),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=i,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&s("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let e;if(null!==this.m_smallCursor){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();){if(n(e),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask){return this.m_intersector.intersect(e)}this.m_smallCursor=this.m_intersector.intersectEx(e);return this.m_smallCursor.next()}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class wm{getOperatorType(){return 1e4}accelerateGeometry(e,t,s){if(!this.canAccelerateGeometry(e))return!1;mt(t,e,!0);let n=0;return e.getGeometryType()!==r.enumPolygon&&e.getGeometryType()!==r.enumPolyline||!Ie(e)||0===s||(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),!!n}canAccelerateGeometry(e){return Ie(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new bm(e,t,s,n,r)}execute(e,t,s,n){if(e.getGeometryType()===r.enumPoint&&t.getGeometryType()===r.enumPoint)return Im.intersectPoints(e,t,s);const i=new es([e]),a=new es([t]),m=this.executeMany(i,a,s,n,-1).next();return m||o("null output"),m}}function vm(e,t,s){return t.m_projector.project(e,s)}function Nm(e,t,s,n,r){e.m_projector.transformInPlaceZ(t,null,s,n,null,r);const i=n.slice(0,s).filter(e=>!e.isNAN());for(let o=0,a=i.length;o<a;++o)n[o].assign(i[o]);return i.length}function Tm(e,t,s,n,r){return e.m_projector.transformInPlaceZ(t,null,s,n,null,r)}function Gm(e,t,n,o){if(e&&t&&t.isPannable()||s("fold_into_360_range_geodetic"),e.isEmpty())return e;if(4===n)return Dm(e,t,o);let m=e;const h=m.getGeometryType();if(a(h)){m=Al(e,t);const s=new Wt;m.queryEnvelope(s);const r=_t(t,s,!1).total(),i=t.getPannableExtent();let o=Math.floor((s.xmin-i.xmin)/i.width())*i.width()+i.xmin,a=m;for(;o<s.xmax;)o>s.xmin+r&&o<s.xmax-r&&(a=kl(a,t,n,!0,o)),o+=i.width();m=a}else{if(h===r.enumEnvelope){const e=new we({vd:m.getDescription()});return e.addEnvelope(m,!1),Gm(e,t,n,o)}if(i(h)){const e=new Ce({vd:m.getDescription()});return e.addSegment(m,!0),Gm(e,t,n,o)}}return Dm(m,t,o)}function Dm(e,t,n){if(e&&t&&t.isPannable()||s(""),e.isEmpty())return e;let o;const a=e.getGeometryType();if(a===r.enumEnvelope){const t=new we({vd:e.getDescription()});t.addEnvelope(e,!1),o=t}else if(i(a)){const t=new Ce({vd:e.getDescription()});t.addSegment(e,!0),o=t}else o=e;const m=Al(o,t);return m.isEmpty()?m:vl(m,t,0,m!==e,0,n)}function Vm(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,i=e.queryInterval(0,0);if(i.width()<r||!f(e.getGeometryType())){if(Number.isNaN(s))return e;const t=i.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new jt,i=k((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const o=e.getGeometryType(),m=e,h=m.getAttributeStreamRef(0),l=e.clone(),g=l.getAttributeStreamRef(0);let u=0,c=0,_=0,d=a(o)?0:-1;const p=A.constructEmpty();let x=!1;for(let f=0,y=m.getPointCount();f<y;f++){const e=h.read(2*f);f===c&&(a(o)?(0===d&&Number.isNaN(s)&&(x=!0),d>0&&Number.isNaN(s)&&(s=p.getCenter(),x=!1),c=m.getPathEnd(d),d++):c=m.getPointCount(),Number.isNaN(s)?_=e:(_=s,u=0));let t=e-_;Math.abs(t)>r&&(t=k(t/n)*n,u-=t,Math.abs(u)<.1*n&&(u=0));const i=e+u;g.write(2*f,i),x&&p.mergeCoordinate(i),_=e}return l.notifyModified(),l}const Fm="missing implementation";function km(e,t,s,n){const r=t.getCoordinateSystemType();if(0===r){const n=new ac;return t.queryPrecisionDescriptor(n),Hm(e,n,t,s)}let i=e;2!==n&&3!==n||!t.isPannable()||(i=Dm(i,t,s));const a=new ac;if(t.queryPrecisionDescriptor(a),i=Hm(i,a,t,s),0===n||i.isEmpty())return i;if(1===r){if(1===n){const e=new Wt;i.queryLooseEnvelope(e);const n=t.getPannableExtent(),r=.01*n.width();return n.xmin=e.xmin-r,n.xmax=e.xmax+r,(new Kt).execute(i,n,t,s)}return i}if(2===r){const e=t.getPCSHorizon();if(1===n||2===n){const n=(new wm).execute(i,e,t,s);return n===e?n.clone():n}return i}if(3===r)return i;o(Fm)}function Hm(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let a=new A,m=new A;i&&(a=t.getZGridRange()),o&&(m=t.getMGridRange());let h=(new Kt).execute(e,r,s,n);if(i){const t=h.queryInterval(1,0);a.contains(t)||(e===h&&(h=h.clone()),Ot(h,a,1,0))}if(o){const t=h.queryInterval(2,0);m.contains(t)||(e===h&&(h=h.clone()),Ot(h,m,2,0))}return h}class Am{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||s(""),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;const t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.densificationStep;const n=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=n.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=n.hasFlag(1073741824),this.m_bClipOutCurvedPoles=n.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const s=e.getGeometryType();if(s===r.enumPoint)return this.projectPoint(e,t);const n=this.m_projTransform.getInputSR().getCoordinateSystemType(),i=this.m_projTransform.getOutputSR().getCoordinateSystemType(),a=this.m_projTransform.getInputSR(),m=this.m_projTransform.getOutputSR();if(0===n&&n===i){const t=Um(a,m),s=e.clone();return s.applyTransformation(t),s}switch(s){case r.enumPolyline:case r.enumPolygon:return this.projectMultiPath(e,t);case r.enumMultiPoint:return this.projectMultiPoint(e,t);case r.enumEnvelope:return this.projectEnvelope(e,t);case r.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:o("")}}projectPoint(e,t){const s=[e.getXY()];let n,r=null;(n=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(s,r,1,s,r,null);const i=e.clone();return i.setXY(s[0]),n&&i.setZ(r[0]),i}projectMultiPoint(e,t){let s=new ve({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),o=r.getCoordinateSystemType();if(3===i&&h(0),s=Xl(s,n,this.m_inputPCSHorizonClipOption,t),s.isEmpty())return s;2===i&&$l(n,0,s),gg(this.m_projTransform,s,!1);let a=0;3===o&&h(0);const m=2===o;return m?a=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(a=this.m_centralMeridianOfOutputGCS),m&&0!==this.m_outputPCSHorizonClipOption||(s=vl(s,Zu(r),a,!1,0,t)),m&&(s=Sl(s,r,this.m_outputPCSHorizonClipOption,t),Kl(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const s=e.getGeometryType();return s===r.enumPolygon?this.projectPolygon(e,t):s===r.enumPolyline?this.projectPolyline(e,t):void o("project_multi_path_")}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&e.hasAttribute(1);let n=A.constructEmpty();if(s&&(n=e.queryInterval(1,0)),n.width()>0){const s=e.clone();s.setInterval(1,0,n.vmin,n.vmin);const r=this.projectEnvelopeHelper(s,t);s.setInterval(1,0,n.vmax,n.vmax);const i=this.projectEnvelopeHelper(s,t);return r.merge(i),r}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){h(e.getGeometryType()===r.enumPolygon),h(!this.m_projTransform.isIdentity()),h(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),i=s.getCoordinateSystemType(),o=n.getCoordinateSystemType(),a=new we({copy:e});3===i&&h(0),3===o&&h(0);const m=2===i,l=2===o,g=m?s.getGCS():s,u=l?n.getGCS():n,c=!l&&!this.m_bDontHackPolesInGeogToGeog;let _=!1,d=Xl(a,s,this.m_inputPCSHorizonClipOption,t);if(d.isEmpty())return d;let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;f&&(d=(new Jt).execute(d,p,0,0,t));let y=l?n.getPCSInfo():null,P=Number.NaN;m&&(P=s.getCentralMeridian());const E=null!==n.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=d;if(m&&(mg(s,P,e),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,c),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}x=e}else{let e=new Ce({vd:d.getDescription()});if(e.addAndExplicitlyOpenAllPaths(d,!1),m){if(mg(s,P,e),f){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),r=n.getSouthPoleGeometry()===Nc.PE_POLE_LINE_CURVED,i=n.getNorthPoleGeometry()===Nc.PE_POLE_LINE_CURVED;if(r||i){const s=Wt.constructEmpty();e.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*g.getOneDegreeGCSUnit();r&&(s.ymin=-n),i&&(s.ymax=n),e=Qt(e,s,g,0,0,t)}}}if(cg(this.m_projTransform,e,c),f){const e=Zu(s).getUnitsPerMillimeter();p*=Zu(n).getUnitsPerMillimeter()/e}let r=Number.NaN;l?(y=n.getPCSInfo(),r=n.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=Mm(s)|Mm(n),o=10*u.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=10*u.getTolerance(0)),x=Vl(d,s,e,u,r,t,i,o,this.m_bNormalizeOutputGeometry),i=0}if(E&&(h(!n.isPannable()),x=cl(x,n,t)),l){if(!_){const e=u.getPannableExtent().width();if(x.queryInterval(0,0).width()>=e-10*u.getTolerance(0)){const e=y.getNorthPoleLocation(),t=y.getSouthPoleLocation(),s=y.getNorthPoleGeometry(),n=y.getSouthPoleGeometry();let r=0;s===Nc.PE_POLE_POINT&&e!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r=1),n===Nc.PE_POLE_POINT&&t!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r|=2),_||=0!==r}}x=Sl(x,n,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(n,x,this.m_bNormalizeOutputGeometry)}return x.isEmpty()||_&&(x=(new Em).execute(x,n,!1,t)),x}projectPolyline(e,t){h(e.getGeometryType()===r.enumPolyline),h(!this.m_projTransform.isIdentity()),h(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),i=s.getCoordinateSystemType(),o=n.getCoordinateSystemType(),a=new Ce({copy:e});3===i&&h(0),3===o&&h(0);const m=2===i,l=2===o;m&&s.getGCS();const g=l?n.getGCS():n,u=!l&&!this.m_bDontHackPolesInGeogToGeog;let c=Xl(a,s,this.m_inputPCSHorizonClipOption,t);if(c.isEmpty())return c;let _=Number.NaN;m&&(_=s.getCentralMeridian());const d=null!==n.getGCSSplitLines();let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;if(f&&(c=(new Jt).execute(c,p,0,0,t)),this.m_bDontGeonormalizePolygon){if(m&&(mg(s,_,c),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,c,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}x=c}else{const e=new Ce({vd:c.getDescription()});if(e.addAndExplicitlyOpenAllPaths(c,!1),m&&(mg(s,_,e),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}let r=Number.NaN;l?r=n.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=Mm(s)|Mm(n),o=10*g.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=0),x=Fl(c,s,e,g,r,t,i,o,this.m_bNormalizeOutputGeometry),i=0}return d&&(h(!n.isPannable()),x=cl(x,n,t)),l&&(x=Sl(x,n,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(n,x,this.m_bNormalizeOutputGeometry)),x.isEmpty(),x}projectGeometryCollection(e,t){return h(0),{}}projectEnvelopeHelper(e,t){const s=(e.height()+e.width())/400;if(0!==s){const n=(new Jt).execute(e,s,0,0,t),r=this.projectMultiPath(n,t),i=new dt({vd:e.getDescription()});if(r.isEmpty()){const s=Math.min(e.height(),e.width()),r=mt(this.m_projTransform.getInputSR(),e,!0).total();if(s>100*r){const e=Wt.constructEmpty(),t=_t(this.m_projTransform.getOutputSR(),e,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(r,t*n))return i}const o=new Ce;o.addAndExplicitlyOpenAllPaths(n,!1);this.projectMultiPath(o,t).queryEnvelope(i);const a=new ve({vd:e.getDescription()});a.reserve(4);const m=new pt;for(let t=0;t<4;t++)e.queryCornerByVal(t,m),a.add(m);const h=this.projectMultiPoint(a,t),l=new dt;return h.queryEnvelope(l),i.merge(l),i}return r.queryEnvelope(i),i}{const s=e.getCenterXY(),n=new pt(s),r=this.projectPoint(n,t),i=new dt({vd:e.getDescription()});if(r.isEmpty())i.setEmpty();else{e.copyTo(i);const t=r.getXY();i.setCoords(t.x,t.y,t.x,t.y)}return i}}transformInPlace(e,t,s,n){return h(0),0}transformInPlaceZ(e,t,s,n,r,i){if(this.m_projTransform.isIdentity())return e!==n&&V(n,e,s),t!==r&&ne(r,t,0,0,s),s;const o=this.m_projTransform,a=o.getInputSR(),m=o.getOutputSR(),l=a.getCoordinateSystemType(),g=m.getCoordinateSystemType();if(0===l&&l===g){return Um(a,m).transformPoints2D(e,s,n),o.isVertical()&&h(0),s}3===l&&_("image: transform_in_place_"),3===g&&_("image: transform_in_place_"),Ll(e,s,n,a,this.m_inputPCSHorizonClipOption),r!==t&&ne(r,t,0,0,s),2===l&&hg(a,0,n,s),fg(this.m_projTransform,n,r,s,!1);let u=0;const c=2===g;c?u=m.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(u=this.m_centralMeridianOfOutputGCS),c&&0!==this.m_outputPCSHorizonClipOption||Nl(n,s,m.getGCS(),u),c&&(wl(n,s,m,this.m_outputPCSHorizonClipOption),Wl(m,n,s,!1));let d=s;for(let h=0;h<s;++h)n[h].isNAN()&&(r&&(r[h]=Number.NaN),d--);return d}}function Mm(e){if(2!==e.getCoordinateSystemType())return 0;let t=0;const s=e.getPCSInfo(),n=s.getNorthPoleLocation(),r=s.getSouthPoleLocation(),i=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return i===Nc.PE_POLE_POINT&&n!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===Nc.PE_POLE_POINT&&r!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function Um(e,t){const s=e.getHorzUnitFactor(),n=t.getHorzUnitFactor();let r=1,i=1;const o=20015077/180;1===e.getUnit().getUnitType()&&(r=o),1===t.getUnit().getUnitType()&&(i=o);const a=s/n*(r!==i?r/i:1),m=new jt;return m.setScaleCoords(a,a),m}class qm{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s){return!t||t.isIdentity()?e:new Bm(e,t,s)}execute(e,t,s){return t.isIdentity()?e:vm(e,t,s)}transform(e,t,s,n,r=!0){return r?Nm(e,t,s,n,null):Tm(e,t,s,n,null)}transform3D(e,t,s,n,r=!0){return h(0),0}foldInto360Range(e,t){return Dm(e,t,null)}foldInto360RangeGeodetic(e,t,s){return Gm(e,t,s,null)}normalizeGeometryEx(e,t,s,n,r=0){return Th(e,t,s,n,r)}normalizeGeometry(e,t,s){return Vm(e,t,s)}clipToSpatialReference(e,t,s,n=0){return km(e,t,s,n)}}class Bm extends $t{m_inputGeoms;m_projTrans;m_index;m_progressTracker;constructor(e,t,n){super(),this.m_projTrans=t,this.m_progressTracker=n,this.m_index=-1,e||s(""),this.m_inputGeoms=e}next(){const e=this.m_inputGeoms.next();return null!=e?(x(e),n(e),this.m_index=this.m_inputGeoms.getGeometryID(),vm(e,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Om(e,t,o,m,g,u,c=!1){e||s("Geometry.Geodetic_densify.densify");let _=e.getGeometryType();if(n(e),e.isEmpty()||l(_))return e;const d=new Wm;d.m_sr=t,d.m_gcs=t.getGCS(),d.m_transform=d.m_gcs!==t?t.getSRToGCSTransform():null,d.m_progressTracker=u;const p=ku();let f,x,y;if(d.m_gcs.querySpheroidData(p),d.m_a=p.majorSemiAxis,d.m_eSquared=p.e2,d.m_rpu=d.m_gcs.getUnit().getUnitToBaseFactor(),d.m_gcsTolerance=d.m_gcs.getTolerance(0),d.m_radTolerance=d.m_gcsTolerance*d.m_rpu,d.m_maxLength=m,d.m_maxDeviation=g,d.m_curveType=o,_===r.enumEnvelope){const t=new we({vd:e.getDescription()});t.addEnvelope(e,!1),f=t,_=r.enumPolygon}else if(i(_)){const t=new Ce({vd:e.getDescription()});t.addSegment(e,!0),f=t,_=r.enumPolyline}else f=e;if(4!==d.m_curveType){if(h(a(_)),x=d.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(f),x.isEmpty())return x;x=Rm(d.m_rpu,x);let e=d.geodeticDensify(x);c||(e=(new qm).foldInto360RangeGeodetic(e,d.m_gcs,d.m_curveType)),y=d.m_transform&&!d.m_transform.isIdentity()?(new qm).execute(e,d.m_transform.getInverse(),u):e}else{let e;if(h(a(_)),t.isPannable())e=Al(f,t);else{const s=t.getPCSHorizon();e=(new wm).execute(f,s,t,u),e===s&&(e=s.clone())}if(x=e,x.isEmpty())return x;y=d.shapePreservingDensify(x)}return y}function Rm(e,t){const s=new Wt;if(t.queryLooseEnvelope(s),s.width()*e<Math.PI)return t;let n=!1;const r=t.querySegmentIterator(),i=new T,o=new T;for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(i.setCoordsPoint2D(t.getStartXY()),o.setCoordsPoint2D(t.getEndXY()),i.scale(e),o.scale(e),Math.abs(i.x-o.x)>Math.PI){if(!Xm(i,o)){n=!0;break}if(Math.abs(i.x-o.x)>2*Math.PI){n=!0;break}}}if(!n)return t;const a=t.createInstance();a.reserve(t.getPointCount());const m=t.getDescription().getAttributeCount()>1,h=new T,l=new T,g=new T(0,0),u=new T(0,0),c=new pt;for(r.resetToFirstPath();r.nextPath();){let t=Number.NaN,s=0;for(;r.hasNextSegment();){const n=r.nextSegment();i.setCoordsPoint2D(n.getStartXY()),o.setCoordsPoint2D(n.getEndXY()),i.scale(e),o.scale(e),Number.isNaN(t)?(s=ih(i.x,Number.NaN,s),g.setCoordsPoint2D(i)):g.setCoordsPoint2D(u),t=g.x;if(Xm(i,o)){if(o.x-i.x>2*Math.PI)for(;o.x-i.x>2*Math.PI;)o.x-=2*Math.PI;else if(o.x-i.x<2*-Math.PI)for(;o.x-i.x<2*-Math.PI;)o.x+=2*Math.PI;s=ih(o.x,Number.NaN,s),u.setCoordsPoint2D(o)}else h.setCoordsPoint2D(o),gh(h),s=ih(h.x,t,s),u.setCoords(s+h.x,h.y);if(Math.abs(u.x-o.x)<.5&&u.setCoordsPoint2D(o),m){n.queryCoord(0,c),l.setCoordsPoint2D(g),l.scale(1/e),c.setXY(l);r.isFirstSegmentInPath()?a.startPathPoint(c):a.lineToPoint(c),r.isLastSegmentInPath()&&!r.isPathClosed()&&(n.queryCoord(1,c),l.setCoordsPoint2D(u),l.scale(1/e),c.setXY(l),a.lineToPoint(c))}else{r.isFirstSegmentInPath()&&a.insertPath2D(-1,null,0,0,!0);const t=a.getPathCount()-1;l.setCoordsPoint2D(g),l.scale(1/e),a.insertPoint2D(t,-1,l),r.isLastSegmentInPath()&&!r.isPathClosed()&&(l.setCoordsPoint2D(u),l.scale(1/e),a.insertPoint2D(t,-1,l))}}}return a}function Ym(e,t,s,n,r,i,o,a,m,h,l,g){const u=new T,c=new T,_=n.compare(r)>0;nh(_,n,r,u,c);const d=Km(e,t,s,u,c,i,o,a,m,h,null,l,g);return _&&sh(m,h,null,l),d}function Xm(e,t){return!(!Pc(e.y,j)||!Pc(t.y,j))||!(!Pc(e.y,-j)||!Pc(t.y,-j))}function Lm(e,t){return!(!Pc(e.y,j)||Pc(t.y,j))||!(!Pc(e.y,-j)||Pc(t.y,-j))}function zm(e,t){return!(!Pc(t.y,j)||Pc(e.y,j))||!(!Pc(t.y,-j)||Pc(e.y,-j))}class Wm{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){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new Ve,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();){const e=[0];for(;s.hasNextSegment();){const a=s.nextSegment(),m=a.getStartXY(),h=a.getEndXY();m.scale(this.m_rpu),h.scale(this.m_rpu);const l=new T,g=new T,u=m.compare(h)>0;nh(u,m,h,l,g),n.length=0,r.length=0,this.m_maxLength>0?Km(this.m_a,this.m_eSquared,this.m_curveType,l,g,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,o?r:null,n,e):Qm(),u&&sh(null,null,o?r:null,n),n[0].setCoordsPoint2D(a.getStartXY()),n.at(-1).setCoordsPoint2D(a.getEndXY());const c=1/this.m_rpu;for(let e=1,t=n.length-1;e<t;e++)n[e].scale(c);if(o){const e=rh(u,a,i);Zm(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),a,e,r,n,t)}else jm(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}}return t}shapePreservingDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new Ve,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment(),a=e.getStartXY(),m=e.getEndXY(),h=a.compare(m)>0,l=rh(h,e,i);n.length=0,r.length=0,th(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,o?r:null,n),h&&sh(null,null,o?r:null,n),o?Zm(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),e,l,r,n,t):jm(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){const t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Al(e,this.m_gcs),!t))return e;const s=e.createInstance();s.reserveParts(e.getPointCount(),e.getPathCount());for(let n=0,r=e.getPathCount();n<r;++n){let t=new ve;const r=e.getPathStart(n),i=e.getPathEnd(n);t.addPoints(e,r,i);const o=e.isClosedPath(n);let a=!1;if(o&&i-r===1&&e.hasNonLinearSegmentsPath(n)){const s=new pt;e.getPointByVal(r,s),t.add(s),a=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!a){const s=new pt;e.getPointByVal(r,s),t.add(s)}if(t=(new qm).execute(t,this.m_transform,this.m_progressTracker),o&&t.getPointCount()>1){const e=t.getXY(0),s=t.getXY(t.getPointCount()-1);e.equals(s)&&t.removePoint(t.getPointCount()-1)}}t.getPointCount()>1&&(s.addPathMultiPoint(t,0,-1,!0),o&&s.closePathWithLine())}return s}}function jm(e,t,s,n){e&&n.insertPath2D(-1,null,0,0,!0);const r=n.getPathCount()-1;n.insertPointsFromPoints(r,-1,s,0,s.length-1,!0),t&&n.insertPoint2D(r,-1,s.at(-1))}function Zm(e,t,s,n,r,i,o){o.reserve(o.getPointCount()+i.length-1);const a=new pt;if(s.queryStart(a),e?o.startPathPoint(a):o.lineToPoint(a),i.length>2){const e=n.calculateLength2D();for(let t=1;t<i.length-1;t++){const s=n.lengthToT(r[t]*e);n.queryCoord(s,a),a.setXY(i[t]),o.lineToPoint(a)}}t&&(s.queryEnd(a),o.lineToPoint(a))}function Km(s,n,r,i,o,a,m,h,l,g,u,c,_){const d={stack:[],error:void 0,hasError:!1};try{const t=e(d,new Cc,!1),p=e(d,new Cc,!1),f=e(d,new Cc,!1);Dc.geodeticDistance(s,n,i.x,i.y,o.x,o.y,f,t,p,r);const x=f.val,y=t.val,P=p.val;let E=y,S=P;E<0&&(E+=2*Math.PI),S<0&&(S+=2*Math.PI),l&&(l[0]=E),g&&(g[0]=S);let C=Number.NaN,I=Number.NaN;if(null!==u){const e=Vc.q90(s,n),t=Vc.q(s,n,i.y);C=(e-t)/x,I=(e+t)/x}const b=Lm(i,o),w=zm(i,o),v=b||w,N=hh(i,o,h),G=e(d,new O(new Cc,new Cc),!1),D=new T,V=new T,F=new T;_[0]=ih(i.x,Number.NaN,_[0]);let k=_[0];if(x<=a)return c.push(i.clone()),_[0]=ih(o.x,Number.NaN,_[0]),null!=u&&u.push(0),v?(b&&oh(i,o,u,c),w&&ah(i,o,u,c)):N?mh(i,o,y,C,I,u,c):m>0&&(V.setCoords(i.x-k,i.y),D.setCoords(o.x-_[0],o.y),k=Jm()),c.push(o.clone()),x;const H=1+Math.ceil(x/a),A=x/(H-1),M=new T;c.push(i.clone()),M.setCoordsPoint2D(i),V.setCoords(i.x-_[0],i.y),null!==u&&u.push(0);for(let e=1;e<H;e++){let t;if(e<H-1){const o=e*A;Dc.geodeticCoordinate(s,n,i.x,i.y,o,y,G.at(0),G.at(1),r),D.setCoords(G.at(0).val,G.at(1).val),_[0]=ih(D.x,M.x,_[0]),F.setCoords(_[0]+D.x,D.y),t=e/(H-1)}else _[0]=ih(o.x,Number.NaN,_[0]),D.setCoords(o.x-_[0],o.y),F.setCoordsPoint2D(o),t=1;v?(1===e&&b&&oh(i,F,u,c),e===H-1&&w&&ah(M,o,u,c)):N?lh(M,F,h)&&(i.x<o.x?M.x>F.x&&(_[0]+=2*Math.PI,F.setCoords(_[0]+D.x,D.y)):M.x<F.x&&(_[0]-=2*Math.PI,F.setCoords(_[0]+D.x,D.y)),mh(M,F,y,C,I,u,c)):m>0&&Jm(),c.push(F.clone()),null!=u&&u.push(t),M.setCoordsPoint2D(F),V.setCoordsPoint2D(D),k=_[0]}return x}catch(p){d.error=p,d.hasError=!0}finally{t(d)}}function Qm(e,t,s,n,r,i,o,a,m,l){h(0)}function Jm(e,t,s,n,r,i,o,a,m,l,g,u,c,_,d){return h(0),0}function $m(e,t,s,n){const r=ds(e,t,s),i=ds(e,t,n);return qt.distance(r,i)}function eh(e,t,s,n,r,i,o,a){const m=new Array,l=B(Array,8);let g=2,u=r.getCoord2D(i);l[0][0]=u.x,l[0][1]=u.y,u=r.getCoord2D(o),l[1][0]=u.x,l[1][1]=u.y;const c=e=>{if(null!==s){const t=wc.projToGeog(s,e,l);h(t===e)}for(const t of l)t[0]*=n,t[1]*=n};c(2),m.push(ds(e,t,new T(l[0][0],l[0][1]))),m.push(ds(e,t,new T(l[1][0],l[1][1])));let _=qt.distance(m[0],m[1]);if(_>a)return _;let d=0;for(g=3;g<=17;){const s=1/(g-1);let n=0;for(let e=1;e<g;++e)if(1&e){const t=R(i,o,e*s);r.queryCoord2D(t,u),l[n][0]=u.x,l[n][1]=u.y,n++}c(n);let p=1;for(let r=0;r<n;++r)m.splice(p,0,ds(e,t,new T(l[r][0],l[r][1]))),p++;p=0;let f=m[p];p++;let x=0;for(;p!==m.length;++p){const e=m[p];x+=qt.distance(f,e),f=e}if(x>a)return x;if(d=x-_,h(d>=0||Math.abs(d)<1e-14*x),d<0&&(d=0),_=x,x+d<=a)return x+d;g=2*g-1}return _+d}function th(e,t,s,n,r,i,o,a,m){const l=n.isCurve(),g=Fs(e,t)*Math.PI*179/180;let u=i;i>0&&!(i>g)||(u=g);const c=o,_=c>0;let d=Number.NaN;_&&(d=Bs(e,t,c));const p=1===r.getCoordinateSystemType();let f=null;p||(f=r.getPECoordSys());const x=r.getTolerance(0),y=n.getStartXY(),P=n.getEndXY(),E=new T,S=new T;if(p)E.setCoordsPoint2D(y),E.scale(s),S.setCoordsPoint2D(P),S.scale(s);else{const e=[y.x,y.y,P.x,P.y];wc.projToGeog(f,2,e),E.setCoords(e[0],e[1]),E.scale(s),S.setCoords(e[2],e[3]),S.scale(s)}let C=0,I=0;const b=[],w=[],v=[];b.push(P.clone()),w.push(S.clone()),v.push(1),m.push(y.clone()),null!==a&&a.push(I);const N=r.isPannable(),G=y.clone(),D=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let V=5;l||(_?(D[0]=.5,D[1]=.25,D[2]=.75,V=3):V=1),h(u>0);const F=e=>{if(e=e.clone(),null!==f){const t=[e.x,e.y];wc.projToGeog(f,1,t),e.setCoords(t[0],t[1])}return e.scale(s),e};for(;w.length>0;){const i=b.at(-1).clone();S.assign(w.at(-1));const o=v.at(-1);let g=!1,c=Number.NaN;const y=eh(e,t,f,s,n,I,o,u);let P=u>=y&&Math.abs(E.y-S.y)<.9*Math.PI;p&&P&&(P=Math.abs(E.x-S.x)<.9*Math.PI);const k=new T,H=new T;let M=!1;if(!_&&P&&P&&(M=!0),n.calculateSubLength(I,o)<=x&&(M=!0),!M)for(let a=0;a<V;a++){const m=R(I,o,D[a]),u=new T;n.queryCoord2D(m,u);const f=F(u);if(0===a&&(c=m,k.setCoordsPoint2D(u),H.setCoordsPoint2D(f),!P)){g=!0;break}if(h(_),p&&Math.abs(E.x-f.x)>=Math.PI){g=!0;break}let x=new T,y=new T;l?(x=T.lerp(G,i,D[a]),y=F(x)):(x=u.clone(),y=f.clone());const C=Ss(e,t,E,S,D[a]),b=C.clone();if(p?(b.x/=s,b.y/=s):(b.x/=s,b.y/=s,Tm(r.getGCSToSRTransform(),[b],1,[b],null)),b.isNAN()){const s=ds(e,t,f),n=ds(e,t,E),r=ds(e,t,S),{second:i}=vs(e,t,s,n,r,2,null);if(i>d){g=!0;break}}else{if(N){const e=r.getPannableExtent().width(),t=R(n.getStartX(),n.getEndX(),.5);for(;b.x<t-.5*e;)b.x+=e;for(;b.x>=t+.5*e;)b.x-=e}const s=n.getClosestCoordinateOnInterval(b,new A(I,o),-1);let i=n.getCoord2D(s);i=F(i);let a=$m(e,t,i,C);if(a>d){if(a<4*d){const s=ds(e,t,i),n=ds(e,t,E),r=ds(e,t,S),{second:o}=vs(e,t,s,n,r,2,null);a=o}if(a>d){g=!0;break}}else if(l){let s=ds(e,t,f);const n=ds(e,t,E),r=ds(e,t,S);let{second:i}=vs(e,t,s,n,r,3,null);if(i<=d){s=ds(e,t,y);const{second:o}=vs(e,t,s,n,r,3,null);i=o}if(i>d){g=!0;break}}}}g?(b.push(k.clone()),w.push(H.clone()),v.push(c)):(b.pop(),w.pop(),v.pop(),m.push(i.clone()),C+=y,null!==a&&a.push(C),G.setCoordsPoint2D(i),E.setCoordsPoint2D(S),I=o)}if(null!==a){const e=1/C;for(let t=0;t<a.length;t++)a[t]*=e}}function sh(e,t,s,n){if(n.reverse(),null!==s&&s.reverse(),e){const s=e[0],n=t[0];e[0]=n,t[0]=s}}function nh(e,t,s,n,r){e?(n.setCoordsPoint2D(s),r.setCoordsPoint2D(t)):(n.setCoordsPoint2D(t),r.setCoordsPoint2D(s))}function rh(e,t,s){return e?(s.create(t.getGeometryType()),t.copyTo(s.get()),s.get().reverse(),s.get()):t}function ih(e,t,s){if(Number.isNaN(t)){for(;s-e>Math.PI;)s-=2*Math.PI;for(;e-s>Math.PI;)s+=2*Math.PI;return s}return s+e-t>Math.PI?s-=2*Math.PI:t-(s+e)>Math.PI&&(s+=2*Math.PI),s}function oh(e,t,s,n){if(e.y>0){const r=new T;r.setCoords(t.x,j),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new T;r.setCoords(t.x,-j),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}}function ah(e,t,s,n){if(t.y>0){const r=new T;r.setCoords(e.x,j),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new T;r.setCoords(e.x,-j),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}}function mh(e,t,s,n,r,i,o){if(Sc(s)){if(j-e.y>0){const t=new T;t.setCoords(e.x,j),o.push(t),null!==i&&i.push(n)}if(j-t.y>0){const e=new T;e.setCoords(t.x,j),o.push(e),null!==i&&i.push(n)}}else{if(j+e.y>0){const t=new T;t.setCoords(e.x,-j),o.push(t),null!==i&&i.push(r)}if(j+t.y>0){const e=new T;e.setCoords(t.x,-j),o.push(e),null!==i&&i.push(r)}}}function hh(e,t,s){return!(!lh(e,t,s)||Pc(e.y,j)||Pc(e.y,-j)||Pc(t.y,j)||Pc(t.y,-j))}function lh(e,t,s){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=s}function gh(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=2*Math.PI;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=2*Math.PI}function uh(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=[r.x],a=[r.y-i],m=[r.x],h=[r.y+i];Vs(t,a),Vs(m,h);const l=e(o,new Cc,!1),g=e(o,new Cc,!1);Dc.greatEllipticDistance(s,n,r.x,r.y,t[0],a[0],l,null,null),Dc.greatEllipticDistance(s,n,r.x,r.y,m[0],h[0],g,null,null);return Math.min(l.val,g.val)}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function ch(e,t,s,n,r){const i=new Wt;s.queryEnvelope(i);const o=mt(null,s,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return s;const a=t.width();let m=0;for(;t.xmin+m*a<i.xmin;)m++;for(;t.xmin+m*a>i.xmin;)m--;const h=m*a,l=new jt;l.setShiftCoords(-h,0);const g=s;g.applyTransformation(l);const u=new Wt;g.queryEnvelope(u);let c=null;if(u.xmax>t.xmax){let s=0;const n=new Wt;n.setCoords({env2D:t}),n.ymin-=1,n.ymax+=1;let i=g;for(;n.xmin<u.xmax;){u.xmax>n.xmax&&(i=kl(i,e,2,!0,n.xmax));const o=zt(i,n),m=_t(null,o,!0).total(),h=Zt(i,n,m,Number.NaN,r);null===c?c=h===i?h.clone():h:(l.setShiftCoords(-s*a,0),h.applyTransformation(l),c.add(h,!1)),s++,n.xmin=n.xmax,n.xmax=t.xmax+s*a}}else c=g;return c}class _h{m_gcs;m_a;m_e2;m_rpu;m_curvCenterRad;m_cartCenter3D;m_basisX=new qt;m_basisY=new qt;m_normal=new qt;m_d;m_northPolePcs;m_southPolePcs;constructor(e,t){h(1===e.getCoordinateSystemType()),this.m_gcs=e;const s=ku();e.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);const n=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,i=Math.cos(n),o=Math.sin(n),a=Math.cos(r),m=Math.sin(r);this.m_cartCenter3D=fs(this.m_a,this.m_e2,i,o,a,m),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),qt.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(T.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(T.construct(0,.5*-Math.PI/this.m_rpu))}project(e){const t=e.getGeometryType();if(f(t)){x(e);const t=e;return this.projectMultiVertex(t)}s("Gnomonic.project")}unproject(e,t,n){const i=e.getGeometryType();if(f(i)){x(e);let s=e;const o=[];if(i===r.enumPolygon){const e=s.getPathCount();for(let t=0;t<e;t++){const e=s.calculateRingArea2D(t);o.push(e)}}return this.unprojectMultiVertex(t,s),a(i)?(Ch(this.m_gcs,0,s),dh(o,this.m_gcs,0,s,n)):s=vl(s,this.m_gcs,0,!0,0,n),s}s("Gnomonic.unproject")}projectPoint(e){const t=e.mul(this.m_rpu),s=ds(this.m_a,this.m_e2,t),n=this.m_normal.dotProduct(s);if(n<=0)return T.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new T;return o.x=this.m_basisX.dotProduct(i),o.y=this.m_basisY.dotProduct(i),o}unprojectPoint(e){const t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return Ps(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){const t=e.getImpl();let s=!0;const n=new T,r=new T;for(let i=0,o=t.getPointCount();i<o;i++)t.queryXY(i,n),n.y*this.m_rpu>.5*Math.PI?r.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?r.assign(this.m_southPolePcs):r.assign(this.projectPoint(n)),t.setXYNoCurves(i,r),r.isNAN()&&(s=!1);return t.notifyModifiedFlags(2001),s}unprojectMultiVertex(e,t){const s=t.getImpl(),n=e*e,r=!this.m_northPolePcs.isNAN(),i=!this.m_southPolePcs.isNAN();for(let o=0,a=s.getPointCount();o<a;o++){const e=s.getXY(o);let t=new T;r&&T.sqrDistance(e,this.m_northPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*Math.PI),t.scale(1/this.m_rpu)):i&&T.sqrDistance(e,this.m_southPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),t.scale(1/this.m_rpu)):t=this.unprojectPoint(e),s.setXYNoCurves(o,t)}s.notifyModifiedFlags(2001)}}function dh(e,t,s,n,i){const o=n.getGeometryType(),a=t.getPannableExtent();let m=n,h=!1,l=!1;if(o===r.enumPolygon){const n=new Wt,r=T.construct(s,0);n.setCoords({env2D:a}),n.centerAt(r),h=ph(e,t,n,m,i);const o=Sh(t,n,m,i);o!==m&&(l=!0),m=o}else m=(new qm).foldInto360RangeGeodetic(m,t,2);o===r.enumPolygon&&(h||l)&&(m=(new Em).execute(m,t,!1,i)),m!==n&&(n.setEmpty(),n.add(m,!1))}function ph(e,t,s,n,r){const i=fh(s,n),o=xh(e,t,s,n,r);return i||o}function fh(e,t){const s=new Wt;t.queryEnvelope(s);const n=Pc(e.ymax,s.ymax),r=Pc(e.ymin,s.ymin),i=n||r;return!!i&&(yh(e,t),i)}function xh(e,t,s,n,r){const i=[],o=[],a=.5*s.width();for(let g=0;g<n.getPathCount();g++){const m=n.getXY(n.getPathStart(g)),h=n.getXY(n.getPathEnd(g)-1),l=e[g]<0;if(Math.abs(m.x-h.x)>a){const e=Ph(l,t,s,g,n,r);i.push(e),o.push(g)}else if(!l){if(n.calculateRingArea2D(g)<0){const e=Eh(t,s,g,n,r);i.push(e),o.push(g)}}}if(0===i.length)return!1;const m=new we({vd:n.getDescription()});let h=0,l=o[h];for(let g=0;g<n.getPathCount();g++)g===l?(m.add(i[h],!1),h++,h<o.length&&(l=o[h])):m.addPath(n,g,!0);return n.setEmpty(),n.add(m,!1),!0}function yh(e,t){const s=new we,n=new Wt;for(let r=0;r<t.getPathCount();r++){t.queryPathEnvelope(r,n);let i=Pc(e.ymax,n.ymax),o=Pc(e.ymin,n.ymin);if(!(i||o)){s.addPath(t,r,!0);continue}s.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(r),m=t.getPathEnd(r),h=m-a;let l=-1;for(l=a;l<m;l++){const s=t.getXY(l);if(i=Pc(e.ymax,s.y),o=Pc(e.ymin,s.y),!i&&!o)break}let g=l,u=!1,c=Number.NaN;do{const n=t.getXY(g);i=Pc(e.ymax,n.y),o=Pc(e.ymin,n.y);const m=a+(g+1-a)%h;if(i||o){let i=T.construct(c,n.y);s.insertPoint2D(r,-1,i);const o=t.getXY(m),a=Pc(e.ymax,o.y),h=Pc(e.ymin,o.y);a||h||(i=T.construct(o.x,n.y),u?s.setXYNoCurves(s.getPointCount()-1,i):s.insertPoint2D(r,-1,i)),u=!0}else s.insertPoint2D(r,-1,n),c=n.x,u=!1;g=m}while(g!==l)}t.setEmpty(),t.add(s,!1)}function Ph(e,t,s,n,r,i){const o=new we,a=new we,m=new jt,h=r.getXY(r.getPathStart(n)),l=r.getXY(r.getPathEnd(n)-1),g=s.width(),u=.5*g,c=new Wt;r.queryEnvelope(c);const _=Math.ceil(c.width()/g)+1;let d,p;h.x>l.x?(d=-g,p=e?s.ymin:s.ymax):(d=g,p=e?s.ymax:s.ymin),m.setShiftCoords(d,0),o.addPath(r,n,!0),a.add(o,!1);const f=new pt;for(let T=0;T<_;T++)a.applyTransformation(m),a.getPointByVal(0,f),o.lineToPoint(f),o.addSegmentsFromPath(a,0,0,a.getSegmentCount()-1,!1);const x=o.getXY(0),y=o.getXY(o.getPointCount()-1);x.y=p,y.y=p,o.lineTo(y);const P=new T;for(P.setCoordsPoint2D(y),P.x-=.5*d;Math.abs(P.x-x.x)>u;)o.lineTo(P),P.x-=.5*d;o.lineTo(x);const E=s.getCenter().x,S=new Wt;o.queryEnvelope(S);let C=0;const I=S.getCenter().x;I-E>u?C=-Math.ceil((I-E-u)/g):E-I>u&&(C=Math.ceil((E-I-u)/g)),0!==C&&(m.setShiftCoords(C*g,0),o.applyTransformation(m));const b=new Te,w=b.addGeometry(o);Hl(b,w,t,0,2,!0,s.xmin),Hl(b,w,t,0,2,!0,s.xmax);const v=b.getGeometry(w),N=zt(v,s);N.inflateCoords(0,1);const G=_t(null,N,!0);return Zt(v,s,G.total(),Number.NaN,i)}function Eh(e,t,s,n,r){const i=t.width(),o=.5*i,a=t.getCenter().x,m=new Wt;n.queryPathEnvelope(s,m);let h,l=0,g=m.getCenter().x;if(g-a>o?l=-Math.ceil((g-a-o)/i):a-g>o&&(l=Math.ceil((a-g-o)/i)),0!==l){const e=new jt;e.setShiftCoords(l*i,0),n.getImpl().applyTransformationToPath(e,s),n.queryPathEnvelope(s,m),g=m.getCenter().x}const u=new Wt;t.containsExclusiveEnvelope(m)?(h=!1,u.setCoords({env2D:t})):(h=!0,u.setCoords({env2D:t}),u.xmin-=i,u.xmax+=i);let c=n.createInstance();c.addPathPoint2D(null,0,!0);const _=new T;if(_.setCoords(u.xmin,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(u.xmin,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymin),c.insertPoint2D(0,-1,_),h){c.addPath(n,s,!0);const o=new jt;g<a?o.setShiftCoords(i,0):o.setShiftCoords(-i,0),n.getImpl().applyTransformationToPath(o,s),c.addPath(n,s,!0);const m=new Te,h=m.addGeometry(c);Hl(m,h,e,0,2,!0,t.xmin),Hl(m,h,e,0,2,!0,t.xmax),c=m.getGeometry(h);const l=zt(c,t);l.inflateCoords(0,1);const u=_t(null,l,!0).total();c=Zt(c,t,u,Number.NaN,r)}else c.addPath(n,s,!0);return c}function Sh(e,t,s,n){const r=new Wt;s.queryEnvelope(r);const i=mt(null,s,!0).total();if(t.xmin-r.xmin<=i&&r.xmax-t.xmax<=i)return s;const o=s.createInstance();let a=s.createInstance();const m=new Wt,h=s.getPathCount();for(let l=0;l<h;l++)s.queryPathEnvelope(l,m),t.xmin-m.xmin<=i&&m.xmax-t.xmax<=i?o.addPath(s,l,!0):(a.setEmpty(),a.addPath(s,l,!0),a=ch(e,t,a,!0,n),o.add(a,!0));return o}function Ch(e,t,s){const n=e.getPannableExtent(),r=T.construct(t,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new T;a.setNAN();let m=Number.NaN;for(let h=0;h<s.getPathCount();h++)for(let e=s.getPathStart(h);e<s.getPathEnd(h);e++){const t=s.getXY(e),r=Pc(t.y,n.ymax)||Pc(n.ymin,t.y);e===s.getPathStart(h)?(a.setNAN(),m=0):a.isNAN()||r||(m=Ih(t.x,a.x,o,i,m)),t.x+=m,s.setXYNoCurves(e,t),r||a.setCoordsPoint2D(t)}s.getImpl().notifyModifiedFlags(2001)}function Ih(e,t,s,n,r){return r+e-t>s?r-=n:t-(r+e)>s&&(r+=n),r}function bh(e,t,s,n,r,i){const o=t.getAttributeStreamRef(0),a=t.getPointCount();let m=!1;const h=new T;for(let P=0;P<a;++P){if(o.queryPoint2D(2*P,h),1&i&&h.y>=s){m=!0;break}if(2&i&&h.y<=-s){m=!0;break}}if(!m)return!1;let l=!1;e&&(l=t.getImpl().isClosedPathInXYPlane(0));const g=new Te,u=g.addGeometry(t),c=g.getFirstPath(u);let _=-1,d=!0;const p=new T,f=new pt;let x=Ae;const y=Gh*r/360;for(let P=g.getFirstVertex(c);P!==Ae;P=g.getNextVertex(P)){g.queryXY(P,h);let e=1&i&&h.y>=s?1:0;if(e|=2&i&&h.y<=-s?2:0,_>0&&_!==e){if(p.x!==h.x){const e=g.getPrevVertex(P);g.queryPoint(e,f);const t=g.insertVertex(c,P,f);p.x=h.x,g.setXY(t,p)}if(l){let e=x!==Ae?g.getNextVertex(x):g.getFirstVertex(c);const t=g.getPrevVertex(P);for(;e!==t;)e=g.removeVertex(e,!1);if(x!==Ae){const e=g.getXY(x),s=g.getXY(t);if(Math.abs(e.x-s.x)>y){g.queryPoint(x,f);const n=g.insertVertex(c,t,f);e.x=R(e.x,s.x,.5),g.setXY(n,e)}}}x=Ae}if(e&&(h.y=Y(n,h.y),g.setXY(P,h),!d&&_!==e))if(h.x!==p.x){g.queryPoint(P,f);const e=g.insertVertex(c,P,f);g.setXYCoords(e,p.x,h.y),x=e}else x=P;_=e,p.assign(h),d=!1}if(l){if(x!==Ae){let e=g.getNextVertex(x);for(;e!==Ae;)e=g.removeVertex(e,!1)}const e=g.getFirstVertex(c);let t=g.getLastVertex(c);const s=g.getXY(e),n=g.getXY(t);if(!s.equals(n)&&(g.queryPoint(e,f),t=g.insertVertex(c,Ae,f),Math.abs(s.x-n.x)>y)){const e=g.insertVertex(c,t,f);s.x=R(s.x,n.x,.5),g.setXY(e,s)}}return t.assignCopy(g.getGeometry(u)),!0}function wh(e,t){let s=new we({vd:e});s.addEnvelope(t,!1);const n=t.width()/180;return s=(new Jt).execute(s,n,0,0,null),s}function vh(e,t){const s=e.getPannableExtent();return Number.isNaN(t)||s.centerAtCoords(t,0),s}function Nh(e,t,s){const n=ku();t.querySpheroidData(n);const r=t.getGCS()!==t?t.getSRToGCSTransform():null,i=B(T,100),o=new qt(0,0,0),a=e.getPointCount(),m=t.getGCS().getUnit().getUnitToBaseFactor();for(let u=0,c=a;u<c;){const t=Math.min(100,c-u);e.queryCoordinates(i,t,u,u+t),r&&(new qm).transform(r,i,t,i,!1);for(let e=0;e<t;e++){if(i[e].isNAN())continue;i[e].scale(m);const t=ds(n.majorSemiAxis,n.e2,i[e]);o.addThis(t)}u+=t}const h=Ps(n.majorSemiAxis,n.e2,o);h.scale(1/m);const l=e;if(!new _h(t.getGCS(),h).project(l))return 0;s.length=e.getPathCount();const g=l.calculateArea2D()<0;for(let u=0,c=e.getPathCount();u<c;u++){const e=l.calculateRingArea2D(u),t=g?e<0:e>0;s[u]=t}return g?-1:1}function Th(e,t,s,n,i){if(!t.isPannable()||e.isEmpty())return e;const a=e.getGeometryType();a===r.enumGeometryCollection&&_("not yet impl for geometry collection");const m=t.getPannableExtent();Number.isNaN(s)&&(s=m.getCenterX());const h=m.width(),l=.5*h,g=i>0,u=e.queryInterval(0,0);if(!g&&u.width()<l||!f(e.getGeometryType())){const t=u.getCenter();if(Math.abs(t-s)<=l)return e;{const n=new jt,r=k((s-t)/h)*h;n.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(n),i}}if(a===r.enumPolygon){let r=new Ce({vd:e.getDescription()});r.addAndExplicitlyOpenAllPaths(e,!1),g&&(r=Om(r,t,2,i,Number.NaN,null,!0));const o=[];if(!n){{let s=e;g&&(s=new we,s.add(r,!1));const n=Nh(e,t,o);if(n)n<0&&r.reverseAllPaths();else{const e=s.getPathCount();for(let t=0;t<e;t++)o.push(s.calculateRingArea2D(t)>0)}}n=o}return new Dh(null,n,r,null,t,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(a===r.enumPolyline){let n=new Ce({vd:e.getDescription()});n.addAndExplicitlyOpenAllPaths(e,!1),g&&(n=Om(n,t,2,i,Number.NaN,null,!0));return new Dh(null,null,n,null,t,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(a===r.enumMultiPoint){const t=e,n=t.getAttributeStreamRef(0);let r,i=null,o=s,a=0;const m=.1*h;for(let s=0,g=t.getPointCount();s<g;s++){const t=n.read(2*s);let g=t-o;if(Math.abs(g)>l&&(g=k(g/h)*h,a-=g,Math.abs(a)<m&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const n=t+a;i.write(2*s,n)}o=t}return i?(r.notifyModified(),r):e}o("")}const Gh=210;class Dh{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,s,n,r,i,o,a,m){this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=a,this.m_poleFlags=o,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=vh(this.m_pannableSR,i),this.m_centralLongitude=Number.isNaN(i)?this.m_pannableExtent.getCenterX():i,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=Gh*this.m_degree,h(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,r,i,a){let m=s;const l=new Ce({vd:this.m_inputPoly.getDescription()});l.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bh(!0,l,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(m=!1));let g=-1;m&&(g=this.m_originalGeometry.getPathStart(e));const u=l.getAttributeStreamRef(0),c=l.getPointCount();let _=0,d=u.read(0),p=0;const f=3*this.m_pannableSR.getTolerance(0);let x=!1;const y=new T,P=new T;let E=!1;const S=l.hasNonLinearSegments(),C=new T;for(let h=1;h<c;++h){u.queryPoint2D(2*h,C);const e=C.x;let t=e+_;const s=t-d;if(C.x=t,Math.abs(s)>this.m_GCSLargeDelta){if(m){const e=g+h-1,t=g+(h+1<c?h:0),r=i.read(2*e),o=(i.read(2*t)-r)*n;Math.abs(s-o)>1*this.m_degree&&(m=!1)}if(!m){_-=Y(this.m_width360,t-d),t=e+_,++p,E=0!==_,C.x=t}}else x||Bt(y,P,C,f)&&(x=!0);E&&(S&&o("error in geonormalize_ring_ for curves"),u.write(2*h,t)),d=t,y.setCoordsPoint2D(P),P.setCoordsPoint2D(C)}p&&l.notifyModified();const I=l.getXY(0),b=l.getXY(c-1);if(T.distance(I,b)<f){const e=this.finalizeGeoNormalizeClosedRing(l,x,r);a.add(e,!1)}else{if(t<0)if(null!==this.m_originalGeometry){h(null!==this.m_originalGeometry);t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0}else t=1;const s=this.finalizeGeoNormalizeOpenedRing(t>0,l);a.add(s,!1)}}geoNormalizePolygonGeometry(e){h(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),h(this.m_pannableSR.isPannable());let t=null,s=Number.NaN;const n=!!this.m_originalSR&&this.m_originalSR.isPannable();n&&(t=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const r=new we({vd:this.m_inputPoly.getDescription()});for(let h=0,_=this.m_inputPoly.getPathCount();h<_;++h){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[h]?1:0:-1;this.geonormalizeRing(h,i,n,s,e,t,r)}const i=this.m_pannableSR.getTolerance(0),o=this.m_pannableExtent.width()/180;Ol(r,this.m_pannableExtent,.1*i,!1);const a=Wt.constructEmpty();if(a.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=Wt.constructEmpty();for(let s=0,n=r.getPathCount();s<n;s++)if(r.queryPathEnvelope(s,t),!(a.xmin<=t.xmin&&a.xmax>=t.xmax||t.xmin>=a.xmax||t.xmax<=a.xmin)){e=!1;break}if(e)break;a.move(.5*this.m_width360,0)}e||a.setCoords({env2D:this.m_pannableExtent})}let m=Zt(r,a,i,o,this.m_progressTracker),l=r!==m;const g=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,u=m.calculateArea2D();let c=0;if(u>0&&g<0)c=1;else if(u<=0&&g>0)if(0===u){if(this.m_originalSR){let e=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?e=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(e=this.m_originalSR.getPannableExtent().getArea()),g>.99*e&&(c=-1)}}else c=-1;if(0!==c){const e=wh(m.getDescription(),a);e.add(m,!1),l=!0,m=e}return l&&(m=(new Em).execute(m,this.m_pannableSR,!1,this.m_progressTracker)),m}geoNormalizePolylineGeometry(e){h(this.m_pannableSR.isPannable());let t=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let n=1;s&&(h(this.m_originalGeometry),n=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const r=this.m_pannableExtent.width(),i=r*q()*4;let a=e,m=Number.NaN;const l=A.constructEmpty();this.m_bAdjustedAtPoles=0;let g=new Ce({vd:this.m_inputPoly.getDescription()});for(let _=0,d=this.m_inputPoly.getPathCount();_<d;++_){let e=s;const u=new Ce({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,_,!0);const c=this.m_inputPoly.isClosedPath(_);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bh(c,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,r,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(e=!1));let d=-1;const p=u.getPointCount();let f=!1;e&&(d=this.m_originalGeometry.getPathStart(_),f=this.m_originalGeometry.isClosedPath(_));const x=u.getAttributeStreamRef(0);let y=0,P=x.read(0),E=0;const S=new T,C=new T;let I=!1;const b=u.hasNonLinearSegments(),w=new T;for(let s=1;s<p;++s){x.queryPoint2D(2*s,w);const r=w.x;let i=r+y;const a=i-P;if(w.x=i,Math.abs(a)>this.m_GCSLargeDelta){if(e){const r=d+s-1;let i=d;(!f||s+1<p)&&(i+=s);const o=t.read(2*r),m=(t.read(2*i)-o)*n;Math.abs(a-m)>1*this.m_degree&&(e=!1)}if(!e){y-=Y(this.m_width360,i-P),i=r+y,++E,I=0!==y,w.x=i}}I&&(b&&o("error in geonormalize_ring_ for curves"),x.write(2*s,i)),P=i,S.setCoordsPoint2D(C),C.setCoordsPoint2D(w)}if(E&&u.notifyModified(),a){let e=!1;if(!u.isEmpty()){const t=Wt.constructEmpty();if(u.queryEnvelope(t),t.width()>=r||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(m)){const e=this.m_centralLongitude-.5*r;m=t.xmin,m+=Math.round((e-t.xmin)/r)*r,m>e&&(m-=r),h(m<=e),m<e&&(m+=r),h(m>=e)}let s=Math.round((m-t.xmin)/r)*r;if(t.xmin+s>m+i&&(s-=r),t.xmin+s<m-i&&(s+=r),l.mergeCoordinate(t.xmin+s),l.mergeCoordinate(t.xmax+s),e=l.width()>=r,!e){const e=new jt;e.setShiftCoords(s,0),u.applyTransformation(e)}}}g.add(u,!1),e&&(g=(()=>{const e=new Ce({vd:g.getDescription()});for(let t=0,s=g.getPathCount();t<s;++t){const s=new Ce({vd:g.getDescription()});s.addPath(g,t,!0);const n=vl(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(n,!1)}return e})(),a=!1)}else{const e=vl(u,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);g.add(e,!1)}}if(a)return g;const u=this.m_pannableSR.getTolerance(0),c=this.m_pannableExtent.width()/180;Ol(g,this.m_pannableExtent,.1*u,!1);return Zt(g,this.m_pannableExtent,u,c,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const s=t.getPointCount(),n=t.getXY(0),r=t.getXY(s-1);{const e=Math.abs(r.x-n.x),t=Math.round(e/this.m_width360)*this.m_width360;h(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const i=U(r.x-n.x),o=Wt.constructEmpty();t.queryLooseEnvelope(o);const a=this.m_pannableExtent.getCenterX();let m=0,l=a-this.m_width360,g=a+this.m_width360;if(i>=0){let e=Math.ceil((l-o.xmin)/this.m_width360);for(e*=this.m_width360;l>o.xmin+e;)e+=this.m_width360;for(;l<o.xmax+e;)e-=this.m_width360;for(m=e,o.width()>720&&(g=l+360*Math.ceil(o.width()/360));g<o.xmax;)g+=this.m_width360}else{let e=Math.ceil((g-o.xmax)/this.m_width360);for(e*=this.m_width360;g<o.xmax+e;)e-=this.m_width360;for(;g>o.xmin+e;)e+=this.m_width360;for(m=e,o.width()>720&&(l=g-360*Math.ceil(o.width()/360));l>o.xmin;)l-=this.m_width360}const u=Math.round(Math.abs(r.x-n.x)/this.m_width360)*this.m_width360,c=i*u,_=o.clone();_.move(m,0);const d=new T(0,0),p=new jt;p.setShiftCoords(m,0),t.applyTransformation(p);const f=new Ce({vd:t.getDescription()});f.add(t,!1),d.assign(t.getXY(s-1));let x=0,y=f.getXY(0).x;for(;i>0?_.xmax<g:_.xmin>l;)_.move(c,0),p.xd=c,t.applyTransformation(p),y+=c,this.m_pannableExtent.xmin<=y&&this.m_pannableExtent.xmax>=y&&(x=f.getPointCount()-1),t.setXY(0,d),d.assign(t.getXY(s-1)),f.addSegmentsFromPath(t,0,0,s-1,!1);const P=new we({vd:f.getDescription()});P.add(f,!1);const E=f.getXY(0),S=f.getXY(f.getPointCount()-1),C=i<0?e:!e,I=P.getPointCount()-1;if(C){const e=new T(S.x,this.m_pannableExtent.ymax);P.lineTo(e);const t=new T(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);P.lineTo(t);const s=new T(E.x,this.m_pannableExtent.ymax);P.lineTo(s)}else{const e=new T(S.x,this.m_pannableExtent.ymin);P.lineTo(e);const t=new T(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);P.lineTo(t);const s=new T(E.x,this.m_pannableExtent.ymin);P.lineTo(s)}if(P.interpolateAttributesPath(0,I,0),P.getImpl().changeRingStartPoint(x),u>this.m_width360){const e=new we({copy:P});p.setShiftCoords(this.m_width360,0),e.applyTransformation(p),P.add(e,!1)}return P}finalizeGeoNormalizeClosedRing(e,t,s){const n=new we({vd:e.getDescription()});n.add(e,!1);const i=()=>{const e=n.getPointCount()-2;return n.getSegmentType(e)!==r.enumLine};if(n.hasNonLinearSegments()&&i()){const e=new Ve,t=n.getPointCount()-2;n.getSegmentBuffer(t,e,!1),n.removePointFromPath(0,t+1),n.closeLastPathWithSegment(e.get())}else n.removePointFromPath(0,n.getPointCount()-1);const o=Wt.constructEmpty();n.queryLooseEnvelope(o);let a=Math.ceil((this.m_pannableExtent.xmin-o.xmin)/this.m_width360);for(a*=this.m_width360;this.m_pannableExtent.xmin>o.xmin+a;)a+=this.m_width360;for(;this.m_pannableExtent.xmin<o.xmax+a;)a-=this.m_width360;if(a+=this.m_width360,0!==a){o.move(a,0);const e=new jt;e.setShiftCoords(a,0),n.applyTransformation(e)}if(this.m_pannableExtent.xmin<=o.xmin&&this.m_pannableExtent.xmax>=o.xmax){if(t){const e=n.calculateArea2D(),t=(new Em).execute(n,this.m_pannableSR,!0,this.m_progressTracker);if(t!==n){const s=t.calculateArea2D();U(e)!==U(s)&&t.reverseAllPaths(),n.assignMove(t)}}let e;if(e=new we(s?{copy:n}:{move:n}),s)for(;o.xmin<this.m_pannableExtent.xmax;){o.move(this.m_width360,0);const t=new jt;t.setShiftCoords(this.m_width360,0),n.applyTransformation(t),e.add(n,!1)}return e}let m=new we({vd:e.getDescription()});m.add(n,!1);const h=t||o.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;o.xmin<this.m_pannableExtent.xmax;){o.move(this.m_width360,0);const e=new jt;e.setShiftCoords(this.m_width360,0),n.applyTransformation(e),m.add(n,!1)}if(h){const e=m.calculateArea2D();m.setFillRule(1),m=(new Em).execute(m,this.m_pannableSR,!0,this.m_progressTracker);const t=m.calculateArea2D();U(e)!==U(t)&&m.reverseAllPaths()}return m}geonormalize_ring_(e,t,s,n,r,i,o){h(0)}}function Vh(e){h(0);const t=ou(e),s=new Hh;return s.setVertProj_(t),s}function Fh(e,t=!0){return h(0),{}}function kh(e){return Su()}class Hh{m_hashCode=0;m_peVertSysVal=null;m_verticalUnit=new bu;m_verticalShift=0;m_userVerticalWKID=0;m_bIsDepth=!1;getType(){return h(0),0}getID(){return h(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return h(0),""}getTextExtended(e){return h(0),""}getText2(e){return h(0),""}getUnit(){return h(0),{}}equals(e){return h(0),!1}equalForProjection(e){return h(0),!1}getPeVertcsCopy(){return h(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return h(0),0}isDepth(){return h(0),!1}getVerticalShift(){return h(0),0}isCustomWkid(){return!!this.m_peVertSysVal&&this.m_peVertSysVal.isCustomWkid()}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Ah(e,t,s,n,r){if(e.equals(t))return!1;if(n){let s=1,i=0,o=1,a=1,m=0,h=1;Number.isNaN(e.m_heightMetersPerUnit)||(s=e.m_heightMetersPerUnit,i=e.m_heightZ0,o=e.m_heightSign,a=t.m_heightMetersPerUnit,m=t.m_heightZ0,h=t.m_heightSign);const l=o*h*s/a;for(let e=0;e<r;e++)n[e]=(n[e]-i)*l+m}let i=1,o=0;if(Number.isNaN(e.m_XYToRadians)||(i=e.m_XYToRadians/t.m_XYToRadians,o=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,0!==o&&(o=at(o),o/=t.m_XYToRadians)),Array.isArray(s)){const e=s;for(let t=0;t<r;t++)e[t][0]=e[t][0]*i+o,e[t][1]=e[t][1]*i}else{const e=s;for(let t=0;t<r;t++){const s=t<<1;e[s]=e[s]*i+o,e[s+1]=e[s+1]*i}}return!0}function Mh(){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 F(this.m_heightSign,e.m_heightSign)&&F(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&F(this.m_heightZ0,e.m_heightZ0)&&F(this.m_XYToRadians,e.m_XYToRadians)&&F(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,t&&h(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){const s=e?e.getPECoordSys():null,n=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Uh{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 dt;constructor(e){this.m_inputUnitParams=Mh(),this.m_outputUnitParams=Mh(),h(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=Ic.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const t=this.m_geogTran.getGeogcs1();Ic.getCode(t);const s=this.m_geogTran.getGeogcs2();Ic.getCode(s),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():(h(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||o("vcs not impl");const t=this.m_geogTran.getParameters();null!==t[bc.PE_PARM_ND]&&(e=0===t[bc.PE_PARM_ND].getValue())}t=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=t}return 0!==t}isUsable(){let e=this.m_isUsable;return-1===e&&(this.m_geogTran?this.m_isUsable=e=this.m_geogTran?1:0:this.m_isUsable=e=this.m_vertTran?1:0),1===e}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return 0===e&&(e=this.m_latestID>0?w(this.m_latestID):$(this.getText()),0===e&&(e=345),this.m_hashCode=e),e}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():(_("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,s,n,r,i;if(this.m_geogTran){const o=this.m_geogTran.getGeogcs1(),a=ru(o),m=this.m_geogTran.getGeogcs2(),h=ru(m);let l=-1,g=-1;l=a.getVcsCode(),g=h.getVcsCode(),s=Yu(o,null,null,1),n=Yu(m,null,null,1),l>0&&g>0?(r=Vh(l),i=Vh(g),e=zu(),t=zu()):(e=s,t=n)}else h(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=s,this.m_outputSRHorz=n,this.m_inputVCS=r,this.m_outputVCS=i)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=Number.NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_outputUnitParams.m_XYToRadians=Number.NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_vertTran)h(0);else if(this.m_geogTran){const e=this.m_geogTran;let t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function qh(e,t,s,n,r,i,o){let a=null;if(t){a=t.getPEVerticalCoordSys()}let m=null;if(e){m=e.getPECoordSys()}let h=null;if(n){h=n.getPEVerticalCoordSys()}let l=null;if(s){l=s.getPECoordSys()}if(!(m||a||l||h))return!1;const g=Mh();g.initFromGcsAndVcsPe(m,a);const u=Mh();return u.initFromGcsAndVcsPe(l,h),Ah(g,u,r,i,o)}function Bh(e,t,s,n,r,i,o,a){const m=t,h=e,l=Mh();l.initFromGcsAndVcsPe(h,m),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Ah(l,a,r,i,o)}function Oh(e,t,s,n,r,i,o,a){const m=Mh();m.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),m.processUnitParams(e);let h=null,l=null;if(n){l=n.getPECoordSys()}const g=Mh();g.initFromGcsAndVcsPe(l,h),g.processUnitParams(m),m.processUnitParams(g),a>0&&Ah(m,g,i,o,a)}function Rh(e,t,s,n,r,i,o,a,m){const h=Mh(),l=Mh();h.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),l.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),h.processUnitParams(e),l.processUnitParams(h),h.processUnitParams(l),a>0&&Ah(h,l,i,o,a),m.assign(l)}function Yh(e,t,s,n,r,i,o){const a=t.getVerttran(),m=t.getGeogtran();if(o.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),i>0){t.prepareOrThrow();const e=s?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;a?dg():pg(m,i,n,r,e)}}function Xh(e,t,s,n,r){const i=e.getVerttran(),o=e.getGeogtran();if(r>0){e.prepareOrThrow();const a=t?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;i?dg():pg(o,r,s,n,a)}}class Lh{supportsCurves(){return!0}accelerateGeometry(e,t,s){return zh(e,t,s)}canAccelerateGeometry(e){return Wh(e)}}function zh(e,t,s){if(!Wh(e))return!1;lt(t,e,!1);let n=0;const r=e.getGeometryType();return a(r)&&Ie(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),a(r)&&be(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function Wh(e){return Ie(e)||be(e)}class jh extends Lh{getOperatorType(){return 8}execute(e,t,s,n){return Hr(e,t,s,1,n)}}function Zh(e,t,n,o){if(e.isEmpty()||t.isEmpty())return e;const a=e.getDimension(),m=t.getDimension();if(a>m)return e;const h=e.getGeometryType(),l=t.getGeometryType(),g=new Wt,u=new Wt,c=new Wt;e.queryEnvelope(g),t.queryEnvelope(u),c.setCoords({env2D:g}),c.mergeEnvelope2D(u);const _=_t(n,c,!0),d=xt(_),p=new Wt;if(p.setCoords({env2D:g}),p.inflateCoords(d,d),!p.isIntersecting(u))return e;if(1===a&&2===m){const s=ol(e,t,l,n,o);if(s)return s}if(h===r.enumPoint){let n;switch(i(l)?(n=new Ce({vd:t.getDescription()}),n.addSegment(t,!0)):n=t,l){case r.enumPolygon:return Jh(e,n,_);case r.enumPolyline:return $h(e,n,_);case r.enumMultiPoint:return el(e,n,_);case r.enumEnvelope:return tl(e,n,_);case r.enumPoint:return sl(e,n,_);default:s("invalid shape type")}}else if(h===r.enumMultiPoint)switch(l){case r.enumPolygon:return nl(e,t,_);case r.enumEnvelope:return rl(e,t,_);case r.enumPoint:return il(e,t,_)}const f=new Wt(g);f.inflate(100*_.total());return Ra(e,Zt(t,f,0,0,o),n,o)}class Kh{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new Qh(e,t,s,n)}execute(e,t,s,n){return this.executeMany(new es([e]),new es([t]),s,n).next()}}class Qh extends $t{m_inputGeoms;m_progressTracker;m_spatialReference;m_geomSubtractor;m_index;constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=s;const r=t.next();this.m_geomSubtractor=r||new we}next(){const e=this.m_inputGeoms.next();return e?(n(e),m(e),this.m_index=this.m_inputGeoms.getGeometryID(),Zh(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Jh(e,t,s,n){return 0===Xo(t,e,s.total())?e:e.createInstance()}function $h(e,t,s,n){const r=e.getXY(),i=t.querySegmentIterator(),o=xt(s),a=o*o;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment(),n=new Wt;if(t.queryEnvelope(n),n.inflateCoords(o,o),!n.contains(r))continue;if(t.isIntersectingPoint(r,s.total()))return e.createInstance();let m=t.getStartXY();if(T.sqrDistance(r,m)<=a)return e.createInstance();if(m=t.getEndXY(),T.sqrDistance(r,m)<=a)return e.createInstance()}return e}function el(e,t,s,n){const r=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),o=e.getXY(),a=xt(s),m=a*a,h=new T;for(let l=0;l<i;l++){r.queryPoint2D(2*l,h);if(T.sqrDistance(h,o)<=m)return e.createInstance()}return e}function tl(e,t,s,n){const r=new Wt;t.queryEnvelope(r),r.inflate(s.total());const i=e.getXY();return r.contains(i)?e.createInstance():e}function sl(e,t,s,n){const r=xt(s),i=r*r,o=e.getXY(),a=t.getXY();return T.sqrDistance(o,a)<=i?e.createInstance():e}function nl(e,t,s,n){const r=new Wt;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=N(i,!1),m=new T;for(let l=0;l<i;l++){if(e.queryXY(l,m),!r.contains(m))continue;0!==Lo(t,m,s.total())&&(o=!0,a[l]=!0)}if(!o)return e;const h=e.createInstance();for(let l=0;l<i;l++)a[l]||h.addPoints(e,l,l+1);return h}function rl(e,t,s,n){const r=new Wt;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=N(i,!1),m=new T;for(let l=0;l<i;l++)e.queryXY(l,m),r.contains(m)&&(o=!0,a[l]=!0);if(!o)return e;const h=e.createInstance();for(let l=0;l<i;l++)a[l]||h.addPoints(e,l,l+1);return h}function il(e,t,s,n){const r=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),o=t.getXY();let a=!1;const m=N(i,!1),h=xt(s),l=h*h,g=new T;for(let c=0;c<i;c++){r.queryPoint2D(2*c,g);T.sqrDistance(g,o)<=l&&(a=!0,m[c]=!0)}if(!a)return e;const u=e.createInstance();for(let c=0;c<i;c++)m[c]||u.addPoints(e,c,c+1);return u}function ol(e,t,s,n,i){const o=new dt;e.queryEnvelope(o);const a=new Wt;t.queryEnvelope(a),o.merge(a);const m=.1*o.width(),h=.1*o.height();o.inflateCoords(m,h);const l=new we;l.addEnvelope(o,!1);const g=l.getImpl();if(s===r.enumPolygon){const e=t.getImpl();g.add(e,!0)}else g.addEnvelope(t,!0);return new Im(l,n,-1,i).tryFastImplementation(e)}class al{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n=0){return new gl(e,t,s,n)}execute(e,t,s,n){const r=new es([e,t]),i=new gl(r,s,n,0).next();return i||o("null output"),i}}function ml(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new T}}function hl(e,t){return T.compareZorder(e.location,t.location)?-1:e.location.equals(t.location)?0:1}class ll{binVertexCount;geometries;constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>hl(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class gl extends $t{m_inputGeoms;m_progressTracker;m_spatialReference;m_bUnionAllDimensions;m_bPreserveAllPathEnds;m_index=-1;m_currentDim=-1;m_bDone=!1;m_unionBins=[];m_readyGeoms=G(4);m_dimGeomCounts=N(4,0);m_addedGeoms=0;m_options;m_maxDimension=-1;m_bHadGeometry=N(4,!1);m_bIs3D;m_complexUnionGeoms=G(4);m_totalNonEmptyGeomCounters=N(4,0);constructor(e,t,s,n,r=!1){super(),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=n,this.m_bIs3D=r}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?h(0):this.m_complexUnionGeoms[e]=(new Kh).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++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===r.enumPoint){const e=new ve({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(e){return this.m_readyGeoms[e]}finishDim(e,t,s){let n=t;if(!s)return 16&this.m_options?(n=ja([n],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),n):n;if(1&this.m_options)return n;if(1===e){if(!(8&this.m_options)&&(!!(16&this.m_options)||this.m_totalNonEmptyGeomCounters[e]>1)){n=ja([n],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=n.getImpl().getIsSimple(0,e);h(this.m_bIs3D||ut(t))}else 1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?h(0):n=(new Em).execute(n,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?h(0):n=(new Em).execute(n,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&n.getGeometryType()===r.enumPoint){const e=new ve({vd:n.getDescription()});n.isEmpty()||e.add(n),n=e}return n}static getLevel(e){const t=4,s=u(e);let n=s>0?(Math.log(s)-Math.log(32))/Math.log(t):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(),null===e?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,null!==e){const t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?ja(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Za(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&(h(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,n=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,n)}}return this.m_bDone}addGeom(e,t,s){const n=ml();n.geom=s;const r=u(s);n.vertexCount=r;const i=Wt.constructEmpty();s.queryEnvelope(i),n.location=r>0?i.getCenter():new T(0,0);const o=gl.getLevel(s);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let a=null;const m=this.m_unionBins[e].get(o);m&&(a=m),null===a&&(a=new ll,this.m_unionBins[e].set(o,a)),n.bUnioned=t,a.addPair(n),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(1&this.m_options&&!this.m_bDone)return null;let t=null;const s=[];for(const n of this.m_unionBins[e].keys())s.push(n);D(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const r=this.m_unionBins[e].get(s[n]);{const i=5e3,o=4,a=r.getBinVertexCount()>i&&r.geomCount()>=o;if(this.m_bDone||a){for(let r=0;r<n;r++){if(-1===s[r])continue;const n=this.m_unionBins[e].get(s[r]);n.sort(),this.m_dimGeomCounts[e]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const e of n.geomPairs())t||(t=new Array),t.push(e.geom);n.clear(),this.m_unionBins[e].delete(s[r]),s[r]=-1}r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(const e of r.geomPairs())t||(t=new Array),t.push(e.geom);if(r.clear(),this.m_unionBins[e].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&c(),e.hasAttribute(1)||s("Geometry must have Zs")),n(e)}}class ul extends Lh{getOperatorType(){return 3}execute(e,t,s,n=null){return Hr(e,t,s,4,n)}}function cl(e,t,s){const n=t.getGCSSplitLines();if(null===n)return e;const r=t.getGCS(),i=r.getPannableExtent().width(),o=Wt.constructEmpty();e.queryLooseEnvelope(o);const a=A.constructEmpty();o.queryIntervalX(a);const m=n.querySegmentIterator();let h=null;const l=new jt;for(;m.nextPath();)for(;m.hasNextSegment();){const e=m.nextSegment(),t=e.queryInterval(0,0),s=A.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>a.vmin;)s.move(-i),n--;for(;s.vmin<=a.vmax;){if(s.isIntersecting(a)){null===h&&(h=new Ce);const t=new Fe({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(l.setShiftCoords(n*i,0),t.applyTransformation(l)),h.addSegment(t,!0)}s.move(i),++n}}if(null!==h){const t=mt(r,h,!0);return Un(e,h,xt(t),s)}return e}function _l(e,t,s){let n=e.getName();return sc(n)||(s||t>0?(n=e.toString(bc.PE_STR_NAME_CANON|bc.PE_STR_AUTH_NONE),n=yl(n)):n=e.toString(bc.PE_STR_AUTH_TOP)),n}function dl(e,t,s,n){return h(0),""}function pl(e,t=-1){if((t>1||t<-1)&&s("verbosity"),-1===t)return e.toString();{const s=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return e.toString(s)}}function fl(e,t){(t>1||t<-1)&&s("verbosity");let n=bc.PE_STR_FMT_WKT2;return-1!==t&&(n|=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),e.toString(n)}function xl(e){return h(0),""}function yl(e){return e.toLocaleUpperCase("en-US")}function Pl(e,t,n){const i=e.getPCSHorizon();if(i.getGeometryType()===r.enumPolygon){const s=e.getDefaultPrecisionSR().getTolerance(0),r=i;for(let e=0;e<n;e++)1!==Lo(r,t[e],s)&&t[e].setNAN();return}if(i.getGeometryType()===r.enumEnvelope){const e=i;for(let s=0;s<n;s++)e.contains(t[s])||t[s].setNAN();return}s("")}function El(e,t,s,n){for(let r=0;r<t;r++){if(e[r].y<s.ymin||e[r].y>s.ymax){e[r].setNAN();continue}const t=e[r].x;e[r].x=Gl(t,s,n)}}function Sl(e,t,s,n){if(e.isEmpty()||1===s)return e;const i=e.getGeometryType();if(i===r.enumPoint){const n=e,r=n.getXY();return 0===wl([r],1,t,s)||r.isNAN()?n.setEmpty():n.setXY(r),e}if(i===r.enumMultiPoint){const n=e,r=e.createInstance(),i=n.getPointCount();r.reserve(i);const o=n.getAttributeStreamRef(0),a=n.getDescription().getAttributeCount()>1,m=new pt,h=Float64Array.from(o.getArray());if(wl(h,i,t,s)>0)for(let e=0,t=2*i;e<t;e+=2)Number.isNaN(h[e])||(a?(n.getPointByVal(e>>1,m),m.setXYCoords(h[e],h[e+1]),r.add(m)):r.addXY(h[e],h[e+1]));return r}let m=e;const h=t.getOneDegreeGCSUnit(),l=90*h,g=180*h,u=360*h,c=t.getCentralMeridian(),_=.5*h,d=Wt.constructEmpty();m.queryEnvelope(d);const p=t.getGCSHorizon(),f=t.getGCSHorisonIsInclusive(),x=p.getGeometryType()===r.enumEnvelope,y=Wt.constructEmpty();p.queryEnvelope(y);const P=t.getGCS();if(2!==s&&4!==s||(y.xmin=c-g,y.xmax=y.xmin+u),4===s){if(!(d.width()>u-h)){const e=Wt.constructEmpty();e.setCoords({xmin:d.xmin-h,ymin:y.ymin,xmax:d.xmax+h,ymax:y.ymax}),m=(new Kt).execute(m,e,P,n);let t=Math.floor((c-d.getCenterX())/u);for(d.move(t*u,0);d.xmin>y.xmax;)t-=1,d.move(-u,0);for(;d.xmin<y.xmin;)t+=1,d.move(u,0);if(0!==t){const e=new jt;e.setShiftCoords(t*u,0),m.applyTransformation(e)}return m}s=2}if(2===s&&(y.xmin=c-g,y.xmax=y.xmin+u),d.ymin<-l||d.ymax>l){const e=Wt.constructEmpty();if(e.setCoords({xmin:d.xmin-h,ymin:-l,xmax:d.xmax+h,ymax:l}),m=(new Kt).execute(m,e,P,n),m.isEmpty())return m;m.queryEnvelope(d)}if(f&&(y.ymax<d.ymin||y.ymin>d.ymax))return m.createInstance();d.width()>u&&(m=ql(m,c-g,u,P,!0,0,!0,n),m.queryEnvelope(d));let E=Ul(d.xmin,d.xmax,y.xmin,y.xmax,u);if(0!==E&&d.move(E,0),d.xmax>y.xmax||d.xmin<y.xmin){if(d.xmax>y.xmax)for(;d.xmin>=y.xmax;)d.move(-u,0),E-=u;for(;d.xmin<y.xmax-u;)d.move(u,0),E+=u}const S=lt(P,p,!1);if(0!==E){const e=new jt;e.setShiftCoords(E,0),m.applyTransformation(e),E=0}if(f){if(x&&y.containsEnvelope(d))return m;const e=new Array(2);for(let t=0;t<2;t++){let s;if(x?s=a(i)?Zt(m,y,S,_,n):Zt(m,y,S,0,n):(s=(new wm).execute(m,p,P,n),s===p&&(s=s.clone())),y.xmin<=d.xmin&&y.xmax>=d.xmax)return s;if(y.xmin>=d.xmin&&y.xmax<=d.xmax)return s;if(e[t]=s,0===t){d.move(-u,0);const e=new jt;e.setShiftCoords(-u,0),m.applyTransformation(e)}}return a(i)?e[0].add(e[1],!1):o("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(y.ymax<d.ymin||y.ymin>d.ymax)return m;let e=0;for(;!m.isEmpty()&&d.xmax>y.xmin;){if(0!==e){const t=new jt;t.setShiftCoords(e,0),m.applyTransformation(t)}if(!(new ul).execute(m,p,P,n)){m=(new Kh).execute(m,p,P,n),p===m&&(m=m.clone())}if(0!==e){const t=new jt;t.setShiftCoords(-e,0),m.applyTransformation(t)}e-=u,d.move(-u,0)}return m}}function Cl(s,n,r,i,o,a){const m={stack:[],error:void 0,hasError:!1};try{if(2===a){return Gs(s,n,r,i,o)}if(Math.abs(r.x-i.x)>=Math.PI||!Fg(r.x,i.x,o))return Number.NaN;r.x>i.x&&(i=M(r,r=i));const t=e(m,new Cc,!1),h=e(m,new Cc,!1),l=e(m,new Cc,!1),g=r.clone();Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,h,t,null,a);const u=h.val;let c=0,_=1;for(;u*(_-c)>1e-12*s;){const e=.5*(c+_);if(Dc.geodeticCoordinate(s,n,r.x,r.y,u*e,t.val,h,l,a),g.x=h.val,g.y=l.val,g.x===o)return g.y;if(Fg(r.x,g.x,o))_=e;else{if(!Fg(i.x,g.x,o))return Number.NaN;c=e}}return g.y}catch(h){m.error=h,m.hasError=!0}finally{t(m)}}function Il(e,t){let s;if(Array.isArray(e)){const n=e;s=new Float64Array(2*t);for(let e=0,r=0;e<t;e++,r+=2)s[r]=n[e].x,s[r+1]=n[e].y}else s=e;return s}function bl(e,t,s,n){for(let r=0,i=0;r<n;r++,i+=2)t[s+r].x=e[i],t[s+r].y=e[i+1]}function wl(e,t,s,n){if(0===t||1===n)return t;const i=Il(e,t);if(2===n){const n=s.getPannableExtentInGCS();let r=t;for(let e=0,s=2*t;e<s;e+=2)(i[e+1]>n.ymax||i[e+1]<n.ymin)&&(i[e]=Number.NaN,r--);return r?(Bl(i,t,n.xmin,n.width(),!0),e!==i&&bl(i,e,0,t),r):(e!==i&&bl(i,e,0,t),0)}const o=s.getOneDegreeGCSUnit(),a=90*o,m=180*o,h=360*o;let l=t;for(let r=0,p=2*t;r<p;r+=2)(i[r+1]>a||i[r+1]<-a)&&(i[r]=Number.NaN,l--);if(!l)return e!==i&&bl(i,e,0,t),0;const g=Wt.constructEmpty();g.setFromPoints(i,t);const u=s.getGCSHorizon(),c=s.getGCSHorisonIsInclusive(),_=u.getGeometryType()===r.enumEnvelope,d=Wt.constructEmpty();if(u.queryEnvelope(d),c&&(d.ymax<g.ymin||d.ymin>g.ymax))return e!==i&&bl(i,e,0,t),0;if(c){if(Bl(i,t,d.getCenterX()-m,h,!0),l=t,_)for(let e=0,s=2*t;e<s;e+=2)d.containsCoords(i[e],i[e+1])||(i[e]=Number.NaN,l--);else{const e=lt(s.getGCS(),u,!1),n=new T;for(let s=0,r=2*t;s<r;s+=2){n.setCoords(i[s],i[s+1]);0!==Lo(u,n,e)||(i[s]=Number.NaN,l--)}}}else{Bl(i,t,-m,h,!0),l=t;const e=lt(s.getGCS(),u,!1),n=new T;for(let s=0,r=2*t;s<r;s+=2){n.setCoords(i[s],i[s+1]),n.isNAN()&&l--;const t=Ml(n.x,d.xmin,d.xmax,h);n.x+=t;0!==Lo(u,n,e)&&(i[s]=Number.NaN,l--)}}return e!==i&&bl(i,e,0,t),l}function vl(e,t,n,r,i,o){if(t.isPannable()||s("fold_into_360_degree_range"),e.isEmpty())return e;let a,m;if(2===t.getCoordinateSystemType()){const e=t.getPannableExtent();m=e.xmin,a=e.width()}else{const e=t.getOneDegreeGCSUnit();a=360*e,m=n-180*e}return ql(e,m,a,t,r,i,!0,o)}function Nl(e,t,s,n){let r,i;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();r=e.xmin,i=e.width()}else{const e=s.getOneDegreeGCSUnit();i=360*e,r=n-180*e}Bl(e,t,r,i)}function Tl(e,t){const s=t.width();let n=v(e-t.vmin,s);n<0&&(n+=s);return t.snapClip(n+t.vmin)}function Gl(e,t,s){return e>t.xmax&&e-t.xmax<s?t.xmax:e<t.xmin&&t.xmin-e<s?t.xmin:e}function Dl(e,t,s){if(e[0]<t.vmin||e[0]>t.vmax||s&&e[0]===t.vmax){const s=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/s)*s,e[0]=t.snapClip(e[0]),!0}return!1}function Vl(e,t,s,n,r,i,o,a,m){return new Dh(e,null,s,t,n,r,o,a,i).geoNormalizePolygonGeometry(m)}function Fl(e,t,s,n,r,i,o,a,m){return new Dh(e,null,s,t,n,r,o,a,i).geoNormalizePolylineGeometry(m)}function kl(e,t,s,n,r){const i=new Te,o=i.addGeometry(e);return Hl(i,o,t,lt(t,e,!1),s,n,r),i.getGeometry(o)}function Hl(s,n,r,i,o,a,m){const l={stack:[],error:void 0,hasError:!1};try{h(Uu()),r.isPannable()||d("insert_geodetic_points");const t=r.getPannableExtent(),g=r.getGCS(),u=ku();g.querySpheroidData(u);const c=g.getUnit().getUnitToBaseFactor(),_=u.majorSemiAxis,p=u.e2;let f=0;const x=new A;t.queryIntervalX(x);let y=null;const P=N(4,Number.NaN);2===r.getCoordinateSystemType()?(y=r.getPECoordSys(),a?(P[0]=Tl(m,x),P[1]=t.getCenterY(),wc.projToGeog(y,1,P),f=P[0]*c):(P[0]=t.getCenterX(),P[1]=m,wc.projToGeog(y,1,P),f=P[1]*c)):f=m*c,a||0===f||2===o||d("insert_geodetic_points: 1");const E=e(l,new Cc,!1),S=new T,C=new T,I=new T,b=new T,w=new T,v=new T;for(let e=s.getFirstPath(n);e!==Ae;e=s.getNextPath(e)){const t=s.getFirstVertex(e);s.queryXY(t,I);let n=!1;const h=s.getNextVertex(t);for(let e=h;e!==Ae;e=s.getNextVertex(e)){if(e===h){if(n)break;n=!0}if(s.queryXY(e,b),a&&(i<m-I.x&&b.x-m>i||i<m-b.x&&I.x-m>i)||!a&&(0!==m||i<-I.y&&b.y>i||i<-b.y&&I.y>i))do{if(Math.abs(I.x-b.x)>=.5*x.width())break;2===r.getCoordinateSystemType()?(P[0]=Tl(I.x,x),P[1]=I.y,P[2]=Tl(b.x,x),P[3]=b.y,ag(y,2,P,0),w.x=P[0]*c,w.y=P[1]*c,v.y=P[3]*c):(w.x=I.x*c,w.y=I.y*c,v.y=b.y*c),v.x=(b.x-I.x)*Math.PI*2/x.width()+w.x;let t=0;const n=B(T,2);if(a){if(C.x=f,C.y=Cl(_,p,w,v,f,o),Number.isNaN(C.y))break;n[0]=C,t=1}else if(2===o){const e=[0,0];if(t=Ds(_,p,w,v,f,e),!t)break;n[0].x=e[0],n[0].y=f,2===t&&(n[1].x=e[1],n[1].y=f)}else{if(C.x=kg(_,p,w,v,o),Number.isNaN(C.x))break;C.y=0,n[0]=C,t=1}let i=-1;for(let h=0;h<t;h++){Dc.geodeticDistance(_,p,w.x,w.y,v.x,v.y,E,null,null,o);const t=E.val;Dc.geodeticDistance(_,p,w.x,w.y,n[h].x,n[h].y,E,null,null,o);const l=E.val;2===r.getCoordinateSystemType()?(P[0]=n[h].x/c,P[1]=n[h].y/c,wc.geogToProj(y,1,P),a?(S.y=P[1],S.x=m):(S.x=Hg(P[0],I.x,b.x,x),S.y=m)):a?(S.x=m,S.y=n[h].y/c):(S.x=Hg(n[h].x/c,I.x,b.x,x),S.y=m);const g=t>0?Z(l/t,0,1):.5;if(0===g||1===g)continue;if(i>g)continue;const u=s.getPrevVertex(e);s.splitSegment(u,[g],1);const d=s.getNextVertex(u);s.setXYCoords(d,S.x,S.y),i=g}}while(0);I.setCoordsPoint2D(b)}}}catch(g){l.error=g,l.hasError=!0}finally{t(l)}}function Al(e,t){h(t.isPannable());const s=t.getPannableExtent();if(e.getGeometryType()===r.enumPoint){const t=e.getY();return s.ymin<=t&&t<=s.ymax?e:e.createInstance()}const n=Wt.constructEmpty();e.queryEnvelope(n);const i=Wt.constructEmpty();i.setCoords({env2D:s}),i.xmin=n.xmin,i.xmax=n.xmax,i.inflateCoords(.01*i.height(),0);const o=ht(t,n,!1);let a;return a=i.containsEnvelope(n)?e:Zt(e,i,o,0,null),a}function Ml(e,t,s,n){return k((.5*(s+t)-e)/n)*n}function Ul(e,t,s,n,r){if(e>=s&&t<=n)return 0;return Ml(.5*(t+e),s,n,r)}function ql(e,t,s,n,i,o,a,m){const h=e.getGeometryType(),l=A.constructEmpty();l.setCoords(t,t+s);const g=[0];if(h===r.enumPoint){const t=e;if(g[0]=t.getX(),Dl(g,l,a)){const t=i?e:e.clone();return t.setX(g[0]),t}return e}const u=Wt.constructEmpty();if(e.queryEnvelope(u),u.isEmpty())return e;if(h===r.enumMultiPoint){const t=i?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let o=!1;for(let e=0;e<r;e+=2)g[0]=n.read(e),Dl(g,l,a)&&(n.write(e,g[0]),o=!0);return o&&s.notifyModifiedFlags(2001),t}const c=A.constructEmpty();if(u.queryIntervalX(c),l.contains(c))return l.vmax,c.vmax,e;const _=Wt.constructEmpty();if(_.setCoords({env2D:u}),0===c.width()){let t=c.vmin;t+=Math.ceil((l.vmin-t)/s)*s,t=l.snapClip(t);const n=i?e:e.clone();return n.setAttributeBasic(0,0,t),n}if(h===r.enumEnvelope){const t=i?e:e.clone();return u.intersect(_),t.setEnvelope(u),t}const d=.1*Math.max(u.height(),u.width())*1;_.inflateCoords(0,d);let p=e;const f=n.getTolerance(0),x=new jt;for(;;){const e=Math.floor((c.vmin-t)/s),i=Math.ceil((c.vmax-t)/s);if(!(i-e>3))break;{const a=Math.floor(.5*(i+e));_.xmin=u.xmin-d,_.xmax=t+s*a;const l=Zt(p,_,f,o,m);_.xmin=_.xmax,_.xmax=u.xmax+d;const g=Zt(p,_,f,o,m);x.setShiftCoords((a-i)*s,0),g.applyTransformation(x),h===r.enumPolygon?p=(new al).execute(l,g,n,m):(p=l,p.add(g,!1)),p.queryEnvelope(u),u.queryIntervalX(c)}}_.xmin=t,_.xmax=t+s;const y=Wt.constructEmpty();y.setCoords({env2D:_}),y.inflateCoords(f,0);const P=Math.floor((u.xmin-_.xmin)/s)*s;let E;P?(_.move(P,0),x.setShiftCoords(-P,0)):x.setIdentity(),E=h===r.enumPolyline?new Ce({vd:p.getDescription()}):new we({vd:p.getDescription()});const S=Wt.constructEmpty(),C=Wt.constructEmpty();for(;u.xmax>_.xmin;){const e=Zt(p,_,f,0,m);e.queryEnvelope(C);let t=!1;t=h===r.enumPolyline?!e.isEmpty()&&(C.width()>f||C.height()>f):!e.isEmpty()&&(h!==r.enumPolygon||C.width()>f),t&&(e.applyTransformation(x),e.queryEnvelope(C),E.queryEnvelope(S),S.inflateCoords(f,f),S.isIntersecting(C)&&h===r.enumPolygon?E=(new al).execute(E,e,n,m):E.add(e,!1)),_.move(s,0),x.shiftCoords(-s,0)}return E}function Bl(e,t,s,n,r=!0){const i=new A;i.setCoords(s,s+n);const o=[0];if(Array.isArray(e)){const s=e;for(let e=0;e<t;e++)i.containsRightExclusive(s[e].x)||(o[0]=s[e].x,Dl(o,i,r),s[e].x=o[0])}else{const s=e;for(let e=0;e<t;e++){const t=e<<1;i.containsRightExclusive(s[t])||(o[0]=s[t],Dl(o,i,r),s[t]=o[0])}}}function Ol(e,t,s,n=!0){if(e.isEmpty())return;const i=e.getGeometryType();if(!n||i!==r.enumPolygon)if(f(i)){let n=!1;if(a(i)&&e.hasNonLinearSegments()){const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=r.getSegmentFlagsStreamRef();h(null!==o);for(let e=0,a=r.getPathCount();e<a;e++){let a=!0;const m=r.isClosedPath(e),h=r.getPathEnd(e);if(m&&r.getPathSize(e)>0){a=1===(31&o.read(h-1))}for(let l=r.getPathStart(e);l<h;l++){if(1===(31&o.read(l))){if(a){const e=i.read(2*l),r=Gl(e,t,s);r!==e&&(n=!0,i.write(2*l,r))}a=!0}else a=!1}}}else{const r=e.getImpl(),i=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){const r=i.read(2*e),o=Gl(r,t,s);o!==r&&(n=!0,i.write(2*e,o))}}n&&e.getImpl().notifyModifiedFlags(2001)}else if(i===r.enumEnvelope){const n=e,r=Wt.constructEmpty();n.queryEnvelope(r),r.xmin=Gl(r.xmin,t,s),r.xmax=Gl(r.xmax,t,s),n.setEnvelope(r)}else if(i===r.enumPoint){const n=e;n.setX(Gl(n.getX(),t,s))}else o("")}function Rl(e,t,s){const n=new T;return n.x=Gl(e.x,t,s),n.y=e.y,n}function Yl(e,t){if(t.isEmpty())return 0;const s=e.getPECoordSys();if(s.getProjection().getCode()===bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=ku();e.querySpheroidData(n);const r=s.getParameters();if(null===r[bc.PE_PARM_LAM0])return 0;if(null===r[bc.PE_PARM_PHI0])return 0;const i=[r[bc.PE_PARM_LAM0].getValue(),r[bc.PE_PARM_PHI0].getValue()];wc.geogToProj(s,1,i);const o=new T(i[0],i[1]),a=Wt.constructEmpty();t.queryEnvelope(a);const m=B(T,4);a.queryCorners(m);let h=0;const l=e.getOneMeter();let g=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,u=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;u-=g/180,g*=l,u*=l;for(let e=0;e<4;e++){const t=T.distance(m[e],o);if(t>g)h++;else if(t>u)return-1}if(0===h)return 1;if(4===h){const e=Wt.constructEmpty();return e.setCoords({center:o,width:g,height:g}),a.isIntersectingNe(e)?-1:0}return-1}return-1}function Xl(e,t,s,n){const i=e.getGeometryType();h(i===r.enumPolygon||i===r.enumPolyline||i===r.enumMultiPoint);const o=t.getCoordinateSystemType();if(2===o){let o=e;if(0===s){const s=Yl(t,e);if(0===s)return e.createInstance();if(1===s)return e;const i=t.getPCSHorizon(),a=i.getGeometryType(),m=t.getDefaultPrecisionSR();if(a===r.enumEnvelope){const s=Wt.constructEmpty();i.queryEnvelope(s);const r=ht(m,s,!1);o=Zt(e,s,r,5e4*t.getOneMeterPCSUnit(),n)}else(new jh).execute(i,e,m,n)||(o=(new wm).execute(o,i,m,n),o===i&&(o=o.clone()))}else if(t.isPannable()){const e=Wt.constructEmpty();o.queryEnvelope(e);const a=t.getPannableExtent();a.containsEnvelope(e)||(Ol(o,a,t.getTolerance(0)),2!==s&&4!==s||(o=Al(o,t)),4!==s?o=vl(o,t,0,!0,1e5*t.getOneMeterPCSUnit(),n):i===r.enumPolygon&&e.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,n)))}return o}if(h(1===o),i===r.enumMultiPoint)return Ol(e,t.getPannableExtent(),t.getTolerance(0)),e;{const s=Wt.constructEmpty();e.queryEnvelope(s);let o=e;const a=t.getPannableExtent();if(s.ymin<a.ymin||s.ymax>a.ymax){const e=Math.max(1,s.calculateToleranceFromEnvelope()),r=new Wt(s.xmin-e,a.ymin,s.xmax+e,a.ymax);if(o=(new Kt).execute(o,r,t,n),o.isEmpty())return o}return i===r.enumPolygon&&s.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,n)),o}}function Ll(e,t,s,n,r,i){const o=n.getCoordinateSystemType();if(2===o){if(0===r)s!==e&&V(s,e,t),Pl(n,s,t);else if(s!==e&&V(s,e,t),n.isPannable()){const e=n.getTolerance(0);El(s,t,n.getPannableExtent(),e),Nl(s,t,n,0)}}else{h(1===o);const r=n.getTolerance(0),i=n.getPannableExtent();for(let n=0;n<t;n++)s[n].assign(Rl(e[n],i,r))}}function zl(e,t){const s=t.getPointCount();if(!s)return;const n=t.getImpl(),r=n.getAttributeStreamRef(0),i=e;wc.geogToProj(i,s,r.getArray()),n.notifyModifiedFlags(2001)}function Wl(e,t,s,n){if(!s)return;const r=e.getPECoordSys();if(1===s){if(t[0].isNAN())return;const s=[t[0].x,t[0].y];if(wc.geogToProj(r,1,s),n){const{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(t[0].x-e.getCentralMeridian())+r}return void t[0].setCoords(s[0],s[1])}const i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let m=0;i&&(m=e.getCentralMeridian());const h=256,l=new Float64Array(2*h);for(let g=0;g<s;){for(let e=g;e<s&&t[e].isNAN();++e)g++;let u=Math.min(h,s-g);if(u>0){for(let e=1,s=g+1;e<u;++e,++s)if(t[s].isNAN()){u=e;break}for(let e=0;e<u;++e){const s=e<<1;l[s]=t[g+e].x,l[s+1]=t[g+e].y}if(wc.geogToProj(r,u,l),n){const{first:s,second:n}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<u;++e){l[e<<1]=s*(t[g+e].x-m)+n}}if(i)for(let e=0,s=g;e<u;e++,s++){const n=e<<1,r=l[n],i=U(r),h=t[s].x-m;i*U(h)<0&&Math.abs(r)>a&&(l[n]-=i*o)}bl(l,t,g,u),g+=u}}}function jl(e,t,s,n){const r=e.getSRToGCSTransform();return(new qm).transform(r,t,s,n,!1)}function Zl(e,t,s,n){const r=new ve({vd:t.getDescription()});let i;r.addPoints(t,0,-1),i=(new qm).execute(r,e,n);const o=t.getPointCount();if(s.setEmpty(),e.getInputSR().isPannable()){if(o!==i.getPointCount())return!1;const n=new Wt;t.queryEnvelope(n);const r=new Wt;i.queryEnvelope(r);const a=n.width(),m=r.width();if(0!==a&&0!==m){const t=m/a,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==a||0!==m)return!1;s.add(t,!1);for(let e=0;e<o;e++){const t=i.getXY(e);s.setXY(e,t)}return!0}return!1}function Kl(e,t,s){h(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),i=r.getAttributeStreamRef(0),o=e.getPECoordSys();let a=0;const m=i.readRange(0,2*n);let l=()=>{wc.geogToProj(o,n,m)};const g=e.isPannable()&&!s,u=g?e.getPannableExtent().width():0,c=179*u/360;if(e.isPannable()&&(a=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;l=()=>{wc.geogToProj(o,n,m);for(let e=0;e<n;e++){const t=e<<1,n=i.read(t),o=s*(n-a)+r;m[t]=o}}}if(l(),g)for(let h=0;h<n;h++){const e=h<<1,t=m[e],s=U(t),n=i.read(e)-a;s*U(n)<0&&Math.abs(t)>c&&(m[e]+=-s*u)}i.writeRangeFromArray(0,2*n,m,!0,1),r.notifyModifiedFlags(2001)}function Ql(e,t,s){switch(t.getGeometryType()){case r.enumLine:return void Ig(e,t,s);case r.enumBezier:return void Gg(e,t,s);case r.enumEllipticArc:return void wg(e,t,s);case r.enumBezier2:return void Dg();case r.enumRationalBezier2:return void Vg();default:o("")}}function Jl(e,t,s){if(!t.hasNonLinearSegments())return void Kl(e,t,s);if(h(!s||e.isPannable()),t.isEmpty())return;const n=0,r=e.getPECoordSys(),i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let m=0;i&&(m=e.getCentralMeridian());const l=t.createInstance();l.reserveParts(t.getPointCount(),t.getPathCount());const g=t.getImpl(),u=new Ve;for(let h=0,c=t.getPathCount();h<c;++h)if(g.hasNonLinearSegmentsPath(h)){let t=!0,n=-1;const r=g.getPathStart(h),i=r+g.getSegmentCountPath(h);g.isClosedPath(h)&&(n=i-1);const o=new T;for(let a=r;a<i;++a){if(g.getSegmentBuffer(a,u,!1),Ql(e,u.get(),s),!t){u.get().getStartXY().equals(o)||u.get().moveTo(o)}if(a!==n)l.addSegment(u.get(),t);else{if(t){const e=new pt;u.get().queryStart(e),l.startPathPoint(e)}l.closeLastPathWithSegment(u.get())}o.assign(u.get().getEndXY()),t=!1}}else{const e=1024;let s,u=g.getPathSize(h),c=Math.min(u,e);l.insertPath(-1,t,h,!0);const _=g.getAttributeStreamRef(0),d=l.getAttributeStreamRef(0);for(let t=g.getPathStart(h),l=g.getPathEnd(h);t<l;){if(s=_.readRange(t,c),wc.geogToProj(r,c,s),i)for(let e=0;e<c;e++){const t=e<<1,r=s[t],i=U(r),h=_.read(2*(n+e))-m;i*U(h)<0&&Math.abs(r)>a&&(s[t]+=-i*o)}d.writeRangeFromArray(t,c,s,!0,1),t+=c,u-=c,c=Math.min(u,e)}}t.assignMove(l)}function $l(e,t,s){const n=1e3;let r=s.getPointCount();if(!r)return;const i=s.getImpl(),o=i.getAttributeStreamRef(0);let a=Math.min(r,n),m=0;const h=e.getPECoordSys();Number.isNaN(t)&&(t=0);const l=e.isPannable(),g=e.getOneDegreeGCSUnit(),u=360*g,c=179*g;let _;for(;r;){if(_=o.readRange(2*m,2*a),ag(h,a,_,t),l)for(let e=0;e<a;e++){const s=e<<1,n=_[s]-t,r=U(n),i=o.read(2*(m+e));r*U(i)<0&&Math.abs(n)>c&&(_[s]+=-r*u)}o.writeRangeFromArray(2*m,2*a,_,!0,1),m+=a,r-=a,a=Math.min(r,n)}i.notifyModifiedFlags(2001)}function eg(e,t,s){switch(s.getGeometryType()){case r.enumLine:return void tg(e,t,s);case r.enumBezier:return void rg(e,t,s);case r.enumEllipticArc:return void sg(e,t,s);case r.enumBezier2:return void ig();case r.enumRationalBezier2:return void og();default:o("")}}function tg(e,t,s){const n=[s.getStartXY(),s.getEndXY()];hg(e,t,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}function sg(e,t,s){if(0===s.projectionBehavior())ng(e,t,s);else{const n=s.isClosed()&&s.isMajor(),r=[s.getStartXY(),n?s.getCenter():s.getEndXY()],i=[r[0].clone(),r[1].clone()];vg(e,t,i,2);const o=new jt;o.initializeFromTwoPointsArray(r,i),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(i[0],i[a],!1)}}function ng(e,t,s){Ng(!1,e,t,s,!1)}function rg(e,t,s){const n=B(T,4);s.queryControlPoints(n),vg(e,t,n,4),s.setControlPoints(n)}function ig(e,t,s){h(0)}function og(e,t,s){h(0)}function ag(e,t,s,n){const r=wc.projToGeogCenter(e,t,s,n);for(let i=0;i<t;++i){const e=i<<1;h(Number.isFinite(s[e]+s[e+1]))}return r}function mg(e,t,s){if(!s.hasNonLinearSegments())return void $l(e,t,s);if(s.isEmpty())return;const n=e.getPECoordSys();Number.isNaN(t)&&(t=0);const r=e.isPannable(),i=e.getOneDegreeGCSUnit(),o=360*i,a=179*i,m=s.createInstance();m.reserveParts(s.getPointCount(),s.getPathCount());const h=s.getImpl(),l=new Ve;for(let g=0,u=s.getPathCount();g<u;++g)if(h.hasNonLinearSegmentsPath(g)){let s=!0,n=-1;const r=h.getPathStart(g),i=r+h.getSegmentCountPath(g);h.isClosedPath(g)&&(n=i-1);const o=new T;for(let a=r;a<i;++a){if(h.getSegmentBuffer(a,l,!1),eg(e,t,l.get()),!s){l.get().getStartXY().equals(o)||l.get().moveTo(o)}if(a!==n)m.addSegment(l.get(),s);else{if(s){const e=new pt;l.get().queryStart(e),m.startPathPoint(e)}m.closeLastPathWithSegment(l.get())}o.assign(l.get().getEndXY()),s=!1}}else{const e=1e3;let i,l=h.getPathSize(g),u=Math.min(l,e);m.insertPath(-1,s,g,!0);const c=h.getAttributeStreamRef(0),_=m.getAttributeStreamRef(0);for(let s=h.getPathStart(g),m=h.getPathEnd(g);s<m;){if(i=c.readRange(2*s,2*u),ag(n,u,i,t),r)for(let e=0;e<u;e++){const n=e<<1,r=i[n]-t,m=U(r),h=c.read(2*s);m*U(h)<0&&Math.abs(r)>a&&(i[n]+=-m*o)}_.writeRangeFromArray(2*s,2*u,i,!0,1),s+=u,l-=u,u=Math.min(l,e)}}s.assignMove(m)}function hg(e,t,s,n){const r=e.getPECoordSys();Number.isNaN(t)&&(t=0);const i=e.isPannable(),o=e.getOneDegreeGCSUnit(),a=360*o,m=179*o,h=256,l=new Float64Array(2*h);for(let g=0;g<n;){for(let t=g;t<n&&s[t].isNAN();++t)g++;let e=Math.min(h,n-g);if(e>0){for(let t=1,n=g+1;t<e;++t,++n)if(s[n].isNAN()){e=t;break}for(let t=0;t<e;t++){const e=t<<1;l[e]=s[g+t].x,l[e+1]=s[g+t].y}if(ag(r,e,l,t),i)for(let n=0,r=g;n<e;++n,++r){const e=n<<1,i=s[r].x,o=l[e]-t,h=U(o);h*U(i)<0&&Math.abs(o)>m&&(l[e]-=h*a)}for(let t=0;t<e;t++){const e=t<<1;s[g+t].x=l[e],s[g+t].y=l[e+1]}g+=e}}}function lg(e,t,s,n){h(0)}function gg(e,t,s){let n=t.getPointCount();if(!n)return!1;const r=t.getImpl(),i=r.getAttributeStreamRef(0);let o=null;const a=e.getInputSR(),m=e.getOutputSR();a.getVCS(),m.getVCS();const h=a.getOneDegreeGCSUnit(),l=m.getOneDegreeGCSUnit(),g=e.isVertical();g&&t.hasAttribute(1)&&(o=r.getAttributeStreamRef(1));const u=e.getDatumTransformation(),c=!!u&&1===u.getType();if(c||null===o||(lg(o.getArray()),o=null),!u||0===u.count()){const e=a.getGcsUnitFactor()/m.getGcsUnitFactor(),t=(a.getPrimeMeridian()-m.getPrimeMeridian())*l,s=-90*h,o=90*h;let g=0;const u=i.getArray(),c=[0];for(let r=1,i=2*n;r<i;)c[0]=u[r],g|=he(c,s,o)?1:0,u[r]=c[0],r+=2;if(0!==t||1!==e){g=1;const s=i.getArray();for(let r=0,i=2*n;r<i;){let n=s[r];n*=e,n+=t,s[r]=n,s[r+1]*=e,r+=2}}return 0!==g&&r.notifyModifiedFlags(2001),!!g}const _=1e3;let d=Math.min(n,_);const p=N(d,Number.NaN),f=N(d,Number.NaN);let x=null;null!==o&&(x=new Float64Array(d));let y=0,P=Number.NaN,E=Number.NaN;const S=360*l,C=l/h;s&&(E=90*l,P=89.9*h,f.fill(0));let I=!0,b=0;for(;n;){let e=!1;const t=i.readRange(2*y,2*d);for(let s=0;s<d;s++)p[s]=t[s<<1];if(s)for(let s=0;s<d;s++){const n=1+(s<<1),r=Math.abs(t[n])-P;if(r>0){const i=t[n];t[n]=Y(P,i),f[s]=Y(r,i),e=!0}}const r=t[0];if(c){const e=u;x&&o.queryRange(y,d,x,!0,1),e.transform(!1,t,x,d),x&&o.writeRangeFromArray(y,d,x,!0,1)}else{u.transform(!1,t,d)}I&&(b=t[0]-C*r,I=!1);for(let s=0;s<d;s++){const e=s<<1,n=t[e]-p[s]*C-b;Math.abs(n)>200&&(t[e]+=n>0?-S:S)}if(e){for(let e=0;e<d;e++)if(f[e]){const s=1+(e<<1);t[s]+=C*f[e],t[s]>E?t[s]=E:t[s]<-E&&(t[s]=-E)}f.fill(0)}i.writeRangeFromArray(2*y,2*d,t,!0,1),g&&o&&o.writeRangeFromArray(y,d,x,!0,1),y+=d,n-=d,d=Math.min(n,_)}return r.notifyModifiedFlags(2001),!0}function ug(e,t,s){switch(t.getGeometryType()){case r.enumLine:return xg(e,t,s);case r.enumBezier:return Eg(e,t,s);case r.enumEllipticArc:return yg(e,t,s);case r.enumBezier2:return Sg();case r.enumRationalBezier2:return Cg();default:o("")}}function cg(e,t,s){if(!t.hasNonLinearSegments())return gg(e,t,s);if(t.isEmpty())return!1;const n=t.createInstance();n.reserveParts(t.getPointCount(),t.getPathCount());const r=t.getImpl(),i=new Ve;for(let o=0,a=t.getPathCount();o<a;++o){let t=!0,a=-1;const m=r.getPathStart(o),h=m+r.getSegmentCountPath(o);r.isClosedPath(o)&&(a=h-1);const l=new T;for(let o=m;o<h;++o){if(r.getSegmentBuffer(o,i,!1),ug(e,i.get(),s),!t){i.get().getStartXY().equals(l)||i.get().moveTo(l)}if(o!==a)n.addSegment(i.get(),t);else{if(t){const e=new pt;i.get().queryStart(e),n.startPathPoint(e)}n.closeLastPathWithSegment(i.get())}l.assign(i.get().getEndXY()),t=!1}}return t.assignMove(n),!0}function _g(e,t,s,n,r,i){if(e.isIdentityGeogToGeog()){const s=90*e.getInputSR().getOneDegreeGCSUnit();let r=0;const i=[0];for(let e=0;e<n;e++)i[0]=t[e].y,r|=he(i,-s,s)?1:0,t[e].y=i[0];return r}const o=e.getInputSR(),a=e.getOutputSR(),m=o.getVCS(),h=a.getVCS(),l=o.getOneDegreeGCSUnit(),g=90*l,u=a.getOneDegreeGCSUnit(),c=e.isVertical(),_=e.getDatumTransformation(),d=!!_&&1===_.getType();if(c||(s=null),!_||0===_.count()){let e=0;const r=[0];for(let s=0;s<n;s++)r[0]=t[s].y,e|=he(r,-g,g)?1:0,t[s].y=r[0];return e|=qh(o.getGCS(),m,a.getGCS(),h,t,s,n)?1:0,e}d||null===s||lg();const p=1024;let f=Math.min(n,p);const x=N(f,Number.NaN),y=N(f,Number.NaN);let P=0,E=Number.NaN,S=Number.NaN;const C=360*u,I=u/l;r&&(S=90*u,E=89.9*l);let b=!0,w=0,v=n;for(;v;){let e=!1;for(let s=0;s<f;s++)x[s]=t[s+P].x;if(r)for(let s=0;s<f;s++){const n=Math.abs(t[s+P].y)-E;if(n>0){const r=t[s+P].y;t[s+P].y=Y(E,r),y[s]=Y(n,r),e=!0}}const n=t[0].x;if(d){_.transform(!1,t,s,f)}else{_.transform(!1,t,f)}b&&(w=t[0].x-I*n,b=!1);for(let s=0;s<f;s++){const e=t[P+s].x-x[s]*I-w;Math.abs(e)>200&&(e>0?t[P+s].x-=C:t[P+s].x+=C)}if(e){for(let e=0;e<f;e++)y[e]&&(t[P+e].y+=I*y[e],t[P+e].y>S?t[P+e].y=S:t[P+e].y<-S&&(t[P+e].y=-S));y.fill(0,0,f)}P+=f,v-=f,f=Math.min(v,p)}return 1}function dg(e,t,s,n,r){return h(0),0}function pg(e,t,s,n,r){h(null===n),h(t<2147483647);const i=Array.isArray(s);let o;o=i?de(s):s;const a=vc.geogToGeog(e,t,o,null,r);return i&&pe(o,s),a}function fg(e,t,s,n,r,i){let o=0,a=!0,m=0;for(let h=0;h<n;++h)t[h].isNAN()?a||(o|=_g(e,t.slice(m,h-m),s?s.slice(m,h-m):null,h-m,r),m=h,a=!0):a&&(m=h,a=!1);return a||(o|=_g(e,0===m?t:t.slice(m),s?0===m?s:s.slice(m):null,n-m,r)),0!==o}function xg(e,t,s){const n=[t.getStartXY(),t.getEndXY()],r=[0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[1]=t.getAttributeAsDbl(1,1,0));const o=fg(e,n,i,2,s);return t.setStartXY(n[0]),t.setEndXY(n[1]),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[1])),t.normalizeAfterEndpointChange(),o}function yg(e,t,s){if(0===t.projectionBehavior())return Pg(e,t,s);const n=t.getStartXY().equals(t.getEndXY()),r=B(T,3),i=B(T,3),o=[0,0,0];let a=null;r[0].assign(t.getStartXY()),r[1].assign(n?t.getCenter():t.getEndXY());let m=!1;t.hasAttribute(1)&&(a=o,a[0]=t.getAttributeAsDbl(0,1,0),a[1]=t.getAttributeAsDbl(1,1,0),a[2]=R(a[0],a[1],.5),n&&(a[1]=a[2])),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]);const h=new jt;if(n||t.isDegenerateToLine())m=fg(e,i,a,2,s),h.initializeFromTwoPoints(r[0],r[1],i[0],i[1]);else{const n=new T;t.queryCoord2D(.5,n),r[2].setCoordsPoint2D(n),i[2].setCoordsPoint2D(n),m=fg(e,i,a,3,s),h.setFromTwoTriangles(r,i)}return h.isIdentity()||(t.applyTransformation(h),t.setStartXY(i[0]),t.setEndXY(n?i[0]:i[1]),t.normalizeAfterEndpointChange()),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,n?a[0]:a[1])),m}function Pg(e,t,s){const n=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()];let r=4;t.isDegenerateToLine()&&(r=2);const i=[0,0,0,0];let o=null;if(t.hasAttribute(1)){o=i,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);const e=R(o[0],o[1],.5);o[2]=e,o[3]=e}const a=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),m=fg(e,n,o,r,s);return a?t.constructCircleCenterAndPoint(n[3],n[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(n[0],n[1]):t.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),m}function Eg(e,t,s){const n=B(T,4);t.queryControlPoints(n);const r=[0,0,0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[3]=t.getAttributeAsDbl(1,1,0),i[1]=R(i[0],i[3],.5),i[2]=i[1]);const o=fg(e,n,i||null,n.length,s);return t.setControlPoints(n),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[3])),t.normalizeAfterEndpointChange(),o}function Sg(e,t,s){return h(0),!1}function Cg(e,t,s){return h(0),!1}function Ig(e,t,s){const n=[t.getStartXY(),t.getEndXY()];Wl(e,n,2,s),t.setStartXY(n[0]),t.setEndXY(n[1]),t.normalizeAfterEndpointChange()}function bg(e,t,s,n){Wl(e,t,s,n)}function wg(e,t,s){if(0===t.projectionBehavior())Tg(e,t,s);else{const n=t.isClosed()&&t.isMajor(),r=[t.getStartXY(),n?t.getCenter():t.getEndXY()],i=[r[0].clone(),r[1].clone()];bg(e,i,2,s);const o=new jt;o.initializeFromTwoPointsArray(r,i),t.applyTransformation(o);const a=n?0:1;t.setCoordsForIntersector(i[0],i[a],!1)}}function vg(e,t,s,n){hg(e,t,s,n);const r=new Wt;r.setFromPoints(s,n);const i=e.getOneDegreeGCSUnit(),o=360*i,a=180*i;if(r.width()>a){for(let e=0;e<n;e++)for(;s[e].x<t;)s[e].x+=o;if(r.setFromPoints(s,n),r.xmax>a+t)for(let e=0;e<n;e++)s[e].x-=o}}function Ng(e,t,s,n,r){const i=B(T,3);let o=0,a=!1,m=!1;const h=n.isDegenerateToLine();h?(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(a=!0,m=!n.isClockwise(),i[0].assign(n.getStartXY()),i[1].assign(n.getCenter()),i[2].setCoords(0,0),o=2):(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].assign(n.getInteriorPoint()),o=3),e?bg(t,i,o,r):vg(t,s,i,o),h?n.constructLineCircularArc(i[0],i[1]):a?n.constructCircleCenterAndPoint(i[1],i[0],m):n.constructCircularArcThreePoint(i[0],i[1],i[2])}function Tg(e,t,s){Ng(!0,e,0,t,s)}function Gg(e,t,s){const n=B(T,4);t.queryControlPoints(n),bg(e,n,4,s),t.setControlPoints(n)}function Dg(e,t,s){h(0)}function Vg(e,t,s){h(0)}function Fg(e,t,s){const n=ot(e),r=ot(t),i=tt(n,r),o=tt(n,ot(s));return 0===o||(i>0&&o>0&&o<=i||i<0&&o<0&&o>=i)}function kg(s,n,r,i,o){const a={stack:[],error:void 0,hasError:!1};try{const t=r.clone(),m=i.clone();if(2===o){const e=[0,0];return Ds(s,n,t,m,0,e),e[0]}if(t.y>m.y){const e=new T;e.assign(t),t.assign(m),m.assign(e)}const l=e(a,new Cc,!1),g=e(a,new Cc,!1),u=e(a,new Cc,!1),c=new A;if(c.setCoords(t.y,m.y),!c.containsCoordinate(0)||Math.abs(t.x-m.x)>=Math.PI)return Number.NaN;if(t.x===m.x)return t.x;Dc.geodeticDistance(s,n,t.x,t.y,m.x,m.y,g,l,null,o);const _=g.val;let d=0,p=1;const f=t.clone();for(;_*(p-d)>1e-12*s;){const e=.5*(d+p);if(Dc.geodeticCoordinate(s,n,t.x,t.y,_*e,l.val,g,u,o),f.x=g.val,f.y=u.val,c.setCoords(t.y,f.y),0===f.y)return f.x;if(c.containsCoordinate(0))p=e;else{if(c.setCoords(m.y,f.y),!c.containsCoordinate(0))return h(!1),Number.NaN;d=e}}return f.x}catch(m){a.error=m,a.hasError=!0}finally{t(a)}}function Hg(e,t,s,n){const r=new A;r.setCoords(t,s);const i=n.width();let o=Math.floor((e-t)/i)*i+e;const a=r.getCenter();for(;Math.abs(o-a)>Math.abs(o+i-a);)o+=i;return o}class Ag extends $t{m_geometryDeque=[];m_index=-1;constructor(){super()}next(){if(this.m_geometryDeque.length>0){this.m_index++;const e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}function Mg(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID))}function Ug(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?1===e.m_csType?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID))}class qg{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=T.getNAN();m_southPole=T.getNAN();m_polesUpdated=0;m_domain=Wt.constructEmpty();m_primeMeridian=Number.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=Wt.constructEmpty();m_pannableExtentGCS=Wt.constructEmpty();m_unit;m_areaOfUse=null;m_canonicalWkt="";m_hashCode;m_peCoordSys;constructor(e,t=!0){this.m_peCoordSys=e,this.m_WKID=Ic.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_l(e,0,!0),this.m_hashCode=$(this.m_canonicalWkt)):this.m_hashCode=ee(this.m_WKID);const n=this.m_peCoordSys.getType();this.m_csType=n===bc.PE_TYPE_PROJCS?2:1,h(n===bc.PE_TYPE_PROJCS||n===bc.PE_TYPE_GEOGCS),n===bc.PE_TYPE_PROJCS&&(e.loadConstants()||s("PeProjcs.loadConstants failed"));const r=n===bc.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();n!==bc.PE_TYPE_GEOGCS&&Ic.getCode(r),this.m_unit=hs(e),this.m_primeMeridian=r.getPrimem().getLongitude();{const e=r.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(n===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=Nc.generate(e,Nc.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;const e=1/r.getUnit().getUnitFactor(),t=r.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 h(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==bc.PE_TYPE_PROJCS)return;let e=!0;const t=this.m_peCoordSys,s=t.getGeogcs(),n=t.horizonGcsGenerate();if(!n)return;h(n.length>0);const r=n[0].getNump(),i=n[0].getKind();let o,a;e=n[0].getInclusive()>0;const m=this.getOneDegreeGCSUnit(),l=90*m,g=360*m,u=370*m,c=180*m*bc.PE_HORIZON_DELTA/Math.PI,_=Wt.constructEmpty();let d=null;if(r>1)for(let h=1;h<r;h++)if(n[h].getKind()===bc.PE_HORIZON_LINE){d||(d=new Ce);const e=n[h].getCoord();d.startPathCoords(e[0][0],e[0][1]),d.lineToCoords(e[1][0],e[1][1])}if(i===bc.PE_HORIZON_RECT){const t=n[0].getCoord();if(_.setFromPoints([new T(t[0][0],t[0][1]),new T(t[1][0],t[1][1])],2),Math.abs(_.ymax-l)<1e-7*c&&(_.ymax=l),Math.abs(_.ymin+l)<1e-7*c&&(_.ymin=-l),_.width()>u){const e=-400*m,t=e+5*g;_.setCoords({xmin:e,ymin:_.ymin,xmax:t,ymax:_.ymax})}const s=new dt({env2D:_});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const i=Yu(s,null,null,1),u=[],c=new A;for(let e=0;e<r;e++){if(n[e].getKind()!==bc.PE_HORIZON_POLY)continue;o=n[e].getSize();const t=n[e].getCoord(),s=Wt.constructEmpty();s.setFromPoints(te(t),o),u.push(new A(s.xmin,s.xmax)),s.width(),c.merge(u.at(-1))}let _=!1;const p=new A;c.width()>g&&u.length>1?(p.vmin=this.getCentralMeridian()-g,p.vmax=p.vmin+2*g,_=!0,t=!0):(p.vmin=c.vmin,p.vmax=p.vmin+g);const f=e=>{let t=0;for(;u[e].vmin+t<p.vmin;)t+=g;for(;u[e].vmax+t-g>p.vmin;)t-=g;return t};let x=new we;if(t){const e=new Ag,t=(new al).executeMany(e,i,null);for(let s=0;s<r;s++){if(n[s].getKind()!==bc.PE_HORIZON_POLY)continue;o=n[s].getSize();const r=n[s].getCoord();a=n[s].getInclusive()>0;const i=new we;if(i.addPathPoint2D(te(r),o-1,!0),_){const t=f(s),n=u[s].clone();n.move(t);let r=t;const o=new jt;do{o.setShiftCoords(r,0);const t=i.clone();t.applyTransformation(o),e.tick(t),e.tock(),r+=g,n.move(g)}while(n.vmin<p.vmax)}else e.tick(i),t.tock()}x=t.next()}else{x=new we;for(let t=0;t<r;t++){if(n[t].getKind()!==bc.PE_HORIZON_POLY)continue;o=n[t].getSize();const s=n[t].getCoord();if(a=n[t].getInclusive()>0,h(a===e),_){const e=new we;e.addPathPoint2D(te(s),o-1,!0);const n=f(t),r=u[t].clone();r.move(n);let i=n;const a=new jt;do{if(0!==i){a.setShiftCoords(i,0);const t=new we({copy:e});t.applyTransformation(a),x.addPath(t,0,!0)}else x.addPath(e,0,!0);i+=g,r.move(g)}while(r.vmin<p.vmax)}else x.addPathPoint2D(te(s),o-1,!0)}}_&&(x=(new Kt).execute(x,new Wt(p.vmin,-l-m,p.vmax,l+m),i,null)),e?(new wm).accelerateGeometry(x,i,1):(new Kh).accelerateGeometry(x,i,1),(new ul).accelerateGeometry(x,i,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=x,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=d)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==bc.PE_TYPE_PROJCS)return;const e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();const s=e[0].getKind();e[0].getInclusive();const n=Wt.constructEmpty(),r=e[0].getNump();let i=!1;if(s===bc.PE_HORIZON_RECT){const s=e[0].getCoord();n.setFromPoints(te(s),2),t=new dt({env2D:n})}else{let s=-1;for(let t=0;t<r;t++)e[t].getKind()===bc.PE_HORIZON_POLY&&(s=t);h(s>=0);const n=e[s].getSize()-1,o=e[s].getCoord(),a=new we;t=a,a.addPathPoint2D(te(o),n,!0),i=!0}if(this.getPCSInfo().isDensificationNeeded()){h(s!==bc.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new Jt).execute(t,e,0,0,null)}if(i){{const e=new dt;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}(new wm).accelerateGeometry(t,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=t)}updatePannableExtent(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),s=e.getGeogcs();s||o("");const n=[t+1/s.getUnit().getUnitFactor()*Math.PI,0];wc.geogToProj(e,1,n);const r=n[0],i=e.getParameters()[bc.PE_PARM_X0].getValue(),a=this.getPCSHorizon(),m=Wt.constructEmpty();a.queryEnvelope(m);const h=Math.abs(r-i),l=h+i,g=-1*h+i,u=m.ymax,c=m.ymin;this.m_pannableExtent.setCoords({xmin:g,ymin:c,xmax:l,ymax:u})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,s=e.getGeogcs();s||o("");const n=1/s.getUnit().getUnitFactor()*Math.PI,r=this.getGCSHorizon(),i=Wt.constructEmpty();r.queryEnvelope(i),this.m_pannableExtentGCS.setCoords({xmin:t-n,ymin:i.ymin,xmax:t+n,ymax:i.ymax})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else o("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=Wt.construct(-e,-e,e,e)}else{h(2===this.m_csType);const e=Nc.generate(this.m_peCoordSys,Nc.PE_PCSINFO_OPTION_DOMAIN);e||o("generate pcs info failed");const t=new Wt(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];wc.geogToProj(this.m_peCoordSys,2,t);const s=this.getPCSInfo().getNorthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(t[0][0],t[0][1]),n&&this.m_southPole.setCoords(t[1][0],t[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=t,s[1]=0,s[2]=t+e,s[3]=0;const n=wc.geogToProj(this.m_peCoordSys,2,s);h(2===n);const r=(s[2]-s[0])/e,i=s[0];0===this.m_geogToProjFactorsUpdated&&(this.m_geogToProjFactor=r,this.m_geogToProjOffset=i,this.m_geogToProjFactorsUpdated=1)}else this.m_geogToProjFactorsUpdated=1}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return this.m_gcsUnitFactor}getUnitsPerMillimeter(){return this.m_oneMillimeter}getGCSSplitLines(){return this.m_bIsPannable?null:(this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSSplitLines)}getGCSHorizon(){return this.m_bIsPannable?this.getGCSHorizonPannable():(null!==this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(null!==this.m_PCSHorizon||this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(e){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),H(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){const t=[0],s=[0];qc(this.m_peCoordSys.getType(),this.m_WKID,t,s)||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 null!==this.m_areaOfUse?this.m_areaOfUse:this.updateAreaOfUse()}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}class Bg{m_oneMeter=0;m_WKID=-1;m_oldWKID=-1;m_canonicalWkt="not yet implemented";m_model=0;m_unit=new bu;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 Og(e,t,s){return Rg(e,t,Wt.constructEmpty())}function Rg(e,t,s,n){return Xg(!0,e,t,s)}function Yg(e,t,s,n){return Lg(!0,e,t,s,n)}function Xg(e,t,s,n,r){Uu()||p("cannot create projection transformation");return t.hasVCS()&&s.hasVCS()?jg():Zg(t,s,n)}function Lg(e,t,s,n,r,i){return Uu()||p("cannot create projection transformation"),new eu(e?2:1,t,s,n,r,i)}function zg(e,t,n,r,i,o=!1){t&&n||s(""),Uu()||p("cannot obtain geotransformation list");if(1===e&&t.hasVCS()&&n.hasVCS())return _("hv xform not impl"),[];{const e=Qc(t,n,r,i,o),s=[];for(const t of e)s.push(t);return s}}function Wg(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return F(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&F(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function jg(e,t,s,n){return h(0),{}}function Zg(e,t,n,r){e&&t||s("!inputSR || !outputSR");const i=e.getLatestID(),o=t.getLatestID();if(3857===i&&4326===o){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return pu()}else if(4326===i&&3857===o&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return fu();const a=Wt.constructEmpty();a.setCoords({env2D:n});const m=e.getCoordinateSystemType(),h=t.getCoordinateSystemType();if(0===m||0===h)return Kg(e,t);const l=e.getGCS().getLatestID(),g=t.getGCS().getLatestID();if(l>0&&l===g)return Kg(e,t);const u=new hu(e,t,n);{const e=gu(u);if(e)return e}const c=zg(0,e,t,a,1,!0);return uu(u,Kg(e,t,c.length?c[0]:void 0))}function Kg(e,t,s,n,r){return new eu(1,e,t,s,n,r)}function Qg(){return{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return 0!==(this.flagsMask&e)}}}function Jg(){return{m_extendedParams:Wg(),m_extendedParamsInternal:Qg()}}function $g(){return Jg()}class eu{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,n,r,i,o){let a,m;t&&n||s("!inputSR || !outputSR"),r&&0===r.getType()&&(r.m_bReadOnly=!0),this.m_bNormalize=!1,1!==e&&(a=t.getVCS(),m=n.getVCS(),this.m_bVertical=null!=a&&null!=m),this.m_inputSR=t,this.m_outputSR=n,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,h(!this.m_params),i&&(this.m_params=Jg(),this.m_params.m_extendedParams=i),o&&(this.m_params||(this.m_params=Jg()),this.m_params.m_extendedParamsInternal=o);let l=!1;const g=null!=r,u=t.getCoordinateSystemType(),c=n.getCoordinateSystemType();if(n.isPannable()&&0!==u&&i){const e=i.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&n.isPannable()){const t=n.getPannableExtent(),s=t.getCenterX();if(s!==e){const n=Math.ceil(t.width());e+n!==s+n&&(l=!0)}}}const _=i&&i.normalizeResultGeometry;if(t.equals(n))return this.m_bIdentity=!l,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!g&&t.equalForProjection(n,this.m_bVertical);this.m_bIdentity=d&&!l,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(_&&this.m_outputSR.isPannable()&&(this.m_bNormalize=_),this.m_datumTran=r||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const e=new eu(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:$g().m_extendedParams}equals(e){return h(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return h(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:$g().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:$g().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new Am(this)}}const tu=new Map,su=new Map,nu=new Map;function ru(e){let t=e.getCode();if(t>0){const e=Iu(t);return e||Cu(Ic.coordsys(t))}const s=e.getName();if(su.has(s)){const t=su.get(s);if(t&&t.deref()){const s=t.deref();if(s.m_peCoordSys.isEqual(e))return s}}return t=Ic.getCode(e),Cu(t>0?Ic.coordsys(t):e)}function iu(e){e<=0&&C(e);{const t=Iu(e);if(t)return t}const t=kc(Ic.coordsys(e));t.get()||C(e);const s=Cu(t.release());return s.getLatestID()!==e&&tu.set(e,new WeakRef(s)),s}function ou(e){const t=new Bg({},!0);return t.m_WKID=e,t}function au(e){const t=kc(Ic.fromString(bc.PE_TYPE_COORDSYS,e));return t.get()||P(e),ru(t.release())}function mu(e){su.delete(e.m_peCoordSys.getName()),nu.delete(_l(e.m_peCoordSys,0,!1))}class hu{m_inputSR;m_outputSR;m_env;m_hashCode=-1;constructor(e,t,s){e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=b(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=b(this.m_hashCode,fe(this.m_env.xmin)),this.m_hashCode=b(this.m_hashCode,fe(this.m_env.xmax)),this.m_hashCode=b(this.m_hashCode,fe(this.m_env.ymin)),this.m_hashCode=b(this.m_hashCode,fe(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return!(this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR)&&(this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR))}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const lu=new Map;function gu(e){if(lu.has(e.getHashCode()))return lu.get(e.getHashCode())}function uu(e,t){return lu.set(e.getHashCode(),t),t}let cu,_u,du;function pu(){return cu||(cu=Yg(mc(),lc())),cu}function fu(){return _u||(_u=pu().getInverse()),_u}function xu(){return du||(du=Ic.unit(9001)),du}function yu(e){return null!==kc(Ic.coordsys(e)).get()}const Pu=new Map;function Eu(e){if(Pu.has(e))return Pu.get(e);{const t=yu(e);return Pu.set(e,t),t}}function Su(e){return!1}function Cu(e){const t=kc(e),s=e.getCode();if(s>0){const e=Iu(s);if(e)return e}const n=e.getName();let r=su.get(n);if(r){const t=r.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}const i=new qg(t.release());if(s>0)return i.setCached(),tu.set(s,new WeakRef(i)),su.set(n,new WeakRef(i)),i;const o=_l(e,0,!1);if(r=nu.get(o),r){const e=r.deref();if(e)return e}return i.setCached(),nu.set(o,new WeakRef(i)),i}function Iu(e){const t=tu.get(e);if(t)return t.deref()}class bu extends ns{constructor(e){return void 0===e?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof e?(super(),this.m_factor=e,void(this.m_wkid=0)):(super(e),void(e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=xu())))}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const wu=["0","1","2","3","4","5","6","7","8","9","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"];function vu(e,t,s){const n=N(t,"R");let r=0,i=0;for(let o=0;o<t;o++){let s=e[r]>>i&31;if(i+=5,i>31){const t=37-i;s&=(1<<t)-1,i-=32,r++,s|=(e[r]&(1<<i)-1)<<t}const a=wu[s];n[t-1-o]=a}return s>t?n.push(..."0".repeat(s-t)):s<t&&(n.length=s),n.join("")}function Nu(e,t,s,n,r){h(n>>5<r.length);let i=t,o=s;for(let a=n;a>=0;a-=2){const t=31&a,s=.5*(o+i);e>=s?(r[a>>5]|=1<<t,i=s):o=s}}let Tu=new Set;const Gu=2147483645n,Du=9007199254740990n,Vu="operation is not supported for unknown coordinate systems";var Fu;function ku(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function Hu(e,t,s){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-s),e.e2=s*(2-s),e.flattening=s}function Au(e){if(Ic)return;Uc(e);const t=Tu;Tu=null,t.forEach(e=>{const t=e.deref();t&&t.attachToPe()})}function Mu(e){Mc(e)}function Uu(){return!!Ic}function qu(){return!!Hc}function Bu(){return!!Ic||!!Hc}function Ou(e,t,s){return h(Bu()),dc(e,void 0===t?0:t,null,!1)}function Ru(e,t){h(Bu());const s=new oc;let n;return Uu()?(n=au(e),s.setHorzProj_(n),s.m_vertcs=null,s.m_userWKID=n.getLatestID()):(n=Ac(e),s.m_unit=n.isPCS?new bu(n.metersOrRadiansPerUnit):new os(n.metersOrRadiansPerUnit)),uc(s.m_precisionDescriptor,n,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=e,s.calculateHashCode(),s.initDbgName(),s}function Yu(e,t,s,n,r=!0){let i=null;return t&&(i=Fh(t,r)),Xu(e,i,s,n,r)}function Xu(e,t,n,r,i){e||s("!PE_coord_sys");const o=new oc;let a;return a=i?ru(e):new qg(e,!1),uc(o.m_precisionDescriptor,a,t,r),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=t,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Lu(e,t,n=!1){3===e.getCoordinateSystemType()&&s("image spatial reference cannot be altered");const r=new oc,i=e;return r.m_peCoordSysVal=i.m_peCoordSysVal,r.m_vertcs=i.m_vertcs,r.m_unit=i.m_unit,r.m_precisionDescriptor.assign(t),r.m_localZToXYFactor=i.m_localZToXYFactor,(Number.isNaN(r.m_precisionDescriptor.m_falseX)||Number.isNaN(r.m_precisionDescriptor.m_falseY))&&(r.m_precisionDescriptor.m_falseX=i.m_precisionDescriptor.m_falseX,r.m_precisionDescriptor.m_falseY=i.m_precisionDescriptor.m_falseY),r.m_precisionDescriptor.snapPrecision(),r.m_precisionDescriptor.fixTolerance(),r.m_userWKID=i.m_userWKID,r.m_precisionDescriptor.equals(i.m_precisionDescriptor)?r.m_bDefaultDescriptor=i.m_bDefaultDescriptor:r.m_bDefaultDescriptor=!1,n&&(r.m_bDefaultDescriptor=!0),r.calculateHashCode(),r.initDbgName(),r}function zu(e,t,s){return{}}function Wu(e,t,n){void 0===t&&(t=1),(t<=0||!Number.isFinite(t))&&s(""),e||1===t||s("null Unit has to have z_to_xy_factor equal to 1");const r=new oc;r.m_unit=e;const i=e||new bu(9001);return _c(r.m_precisionDescriptor,i,null,1),r.m_bDefaultDescriptor=!0,Number.isNaN(r.m_precisionDescriptor.m_falseX)&&s("NAN false X/Y are not allowed here"),r.m_localZToXYFactor=t,r.calculateHashCode(),r.initDbgName(),r}function ju(e,t){return e.snapGeometry(t)}function Zu(e){const t=e.getCoordinateSystemType();return 1===t?e:(3===t&&h(0),e.getGCS())}function Ku(e){return h(Bu()),qu()?Bc(e):Eu(e)}function Qu(s){if(Uu()){const r={stack:[],error:void 0,hasError:!1};try{return null!==e(r,Ic.fromString(bc.PE_TYPE_COORDSYS,s,!0),!1)}catch(n){r.error=n,r.hasError=!0}finally{t(r)}}try{return Ac(s),!0}catch(r){}return!1}let Ju;function $u(){return Ju||(Ju=(()=>{const e=Math.trunc(Math.random()*re()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})()),Ju}!function(e){e[e.utmDefault=0]="utmDefault",e[e.utmNorthSouth=1]="utmNorthSouth"}(Fu||(Fu={}));let ec=0;function tc(e=""){let t=`${$u()}${ec++}`;return""!==e&&(t+=`|${e}`),t}function sc(e){return e.startsWith($u())}let nc,rc,ic,oc=class e{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 ac;m_hashCode=0;m_bDefaultDescriptor=!1;destroy(){mu(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():o("SpatialReference.destroy")}constructor(){gc(this.m_precisionDescriptor),Tu&&Tu.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ou(this.m_userWKID):Ru(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(1===this.getCoordinateSystemType())return Yg(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;const s=this.getGCS(),n=this;t=e?Yg(n,s,null):Yg(s,n,null);const r=t,i=e?this.m_srToGcs:this.m_gcsToSr;return i||(e?this.m_srToGcs=r:this.m_gcsToSr=r,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal();const t=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();e=b(e,t),this.m_hashCode=b(e,s)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){if(this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType())return 0;return this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const e=this.getPECoordSys();if(e){switch(e.getType()){case bc.PE_TYPE_GEOGCS:return 1;case bc.PE_TYPE_PROJCS:return 2;default:return 0}}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof bu)return 2;if(this.m_unit instanceof os)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 _("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return _("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){const e=this.getPECoordSys();return e?pl(e):this.m_userWKT??""}getTextExtended(e){const t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?dl(null,t,this.getPEVerticalCoordSys()):pl(t,e):this.m_userWKT??""}getText2(e=-1){const t=this.getPECoordSys();return t?fl(t,e):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof bu?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof os?.001/(Ac(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):(d("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?xl():""}getVerticalUnit(){return _("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)d(Vu);else{if(1===e)return this;3===e&&d("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===mc()||this===hc())t=lc();else{h(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||o(""),t=Yu(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(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(0===e.length)return 0;e.length>t.length&&s("coordsSrc.size() > coordsDst.size()");const n=this.getCoordinateSystemType();if(0===n&&d(Vu),1===n)return V(t,e,e.length),e.length;h(this.m_peCoordSysVal);const r=this.getSRToGCSTransform();return(new qm).transform(r,e,e.length,t)}toGeohash(e,t=8){const s=e.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=v(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=v(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*t,r=new Uint32Array(4);Nu(s.x,-180,180,n-1,r),Nu(s.y,-90,90,n-2,r);return vu(r,t,t)}isPannable(){const e=this.getCoordinateSystemType();return 0!==e&&3!==e&&(h(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||s("!is_pannable"),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||s("!is_pannable"),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const e=this.getCoordinateSystemType();1!==e&&2!==e&&s("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),h(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(Uu()||p("cannot query precision descriptor"),h(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{const t=this.getCoordinateSystemType();0===t?_c(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===t?_("image cs"):uc(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}horizontalEqual(e){return Mg(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return null!==this.m_vertcs==(null!==e.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs))}equals(e){const t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t))return!1;if(!t.m_peCoordSysVal){if(h(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==t.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(t.m_unit))return!1;if(this.m_localZToXYFactor!==t.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;h(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){const t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,s=t.ymin}let n=t.m_precisionDescriptor.m_falseX,r=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(n)){const e=t.m_peCoordSysVal.getDomainXY();n=e.xmin,r=e.ymin}return e===n&&s===r}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;const s=this.getCoordinateSystemType(),n=e.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!t||this.getZToXYFactor()===e.getZToXYFactor())&&(!this.getUnit()||!e.getUnit()||this.getUnit().equals(e.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===e.getUnit()||(!t||this.getZToXYFactor()===e.getZToXYFactor())&&this.getUnit().equals(e.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(e);if(Ug(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(null!==this.m_vertcs==(null!==e.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return h(0),!1}equalVerticalVCS(e){return h(0),!1}convergenceAngle(e){return h(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||o("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return h(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&s(Vu)}getPrimeMeridian(){return this.throwIfLocal(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return 1e3*this.getUnitsPerMillimeter()}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const e=new ac;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=Lu(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();Hu(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&d(""),h(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.getAreaOfUse();return null===e?new ss:new ss({geom:e.clone(),sr:Ou(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),h(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const t=e.getGeometryType();if(f(t))return this.snapMultiVertex_(e);if(t===r.enumPoint)return this.snapPoint_(e);if(t===r.enumEnvelope)return this.snapEnvelope_(e);if(i(t))return this.snapSegment_(e);if(t===r.enumGeometryCollection){const t=e;let s=!1;for(let e=0,n=t.getGeometryCount();e<n;++e)s=this.snapGeometry(t.getGeometry(e))||s;return s}o("what else?")}snapMultiVertex_(e){if(h(!e.isEmpty()),h(2!==this.m_precisionDescriptor.getPrecision()),a(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const t=e.getImpl(),s=t.getDescription();let n=!1;for(let r=0,i=s.getAttributeCount();r<i;r++){const e=s.getSemantics(r),i=t.getAttributeStreamRef(e);n=this.snapAttributes(e,i,0,t.getPointCount())||n}return n&&t.notifyModifiedFlags(2001),n}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){h(!e.isEmpty()),h(2!==this.m_precisionDescriptor.getPrecision());const t=new ac;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new T;n.x=pc(s.x,t.getFalseX(),t.getGridUnitsXY()),n.y=pc(s.y,t.getFalseY(),t.getGridUnitsXY());let r=!n.equals(s);const i=e.getEndXY(),o=new T;o.x=pc(i.x,t.getFalseX(),t.getGridUnitsXY()),o.y=pc(i.y,t.getFalseY(),t.getGridUnitsXY()),r||=!o.equals(i),r&&e.changeEndPoints2D(n,o);const a=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=pc(i,s,n),a=!F(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=pc(i,s,n),a=!F(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let m=r?1:0;return e.hasAttribute(1)&&(m|=a(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(m|=a(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!m}snapGeometryWithCurves_(e){h(!e.isEmpty()),h(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new Ve;let n=0;for(let r=0,i=e.getPathCount();r<i;++r){const i=e.getSegmentCountPath(r);if(0===i){if(t.addPath(e,r,!0),1===t.getPathSize(r)){const e=new pt;t.getPointByVal(t.getPointCount()-1,e),n|=this.snapGeometry(e)?1:0,t.setPointByVal(t.getPointCount()-1,e)}continue}const o=e.isClosedPath(r);for(let a=0,m=o?i-1:i;a<m;++a)e.getSegmentFromPath(r,a,s,!1),n|=this.snapGeometry(s.get())?1:0,t.addSegment(s.get(),0===a);o&&(e.getSegmentFromPath(r,i-1,s,!1),n|=this.snapGeometry(s.get())?1:0,1===i?t.addPathFromClosedSegment(s.get(),!1):t.closeLastPathWithSegment(s.get()))}return n&&t.copyTo(e),!!n}snapAttributes(t,s,n,r){let i=!1;const o=new ac;if(this.queryPrecisionDescriptor(o),0===t){const t=s;for(let s=n;s<r;s++){const n=t.read(2*s),r=e.s_SnapValue(n,o.getFalseX(),o.getGridUnitsXY()),a=t.read(2*s+1),m=e.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());i=i||r!==n||m!==a,i&&(t.write(2*s,r),t.write(2*s+1,m))}}else if(1===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseZ(),o.getGridUnitsZ());i=i||!F(r,n),i&&t.write(s,r)}}else if(2===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseM(),o.getGridUnitsM());i=i||!F(r,n),i&&t.write(s,r)}}return i}static s_SnapValue(e,t,s){return k((e-t)*s)/s+t}};class ac{m_falseX;m_falseY;m_unitsXY;m_falseZ;m_unitsZ;m_falseM;m_unitsM;m_toleranceXY;m_toleranceZ;m_toleranceM;m_precision;constructor(){const e=Du,t=1e-4,s=.001,n=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(e)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let e=7777,t=7777;return t=b(t,this.m_falseM),t=b(t,this.m_unitsM),e=b(e,this.m_unitsXY),t=b(t,this.m_toleranceXY),e=b(e,this.m_falseZ),t=b(t,this.m_toleranceZ),e=b(e,this.m_unitsZ),t=b(t,this.m_toleranceM),e=b(e,this.m_precision),b(e,t)}clone(){const e=new ac;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(2===this.m_precision)return 0;switch(e){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){const e=new Wt;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{const t=Number(ac.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(){const e=new A;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{const t=Number(ac.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(){const e=new A;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{const t=Number(ac.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&&s("tol < 0"),Number.isFinite(t)||s("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:s("cannot set tolerance for this attribute")}}setGridParams(e,t,n){Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)||s("grid params are not finite"),n<1&&s("grid units cannot be smaller than 1.0"),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=n}setZParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||s("grid params are not finite"),t<1&&s("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)||s("grid params are not finite"),t<1&&s("grid units cannot be smaller than 1.0"),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||F(this.m_falseX,e.m_falseX)&&F(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(2===this.m_precision)return;const e=(e,t,s,n)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const r=Number(e)/s;return Math.trunc((t+r-t)*s)>e&&(s=e/(t+r-t)),Math.max(1,s)},t=Number(0===this.m_precision?Gu:Du);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const e=(e,t,s,n)=>{if(s<1)return!1;if(!Number.isFinite(t)||!Number.isFinite(s))return!1;if(!n)return!0;const r=Number(e)/s;return!(BigInt((t+r-t)*s)>e)},t=0===this.m_precision?Gu:Du;return!!e(t,this.m_falseX,this.m_unitsXY,!0)&&(!!e(t,this.m_falseY,this.m_unitsXY,!0)&&(!!e(t,this.m_falseZ,this.m_unitsZ,!1)&&!!e(t,this.m_falseM,this.m_unitsM,!1)))}fixTolerance(){2!==this.m_precision&&(this.m_toleranceXY=Math.max(2/this.m_unitsXY,this.m_toleranceXY),this.m_toleranceZ=Math.max(2/this.m_unitsZ,this.m_toleranceZ),this.m_toleranceM=Math.max(2/this.m_unitsM,this.m_toleranceM),(Number.isNaN(this.m_falseX)||Number.isNaN(this.m_falseY))&&(this.m_falseX=this.m_falseY=Number.NaN))}equalsWithoutFalseXY(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,s){}setBestMDomainFromMRange(e,t,s){}}function mc(){return(!nc||Uu()&&null===nc.getPECoordSys())&&(nc=dc(3857,0,null,!0)),nc}function hc(){return(!rc||Uu()&&null===rc.getPECoordSys())&&(rc=dc(102100,0,null,!0)),rc}function lc(){return(!ic||Uu()&&null===ic.getPECoordSys())&&(ic=dc(4326,0,null,!0)),ic}function gc(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=100*q(),e.m_toleranceZ=100*q(),e.m_toleranceM=100*q(),e.m_precision=2}function uc(e,t,n,r){const i=t instanceof qg;gc(e),e.m_precision=r,e.m_falseX=Number.NaN,e.m_falseY=Number.NaN;const o=1e-4,a=.001,m=i?t.m_csType:t.isPCS?2:1;if(1===m){const s=(0===r?1/18e5:1e-9)*(i?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180);e.m_unitsXY=1/s}else if(2===m){const s=(0===r?a:o)*(i?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit);e.m_unitsXY=1/s}else s("unrecognized cs type");e.m_falseM=-1e5,e.m_unitsM=1/(0===r?a:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let h=0,l=0;0!==r&&1!==r||(h=2/e.m_unitsXY,l=2/e.m_unitsM),e.m_toleranceXY=Math.max(h,i?t.getUnitsPerMillimeter():2===m?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(a,l),cc(e,n)}function cc(e,t){const s=1e-4,n=.001;if(e.m_falseZ=-1e5,t){const r=(0===e.m_precision?n:s)*t.getOneMeter();e.m_unitsZ=1/r}else e.m_unitsZ=1/(0===e.m_precision?n:s);e.m_unitsZ=Math.max(1,e.m_unitsZ);let r=0;0!==e.m_precision&&1!==e.m_precision||(r=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*n:n,r)}function _c(e,t,s,n){gc(e),e.m_precision=n;const r=0===n?Gu:Du,i=1e-4,o=.001;let a=1,m=1,h=.001;t&&(m=t.getUnitToBaseFactor()),t&&1===t.getUnitType()?(a=400*Math.PI/180,h=8.983152841195215e-9*Math.PI/180/m):(a=(0===n?o:i)*Number(r)*.5,h=o/m),a/=m,e.m_falseX=-a,e.m_falseY=-a,e.m_unitsXY=Number(r)/(2*a),e.m_falseM=-1e5,e.m_unitsM=1/(0===n?o:i),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let l=0,g=0;0!==e.m_precision&&1!==e.m_precision||(g=2/e.m_unitsM,l=2/e.m_unitsXY),e.m_toleranceXY=Math.max(l,h),e.m_toleranceM=Math.max(o,g),cc(e,s)}function dc(e,t,s,n){if(!n&&t<=0){if(3857===e)return mc();if(102100===e)return hc();if(4326===e)return lc()}const r=new oc;let i,o=null;return Uu()?(i=iu(e),t>0?o=null:t=0,r.setHorzProj_(i),r.m_vertcs=o):(i=Ac(e),r.m_unit=i.isPCS?new bu(i.metersOrRadiansPerUnit):new os(i.metersOrRadiansPerUnit)),uc(r.m_precisionDescriptor,i,o,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=e,r.calculateHashCode(),r.initDbgName(),r}function pc(e,t,s){return k((e-t)*s)/s+t}let fc=null;const xc=3552713678800501e-30;function yc(e,t,s){return e===t||Math.abs(e-t)<=s*(1+(Math.abs(e)+Math.abs(t))/2)}function Pc(e,t){return yc(e,t,xc)}function Ec(e,t){return 0===e||Math.abs(e)<=t}function Sc(e){return Ec(e,xc)}let Cc,Ic,bc,wc,vc,Nc,Tc,Gc,Dc,Vc,Fc;function kc(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){const e=this._this;return this._this=null,e}}}let Hc=null;function Ac(e){h(Hc);const t=Hc(e);return t.semiMajor=t.isPCS?Number.NaN:Yc(e),t}function Mc(e){Hc=e,h(Hc)}function Uc(e){const t=e;Ic=t.PeFactory,h(Ic),Fc=t.PeGCSExtent,h(Fc),Dc=t.PeLineType,h(Dc),Vc=t.PeMath,h(Vc),Cc=t.PeDouble,h(Cc),bc=t.PeDefs,h(bc),wc=t.PeCSTransformations,h(wc),vc=t.PeGTTransformations,h(vc),Nc=t.PePCSInfo,h(Nc),Tc=t.PeGTlistExtended,h(Tc),Ic.initialize(),Gc=t.PeGTlistExtendedEntry,h(Gc),bc.PE_TYPE_ANGUNIT=512,bc.PE_STR_AUTH_ALL=2,Nc.PE_POLE_LINE_STRAIGHT=2,Nc.PE_POLE_LINE_CURVED=3,bc.PE_PARM_LAM0=2,bc.PE_PARM_PHI0=6,bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,bc.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,bc.PE_PRJ_ALBERS=43007,bc.PE_PRJ_CYLINDRICAL_EQAREA=43034,bc.PE_TYPE_VERTCS=8,bc.PE_LINETYPE_GEODESIC=0,bc.PE_LINETYPE_LOXODROME=1,bc.PE_LINETYPE_GREAT_ELLIPTIC=2,bc.PE_LINETYPE_NORMAL_SECTION=3,Tc.PE_GTLIST_OPTS_USABLE=1,Hc=null}function qc(e,t,s,n){return t<=0?(s[0]=0,n[0]=0,!1):(s[0]=t,n[0]=t,!0)}function Bc(e){h(qu());return!!Hc(e).isPCS||Oc(e)}function Oc(e){return Ic&&d("pe has been loaded. no-pe methods should not be used at this point."),fc||Xc(),fc.has(e)}const Rc=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Yc(e){if(Ic&&d("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof e){const t=e.match(Rc);t&&2===t.length||s("bad gcs wkt");const n=Number.parseFloat(t[1]);return Number.isFinite(n)||s("bad gcs wkt"),n}return fc||Xc(),fc.has(e)||d("gcs wkid not found"),fc.get(e)}function Xc(){fc=new Map;for(const e in rs){const t=Number.parseFloat(e),s=rs[e];if(Array.isArray(s))for(const e of s)fc.set(e,t);else fc.set(s,t)}is()}function Lc(e,t){const s=Ic.geogtran(e);s||C(e);return new Kc(s,t)}function zc(e,t){const s=Ic.fromString(bc.PE_TYPE_GEOGTRAN,e);s||P(e);return new Kc(s,t)}function Wc(e,t){return new Kc(e,t)}const jc=w(0),Zc=w(1);class Kc{m_geogTranWrapper;m_hashCode;m_bInverted;constructor(e,t){if(e instanceof Kc)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=b(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc));this.m_geogTranWrapper=new Uh(e),this.m_bInverted=t,this.m_hashCode=b(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===e)return this.m_geogTranWrapper.getGeogtran().toString();{const t=0===e?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=bc.PE_STR_FMT_WKT2;return-1!==e&&(t|=0===e?bc.PE_STR_AUTH_TOP:bc.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 Kc(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){const t=e;return t===this||this.m_bInverted===t.m_bInverted&&(this.GetPeGeogtran()===t.GetPeGeogtran()||this.getID()===t.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Qc(s,n,r,i,o){const a=s.getGCS(),m=n.getGCS(),l=a.getPECoordSys(),g=m.getPECoordSys();let u=null;if(!r.isEmpty()){const e=r.clone();if(!e.isEmpty()&&2===s.getCoordinateSystemType()){let t=new dt({env2D:e});const n=Yg(s,a,null);t=(new qm).execute(t,n,null),t.queryEnvelope(e)}if(!e.isEmpty()){const t=l.getPrimem().getLongitude(),s=l.getUnit().getUnitFactor();u=new Fc(e.xmin,e.ymin,e.xmax,e.ymax,t,s)}}let c=i;c>=re()&&(c=0);const _=[];let d=Tc.PE_GTLIST_OPTS_COMMON;o||(d&=~Tc.PE_GTLIST_OPTS_USABLE);for(let f=0;f<2;f++){const s={stack:[],error:void 0,hasError:!1};try{_.length=0;const t=Tc.getGTlist(l,g,2,d,u,c);if(null==t||0===t.length)break;e(s,{[Symbol.dispose](){Gc.destroy(t)}},!1);let n=!1;for(const e of t){const t=$c(e);if(h(t),o&&t.referencesMissingData())n=!0,c=0;else if(_.push(t),_.length===i)break}if(!n)break}catch(p){s.error=p,s.hasError=!0}finally{t(s)}}return u&&u.destroy(),_}function Jc(){return new e_([],null,null,null)}function $c(e){const t=new t_,s=e.getSteps();if(s){const n=e.getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection();let r;const i=n[e].getGeogtran().getCode();if(i>=0)r=Ic.geogtran(i);else{const t=n[e].getGeogtran().toString(bc.PE_STR_FMT_WKT);r=Ic.fromString(bc.PE_TYPE_GEOGTRAN,t)}if(null==r)return null;const o=Wc(r,s);t.add(o)}return t.create()}return null}class e_{m_bReadOnly=!0;m_transforms;m_inputSr;m_outputSr;m_name="";m_fastTrack=-1;m_bNameIsSet=!1;constructor(e,t,s,n){this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=s,this.m_outputSr=n}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=b(e,this.m_transforms[t].getHashCode());return e}equals(e){return h(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return h(0),!1}validateTransformation(e,t){return h(0),!1}nameIsSet(){return h(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&I(""),this.m_transforms[e]}getInverse(){const e=new t_;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,s){if(0===this.count())return;let n=this.m_inputSr,r=this.m_outputSr;if(e&&(r=M(n,n=r)),0===this.m_transforms.length)return void qh(n,null,r,null,t,null,s);let i=this.m_fastTrack;if(1===i)return void it(e,this.m_transforms,n=>{Xh(n.getWrapper(),e!==n.isInverted(),t,null,s)});const o=Mh();-1===i&&o.initFromGcsAndVcs(n,null);const a=Mh();let m=e?this.m_transforms.length-1:0;const h=e?-1:1;for(let g=0,u=this.m_transforms.length;g<u;g++,m+=h){if(0===g){const r=this.m_transforms[m];Bh(n.getPECoordSys(),null,r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}else{const n=this.m_transforms[m-h],r=this.m_transforms[m];Rh(o,n.getWrapper(),e!==n.isInverted(),r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}const r=this.m_transforms[m];Yh(o,r.getWrapper(),e!==r.isInverted(),t,null,s,a),o.assign(a)}const l=this.m_transforms[m-h];Oh(o,l.getWrapper(),e!==l.isInverted(),r,null,t,null,s),-1===i&&(a.initFromGcsAndVcs(r,null),o.equals(a)||(i=0)),this.m_fastTrack=0===i?0:1}}class t_{m_transforms=[];m_inputGCS=null;m_outputGCS=null;m_name="";m_bNameIsSet=!1;getInputSpatialReference(){return null!==this.m_inputGCS?this.m_inputGCS:this.count()>0?this.m_transforms[0].getInputSpatialReference():null}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&I(""),this.m_transforms[e]}setStep(e,t){h(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let s=e.count()-1;s>=0;--s)this.add(e.getStep(s).getInverse());else for(let s=0;s<e.count();++s)this.add(e.getStep(s))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){h(0)}create(){const e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),s=new e_(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return s.m_bReadOnly=!0,this.clear(),s}}const s_=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:oc,SpatialReferencePrecisionDescriptor:ac,create:Ou,createFromWKT:Ru,createImplFromPe:Yu,createLocal:Wu,createWithNewPrecision:Lu,createWithNewVCS:zu,getGCS:Zu,getTempName:tc,hasNoPe:qu,hasPe:Uu,injectNoPe:Mu,injectPe:Au,isInitialized:Bu,isTempName:sc,isValidWkid:Ku,isValidWkt:Qu,makeSpheroidData:ku,snapGeometry:ju,webMercator:mc,webMercator102100:hc,wgs84:lc},Symbol.toStringTag,{value:"Module"}));export{ku as $,Hr as A,Kh as B,fa as C,wm as D,Fa as E,la as F,Zn as G,Ko as H,t_ as I,Lc as J,zc as K,Jc as L,Vc as M,Om as N,qm as O,eu as P,Al as Q,Rm as R,Wu as S,Ka as T,as as U,Ag as V,ch as W,Hl as X,Pc as Y,Cc as Z,Dc as _,Yg as a,uh as a0,Lm as a1,zm as a2,Ym as a3,Xm as a4,_h as a5,ds as a6,Wl as a7,hg as a8,cs as a9,tn as aA,sn as aB,Rs as aC,tc as aD,Ru as aE,Ic as aF,zl as aG,Hs as aH,Qu as aI,Ku as aJ,kh as aK,Ou as aL,ac as aM,Lu as aN,ss as aO,s_ as aP,Xl as aa,ql as ab,Wo as ac,Ps as ad,wc as ae,Tl as af,Zl as ag,qs as ah,Is as ai,vs as aj,Tm as ak,Us as al,Cs as am,jl as an,bc as ao,Zu as ap,cl as aq,fg as ar,sr as as,ir as at,zh as au,Wh as av,ma as aw,Ya as ax,Ha as ay,nm as az,Rg as b,Og as c,Lg as d,Qg as e,Em as f,Lo as g,Uu as h,Mu as i,er as j,_a as k,da as l,Wg as m,aa as n,Sa as o,ya as p,zg as q,pa as r,ju as s,al as t,Ma as u,im as v,mm as w,jh as x,ul as y,Lh as z};