@arcgis/core 5.1.0-next.74 → 5.1.0-next.76

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 (254) hide show
  1. package/arcade/ArcadePortal.js +1 -1
  2. package/arcade/functions/aiServices.js +1 -1
  3. package/arcade/functions/featuresetbase.js +1 -1
  4. package/arcade/functions/geomasync.js +1 -1
  5. package/arcade/functions/knowledgegraph.js +1 -1
  6. package/arcade/functions/string.js +1 -1
  7. package/arcade/languageUtils.js +1 -1
  8. package/arcade/portalUtils.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +2 -0
  11. package/assets/esri/core/workers/chunks/09630888267cde87654f.js +1 -0
  12. package/assets/esri/core/workers/chunks/0fa207c68dfd7ddee160.js +1 -0
  13. package/assets/esri/core/workers/chunks/146424b5717d0a645ee1.js +1 -0
  14. package/assets/esri/core/workers/chunks/{d00dafad202450e6ee2e.js → 14eb2cc8e2ad6d8d03fd.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1765dfeac20e34ce25b7.js +1 -0
  16. package/assets/esri/core/workers/chunks/176dd195f77b98cb0b0f.js +1 -0
  17. package/assets/esri/core/workers/chunks/1906416c84bab369bbd6.js +1 -0
  18. package/assets/esri/core/workers/chunks/{b98c24229463029504e8.js → 1f6b7626f333809837ef.js} +1 -1
  19. package/assets/esri/core/workers/chunks/1ff3c15a51c4dc991806.js +1 -0
  20. package/assets/esri/core/workers/chunks/2a2e97918524e0f436d7.js +1 -0
  21. package/assets/esri/core/workers/chunks/2b0b398180ed98c2c84c.js +1 -0
  22. package/assets/esri/core/workers/chunks/{bab23b905678e42815e5.js → 312036c89a6a09bb06c2.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{37091cf498a16ccad7ff.js → 330b47ac0759c3c35cc5.js} +1 -1
  24. package/assets/esri/core/workers/chunks/34b6b5dd415c68f0b0d1.js +1 -0
  25. package/assets/esri/core/workers/chunks/{a270960d80d8344dd75f.js → 34ea3ed78041437a8fc8.js} +1 -1
  26. package/assets/esri/core/workers/chunks/384c235d36f32769e32b.js +1 -0
  27. package/assets/esri/core/workers/chunks/3a183259805638c25363.js +1 -0
  28. package/assets/esri/core/workers/chunks/{deaca3cd202851ecf9c2.js → 3cce9dad8ee0e4971d50.js} +1 -1
  29. package/assets/esri/core/workers/chunks/3efbb684c0409955186d.js +1 -0
  30. package/assets/esri/core/workers/chunks/40d251b6b42a41d68bd2.js +1 -0
  31. package/assets/esri/core/workers/chunks/42336e0d1ef88737b078.js +1 -0
  32. package/assets/esri/core/workers/chunks/47b3a5213539548ff3a6.js +1 -0
  33. package/assets/esri/core/workers/chunks/4a23b27bfbcfa08fd9a7.js +1 -0
  34. package/assets/esri/core/workers/chunks/52b3a11c962810bc6dbe.js +1 -0
  35. package/assets/esri/core/workers/chunks/53750e85f3128993a43a.js +1 -0
  36. package/assets/esri/core/workers/chunks/{4bbe684050b3b04681d0.js → 537fe2522dff1e6ce03b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/55fd201ca5e10c6e4761.js +1 -0
  38. package/assets/esri/core/workers/chunks/56941e8bbd2d49bf2656.js +1 -0
  39. package/assets/esri/core/workers/chunks/5d8e944b192aad4cf986.js +1 -0
  40. package/assets/esri/core/workers/chunks/{5476c2f7b83f4ccd0335.js → 5e1b847b116d21908a54.js} +1 -1
  41. package/assets/esri/core/workers/chunks/5ed8d8b5336c81fbcda3.js +1 -0
  42. package/assets/esri/core/workers/chunks/60915a3708a34da1977e.js +1 -0
  43. package/assets/esri/core/workers/chunks/61c523dd9d8027922465.js +1 -0
  44. package/assets/esri/core/workers/chunks/65c61171e6c6be5c5c2f.js +1 -0
  45. package/assets/esri/core/workers/chunks/6a3d207308b29651f397.js +1 -0
  46. package/assets/esri/core/workers/chunks/6c35583707f5c339ee99.js +1 -0
  47. package/assets/esri/core/workers/chunks/702e8468836863abd81b.js +1 -0
  48. package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +1 -0
  49. package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +1 -0
  50. package/assets/esri/core/workers/chunks/7b6c8be59ed87e386aa4.js +1 -0
  51. package/assets/esri/core/workers/chunks/7c820c5f6f05480d5050.js +1 -0
  52. package/assets/esri/core/workers/chunks/80f4f686ce403cb2693f.js +1 -0
  53. package/assets/esri/core/workers/chunks/852f4cd514008fee5a55.js +1 -0
  54. package/assets/esri/core/workers/chunks/8a3bff0f58483c1665f9.js +1 -0
  55. package/assets/esri/core/workers/chunks/8b046e28f879079caada.js +1 -0
  56. package/assets/esri/core/workers/chunks/8d738e9acc2f222235ea.js +1 -0
  57. package/assets/esri/core/workers/chunks/9103eb0b9078019d3a26.js +1 -0
  58. package/assets/esri/core/workers/chunks/915e2711d3a2cfa402b2.js +1 -0
  59. package/assets/esri/core/workers/chunks/91f9e0e3662d4bf9f163.js +1 -0
  60. package/assets/esri/core/workers/chunks/99c161fecae710b53b40.js +1 -0
  61. package/assets/esri/core/workers/chunks/99d298d0039c536fcf3e.js +1 -0
  62. package/assets/esri/core/workers/chunks/9a5ef33d99a8f89956ff.js +1 -0
  63. package/assets/esri/core/workers/chunks/9d10db72e342fe63c981.js +1 -0
  64. package/assets/esri/core/workers/chunks/{a36761e3122f70fbb3c9.js → 9d6491f996eeb0c646ed.js} +1 -1
  65. package/assets/esri/core/workers/chunks/a015c2f54eb91e43a1f4.js +1 -0
  66. package/assets/esri/core/workers/chunks/a242ec19a7508de436da.js +1 -0
  67. package/assets/esri/core/workers/chunks/a320998f18922a35899f.js +1 -0
  68. package/assets/esri/core/workers/chunks/a7f9f478bd1493fc3c76.js +1 -0
  69. package/assets/esri/core/workers/chunks/aac6a57edd7494125204.js +1 -0
  70. package/assets/esri/core/workers/chunks/b73c146d3e550eaf07eb.js +1 -0
  71. package/assets/esri/core/workers/chunks/b7af0e6b9aadbcaf6a0b.js +1 -0
  72. package/assets/esri/core/workers/chunks/b803e7b0d489bb628d72.js +1 -0
  73. package/assets/esri/core/workers/chunks/baeb96aef03d4c566af7.js +1 -0
  74. package/assets/esri/core/workers/chunks/bc75ab48f4c7609ef09d.js +1 -0
  75. package/assets/esri/core/workers/chunks/bc78937986854e500b8e.js +1 -0
  76. package/assets/esri/core/workers/chunks/bd10d21545bca9a49de0.js +1 -0
  77. package/assets/esri/core/workers/chunks/{b905e637a67fbb7af4ae.js → bf8f603848bad4a7deb4.js} +1 -1
  78. package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +2 -0
  79. package/assets/esri/core/workers/chunks/c31ee5617c61a933cb0e.js +1 -0
  80. package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +1 -0
  81. package/assets/esri/core/workers/chunks/ce7ef7c4ca14d66d96f6.js +1 -0
  82. package/assets/esri/core/workers/chunks/{5b324e572737a308500d.js → cf14b3a44705dacefac4.js} +1 -1
  83. package/assets/esri/core/workers/chunks/d3b086eb9aa8c7d09048.js +1 -0
  84. package/assets/esri/core/workers/chunks/d55cef8199b8246fea3f.js +1 -0
  85. package/assets/esri/core/workers/chunks/d8decaee2c780e1b5e35.js +1 -0
  86. package/assets/esri/core/workers/chunks/{41809c16544ec25120fa.js → d95ffd990b3a7df69e1e.js} +1 -1
  87. package/assets/esri/core/workers/chunks/dc54d4a9fe1691862356.js +1 -0
  88. package/assets/esri/core/workers/chunks/dda2cb5c073d1e65f14f.js +1 -0
  89. package/assets/esri/core/workers/chunks/e18badd11f360cc2912b.js +1 -0
  90. package/assets/esri/core/workers/chunks/{ad064583f8a836005098.js → e262c4864dc06c43b380.js} +1 -1
  91. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +1 -0
  92. package/assets/esri/core/workers/chunks/e9c5c295b6bf10e942a4.js +1 -0
  93. package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +1 -0
  94. package/assets/esri/core/workers/chunks/{873c1b705ac3d4e6c384.js → ea97619a4470f1540b99.js} +1 -1
  95. package/assets/esri/core/workers/chunks/eaab5ac049622986e3bc.js +1 -0
  96. package/assets/esri/core/workers/chunks/edee616b6f1b5be8fd39.js +1 -0
  97. package/assets/esri/core/workers/chunks/ef0085aa743b33cb549f.js +1 -0
  98. package/assets/esri/core/workers/chunks/f0250cecb243b32cdba7.js +1 -0
  99. package/assets/esri/core/workers/chunks/f518835b2dc89a48cfb1.js +1 -0
  100. package/assets/esri/core/workers/chunks/f6c8e93ca2987e83f925.js +1 -0
  101. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -0
  102. package/assets/esri/themes/dark/main.css +1 -1
  103. package/assets/esri/themes/light/main.css +1 -1
  104. package/assets/esri/themes/light/view.css +1 -1
  105. package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
  106. package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
  107. package/chunks/MultiPathImpl.js +1 -1
  108. package/chunks/Point2D.js +1 -1
  109. package/chunks/SpatialReference.js +1 -1
  110. package/chunks/aiServices.js +1 -1
  111. package/chunks/languageUtils.js +1 -1
  112. package/config.js +1 -1
  113. package/core/workers/registry.js +1 -1
  114. package/form/elements/AttachmentElement.d.ts +15 -16
  115. package/form/elements/GroupElement.d.ts +3 -2
  116. package/form/elements/inputs/attachments/AttachmentInput.d.ts +7 -9
  117. package/form/elements/inputs/attachments/AudioInput.d.ts +6 -8
  118. package/form/elements/inputs/attachments/DocumentInput.d.ts +5 -7
  119. package/form/elements/inputs/attachments/ImageInput.d.ts +6 -8
  120. package/form/elements/inputs/attachments/Input.d.ts +2 -6
  121. package/form/elements/inputs/attachments/SignatureInput.d.ts +5 -7
  122. package/form/elements/inputs/attachments/VideoInput.d.ts +6 -8
  123. package/form/elements/inputs/attachments/types.d.ts +3 -3
  124. package/geometry/FlatGeometry.js +1 -1
  125. package/geometry/operators/projectOperator.js +1 -1
  126. package/graphic/ImageryGraphicOrigin.js +1 -1
  127. package/graphic/ImageryTileGraphicOrigin.js +1 -1
  128. package/graphic/WCSGraphicOrigin.js +1 -1
  129. package/kernel.js +1 -1
  130. package/layers/mixins/ArcGISImageService.js +1 -1
  131. package/package.json +4 -4
  132. package/popup/Features.js +1 -1
  133. package/support/revision.js +1 -1
  134. package/symbols/cim/CIMSymbolHelper.js +1 -1
  135. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  136. package/symbols/support/previewCIMSymbol.js +1 -1
  137. package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
  138. package/views/2d/engine/webgl/TextureManager.js +1 -1
  139. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  140. package/views/2d/layers/MediaLayerView2D.js +1 -1
  141. package/views/2d/layers/TileLayerView2D.js +1 -1
  142. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  143. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  144. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  145. package/views/3d/analysis/Dimension/DimensionController.js +1 -1
  146. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  147. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  148. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  149. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  150. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  151. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  152. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  153. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  154. package/views/VideoView.js +1 -1
  155. package/views/draw/DrawGraphicTool.js +1 -1
  156. package/views/draw/DrawTool.js +1 -1
  157. package/views/draw/support/Box.js +1 -1
  158. package/views/draw/support/Reshape.js +1 -1
  159. package/views/draw/support/managers/MeasurementManager.js +1 -1
  160. package/views/interactive/SegmentLabels.js +1 -1
  161. package/views/interactive/snapping/SelfSnappingEngine.js +1 -1
  162. package/views/support/GeometryWorker.js +2 -0
  163. package/views/support/GeometryWorkerHandle.js +2 -0
  164. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -3
  165. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +2 -11
  166. package/widgets/FeatureTable/support/types.d.ts +2 -1
  167. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +28 -0
  168. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
  169. package/widgets/OrientedImageryViewer.d.ts +27 -0
  170. package/widgets/Sketch/SketchViewModel.d.ts +10 -2
  171. package/widgets/Sketch/SketchViewModel.js +1 -1
  172. package/widgets/Sketch/support/ResponsiveToolbar/MeasuredContentGroup.js +1 -1
  173. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  174. package/widgets/Sketch.js +1 -1
  175. package/assets/esri/core/workers/chunks/00bae4b7e179336e0362.js +0 -1
  176. package/assets/esri/core/workers/chunks/041c372e98a6fba90b36.js +0 -1
  177. package/assets/esri/core/workers/chunks/0783890816bac45277b9.js +0 -1
  178. package/assets/esri/core/workers/chunks/07aac6245a0d1adbb2d4.js +0 -1
  179. package/assets/esri/core/workers/chunks/1286f41f245ef22b3a26.js +0 -1
  180. package/assets/esri/core/workers/chunks/12e575a6d2b008b8fc2b.js +0 -1
  181. package/assets/esri/core/workers/chunks/161d60fdac2013c15543.js +0 -1
  182. package/assets/esri/core/workers/chunks/168de44a789d1cecc1f8.js +0 -1
  183. package/assets/esri/core/workers/chunks/1d9d7915cf7449e5d468.js +0 -1
  184. package/assets/esri/core/workers/chunks/1db1656a033f3992f0d6.js +0 -1
  185. package/assets/esri/core/workers/chunks/235cb82952a18ff8d206.js +0 -1
  186. package/assets/esri/core/workers/chunks/27b80c386cebadcaca3c.js +0 -1
  187. package/assets/esri/core/workers/chunks/29d3890a5a43d934067a.js +0 -1
  188. package/assets/esri/core/workers/chunks/2f17438d215bea3ce70f.js +0 -1
  189. package/assets/esri/core/workers/chunks/356cb86606b8c674f947.js +0 -1
  190. package/assets/esri/core/workers/chunks/398e0dd2bc7e1ab84831.js +0 -1
  191. package/assets/esri/core/workers/chunks/3b1052aa30af3f6186cc.js +0 -1
  192. package/assets/esri/core/workers/chunks/3e87e3ad857d72f6ecbb.js +0 -1
  193. package/assets/esri/core/workers/chunks/42e483fde18f12da32a6.js +0 -1
  194. package/assets/esri/core/workers/chunks/43ab44d37bc0ea97ef98.js +0 -1
  195. package/assets/esri/core/workers/chunks/488ed9584b527ec47be3.js +0 -1
  196. package/assets/esri/core/workers/chunks/4ad32580e0c0699fde1f.js +0 -1
  197. package/assets/esri/core/workers/chunks/4c13869d260a902d3014.js +0 -1
  198. package/assets/esri/core/workers/chunks/54ed37ec9682ea739deb.js +0 -1
  199. package/assets/esri/core/workers/chunks/5511e640e171c294f52a.js +0 -2
  200. package/assets/esri/core/workers/chunks/55369c5bd65bcaf78da1.js +0 -1
  201. package/assets/esri/core/workers/chunks/56fd3da911c2c4511e5d.js +0 -1
  202. package/assets/esri/core/workers/chunks/59592bb25f226865e88a.js +0 -1
  203. package/assets/esri/core/workers/chunks/5d55b4449bcb24cd72b6.js +0 -1
  204. package/assets/esri/core/workers/chunks/5d8fe41a3c06ddb4094b.js +0 -1
  205. package/assets/esri/core/workers/chunks/608d707fd9d9f9088473.js +0 -1
  206. package/assets/esri/core/workers/chunks/6a21c9a4aeebe806ea39.js +0 -1
  207. package/assets/esri/core/workers/chunks/6c7ff968bd4fc816442d.js +0 -1
  208. package/assets/esri/core/workers/chunks/6d11ec355e5474b2968b.js +0 -1
  209. package/assets/esri/core/workers/chunks/6d25230dd85a4ba54c4f.js +0 -1
  210. package/assets/esri/core/workers/chunks/7027d93dc5a4595d70c6.js +0 -1
  211. package/assets/esri/core/workers/chunks/70b35b2446558d5280e3.js +0 -1
  212. package/assets/esri/core/workers/chunks/7349cb45a93e6916f115.js +0 -1
  213. package/assets/esri/core/workers/chunks/76edaeaf8fe344bb77a8.js +0 -1
  214. package/assets/esri/core/workers/chunks/76fe5b821d6b54db5721.js +0 -1
  215. package/assets/esri/core/workers/chunks/7951d93f5f15aa76f49c.js +0 -1
  216. package/assets/esri/core/workers/chunks/7a56c836c89a8b978800.js +0 -1
  217. package/assets/esri/core/workers/chunks/81d30c9062ad0120a863.js +0 -1
  218. package/assets/esri/core/workers/chunks/88c5f7c712c6b89b5109.js +0 -1
  219. package/assets/esri/core/workers/chunks/88e469b82d2594f23649.js +0 -1
  220. package/assets/esri/core/workers/chunks/8a8242e7cc7e6a9e7876.js +0 -1
  221. package/assets/esri/core/workers/chunks/9444ed8ea117861ae89b.js +0 -1
  222. package/assets/esri/core/workers/chunks/9a38fd68b02b617c45d3.js +0 -1
  223. package/assets/esri/core/workers/chunks/9be9ccce6369f67202bc.js +0 -1
  224. package/assets/esri/core/workers/chunks/a37c28e3c4a2be9fd1d5.js +0 -1
  225. package/assets/esri/core/workers/chunks/a8d7f59927bdad564141.js +0 -1
  226. package/assets/esri/core/workers/chunks/a94bd20551c1179c7ec5.js +0 -1
  227. package/assets/esri/core/workers/chunks/a9d2c83bb10b5ade0ca0.js +0 -1
  228. package/assets/esri/core/workers/chunks/abe22ae8ee0dcc9efbb7.js +0 -1
  229. package/assets/esri/core/workers/chunks/b702279c48f3009f6dd8.js +0 -1
  230. package/assets/esri/core/workers/chunks/bc887bd62579dba81e2b.js +0 -1
  231. package/assets/esri/core/workers/chunks/be0341567bb19e101a4f.js +0 -1
  232. package/assets/esri/core/workers/chunks/be1d6a571f76933dfbb0.js +0 -1
  233. package/assets/esri/core/workers/chunks/bfcdc5c315131aae34d8.js +0 -1
  234. package/assets/esri/core/workers/chunks/c0f624a2ca0d07ef8f8c.js +0 -1
  235. package/assets/esri/core/workers/chunks/c327fe276238af60fda4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c5f155fe114a2a05aaf2.js +0 -2
  237. package/assets/esri/core/workers/chunks/c61002a117dc2218d6af.js +0 -1
  238. package/assets/esri/core/workers/chunks/c804a66ef7615aa8de89.js +0 -1
  239. package/assets/esri/core/workers/chunks/cb5e4b9b4a59c2622eb5.js +0 -1
  240. package/assets/esri/core/workers/chunks/d201a5dff18a5bb467ab.js +0 -1
  241. package/assets/esri/core/workers/chunks/d21fdd67477800101f3b.js +0 -1
  242. package/assets/esri/core/workers/chunks/db588bf3256e95c977b7.js +0 -1
  243. package/assets/esri/core/workers/chunks/dfdd474fddcd1d6091ce.js +0 -1
  244. package/assets/esri/core/workers/chunks/e235ea4293d5d463acfb.js +0 -1
  245. package/assets/esri/core/workers/chunks/e43486113aaf72ac4dc1.js +0 -1
  246. package/assets/esri/core/workers/chunks/ea4c3393c5757e309a71.js +0 -1
  247. package/assets/esri/core/workers/chunks/ed216ddeb7f59f510bd0.js +0 -1
  248. package/assets/esri/core/workers/chunks/ef8886dff54063928bcb.js +0 -1
  249. package/assets/esri/core/workers/chunks/f43a63094190d2074cd0.js +0 -1
  250. package/assets/esri/core/workers/chunks/f5223ffb3be548c9b0a1.js +0 -1
  251. package/views/support/MeasurementWorker.js +0 -2
  252. package/views/support/MeasurementWorkerHandle.js +0 -2
  253. /package/assets/esri/core/workers/chunks/{5511e640e171c294f52a.js.LICENSE.txt → 07aca5ecad659d55e795.js.LICENSE.txt} +0 -0
  254. /package/assets/esri/core/workers/chunks/{c5f155fe114a2a05aaf2.js.LICENSE.txt → bfe575da727ce7c8d331.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8885,9187],{95213(t,e,s){s.d(e,{$:()=>Ct,A:()=>L,B:()=>V,C:()=>J,D:()=>N,E:()=>Ft,F:()=>q,G:()=>M,H:()=>wt,I:()=>St,J:()=>ot,K:()=>nt,L:()=>rt,M:()=>A,N:()=>ct,O:()=>l,P:()=>qt,Q:()=>vt,R:()=>Z,S:()=>B,T:()=>j,U:()=>_t,V:()=>g,W:()=>mt,X:()=>Pt,Y:()=>pt,Z:()=>ht,_:()=>At,a:()=>F,a0:()=>bt,a1:()=>Dt,a2:()=>Et,a3:()=>$,a4:()=>tt,a5:()=>It,a6:()=>W,a7:()=>S,b:()=>X,c:()=>at,d:()=>lt,e:()=>ut,f:()=>b,g:()=>it,h:()=>dt,i:()=>yt,j:()=>st,k:()=>ft,l:()=>v,m:()=>Xt,n:()=>x,o:()=>P,p:()=>D,q:()=>c,r:()=>y,s:()=>xt,t:()=>_,u:()=>E,v:()=>T,w:()=>I,x:()=>et,y:()=>z,z:()=>C});var i=s(83661),n=s(79187),r=s(55537);const o=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],a=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],h=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],m=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],u=[4,8,4,8,1],l=25;function c(){return(0,i.d)(l,Number.NaN)}let g=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return h[t]}static getPersistence(t){return m[t]}static getPersistenceSize(t){return u[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return a[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return o[t]}static isDefaultValue(t,e){return(0,i.Q)(o[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=(0,i.d)(l,Number.NaN),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,n=1,r=14;for(;s<r;s++)e&n&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),n<<=1;let o=0;for(s=0,r=this.getAttributeCount();s<r;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=o;for(let t=0;t<i;t++)this.m_defaultPointAttributes[o]=n,o++}}};var d=g;function _(){return(0,i.d)(14,0)}class p{static getInstance(){return p.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new d(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new d(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new d(t);return this.m_map.set(t,s),s}}function f(t){return p.getInstance().FindOrAdd(t)}function x(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:f(s)}function P(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:f(s)}function y(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:f(s)}function v(){return p.getInstance().GetVD2D()}function C(){return p.getInstance().GetVD3D()}function E(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}p.s_thisInstance=new p;class b{static construct(t,e,s){return new b(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new b(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new b;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,i.a)(t.x-e.x)+(0,i.a)(t.y-e.y)+(0,i.a)(t.z-e.z)}static sqrDistanceCoords(t,e,s,n,r,o){return(0,i.a)(t-n)+(0,i.a)(e-r)+(0,i.a)(s-o)}static distance(t,e){return Math.sqrt(b.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,i.G)(this.z,t.z,e)}static compareByLength(t,e,s,i){return(0,r.g)(0),0}isEqualCoords(t,e,s,i){return(0,r.g)(0),this.x===t&&this.y===e&&this.z===s}isEqualsTols(t,e,s){return(0,r.g)(0),!1}isEqualCoordsTols(t,e,s,i,n){return(0,r.g)(0),!1}static st_isEqual(t,e,s,i){return(0,r.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,s){return(0,r.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return b.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return b.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new b(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return b.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return(0,r.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,r.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,r.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,s,i=!1){return(0,r.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return(0,r.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,r.g)(0),{}}static average(t,e){return(0,r.g)(0),{}}static size(){return b.dimensions}static lerp(t,e,s){const n=new b;return(0,i.x)(t,e,s,n),n}static slerp(t,e,s){return(0,r.g)(0),{}}static compareVectors(t,e){return(0,r.g)(0),0}static selectRightHandedBasisFromNormal(t,e,s){const i=t.getUnitVector(),n=i.createAPerpendicular(),r=new b;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new b(0,0,1)),this.crossProductVector(new b(1,0,0)),this.crossProductVector(new b(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce((t,s,i)=>e[t]>e[i]?t:i,0)];return s.normalizeThis(),s}calculateAngle(t){return(0,r.g)(0),0}static crossDotSign(t,e,s){return(0,r.g)(0),0}static isBisectorRobust(t,e,s){return(0,r.g)(0),0}static compareZOrder(t,e){return(0,r.g)(0),!1}}b.dimensions=3;class D{static constructEmpty(){return new D(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,s){(0,r.g)(0)}getEnvelope2D(){return new n.Envelope2D(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new i.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,i.c)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,i.c)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,i.c)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,s,i=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}const S=-559038737;var w=g;function A(t,e,s){switch(t){case 0:return new R(e,s);case 1:return new L(e,s);case 2:return new F(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new X(e,s);default:(0,r.a)("")}}function T(t,e){const s=w.getComponentCount(t);return A(w.getPersistence(t),e*s,w.getDefaultValue(t))}function I(t,e){const s=w.getComponentCount(t);return A(w.getPersistence(t),e*s)}function N(t,e){return new F(t,e)}function q(t,e){return new X(t,e)}function M(t,e){return new L(t,e)}class Y{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>Y.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&(0,r.a)(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}getArray(){return this.m_a}equals(t,e,s,n){return this.getPersistence()===t.getPersistence()&&function(t,e,s,n,r){if(t.getPersistence()!==e.getPersistence())return!1;const o=t.getPersistence()<=1,a=t.size(),h=e.size();if(n>a||n>h)return!1;if(r)if(o){for(let o=s;o<n;o++)if(!(0,i.G)(t.read(o),e.read(o),r))return!1}else for(let i=s;i<n;i++){let s=t.read(i)-e.read(i);if(s<0&&(s=-s),s>r)return!1}else for(let i=s;i<n;i++){const s=t.read(i),n=e.read(i);if(s!==n){if(o&&Number.isNaN(s)&&Number.isNaN(n))continue;return!1}}return!0}(this,t,e,s,n)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,s,i,n,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;i&&this.checkResize(Math.max(0,a)+i),this.m_a.copyWithin(t+i,t,a>=0?a:m),this.m_a.set(h.readRange(s,i),t),n||this.reverseRange(t,i,o)}writeRange(t,e,s,i,n,o){(0,r.g)(this.getPersistence()===s.getPersistence());const a=s;if((t<0||e<0||i<0)&&(0,r.a)(),a.size()<i+e&&(0,r.a)(),0===e)return;this.size()<e+t&&this.resize(e+t);const h=a.m_a.subarray(i,i+e);!function(t,e,s,i){if((e<0||s<0)&&(0,r.a)(),0===s)return;if(1===s)return void(t[e]=i[0]);let n=i;s<i.length&&(n=i.subarray(0,s)),t.set(n,e)}(this.m_a,t,e,h)}insertAttributes(t,e,s,i){const n=w.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let i=0;i<n;i++)this.m_a[t+i]=e.getAttributeAsDbl(s,i)}insertAttributesFromPoints(t,e,s,n,o){(0,r.g)(w.getPersistence(n)===this.getPersistence());const a=w.getComponentCount(n),h=this.m_size;if(this.checkResize(Math.max(0,o)+a*s),this.m_a.copyWithin(t+a*s,t,o>=0?o:h),0===n){const n=new i.P;for(let i=t,r=0;r<s;r++,i+=2)e[r].queryXY(n),this.m_a[i]=n.x,this.m_a[i+1]=n.y}else if(1===a)for(let i=t,r=0;r<s;r++,i++)this.m_a[i]=e[r].getAttributeAsDbl(n,0);else for(let i=t,r=0;r<s;r++,i+=a)for(let t=0;t<a;t++)this.m_a[i+t]=e[r].getAttributeAsDbl(n,t)}eraseRange(t,e,s){this.m_size<t+e&&(0,r.a)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!==0)&&(0,r.a)(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let i=t,n=t+e;i<n;i+=s){let t=i,e=i+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(t,e,s){(e<t||e>s||t>s)&&(0,r.r)("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.fromArray)this.m_a=t.fromArray,this.m_size=t.size??t.fromArray.length;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,Y.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}Y.s_constructMin=2,Y.s_resizeMin=30;class X extends Y{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new X({ctor:Int8Array,copy:this})}restrictedClone(t){return new X({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class F extends Y{getPersistence(){return 2}clone(){return new F({ctor:Int32Array,copy:this})}restrictedClone(t){return new F({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,i.i)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class R extends Y{getPersistence(){return 0}clone(){return new R({ctor:Float32Array,copy:this})}restrictedClone(t){return new R({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class L extends Y{getPersistence(){return 1}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&(0,r.a)();const i=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(i,s,i)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new i.P(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let n=s,r=t,o=0;o<i;++o,++n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}else for(let n=s+i-1,r=t,o=0;o<i;++o,--n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}}queryRange(t,e,s,i,n){if((t<0||e<0)&&(0,r.a)(),!i&&(n<=0||e%n!==0)&&(0,r.a)(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+e);s.set(o)}writeRangeFromArray(t,e,s,i,n){if((t<0||e<0)&&(0,r.a)(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let o=s;e<s.length&&(o=s.subarray(0,e)),this.m_a.set(o,t)}clone(){return new L({ctor:Float64Array,copy:this})}restrictedClone(t){return new L({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}const z={partCount:0,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:0,segmentCountBezier:0};class V{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new F(0),this.m_bucketedIndices=new F(0)}static sortEx(t,e,s,i,n=32){s-e<=n?i.userSort(e,s,t):(new V).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let n=e;n<s;n++){const e=i.getValue(t.read(n));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let n=e;n<s;n++){const s=t.read(n),r=i.getValue(s),o=this.getBucket(r);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(n-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let n=e;n<s;n++){const s=this.m_bucketedIndices.read(n-e),r=i.getValue(s),o=this.getBucket(r),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let s=0,n=this.m_buckets.size();s<n;s++){const n=h;h=this.m_buckets.read(s),h>n&&i.userSort(e+n,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(V.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}V.c_maxBuckets=65536;class B{capacity(){return this.capacity_}constructor(t){this.m_buffer=new Int32Array(0),this.m_firstFree=-1,this.m_last=0,this.size_=0,this.capacity_=0,this.stride=t}size(){return this.size_}deleteElement(t){t<this.m_last?(this.m_buffer[t*this.stride]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.size_--}getField(t,e){return this.m_buffer[t*this.stride+e]}setField(t,e,s){this.m_buffer[t*this.stride+e]=s}elementToIndex(t){return t}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}t=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[t*this.stride];this.size_++;for(let e=t*this.stride;e<t*this.stride+this.stride;e++)this.m_buffer[e]=-1;return t}newElementPset(t){let e=this.m_firstFree;if(-1===e){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}e=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[e*this.stride];this.size_++;const s=e*this.stride;for(let e=0;e<t.length;e++)this.m_buffer[s+e]=t[e];return e}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.size_=0,t&&(this.m_buffer=new Int32Array(0),this.capacity_=0)}setCapacity(t){t>this.capacity_&&this.grow_(t)}swap(t,e){const s=t*this.stride,i=e*this.stride;for(let t=0;t<this.stride;t++){const e=this.m_buffer[i+t];this.m_buffer[i+t]=this.m_buffer[s+t],this.m_buffer[s+t]=e}}swapField(t,e,s){const i=this.m_buffer[this.stride*e+s];this.m_buffer[this.stride*e+s]=this.m_buffer[this.stride*t+s],this.m_buffer[this.stride*t+s]=i}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}grow_(t){null==this.m_buffer&&(this.m_buffer=new Int32Array(0));const e=this.stride*t,s=new Int32Array(e);s.set(this.m_buffer,0),this.m_buffer=s,this.capacity_=t}}class G{constructor(t,e,s){this.m_extent=new n.Envelope2D,this.m_dataExtent=new n.Envelope2D,this.m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D],this.m_elementNodes=new B(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new B(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){this.m_quadTreeNodes.deleteAll(!1),this.m_elementNodes.deleteAll(!1),this.m_data.length=0,this.m_freeData.length=0,this.reset_(t,e)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,r.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,r.g)(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,r.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,r.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>G.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new n.Envelope2D;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const r=s.length;for(let t=0;t<r;t++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const r=new n.Envelope2D;r.setCoords({env2D:t}),r.inflateCoords(e,e);const o=[],a=[];o.push(this.m_root),a.push(this.m_extent.clone());const h=(0,i.m)(n.Envelope2D,4);let m=0;for(;o.length>0;){let t=!1;const e=o.at(-1),i=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(i)){if(m+=this.getSubTreeElementCount(e),s>0&&m>=s)return s}else if(r.isIntersecting(i)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(r)&&(m++,s>0&&m>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){G.setChildExtents_(i,h);for(let t=0;t<4;t++){const s=this.getChild_(e,t);-1!==s&&this.getSubTreeElementCount_(s)>0&&r.isIntersecting(h[t])&&(o.push(s),a.push(h[t].clone()))}}}return m}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new H(this,t,e)}getIteratorForQT(){return new H(this)}getSortedIterator(t,e){return new k(this.getIterator(t,e))}getSortedIteratorForQT(){return new k(this.getIteratorForQT())}visitLeavesNearest(t,e,s,i){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.a)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,r,o,a){if(!i.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,o,a);if(!o)for(let t=r;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);const h=new n.Envelope2D;h.setCoords({env2D:i});let m,u=r;for(m=s;m<this.m_height&&this.canPushDown_(u);m++){G.setChildExtents_(h,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(u,s);-1===e&&(e=this.createChild_(u,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),u=e,h.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,m,h,u,o,r,a,-1)}insertDuplicates_(t,e,s,r,o,a,h){if(!a){if(!r.containsEnvelope(e))return-1;this.setSubTreeElementCount_(o,this.getSubTreeElementCount_(o)+1),this.setContainedSubTreeElementCount_(o,this.getContainedSubTreeElementCount_(o)+1)}const m=Math.max(e.width(),e.height());let u=-1;const l=[],c=[],g=[];l.push(o),c.push(r.clone()),g.push(s);const d=(0,i.m)(n.Envelope2D,4);for(;l.length>0;){let s=!1;const i=l.at(-1),n=c.at(-1),r=g.at(-1);if(l.pop(),c.pop(),g.pop(),r+1<this.m_height&&this.canPushDown_(i)&&m<=Math.max(n.width(),n.height())/2&&(s=!0),s){G.setChildExtents_(n,d);let t=!1;for(let s=0;s<4;s++)if(t=d[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),l.push(t),c.push(d[s].clone()),g.push(r+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(d[t].isIntersecting(e)){let e=this.getChild_(i,t);-1===e&&(e=this.createChild_(i,t)),l.push(e),c.push(d[t].clone()),g.push(r+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else u=this.insertAtQuad_(t,e,r,n,i,a,o,h,u),a=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let u=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),u=a}else-1===h?(u=this.createElement_(),this.setDataValues_(this.getData_(u),t,e)):u=this.createElementFromDuplicate_(h);return this.setQuad_(u,n),-1!==m?(this.setPrevElement_(u,m),this.setNextElement_(m,u)):this.setFirstElement_(n,u),this.setLastElement_(n,u),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),u}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===G.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const r=new n.Envelope2D;let o=this.getFirstElement_(s),a=-1,h=-1;do{h=this.getData_(o),i=this.getElementValue_(h),r.setCoords({env2D:this.getBoundingBoxValue_(h)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(i,r,t,e,s,!0,o):this.insert_(i,r,t,e,s,!0,o),o=a}while(-1!==o)}canPushDown_(t){return this.getLocalElementCount_(t)>=G.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){(0,r.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&G.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>G.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const i=e<<G.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,s)}}G.m_quadrantMask=3,G.m_heightBitShift=2,G.m_flushingCount=5;class H{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new i.P,this.m_queryEnd=new i.P,this.m_queryBox=new n.Envelope2D,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof n.Envelope2D)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===r.G.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new i.P,e=new i.P,s=new n.Envelope2D;let r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){const i=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(i)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){r=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){r=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),i=this.m_extentsStack.at(-1);G.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let i=0;i<4;i++){const r=this.m_quadTree.getChild_(s,i);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[i].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new n.Envelope2D;s.setCoords({env2D:this.m_childExtents[i]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[i].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[i].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class k{constructor(t){this.m_bucketSort=new V,this.m_sortedHandles=new F(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,(t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,r.g)(0),{}}}class W{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class j{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new B(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||((0,r.g)(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,n,r,o=-1){if(-1===o&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===j.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,h,m,u,l;if(r?(a=e!==j.st_nullNode()?this.m_comparator.compare(this,s,e):-1,h=t!==j.st_nullNode()?this.m_comparator.compare(this,s,t):1):(a=-1,h=1),n&&(0===a||0===h)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===a?e:t;return this.setDuplicateElement_(i,o),-1}l=e!==j.st_nullNode()&&t!==j.st_nullNode()?this.m_random>(0,i.B)(this.m_random)>>1:e!==j.st_nullNode(),l?(u=a,m=e):(u=h,m=t);let c=-1,g=-1,d=!0;for(;;){if(u<0){const t=this.getLeft(m);if(t===j.st_nullNode()){g=m,c=this.newNode_(s),this.setLeft_(m,c),this.setParent_(c,m);break}m=t}else{const t=this.getRight(m);if(t===j.st_nullNode()){g=this.getNext(m),c=this.newNode_(s),this.setRight_(m,c),this.setParent_(c,m);break}m=t}d&&(u*=-1,d=!1)}return this.bubbleUp_(c),this.getParent(c)===j.st_nullNode()&&this.setRoot_(c,o),this.addToList_(g,c,o),c}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==j.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==j.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===j.st_nullNode()&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==j.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),j.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==j.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==j.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=j.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return B.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const n=this.getPriority_(t);for(;e!==j.st_nullNode()||s!==j.st_nullNode();){const r=e!==j.st_nullNode()?this.getPriority_(e):(0,i.j)(),o=s!==j.st_nullNode()?this.getPriority_(s):(0,i.j)();if(n<=Math.min(r,o))return;r<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==j.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==j.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==j.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==j.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==j.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==j.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,i.B)(this.m_random),this.m_random&(0,i.j)()>>1}maxPriority(){return(0,r.g)(0),0}getMaxDepthHelper_(t){return t===j.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===j.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===j.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===j.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===j.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),n=this.getRight(t),r=this.getParent(t),o=t;if(-1!==s&&-1!==n){let a;this.m_random=(0,i.B)(this.m_random),a=this.m_random>(0,i.j)()>>1?this.getNext(t):this.getPrev(t);const h=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1!==r?this.getLeft(r)===t?this.setLeft_(r,a):this.setRight_(r,a):this.setRoot_(a,e),h?(s===a?(this.setLeft_(a,t),this.setParent_(n,a)):n===a&&(this.setRight_(a,t),this.setParent_(s,a)),this.setParent_(t,a),r=a):(this.setParent_(s,a),this.setParent_(n,a),r=this.getParent(t),o=a),s=this.getLeft(t),n=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==n&&this.setParent_(n,t)}const a=-1!==s?s:n;-1===r?this.setRoot_(a,e):this.getLeft(r)===o?this.setLeft_(r,a):this.setRight_(r,a),-1!==a&&this.setParent_(a,r),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,i.j)());let s=j.st_nullNode(),n=j.st_nullNode();const r=this.getRoot_(e),o=r===t;if(o&&(s=this.getLeft(r),n=this.getRight(r),s===j.st_nullNode()&&n===j.st_nullNode()))return this.removeFromList_(r,e),this.freeNode_(r,e),void this.setRoot_(j.st_nullNode(),e);this.bubbleDown_(t);const a=this.getParent(t);a!==j.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,j.st_nullNode()):this.setRight_(a,j.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(s===j.st_nullNode()||this.getParent(s)!==j.st_nullNode()?n:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===j.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===j.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Z{constructor(t){this.m_lists=new B(6),this.m_listOfLists=Z.st_nullNode(),void 0===t?(this.m_listNodes=new B(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new B(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,r.g)(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){(0,r.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,r.g)(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Z.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Z.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Z.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){(0,r.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,r.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;if(e!==Z.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Z.st_nullNode()&&this.setNext_(n,i),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Z.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Z.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Z.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Z.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,r.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class U extends W{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?O.isLeft_(e)&&O.isRight_(i)?-1:O.isLeft_(i)&&O.isRight_(e)?1:0:1}}class O{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new B(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new B(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new j,this.m_secondaryTreaps.setComparator(new U(this)),this.m_secondaryLists=new Z}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.q)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.q)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new F(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)("");const e=this.m_intervalHandles[t];let s;-1===e&&(0,r.a)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(i),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),i),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),i),s=this.m_secondaryTreaps.size(i),0===s&&(this.m_secondaryTreaps.deleteTreap(i),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(n),a=this.getLptr_(n),h=this.getRptr_(n);for(;!(s>0||n===this.m_root||-1!==a&&-1!==h);)n===this.getLptr_(o)?-1!==a?(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setLptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(o,-1),this.setPptr_(n,-1)):-1!==a?(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setRptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(o,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=o,i=this.getSecondaryFromTertiary_(n),s=-1!==i?this.m_secondaryTreaps.size(i):0,a=this.getLptr_(n),h=this.getRptr_(n),o=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof i.E?new Q(this,t,e):((0,r.g)(0),{})}getIterator(){return new Q(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new F(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=(0,i.d)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){const i=e.read(t);let n=s[i>>1];if(-1!==n){const t=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(t,i))}else n=this.insertIntervalEnd_(i,this.m_root),s[i>>1]=n}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const g=this.getMin_(m),d=this.getMax_(m);let _=-1;for(;c;){h=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(_);if(d<e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(g>e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||_!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(_):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&_===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;return s=t<e?t+(e-t>>1)+2:-(t+2),s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new V).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,(t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&O.isLeft_(t)&&O.isRight_(e)?-1:1})}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return O.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return O.isLeft_(t)?e.xmin:e.xmax}}class Q{constructor(t,e,s){this.m_query=i.E.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return(0,r.d)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new i.E;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||(0,r.q)(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class ${constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new F(0),this.m_sortedEndIndicesBlue=new F(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Z,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new n.Envelope2D(e))}endConstruction(){this.m_bAddRedRed||(0,r.q)(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.q)(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||(0,r.q)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.q)(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new O(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&((0,i.w)(this.m_queuedIndicesRed,this.m_envelopesRed.length,-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=i.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&((0,i.w)(this.m_queuedIndicesBlue,this.m_envelopesBlue.length,-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.d)("should not be called"),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new V).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,(t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1})}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}var K=g;class J{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new J(this.tolerance+t,this.resolution)}scale(t){return new J(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function tt(t,e,s,n,r){const o=n*n,a=t.sub(e),h=s.sub(e),m=a.sqrLength(),u=h.sqrLength();if(m<=o||u<=o)return!0;const l=(0,i.a)(a.crossProduct(h));return(l<=o*m||l<=o*u)&&a.dotProduct(h)>=0}function et(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function st(t,e){const s=new n.Envelope2D;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function it(t,e){const s=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s);const i=n.Envelope2D.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function nt(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function rt(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function ot(t,e,s){const i=n.Envelope2D.constructEmpty();return i.setFromPoints(t,e),gt(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function at(t,e,s){return gt(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function ht(t,e,s){return gt(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function mt(t,e,s){return ht(t,e.queryInterval(1,0),s)}function ut(t,e,s){const i=n.Envelope2D.constructEmpty();return e.queryEnvelope(i),at(t,i,s)}function lt(t,e,s=!1){return gt(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ct(t,e,s){const i=n.Envelope2D.constructEmpty();return e.queryEnvelope(i),lt(t,i,s)}function gt(t,e,s,i,n){const r=new J(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}return i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01),r.total()<s?new J(s,0):r}function dt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function _t(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function pt(t){return t>=3}function ft(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function xt(t,e){t.getImpl().setIsSimple(3,e)}function Pt(t,e,s,n){if((0,i.a)(e.x-t.x)+(0,i.a)(e.y-t.y)<=s*s){const s=t.z,r=e.z;return(0,i.G)(s,r,n)}return!1}function yt(t){return t>=4}function vt(t,e){return t===r.G.enumPolygon?pt(e):e>=1}function Ct(t,e,s){const i=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=e.querySegmentIterator(),m=n.Envelope2D.constructEmpty(),u=n.Envelope2D.constructEmpty(),l=new $;l.setTolerance(s);let c=!1;for(l.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(o)&&(c=!0,l.addRedEnvelope(a.getStartPointIndex(),m));if(l.endRedConstruction(),!c)return null;let g=!1;for(l.startBlueConstruction();h.nextPath();)for(;h.hasNextSegment();)h.nextSegment().queryLooseEnvelope(u),u.isIntersecting(o)&&(g=!0,l.addBlueEnvelope(h.getStartPointIndex(),u));return l.endBlueConstruction(),g?l:null}function Et(t,e,s,i,r){t.getGeometryType(),e.getGeometryType();const o=n.Envelope2D.constructEmpty(),a=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(s,s),a.inflateCoords(s,s);const h=n.Envelope2D.constructEmpty();h.setCoords({env2D:o}),h.intersect(a);const m=new $;m.setTolerance(s);let u=!1;m.startRedConstruction();for(let e=0,s=t.getPathCount();e<s;e++)t.queryLoosePathEnvelope(e,o),o.isIntersecting(h)&&(u=!0,m.addRedEnvelope(e,o));if(m.endRedConstruction(),!u)return null;let l=!1;m.startBlueConstruction();for(let t=0,s=e.getPathCount();t<s;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(h)&&(l=!0,m.addBlueEnvelope(t,a));return m.endBlueConstruction(),l?m:null}function bt(t,e,s){const i=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=new $;h.setTolerance(s);let m=!1;for(h.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(i),i.isIntersecting(o)&&(m=!0,h.addRedEnvelope(a.getStartPointIndex(),i));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let t=0,s=e.getPointCount();t<s;t++){const s=e.getXY(t);o.contains(s)&&(u=!0,h.addBlueEnvelope(t,n.Envelope2D.construct(s.x,s.y,s.x,s.y)))}return h.endBlueConstruction(),u?h:null}function Dt(t,e,s){const r=n.Envelope2D.constructEmpty(),o=n.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=n.Envelope2D.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new $;h.setTolerance(s);let m=!1;h.startRedConstruction();const u=new i.P;for(let e=0,s=t.getPointCount();e<s;e++)t.queryXY(e,u),a.contains(u)&&(m=!0,h.addRedEnvelope(e,n.Envelope2D.construct(u.x,u.y,u.x,u.y)));if(h.endRedConstruction(),!m)return null;let l=!1;h.startBlueConstruction();const c=new i.P;for(let t=0,s=e.getPointCount();t<s;t++)e.queryXY(t,c),a.contains(c)&&(l=!0,h.addBlueEnvelope(t,n.Envelope2D.construct(c.x,c.y,c.x,c.y)));return h.endBlueConstruction(),l?h:null}function St(t){const e=new n.Envelope2D;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){const s=new n.Envelope2D;if(t.queryLooseEnvelope(s),s.isEmpty())return null;t.getGeometryType();const i=new G(s,8);let o=-1;const a=new n.Envelope2D;let h=!1;do{for(let n=0,m=t.getPathCount();n<m;n++)if(t.queryLoosePathEnvelope(n,a),a.isIntersecting(e)){if(o=i.insertEx(n,a,o),-1===o){h&&(0,r.d)("build_quad_tree_for_paths"),s.assign(t.calculateEnvelope2D(!1)),h=!0,i.reset(s,8);break}h=!1}}while(h);return i}(t,e)}function wt(t,e){if(!e){const e=new n.Envelope2D;t.queryLooseEnvelope(e);const s=new G(e,8);let i=-1;const o=new n.Envelope2D,a=t.querySegmentIterator();let h=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const n=a.nextSegment(),m=a.getStartPointIndex();if(n.queryLooseEnvelope(o),i=s.insertEx(m,o,i),-1===i){h&&(0,r.d)(""),e.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(e,8),a.resetToFirstPath();break}}return s}const s=new n.Envelope2D;t.queryLooseEnvelope(s);const i=new G(s,8);let o=-1;const a=new n.Envelope2D,h=t.querySegmentIterator();let m=!1;for(;h.nextPath();)for(;h.hasNextSegment();){const n=h.nextSegment(),u=h.getStartPointIndex();if(n.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=i.insertEx(u,a,o),-1===o)){m&&(0,r.d)(""),s.assign(t.calculateEnvelope2D(!1)),m=!0,i.reset(s,8),h.resetToFirstPath();break}}return i}function At(t,e){if(e){const s=new G(e,8),o=new i.P,a=new n.Envelope2D;let h=!1;for(let i=0;i<t.getPointCount();i++)o.setCoordsPoint2D(t.getXY(i)),e.contains(o)&&(a.setCoords({pt:o}),-1!==s.insert(i,a)||(h&&(0,r.d)(""),h=!0,s.reset(t.calculateEnvelope2D(),8),i=-1));return s}return(0,r.t)("no-extent version not yet impl"),null}function Tt(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let n=s;n<e;n+=i){const e=t.read(n);e<o?(r=!0,t.write(n,o)):e>a&&(r=!0,t.write(n,a))}return r}function It(t,e,s,i){if(!t.hasAttribute(s))return!1;const n=t.getGeometryType();if(n===r.G.enumGeometryCollection){const n=t,r=n.getGeometryCount();let o=0;for(let t=0;t<r;++t)o|=It(n.getGeometry(t),e,s,i)?1:0;return!!o}if((0,r.i)(n)){const n=t,o=K.getPersistence(s),a=K.getComponentCount(s),h=n.getPointCount();if(1===o){const t=Tt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}if(2===o){const t=Tt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}(0,r.d)("snap_coordinate not implemented")}if(n===r.G.enumEnvelope){const n=t,r=n.queryInterval(s,i);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&n.setIntervalEnvelope(s,i,r),o}if(n===r.G.enumPoint){const n=t;let r=n.getAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setAttributeBasic(s,i,r),o}if((0,r.f)(n)){const n=t;let r=n.getStartAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setStartAttribute(s,i,r),r=n.getEndAttributeAsDbl(s,i),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setEndAttribute(s,i,r),o}(0,r.d)("snap_coordinate not implemented")}var Nt=g;class qt{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=v(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=C(),this.ensureAttributes(),this.setXYZ(new b(t.x,t.y,t.z))):(this.m_description=v(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=v()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new i.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new b;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Nt.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;(0,r.r)("")}const s=Nt.getComponentCount(t);(e<0||e>=s)&&(0,r.r)("");const i=this.m_description.getAttributeIndex(t);return i>=0?this.m_attribs[this.m_description.getPointAttributeOffset(i)-2+e]:Nt.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:(0,r.r)(""));const i=Nt.getComponentCount(t);(e<0||e>=i)&&(0,r.r)("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=Nt.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=v();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof Ft)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof D){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new i.E;if(this.isEmpty())return s.setEmpty(),s;const n=this.getAttributeAsDbl(t,e);return s.vmin=n,s.vmax=n,s}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){const e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,r.t)("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=et(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new qt({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=v(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&(0,i.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.G.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let t=0,n=this.m_description.getTotalComponentCount()-2;t<n;t++)if(!(0,i.G)(this.m_attribs[t],s.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){const t=new qt({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,i.c)(this.m_description,this.m_description=e.m_description),e.x=(0,i.c)(this.x,this.x=e.x),e.y=(0,i.c)(this.y,this.y=e.y),e.m_attribs=(0,i.c)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Nt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,e,s){if(t.getDescription()!==e.getDescription()&&(0,r.a)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const n=c();t.queryValues(n,n.length);const o=c();e.queryValues(o,o.length);const a=c();let h=n,m=o;const u=a;let l=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),n=Nt.getInterpolation(e),r=Nt.getComponentCount(e),o=Nt.getDefaultValue(e);(0,i.A)(n,h,m,u,l,r,s,o),h=h.slice(r),m=m.slice(r),l+=r}return this.setValues(a,l),this}static lerp(t,e,s,i){i.lerp(t,e,s)}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,i.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return i.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=v());const e=_();E(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=Nt.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),t[0]=this.x,t[1]=this.y,(0,i.b)(t,this.m_attribs,2,0,s-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,i.b)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=Nt.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Nt.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),this.x=t[0],this.y=t[1],(0,i.b)(this.m_attribs,t,0,2,s-2)}dbgDefaultAttribs(){}toFlatGeometry(){const t=Float64Array.of(this.getX(),this.getY(),this.getZ(),this.getM());return{type:"point",vertexCount:1,vertexXY:t.subarray(0,2),vertexZ:this.hasAttribute(1)?t.subarray(2,3):void 0,vertexM:this.hasAttribute(2)?t.subarray(3,4):void 0,...z}}}qt.type=r.G.enumPoint;var Mt=g;function Yt(t,e){return e*(t.getTotalComponentCount()-2)}class Xt{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new n.Envelope2D(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new n.Envelope2D(t.env2D);else if(t.move)this.m_envelope2D=new n.Envelope2D(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new n.Envelope2D(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=n.Envelope2D.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=(0,i.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const s=e,o=t.getTotalComponentCount()-2;if(s.m_description!==t&&(s.releaseAttributes_(),s.m_description=t,o&&(s.m_data.m_attributes=(0,i.d)(2*o,Number.NaN))),o){(0,r.g)(this.m_attributes&&s.m_data.m_attributes);const t=2*o;(0,i.b)(s.m_data.m_attributes,this.m_attributes,0,0,t)}s.m_data.m_envelope2D=new n.Envelope2D(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new n.Envelope2D(this.m_envelope2D),e.releaseAttributes(),t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,s,i,n){(0,r.g)(0)}queryInterval(t,e,s,i){if(this.isEmpty())return void i.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(i):1===s?this.m_envelope2D.queryIntervalY(i):(0,r.r)(""));const n=Mt.getComponentCount(e);(s<0||s>=n)&&(0,r.r)("");const o=t.getAttributeIndex(e);if(o>=0)return i.vmin=this.m_attributes[Yt(t,0)+t.getPointAttributeOffset(o)-2+s],void(i.vmax=this.m_attributes[Yt(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=Mt.getDefaultValue(e);return void i.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new i.E;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=(0,i.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}let Ft=class t{constructor(t){if(this.m_EnvelopeType=4,this.m_description=v(),void 0===t)this.m_data=new Xt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Xt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Xt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Xt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Xt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Xt({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Xt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Xt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,s,i,n){(0,r.g)(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new n.Envelope2D(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.G.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new i.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=Mt.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof n.Envelope2D)this.m_data.m_envelope2D=new n.Envelope2D(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=i.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof n.Envelope2D)return e.isValid()||(0,r.a)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(e);if(e instanceof t){if(e.m_data.isEmpty())return;const t=e.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(e.m_data.m_envelope2D);for(let s=1,i=t.getAttributeCount();s<i;s++){const i=t.getSemantics(s),n=Mt.getComponentCount(i);for(let t=0;t<n;t++){const s=e.queryInterval(i,t),n=this.queryInterval(i,t);n.merge(s),this.setIntervalEnvelope(i,t,n)}}return}if(e instanceof qt){const t=e;if(t.isEmpty())return;const s=t.getDescription();if(this.mergeVertexDescription(s),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let e=1,i=s.getAttributeCount();e<i;e++){const i=s.getSemantics(e),n=Mt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.getAttributeAsDbl(i,e),n=this.queryInterval(i,e);n.mergeCoordinate(s),this.setIntervalEnvelope(i,e,n)}}return}(0,r.t)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=Mt.getComponentCount(s);for(let e=0;e<i;e++){const i=t.queryInterval(s,e),n=this.queryInterval(s,e);n.intersect(i),this.setIntervalEnvelope(s,e,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=Mt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=new i.E(s);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):(0,r.r)("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,s,n){this.setIntervalEnvelope(t,e,new i.E(s,n))}queryInterval(t,e){const s=new i.E;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,r.t)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,r.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new t({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=v()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,r.g)(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,n=2*(this.m_description.getTotalComponentCount()-2);t<n;t++)if(!(0,i.G)(this.m_data.m_attributes[t],s.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.t)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new t({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumEnvelope&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,i.c)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,i.c)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,i.c)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.a)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.r)(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=Mt.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=v();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=Mt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let e=1,s=i.getAttributeCount();e<s;e++){const s=i.getSemantics(e),n=Mt.getComponentCount(s);for(let e=0;e<n;e++){const i=t.getAttributeAsDbl(s,e);this.setInterval(s,e,i,i)}}}assignVertexDescriptionImpl(t){const e=_();E(t,this.m_description,e);let s=null;const n=t.getTotalComponentCount()-2,r=this.m_description?this.m_description.getTotalComponentCount()-2:0;n>0&&(s=(0,i.d)(2*n,Number.NaN));for(let o=1;o<t.getAttributeCount();o++){const a=e[o];if(-1!==a){const e=t.getPointAttributeOffset(o)-2,h=Mt.getComponentCount(t.getSemantics(o)),m=this.m_description.getPointAttributeOffset(a)-2;(0,i.b)(s,this.m_data.m_attributes,e,m,h),(0,i.b)(s,this.m_data.m_attributes,n+e,r+m,h)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&(0,r.u)(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=Mt.getComponentCount(e)&&(0,r.r)("");const i=this.m_description.getAttributeIndex(e);return i>=0?this.m_data.m_attributes[Yt(this.m_description,t)+this.m_description.getPointAttributeOffset(i)-2+s]:g.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,i){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=i:0===s?this.m_data.m_envelope2D.xmax=i:(0,r.r)(""):1===s?this.m_data.m_envelope2D.ymin=i:0===s?this.m_data.m_envelope2D.xmin=i:(0,r.r)(""));const n=Mt.getComponentCount(e);(s<0||s>=n)&&(0,r.r)(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[Yt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=i}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}};Ft.type=r.G.enumEnvelope,Object.freeze(Object.defineProperty({__proto__:null,Envelope:Ft,EnvelopeData:Xt},Symbol.toStringTag,{value:"Module"}))},79187(t,e,s){s.r(e),s.d(e,{Envelope2D:()=>r});var i=s(55537),n=s(83661);class r{static construct(t,e,s,i){return new r(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new r(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new r(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return n.P.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(t){void 0!==t.xmin?(this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax):void 0!==t.x?(this.xmin=t.x,this.xmax=t.x,this.ymin=t.y,this.ymax=t.y):void 0!==t.pt1?(this.xmin=t.pt1.x,this.ymin=t.pt1.y,this.xmax=t.pt2.x,this.ymax=t.pt2.y,this.normalize()):void 0!==t.env2D?(this.xmin=t.env2D.xmin,this.xmax=t.env2D.xmax,this.ymin=t.env2D.ymin,this.ymax=t.env2D.ymax,this.normalize()):void 0!==t.pt?(this.xmin=t.pt.x,this.xmax=t.pt.x,this.ymin=t.pt.y,this.ymax=t.pt.y):void 0!==t.center?(this.xmin=t.center.x-.5*t.width,this.xmax=this.xmin+t.width,this.ymin=t.center.y-.5*t.height,this.ymax=this.ymin+t.height,this.normalize()):(0,i.t)("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let t=1,i=2*e;t<i;t+=2){if(!this.isEmpty()){for(let i=t,n=2*e;i<n;i+=2)this.mergeNeCoords(s[i],s[i+1]);return}this.setCoords({x:s[t],y:s[t+1]}),t+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new n.P(this.xmin,this.ymin)}getLowerRight(){return new n.P(this.xmax,this.ymin)}getUpperLeft(){return new n.P(this.xmin,this.ymax)}getUpperRight(){return new n.P(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new n.P(this.xmin,this.ymin);case 1:return new n.P(this.xmin,this.ymax);case 2:return new n.P(this.xmax,this.ymax);default:return new n.P(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,o=e.y-t.y;if(Math.abs(n)>Math.abs(o)?s&r.XMASK?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&r.XMASK?(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s&r.YMASK?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):i&r.YMASK?(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),o=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),o=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=(0,n.m)(n.P,4);this.queryCorners(s);const i=(0,n.m)(n.P,4);t.queryCorners(i);for(let t=0;t<4;t++)for(let r=0;r<4;r++){const o=n.P.sqrDistance(s[t],i[r]);o>e&&(e=o)}return e}sqrMaxMinDistance(t){const e=n.P.sqrDistance(t,this.getLowerLeft()),s=n.P.sqrDistance(t,this.getUpperLeft()),i=n.P.sqrDistance(t,this.getLowerRight()),r=n.P.sqrDistance(t,this.getUpperRight());let o,a=Math.max(e,s);return o=Math.max(e,i),a>o&&(a=o),o=Math.max(s,r),a>o&&(a=o),o=Math.max(i,r),a>o&&(a=o),a}sqrMinDistance(t){return this.contains(t)?0:this.sqrDistance(t)}sqrMaxDistance(t){let e=n.P.sqrDistance(t,this.getLowerLeft());return e=Math.max(n.P.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(n.P.sqrDistance(t,this.getUpperRight()),e),e=Math.max(n.P.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=(0,n.s)(t.x,this.xmin,this.xmax),s=(0,n.s)(t.y,this.ymin,this.ymax);return n.P.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new n.P;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:(0,i.a)("query_side")}return e}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){return this.isEmpty()?(0,n.g)():(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*(0,n.g)()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}r.XLESSXMIN=1,r.YLESSYMIN=4,r.XMASK=3,r.YMASK=12},88885(t,e,s){s.d(e,{$:()=>B,A:()=>lr,B:()=>ir,C:()=>fs,D:()=>Yn,E:()=>ls,F:()=>Vn,H:()=>xt,I:()=>dt,J:()=>_t,K:()=>wt,L:()=>Fr,M:()=>_,N:()=>qn,O:()=>Mn,P:()=>rs,Q:()=>Sr,R:()=>w,S:()=>Rr,T:()=>Ut,U:()=>dn,V:()=>_r,W:()=>j,X:()=>ms,Y:()=>wr,Z:()=>Ir,_:()=>y,a:()=>Dt,a0:()=>nt,a1:()=>Ar,a2:()=>Tr,a3:()=>Mr,a4:()=>An,a5:()=>C,a6:()=>jn,a7:()=>us,a8:()=>Dn,a9:()=>u,b:()=>bn,c:()=>At,d:()=>Nn,e:()=>_s,f:()=>cs,g:()=>O,i:()=>ds,l:()=>In,n:()=>as,s:()=>l,x:()=>fe,y:()=>Ci,z:()=>ur});var i=s(55537),n=s(95213),r=s(83661),o=s(79187),a=s(11878),h=s(61691);class m{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function u(t,e,s){if(t)for(let t=e.length-1;t>=0;--t)s(e[t]);else e.forEach(s)}function l(t,e){let s=(0,r.B)(t);const i=e.length/(0,r.i)();for(let t=0;t<e.length;++t){const t=Math.trunc(s*i);s=(0,r.B)(s);const n=Math.trunc(s*i),o=e[t];e[t]=e[n],e[n]=o}}var c=n.V;const g="can not assign an empty point to a vertex";class d{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,n.l)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new m,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new n.m,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:(0,n.l)();this.m_description=e,this.m_vertexAttributes=new m,this.m_envelopeData=new n.m,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,i.i)(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const i=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(i),o=s.getAttributeStreamRef(i),a=c.getComponentCount(i);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,r,o){if(this.addAttribute(t),!this.isEmpty()&&(0!==s||1!==r)){if(0===t){const t=new a.T;return 0===o?0===e?(t.setShiftCoords(s,0),t.scale(r,1)):1===e?(t.setShiftCoords(0,s),t.scale(1,r)):(0,i.a)(""):0===e?(t.setScaleCoords(1/r,1),t.shiftCoords(-s,0)):1===e?(t.setScaleCoords(1,1/r),t.shiftCoords(0,-s)):(0,i.a)(""),void this.applyTransformation(t)}(function(t,e,s,n,r){(e<0||s<0||n<1||e+n*(s-1)+1>t.size())&&(0,i.a)("Index out of bound");for(let i=e,o=e+n*(s-1)+1;i<o;i+=n)t.writeAsDbl(i,r(t.readAsDbl(i)))})(this.getAttributeStreamRef(t),e,this.getPointCount(),c.getComponentCount(t),(0,n.x)(s,r,o)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,i.a)("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,i.a)("stream"),e&&c.getPersistence(t)!==e.getPersistence()&&(0,i.a)(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){const i=this.m_description.getSemantics(e);for(let n=0,r=c.getComponentCount(i);n<r;n++){const o=this.m_vertexAttributes.get(e).readAsDbl(r*t+n);s.setAttributeBasic(i,n,o)}}}setPointByValNoCurves(t,e){const s=e;s.isEmpty()&&(0,i.a)(g);const n=s.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,s.getX()),r.write(2*t+1,s.getY());for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),n=c.getComponentCount(i);for(let r=0;r<n;r++){const o=s.getAttributeAsDbl(i,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,s,n){(0,i.g)(0)}getPointByValAsArray(t,e,s,n){(0,i.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=c.getComponentCount(t);s>=n&&(0,i.r)("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):c.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=c.getComponentCount(t);n<r&&(0,i.r)("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=c.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}setAttributeNoCurves(t,e,s,n){const r=c.getComponentCount(t);s>=r&&(0,i.r)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArrayNoCurves(t,e,s,n){(e<0||e>=this.m_pointCount)&&(0,i.r)("");const r=c.getComponentCount(t);n<r&&(0,i.r)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let t=0;t<r;++t)a.writeAsDbl(e*r+t,s[t])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=n.f.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=c.getDefaultValue(1),s}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.Envelope2D||t instanceof n.p?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=r.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let i=!1;const n=c.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let t=e,o=this.m_pointCount*n;t<o;t+=n)r.readAsDbl(t)!==s&&(r.writeAsDbl(t,s),i=!0);i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=c.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let t=0;t<i;t++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,r=this.m_pointCount*i;t<r;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,i.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,i.a)(""),this.m_envelopeData=new n.m({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,i.a)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*s,i=2*r,n=0;e<i;e+=2,n++)o.queryPoint2D(e,t[n]);return r}queryCoordinates3D(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=c.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=s;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;return 1&i||(s=(14&i)>>1,e[0]=n,n<t&&(s=-1)),s}setIsSimple(t,e,s=!1){if(2===t?(0,i.g)(this.getGeometryType()===i.G.enumPolyline):1===t?(0,i.g)(this.getGeometryType()===i.G.enumMultiPoint||this.getGeometryType()===i.G.enumPolyline):3===t&&(0,i.g)(this.getGeometryType()===i.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let i=t<<1;s||(i|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,i),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&(0,i.s)("Cannot do shallow clone on unprepared geometry");const s=t,n=this.getGeometryType(),r=s.getGeometryType();(0,i.g)(n===r||n===i.G.enumPolygon&&r===i.G.enumPolyline,"failure in copyToUnchcked"),s.clearAccelerators(),s.m_description=this.m_description,s.m_vertexAttributes.destroyAndSetSize(0),s.m_envelopeData.releaseAttributes();const o=this.m_description.getAttributeCount(),a=new m;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{const e=c.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,s.m_envelopeData),s.m_flags=this.m_flags,s.m_simpleTolerance=this.m_simpleTolerance,n!==r){const t=[Number.NaN];s.getIsSimple(0,t)>=3?s.setIsSimple(1,t[0]):s.setIsSimple(-1,0)}s.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),s.m_pointCount=this.m_pointCount,s.hasDirtyFlag(32)||s.m_vertexAttributes.empty()?((0,i.g)(!e||0===s.m_pointCount),s.m_reservedPointCount=-1):s.m_reservedPointCount=s.m_pointCount;try{this.copyToImpl(s,e)}catch(t){throw s.setEmpty(),t}s.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,o){(t<0||t>=this.m_pointCount)&&(0,i.r)(""),(e<0||e>=this.m_pointCount)&&(0,i.r)(""),o.assignVertexDescription(this.m_description);const a=(0,r.d)(c.maxComponentCount(),Number.NaN),h=(0,r.d)(c.maxComponentCount(),Number.NaN),m=(0,n.q)();let u=0;for(let o=0;o<this.m_description.getAttributeCount();o++){const l=this.m_description.getSemantics(o),g=c.getInterpolation(l),d=c.getComponentCount(l),_=c.getDefaultValue(l);this.queryAttributeAsDbl(l,t,a,d),this.queryAttributeAsDbl(l,e,h,d),(0,i.g)(u+d<=n.O),(0,r.A)(g,a,h,m,u,d,s,_),u+=d}!function(t,e){const s=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,r.b)(t.getAttributeArray(),e,0,2,s-2)}(o,m)}getShortestDistance(t,e){return r.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return r.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,i.a)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=(0,n.t)();(0,n.u)(t,this.m_description,e);const s=new m;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return 0!==(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const i=this.m_description.getSemantics(s);let r=0;if(null!==this.m_vertexAttributes.get(s)){const t=c.getComponentCount(i);r=this.m_vertexAttributes.get(s).size()/t,r<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,c.getDefaultValue(i)),r=e)}else this.m_vertexAttributes.set(s,(0,n.v)(i,e)),r=e;r<t&&(t=r)}this.m_reservedPointCount=t}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new n.E({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=c.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const o=new r.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);o.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new n.m({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=o.Envelope2D.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){(0,i.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.Envelope2D?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&(0,i.a)(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,n.w)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*s),s=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,n.w)(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=c.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,(0,n.w)(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&(0,i.a)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,i.u)("")}exportVertexAttributes(){const t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),s=this.m_description.getAttributeIndex(2),i=this.m_vertexAttributes.posStream,n=e>0?this.m_vertexAttributes.get(e):void 0,r=s>0?this.m_vertexAttributes.get(s):void 0,o=i?.getArray()??new Float64Array,a=n?.getArray(),h=r?.getArray();return{vertexCount:t,vertexXY:o,vertexZ:a,vertexM:h}}}class _ extends d{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,e){t>this.getPointCount()&&(0,i.a)("invalid point index"),t<0&&(t=this.getPointCount());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(0===r)this.m_vertexAttributes.get(i).insert(o*t,e,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,i.a)(g),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(e.hasAttribute(r))this.m_vertexAttributes.get(i).insertAttributes(o*t,e,r,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.r)(""),t<0&&(t=this.getPointCount()),0===s)return;const r=e[0].getDescription();this.mergeVertexDescription(r);const o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,a=this.m_description.getAttributeCount();i<a;i++){const a=this.m_description.getSemantics(i),h=n.V.getComponentCount(a);if(this.m_vertexAttributes.get(i))if(r.hasAttribute(a))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*h,e,s,a,o*h);else{const e=n.V.getDefaultValue(a);this.m_vertexAttributes.get(i).insertRange(h*t,e,h*s,h*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.a)("invalid point index"),t<0&&(t=this.getPointCount()),0===s)return;const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=n.V.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(0===o)this.m_vertexAttributes.get(i).insertRangeFromPoints(a*t,e,0,s,!0,a*r);else{const e=n.V.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a,a*r)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,i.r)("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i);this.m_vertexAttributes.get(s).eraseRange(r*t,r*e,r*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),i=n.V.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=n.V.getDefaultValue(s),r=n.V.getComponentCount(s);this.m_vertexAttributes.get(t).insertRange(r*e,i,r*(this.m_pointCount-e),r*e)}}queryCoordinates3D(t,e,s,r){let o=r<0?this.m_pointCount:r;if(o=Math.min(o,s+e),(s<0||o<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return o;const a=this.getAttributeStreamRef(0);let h=null;const m=n.V.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(h=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<o;e++,l++)t[l].x=a.read(2*e),t[l].y=a.read(2*e+1),t[l].z=u?h.read(e):m;return o}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}add(t){t.isEmpty()&&(0,i.a)(g),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new r.P(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new n.f;i.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,s){this===t&&(0,i.a)("Multi_point_impl.add");const r=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||r<e)&&(0,i.a)(""),e===r)return;const o=t.getDescription();this.mergeVertexDescription(o);const a=r-e,h=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let s=0,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i),m=this.getAttributeStreamRef(i);if(o.hasAttribute(i)){const s=t.getAttributeStreamRef(i);m.insertRangeFromStream(h*r,s,e*r,a*r,!0,1,h*r)}else{const t=n.V.getDefaultValue(i);m.insertRange(h*r,t,a*r,h*r)}}}addPoints2D(t,e,s,n){let r=e;const o=n<0?r:n;if((r<0||s<0||s>r||o<s)&&(0,i.a)(""),s===o)return;r=o-s;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[s+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,s,n){let o=e;const a=n<0?o:n;if((o<0||s<0||s>o||a<s)&&(0,i.a)(""),this.addAttribute(1),s===a)return;o=a-s;const h=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);const m=this.getAttributeStreamRef(0),u=new r.P;for(let e=0;e<o;e++)u.x=t[s+e].x,u.y=t[s+e].y,m.writePoint2D(2*(h+e),u);const l=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)l.write(h+e,t[s+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,i){this.setAttributeNoCurves(t,e,s,i)}getGeometryType(){return i.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new _({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,i.t)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.G.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):(0,i.t)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){(0,i.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...n.y}}}_.type=i.G.enumMultiPoint;class p{constructor(){this.m_EnvelopeType=5,this.envAabb=o.Envelope2D.constructEmpty(),this.envRot=o.Envelope2D.constructEmpty()}static constructEmpty(){return new p}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:f(t),y:x(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(f(t),x(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=f(t[i]),s=x(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=f(t[s]),i=x(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(f(t),x(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*(0,r.D)();this.envRot.inflateCoords(e,e),e<0&&p.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(P(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(P(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(P(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=function(t,e){return t-e}(t.x,t.y),i=function(t,e){return t+e}(t.x,t.y);e.setCoords(s,i)}}function f(t){return t.x-t.y}function x(t){return t.x+t.y}function P(t){return new r.P(f(t),x(t))}class y{constructor(){this.x=r.H.getNAN(),this.y=r.H.getNAN()}static getNAN(){return new y}static constructPoint2D(t){const e=new y;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new y;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new y;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new y).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new y;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new y;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=r.I.clone(),this.y=r.J.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return r.P.construct(this.x.value(),this.y.value())}}class v{constructor(){this.a11=new r.H(1),this.a12=new r.H(0),this.a21=new r.H(0),this.a22=new r.H(1)}clone(){const t=new v;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,r.c)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new r.H(1),n=new r.H(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new r.H(1);if(this.a11.ne(this.a22)){const o=this.a11.subE(this.a22).divE(s);o.mulThisByPower2(.5);const a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(r.J)&&e.negateThis();const h=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(h),i.setE(h);const m=e.mulE(s);t[0]=this.a11.addE(m),t[1]=this.a22.subE(m)}else i=new r.H(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,r.c)(t[0],t[0]=t[1]),e[1]=(0,r.c)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class C{static constructPoint2D(t){return new C(r.M.constructDouble(t.x),r.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new r.M).setNAN(),void(this.y=(new r.M).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new r.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new C(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new C(this.x.add(t.x),this.y.add(t.y))}sub(t){return new C(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var E=n.V;function b(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[3][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),(0,r.F)(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),(0,r.F)(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),(0,r.F)(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),(0,r.F)(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function D(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function S(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function w(t,e,s){const n=(0,r.m)(r.P,4);let o=t.queryControlPointsHelper(n);const a=(0,r.m)(r.P,4);let h=e.queryControlPointsHelper(a);n[0].equals(a[0])||(0,i.w)("");const m=t.getGeometryType();if(m===e.getGeometryType()&&n.map((t,e)=>a[e].equals(t)).reduce((t,e)=>t&&e)){if(m!==i.G.enumRationalBezier2)return 0;{const s=e,i=[0,0,0],n=[0,0,0];if(t.queryWeights(i),s.queryWeights(n),i.map((t,e)=>n[e]===t).reduce((t,e)=>t&&e))return 0}}for(;o>2&&n[1].equals(n[0]);)n.splice(1,1),o--;for(;h>2&&a[1].equals(a[0]);)a.splice(1,1),h--;(n[1].equals(n[0])||a[1].equals(n[0]))&&(0,i.w)("");const u=r.P.compareVectorsOrigin(n[0],n[1],a[1]);if(0===u){const s=C.constructPoint2D(n[0]),i=new C;t.queryCoord2DMP(1e-16,i),i.sub(s);const r=new C;return e.queryCoord2DMP(1e-16,r),r.sub(s),r.crossProduct(i).sign()}return u}function A(t,e,s,n,o,a,h,m){let u=t.calculateUpperLength2D(),l=e.calculateUpperLength2D(),c=t,g=e,d=!1;u>l&&(g=(0,r.c)(c,c=g),n=(0,r.c)(s,s=n),l=(0,r.c)(u,u=l),d=!0);const _=0===s;{h[0]=_?1:0;const t=c.getCoord2D(h[0]);m[0]=g.getClosestCoordinate(t,!1);const e=g.getCoord2D(m[0]);if(r.P.distance(t,e)<=o){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(c.getCoord2D(e[i])),!g.isCloserThanDistance(t,new r.E(0,1),o)){s=!1;break}if(s)return d&&(m[0]=(0,r.c)(h[0],h[0]=m[0])),1}}if(u<=3*o)return 0;let p=(0,r.s)(Math.max(o/u,.1),0,.5),f=.01*o,x=0,P=0,y=p,v=-1,C=0,E=1/32;for(let t=0;;t++){(0,i.g)(t<4095);const e=_?p:1-p,s=c.getCoord2D(e),u=g.getClosestCoordinate(s,!1);if(u===n)return C;const l=g.getCoord2D(u),b=r.P.distance(s,l);if(0===t&&(v=b),b<=f?(E=.5,P=b,x=p):(y=p,v=b),Math.abs(P-v)>.1*f&&y-x>1e-16)p=(0,r.q)(x,y,E);else{if(h[C]=e,m[C]=u,d&&(m[C]=(0,r.c)(h[C],h[C]=m[C])),1===a||1===C)return 1===C&&h[0]>h[1]&&(h[1]=(0,r.c)(h[0],h[0]=h[1]),m[1]=(0,r.c)(m[0],m[0]=m[1])),C+1;C++,x=y,P=v,y=.8,v=-1,p=.8,E=1/32,f=10*o,t=0}}}function T(t,e,s,i,n,o,a,h,m){if((0,r.N)(s,0,1)&&(0,r.N)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new y,l=(0,r.O)();if(t.queryDerivative(new r.H(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new r.H(s,l).add(e),u)}1===s&&u.negateThis();const c=new y;if(e.queryDerivative(new r.H(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new r.H(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const g=u.dotProduct(c),d=u.crossProduct(c);d.scaleError(3);const _=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(g.ge(r.J)&&(d.isZero()||Math.abs(d.value())<_()))return A(t,e,s,i,n,o,a,h)}return 0}function I(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function N(t,e,s){t.m_XStart=e,t.m_YStart=s}function q(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function M(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Y(t,e){const s=new n.f;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:E.getDefaultValue(1)}(t,e),s}function X(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function F(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let i=1;i<t.m_description.getAttributeCount();i++){const n=t.m_description.getSemantics(i);for(let i=0,r=E.getComponentCount(n);i<r;i++){const r=L(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function R(t,e,s){s.isEmpty()&&(0,i.u)(""),function(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=E.getComponentCount(r);for(let i=0;i<o;i++)z(t,e,r,i,s.getAttributeAsDbl(r,i))}}function L(t,e,s,n){if((e<0||e>1)&&(0,i.r)(""),0===s)return(n<0||n>=2)&&(0,i.r)(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=E.getComponentCount(s);(n<0||n>=r)&&(0,i.r)("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:E.getDefaultValue(s)}function z(t,e,s,n,r){if((e<0||e>1)&&(0,i.r)(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:(0,i.r)(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:(0,i.r)(""):(0,i.r)(""),void t.endPointModified();const o=E.getComponentCount(s);(n<0||n>=o)&&(0,i.r)("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function V(t,e){if(t===e)return;e.isEmpty()&&(0,i.u)("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=E.getComponentCount(n);for(let s=0;s<r;s++){let i=L(e,0,n,s);z(t,0,n,s,i),i=L(e,1,n,s),z(t,1,n,s,i)}}}function B(t){return t.absNorm()*(0,r.g)()}function G(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,r.g)()}function H(t,e,s){const i=new p;t.queryEnvelopeW(r.E.unit(),i);const n=new p;return e.queryEnvelopeW(r.E.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function k(t,e,s){const i=(0,r.L)(t,s),n=(0,r.L)(e,s);i.sort((t,e)=>t.compare(e)),n.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(i[t].compare(n[t])<0)return-1;if(0!==i[t].compare(n[t]))return 1}return 0}var W=n.V;class j{constructor(t){if(t.copy)this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice());else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:(0,n.l)(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:(0,n.z)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=(0,n.l)());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:(0,n.z)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);(0,i.d)("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,r.d)(2*t,Number.NaN)),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,i.t)("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return(0,i.t)("not implemented"),!1}setCoordsForIntersector3D(t,e,s){(0,i.t)("not implemented")}transformAttribute(t,e,s,n,r){(0,i.t)("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let s=1,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=W.getComponentCount(i);for(let s=0;s<r;s++)z(this,0,i,s,t.getAttributeAsDbl(i,s)),z(this,1,i,s,e.getAttributeAsDbl(i,s))}}getStartXY(){return new r.P(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return Y(this,0)}setStartXYZ(t){X(this,0,t)}setStartXYZCoords(t,e,s){X(this,0,n.f.construct(t,e,s))}queryStart(t){F(this,0,t)}setStart(t){R(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return L(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,i.g)(0),0}setStartAttribute(t,e,s){z(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=W.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=W.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,i.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,i.g)(0),0}getEndXY(){return new r.P(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return Y(this,1)}setEndXYZ(t){X(this,1,t)}setEndXYZCoords(t,e,s){X(this,1,n.f.construct(t,e,s))}queryEnd(t){F(this,1,t)}setEnd(t){R(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return L(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,i.g)(0),Math.trunc(0)}setEndAttribute(t,e,s){z(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.a)("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,r.b)(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=r.E.constructEmpty();return s.vmin=L(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(L(this,1,t,e)),s}calculateLength3D(t){return(0,i.g)(0),0}getCoord3D(t){return(0,i.g)(0),{}}getCoord2D(t){const e=r.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return(0,i.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=W.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=o.Envelope2D.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,i),i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&r.P.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=W.getComponentCount(e);t<s;t++){const s=L(this,0,e,t);z(this,0,e,t,L(this,1,e,t)),z(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==n){const e=(0,r.d)(9,Number.NaN),o=(0,r.d)(9,Number.NaN),a=this.intersect(t,null,e,o,0);(0,i.g)(a<=9),0===a&&(0,i.d)(""),null!==s&&(s[0]=e[0]),null!==n&&(n[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,h=-1,m=a;return o=this.getStartXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==n&&(n[0]=h),null!==s&&(s[0]=0)),o=this.getEndXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==n&&(n[0]=h),null!==s&&(s[0]=1)),o=t.getStartXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==n&&(n[0]=0)),o=t.getEndXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==n&&(n[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return(0,r.q)(t,e,s)}moveTo(t){const e=this.isClosed(),s=new a.T;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,i.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){const s=(0,n.t)();(0,n.u)(e,t.m_description,s);let i=null;const o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(i=(0,r.d)(2*o,Number.NaN),(0,r.b)(i,e.getDefaultPointAttributes(),0,2,o),(0,r.b)(i,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let n=1;n<e.getAttributeCount();n++){const r=s[n];if(-1!==r){const s=t.m_description.getPointAttributeOffset(r)-2,h=e.getPointAttributeOffset(n)-2,m=E.getComponentCount(e.getSemantics(n));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[o+h]=t.m_attributes[a+s]}}t.m_attributes=i,t.m_description=e}(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.a)("wrong geometry type");const e=t;e.m_description=(0,r.c)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,r.c)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,r.c)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,r.c)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,r.c)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,r.c)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let t=0,s=2*(this.m_description.getTotalComponentCount()-2);t<s;t++)if(!(0,r.G)(this.m_attributes[t],i.m_attributes[t],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,e,s){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,i.a)("");const t=new a.T,n=0===e?s:0,r=1===e?s:0;t.setShiftCoords(n,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,s),this.setEndAttribute(t,e,s)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=W.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}j.s_maxMonotonicPartParams=8;class Z extends h.G{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class U{constructor(t){this.m_geoms=[],this.m_description=(0,n.l)(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,i.a)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&(0,i.a)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.G.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new r.E;const i=new r.E;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new n.E;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,i.t)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,i.t)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);(0,i.t)("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new U({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.a)("");const e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(const t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,i.g)(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const t of this.m_geoms){const s=t.getBoundary();s&&e.m_geoms.push(s)}return t}clone(){return new U({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.G.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(s.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.a)("");const e=t;e!==this&&(this.m_geoms=(0,r.c)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}}function O(t,e=-1){return new Z(t,e)}U.type=i.G.enumGeometryCollection;class Q extends j{constructor(t){super(t)}}class $ extends Q{isTrue3D(){return!0}constructor(t){super(t)}}function K(t,e,s){J(e,t.getStartXY(),t.getEndXY(),s)}function J(t,e,s,i){(0,r.U)(e,s,t,i)}function tt(t,e){return(0,r.q)(t.m_XStart,t.m_XEnd,e)}function et(t,e){return(0,r.q)(t.m_YStart,t.m_YEnd,e)}function st(t,e,s){e.value()<=.5?(0,r.a3)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,s):(0,r.a4)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,s)}function it(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function nt(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,r.c)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,r.c)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=(0,r.c)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function rt(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:function(t,e){const s=ht(t,e.m_XStart,e.m_YStart),i=ht(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=ht(e,t.m_XStart,t.m_YStart),r=ht(e,t.m_XEnd,t.m_YEnd);return!(n<0&&r<0||n>0&&r>0)&&(lt(t)>lt(e)?ut(t,e):ut(e,t))}(t,e)?4:0}function ot(t,e,s,i,n,o,a,h){null!==i&&(0,r.w)(i,2,Number.NaN),null!==n&&(0,r.w)(n,2,Number.NaN),null!==s&&(0,r.ac)(s,r.P,2);const m=function(t,e,s,i,n,o,a,h,m){const u=at(t,e.getStartXY(),a,!1),l=at(t,e.getEndXY(),a,!1),c=at(e,t.getStartXY(),a,!1),g=at(e,t.getEndXY(),a,!1);let d=0,_=0;if(!Number.isNaN(u)){let s=!1;h&&(0,r.N)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[_]=u),o&&(o[_]=0),i&&i[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(l)){let s=!1;h&&(0,r.N)(l,0,1)&&t.getCoord2D(l).isEqualPoint2D(e.getEndXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=l),o&&(o[_]=1),i&&i[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(2!==_&&!Number.isNaN(c)&&!(0===u&&0===c||0===l&&1===c)){let s=!1;h&&(0,r.N)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getStartXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=0),o&&(o[_]=c),i&&i[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(2!==_&&!Number.isNaN(g)&&!(1===u&&0===g||1===l&&1===g)){let s=!1;h&&(0,r.N)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=1),o&&(o[_]=g),i&&i[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return m&&(o=(0,r.c)(n,n=o)),2===_&&n&&n[0]>n[1]&&(n[1]=(0,r.c)(n[0],n[0]=n[1]),o&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),i&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),_;if(d>0)return 0;const p=function(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,h=o*n-i*a;if(0===h)return r.P.getNAN();const m=4*(0,r.O)()*(Math.abs(o*n)+Math.abs(i*a)),u=e.m_XStart-t.m_XStart,l=e.m_YStart-t.m_YStart,c=o*l-u*a,g=4*(0,r.O)()*(Math.abs(o*l)+Math.abs(u*a)),d=c/h,_=Math.abs(h),p=(g*_+m*Math.abs(c))/(h*h)+(0,r.O)()*Math.abs(d);if(d<-p||d>1+p)return r.P.getNAN();const f=i*l-u*n,x=f/h,P=(4*(0,r.O)()*(Math.abs(i*l)+Math.abs(u*n))*_+m*Math.abs(f))/(h*h)+(0,r.O)()*Math.abs(x);if(x<-P||x>1+P)return r.P.getNAN();let y=(0,r.s)(d,0,1),v=(0,r.s)(x,0,1);const C=r.P.getNAN();K(t,y,C);const E=r.P.getNAN();if(K(e,v,E),!s||r.P.distance(C,E)>s){const i=r.P.getNAN();(0,r.U)(C,E,.5,i),y=t.getClosestCoordinate(i,!1),v=e.getClosestCoordinate(i,!1);const n=r.P.getNAN();K(t,y,n);const o=r.P.getNAN();K(e,v,o),n.subThis(o);const a=n.length(),h=(t.absNorm()+e.absNorm())*(0,r.g)();if(a>Math.max(s,h))return r.P.getNAN()}return new r.P(y,v)}(t,e,a);return Number.isNaN(p.x)?0:(i&&(i[0]=t.getCoord2D(p.x)),n&&(n[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,s,i,n,o,a,h);return i&&(i.length=m),n&&(n.length=m),s&&(s.length=m),m}function at(t,e,s,i){const n=r.P.getNAN(),o=r.P.getNAN();let a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(n.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));const h=a?1:0,m=a?0:1,u=r.P.getNAN();u.setSub(e,n);let l=u.length(),c=3*l*(0,r.O)();if(l<=Math.max(s,c))return i&&0===l?Number.NaN:h;if(u.setSub(e,o),l=u.length(),c=3*l*(0,r.O)(),l<=Math.max(s,c))return i&&0===l?Number.NaN:m;u.setCoords(o.x-n.x,o.y-n.y);const g=u.length();if(g>0){const t=1/g;u.scale(t);const i=r.P.getNAN();i.setSub(e,n);const l=i.dotProduct(u),c=8*i.dotProductAbs(u)*(0,r.O)();u.leftPerpendicularThis();const d=i.dotProduct(u),_=8*i.dotProductAbs(u)*(0,r.O)(),p=Math.max(s,c);if(l<-p||l>g+p)return Number.NaN;const f=Math.max(s,_);if(Math.abs(d)<=f){let i=l*t;i=(0,r.s)(i,0,1);const u=r.P.getNAN();if(J(i,n,o,u),r.P.distance(u,e)<=s){if(i<.5){if(r.P.distance(u,n)<=s&&r.P.distance(e,n)<=s)return h}else if(r.P.distance(u,o)<=s&&r.P.distance(e,o)<=s)return m;return a?1-i:i}}}return Number.NaN}function ht(t,e,s){const i=r.P.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=r.P.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const o=n.crossProduct(i),a=4*(0,r.O)()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?-1:o<-a?1:0}function mt(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,o=i?t.m_YStart:t.m_YEnd,a=r.P.getNAN();return a.x=e.getEndX()-n,a.y=e.getEndY()-o,!(s.dotProduct(a)>3*(0,r.O)()*s.dotProductAbs(a))||(a.x=e.getStartX()-n,a.y=e.getStartY()-o,s.dotProduct(a)<=3*(0,r.O)()*s.dotProductAbs(a))}function ut(t,e){const s=r.P.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!mt(t,e,s,!1)&&(s.negateThis(),!!mt(t,e,s,!0))}function lt(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}class ct{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&(0,i.r)("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&(0,i.r)("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,i.r)(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount()||(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,0))}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&(0,i.r)(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,i.q)(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.r)("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&(0,i.r)(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!=(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.r)(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&(0,i.r)(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class gt{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,i.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new gt;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0===--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,i.g)(this.uniqueUse())}setQuadTree(t){(0,i.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,i.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function dt(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function _t(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function pt(t,e){return t.readPoint2D(e+4)}function ft(t){const e=t.getGeometryType();return e===i.G.enumEllipticArc?10:e===i.G.enumBezier?4:e===i.G.enumRationalBezier2?5:e===i.G.enumBezier2?2:void(0,i.d)("")}function xt(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Pt(t,e,s,i){const n=t.getPathStart(e),o=t.getPathEnd(e);if(o-n<3)return;const a=2*n,h=r.P.getNAN();s.queryPoint2D(a,h);const m=h.x,u=h.y,l=r.P.getNAN();s.queryPoint2D(a+2,l);const c=r.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)s.queryPoint2D(t,c),i.pe((c.x-h.x)*(l.y-u)),h.setCoordsPoint2D(l),l.setCoordsPoint2D(c);i.pe((m-h.x)*(l.y-u))}function yt(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var vt=n.V;class Ct{static toSegType(t){let e=0;switch(t){case i.G.enumLine:e=1;break;case i.G.enumBezier:e=2;break;case i.G.enumEllipticArc:e=4;break;case i.G.enumRationalBezier2:e=8;break;case i.G.enumBezier2:e=16;break;default:(0,i.d)("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Et extends d{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?i.G.enumPolygon:i.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,i.g)(this.m_bPolygon);const e=this.getPathIndexFromPointIndex(t),s=this.getPathStart(e);if(s===t)return;const n=this.getPathEnd(e);(t>=n||t<s)&&(0,i.a)("change_ring_start_point");for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=vt.getComponentCount(i);this.m_vertexAttributes.get(e).rotate(s*r,t*r,n*r)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(s,t,n),this.m_curveData.m_segmentParamIndex.rotate(s,t,n))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new n.A(t),s=new r.K(0),i=new r.K(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new ct({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();Pt(this,r,n,i),yt(0,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),Pt(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),o=xt(s);for(let t=0;t<o;t++){const s=this.m_curveData.m_segmentParams.read(i+t),o=e.m_curveData.m_segmentParams.read(n+t);if(!(0,r.Q)(s,o))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=(0,n.D)(1,0),this.m_pathFlags=(0,n.F)(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Ct),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new r.K(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new r.K(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return(0,i.g)(0),0}calculatePathLength3D(t,e){return(0,i.g)(0),0}copyTo(t){(0,i.h)(t.getGeometryType())||(0,i.a)(""),this!==t&&super.copyTo(t)}swap(t){(0,i.g)(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){const s=e.getXY();if(this.setXYCoordsWithCurves(t,s.x,s.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,s){if(this.hasNonLinearSegments()){const i=Et.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=i;const n=this.getPrevSegmentTypeFromPath(i,t),o=this.getNextSegmentType(t);if(1!==n||1!==o){let a=t-1;const h=new Rr;1!==n&&(this.isClosedPath(i)&&t===this.getPathStart(i)&&(a=this.getPathEnd(i)-1),this.getSegmentBuffer(a,h,!0));const m=new Rr;1!==o&&this.getSegmentBuffer(t,m,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const l=new r.P(e,s);return 1!==n&&(h.get().changeEndPoints2D(h.get().getStartXY(),l),this.replaceSegmentImpl(a,t,h.get(),!0)),void(1!==o&&(m.get().changeEndPoints2D(l,m.get().getEndXY()),this.replaceSegmentImpl(t,u,m.get(),!0)))}}this.setXYCoordsNoCurves(t,e,s)}setXYZWithCurves(t,e){this.hasNonLinearSegments()?(this.setXYCoordsWithCurves(t,e.x,e.y),this.setAttributeNoCurves(1,t,0,e.z)):this.setXYZNoCurves(t,e)}setAttributeWithCurves(t,e,s,i){if(0===t&&this.hasNonLinearSegments()){const t=this.getXY(e);0===s?t.x=i:t.y=i,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,s,i)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,s){this.setXYCoordsWithCurves(t,e,s)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,s,i){this.setAttributeWithCurves(t,e,s,i)}setAttributeWithCurvesFromArray(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){n<2&&(0,i.r)("");const t=this.getXY(e);t.x=s[0],t.y=s[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,s,n)}setAttributeFromArray(t,e,s,i){this.setAttributeWithCurvesFromArray(t,e,s,i)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,i.a)("Multi_path_impl::add");for(let s=0,i=t.getPathCount();s<i;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addPathMultiPoint(t,e,s,i){s<0&&(s=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,s,i)}addSegmentsFromPath(t,e,s,n,r){if(this===t&&(0,i.a)("Multi_path_impl.add_segments_from_path"),r||0!==this.getPathCount()||(r=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||n<0||s+n>t.getSegmentCountPath(e))&&(0,i.r)("add_segments_from_path"),0===n)return;const o=t.getPathStart(e),a=t.isClosedPath(e)&&s+n===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let h=n;const m=o+s;let u=m+1;r&&(h++,u--),!r&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||(0,i.a)("add_segments_from_path: start point mismatch"));const l=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange(),r){if(0===h)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const c=a?h-1:h;for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=vt.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(c>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=vt.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*l,t,c*i,i*l),a&&this.m_vertexAttributes.get(e).insertRange(i*l+c*i,t,i,i*l);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*l,t.m_vertexAttributes.get(n),i*u,c*i,!0,i,i*l)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(l+c),t.m_vertexAttributes.get(n),i*o,i,!0,i,i*(l+c))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=m;s<n;s++)e+=xt(t.m_curveData.m_segmentFlags.read(i)),i++;if(e>0){this.initSegmentData(e);let s=m,i=l-(r?0:1),o=0;for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),Et.isNonLinearSegmentFlag(e)){o++;let n=t.m_curveData.m_segmentParamIndex.read(s);const r=xt(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentParams.read(n);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,n++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(o)}}if(a){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&(0,i.a)("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const i=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,i,!0),i.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,s)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const r=n?1:0;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++)if(this.m_vertexAttributes.get(t)){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i);this.m_vertexAttributes.get(t).reverseRange(n*(s+r),n*(e-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,i.a)("");const s=this.getPathStart(t),n=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*s,i*n,i*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=s,i=s+n;e<i;e++){const s=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(s,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(s,n,this.m_pointCount)}for(let s=t+1;s<=e;s++){const t=this.m_paths.read(s);this.m_paths.write(s-1,t-n)}if(this.m_pathFlags)for(let s=t+1;s<=e;s++){const t=this.m_pathFlags.read(s);this.m_pathFlags.write(s-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,s,r){this===e&&(0,i.a)("Multi_path_impl::insert_path");const o=this.getPathCount();if(!r&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&(0,i.a)(""),t>o&&(0,i.a)(""),t<0&&(t=o),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const a=e.getPathStart(s),h=e.getPathSize(s);if(0===h)return this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=e.isClosedPath(s)&&!r?1:0;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<o?this.getPathStart(t):m;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=e.getDescription().getAttributeIndex(s),n=vt.getComponentCount(s);if(i>=0&&e.m_vertexAttributes.get(i))0!==u&&this.m_vertexAttributes.get(t).insertRangeFromStream(l*n,e.m_vertexAttributes.get(i),n*a,n,!0,n,n*m),this.m_vertexAttributes.get(t).insertRangeFromStream((l+u)*n,e.m_vertexAttributes.get(i),n*(a+u),n*(h-u),r,n,n*(m+u));else{const e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(l*n,e,n*h,n*m)}}const c=m+h;this.m_paths.add(c);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=e.getPathFlagsStreamRef().read(s);if(g&=-9,this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,s=0;for(let i=0;i<h;i++)s+=xt(e.m_curveData.m_segmentFlags.read(t)),t++;if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,n.F)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,n.D)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(l,1,h,m),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,h,m)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=(0,n.G)(s),t=a;let i=l,r=0;for(let s=0;s<h;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const n=xt(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<n;t++){const t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}r++,this.incCurveType(s,1)}t++,i++}this.modifyCurveCounter(r)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,n,r){const o=this.getPathCount();(t>o||s<0)&&(0,i.a)(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,e,s,n,r,2*a);else{const t=vt.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e),i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,s,n,r){const o=e.getImpl(),a=this.getPathCount();(t>a||s<0)&&(0,i.a)("");const h=n<0?o.getPointCount()-s:n;if(h>o.getPointCount()&&(0,i.a)(""),s>=o.getPointCount()&&(0,i.a)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=s;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):m;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),i=vt.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(l*i,s,i*u,i*h,r,i,i*m)}else{const s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,e,s,n,r,o,a){if(this===s&&(0,i.a)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),n<0&&(n=s.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||n>=s.getPathCount()||o>s.getPathSize(n))&&(0,i.r)(""),!o)return;if(this.mergeVertexDescription(s.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=s.m_pathFlags.read(n);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),u=m+e;o<0&&(o=s.getPathSize(n));const l=s.getPathStart(n),c=l+o;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i),g=s.m_description.getAttributeIndex(i);if(g<0||!s.m_vertexAttributes.get(g)){const e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*u,e,c*n,n*h);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(n*(m+e),s.m_vertexAttributes.get(g),n*(l+r),o*n,a,n,n*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,o,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,o,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&(0,i.r)(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=vt.getComponentCount(s),n=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange((h+e)*i,n,i*r,i*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const m=a.getPointCount();if((n<0||n>m)&&(0,i.r)(""),(r<0||n+r>m)&&(r=m-n),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&(0,i.r)(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===h){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const l=this.getPathStart(t),c=l+e,g=0+r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=vt.getComponentCount(s);if(a.getDescription().getAttributeIndex(s)<0){const e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(i*c,e,g*i,i*u);continue}const h=a.getAttributeStreamRef(s);this.m_vertexAttributes.get(t).insertRangeFromStream(i*(l+e),h,i*(0+n),r*i,o,i,i*u)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,r,u),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,r,u),e>0&&this.isNonLinearSegment(l+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(l+e-1),-1),this.m_curveData.m_segmentFlags.write(l+e-1,1),this.m_curveData.m_segmentParamIndex.write(l+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.r)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e),i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.r)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByValNoCurves(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&(0,i.r)("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,i.r)("Multi_path.remove_point");const o=n+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*o,s,s*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=s;e>=t+1;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNextSegmentType(t){return this.hasNonLinearSegments()?this.m_curveData.m_segmentFlags.read(t):1}getPrevSegmentTypeFromPath(t,e){if(!this.hasNonLinearSegments())return 1;const s=this.getPathStart(t);if(e>s)return this.m_curveData.m_segmentFlags.read(e-1);if(e===s){if(this.isClosedPath(t)){const e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}(0,i.d)("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)Et.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=Et.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new n.P({x:t,y:e}))}startPath(t){this.startPathPoint(new n.P({pt:t}))}startPath3D(t){this.startPathPoint(new n.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new n.P({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&(0,i.a)("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new n.P({vd:this.m_description});t.copyCommonAttributesTo(i),s=i}else s=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,n.D)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,n.F)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoordsNoCurves(this.m_pointCount-1,t,e);else{const s=(0,n.q)(),i=new n.P({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=(0,n.n)(this.m_description,(0,n.z)()),s=(0,n.q)(),i=new n.P({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new n.f(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=(0,n.q)(),s=new n.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,i.d)("");const e=this.getPathCount();if(t>e&&(0,i.a)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,i.d)("");const s=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!==0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(i*r,this.m_vertexAttributes.get(t),i*n,i,!0,1,i*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,i.d)(""),t>this.getPathCount()&&(0,i.a)(""),this.m_pathFlags||(0,i.d)(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&(0,i.d)(""),this.isEmpty())return;this.m_pathFlags||(0,i.d)("");let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)this.isClosedPath(s)&&(this.getPathSize(s)>0?t++:this.m_pathFlags.clearBits(s,1));if(0===t)return;const s=this.hasNonLinearSegments();let r=0;const o=this.getPathCount(),a=this.m_description.getAttributeCount(),h=new Array(a);let m=null,u=null;for(let e=0;e<o;++e){const i=this.getPathStart(e),o=this.getPathSize(e),l=this.isClosedPath(e);if(o>0){const e=i+r;for(let s=0;s<a;s++)if(this.m_vertexAttributes.get(s)){const r=this.m_description.getSemantics(s),a=vt.getComponentCount(r);if(!h[s]){const e=a*(this.m_pointCount+t),i=(0,n.w)(r,e);h[s]=i}h[s].writeRange(e*a,o*a,this.m_vertexAttributes.get(s),i*a,!0,1),l&&h[s].writeRange((e+o)*a,a,this.m_vertexAttributes.get(s),i*a,!0,1)}if(s){if(null===m){const e=this.m_pointCount+t;m=(0,n.F)(e),u=(0,n.D)(e)}m.writeRange(e,o,this.m_curveData.m_segmentFlags,i,!0,1),u.writeRange(e,o,this.m_curveData.m_segmentParamIndex,i,!0,1),l&&(m.write(e+o,1),u.write(e+o,-1))}}this.m_paths.write(e,i+r),l&&(this.m_pathFlags.clearBits(e,1),++r)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,h[t]);s&&(this.m_curveData.m_segmentFlags=m,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,i.a)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);1!==s&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,i.a)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,i.a)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),n=this.getPathEnd(t)-1;s.equals(this.getXY(n))||(0,i.a)("close_path_with_segment: start point mismatch");const r=e.getGeometryType();if(r===i.G.enumLine)return void this.closePathWithLine(t);{const t=ft(e);this.initSegmentData(t);const s=Ct.toSegType(r),i=this.m_curveData.m_segmentFlags.read(n);if(i!==s)this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(n);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(n,s)}}const s=this.m_pathFlags.read(t);1&s||this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(t){return(0,i.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Et.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof o.Envelope2D)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=(0,n.q)(),r=new n.P({vd:s,attribBuffer:i,initDefaultValues:!1});for(let s=0,i=4;s<i;s++){const n=e?i-s-1:s;t.queryCornerByVal(n,r),0===s?this.startPathPoint(r):this.lineToPoint(r)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,i.a)("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new n.P;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new n.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const r=(0,n.q)(),o=new n.P({vd:s,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===i.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),s||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,i.a)("add_segment: start point mismatch"),s&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=(0,n.q)(),e=new n.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const r=ft(t);this.initSegmentData(r),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=r;const h=Ct.toSegType(a);this.incCurveType(h,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,h)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,s,n){for(let e=t;e<s-1;e++)this.isClosedPath(e)&&(0,i.a)("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,e,s,n);if(0!==o)for(let i=1;i<r;i++){const r=this.m_description.getSemantics(i);this.interpolateAttributesSemanticsImpl(r,t,e,s,n,o)}}interpolateAttributesSemantics(t,e,s,n,r){if(0===t)return;this.hasAttribute(t)||(0,i.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,i.a)("angular interpolation");for(let t=e;t<n-1;t++)this.isClosedPath(t)&&(0,i.a)("cannot interpolate across closed paths");const o=this.calculateSubLength2D(e,s,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,s,n,r,o)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(t,e,s,n){if(0===t)return;this.hasAttribute(t)||(0,i.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,i.a)("angular interpolation");const r=this.calculatePathSubLength2D(e,s,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,e,s,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,n,o){const a=this.querySegmentIterator(),h=this.getPathStart(e)+s,m=this.getPathStart(i)+n,u=vt.getComponentCount(t),l=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,u);const g=(0,r.d)(vt.maxComponentCount(),Number.NaN);(0,r.b)(g,l,0,0,u);let d=0;const _=vt.getDefaultValue(t),p=vt.getInterpolation(t);a.resetToVertex(h,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===m)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,u),a.previousSegment();do{const e=a.nextSegment();if(a.getEndPointIndex()===m)return;d+=e.calculateLength2D(),(0,r.A)(p,l,c,g,0,u,d/o,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,u)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,n,o){(0,i.g)(0!==t);const a=this.querySegmentIterator(),h=vt.getInterpolation(t),m=this.getPathStart(e)+s,u=this.getPathStart(e)+n;if(u===m)return;const l=vt.getComponentCount(t),c=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,l);const g=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,g,l);const d=new r.K(0);a.resetToVertex(m,e),a.setCirculator(this.isClosedPath(e));const _=vt.getDefaultValue(t),p=(0,r.d)(vt.maxComponentCount(),Number.NaN);(0,r.b)(p,c,0,0,l);const f=0===o;let x=.5;do{const e=a.nextSegment();if(this.setAttributeFromArrayNoCurves(t,a.getStartPointIndex(),p,l),!f){const t=e.calculateLength2D();d.pe(t),x=d.getResult()/o}(0,r.A)(h,c,g,p,0,l,x,_)}while(a.getEndPointIndex()!==u)}querySegment(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.a)("get_segment"),this.getSegmentFromPath(n,r,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const e=this.getPathIndexFromPointIndex(t),s=t-this.getPathStart(e);return s>=this.getSegmentCountPath(e)&&(0,i.a)("get_segment"),this.getSegmentTypeFromPath(e,s)}getSegmentFromPath(t,e,s,r){const o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef();let h=1;switch(a&&(h=31&a.read(o)),h){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:(0,i.d)("")}const m=s.get();let u,l=null;if(r?(l=(0,n.l)(),m.assignVertexDescription(l)):m.assignVertexDescription(this.m_description),u=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,I(m,this.getXY(o)),q(m,this.getXY(u)),!r)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);for(let t=0;t<s;t++){const s=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,s);const i=this.getAttributeAsDbl(e,u,t);m.setEndAttribute(e,t,i)}}if(Et.isNonLinearSegmentFlag(h)){const t=this.m_curveData.m_segmentParamIndex.read(o);m.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);pt(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,e,s,n=!1){const o={iSegment:-1},a=n?o:{tSegment:0};if(s.setEmpty(),this.isEmpty())return o;if((t<0||t>=this.getPathCount())&&(0,i.a)("query_point_along_path"),e<0)return o;const h=this.getPathSize(t);if(0===h)return o;if(1===h)return this.getPointByVal(this.getPathStart(t),s),a.tSegment=0,o.iSegment=this.getPathStart(t),o;const m=this.querySegmentIteratorAtVertex(this.getPathStart(t)),u=new r.K(0);for(;m.hasNextSegment();){const t=m.nextSegment(),i=t.calculateLength2D(),n=u.getResult();if(u.add(i),u.getResult()>=e){let r=e-n;r>i&&(r=i);const h=t.lengthToT(r);return t.queryCoord(h,s),a.tSegment=h,o.iSegment=m.getStartPointIndex(),o}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,s,n,o,a){{let t=0;for(let r=0;r<e;++r)n&&n[r].setEmpty(),o&&(o[r]=-1),a&&(a[r]=0),t>s[r]&&(0,i.a)("query_points_along"),t=s[r]}const h=this.getPathSize(t);if(0===e||0===h)return 0;if(1===h){const e=this.getPathStart(t);return n&&this.getPointByVal(e,n[0]),a&&(a[0]=0),o&&(o[0]=e),1}const m=this.getPathStart(t),u=new r.K(0),l=this.querySegmentIteratorAtVertex(m);let c=0,g=0,d=s[c];for(;l.hasNextSegment();){const t=l.nextSegment(),i=t.calculateLength2D(),r=u.getResult();for(u.add(i);u.getResult()>=d;){let h=d-r;h>i&&(h=i);const m=t.lengthToT(h);if(n&&t.queryCoord(m,n[g]),a&&(a[g]=m),o&&(o[g]=l.getStartPointIndex()),g++,c++,d=s[c],c===e)return g}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;n&&this.getPointByVal(e,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;n&&this.getPointByVal(e+1,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,s,n,o){{let r=0;for(let a=0;a<t;++a)s&&s[a].setEmpty(),n&&(n[a]=-1),o&&(o[a]=0),r>e[a]&&(0,i.a)("query_points_along"),r=e[a]}if(0===t)return 0;const a=new r.K(0),h=this.querySegmentIterator();let m=-1,u=0,l=0,c=e[u];for(;h.nextPath();)for(;h.hasNextSegment();){m=h.getPathIndex();const i=h.nextSegment(),r=i.calculateLength2D(),g=a.getResult();for(a.add(r);a.getResult()>=c;){let a=c-g;a>r&&(a=r);const m=i.lengthToT(a);if(s&&i.queryCoord(m,s[l]),o&&(o[l]=m),n&&(n[l]=h.getStartPointIndex()),l++,u++,c=e[u],u===t)return l}}if(m<0)return 0;if(this.isClosedPath(m)){const t=this.getPathStart(m),e=0;s&&this.getPointByVal(t,s[l]),o&&(o[l]=e),n&&(n[l]=t),l++}else if(this.getPathSize(m)>1){const t=this.getPathEnd(m)-2,e=1;s&&this.getPointByVal(t+1,s[l]),o&&(o[l]=e),n&&(n[l]=t),l++}return l}querySegmentIterator(){return new ct({parent:this})}querySegmentIteratorAtVertex(t){return new ct({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,s){if(e instanceof n.E&&(0,i.g)(0,"not implemented for Envelope"),e instanceof n.p&&(0,i.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,i.a)(""),this.isEmpty())return void e.setEmpty();const r=this.getAttributeStreamRef(0),a=o.Envelope2D.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),s=2*this.getPathEnd(t);e<s;){const t=s-e;(0,i.g)(!(1&t)),a.mergePointsInterleaved(r,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){const n=this.querySegmentIterator();if(n.resetToPath(t),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const i=o.Envelope2D.constructEmpty();s?t.queryEnvelope(i):t.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}else(0,i.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=xt(4)*this.m_curveData.m_arcCount+xt(2)*this.m_curveData.m_bezierCount+xt(8)*this.m_curveData.m_rbezier2Count+xt(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,s=this.getPointCount();e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(s)&&(t+=xt(s))}const e=(0,n.G)(t);let s=0;for(let t=0,i=this.getPointCount();t<i;t++){const i=this.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(i)){let n=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,s);const r=xt(i);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,i.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,n.D)(0),this.m_pathFlags=(0,n.F)(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=(0,n.D)(0),this.m_pathFlags=(0,n.F)(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new bt(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new Ct),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;(0,i.o)("")}let r=0,o=e-1;for(;o>r;){const e=r+(o-r>>1);if(s<t.read(e))o=e-1;else{if(!(s>=t.read(e+1)))return e;r=e+1}}return r}getHighestPointIndex(t){(0,i.g)(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),n=this.getPathStart(t);let o=-1;const a=new r.P;a.y=Number.NEGATIVE_INFINITY,a.x=Number.NEGATIVE_INFINITY;for(let t=n+0;t<s;t++){const s=e.readPoint2D(2*t);-1===a.compare(s)&&(o=t,a.setCoordsPoint2D(s))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,i.a)("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let i,n;return e<0?(i=0,n=this.m_pointCount):(i=this.getPathStart(e),n=this.getPathEnd(e)),s.applyTransformation(t,2*i,n-i),void this.notifyModifiedFlags(2001)}const n=new this.m_segmentBufferCTor,o=this.getPathCount();let a=e<0?0:e;do{const i=this.getPathStart(a),o=this.getPathEnd(a),h=this.isClosedPath(a),m=s.readPoint2D(2*i);if(!this.hasNonLinearSegmentsPath(a)){s.applyTransformation(t,2*i,o-i);continue}const u=r.P.getNAN();for(let e=i;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){const r=h&&e+1===o;r&&s.writePoint2D(2*i,m),this.getSegmentBuffer(e,n,!0),n.get().applyTransformation(t);const a=this.m_curveData.m_segmentParamIndex.read(e);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),s.writePoint2D(2*e,n.get().getStartXY()),r&&s.writePoint2D(2*i,n.get().getEndXY());continue}const r=2*e;s.queryPoint2D(r,u),t.transformInPlace(u),s.writePoint2D(r,u)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,n){const r=this.getPathStart(t)+e,o=this.getPathStart(s)+n;(o<r||r<0||o>this.getPointCount()-1)&&(0,i.q)("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(r,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===o)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return h}calculatePathSubLength2D(t,e,s){const n=this.getPathStart(t)+e,r=this.getPathStart(t)+s;(n<0||r>this.getPointCount()-1)&&(0,i.q)("");const o=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||(0,i.a)("cannot iterate across an open path"),o.setCirculator(!0)),n===r)return 0;let a=0,h=0;o.resetToVertex(n,t);do{h+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=o.Envelope2D.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&(0,i.a)("Multi_path_impl::add");let s=this.getPathCount();for(let i=0,n=t.getPathCount();i<n;i++)this.addPath(t,i,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.a)("getSegmentBuffer"),this.getSegmentFromPath(n,r,e,s)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.G.enumLine;case 2:return i.G.enumBezier;case 4:return i.G.enumEllipticArc;case 8:return i.G.enumRationalBezier2;case 16:return i.G.enumBezier2;default:(0,i.d)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),n=this.getPathEnd(e),o=n-s;for(let e=s;e<n;e++){const n=31&this.m_curveData.m_segmentFlags.read(e);if(1===n)continue;2!==n&&(0,i.t)("ensure_xy_monotone_segments");const a=(e-s+1)%o+s,h=this.m_curveData.m_segmentParamIndex.read(e),m=(0,r.m)(r.P,4);m[0]=this.getXY(e),m[3]=this.getXY(a),m[1].x=this.m_curveData.m_segmentParams.read(h),m[1].y=this.m_curveData.m_segmentParams.read(h+1),m[2].x=this.m_curveData.m_segmentParams.read(h+2),m[2].y=this.m_curveData.m_segmentParams.read(h+3),b(m)&&(t=!0,this.m_curveData.m_segmentParams.write(h,m[1].x),this.m_curveData.m_segmentParams.write(h+1,m[1].y),this.m_curveData.m_segmentParams.write(h+2,m[2].x),this.m_curveData.m_segmentParams.write(h+3,m[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=(0,n.H)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=(0,n.I)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Et.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Ct),Et.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Ct),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Ct);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,n.F)(e,1),this.m_curveData.m_segmentParamIndex=(0,n.D)(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,n.G)(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Ct),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=(0,r.e)(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,s){(t<0||t>=this.getPointCount())&&(0,i.a)("Multi_path_impl.replace_segment"),(0,i.g)(e.isCurve());const n=this.getPathIndexFromPointIndex(t),r=this.getPathStart(n),o=(t-r+1)%this.getPathSize(n)+r;{const s=this.getXY(t),n=this.getXY(o),r=!s.isEqualPoint2D(e.getStartXY())||!n.isEqualPoint2D(e.getEndXY());(0,i.g)(!r)}this.replaceSegmentImpl(t,o,e,s)}replaceSegmentImpl(t,e,s,o){const a=s.getDescription();this.mergeVertexDescription(a);const h=(0,r.d)(32,Number.NaN),m=new n.P({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),l=xt(u),c=ft(s);let g,d=!1;l>=c?((0,i.g)(null!==this.m_curveData),d=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(c),d=!1,g=this.m_curveData.m_curveParamWritePoint);const _=s.getGeometryType(),p=Ct.toSegType(_);o||(s.queryStart(m),this.setPointByValNoCurves(t,m),s.queryEnd(m),this.setPointByValNoCurves(e,m)),this.m_curveData.m_segmentParamIndex.write(t,1!==p?g:-1),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&s.writeInBufferStream(this.m_curveData.m_segmentParams,g),d||(this.m_curveData.m_curveParamWritePoint+=c),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}setAttributeImpl(t,e,s){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,i.a)("");const t=new a.T,n=0===e?s:0,r=0===e?0:1;t.setShiftCoords(n,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,s)}toFlatGeometry(){const t=this.m_bPolygon?"polygon":"polyline",e=this.getPathCount(),s=this.m_paths?this.m_paths.getArray():new Int32Array,i=this.m_paths?this.m_pathFlags.getArray():new Int8Array;let n,r,o,a=0,h=0;if(this.m_curveData){const{m_segmentFlags:t,m_segmentParamIndex:e,m_segmentParams:s}=this.m_curveData;n=t?.getArray()??new Int8Array,r=e?.getArray()??new Int32Array,o=s?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,h=this.m_curveData.m_bezierCount}return{type:t,...this.exportVertexAttributes(),partCount:e,partOffsets:s,partFlags:i,segmentFlags:n,segmentIndices:r,segmentParams:o,segmentCountArc:a,segmentCountBezier:h}}}Et.st_totalCurveCount=0;class bt{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o.Envelope2D(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=o.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Dt extends Et{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Rr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Rr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Rr):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Rr,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Rr,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,i.d)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Rr)}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Dt.type}getDimension(){return 1}createInstance(){return new Dt({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Dt.type=i.G.enumPolyline;var St=i.G;function wt(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===St.enumPolygon)return 0!==t.calculateArea2D();if(s===St.enumPolyline)return Tt(t.getImpl(),0,!0).bNotEmpty;if(s===St.enumEnvelope)return!0;if((0,i.f)(s))return!!t.isClosed();if((0,i.e)(s))return!1;if(s===St.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(wt(s.getGeometry(t),e))return!0;return!1}(0,i.t)("")}function At(t,e){const s=t.getGeometryType();if(s===St.enumPolygon){const e=new Dt({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===St.enumPolyline)return Tt(t.getImpl(),0,!1).boundary;if(s===St.enumEnvelope){const e=new Dt({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,i.f)(s)){const e=new _({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new n.P;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===St.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=At(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if((0,i.e)(s))return new n.P({vd:t.getDescription()});(0,i.t)("")}function Tt(t,e,s){const i=!1,o=t;let a=null;if(s||(a=new _({vd:o.getDescription()})),!o.isEmpty()){const t=new n.a(0);for(let e=0,s=o.getPathCount();e<s;e++)if(o.getPathSize(e)>0&&!o.isClosedPathInXYPlane(e)){const s=o.getPathStart(e);t.add(s);const i=o.getPathEnd(e)-1;t.add(i)}if(t.size()>0){const e=new n.B,i=o.getAttributeStreamRef(0),h={userSort(t,e,s){const n=r.P.getNAN(),o=r.P.getNAN();s.sort(t,e,(t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,o),n.compare(o)))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),h);let m=i.readPoint2D(2*t.read(0)),u=0,l=1;const c=new n.P;for(let e=1,n=t.size();e<n;e++){const n=i.readPoint2D(2*t.read(e));if(n.isEqualPoint2D(m))t.read(u)>t.read(e)?(t.write(u,(0,r.j)()),u=e):t.write(e,(0,r.j)()),l++;else{if(1&l){if(s)return{bNotEmpty:!0,boundary:new _({})}}else t.write(u,(0,r.j)());m=n,u=e,l=1}}if(1&l){if(s)return{bNotEmpty:!0,boundary:new _({})}}else t.write(u,(0,r.j)());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==(0,r.j)();e++)o.getPointByVal(t.read(e),c),a.add(c)}}}return s?{bNotEmpty:i,boundary:new _({})}:{bNotEmpty:i,boundary:a}}function It(t,e,s,n){const o=4*(0,r.O)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,r.O)();if(1===t.getMaxDerivative()){(0,i.g)(s>0);const a=Yt(t,0,e,(0,r.O)(),o);return n[0]=a.root,a.cRoots}let h,m=[];const u=new r.E(e.vmin-o,e.vmax+o);m.push(new r.P(u.vmin,u.vmax));let l=0;for(let i=t.getMaxDerivative()-1;i>=0;i--){h=m,m=[];for(let u=0,c=h.length;u<c;u++){if(h[u][0]<h[u][1]){let c,g,d;if(i===t.getMaxDerivative()-1?({root:c,funcAtRoot:g,cRoots:d}=Yt(t,i,r.E.construct(h[u][0],h[u][1]),a,.5*o)):({root:c,funcAtRoot:g,cRoots:d}=Xt(t,i,r.E.construct(h[u][0],h[u][1]),0,.5*o)),1===d){if(0===i)l<s&&(h[u][0]<=e.vmin&&h[u][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),h[u][0]<=e.vmax&&h[u][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),n[l]=e.snapClip(c),l>0?n[l]-n[l-1]>o&&l++:l++);else{const t=r.P.getNAN();t[0]=h[u][0],t[1]=c,m.push(t);const e=r.P.getNAN();e[0]=c,e[1]=h[u][1],m.push(e)}continue}}m.push(h[u])}}return l}function Nt(t,e,s,i,n,o){const a=(0,r.m)(r.H,2),h=Lt(new r.H(t),new r.H(e),new r.H(s),i,n,a);return o[0]=a[0].value(),o[1]=a[1].value(),h}function qt(t,e,s,i,n,o,a){const h=(0,r.m)(r.H,3),m=zt(new r.H(t),new r.H(e),new r.H(s),new r.H(i),n,o,h);return a[0]=h[0].value(),a[1]=h[1].value(),a[2]=h[2].value(),m}function Mt(t,e,s,i,n,o,a,h){return function(t,e,s,i,n,o,a,h){const m=(0,r.d)(s*s,Number.NaN);m.fill(0),(0,r.b)(h,i,0,0,s);const u=(0,r.d)(s,Number.NaN),l=(0,r.d)(s,Number.NaN),c=(0,r.d)(s,Number.NaN);let g=t(h,s,e);let d=0;for(d=0;d<100;d++){const i=g;for(let t=0;t<s;++t)l[t]=h[t];if(d%s===0){m.fill(0);for(let t=0;t<s;t++)m[t*s+t]=1}let a=0,_=0;for(let i=0;i<s;++i){for(let t=0;t<s;++t)u[t]=m[i*s+t];const r=g;g=Ft(t,e,h,u,n,o,s);const l=r-g;l>a&&(_=i,a=l)}for(let t=0;t<s;t++)u[t]=h[t]-l[t],c[t]=h[t]+(h[t]-l[t]);const p=t(c,s,e);if(p<i&&2*(i-2*g+p)*(0,r.a)(i-g-a)<(0,r.a)(i-p)*a){g=Ft(t,e,h,u,n,o,s);for(let t=0;t<s;++t)m[_*s+t]=m[(s-1)*s+t],m[(s-1)*s+t]=u[t]}if(i<=g)return t(h,s,e)}return g}(t,e,s,i,n,o,0,h)}function Yt(t,e,s,n,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=s.vmax,u=0,l=Number.MAX_VALUE,c=t.getValue(e,h),g=t.getValue(e,m),d=0,_=0,p=0;if(c>=0&&g>=0||c<=0&&g<=0)return Math.abs(c)<Math.abs(g)?(a.funcAtRoot=c,a.root=h,a.cRoots=0===c?1:0,a):(a.funcAtRoot=g,a.root=m,a.cRoots=0===g?1:0,a);Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),u=h,d=c;let f=!0,x=0;for(;0!==g&&Math.abs(h-m)>n*Math.abs(m)+o;x++){let s=x>64;if(!s){_=c!==d&&g!==d?h*g*d/((c-g)*(c-d))+m*c*d/((g-c)*(g-d))+u*c*g/((d-c)*(d-g)):m-g*(m-h)/(g-c);const t=(3*h+m)/4;if(s=!(_>t&&_<m||_>m&&_<t),!s){const t=n*Math.abs(m)+o;if(f){const e=Math.abs(m-u);s=Math.abs(_-m)>=.5*e||e<t}else{const e=Math.abs(u-l);s=Math.abs(_-m)>=.5*e||e<t}}}if(s?(_=(h+m)/2,f=!0):f=!1,p=t.getValue(e,_),0===p)return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!s){const s=h-_,i=_-m;if(Math.abs(s)>10*Math.abs(i)){let s=m+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);(0,r.e)(c)*(0,r.e)(i)>0?(h=s,c=i):s=(0,r.q)(h,m,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=h-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);(0,r.e)(g)*(0,r.e)(s)>0?(m=i,g=s):i=(0,r.q)(h,m,.25)}}}l=u,u=m,d=g,(0,r.e)(c)*(0,r.e)(p)<0?(m=_,g=p):(h=_,c=p),Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),128===x&&(0,i.d)("Root_finder iterations exceeded")}return a.root=m,a.funcAtRoot=g,a.cRoots=1,a}function Xt(t,e,s,n,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=t.getValue(e,h),u=s.vmax,l=t.getValue(e,u);if(m>=0&&l>=0||m<=0&&l<=0)return Math.abs(m)<Math.abs(l)?(a.funcAtRoot=m,a.root=h,a.cRoots=0===m?1:0,a):(a.funcAtRoot=l,a.root=u,a.cRoots=0===l?1:0,a);l<0&&(l=(0,r.c)(m,m=l),u=(0,r.c)(h,h=u));let c=.5*(h+u),g=Math.abs(u-h),d=g,_=t.getValue(e,c),p=t.getValue(e+1,c),f=4,x=1,P=0,y=0,v=1,C=0;for(;++C<100;){let s;C>32||0===p||2===v&&P>1||1===v&&f<4?(v=1,x>1&&x--):(v=2,y>1&&Math.abs(2*_)>Math.abs(g*p)&&x++),g=d;let i=!1;if(1===v)do{if(y>2){const t=16*Math.abs(g);if(.5*Math.abs(h-u)>t){const e=Math.min(h,u),i=Math.max(h,u);if(c===e){s=c,c=e+t,d=c-s;break}if(c===i){s=c,c=i-t,d=c-s;break}}}d=.5*(u-h),s=c,c=h+d,i=h===c||u===c}while(0);else for(;;){d=x*_/p,s=c,c-=d,i=c===s;const t=Math.min(h,u),e=Math.max(h,u);if(c<t){if(x>1){c=s,x--;continue}d=s-t,c=t}else if(c>e){if(x>1){c=s,x--;continue}d=s-e,c=e}break}if(i||Math.abs(d)<o){s!==c&&(_=t.getValue(e,c));break}_=t.getValue(e,c),p=t.getValue(e+1,c);const n=h,r=u;_<0?(m=_,h=c):(l=_,u=c),2===v&&(h===n&&u===r||y>1&&Math.abs(d)>=.5001*Math.abs(g))?P++:P=0,1===v?(f++,y=0):(f=0,y++)}return 100===C&&(0,i.d)("Root_finder iterations exceeded"),a.root=c,a.funcAtRoot=_,a.cRoots=1,a}function Ft(t,e,s,i,n,o,a){const h=i.slice(0,a);let m=0;for(let t=0;t<a;t++)m+=i[t]*i[t];if(m=Math.sqrt(m),m>0)for(let t=0;t<a;t++)h[t]/=m;let u=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;{const t=(0,r.d)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{const s=Math.abs(h[t]),i=Math.abs(h[e]);return s<i?-1:s>i?1:0});for(let e=0;e<a;e++){const i=t[e];if(0===h[i])continue;let a=(n[i]-s[i])/h[i],m=(o[i]-s[i])/h[i];m<a&&(m=(0,r.c)(a,a=m)),a>u&&(u=a),m<l&&(l=m)}}let c=0;const g=(Math.abs(u)+Math.abs(l))*(0,r.O)()*100,d=(0,r.d)(a,Number.NaN),_=h.slice();function p(i,n){for(let t=0,e=a;t<e;t++)d[t]=s[t]+i*_[t];return t(d,a,e)}g>0&&(c=function(t,e,s,i,n,o){return function(t,e,s,i,n,o){const a=(0,r.aq)();let h=i,m=t(h,e),u=s,l=n,c=t(u,e),g=t(l,e);m>c&&(m=c,h=u),m>g&&(m=g,h=l);let d=u,_=l,p=c,f=g;p>f&&(p=(0,r.c)(f,f=p),_=(0,r.c)(d,d=_));let x=h-d,P=d-_;const y=.5*Math.min(o,l-u),v=2*y;let C,E=0;for(C=0;C<100&&!(l-u<=v);++C){const s=u+.5*(l-u);let i=E>0;if(!i&&Math.abs(P)<=y&&(i=!0,E=3),!i){const t=h-d,e=h-_,s=t*(m-f);let n=e*(m-p),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*P/2)||r<=n*(u-h)||r>=n*(l-h)?(i=!0,E=3):(P=x,x=r/n)}i&&(P=h>=s?u-h:l-h,x=a*P,E--);let n=h+x;n<u+y?n=u+y:n>l-y&&(n=l-y);const r=t(n,e);r<m?(n>=h?(u=h,c=m):(l=h,g=m),_=d,d=h,h=n,f=p,p=m,m=r):(n<h?(u=n,c=r):(l=n,g=r),r<=p||d===h?(_=d,d=n,f=p,p=r):(r<=f||_===h||_===d)&&(_=n,f=r))}return h}(t,e,s,i,n,o)}(p,null,u,0,l,g));const f=p(c);for(let t=0,e=a;t<e;t++)s[t]=(0,r.s)(d[t],n[t],o[t]);return f}function Rt(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Lt(t,e,s,i,n,o){if(0===t.value())return n?(o[0].set(1),i.containsCoordinate(o[0].value())?1:0):Rt(e,s,i,o[0]);if(n){let e=2;return o[0].set(1),o[1].setE(s).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),e}const a=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(r.a5));if(a.lt(r.J))return 0;const h=new r.H(e.value()>=0?1:-1),m=a.clone().sqrtThis(),u=new r.H(-.5).mulThisE(e.clone().addThisE(h.clone().mulThisE(m)));let l=0;o[0].setE(u.divE(t));const c=new r.H(o[0].value()),g=new r.H(t.value()).mulE(c).addE(new r.H(e.value()).mulE(c).addE(new r.H(s.value())));return g.isZero()||jt(o[0],t,e,s,o[0]),i.containsCoordinate(o[0].value())&&l++,0!==m.value()&&0!==u.value()?(o[l].assign(s.divE(u)),c.set(o[l].value()),g.assign(new r.H(t.value()).mulE(c).addE(new r.H(e.value()).mulE(c).addE(new r.H(s.value())))),g.isZero()||jt(o[l],t,e,s,o[l]),i.containsCoordinate(o[l].value())&&l++,2===l&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),l):l}function zt(t,e,s,n,o,a,h){if(0===t.value())return Lt(e,s,n,o,a,h);if(a){let s=1;h[0].set(1);const i=h.slice(s),a=Lt(t,e.addE(t),n.negate(),o,!1,i);if(a>0){s+=a;for(let t=1;t<s;t++)h[t].eq(r.I)&&(h[s-1]=(0,r.c)(h[t],h[t]=h[s-1]),s--)}const m=h.slice(0,s);m.sort((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);for(let t=0;t<s;++t)h[t]=m[t];return s}return function(t,e,s,n,o,a){const h=(0,r.m)(r.H,3);let m=0;const u=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(u.value())&&(h[0].setE(u),m=1);const l=(0,r.m)(r.H,2),c=Lt(t.mul(3),e.mul(2),s,o,!1,l);if(c<0)return n.isZero()?-1:0;for(let t=0;t<c;t++)o.containsCoordinate(l[t].value())&&h[m++].setE(l[t]);(0,r.C)(h,0,m,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const g=(0,r.m)(r.H,5);g[0].set(o.vmin);for(let t=0;t<m;t++)g[1+t].setE(h[t]);g[1+m].set(o.vmax);const d=m+2;let _=1,p=0;{const i=g[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(n).isZero()){const r=Bt(t,e,s,n);i.setError(r.estimateError(i.value())),a[p]=i,p++,_++}}for(let r=_;r<d;r++){const h=g[r].clone(),m=t.clone().mulThisE(h).addThisE(e).mulThisE(h).addThisE(s).mulThisE(h).addThisE(n).isZero();if(m||!g[r].eq(g[r-1])){if(m||kt(g[r-1].value(),g[r].value(),g[r-1].clone().addThisE(g[r]).divThisByPower2(2),t,e,s,n,h)){if(p>0&&h.eq(a[p-1]))continue;if(p>=3&&(0,i.d)("cubic_polynomial_solver_too_many_roots"),m){const i=Bt(t,e,s,n);h.setError(i.estimateError(h.value()))}a[p]=h,p++}if(g[r].value()===o.vmax)break;m&&r++}}return p}(t,e,s,n,o,h)}function Vt(t,e,s,n,o,a){return(a<e||e<0)&&(0,i.a)("nth_degree_real_roots"),function(t,e,s,i,n){const o=new Gt(t,e,s,(0,r.O)());let a=0;if(2===o.truePower)a=Lt(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Rt(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=It(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let t=0;t<a;t++)n[t].setError(o.getError(n[t].value()));return a}(t,e,s,n,o)}function Bt(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class Gt{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let s=0,i=this.truePower-t;s<=i;++s){e.push(this.coefs[s+t].clone());let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new r.K(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new r.K(0),i=new r.H(1),n=new r.H(0);for(let t=0,r=this.power;t<=r;++t)n.addThisE(this.coefs[t].mulE(i)),s.pe(i.value()*this.coefs[t].eps()),i.mulThis(e);s.pe(n.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);const i=new r.H(1),n=new r.H(0);for(let s=0,r=this.truePower-e;s<=r;++s)n.addThisE(this.curCoefs[s].mulE(i)),i.mulThis(t);if(!n.isZero())return Math.pow(o*s.getResult()/Math.abs(n.value()),1/e)}return 0}}function Ht(t,e,s,i,n,o){let a=t,h=e,m=h-a;if(!o){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(h=(0,r.c)(a,a=h),n=(0,r.c)(s,s=n)),s>=0||n<=0)return!1}let u,l=!1,c=s,g=0;for(;g<100;g++){const t=i.calcF(c);if(u=i.calcDF(c),u.isZero())return!1;if(!t.value()||g>3&&t.isZero()){l=!0;break}o||(t.value()<0?a=c:h=c);const e=t.value()/u.value(),s=c-e;o||(s>=a&&s<=h||s>=h&&s<=a)&&Math.abs(e)<=.5*m?(c=s,m=Math.abs(e)):(m=Math.abs(.5*(h-a)),c=.5*(a+h))}return!!l&&(n.set(c,i.estimateError(c)),!0)}function kt(t,e,s,i,n,r,o,a){return Ht(t,e,s.value(),Bt(i,n,r,o),a,!1)}class Wt{constructor(t,e,s){this.coefs=(0,r.m)(r.H,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new r.H(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new r.H(t);return r.H.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new r.H(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function jt(t,e,s,i,n){return Ht(0,0,t.value(),new Wt(e,s,i),n,!0)}var Zt=n.V;class Ut extends Q{constructor(t){return void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&(0,i.a)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,i.t)("unexpected constructor param"))}getBoundary(){return At(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Ti(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),Ti(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Ti(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.Envelope2D){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Gi(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ni(s,this.m_weights,e);const i=new r.P;for(const s of e)this.queryCoord2D(s,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof a.T){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new Ut({vd:this.m_description})}calculateLength2D(){return qi(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp):r.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),function(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const n=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],h=new r.H,m=new r.H,u=new r.H;if(s.value()<=.5){const t=(0,r.ad)(n[0],n[1],s),e=(0,r.ad)(n[1],n[2],s);h.setE((0,r.ad)(t,e,s));const i=(0,r.ad)(o[0],o[1],s),l=(0,r.ad)(o[1],o[2],s);m.setE((0,r.ad)(i,l,s));const c=(0,r.ad)(a[0],a[1],s),g=(0,r.ad)(a[1],a[2],s);u.setE((0,r.ad)(c,g,s))}else{const t=(0,r.ae)(n[0],n[1],s),e=(0,r.ae)(n[1],n[2],s);h.setE((0,r.ae)(t,e,s));const i=(0,r.ae)(o[0],o[1],s),l=(0,r.ae)(o[1],o[2],s);m.setE((0,r.ae)(i,l,s));const c=(0,r.ae)(a[0],a[1],s),g=(0,r.ae)(a[1],a[2],s);u.setE((0,r.ae)(c,g,s))}h.divThisE(u),m.divThisE(u);const l=new r.P(h.value(),m.value());Pn([t[0].value(),t[1].value(),t[2].value()],l),i.x.set(l.x,h.eps()),i.y.set(l.y,m.eps())}([y.constructPoint2D(i[0]),y.constructPoint2D(i[1]),y.constructPoint2D(i[2])],[new r.H(n[0]),new r.H(n[1]),new r.H(n[2])],e,s)}(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0)return void K(new Fr({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void K(new Fr({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}const i=(0,r.m)(r.P,3);this.queryControlPoints(i),cn(i,this.m_weights,t,e)}getCoordX(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Zt.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Zt.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=(0,r.d)(3,Number.NaN);t.queryWeights(o),function(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const o=(0,r.m)(y,4);(function(t,e,s,n,o){const a=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,s,n,o){(0,i.g)(!0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=y.constructCoords(0,0)}const h=Fi(a,e,0,n),m=function(t,e,s){if(s.toDouble()<=.5){const e=(0,r.ad)(t[0],t[1],s),i=(0,r.ad)(t[1],t[2],s);return(0,r.ad)(e,i,s)}{const e=(0,r.ae)(t[0],t[1],s),i=(0,r.ae)(t[1],t[2],s);return(0,r.ae)(e,i,s)}}(e,0,n),u=h.divE(m);o[0].setE(u);const l=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],c=Fi([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],l,0,n).mul(2),g=m.sqr(),d=c.divE(g);o[1].setE(d)}(a,[new r.H(e[0]),new r.H(e[1]),new r.H(e[2])],0,n,o)})(t,e,0,s,o),n.setE(o[1])}(n,o,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.a)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,3);this.queryControlPoints(n);const o=[0,0,0];Ki(n,this.m_weights,t,e,n,o),s.setControlPointsAndWeights(n,o)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Zt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Zt.getDefaultValue(e))}getClosestCoordinate(t,e){return ki(this,t,r.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return ki(this,t,0,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=Ii(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)Oi(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),o=(0,r.m)(r.H,2),a=new r.E(0,1);let h=0;const m=(0,r.m)(r.P,3);if(this.queryControlPoints(m),t){if(n[0]=new r.H(m[0].y).sub(e).mul(this.m_weights[0]),n[1]=new r.H(m[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.H(m[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.H(m[0].x).sub(e).mul(this.m_weights[0]),n[1]=new r.H(m[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.H(m[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.C)(s,0,h,r.a7);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.Envelope2D)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ki(s,this.m_weights,t.vmin,t.vmax,s,[0,0,0]),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return qi(this,t,!0)}lengthToT(t){return function(t,e){const s=qi(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new zi(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=function(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=dn(e);if(1===s){const e=(0,r.m)(r.P,3);Oe(t,e);const s=e[2].clone(),i=e[1].clone(),n=new r.P,o=s.y*i.x-s.x*i.y;return n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60,n}if(0===s)return new r.P(0,0);(0,i.g)(s>0);const n=t[1].sub(t[0]),o=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atan2(t,e),a=s*t*e,h=s*s,m=n.mul(2*(2+h)),u=o.mul(2*h-5),l=m.add(u).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return l.add(c).mul(i)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atanh(t/e),a=s*t*e,h=s*s,m=n.mul(4).sub(o.mul(5)),u=n.add(o).mul(2*h),l=m.add(u).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return l.add(c).mul(i)}}(e,s)}(this),s=Vi(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=Ii(t),a=Bi(t),h=a/t.calculateUpperLength2D();let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Ai(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}queryCoord2DMP(t,e){const s=(0,r.m)(r.P,3);return this.queryControlPoints(s),function(t,e,s,i){const n=s.lte(r.a6)?r.M.lerpLo:r.M.lerpHi,[o,a,h]=[e.map((e,s)=>t[s].x.mul(e)),e.map((e,s)=>t[s].y.mul(e)),e].map(([t,e,i])=>n(n(t,e,s),n(e,i,s),s)),m=new r.P(o.divThis(h).value(),a.divThis(h).value());Pn(t.map(t=>t.asPoint2D()),m),i.x=r.M.constructDouble(m.x),i.y=r.M.constructDouble(m.y)}(s.map(t=>C.constructPoint2D(t)),this.m_weights.map(t=>r.M.constructDouble(t)),r.M.constructDouble(t),e)}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),Li(e,this.m_weights,t)}getDerivative(t){const e=(0,r.s)(t,0,1),s=(0,r.m)(r.P,4);return Mi(this,1,e,s),s[1]}getCurvature(t){const e=(0,r.m)(r.P,4);Mi(this,2,t,e);const s=e[1].sqrLength();return 0===s?Number.NaN:(e[1].divThis(Math.sqrt(s)),e[1].crossProduct(e[2])/s)}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,3);return this.queryControlPoints(t),Ui(t)}getMonotonicPartParams(t,e){const s=Ii(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-i>t)return!1;const n=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/i>n)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Vi(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,i.g)(0),0}queryEnvelopeW(t,e){ji(this,t,e)}setSegmentFromCoordsForStitcher(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),i=r.P.sqrDistance(e[1],e[2]);let n=e[0].clone(),o=s;s>i&&(n=e[2].clone(),o=i);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(n)),a}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),i=r.P.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Oi(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformInPlace(t.m_cp):(0,r.U)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Oi(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Hi(e,Gi(this))}reverseImpl(){this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=(0,r.m)(r.P,3);this.queryControlPoints(i);const o=(0,r.m)(r.P,3);s.queryControlPoints(o);const a=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let t=0;t<3;t++){const s=new n.f;s.setCoordsPoint2DZ(i[t].mul(this.m_weights[t]),this.m_weights[t]);const r=new n.f;if(r.setCoordsPoint2DZ(o[t].mul(a[t]),a[t]),!s.isEqual(r,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,r.c)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ti(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(ji(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Ii(t);let h=0;const m=[];let u=a.specialPoints[0];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=wi(t,e,u,n);if(0===m.length)m.push(r);else if(r.t===r.tmin)(0,i.g)(m.at(-1).d<=r.d),m.at(-1).tmax=r.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,i.g)(m.at(-1).d>=r.d);const t=m.at(-1).tmin;m[m.length-1]=r,m.at(-1).tmin=t}else m.push(r);u=n}for(const t of m)if(t.d<=n){const e=t.t;s?(s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Ti(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,n,r,o){(n<=0||o<=0||r<0)&&(0,i.a)("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&(0,i.a)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}Ut.type=i.G.enumRationalBezier2;var Ot=n.V;class Qt extends Q{constructor(t){void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):(0,i.d)("unexpected constructor args")}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),Ee(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),Ee(this)}getGeometryType(){return i.G.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Ye(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[];De(this,e);const s=new r.P;for(const i of e)this.queryCoord2D(i,s),t.mergeNe(s)}return}(0,i.t)("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}(0,i.g)(0)}createInstance(){return new Qt({vd:this.m_description})}calculateLength2D(){return Se(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=(0,r.m)(r.P,3);this.queryControlPoints(i),$e(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=y.constructPoint2D(t[1]),n=new y;(0,r.a3)(2,y.constructPoint2D(t[0]),i,e,n);const o=new y;(0,r.a3)(2,i,y.constructPoint2D(t[2]),e,o);const a=new y;(0,r.a3)(2,n,o,e,a),s.setE(a)}else{const i=y.constructPoint2D(t[1]),n=new y;(0,r.a4)(2,y.constructPoint2D(t[0]),i,e,n);const o=new y;(0,r.a4)(2,i,y.constructPoint2D(t[2]),e,o);const a=new y;(0,r.a4)(2,n,o,e,a),s.setE(a)}}(i,e,s)}(this,t,e)}queryCoord2DMP(t,e){(0,i.g)(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=(0,r.X)(this.getStartX(),this.m_cp.x,t),s=(0,r.X)(this.m_cp.x,this.getEndX(),t);return(0,r.X)(e,s,t)}{const e=(0,r.Y)(this.getStartX(),this.m_cp.x,t),s=(0,r.Y)(this.m_cp.x,this.getEndX(),t);return(0,r.Y)(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=(0,r.X)(this.getStartX(),this.m_cp.x,t),s=(0,r.X)(this.m_cp.x,this.getEndX(),t);return(0,r.X)(e,s,t)}{const e=(0,r.Y)(this.getStartY(),this.m_cp.y,t),s=(0,r.Y)(this.m_cp.y,this.getEndY(),t);return(0,r.Y)(e,s,t)}}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Ot.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Ot.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){{const e=y.constructPoint2D(t[1]).subE(y.constructPoint2D(t[0])),i=new r.H(1).subE(s),n=y.constructPoint2D(t[2]).subE(y.constructPoint2D(t[1])),o=e.mulE(i).addE(n.mulE(s));return o.mulThisE(new r.H(2)),o}}(t,0,e))}(i,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&(0,i.a)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const n=(0,r.m)(r.P,3);this.queryControlPoints(n),He(n,t,e,n),s.constructPoints(n)}splitBezierIgnoreAttributes(t,e,s){(0,i.g)(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Ot.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Ot.getDefaultValue(e))}getClosestCoordinate(t,e){return Fe(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Fe(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=be(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)Ve(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.H,3),o=(0,r.m)(r.H,2),a=new r.E(0,1);let h=0;if(t){if(n[0]=new r.H(this.getStartY()).sub(e),n[1]=new r.H(this.m_cp.y).subE(new r.H(this.getStartY())).mulThisByPower2(2),n[2]=new r.H(this.getStartY()).add(this.getEndY()).subE(new r.H(this.m_cp.y).mulThisByPower2(2)),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.H(this.getStartX()).sub(e),n[1]=new r.H(this.m_cp.x).subE(new r.H(this.getStartX())).mulThisByPower2(2),n[2]=new r.H(this.getStartX()).add(this.getEndX()).subE(new r.H(this.m_cp.x).mulThisByPower2(2)),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.Z)(s,h);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new o.Envelope2D;this.queryEnvelope(t);const s=new r.E;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),He(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Se(this,t,!0)}lengthToT(t){return function(t,e){const s=Se(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new ve(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,3);!function(t,e,s=!1){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),Oe(i,e,s)}(this,e);const s=e[2],i=e[1],n=new r.P,o=s.y*i.x-s.x*i.y;n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60;const a=qe(this);return n.x+=(e[0].x-t.x)*a,n.y+=(e[0].y-t.y)*a,n}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=be(t),a=B(t),h=Math.min(a/t.calculateUpperLength2D(),1e-7);let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Ce(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPoints(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,i.a)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.s)(t,0,1);let s=Ie(this,1,e);return s.isZero()&&(s=Ie(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Ie(this,1,(0,r.s)(t,0,1))}getCurvature(t){const e=Ie(this,1,t),s=Ie(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new o.Envelope2D;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){const s=be(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-i>t)return!1;const n=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/i>n)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return qe(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Le(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);let o=s[0].clone(),a=i;i>n&&(o=s[2].clone(),a=n);let h=!1;return a<=e&&0!==a&&(h=!0,t.setControlPoint1(o)),h}(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);s[0].clone();let o=i;return i>n&&(s[2].clone(),o=n),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ve(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformInPlace(t.m_cp):(0,r.U)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Ve(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Xe(e,Ye(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ee(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,i,n){const o=new p;if(function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),Le(i,e,s)}(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=new r.P,h=Fe(t,e,r.E.unit(),!1);return t.queryCoord2D(h,a),r.P.distance(a,e)<=n?(i&&(i[0]=h),1):0}(this,t,e.length,e,s)}endPointModified(){Ee(this)}clearEndPointModified(){}}Qt.type=i.G.enumBezier2;class $t{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,i.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}scaleRangeToUnitInterval(t,e){const s=e;s.subThis(t);const i=this.power();for(let e=0;e<=i;e++){const n=new this.m_zeroCtor;for(let s=e;s<=i;s++){const i=this.m_elements[s];i.mulDoubleThis((0,r.ao)(s,e));const o=t.pow(s-e);i.mulThis(o),n.addThis(i)}const o=s.pow(e);n.mulThis(o),this.m_elements[e]=n}}fmSubThis(t,e){return(0,i.g)(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].addThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,i.g)(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(t){return(0,i.g)(0),this}subNumber0(t){return(0,i.g)(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let s=e;s<=n;++s)this.m_elements[s].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=n+1;e<=i;++e)this.m_elements[e].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let i=s;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let s=r+1;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let i=0,n=e.power();i<=n;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return(0,i.g)(0),this}mulBigint0(t){return(0,i.g)(0),this}mulBigIntThis(t){return(0,i.g)(0),this}mulInt320(t){return(0,i.g)(0),this}div0(t){return(0,i.g)(0),this}absThis(){return(0,i.g)(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let o=n.power();const a=n.power()-t.power();let h=a;for(e.m_elements=(0,r.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){s.assignMove(n);break}if(o===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[h]=s.clone()}h--,o--}s.updatePower(),e.updatePower()}divThis(t){return(0,i.g)(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,i.g)(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(r.M.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{const s=e.hiBitIndex();return t<s?s:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){const e=this.power(),s=this.m_elements[e];s.mulDoubleThis(e);for(let i=e-1;i>=1;--i){s.mulThis(t);const e=this.m_elements[i];e.mulDoubleThis(i),s.addThis(e)}return s}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class Kt extends $t{constructor(t){super(void 0===t?{zeroCtor:r.M}:{...t,zeroCtor:r.M})}clone(){return new Kt({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let t=e-1;t>=0;--t)s.mulThis(i),s.addThis(this.m_elements[t].abs());return s}}class Jt extends $t{constructor(t){super(void 0===t?{zeroCtor:Kt}:{...t,zeroCtor:Kt})}clone(){return new Jt({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new Kt({coef0:t[s]}));return this.updatePower(),this}}function te(t,e,s,n,o,a,h,m,u,l,c,g,d,_,p,f,x,P,y,v=!1){const C={polypoly1:new Jt,polypoly2:new Jt,polyX2:new Kt,polyY2:new Kt,polyX2Deriv:new Kt,polyY2Deriv:new Kt,polypolyX1:new Jt,polypolyY1:new Jt,polypolyX1Deriv:new Jt,polypolyY1Deriv:new Jt,lazyPolypolyD1:new Jt,lazyPolypolyD1Deriv:new Jt,lazyPolyD2:new Kt,lazyPolyD2Deriv:null,polypoly11:new Jt,polypoly12:new Jt,tempPp:new Jt,tempPp1:new Jt,tempPp2:new Jt,tempP:new Kt,tempP1:new Kt,tempP2:new Kt};C.polyX2.construct(h,m),C.polyY2.construct(u,l),C.polypolyX1.constructFromMPValues(t,e),C.polypolyY1.constructFromMPValues(s,n),C.polypoly11.assignCopy(C.polypolyX1),C.polypoly12.assignCopy(C.polypolyY1),c&&(C.lazyPolyD2.construct(c,g),C.polypoly11.mulElementThis(C.lazyPolyD2),C.polypoly12.mulElementThis(C.lazyPolyD2)),o?(C.lazyPolypolyD1.constructFromMPValues(o,a),C.lazyPolypolyD1Deriv=new Jt({copy:C.lazyPolypolyD1}),C.lazyPolypolyD1Deriv.derivative1This(),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyX2),C.polypoly11.subThis(C.tempPp),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyY2),C.polypoly12.subThis(C.tempPp)):(C.polypoly11.sub0This(C.polyX2),C.polypoly12.sub0This(C.polyY2)),C.polypolyX1Deriv.assignCopy(C.polypolyX1),C.polypolyX1Deriv.derivative1This(),C.polypolyY1Deriv.assignCopy(C.polypolyY1),C.polypolyY1Deriv.derivative1This(),o&&(C.polypolyX1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyX1),C.polypolyX1Deriv.subThis(C.tempPp2),C.polypolyY1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyY1),C.polypolyY1Deriv.subThis(C.tempPp2)),C.polyX2Deriv.assignCopy(C.polyX2),C.polyX2Deriv.derivative1This(),C.polyY2Deriv.assignCopy(C.polyY2),C.polyY2Deriv.derivative1This(),c&&((0,i.g)(null===C.lazyPolyD2Deriv),C.lazyPolyD2Deriv=new Kt({copy:C.lazyPolyD2}),C.lazyPolyD2Deriv.derivative1This(),C.polyX2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyX2),C.polyX2Deriv.subThis(C.tempP1),C.polyY2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyY2),C.polyY2Deriv.subThis(C.tempP1)),C.polypoly1.assignCopy(C.polypoly11),C.polypoly1.mulElementThis(C.polyX2Deriv),C.tempPp.assignCopy(C.polypoly12),C.tempPp.mulElementThis(C.polyY2Deriv),C.polypoly1.addThis(C.tempPp),C.polypoly2.assignCopy(C.polypolyX1Deriv),C.polypoly2.mulElementThis(C.polyY2Deriv),C.tempPp.assignCopy(C.polypolyY1Deriv),C.tempPp.mulElementThis(C.polyX2Deriv),C.polypoly2.subThis(C.tempPp);let E=[];const b=[];x||(x=[]),f||(f=[]),he(C.polypoly11,C.polypoly12,C.tempP);const D=r.ai.ldexp(-59).toDouble(),S=[];let w=me(C.tempP,0,p,D,64,S,P,P);if(w<0)return-1;for(let t=0;t<w;t++){const e=C.tempP1,s=C.tempP2;Kt.evaluateCoefs(C.polypoly11,S[t],e);const n=(0,r.aj)(e.m_elements,e.power()+1);n.sort((t,e)=>t.compare(e)),Kt.evaluateCoefs(C.polypoly12,S[t],s);const o=(0,r.aj)(s.m_elements,s.power()+1);o.sort((t,e)=>t.compare(e));const a=n[0],h=n.at(-1),m=o[0],u=o.at(-1);h.subThis(a),u.subThis(m);const l=h.subThis(u).GEZ(),c=58,g=[];let d;if(d=me(l?e:s,0,_,r.ai.ldexp(-59).toDouble(),c,g,P,P),d<0&&(0,i.d)("mp_curve_proximity"),d>0){const n=l?s:e;for(let e=0;e<d;e++){let s;if(l){const i=C.tempP;Kt.evaluateCoefs(C.polypoly12,S[t].addDouble(Number.EPSILON),i),s=i.evaluate(g[e])}else{const i=C.tempP;Kt.evaluateCoefs(C.polypoly11,S[t].addDouble(Number.EPSILON),i),s=i.evaluate(g[e])}const o=n.evaluateDerivative(g[e]).abs().mulDoubleThis(Number.EPSILON),a=n.evaluate(g[e]);o.addThis(s.sub(a).absThis()),o.ldexpThis(3),a.absThis(),a.lt(o)?b.push((0,r.k)(g[e].toDouble(),S[t].toDouble())):(0,i.g)(a.gte(o))}}}w=b.length,he(C.polypoly1,C.polypoly2,C.tempP);const A=[];let T=me(C.tempP,0,p,D,64,A);T<0&&(T=0);for(let t=0;t<T;t++){Kt.evaluateCoefs(C.polypoly1,A[t],C.tempP1);const e=[];let s=me(C.tempP1,0,_,D,64,e);if(0!==s)if(Kt.evaluateCoefs(C.polypoly2,A[t],C.tempP2),s<0){if(s=me(C.tempP2,0,_,D,64,e),s<0)continue;for(let i=0;i<s;i++)E.push((0,r.k)(e[i].toDouble(),A[t].toDouble()))}else{const i=C.tempP2.absEvaluate(r.ai);i.mulThis(r.M.constructDouble(1e-12));for(let n=0;n<s;n++){const s=C.tempP2.evaluate(e[n]);s.absThis(),s.lt(i)&&E.push((0,r.k)(e[n].toDouble(),A[t].toDouble()))}}}if(T=E.length,0===w&&0===T)return 0;E=E.concat(b),E.sort((t,e)=>v?(0,r.a7)(t.second,e.second):(0,r.a7)(t.first,e.first));const I=(0,r.u)(E,(t,e)=>t.first===e.first&&t.second===e.second);E=E.slice(0,I),f.length=0,x.length=0;for(const t of E)f.push(t.first),x.push(t.second);return(0,i.g)(f.length===x.length),x.length}function ee(t,e,s,i,n,o,a,h,m,u,l,c,g){const d={polyIntersect:new Kt,polyX1:new Kt,polyY1:new Kt,polyX1Deriv:new Kt,polyY1Deriv:new Kt,lazyPolyD1:new Kt,lazyPolyD1Deriv:new Kt,tempP:new Kt,tempP1:new Kt,tempP2:new Kt,polypoly1Proximity:new Jt,polypoly2Proximity:new Jt};d.polyX1.construct(t,e),d.polyY1.construct(s,i),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.polyIntersect.assignCopy(d.polyX1),d.polyIntersect.mulThis(d.polyX1),d.polyIntersect.mulElementThis(a[0]),d.tempP.assignCopy(d.polyY1),d.tempP.mulThis(d.polyY1),d.tempP.mulElementThis(a[1]),d.polyIntersect.addThis(d.tempP),n?(d.lazyPolyD1.construct(n,o),d.tempP.assignCopy(d.lazyPolyD1),d.tempP.mulThis(d.lazyPolyD1),d.tempP.mulElementThis(a[2]),d.polyIntersect.addThis(d.tempP)):d.polyIntersect.add0(a[2]);{const n=a[0].clone(),o=n.clone();o.sqrThis();const h=a[1].clone(),m=h.clone();m.sqrThis();const u=a[2].clone(),l=n.clone();l.subThis(h),d.polyX1.construct(t,e),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1.construct(s,i),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(m),d.tempP.mulElementThis(u),d.polypoly1Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(h.mul(l).mul(u).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(n.mul(m)),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1),d.tempP1.mulElementThis(o.mul(h)),d.tempP.addThis(d.tempP1),d.tempP.add0(l.mul(l).mul(u)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulElementThis(l.mul(n).mul(h).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.construct0(n.mul(l).mul(l)),d.polypoly1Proximity.addElement(d.tempP),d.polypoly1Proximity.updatePower(),d.tempP.construct0(r.ah),d.polypoly2Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1Deriv),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1Deriv),d.tempP.addThis(d.tempP1),d.tempP.mulElementThis(n.mul(h)),d.polypoly2Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1Deriv),d.tempP.mulElementThis(l.mul(n)),d.polypoly2Proximity.addElement(d.tempP),d.polypoly2Proximity.updatePower()}const _=[],p=[];null===l&&(l=[]);let f=2*d.polyIntersect.power()+58;const x=.5*Number.EPSILON,P=[],y=me(d.polyIntersect,0,m,x,f,P,c,c);if(y<0)return-1;for(const t of P)p.push(t.toDouble());he(d.polypoly1Proximity,d.polypoly2Proximity,d.tempP),f=2*d.tempP.power()+58,P.length=0;let v=me(d.tempP,0,m,x,f,P);if(v<0&&(v=0),0===y&&0===v)return 0;for(const t of P)_.push(t.toDouble());const C=_.concat(p);l.length=C.length,(0,r.b)(l,C,0,0,C.length),(0,r.v)(l);const E=(0,r.u)(l,(t,e)=>0===(0,r.a7)(t,e));return l.length=E,l.length}function se(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function ie(t,e,s,i,n,o,a){if(t.isZero())return o?(a[0].setInt32(1),n.containsCoordinate(1)?1:0):se(e,s,n,a[0]);if(o){let e=2;return a[0].setInt32(1),s.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(s.div(t)),n.containsCoordinate(a[1].value())||(e=1),n.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,r.c)(a[0],a[0]=a[1])),e}const h=e.clone();h.sqrThis();const m=t.clone();if(m.mulThis(s).ldexpThis(2).negateThis().addThis(h),m.LZ())return 0;const u=i+2,l=r.M.sqrt(m,u),c=l.clone();e.LZ()&&c.negateThis(),c.addThis(e).limitPrecisionThis(u).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(c).divThis(r.M.constructAssign(t,u)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(a[0].value()))&&g++,l.isZero()||c.isZero()||(a[g].setThis(s).divThis(c).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,r.c)(a[0],a[0]=a[1]))),g}function ne(t,e,s,n,o,a,h,m){if(t.isZero())return ie(e,s,n,o,a,h,m);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.C)(m,0,e,(t,e)=>t.compare(e)),e};if(n.isZero()){let i=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),i=1),u(ie(t,e,s,o,a,h,m.slice(1)),i)}if(h){let s=0;a.containsCoordinate(1)&&(m[0].setInt32(1),s=1);const i=e.add(t),r=n.negate(),h=t.add(i).add(r).isZero();return u(ie(t,i,r,o,a,h,m.slice(s)),s)}const l=new r.M,c=new r.M,g=new r.M,d=e.clone();if(d.isZero())c.setThis(s),c.divThis(t),g.setThis(n),g.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();const i=e.clone();i.sqrThis();const r=t.clone();r.sqrThis(),c.setThis(t),c.mulThis(s).mulDoubleThis(3).subThis(i).divThis(r).divDoubleThis(3),g.setThis(i),g.mulThis(e),g.ldexpThis(1),l.setThis(t),l.mulThis(e).mulThis(s).mulDoubleThis(9),g.subThis(l),l.setThis(r),l.mulThis(n).mulDoubleThis(27),g.addThis(l),g.divThis(r).divThis(t).divDoubleThis(27)}if(c.isZero()){const t=g.clone();return t.negateThis(),t.isZero()?(m[0].setThis(d),pe(a,o,m,1)):(m[0].setThis(r.M.cubicRoot(t,o).add(d)),pe(a,o,m,1))}const _=g.clone();if(_.sqrThis().ldexpThis(-2),l.setThis(c.clone()),l.sqrThis().mulThis(c).divDoubleThis(27),_.addThis(l),_.isZero())return m[0].setThis(g),m[0].mulDoubleThis(3).divThis(c),m[1].setThis(m[0]),m[1].negateThis(),m[1].ldexpThis(-1),m[0].addThis(d),m[1].addThis(d),pe(a,o,m,2);if(_.GZ())return _.setThis(r.M.sqrt(_,o+8)),l.setThis(g),l.ldexpThis(-1).negateThis(),l.addThis(_),m[0].setThis(r.M.cubicRoot(l,o+8)),l.setThis(g),l.ldexpThis(-1).negateThis(),l.subThis(_),m[0].addThis(r.M.cubicRoot(l,o+8)),m[0].addThis(d),pe(a,o,m,1);l.setThis(c),l.divDoubleThis(3).negateThis(),(0,i.g)(l.GEZ());const p=r.M.sqrt(l,o+8),f=p.clone();f.negateThis(),f.addThis(d),p.addThis(d);const x=r.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),P=r.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),y=new Kt({zeroCtor:r.M});y.construct0(n),y.addElement(s),y.addElement(e),y.addElement(t);const v=new Kt({copy:y});v.derivative1This();let C=0;const E=(0,r.m)(r.M,4);E[C++].setThis(x),f.gt(x)&&f.lt(P)&&E[C++].setThis(f),p.gt(x)&&p.lt(P)&&E[C++].setThis(p),E[C++].setThis(P);const b=3*o;let D=52,S=Number.EPSILON;for(;D<b;)2*D<=b?(S*=S,D*=2):(S*=Number.EPSILON,D+=52);D+=2;let w=0,A=!1;for(let t=1;t<C;t++)if(ce(y,v,E[t-1],E[t],S,D,m[0])){w=1,A=t+1<C;break}if(!w)return 0;if(A){const t=new Kt({zeroCtor:r.M,coef0:m[0]});t.negateThis(),t.addElement(r.ai);const e=new Kt({zeroCtor:r.M}),s=new Kt({zeroCtor:r.M});y.div(t,e,s),(0,i.g)(2===e.power()),(0,i.g)(0===s.power());const n=ie(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,m.slice(1));(0,i.g)(n>=0&&n<=2),w+=n}return pe(a,o,m,w)}function re(t,e,s,i,n,o,a,h,m){if(t.isZero())return ne(e,s,i,n,o,a,h,m);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.C)(m,0,e,(t,e)=>t.compare(e)),e};if(n.isZero()){let n=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),n=1),u(ne(t,e,s,i,o,a,h,m.slice(n)),n)}const l=new Kt({zeroCtor:r.M,coef0:n});if(l.addElement(i),l.addElement(s),l.addElement(e),l.addElement(t),h){let t=0;a.containsCoordinate(1)&&(m[0].setInt32(1),t=1);const e=new Kt({zeroCtor:r.M,coef0:r.M.constructInt32(-1)});e.addElement(r.M.constructInt32(1));const s=new Kt({zeroCtor:r.M}),i=new Kt({zeroCtor:r.M});return l.div(e,s,i),u(ne(3===s.power()?s.getElement(3):r.ah.clone(),s.power()>=2?s.getElement(2):r.ah.clone(),s.power()>=1?s.getElement(1):r.ah.clone(),s.getElement(0),o,a,s.evaluate(r.ai).isZero(),m.slice(t)),t)}if(l.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,m[0].setDouble(0));l.getElement(0).isZero()&&l.power()>0;)l.shiftRight(1);const e=ne(3===l.power()?l.getElement(3):r.ah.clone(),l.power()>=2?l.getElement(2):r.ah.clone(),l.power()>=1?l.getElement(1):r.ah.clone(),l.getElement(0),o,a,!1,m.slice(t));return e>0&&(t+=e),(0,r.C)(m,0,t,(t,e)=>t.compare(e)),t}let c=52,g=Number.EPSILON;for(;c<o;)2*c<=o?(g*=g,c*=2):(g*=Number.EPSILON,c+=52);c+=2;const d=_e(l),_=r.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(d.lt(_)?d:_).mul(r.M.constructDouble(g)).toDouble(),de(l,a,g,c,h,0,m,4)}function oe(t,e){let s=t,i=e;i.power()>s.power()&&(i=(0,r.c)(s,s=i));const n=s.power()-i.power(),o=new Kt({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let t=0,e=s.power();t<e;t++)if(t>=n){const e=new Kt({copy:i.getElement(t-n)});e.mulThis(o);const r=s.getElement(t).sub(e);s.setElement(t,r)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),ae(s)}function ae(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function he(t,e,s){const i=t.clone(),n=e.clone();for(ae(i),ae(n);0!==i.power()||0!==n.power();)oe(i,n);s.assignMove(i.getElement(0))}function me(t,e,s,i,n,o,a=!1,h=!1){o.length=0;const m=t.power(),u=(0,r.m)(r.M,2*m+4),l=function(t,e,s,i,n,o,a){if(0===t.power())return t.isZero()?-1:0;const h=t.evaluate(r.M.constructInt32(1)).isZero();if(1===t.power()){const s=se(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(i),1!==s?0:(o[0].limitPrecisionThis(i),1)}return 2===t.power()?ie(t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):3===t.power()?ne(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):4===t.power()?re(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):de(t,e,s,i,h,0,o,a)}(t,s||r.E.unit(),i,n,0,u,u.length);if(l>0){o.length=0;for(let t=0;t<l;t++){const e=u[t];t>0&&e.lte(o.at(-1))||o.push(e.clone())}return o.length}return l}function ue(t,e,s){if((0,i.g)(s>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function le(t,e,s,n){if(t.power()<2)return ue(t,s,n);(0,i.g)(n>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));const a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){const i=t.getElement(1);return i.negateThis(),i.divThis(t.getElement(2)),i.ldexpThis(-1),i.limitPrecisionThis(e),s[0].setThis(i),1}(0,i.g)(n>=2),o=r.M.sqrt(o,e+8);const h=t.getElement(1);h.negateThis();const m=h.clone();m.subThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e);const u=h.clone();return u.addThis(o),u.divThis(t.getElement(2)),u.ldexpThis(-1),u.limitPrecisionThis(e),m.lt(u)?(s[0].setThis(m),s[1].setThis(u)):(s[1].setThis(m),s[0].setThis(u)),2}function ce(t,e,s,n,o,a,h){let m=s.clone(),u=n.clone();m.limitPrecisionThis(a),u.limitPrecisionThis(a);let l=t.evaluate(m);l.limitPrecisionThis(a+2);let c=t.evaluate(u);if(c.limitPrecisionThis(a+2),l.GEZ()&&c.GEZ()||l.LEZ()&&c.LEZ())return l.absLessAbs(c)?(h=m,l.isZero()):(h=u,c.isZero());const g=c.LZ();g&&(c=(0,r.c)(l,l=c),u=(0,r.c)(m,m=u));const d=g?u:m,_=g?m:u,p=m.add(u).ldexpThis(-1);p.limitPrecisionThis(a);const f=u.sub(m);f.limitPrecisionThis(a),f.absThis();const x=f.clone();let P=t.evaluate(p),y=e.evaluate(p);const v=new Kt({copy:t}),C=new Kt({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=r.ai.clone();i.ldexpThis(-(a+2));for(let n=64;n<s;){v.limitPrecisionThis(n),C.limitPrecisionThis(n);const r=v.evaluate(p),o=C.evaluate(p),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(i)&&(y.isZero()||h.divThis(y).absThis().lt(i)))break;v.assignCopy(t),C.assignCopy(e),n=Math.min(n+64,s)}P.limitPrecisionThis(a+2),y.limitPrecisionThis(a+2)}let E=4,b=1,D=0,S=0,w=1;const A=r.M.constructDouble(.25*o),T=r.M.constructDouble(.5001);let I=0;for(;++I<300;){if(I>32&&D>0||y.isZero()||2===w&&D>1||1===w&&E<4)w=1,b>1&&b--;else if(w=2,S>1){const t=f.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&b++}f.setThis(x);const t=new r.M;let e=!1;if(1===w)do{if(S>2){const e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(d).ldexpThis(-1).gt(e)){if(p.equals(d)){t.setThis(p),p.setThis(d.add(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}}}x.setThis(u.sub(m)),x.ldexpThis(-1),x.limitPrecisionThis(a),t.setThis(p),p.setThis(m.add(x)),p.limitPrecisionThis(a),p.lt(d)?p.setThis(d):p.gt(_)&&p.setThis(_),e=m.equals(p)||u.equals(p)}while(0);else for(;;){if(x.setThis(P.div(y)),x.limitPrecisionThis(a),1!==b&&x.mulDoubleThis(b),t.setThis(p),p.subThis(x),p.limitPrecisionThis(a),e=p.equals(t),p.lt(d)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(d)),p.setThis(d)}else if(p.gt(_)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(_)),p.setThis(_)}break}if(e||x.absLessAbs(A)){t.equals(p)||(P=v.evaluate(p),P.limitPrecisionThis(a+2));break}P=v.evaluate(p),P.limitPrecisionThis(a+2),y=C.evaluate(p),y.limitPrecisionThis(a+2);const s=m.clone(),i=u.clone();P.LZ()?(l.setThis(P),m.setThis(p)):(c.setThis(P),u.setThis(p)),2===w&&(m.equals(s)&&u.equals(i)||S>1&&!x.absLessAbs(T.mul(f)))?D++:D=0,1===w?(E++,S=0):(E=0,S++)}return I>=300&&(0,i.d)("Root_finder iterations exceeded"),h.setThis(p),!0}function ge(t,e,s,i,n){const o=t.evaluate(s);if(o.isZero())return!0;const a=r.M.constructDouble(.5*i),h=s.clone();h.subThis(a);const m=t.evaluate(h),u=s.clone();u.addThis(a);const l=t.evaluate(u);if(m.LZ()&&l.GZ()||m.GZ()&&l.LZ())return!0;if(o.GZ()?m.LEZ()||l.LEZ():m.GEZ()||l.GEZ())return!0;const c=m.LEZ()&&l.LEZ(),g=m.GEZ()&&l.GEZ();let d=!1;return c?o.gt(m)&&o.gt(l)&&(d=!0):g&&o.lt(m)&&o.lt(l)&&(d=!0),!!d&&o.absThis().lt(r.M.constructDouble(1e-17))}function de(t,e,s,n,o,a,h,m){(0,i.g)(s>0),(0,i.g)(m>=t.power());const u=h,l=[];let c=[];const g=new Kt({zeroCtor:t.m_zeroCtor}),d=new Kt({zeroCtor:t.m_zeroCtor}),_=new Kt({zeroCtor:t.m_zeroCtor}),p=r.M.constructDouble(s),f=r.M.constructDouble(e.vmin),x=r.M.constructDouble(e.vmax),P=f.sub(p),y=x.add(p),v=_e(t),C=v.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(p));else if(P.gt(v))return 0;if(y.gt(v))y.setThis(v.add(p));else if(y.lt(C))return 0;let E=t,b=null;if(o){const e=new Kt({coef0:r.M.constructInt32(-1)});e.addElement(r.ai),b=new Kt,E=b;const s=new Kt,i=new Kt;for(t.div(e,s,i),b.assignCopy(s);E.evaluate(r.ai).isZero();)E.div(e,s,i),b.assignCopy(s)}let D=!1;if(E.power()>0&&E.getElement(0).isZero())for(D=!0,b||(b=new Kt({copy:E}),E=b);E.getElement(0).isZero();)b.shiftRight(1);let S=n+2*E.power()+2,w=s/Math.pow(2,E.power()+2),A=S;if(r.ah.gt(P)&&r.ah.lt(y))for(let t=0,e=E.power();t<e;t++)if(E.getElement(t).isZero()){l.push(r.ah.clone());break}for(let t=E.power()-1;t>0;t--)if(w*=2,S-=2,A-=2,E.power()-t!==1){if(E.power()-t===2){d.assignMove(E.derivative(t));const e=le(d,S,u,m);(0,i.g)(e>=0&&e<=2);for(let t=0;t<e;t++)u[t].gt(P)&&u[t].lt(y)&&!u[t].isZero()&&l.push(u[t].clone());if(l.length>1&&l.sort((t,e)=>t.compare(e)),l.length>0){let t=l[0].sub(p);t.limitPrecisionThis(A),c.push((0,r.k)(P.clone(),t));let e=1===l.length?y.clone():l[1].sub(p);t=l[0].add(p),t.limitPrecisionThis(A),e.limitPrecisionThis(A),c.push((0,r.k)(t,e)),l.length>1&&(e=2===l.length?y.clone():l[2].sub(p),e.limitPrecisionThis(A),t=l[1].add(p),t.limitPrecisionThis(A),c.push((0,r.k)(t,e)),l.length>2&&(t=l[2].add(p),t.limitPrecisionThis(A),c.push((0,r.k)(t,y.clone()))))}else c.push((0,r.k)(P.clone(),y.clone()));g.assignCopy(d),_.assignMove(E.derivative(t-1));continue}{d.assignMove(_),_.assignMove(E.derivative(t-1));let e=[];for(let t=0,s=c.length;t<s;++t)if(c[t].first.lte(c[t].second)){const s=new r.M;if(ce(d,g,c[t].first,c[t].second,w,S,s)){l.push(s);let i=s.sub(p);i.limitPrecisionThis(A),e.push((0,r.k)(c[t].first,i)),i=s.add(p),i.limitPrecisionThis(A),e.push((0,r.k)(i,c[t].second))}else e.push(c[t])}c=e,e=[],g.assignMove(d)}}else d.assignMove(E.derivative(t)),1===ue(d,u,m)&&(u[0].gt(P)&&u[0].lt(y)&&!u[0].isZero()&&l.push(u[0].clone()),g.assignMove(d),_.assignMove(E.derivative(t-1)));l.sort((t,e)=>t.compare(e)),0===c.length&&(g.assignMove(E.derivative(E.power())),g.isZero()||c.push((0,r.k)(P.clone(),y.clone())));let T=0,I=0,N=0;const q=new r.M;for(;;){if(I<c.length){if(c[I].first.gt(c[I].second)){I++;continue}let t=!1;if(N<l.length&&l[N].lt(c[I].first)&&(t=!0),!t){ce(E,g,c[I].first,c[I].second,s,n,q)&&(q.lt(f)?u[T++].setThis(f):q.gt(x)?u[T++].setThis(x):u[T++].setThis(q)),I++;continue}}if(!(N<l.length))break;0!==N&&l[N-1].equals(l[N])||ge(E,0,l[N],s)&&(q.setThis(l[N]),q.lt(f)?q.setThis(f):q.gt(x)&&q.setThis(x),0!==T&&u[T].equals(q)||u[T++].setThis(q)),N++}return D&&r.ah.gt(P)&&r.ah.lt(y)&&(u[T++].setThis(r.ah),(0,r.C)(u,0,T,(t,e)=>t.compare(e))),o&&r.ai.gt(P)&&r.ai.lt(y)&&(u[T++].setThis(r.ai),(0,r.C)(u,0,T,(t,e)=>t.compare(e))),T}function _e(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=r.ah.clone();for(let e=0,i=t.power();e<i;e++){const i=t.getElement(e);i.limitPrecisionThis(53),i.gt(s)&&s.setThis(i)}return s.divThis(e),s.addThis(r.ai),s.mulThis(r.M.constructDouble(1+100*Number.EPSILON)),s}function pe(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=(0,r.c)(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=(0,r.c)(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=(0,r.c)(s[1],s[1]=s[2]))));for(let t=0;t<n;++t)s[t].limitPrecisionThis(e);return n}function fe(t,e,s,n,o,a){return function(t,e,s,n,o,a){if(s<e&&(0,i.a)("xTo < xFrom"),s===e)return 0;const h=[0];let m=Number.MAX_VALUE;const u=[Number.MAX_VALUE];let l=0;const c=(0,r.d)(33,Number.NaN),g=(0,r.d)(33,Number.NaN),d=[0];c[0]=1;let _=0,p=0;for(let r=0;r<32;r++){if(l=xe(e,s,n,0===r,l,d),g[r]=l,r+1>=t){Pe(r+1-t,t,c,g,0,h,u)||(0,i.d)("polynomial_interpolation");const e=o*Math.abs(h[0])+a,s=Math.abs(m-h[0]);if(s<=e&&Math.abs(u[0])<=e){if(_++,_>1&&(s<=.1*p||0===p||_>2))return h[0]}else _=0;p=s,m=h[0]}g[r+1]=g[r],c[r+1]=.25*c[r]}return h[0]}(t,e,s,a,n,o)}function xe(t,e,s,i,n,o){let a=n;if(i)return o[0]=1,a=.5*(e-t)*(s(t)+s(e)),a;const h=o[0],m=(e-t)/h,u=t,l=new r.K(0);for(let t=1;t<=o[0];++t){const e=(t-.5)*m;l.add(s(u+e))}return a=.5*(a+(e-t)*l.getResult()/h),o[0]*=2,a}function Pe(t,e,s,i,n,o,a){let h=0,m=Math.abs(n-s[t]);const u=(0,r.d)(e,Number.NaN),l=(0,r.d)(e,Number.NaN);for(let r=0;r<e;++r){const e=Math.abs(n-s[t+r]);e<m&&(h=r,m=e),u[r]=i[t+r],l[r]=i[t+r]}let c=0,g=0,d=0;o[0]=i[t+h],h--;for(let i=1;i<e;i++){for(let r=0;r<e-i;r++){if(g=s[t+r]-n,d=s[t+r+i]-n,c=g-d,0===c)return!1;const e=(u[r+1]-l[r])/c;u[r]=g*e,l[r]=d*e}if(2*(h+1)<e-i){const t=h+1;a[0]=u[t]}else{const t=h;a[0]=l[t],h--}o[0]+=a[0]}return!0}class ye{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ve=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Se(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}};function Ce(t,e,s,i,n){let o=!0;const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=o?0:1,m=a[1][h]-a[0][h],u=a[2][h]-a[0][h];const l=fe(5,e,s,i,n,t=>{let e;if(t<=.5){const s=(0,r.X)(0,m,t),i=(0,r.X)(m,u,t);e=(0,r.X)(s,i,t)}else{const s=(0,r.Y)(0,m,t),i=(0,r.Y)(m,u,t);e=(0,r.Y)(s,i,t)}return e*Ne(a,1,t).length()});o=!1,h=o?0:1,m=a[1][h]-a[0][h],u=a[2][h]-a[0][h];const c=fe(5,e,s,i,n,t=>{let e;if(t<=.5){const s=(0,r.X)(0,m,t),i=(0,r.X)(m,u,t);e=(0,r.X)(s,i,t)}else{const s=(0,r.Y)(0,m,t),i=(0,r.Y)(m,u,t);e=(0,r.Y)(s,i,t)}return e*Ne(a,1,t).length()});return new r.P(l,c)}function Ee(t){t.m_cachedValues=null}function be(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ye;return De(t,e.specialPoints),Xe(t,e),e}function De(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=(0,r.m)(r.H,8);i[0].set(0);let n=1;{const t=(0,r.m)(r.H,3);!function(t,e,s=!1){const i=new r.H(t[1][0]).subE(new r.H(t[0][0]));e[1]=i.mul(2),e[2]=new r.H(t[2][0]).subE(new r.H(t[1][0])).subE(i),s?e[0].set(0):e[0].set(t[0][0])}(s,t,!1);const e=(0,r.m)(r.H,2),o=new r.E(0,1);let a=Rt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.N)(e[t].value(),0,1)||(i[n]=e[t],n++)}{const t=(0,r.m)(r.H,3);!function(t,e,s=!1){const i=new r.H(t[1][1]).subE(new r.H(t[0][1]));e[1]=i.mul(2),e[2]=new r.H(t[2][1]).subE(new r.H(t[1][1])).subE(i),s?e[0].set(0):e[0].set(t[0][1])}(s,t,!1);const e=(0,r.m)(r.H,2),o=new r.E(0,1);let a=Rt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.N)(e[t].value(),0,1)||(i[n]=e[t],n++)}if(i[n].set(1),n++,n>2){(0,r.C)(i,0,n,(t,e)=>t.value()-e.value());let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),e.length=n;for(let t=0;t<n;t++)e[t]=i[t].value()}function Se(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),we(i,e,s)}function we(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+we(t,1,!1)}if(1===e)return Ae(t);const i=(0,r.m)(r.P,3);return Ge(t,e,i,null),Ae(i)}function Ae(t){if(t[0].equals(t[1]))return r.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return r.P.distance(t[0],t[2]);const e=r.P.distance(t[0],t[1])+r.P.distance(t[2],t[1]),s=r.P.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const i=(0,r.m)(r.P,3);Oe(t,i,!0);const n=4*((0,r.a)(i[2].x)+(0,r.a)(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=(0,r.a)(i[1].x)+(0,r.a)(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(n))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*(Math.pow(1*o+a,1.5)-Math.pow(a,1.5));const h=o/n,m=a/n,u=m-h*h,l=1+h;if(0===u)return h>=0&&l>=0||h<=0&&l<=0?Math.abs(.5*Math.sqrt(n)*(l*l-h*h)):.5*Math.sqrt(n)*(l*l+h*h);const c=Math.sqrt(u+l*l),g=Math.sqrt(m);return.5*Math.sqrt(n)*(l*c-h*g+u*Math.log(Math.abs((l+c)/(h+g))))}function Te(t,e){const s=(0,r.s)(e,0,1);let i=Ne(t,1,s);return i.isZero()&&(i=Ne(t,2,s)),i}function Ie(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),Ne(i,e,s)}function Ne(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):r.P.construct(0,0)}function qe(t){const e=(0,r.m)(r.P,3);return t.queryControlPoints(e),Me(e)}function Me(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Ye(t){return t.m_cachedValues}function Xe(t,e){t.m_cachedValues=e}function Fe(t,e,s,n,o){(0,i.x)(r.E.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=Number.MAX_VALUE;const m=[0],u=Re(a,e,m);if(s.containsCoordinate(m[0]))h=r.P.distance(e,u);else{m[0]=s.vmin,$e(a,m[0],u),h=r.P.distance(u,e);const t=new r.P;$e(a,s.vmax,t);const i=r.P.distance(t,e);h>i&&(u.setCoordsPoint2D(t),m[0]=s.vmax,h=i)}if(!n)return m[0];if(s.vmin<=0){const i=new r.P;t.queryCoord2DExtended(-1,i,!0);const n=new r.P;t.queryCoord2D(s.vmin,n);const o=new Fr({start:i,end:n}),a=o.getClosestCoordinate(e,!0);if(a<1){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=a-1,u.assign(t))}}if(s.vmin>=1){const i=new r.P;t.queryCoord2DExtended(2,i,!0);const n=new r.P;t.queryCoord2D(s.vmax,n);const o=new Fr({start:n,end:i}),a=o.getClosestCoordinate(e,!0);if(a>0){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=1+a,u.assign(t))}}return m[0]}function Re(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(n),h=o.dotProduct(i)+2*n.dotProduct(n),m=3*n.dotProduct(i),u=i.dotProduct(i),l=(0,r.d)(3,Number.NaN),c=qt(u,m,h,a,r.E.unit(),!1,l),g=t[0].clone();let d=0,_=r.P.sqrDistance(t[0],e),p=r.P.sqrDistance(t[2],e);p<_&&(d=1,g.assign(t[2]),_=p);for(let s=0;s<c;s++){const i=new r.P;$e(t,l[s],i),p=r.P.sqrDistance(i,e),p<_&&(_=p,g.assign(i),d=l[s])}return s&&(s[0]=d),g}function Le(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=(0,r.m)(r.P,3);He(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function ze(t,e,s){s.setEmpty();const i=[];i.push(new r.E(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new p;if(Le(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=n||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(r.E.construct(o.vmin,t)),i.push(r.E.construct(t,o.vmax))}}}}function Ve(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Be(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Be(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[2][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Ge(t,e,s,i){(new r.P).setCoordsPoint2D(t[0]),(new r.P).setCoordsPoint2D(t[1]),(new r.P).setCoordsPoint2D(t[2]);const n=new r.P,o=new r.P,a=new r.P;if((0,r.U)(t[0],t[1],e,n),(0,r.U)(t[1],t[2],e,o),(0,r.U)(n,o,e,a),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(a)),i){const e=t[2];i[0].assign(a),i[1].assign(o),i[2].assign(e)}}function He(t,e,s,i){if(e===s){const s=new r.P;return $e(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=(0,r.m)(r.P,3);Ge(t,s,n,null),Ge(n,e/s,null,n),$e(t,e,n[0]),$e(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ke(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==je(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function We(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==Ze(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function je(t,e,s,n,o,a,h,m,u,l){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!==a)for(let t=0;t<i;t++)a.push(0);if(null!==n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=G(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Fr({start:e.getStartXY(),end:e.getEndXY()}),i=ot(t,s,n,o,a,h,m,l);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=C.constructPoint2D(s.getStartXY()),d=C.constructPoint2D(s.getEndXY()).sub(g),_=d.clone();_.leftPerpendicularThis();const p=C.constructPoint2D(e.m_cp).sub(C.constructPoint2D(e.getStartXY())),f=C.constructPoint2D(e.getEndXY()).sub(C.constructPoint2D(e.m_cp));let x=p.dotProduct(_).toDouble(),P=f.sub(p).dotProduct(_).toDouble();const y=(0,r.d)(12,Number.NaN),v=(0,r.d)(12,Number.NaN);let E=function(t,e,s,i){const n=new r.H,o=Rt(new r.H(t),new r.H(e),s,n);return i[0]=n.value(),o}(P,x,r.E.unit(),y);E<0&&(y[0]=0,y[1]=1,E=2);let b,D=0;for(let t=0,i=D;t<E;++t){const n=e.getCoord2D(y[t+i]);v[D]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(v[D]))<=h&&(y[D]=y[t+i],D++)}const S=(0,r.m)(r.P,3);e.queryControlPoints(S);{const t=(0,r.m)(C,3);if(Qe(S,t,!1),t[0]=t[0].sub(g),d.x.abs().gte(d.y.abs())){const e=d.y.div(d.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),x=t[1].y.sub(t[1].x.mul(e)).toDouble(),b=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=d.x.div(d.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),x=t[1].x.sub(t[1].y.mul(e)).toDouble(),b=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const w=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),A=[0,0];E=Nt(P,x,b,r.E.unit(),w,A);for(let t=0,i=D;t<E;++t){y[t+i]=A[t];const n=e.getCoord2D(y[t+i]);v[D]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(v[D]))<=h&&(y[D]=y[t+i],D++)}(0,i.g)(D<y.length+4),E=e.intersectPoint(s.getStartXY(),A,h);for(let t=0;t<E;t++)y[D]=A[t],v[D++]=0;E=e.intersectPoint(s.getEndXY(),A,h);for(let t=0;t<E;t++)y[D]=A[t],v[D++]=1;E=s.intersectPoint(e.getStartXY(),A,h);for(let t=0;t<E;t++)v[D]=A[t],y[D++]=0;E=s.intersectPoint(e.getEndXY(),A,h);for(let t=0;t<E;t++)v[D]=A[t],y[D++]=0;return 0===D?0:qr(t,e,s,y,v,D,n,o,a,h,m,0,l)}function Ze(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return je(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,3);{e.queryControlPoints(_);const t=(0,r.m)(r.P,3),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(_,3,t);const o=(0,r.m)(C,3);Qe(t,o);const u=[o[0].x,o[1].x,o[2].x],l=[o[0].y,o[1].y,o[2].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2]=c[0],c[2].mul(c[1]),c[2].negate();const p=ee(u,2,l,2,null,0,c,0,r.E.unit(),r.E.unit(),g,m);if(p>0){let t=0;for(let i=0;i<p;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];Re(_,e,i);const n=new r.P;$e(_,i[0],n),r.P.distance(e,n)<=h&&(g.push(i[0]),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,2];{const i=s.getClosestCoordinate(_[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(_[e[t]],n)<=h&&(g.push(p[t]),d.push(i))}}return qr(t,e,s,g,d,g.length,i,n,o,h,m,0,l)}function Ue(t,e,s,i,n,o,a,h,m,u){const l=(0,r.m)(r.P,3);e.queryControlPoints(l);const c=(0,r.m)(r.P,3);if(s.queryControlPoints(c),k(l,c,3)<0)return Ue(t,s,e,i,o,n,a,h,m,!u);const g=G(e,s);if(H(e,s,a=Math.max(a,g)))return 0;if(function(t,e,s,i,n,o,a,h,m){const u=(0,r.m)(r.P,3);t.queryControlPoints(u);const l=(0,r.m)(r.P,3);if(e.queryControlPoints(l),u[0].equals(l[0])){if(u[1].equals(l[1])&&u[2].equals(l[2]))return s&&(s.length=0,s.push(u[0]),s.push(u[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!u[0].equals(l[2]))return!1}return!!(u[0].equals(l[2])&&u[1].equals(l[1])&&u[2].equals(l[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,i,n,o,0,0,0,u))return 2;const d=new r.E(0,1),_=new r.E(0,1);{const t=new p;Le(l,r.E.unit(),t);const e=new p;Le(c,r.E.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(ze(l,t,d),ze(c,t,_),d.isEmpty()||_.isEmpty())return 0;He(l,d.vmin,d.vmax,l),He(c,_.vmin,_.vmax,c)}}const f=Yr(l,2,c,2,a);if(0===f)return 0;const x=[],P=[];if(-1===f){const t=(0,r.m)(C,3);Qe(l,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=(0,r.m)(C,3);Qe(c,i);const n=te(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,0,r.E.unit(),r.E.unit(),x,P,u,0,u);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new r.P,i=new r.P;$e(c,P[e],i),$e(l,x[e],s),r.P.distance(s,i)<=a&&(x[t]=x[e],P[t]=P[e],t++)}x.length=t,P.length=t}}for(let t=0;t<2;t++){const e=0===t?l:c,s=0===t?c:l;for(let i=0;i<2;i++){const n=0===i?0:2,o=[0];Re(s,e[n],o);const h=new r.P;$e(s,o[0],h),r.P.distance(e[n],h)<=a&&(0===t?(x.push(0===n?0:1),P.push(o[0])):(P.push(0===n?0:1),x.push(o[0])))}}if(0===x.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=Qt.recalculateParentT(d.vmin,d.vmax,x[t]);if(!_.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=Qt.recalculateParentT(_.vmin,_.vmax,P[t]);return qr(t,e,s,x,P,x.length,i,n,o,a,h,0,u)}function Oe(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Qe(t,e,s=!1){const i=C.constructPoint2D(t[1]),n=i.sub(C.constructPoint2D(t[0]));e[1]=n.mul(r.M.constructInt32(2)),e[2]=C.constructPoint2D(t[2]).sub(i).sub(n),e[0]=s?new C(r.ah,r.ah):C.constructPoint2D(t[0])}function $e(t,e,s,i){if(i){if(e<0)return void K(new Fr({start:t[0],end:t[0].add(Te(t,0).getUnitVector())}),e,s);if(e>1)return void K(new Fr({start:t[2],end:t[2].add(Te(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=t[1].clone(),n=new r.P;(0,r.a1)(2,t[0],i,e,n);const o=new r.P;(0,r.a1)(2,i,t[2],e,o);const a=new r.P;(0,r.a1)(2,n,o,e,a),s.assign(a)}else{const i=t[1].clone(),n=new r.P;(0,r.a2)(2,t[0],i,e,n);const o=new r.P;(0,r.a2)(2,i,t[2],e,o);const a=new r.P;(0,r.a2)(2,n,o,e,a),s.assign(a)}}const Ke=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Je=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ts=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],es=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],ss=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],is=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function ns(t,e,s,i){const n=.5*(i-s),o=s+n,a=new r.K(0);for(let s=0,i=Math.trunc(t/2);s<i;++s){let i,h;switch(t){case 4:i=Ke[s][0],h=Ke[s][1];break;case 8:i=Je[s][0],h=Je[s][1];break;case 16:i=ts[s][0],h=ts[s][1];break;case 32:i=es[s][0],h=es[s][1];break;case 64:i=ss[s][0],h=ss[s][1];break;case 128:i=is[s][0],h=is[s][1];break;default:throw new Error("Quadrature_integral: invalid n")}const m=(0,r.am)(-n,i,o),u=(0,r.am)(n,i,o);a.pe(e(m)*h),a.pe(e(u)*h)}return a.getResult()*n}class rs extends Et{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Rr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Rr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Rr):t.envelope?(0,i.t)("envelope constructor not impl"):(0,i.d)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Rr)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return At(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return rs.type}getDimension(){return 2}createInstance(){return new rs({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}rs.type=i.G.enumPolygon;var os=n.V;const as=-1;class hs{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}class ms{constructor(t){!function(t){return void 0!==t.parent}(t)?(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom):(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==as;){for(;this.m_path!==as;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==as)return this.m_vertex;if(this.m_bOneGeom)return as;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===as)break;this.m_bSkipMultiPoints&&!(0,i.h)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return as}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==as&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return as}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==as?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==as&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):as}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new ms({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class us{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class ls{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,s=this.m_indices.length;t<s;t++){if(t===this.m_selectionIndex)continue;const s=this.m_indices[t];null!==s&&s.size()>e&&s.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,1),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==as?this.getPrevVertex(e):this.getLastVertex(t),r=n!==as?this.getNextVertex(n):as,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByValNoCurves(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==as&&this.setPrevVertex(r,o),n!==as&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===as&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==as||this.setFirstVertex(t,o)),h&&r===as&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new n.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(i.G.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let e=0,n=s.getPathCount();e<n;e++){if(0===s.getPathSize(e))continue;const n=this.insertPath(t,as);this.setClosedPath(n,s.isClosedPath(e));for(let t=s.getPathStart(e),r=s.getPathEnd(e);t<r;t++){const e=this.insertVertex_(n,as,null,!1);if(i){const i=this.getVertexIndex(e);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{const e=new Rr;s.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}s.isStrongPathStart(e)&&this.setStrongPathStart(n,!0),s.isStrongPathEnd(e)&&this.setStrongPathEnd(n,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.G.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new o.Envelope2D;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,u=0,l=-1,c=as,g=!1,d=s.nextSegment();if(null!==d)for(;;d=s.nextSegment()){let r=null===d;const o=null!==d?s.getPathIndex():a,_=null!==d?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?u++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(u===m){this.setClosedPath(c,g);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-l),this.m_verticesMp.addPoints(e,l,n),s=i.getPathSize(a),t=n-1}else if(!g||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,as,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Rr;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;u=1,l=_,a!==o?(c=this.insertPath(t,as),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),g=i.isClosedPath(o),a=o):c=this.insertPath(t,as)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const n=e.getImpl(),a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),h=o.Envelope2D.constructEmpty();e.queryEnvelope(h),(0,i.g)(s.isIntersecting(h)&&!s.containsEnvelope(h));let m=o.Envelope2D.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),u=o.Envelope2D.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const l=n.getAccelerators();if(l&&l.getQuadTree()){const t=l.getQuadTree(),e=t.getIntersectionCount(m,0,0);e>t.getIntersectionCount(u,0,e+1)&&(u=(0,r.c)(m,m=u))}else m.height()>u.width()&&(u=(0,r.c)(m,m=u));const c=[],g=n.queryLimitedSegmentIterator(m);let d=-1,_=-100,p=-1,f=0,x=-1,P=-1,y=as,v=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let s=null===C;const h=null!==C?g.getPathIndex():d,m=null!==C?g.getStartPointIndex():_;if(s||(h===d?_+1===m?f++:s=!0:(s=d>=0,d<0&&(d=h,p=n.getSegmentCountPath(d),x=m,y=as,f=1))),s){if(0!==c.length||p!==f){0!==c.length&&c[0].first===x||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,x,x+1),-1===P&&(P=x),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(y,as,null,!1));for(const{first:s,second:r}of c){-1===P&&(P=s);let o=-1,h=-1;const m=s+r-1;if(r===p){const t=m+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m,(0,i.g)(1===c.length)}else if(m+1<n.getPathEnd(d)){const t=m+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m}else{const t=n.getPathStart(d),i=t!==P?1:0,r=m+1;h=r-s+i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+i),this.m_verticesMp.addPoints(e,s,r),o=m,i>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(y,as,null,!1);if(a){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>o)this.setSegmentToIndex(s,null);else{const t=new Rr;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===c.length||c.at(-1).first+c.at(-1).second!==x+f){let t=x+f;t===e.getPathEnd(d)&&(t=e.getPathStart(d)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(y,as,null,!1))}}c.length=0,v=!0,h!==d&&(d=h,p=n.getSegmentCountPath(d),y=as,P=-1),x=m,f=1}if(!C)break;{const t=o.Envelope2D.constructEmpty();C.queryLooseEnvelope(t),u.isIntersecting(t)?(v?c.push((0,r.k)(m,1)):c.at(-1).second++,v=!1):v=!0}_=m}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.G.enumPolygon,r=o.Envelope2D.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,as);this.insertVertex_(i,as,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,as);for(let t=0,i=e.getPointCount();t<i;t++)this.insertVertex_(s,as,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let t=0,r=e.getPointCount();t<r;t++){const e=i.readPoint2D(2*t);s.contains(e)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let t=0,n=e.getPointCount();t<n;t++){const n=i.readPoint2D(2*t);s.contains(n)?(-1===r&&(r=t,o=t),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,as);for(let t=0,n=e.getPointCount();t<n;t++){const e=i.readPoint2D(2*t);s.contains(e)&&this.insertVertex_(h,as,null,!1)}}splitSegmentForward(t,e,s,n,r){const o=this.getNextVertex(t);o===as&&(0,i.a)("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const l=this.getVertexIndex(m),c=this.getNextVertex(m),g=e.getResultSegment(s,t);let d=null;if(g.getGeometryType()!==i.G.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(l,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),r)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),u){const i=e.getResultSegmentSegmentParentage(s,t),n=e.getResultSegmentStartPointIsBreak(s,t);this.setSegmentParentageAndBreak(m,i,n)}if(g.queryEnd(a),t<n-1){this.setSegmentToIndex(l,d);const i=this.insertVertex(h,c,a);this.setWeight(i,e.getResultSegmentEndPointWeight(s,t)),this.setRank(i,e.getResultSegmentEndPointRank(s,t)),this.select(i),m=i}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),r);const i=e.getResultSegmentEndPointIsBreak(s,t);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(l,d)}}}splitSegmentBackward(t,e,s,n,r){const o=this.getNextVertex(t);o===as&&(0,i.a)("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const l=n-t-1,c=this.getVertexIndex(m),g=this.getNextVertex(m),d=e.getResultSegment(s,l);let _=null;if(d.getGeometryType()!==i.G.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(a),this.setSegmentToIndex(c,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,l),e.getResultSegmentEndPointWeight(s,l),r),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,l),e.getResultSegmentEndPointIsBreak(s,l))),d.getGeometryType()===i.G.enumLine?this.setSegmentToIndex(c,null):this.setSegmentToIndex(c,_),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,l)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,l)),d.queryStart(a),t<n-1){const t=this.insertVertex(h,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(s,l)),this.setRank(t,e.getResultSegmentStartPointRank(s,l)),this.select(t),m=t,u&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(s,l),e.getResultSegmentEndPointIsBreak(s,l))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,l),e.getResultSegmentStartPointWeight(s,l),r)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,n.D)(0,-1):(0,n.D)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,n.D)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=(0,r.c)(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,as,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return as}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,(t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s})}sortVerticesSimpleByYHelper3D(t,e,s){(0,i.g)(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=n.p.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=r.P.getNAN(),this.m_workPoint2_2D=r.P.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=as,this.m_lastGeometry=as,this.m_vertexIndexList=new n.S(5),this.m_pathIndexList=new n.S(8),this.m_geometryIndexList=new n.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new n.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.Envelope2D(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=o.Envelope2D.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let t=i.next();t!==as;t=i.next()){if(n?s.merge(this.getXY(t)):s.mergeNe(this.getXY(t)),e){const e=this.getSegment(t);if(null!==e){const t=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}n=!1}return s}getEnvelope3D(t){return(0,i.g)(0),n.p.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,i.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if((0,i.h)(s))return this.addMultiPath(t,e);if(s===i.G.enumMultiPoint)return this.addMultiPoint(t,e);if(s===i.G.enumPoint)return this.addPoint_(t,e);if(s===i.G.enumEnvelope){const s=new rs;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}(0,i.a)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());const s=e.getGeometryType();(0,i.h)(s)?this.appendMultiPath(t,e):s!==i.G.enumMultiPoint?(0,i.a)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);const s=this.queryVertexIterator();for(let t=s.next();t!==as;t=s.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=as,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==as;){if(t===i.G.enumUnknown||this.getGeometryType(r)===t){if(e===as){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let t=this.getFirstPath(r);t!==as;t=this.getNextPath(t))this.setPathGeometry(t,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==as?this.setNextPath(t,i):this.setFirstPath(e,i),i!==as&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,as),this.setLastPath(r,as);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return e!==as&&(this.setGeometryVertexCount(e,n),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let s=this.getFirstPath(t);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,e);for(let s=this.getFirstPath(e);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const u=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,u)}addPathFromMultiPath(t,e,s){const n=this.createGeometry(s?i.G.enumPolygon:i.G.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,as);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let t=r.getPathStart(e),s=r.getPathEnd(e);t<s;t++){const e=this.insertVertex_(o,as,null,!1);if(a){const s=this.getVertexIndex(e);if(1&r.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{const e=new Rr;r.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=function(t,e){let s,r=e,o=null;switch(r||(o=(0,i.j)(t)?(0,n.z)():(0,n.l)(),r=o),t){case i.G.enumPoint:s=new n.P({vd:r});break;case i.G.enumLine:s=new Fr({vd:r});break;case i.G.enumBezier:s=new Ci({vd:r});break;case i.G.enumEllipticArc:s=new In({vd:r});break;case i.G.enumRationalBezier2:s=new Ut({vd:r});break;case i.G.enumBezier2:s=new Qt({vd:r});break;case i.G.enumEnvelope:s=new n.E({vd:r});break;case i.G.enumMultiPoint:s=new _({vd:r});break;case i.G.enumPolyline:s=new Dt({vd:r});break;case i.G.enumPolygon:s=new rs({vd:r});break;case i.G.enumMultipatch:(0,i.t)("multipatch not impl");break;case i.G.enumGeometryCollection:s=new U({vd:r});break;default:(0,i.a)("Geometry.create")}return s}(e,this.m_verticesMp.getDescription()),r=this.getPointCount(t);if(0===r)return s;if((0,i.h)(e)){const e=s.getImpl(),i=this.getPathCount(t),o=(0,n.D)(i+1),a=(0,n.F)(i+1,0),h=s.getDescription(),m=this.hasCurves();for(let s=0,m=h.getAttributeCount();s<m;s++){const m=h.getSemantics(s),u=os.getComponentCount(m),l=(0,n.v)(m,r),c=this.m_vertices.getAttributeStreamRef(m);let g=0,d=0,_=0;for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&a.setBits(d,t);const s=this.getPathSize(e);if(o.write(d++,_),_+=s,0===m){const t=c,s=l;let i;for(let n=this.getFirstVertex(e);g<_;n=this.getNextVertex(n),g++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*g,i)}}else for(let t=this.getFirstVertex(e);g<_;t=this.getNextVertex(t),g++){const e=this.getVertexIndex(t);for(let t=0;t<u;t++){const s=c.readAsDbl(e*u+t);l.writeAsDbl(g*u+t,s)}}}e.setAttributeStreamRef(m,l),o.write(i,r)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),m){let s=0,i=0;for(let n=this.getFirstPath(t);n!==as;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===i.G.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(r),e.resizeNoInit(r);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=os.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(t),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(n,o)}e.notifyModifiedFlags(65535)}else(0,i.d)("getGeometry");return s}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==i.G.enumMultiPoint&&(0,i.a)("get_point_geometry_only");const s=this.getPointCount(t);if(s>1&&(0,i.a)("get_point_geometry_only"),0===s)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();const n=this.getFirstPath(t),r=this.getFirstVertex(n);this.queryPoint(r,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==as;e=this.removePath(e));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==as?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==as?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=(0,n.l)());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new _({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===as?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,n.D)(0),t;this.m_geometryIndices.push((0,n.D)(0));const t=this.m_geometryIndices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))if(!(0,i.h)(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,s,n,o){const a=t*t;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage(),l=!0;for(let t=o===as?this.getFirstGeometry():o;t!==as;t=o===as?this.getNextGeometry(t):as){const o=this.getGeometryType(t);if(!(0,i.h)(o))continue;if(s&&o!==i.G.enumPolygon)continue;const c=this.getGeometryType(t)===i.G.enumPolygon;let g=this.getGeometryModified(t);for(let s=this.getFirstPath(t);s!==as;){let o=0;for(let e=this.getFirstVertex(s);o<Math.trunc(this.getPathSize(s)/2);){const c=this.getNextVertex(e);if(c===as)break;const d=this.getXY(e),_=this.getXY(c);let p=r.P.sqrDistance(d,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,c!==this.getLastVertex(s)){const s=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(c));if(this.transferAllDataToTheVertex(c,e,l),this.removeVertex(c,!1),n&&!g&&(this.setGeometryModified(t,!0),g=!0),u&&e!==c){this.setSegmentParentageBreakVertex(e,s);const t=this.getNextVertex(e);(0,i.g)(t!==as),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}f=!1}}while(0);f&&(e=this.getNextVertex(e)),o++}let d=this.getFirstVertex(s);for(let e=this.isClosedPath(s)?d:this.getLastVertex(s);this.getPathSize(s)>0;){const o=this.getPrevVertex(e);if(o===as)break;{const c=this.getXY(o),_=this.getXY(e);let p=r.P.sqrDistance(c,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(o);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,u){(0,i.g)(this.m_segmentParentageIndex>=0);const t=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(o,e,l),this.setUserIndex(e,this.m_segmentParentageIndex,t)}else this.transferAllDataToTheVertex(o,e,l);const r=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(o));this.removeVertex(o,!0),n&&!g&&(this.setGeometryModified(t,!0),g=!0),u&&o!==e&&(r||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),d===o&&(d=this.getFirstVertex(s)),f=!1}}while(0);if(f&&(e=this.getPrevVertex(e),e===d))break}}const _=this.getPathSize(s);let p=e&&_<(c?3:2);p&&c&&2===_&&m&&(p=!this.pathHasCurves(s)),p?(s=this.removePath(s),0===h&&(h=-1),n&&!g&&(this.setGeometryModified(t,!0),g=!0)):s=this.getNextPath(s)}}return h}filterClosePoints3D(t,e,s,n,r,o){return(0,i.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==as;e=this.getNextGeometry(e))if((0,i.h)(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==as;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===as)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return(0,i.g)(0),!1}transferAllDataToTheVertex(t,e,s=!1){const i=this.getVertexIndex(t),n=this.getVertexIndex(e);if(s){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(i),e=this.getRankWithIndex(n)),t>e&&this.setRankWithIndex(n,t),t>=e&&this.m_weights){const s=this.getWeightWithIndex(i),r=this.getWeightWithIndex(n);(t>e||s>r)&&this.setWeightWithIndex(n,s)}}else{if(this.m_weights){const t=this.getWeightWithIndex(i);this.setWeightWithIndex(n,t)}if(this.m_ranks){const t=this.getRankWithIndex(i);this.setRankWithIndex(n,t)}}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(i);this.setSegmentWeightWithIndex(n,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(i);this.setSegmentRankWithIndex(n,t)}for(let s=0,i=this.m_indices.length;s<i;s++)if(s!==this.m_selectionIndex&&null!==this.m_indices[s]){const i=this.getUserIndex(t,s);this.setUserIndex(e,s,i)}const r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,n,r){let o=0;const a=this.getNextVertex(t);a===as&&(0,i.a)("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),u=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&u&&(l=u.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(u){let t=0,i=0,r=as;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=u.cut(t,s);if(null!==n&&(p>0&&e.setStartXY(n[p-1]),e.setEndXY(n[p]),e.normalizeAfterEndpointChange(),i=p),g){const t=l>0?u.calculateSubLengthFromStart(s)/l:0;this.m_vertices.interpolateTwoVertices(h,m,t,_)}_.setXY(e.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==d&&this.setSegmentParentageAndBreak(r,d,!1),t=s}}if(r!==as){const e=u.cut(t,1);null!==n&&(e.setStartXY(n[i]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(r);this.setSegmentToIndex(s,e)}}else{let t=0;for(let i=0;i<s;i++){const s=e[i];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(h,m,s,_);const t=this.insertVertex(c,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=s}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,e,s){this.getNextVertex(t)===as&&(0,i.a)("");let n=t,r=!1;for(let t=0;t<e;++t){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(s);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==as;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return(0,i.g)(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(s,e)}setPointOnlyEx(t,e,s,n){(0,i.g)(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new r.P(e,s),t,!1),n.ensureXYMonotone()}const o=this.getPrevVertex(t);if(o!==as){const t=this.getVertexIndex(o),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new r.P(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){(0,i.g)(0)}setXYZ(t,e,s){(0,i.g)(0)}setXYZCoords(t,e,s,n){(0,i.g)(0)}queryXYZ(t,e){(0,i.g)(0)}getXYZ(t){return(0,i.g)(0),n.f.getNAN()}getXYZWithIndex(t){return(0,i.g)(0),n.f.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,i.g)(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){(0,i.g)(0)}setAttributeInt(t,e,s,n){(0,i.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,i.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return(0,i.g)(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=(0,n.G)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=(0,n.G)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return 1;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,n.D)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,1)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,n.D)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,n.G)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,n.G)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return ls.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?ls.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,n.D)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,1)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,n.D)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];return s<i.size()?i.read(s):-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=(0,r.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let r=0,o=this.getPathSize(e);r<o;r++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){(0,i.g)(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===as)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new n.P({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return(0,i.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,i.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===as)return!1;const s=this.getPathSize(t);let n=e;for(let t=0;t<s;t++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.G.enumLine)return!0}return!1}insertPath(t,e){let s=as;e!==as?(t!==this.getGeometryFromPath(e)&&(0,i.a)(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const n=this.newPath(t);return e!==as&&this.setPrevPath(e,n),this.setNextPath(n,e),this.setPrevPath(n,s),s!==as?this.setNextPath(s,n):this.setFirstPath(t,n),e===as&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==as?this.setNextPath(e,s):this.setFirstPath(i,s),s!==as?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==as){let s=e;for(let e=0,i=this.getPathSize(t);e<i;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,as),this.setPrevVertex(s,as);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){(0,i.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===as)return 0;const s=this.getXY(e),n=new r.K(0),o=this.getPathSize(t);if(o>2){const t=s.clone(),i=t.x,a=t.y;let h=this.getNextVertex(e);const m=this.getXY(h);h=this.getNextVertex(h);const u=r.P.getNAN();for(let e=2;e<o;e++,h=this.getNextVertex(h))this.queryXY(h,u),n.pe((u.x-t.x)*(m.y-a)),t.setCoordsPoint2D(m),m.setCoordsPoint2D(u);n.pe((i-t.x)*(m.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.G.enumLine)continue;const s=2*e.calculateArea2DHelper();n.pe(s)}}this.setRingAreaValid(t,!0);const a=.5*n.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){const t=this.getPathIndex(e);t<n&&i.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===as&&(0,i.a)(""),e===s)return;const n=this.getNextPath(s);let r=this.getPrevPath(s);const o=this.getGeometryFromPath(s);r===as?this.setFirstPath(o,n):this.setNextPath(r,n),n===as?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(s)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=e===as?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,r),this.setNextPath(s,e),e===as?this.setLastPath(t,s):this.setPrevPath(e,s),r===as?this.setFirstPath(t,s):this.setNextPath(r,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,as,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==as&&this.setNextVertex(i,n);const r=this.getPathSize(s);if(t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:as),n!==as&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:as),this.hasCurves()&&i!==as&&n!==as){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(t,e){(0,i.g)(t!==e);const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==as&&this.setNextVertex(n,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,as),this.setNextVertex(r,as);let h=0,m=t;const u=this.getFirstVertex(s);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(s,o>0?e:as),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,as,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,i.d)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=as){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=as){let s=as,n=as,r=as,o=as,a=0,h=!1;for(s=e!==as?e:this.getFirstGeometry();s!==as;s=this.getNextGeometry(s))if(!t||(0,i.h)(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==as;n=this.getNextPath(n))if(r=this.getFirstVertex(n),o=r,a=0,r!==as){h=!0;break}if(h||e!==as)break}return h||(s=as),ms.create_(this,s,n,r,o,a,t,!1,e!==as)}queryVertexIteratorOnSelection(t=as){return this.m_selection?ms.create_(this,t,as,as,as,-1,!1,!0,t!==as):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,i.g)(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=as,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return(0,i.g)(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;const e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===as)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return(0,i.g)(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==as?this.setNextPath(e,s):this.setFirstPath(i,s),s!==as?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,as),this.setLastVertex(t,as),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,as);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return(0,i.g)(0),0}findVertex3D(t,e,s){return(0,i.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let s=t;for(let t=0;t<e;++t)if(s=e>0?this.getNextVertex(s):this.getPrevVertex(s),s===as)return as;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);if(s!==as&&this.setNextVertex(s,i),i!==as&&this.setPrevVertex(i,s),this.hasCurves()&&s!==as&&i!==as){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,i.g)(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new hs(this))}sortVerticesSimpleByX(t,e,s){(0,i.g)(0)}sortVerticesSimpleByY3D(t,e,s){(0,i.g)(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==as&&this.replaceCurveWithLine(s),this.getNextVertex(t)!==as&&this.replaceCurveWithLine(t);const i=new r.P;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.j)()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,i.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.j)()>>1),e<<=1,e|=this.getSegmentParentageBreakVertex(t)?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new us(e)}return new us(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=(0,r.j)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);return e!==as&&this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function cs(t){if(t.isEmpty())return new rs({vd:t.getDescription()});if((0,i.h)(t.getGeometryType())&&t.hasNonLinearSegments())return function(t){(0,i.g)(t.hasNonLinearSegments()&&!t.isEmpty());const e=new fs;return e.addGeometry(t),e.getBoundingGeometry()}(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new n.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new n.P,s=new Dt({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const o=e.getAttributeStreamRef(0),a=new fs({stream:o,n:s});let h=1;const m=o.readPoint2D(0),u=new r.P;for(;h<s&&o.queryPoint2D(h<<1,u).equals(m);)h++;if(a.m_treeHull.addElement(0),h<s){a.m_treeHull.addBiggestElement(h);const t=new r.P;for(let s=h+1;s<e.getPointCount();s++){o.queryPoint2D(s<<1,t);const e=a.treeHull(t);-1!==e&&a.m_treeHull.setElement(e,s)}}const l=e.getDescription(),c=l.getAttributeCount()>1,g=a.m_treeHull.size();let d=null;if(g>=2){d=g>=3?new rs({vd:l}):new Dt({vd:l});const t=d.getImpl();t.reserve(a.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new r.P;for(let i=a.m_treeHull.getFirst();-1!==i;i=a.m_treeHull.getNext(i))if(c){const s=new n.P;e.getPointByVal(a.m_treeHull.getElement(i),s),t.insertPoint(0,-1,s)}else o.queryPoint2D(a.m_treeHull.getElement(i)<<1,s),t.insertPoint2D(0,-1,s)}else if(c){const t=new n.P({vd:l});e.getPointByVal(a.m_treeHull.getElement(a.m_treeHull.getFirst()),t),d=t}else{const t=o.readPoint2D(a.m_treeHull.getElement(a.m_treeHull.getFirst())<<1);d=new n.P(t)}return d}function gs(t,e,s,i=!1){if(e<=262144)return function(t,e,s,i){const r=new n.a(0);for(let t=0;t<e;t++)r.add(t);const o={userSort(e,s,i){i.sort(e,s,(e,s)=>t[e].compareX(t[s]))},getValue:e=>t[e].x};i||n.B.sortEx(r,0,e,o);let a=0;t:for(let i=0;i<e;++i){const e=r.read(i);for(;a>=2;){const n=s[a-2],o=s[a-1];if(t[o].equals(t[e])){r.write(i,-1);continue t}if(!(xs(t[n],t[o],t[e])>=0)){o===r.read(i-1)&&r.write(i-1,-1);break}a--}s[a++]=e,2===a&&t[e].equals(t[s[0]])&&(r.write(1,-1),a--)}const h=a+1;t:for(let i=e-2;i>=0;--i){const e=r.read(i);if(!(e<0)){for(;a>=h;){const i=s[a-2],n=s[a-1];if(t[n].equals(t[e]))continue t;if(!(Ps(t[i],t[n],t[e])>=0))break;a--}if(0!==i){const i=s[a-1];s[a++]=e,t[e].equals(t[i])&&a--}}}return a>1&&t[s[0]].equals(t[s[a-1]])&&a--,a}(t,e,s,i);const r=new fs({points:t,n:e});let o=1;const a=t[0];for(;o<e&&t[o].equals(a);)o++;if(r.m_treeHull.addElement(0),o<e){r.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],i=r.treeHull(e);-1!==i&&r.m_treeHull.setElement(i,s)}}let h=0;for(let t=r.m_treeHull.getFirst();-1!==t;t=r.m_treeHull.getNext(t))s[h++]=r.m_treeHull.getElement(t);return h}function ds(t,e,s){if((e<0||e>=t.getPathCount())&&(0,i.a)("path index"),t.hasNonLinearSegmentsPath(e))return!1;const n=t.getImpl(),o=n.getPathStart(e),a=n.getPathEnd(e),h=!n.isClosedPath(e)&&n.isClosedPathInXYPlane(e),m=n.getAttributeStreamRef(0),u=2*o;let l=2*a;if(h&&(l-=2),l-u<6)return!0;const c=m.readPoint2D(u),g=m.readPoint2D(u+2),d=m.readPoint2D(u+4);if(!ys(r.P.orientationRobust(g,d,c)))return!1;const _=g.clone(),p=new r.P;for(let t=u+6;t<l;t+=2){if(p.assign(g),g.assign(d),m.queryPoint2D(t,d),!ys(r.P.orientationRobust(g,d,c)))return!1;if(!ys(r.P.orientationRobust(_,d,c)))return!1;if(!ys(r.P.orientationRobust(g,d,p)))return!1}return!0}function _s(t,e,s,n,o){if(function(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}(s,n,o),t.isEmpty())return;if(t.getGeometryType()===i.G.enumPoint)return void s.assign(t.getXY());const a=t,h=a.getPointCount();0!==h&&(1!==h?function(t,e,s,i,n,o){if(2===e){const e=t.getXY(0),s=t.getXY(1);i.assign(e.add(s).mul(.5));const r=s.sub(e);n=Es(r),o.setCoords(.5*r.length(),0)}else{let a=Number.MAX_VALUE;const h=[0,1,0,0],m=new r.R(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);h[0]<e;++h[0],bs(m,0,e)){h[1]===h[0]&&(++h[1],bs(m,1,e));for(let s=1;;++s){for(;;){const i=Ds(t.getXY(m.get(0,0)),t.getXY(m.get(0,1)),t.getXY(m.get(s,0)),t.getXY(m.get(s,1)),2^s);if(i>0)break;if(++h[s],bs(m,s,e),0===i)break}if(3===s)break;h[s+1]<h[s]&&(h[s+1]=h[s],m.set(s+1,0,m.get(s,0)),m.set(s+1,1,m.get(s,1)))}const u=t.getXY(m.get(0,0)).add(t.getXY(m.get(2,0))).mul(.5),l=Es(t.getXY(m.get(0,1)).sub(t.getXY(m.get(0,0)))),c=new r.P;let g,d;if(c.x=Math.max(0,l.dotProduct(t.getXY(m.get(1,0)).sub(t.getXY(m.get(3,0))))),c.y=Math.max(0,l.crossProduct(t.getXY(m.get(0,0)).sub(t.getXY(m.get(2,0))))),s?(g=c.x*c.y,d=g<a):(g=c.y,d=g<a),d){a=g;const e=t.getXY(m.get(1,0)),s=t.getXY(m.get(3,0)),r=e.add(s).mul(.5).sub(u);i.assign(u.add(l.mul(l.dotProduct(r)))),n.assign(l),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,r.c)(o.x,o.x=o.y),n.leftPerpendicularThis())}n.y<0?n.negateThis():0===n.y&&(n.x=1)}(a,h,e,s,n,o):s.assign(a.getXY(0)))}ls.st_defaultRank=1;class ps{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,i.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,i.g)(0),!1}get_vertex_handle_p(){return(0,i.g)(0),0}get_vertex_handle_q(){return(0,i.g)(0),0}get_current_support(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}intialize_(){return(0,i.g)(0),!1}increment_(){return(0,i.g)(0),!1}increment_q_(){return(0,i.g)(0),!1}increment_p_(){return(0,i.g)(0),!1}parallel_edge_with_q_support_(){return(0,i.g)(0),!1}parallel_edge_with_p_support_(){return(0,i.g)(0),!1}done_(){return(0,i.g)(0),!1}}class fs{nullGetXY(t){return(0,i.d)("m_getXY is null"),{}}nullDeleteNode(t){(0,i.d)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new n.T,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):void(0,i.q)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new ls,this.m_geometryHandle=this.m_shape.createGeometry(i.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,as),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,i.g)(0),new r.P}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){(0,i.g)(0)}addGeometry(t){if(t.isEmpty())return;const e=t.getGeometryType();if(e===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else(0,i.i)(e)?this.addMultiVertexGeometry(t):(0,i.f)(e)?this.addSegment(t,!1):e===i.G.enumEnvelope?this.addEnvelope(t):e===i.G.enumPoint?this.addPoint(t):(0,i.a)("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new n.P,e=this.m_treeHull.getFirst(),s=new rs({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return(0,i.g)(0),new ps(this)}getXY(t){return(0,i.g)(0),new r.P}getXYWithIndex(t){return(0,i.g)(0),new r.P}getFirst(){return(0,i.g)(0),0}getLast(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}getVertexIndex(t){return(0,i.g)(0),0}getPointCount(){return(0,i.g)(0),0}addMultiVertexGeometry(t){const e=new n.P,s=t.getImpl(),o=new r.P;for(let i=0;i<t.getPointCount();i++){s.queryXY(i,o);const n=this.addPoint2D(o);if(-1!==n){t.getPointByVal(i,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,s)}}if((0,i.h)(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments()){const t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){const e=new n.P;for(let s=0;s<4;s++){const i=new r.P;t.queryCorner(s,i);const n=this.addPoint2D(i);if(-1!==n){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}static querySegmentControlPoints(t,e,s){const o=t.getGeometryType();if((0,i.g)(o!==i.G.enumLine),o===i.G.enumEllipticArc){const s=t,i=60*Math.PI/180,o=Math.abs(s.getSweepAngle());if(o>i){const t=Math.min(6,Math.ceil(o/i)),a=1/t,h=new Rr;s.queryStart(e[0]);let m=1;for(let i=0;i<t;i++){s.queryCut(i*a,(i+1)*a,h);const o=(0,r.m)(r.P,3);gr(h.get(),o);const u=r.P.calculateLength(o,3),l=r.P.calculateLength(o,2),c=u>0?l/u:.5;i<t-1?h.get().queryEnd(e[m+1]):s.queryEnd(e[m+1]),n.P.lerp(e[m-1],e[m+1],c,e[m]),e[m].setXY(o[1]),m+=2}return m}{const s=(0,r.m)(r.P,3);gr(t,s);const i=r.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);const o=r.P.calculateLength(s,2),a=i>0?o/i:.5;return n.P.lerp(e[0],e[2],a,e[1]),e[1].setXY(s[1]),3}}if(o===i.G.enumBezier){const s=t,i=(0,r.m)(r.P,4);s.queryControlPoints(i);const o=r.P.calculateLength(i,4),a=r.P.calculateLength(i,2),h=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[3]);const m=o>0?a/o:.5;n.P.lerp(e[0],e[3],m,e[1]),e[1].setXY(i[1]);const u=o>0?h/o:.5;return n.P.lerp(e[0],e[3],u,e[2]),e[2].setXY(i[2]),4}if(o===i.G.enumBezier2){const s=t,i=(0,r.m)(r.P,3);s.queryControlPoints(i);const o=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(i,2),h=o>0?a/o:.5;return n.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(i[1]),3}if(o===i.G.enumRationalBezier2){const s=t,i=(0,r.m)(r.P,3);s.queryControlPoints(i);const o=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(i,2),h=o>0?a/o:.5;return n.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(i[1]),3}(0,i.a)("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new n.P,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const r=t.getEndXY(),o=this.addPoint2D(r);if(-1!==o){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,s)}}if(t.isCurve()){const e=(0,r.m)(n.P,13);for(let s=1,i=fs.querySegmentControlPoints(t,e,e.length)-1;s<i;++s){const t=e[s].getXY(),i=this.addPoint2D(t);if(-1!==i){const t=this.m_shape.addPoint(this.m_pathHandle,e[s]);this.m_treeHull.setElement(i,t)}}}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),n=this.m_treeHull.getElement(s),o=this.m_treeHull.getElement(i),a=this.m_getXY(n),h=this.m_getXY(o),m=r.P.orientationRobust(h,t,a);if(ys(m)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(vs(m)){let n=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),h=this.m_treeHull.getLast(),m=-1,u=-1,l=-1;for(;o!==this.m_treeHull.getPrev(h);){u=this.m_treeHull.getElement(n);const e=this.m_getXY(u);vs(r.P.orientationRobust(e,t,a))?(h=n,n=this.m_treeHull.getLeft(n)):(o=n,n=this.m_treeHull.getRight(n))}n=h,m=o,u=this.m_treeHull.getElement(n),l=this.m_treeHull.getElement(m);const c=this.m_getXY(u),g=this.m_getXY(l);if(m!==s&&!ys(r.P.orientationRobust(g,t,c)))break;e=this.m_treeHull.addElementAtPosition(m,n,-2,!0,!1),this.treeHullWalkForward(t,n,i),this.treeHullWalkBackward(t,m,s);break}{const n=Cs(t,h,a);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getNext(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(s,t,a)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getNext(i),this.m_deleteNode(h)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getPrev(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(a,t,s)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getPrev(i),this.m_deleteNode(h)}return i}}function xs(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function Ps(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function ys(t){return t<0}function vs(t){return t>0}function Cs(t,e,s){let i=-1;i=e.y===s.y?0:e.x===s.x?1:Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1;let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Es(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function bs(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Ds(t,e,s,n,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,i.a)("")}return r.P.orientationRobustEx(t,e,s,n)}class Ss{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function ws(t){return function(t){return 256*(0,r.O)()*t}(t.calculateUpperLength2D())}function As(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Ts(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),Ns(i,e,s)}function Is(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),qs(i,e,s)}function Ns(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function qs(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function Ms(t,e,s=!1){const i=(0,r.m)(C,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(r.M.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(r.M.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(r.ah,r.ah):e[0]=i[0].clone()}function Ys(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ys(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Xs(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=ws(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=xi(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function Xs(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Ss,s=(0,r.m)(r.H,8),i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=gi(i,s);e.specialPoints=[];for(let t=0;t<n;t++)e.specialPoints.push(s[t].value());return Rs(t,e),e}function Fs(t){let e=null;return e=t.m_cachedValues,e}function Rs(t,e){t.m_cachedValues=e}function Ls(t){t.m_cachedValues=null}function zs(t,e,s,i){const n=(0,r.m)(r.P,4);t.queryControlPoints(n);const o=(0,r.d)(18,NaN),a=It(new mi(n,e,NaN),r.E.construct(s,i),18,o),h=new r.P;t.queryCoord2D(s,h);let m=s,u=r.P.distance(h,e);const l=new r.P;t.queryCoord2D(i,l);const c=r.P.distance(l,e);c<u&&(u=c,m=i,h.assign(l));for(let s=0;s<a;s++){t.queryCoord2D(o[s],l);const i=r.P.distance(l,e);i<u&&(u=i,m=o[s],h.assign(l))}return function(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}(s,i,m,u,h)}function Vs(t,e){const s=(0,r.m)(r.H,4);Ts(t,s,!0);const n=(0,r.m)(r.H,4);Is(t,n,!0);const o=s[3].clone(),a=s[2].clone(),h=s[1].clone(),m=n[3].clone(),u=n[2].clone(),l=n[1].clone(),c=a.mulE(h).addE(u.mulE(l)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(h).mul(12)).addE(u.mulE(u).mul(8).addE(m.mulE(l).mul(12))),d=o.mulE(a).addE(m.mulE(u)).mul(36),_=o.mulE(o).addE(m.mulE(m)).mul(36),p=(0,r.m)(r.H,3),f=zt(_,d,g,c,new r.E(0,1),!1,p);if((0,i.g)(f<=3),f>0){const s=Gs(t,1,0).sqrLength(),i=Gs(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let s=0;s<f;s++){const i=Gs(t,1,p[s].value()).sqrLength();i<n&&(n=i,e=p[s])}}}function Bs(t,e,s){const i=new r.P;return function(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}(t,e,s,i),i}function Gs(t,e,s){const i=(0,r.m)(r.P,4);return t.queryControlPoints(i),Bs(i,e,s)}function Hs(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e),(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function ks(t){const e=(0,r.m)(r.P,4);t.queryControlPoints(e);const s=Ws(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Ws(t){return b(t)}function js(t,e,s){const i=new r.P,n=new r.P,o=new r.P,a=new r.P,h=new r.P;e<=.5?((0,r.a1)(2,t[0],t[1],e,i),(0,r.a1)(2,t[1],t[2],e,n),(0,r.a1)(2,t[2],t[3],e,o),(0,r.a1)(2,i,n,e,a),(0,r.a1)(2,n,o,e,h),(0,r.a1)(2,a,h,e,s)):((0,r.a2)(2,t[0],t[1],e,i),(0,r.a2)(2,t[1],t[2],e,n),(0,r.a2)(2,t[2],t[3],e,o),(0,r.a2)(2,i,n,e,a),(0,r.a2)(2,n,o,e,h),(0,r.a2)(2,a,h,e,s))}function Zs(t,e,s,n){(0,i.g)(e>=0&&e<=1);const o=new r.P,a=new r.P,h=new r.P,m=new r.P,u=new r.P,l=new r.P;e<=.5?((0,r.a1)(2,t[0],t[1],e,o),(0,r.a1)(2,t[1],t[2],e,a),(0,r.a1)(2,t[2],t[3],e,h),(0,r.a1)(2,o,a,e,m),(0,r.a1)(2,a,h,e,u),(0,r.a1)(2,m,u,e,l)):((0,r.a2)(2,t[0],t[1],e,o),(0,r.a2)(2,t[1],t[2],e,a),(0,r.a2)(2,t[2],t[3],e,h),(0,r.a2)(2,o,a,e,m),(0,r.a2)(2,a,h,e,u),(0,r.a2)(2,m,u,e,l));const c=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(o),s[2].assign(m),s[3].assign(l)),n&&(n[0].assign(l),n[1].assign(u),n[2].assign(h),n[3].assign(c))}function Us(t,e,s,n){if((0,i.g)(e>=0&&s<=1&&e<=s),e===s){const s=new r.P;return Os(t,e,s),n[0].assign(s),n[1].assign(s),n[2].assign(s),void n[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)n[e].assign(t[e]);return}const o=(0,r.m)(r.P,4);Zs(t,s,o,null),Zs(o,s>0?e/s:0,null,o),Os(t,e,o[0]),Os(t,s,o[3]),n[0].setCoordsPoint2D(o[0]),n[1].setCoordsPoint2D(o[1]),n[2].setCoordsPoint2D(o[2]),n[3].setCoordsPoint2D(o[3])}function Os(t,e,s,i){if(i){if(e<0)return void K(new Fr({start:t[0],end:t[0].add(Qs(t,0).getUnitVector())}),e,s);if(e>1)return void K(new Fr({start:t[3],end:t[3].add(Qs(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=new r.P;(0,r.a1)(2,t[0],t[1],e,i);const n=new r.P;(0,r.a1)(2,t[1],t[2],e,n);const o=new r.P;(0,r.a1)(2,t[2],t[3],e,o);const a=new r.P;(0,r.a1)(2,i,n,e,a);const h=new r.P;(0,r.a1)(2,n,o,e,h),(0,r.a1)(2,a,h,e,s)}else{const i=new r.P;(0,r.a2)(2,t[0],t[1],e,i);const n=new r.P;(0,r.a2)(2,t[1],t[2],e,n);const o=new r.P;(0,r.a2)(2,t[2],t[3],e,o);const a=new r.P;(0,r.a2)(2,i,n,e,a);const h=new r.P;(0,r.a2)(2,n,o,e,h),(0,r.a2)(2,a,h,e,s)}}function Qs(t,e){const s=(0,r.s)(e,0,1);let i=Bs(t,1,s);return i.isZero()&&(i=Bs(t,2,s),i.isZero()?i=Bs(t,3,s):1===s&&i.negateThis()),i}function $s(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){const i=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),y.constructPoint2D(t[3])],n=new y;return function(t,e,s,i){{const e=r.I.subE(s),n=e.sqr(),o=s.sqr(),a=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new r.H(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(o));i.setE(a.mulE(new r.H(3)))}}(i,0,s,n),n}(t,0,e))}(i,e,s)}function Ks(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==si(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Js(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==ii(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ti(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==ri(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ei(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==oi(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function si(t,e,s,i,n,o,a,h,m,u){if(null!==n&&(n.length=0),null!=o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],h=e.intersectPoint(s.getStartXY(),t,a);if(h>0){if(null!==n)for(let e=0;e<h;e++)n.push(t[e]);if(null!==o)for(let t=0;t<h;t++)o.push(0);if(null!=i)for(let s=0;s<h;s++){const n=new r.P;e.queryCoord2D(t[s],n),i.push(n)}}return h}const l=G(e,s);if(H(e,s,a=Math.max(a,l)))return 0;const c=(0,r.m)(r.P,4);As(e,c);const g=s.getEndXY();g.subThis(s.getStartXY());const d=g.clone();d.leftPerpendicularThis();let _=3*c[3].dotProduct(d),p=2*c[2].dotProduct(d),f=c[1].dotProduct(d);const x=(0,r.d)(15,Number.NaN),P=(0,r.d)(15,Number.NaN);let y=Nt(_,p,f,r.E.unit(),!1,x);y<0&&(x[0]=0,x[1]=1,y=2);let v,C=0;for(let t=0,i=C;t<y;++t){const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}if(c[0].subThis(s.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;_=c[3].y-c[3].x*t,p=c[2].y-c[2].x*t,f=c[1].y-c[1].x*t,v=c[0].y-c[0].x*t}else{const t=g.x/g.y;_=c[3].x-c[3].y*t,p=c[2].x-c[2].y*t,f=c[1].x-c[1].y*t,v=c[0].x-c[0].y*t}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),b=[0,0,0];y=qt(_,p,f,v,r.E.unit(),E,b);for(let t=0,i=C;t<y;++t){x[t+i]=b[t];const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}y=e.intersectPoint(s.getStartXY(),b,a);for(let t=0;t<y;t++)x[C]=b[t],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,a);for(let t=0;t<y;t++)x[C]=b[t],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),b,a)&&(P[C]=b[0],x[C++]=0),0!==s.intersectPoint(e.getEndXY(),b,a)&&(P[C]=b[0],x[C++]=1),0===C?0:qr(t,e,s,x,P,C,i,n,o,a,h,0,u)}function ii(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return si(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=[],p=(0,r.m)(r.P,4);{e.queryControlPoints(p);const t=(0,r.m)(r.P,4),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(p,4,t);const o=(0,r.m)(C,4);Ms(t,o);const u=[o[0].x,o[1].x,o[2].x,o[3].x],l=[o[0].y,o[1].y,o[2].y,o[3].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2].setThis(c[0]),c[2].mulThis(c[1]),c[2].negateThis();const f=ee(u,3,l,3,null,0,c,0,r.E.unit(),r.E.unit(),d,m);if(f>0){let t=0;for(let i=0;i<f;i++){const n=new r.P;e.queryCoord2D(d[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g.push(n.clone()),d[t]=d[i],_.push(o),t++)}d.length=t,g.length=t}}const f=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];ui(p,e,r.E.unit(),!1,-1,1,i);const n=new r.P;Os(p,i[0],n),r.P.distance(e,n)<=h&&(d.push(i[0]),_.push(f[t]),g.push(n.clone()))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(p[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(p[e[t]],n)<=h&&(d.push(f[t]),_.push(i),g.push(n.clone()))}}return qr(t,e,s,d,_,d.length,i,n,o,h,m,0,l)}function ni(t,e,s,n,o,a,h,m,u,l){const c=(0,r.m)(r.P,4);e.queryControlPoints(c);const g=(0,r.m)(r.P,4);if(s.queryControlPoints(g),k(c,g,4)<0)return ni(t,s,e,n,a,o,h,m,u,!l);const d=G(e,s);if(H(e,s,h=Math.max(h,d)))return 0;if(function(t,e,s,i,n,o,a,h,m){const u=(0,r.m)(r.P,4);t.queryControlPoints(u);const l=(0,r.m)(r.P,4);if(e.queryControlPoints(l),u[0].equals(l[0])){if(u[1].equals(l[1])&&u[2].equals(l[2])&&u[3].equals(l[3]))return s&&(s.length=0,s.push(u[0]),s.push(u[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!u[0].equals(l[3]))return!1}return!!(u[0].equals(l[3])&&u[1].equals(l[2])&&u[2].equals(l[1])&&u[3].equals(l[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,n,o,a,0,0,0,l))return 2;const _=new r.E(0,1),f=new r.E(0,1);{const t=new p;hi(c,new r.E(0,1),t);const e=new p;hi(g,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(_i(c,t,_),_.isEmpty())return 0;if(_i(g,t,f),f.isEmpty())return 0;Us(c,_.vmin,_.vmax,c),Us(g,f.vmin,f.vmax,g)}}const x=Yr(c,3,g,3,h);if(0===x)return 0;const P=[],y=[],v=[];let E=!1;if(-1===x){const t=(0,r.m)(C,4);Ms(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(C,4);Ms(g,i);const n=[],o=[],a=te(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,0,r.E.unit(),r.E.unit(),n,o,u);if(a>0)for(let t=0;t<a;t++){const e=new r.P;Os(g,o[t],e);const s=new r.P;Os(c,n[t],s),r.P.distance(s,e)<=h&&(P.push(s.clone()),v.push(o[t]),y.push(n[t]))}else-1===a&&(E=!0)}for(let t=0;t<2;t++){const e=0===t?c:g,s=0===t?g:c;for(let i=0;i<2;i++){const n=0===i?0:3,o=[0];ui(s,e[n],r.E.unit(),!1,-1,1,o);const a=new r.P;Os(s,o[0],a),r.P.distance(e[n],a)<=h&&(0===t?(y.push(0===n?0:1),v.push(o[0])):(v.push(0===n?0:1),y.push(o[0])),P.push(a.clone()))}}if(0===y.length&&E){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const n=[0,0];if(2===ci(t?e:s,n,!0)&&((0,i.g)(r.E.unit().containsCoordinate(n[0])),!r.E.unit().containsCoordinate(n[1]))){const e=new r.P;Os(t?c:g,n[0],e);const s=[0,0];1===ui(t?g:c,e,r.E.unit(),!1,-1,2,s)&&(P.push(e.clone()),y.push(t?n[0]:s[0]),v.push(t?s[0]:n[0]))}}}if(0===y.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=Ci.recalculateParentT(_.vmin,_.vmax,y[t]);if(!f.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=Ci.recalculateParentT(f.vmin,f.vmax,v[t]);return qr(t,e,s,y,v,y.length,n,o,a,h,m,0,l)}function ri(t,e,s,n,o,a,h,m,u,l){const c=G(e,s);if(s.isDegenerateToLineHelper(c)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()}),r=si(t,e,i,n,o,a,h,m,0,l);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);s.queryControlPoints(d);const _=new r.E(0,1),f=new r.E(0,1),x=[0,0,0];s.queryWeights(x);const P=[1,dn(x),1];{const t=new p;hi(g,new r.E(0,1),t);const e=new p;Zi(d,P,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(_i(g,t,_),_.isEmpty())return 0;if(gn(d,P,t,f),f.isEmpty())return 0;Us(g,_.vmin,_.vmax,g),Ki(d,P,f.vmin,f.vmax,d,P)}}const y=Yr(g,3,d,2,h);if(0===y)return 0;const v=[],E=[],b=[];if(-1===y){const t=(0,r.m)(C,4);Ms(g,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hn(d,P,i,n,o);const a=[],m=[],l=te(i,2,n,2,o,2,e,3,s,3,null,0,0,r.E.unit(),r.E.unit(),m,a,u);if(l>0)for(let t=0;t<l;t++){const e=new r.P;Os(g,a[t],e);const s=new r.P;cn(d,P,m[t],s),r.P.distance(e,s)<=h&&(v.push(e.clone()),E.push(a[t]),b.push(m[t]))}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=d):(s=g,e=d);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t){const t=Wi(s,P,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),cn(s,P,a[0],m)}else{const t=ui(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),Os(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(E.push(0===o?0:1),b.push(a[0])):(b.push(0===o?0:1),E.push(a[0])),v.push(m.clone()))}}if(0===E.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ci.recalculateParentT(_.vmin,_.vmax,E[t]);if(!f.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(f.vmin,f.vmax,b[t]);for(let t=0;t<b.length;++t)b[t]=_n(x,b[t]);return qr(t,e,s,E,b,E.length,n,o,a,h,m,0,l)}function oi(t,e,s,n,o,a,h,m,u,l){const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);s.queryControlPoints(d);const _=Yr(g,3,d,2,h);if(0===_)return 0;const p=[],f=[],x=[];if(-1===_){const t=(0,r.m)(C,4);Ms(g,t);const i=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,r.m)(C,3);Qe(d,o);const a=te([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,i,3,n,3,null,0,0,r.E.unit(),r.E.unit(),x,f,m);if(a>0){let t=0;for(let i=0;i<a;i++){const n=new r.P;e.queryCoord2D(f[i],n);const o=new r.P;s.queryCoord2D(x[i],o),r.P.distance(n,o)<=h&&(p.push(n.clone()),f[t]=f[i],x[t]=x[i],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=d):(s=g,e=d);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t)Re(s,e[o],a),$e(s,a[0],m);else{const t=ui(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),Os(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(f.push(0===o?0:1),x.push(a[0])):(x.push(0===o?0:1),f.push(a[0])),p.push(m.clone()))}}return qr(t,e,s,f,x,f.length,n,o,a,h,m,0,l)}function ai(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),hi(i,e,s)}function hi(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=(0,r.m)(r.P,4);Us(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}let mi=class{constructor(t,e,s){this.dbgCounter=0,this.controlPoints=t,this.point=e.clone(),this.maxDistance=s}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e),i=Bs(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e),i=Bs(this.controlPoints,2,e),n=Bs(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=Bs(this.controlPoints,1,e),s=Bs(this.controlPoints,2,e),i=Bs(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=Bs(this.controlPoints,2,e),s=Bs(this.controlPoints,3,e);return 10*t.dotProduct(s)*2}case 5:{const t=Bs(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){const s=(0,r.m)(r.P,4);Us(this.controlPoints,t,e,s);const i=new p;if(i.setFromPoints(s,4),Math.sqrt(i.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function ui(t,e,s,o,a,h,m){(0,i.x)(r.E.unit().contains(s)&&h>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);const u=[],l=new r.P;Os(t,s.vmin,l);let c=r.P.distance(l,e);if(c<=a&&u.push(new r.P(s.vmin,c)),s.vmin!==s.vmax&&(Os(t,s.vmax,l),c=r.P.distance(l,e),c<=a&&u.push(new r.P(s.vmax,c))),s.width()>0){const i=(0,r.d)(18,Number.NaN),n=It(new mi(t,e,a),s,18,i);for(let s=0;s<n;s++)Os(t,i[s],l),c=r.P.distance(l,e),c>a||u.push(new r.P(i[s],c))}if(o){(0,i.g)(s.equals(r.E.unit()));{Os(t,-1,l,!0);const s=new r.P;Os(t,0,s);const i=new Fr({start:l,end:s}),n=i.getClosestCoordinate(e,!0);n<1&&(l.assign(i.getCoord2D(n)),c=r.P.distance(l,e),c<=a&&u.push(new r.P(n-1,c)))}{Os(t,2,l,!0);const i=new r.P;Os(t,s.vmax,i);const n=new Fr({start:i,end:l}),o=n.getClosestCoordinate(e,!0);o>0&&(l.assign(n.getCoord2D(o)),c=r.P.distance(l,e),c<=a&&u.push(new r.P(1+o,c)))}}if(!u.length)return 0;u.sort((t,e)=>t.compare(e));let g=0;const d=u[0].x;if(m[g++]=d,g<h){const e=(0,n.J)(t,4,!1).total(),s=u[0].y;for(let t=1,i=u.length;t<i;t++)if(u[t].y>s+e){u.length=t;break}u.sort((t,e)=>(0,r.a7)(t.x,e.x)),g=0,m[g++]=u[0].x;for(let t=1,e=u.length;t<e;t++)u[t].x!==m[g-1]&&g<h&&(m[g++]=u[t].x)}return g}function li(t,e,s,i,n,o,a){const h=(0,r.m)(r.P,4);return t.queryControlPoints(h),ui(h,e,s,i,n,o,a)}function ci(t,e,s=!1){const i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=(0,r.m)(C,4);let o,a,h;Ms(i,n,!0);const m=n[3].x.isZero(),u=n[3].y.isZero();if(m||u)if(m&&!u){if(n[2].x.isZero())return 0;o=n[1].x.div(n[2].x).negate(),a=n[2].y.div(n[3].y),h=n[1].y.div(n[3].y)}else{if(m||!u)return 0;if(n[2].y.isZero())return 0;o=n[1].y.div(n[2].y).negate(),a=n[2].x.div(n[3].x),h=n[1].x.div(n[3].x)}else{n[2].x.divThis(n[3].x),n[1].x.divThis(n[3].x),n[2].y.divThis(n[3].y),n[1].y.divThis(n[3].y);const t=n[2].x.sub(n[2].y);if(t.isZero())return 0;o=n[1].x.sub(n[1].y).div(t).negate(),a=n[2].x.clone(),h=n[1].x.clone()}if(!s&&o.abs().value()>2)return 0;const l=[0,0],c=t.getStartXY().equals(t.getEndXY()),g=Nt(1,-o.toDouble(),o.add(a).mul(o).add(h).toDouble(),r.E.unit(),c,l);if(0===g)return 0;if(l[0]>=0&&l[0]<=1){const t=o.toDouble()-l[0];if(s||t>=0&&t<=1)return e[0]=l[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}if(2===g&&l[1]>=0&&l[1]<=1){const t=o.toDouble()-l[1];if(s||t>=0&&t<=1)return e[0]=l[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}return 0}function gi(t,e){e[0].set(0);let s=1;const n=(0,r.m)(r.H,4);Ns(t,n,!0);const o=(0,r.m)(r.H,4);qs(t,o,!0);{const t=n[3].mul(3),i=n[2].mul(2),o=n[1].clone(),a=(0,r.m)(r.H,2);let h=Lt(t,i,o,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(e[s]=a[t],s++)}{const t=o[3].mul(3),i=o[2].mul(2),n=o[1].clone(),a=(0,r.m)(r.H,2);let h=Lt(t,i,n,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(e[s]=a[t],s++)}if(s+=function(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,r.m)(r.H,2);let h=Lt(o,n,i,new r.E(0,1),!1,a);h<0&&(h=0);let m=0;for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(s[m].setE(a[t]),m++);return m}(n,o,e.slice(s)),e[s].set(1),s++,s>2){(0,r.C)(e,0,s,(t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0});let i=0;const n=e[0].clone();let o=0;const a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,r.O)(),h=new r.P;js(t,e[0].value(),h);for(let m=1;m<s;m++){const s=new r.P;if(js(t,e[m].value(),s),e[m].eq(n)||s.isEqualPoint2D(h,a)){if(0!==i){if(0===e[m].eps())n.setE(e[m]),o=0;else if(0!==o){const t=(0,r.a)(1/e[m].eps()),s=1/o,i=t+s;n.set((e[m].value()*t+n.value()*s)/i),o=1/i,n.setError(Math.sqrt(o))}e[i].setE(n),js(t,n.value(),h)}}else i++,e[i].setE(e[m]),n.setE(e[m]),js(t,n.value(),h),o=(0,r.a)(e[m].eps())}i++,s=i}return 1===s&&(s=2,e[1].set(1)),(0,i.g)(0===e[0].value()),(0,i.g)(1===e[s-1].value()),s}function di(t,e,s,i){const n=(0,r.m)(r.P,s);for(let t=0;t<s;++t)n[t]=new r.P(t/(s-1),0);const o=(t,e,s,i)=>{const n=new r.H(e.x).subE(new r.H(t.x)).divE(new r.H(e.y).subE(new r.H(t.y))).mulE(new r.H(s).subE(new r.H(t.y))).addE(new r.H(t.x));if(n.eps()>.1){const i=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;n.set(i,(0,r.O)())}if(n.lt(new r.H(0))||n.gt(new r.H(1)))return!1;let o=n.value()-n.eps();o=(0,r.s)(o,0,1);let a=n.value()+n.eps();return a=(0,r.s)(a,0,1),i.mergeCoordinate(o),i.mergeCoordinate(a),!0},a=[];{const e=(t,e)=>{a.length=s;const i=gs(n,s,a,!0),h=new r.E;h.setEmpty();const m=s=>s.y<t?-1:s.y>e?1:0;let u=n[a[0]],l=m(u);0===l&&h.mergeCoordinate(u.x);for(let s=1;s<=i;++s){const r=n[a[s%i]],c=m(r);0===c&&h.mergeCoordinate(r.x);let g=0;c!==l&&(g=c*l===0?1===c||1===l?2:1:3,1&g&&o(u,r,t,h),2&g&&o(u,r,e,h)),u=r,l=c}return h};for(let e=0;e<s;++e)n[e].y=t[e].x;const h=e(i.xmin,i.xmax);if(h.isEmpty())return new r.E(h);for(let e=0;e<s;++e)n[e].y=t[e].y;const m=e(i.ymin,i.ymax);return h.intersect(new r.E(m)),new r.E(h)}}function _i(t,e,s){s.setEmpty(),s.merge(function(t,e,s,i){const n=di(t,0,4,i.getEnvelope2D());if(n.isEmpty())return new r.E(n);const o=(0,r.m)(r.P,4);for(let e=0;e<4;++e)i.xyRot(t[e],o[e]);const a=di(o,0,4,i.getRotatedEnvelope2D());return n.intersect(new r.E(a)),new r.E(n)}(t,0,0,e))}class pi{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ys(this.b,e,!1):0}getError(t){return 0}}function fi(t,e,s,n,o,a,h){for(;;){const m=r.P.distance(e[0],e[3]),u=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2])+r.P.distance(e[2],e[3]);if(u-m<=n+s*u)return t+(0,r.q)(m,u,.5);const l=t=>Bs(e,1,t).length();{(0,i.g)(h<12);let m=l(0),c=l(1);o[0]+=2,m>c&&(c=(0,r.c)(m,m=c),e[3]=(0,r.c)(e[0],e[0]=e[3]),e[2]=(0,r.c)(e[1],e[1]=e[2]));let g=m/(m+c),d=1,_=u;for(;g<1/32&&_>=32*(n+s*_);){d/=4;const t=l(d);o[0]++,g=m/(t+m);const s=new r.P;if(Os(e,.5*d,s),_=r.P.distance(s,e[0]),_<=n){const t=new r.P;Os(e,d,t),_+=r.P.distance(t,s)}}if(1!==d){const i=(0,r.m)(r.P,4);Zs(e,d,e,i),t=fi(t,i,s,n,o,0,h+1),a++,h++;continue}}const c=8;o[0]+=c;const g=ns(c,l,0,1),d=16;o[0]+=d;const _=ns(d,l,0,1);let p=Math.abs(g-_)>n+s*u;if(!p)return t+_;if(a<3){const i=(0,r.m)(r.P,4);Zs(e,.5,e,i),t=fi(t,i,s,n,o,a+1,h+1),a++,h++;continue}const f=32;o[0]+=f;const x=ns(f,l,0,1);if(p=Math.abs(_-x)>n+s*u,!p)return t+x;const P=64;o[0]+=P;const y=ns(P,l,0,1);if(p=Math.abs(x-y)>n+s*u,!p)return t+y;const v=128;o[0]+=v;const C=ns(v,l,0,1);return p=Math.abs(y-C)>n+s*u,t+C}}function xi(t,e,s,i,n){if(s===e)return 0;const o=(0,r.m)(r.P,4);t.queryControlPoints(o);const a=(0,r.m)(r.P,4);return Us(o,e,s,a),fi(0,a,i,n,[0],0,0)}function Pi(t,e,s,i,n){let o=!0;const a=fe(5,e,s,i,n,e=>{const s=Gs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});o=!1;const h=fe(5,e,s,i,n,e=>{const s=Gs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new r.P(a,h)}function yi(t,e,s,n,o,a,h,m,u,l,c,g){(0,i.g)(l+2===g);let d=0,_=0,p=0,f=0,x=0,P=0,y=0;const v=(t,e)=>{const i=1-e,h=s.mul((0,r.an)(i)),m=n.mul(3*e*i*i),u=o.mul(3*e*e*i),l=a.mul((0,r.an)(e));return h.add(m).add(u).add(l).sub(c[t]).sqrLength()};for(let e=1,i=g-1;e<i;e++){let i=u[e-1];if(t){e>2?(i=(0,r.s)(2*u[e-2]-u[e-3],0,1),u[e-1]=i):2===e&&(i=(0,r.s)(2*u[e-2],0,1),u[e-1]=i);const t=(t,e,i)=>{let h=-1;for(let m=0;!(Math.abs(e-h)<1e-12)&&10!==m;m++){const m=e*e,u=1-e,l=u*u,g=l*u,d=s.x-2*n.x+o.x,_=s.x-3*n.x+3*o.x-a.x,p=s.y-2*n.y+o.y,f=s.y-3*n.y+3*o.y-a.y,x=s.x-n.x-2*d*e+_*m,P=-c[t].x+s.x*g+e*(3*n.x*l+e*(3*o.x*u+a.x*e)),y=s.y-n.y-2*p*e+f*m,v=-c[t].y+s.y*g+e*(3*n.y*l+e*(3*o.y*u+a.y*e)),C=-6*(x*P+y*v),E=6*(3*(0,r.a)(x)-(-2*d+2*_*e)*P)+6*(3*(0,r.a)(y)-(-2*p+2*f*e)*v);if(h=e,0===E)break;e=(0,r.s)(e-C/E,i,1)}return h};{const s=v(e,u[e-1]);let i=t(e,u[e-1],0),n=v(e,i);if(1.01*s<n){const s=e>1?u[e-2]:0,r=t(e,.3*(u[e-1]-s)+s,0),o=v(e,r);o<n&&(n=o,i=r)}s>n&&(u[e-1]=i)}}const h=u[e-1],m=h*h,l=m*h,g=1-h,C=g*g,E=C*g;d+=3*m*C*C,_+=3*l*E,p+=3*m*m*C;const b=-(E*s.x+l*a.x-c[e].x);f+=b*h*C,x+=b*m*g;const D=-(E*s.y+l*a.y-c[e].y);P+=D*h*C,y+=D*m*g}if(e){const t=d*p-_*_;Math.abs(t)>=1e-12*(Math.abs(d*p)+Math.abs(_*_))+1e-10?(h||(n.x=(f*p-x*_)/t,n.y=(P*p-y*_)/t),m||(o.x=(d*x-_*f)/t,o.y=(d*y-_*P)/t)):((0,r.U)(s,a,.3,n),(0,r.U)(s,a,.6,o))}let C=0;for(let t=1,e=g-1;t<e;t++)C+=v(t,u[t-1]);return C}var vi=n.V;class Ci extends Q{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),(0,i.d)("unrecognized constructor params"),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return At(this)}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=(0,r.m)(r.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,r.U)(t[0],t[1],2/3,e[1]),(0,r.U)(t[1],t[2],1/3,e[2])})(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),(0,r._)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,r._)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),V(this,t)}getGeometryType(){return i.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,i.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Fs(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const s=(0,r.m)(r.H,8),n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=gi(n,s),a=new r.P;for(let e=1;e<o-1;e++)this.queryCoord2D(s[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Ls(this)}(0,i.g)(0)}createInstance(){return new Ci({vd:this.m_description})}calculateLength2D(){return Ys(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return r.P.distance(this.getStartXY(),this.m_cp[0])+r.P.distance(this.m_cp[0],this.m_cp[1])+r.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){(0,i.g)(0)}queryCoord2DExtends(t,e,s){const i=(0,r.m)(r.P,4);this.queryControlPoints(i),Os(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=new y;(0,r.a3)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,i);const n=new y;(0,r.a3)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,n);const o=new y;(0,r.a3)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);const a=new y;(0,r.a3)(2,i,n,e,a);const h=new y;(0,r.a3)(2,n,o,e,h),(0,r.a3)(2,a,h,e,s)}else{const i=new y;(0,r.a4)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,i);const n=new y;(0,r.a4)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,n);const o=new y;(0,r.a4)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);const a=new y;(0,r.a4)(2,i,n,e,a);const h=new y;(0,r.a4)(2,n,o,e,h),(0,r.a4)(2,a,h,e,s)}}(i,e,s)}(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.x}const e=(0,r.q)(this.getStartX(),this.m_cp[0].x,t),s=(0,r.q)(this.m_cp[0].x,this.m_cp[1].x,t),i=(0,r.q)(this.m_cp[1].x,this.getEndX(),t),n=(0,r.q)(e,s,t),o=(0,r.q)(s,i,t);return(0,r.q)(n,o,t)}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.y}const e=(0,r.q)(this.getStartY(),this.m_cp[0].y,t),s=(0,r.q)(this.m_cp[0].y,this.m_cp[1].y,t),i=(0,r.q)(this.m_cp[1].y,this.getEndY(),t),n=(0,r.q)(e,s,t),o=(0,r.q)(s,i,t);return(0,r.q)(n,o,t)}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=vi.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=vi.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){$s(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.a)("Cubic_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4);Us(n,t,e,o),s.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&(0,i.a)("Cubic_bezier.split_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4),a=(0,r.m)(r.P,4);Zs(n,t,o,a),e&&e.setControlPoints(o),s&&s.setControlPoints(a)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.getStartAttributeAsDbl(e,s),n=this.getEndAttributeAsDbl(e,s),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,h=vi.getInterpolation(e);return(0,r.V)(h,i,n,a,vi.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return li(this,t,r.E.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===li(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=Xs(this);if(2===s.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)ks(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.P,4);return this.queryControlPoints(n),function(t,e,s,i,n){const o=(0,r.m)(r.H,4),a=(0,r.m)(r.H,3),h=new r.E(0,1);let m=0;if(e){if(qs(t,o,!1),m=zt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;Os(t,a[e].value(),s),i[e]=s.x}}else if(Ns(t,o,!1),m=zt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;Os(t,a[e].value(),s),i[e]=s.y}if(n)for(let t=0;t<m;t++)n[t]=a[t].value();else i&&(0,r.C)(i,0,m,r.a7);return m}(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),Us(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ys(this,t,!0)}lengthToT(t){return function(t,e){const s=Ys(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new pi(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,4);As(this,e);const s=e[3],i=e[2],n=e[1],o=new r.P;o.x=(5*s.x*s.x*(7*i.y+16*n.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*n.x+140*i.x*n.y+112*n.x*n.y)-2*(s.y*(20*i.x*i.x+70*i.x*n.x+56*n.x*n.x)-7*(4*i.x+5*n.x)*(-i.y*n.x+i.x*n.y)))/840,o.y=(-5*s.y*s.y*(7*i.x+16*n.x)+s.y*(5*s.x*(7*i.y+16*n.y)-4*(10*i.x*i.y+35*i.y*n.x+28*n.x*n.y))+2*(-7*(4*i.y+5*n.y)*(i.y*n.x-i.x*n.y)+s.x*(20*i.y*i.y+70*i.y*n.y+56*n.y*n.y)))/840;const a=Hs(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weightedCentroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=Xs(t),a=ws(t),h=a/t.calculateUpperLength2D();let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Pi(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),4}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&(0,i.a)("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Qs(e,t)}getDerivative(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Bs(e,1,t)}getCurvature(t){const e=Gs(this,1,t),s=Gs(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new o.Envelope2D;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,4);return this.queryControlPoints(t),function(t){return function(t){const e=(0,r.F)(t[0].y,t[1].y),s=(0,r.F)(t[1].y,t[2].y),i=(0,r.F)(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=(0,r.F)(t[0].x,t[1].x),s=(0,r.F)(t[1].x,t[2].x),i=(0,r.F)(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}(t)}(t)}getMonotonicPartParams(t,e){const s=Xs(this),n=s.specialPointsCount();if((0,i.g)(j.s_maxMonotonicPartParams>=n),!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new r.H;return Vs(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])+r.P.distance(e[2],e[3])-i>t)return!1;const n=t;let o=e[1].clone();o.subThis(e[0]);let a=Math.abs(o.crossProduct(s))/i;return!(a>n||(o=e[2].clone(),o.subThis(e[1]),a=Math.abs(o.crossProduct(s))/i,a>n))}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Hs(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){ai(this,t,e)}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){if((0,i.g)(s>=2),2===s){const i=new r.P;(0,r.U)(e[0],e[s-1],1/3,i);const n=new r.P;return(0,r.U)(e[0],e[s-1],2/3,n),void t.construct(e[0],i,n,e[s-1])}const n=e[0],o=e[s-1],a=[0,0],h=li(t,n,r.E.unit(),!1,Number.NaN,2,a),m=[0,0],u=li(t,o,r.E.unit(),!1,Number.NaN,2,m),l=[];for(let i=0;i<h;i++)for(let h=0;h<u;h++){const u=a[i],c=m[h],g=u>c,d=(i,a)=>{const h=(0,r.d)(s-2,Number.NaN),m=()=>{let t=0;for(let i=1,n=s-1;i<n;i++){t+=r.P.distance(e[i-1],e[i]);const s=t;h[i-1]=s}t+=r.P.distance(e[s-2],e[s-1]),g&&h.reverse();for(let e=1,i=s-1;e<i;e++)h[e-1]/=t,g&&(h[e-1]=1-h[e-1])};let l=!1,d=!1;{const e=new Rr;g?(t.queryCut(c,u,e,!0),i.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())):(t.queryCut(u,c,e,!0),i.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())),n.equals(i)&&(l=!0),o.equals(a)&&(d=!0)}m();let _=Number.MAX_VALUE;const p=i.clone(),f=a.clone();for(let t=0;t<5;t++)_=yi(!0,!1,n,p,f,o,l,d,h,s-2,e,s);for(let t=0;t<30;t++){const t=p.clone();f.clone();const i=yi(!0,!0,n,p,f,o,l,d,h,s-2,e,s);if(_<=i&&t.equals(p)&&t.equals(f))break;_=i}m();let x=!1,P=Number.MAX_VALUE;const y=i.clone(),v=a.clone();for(let t=0;t<30;t++){const t=y.clone();v.clone();const i=yi(x,!0,n,y,v,o,l,d,h,s-2,e,s);if(P<=i&&t.equals(y)&&t.equals(v))break;x=!0,P=i}return P<_?(i.assign(y),a.assign(v)):(i.assign(p),a.assign(f),P=_),P},_=new r.P,p=new r.P,f=[d(_,p),r.P.distance(n,_)+r.P.distance(_,p)+r.P.distance(p,o),_.x,_.y,p.x,p.y];l.splice(l.length,0,...f)}let c=l[0],g=l[1],d=0;for(let t=6;t<l.length;t+=6)l[t]<c&&(c=l[t],g=l[t+1],d=t);let _=d;for(let t=0;t<l.length;t+=6)t!==d&&l[t+1]<g&&Math.abs(c-l[t])<10*c&&(g=l[t+1],_=t);t.construct(n,new r.P(l[_+2],l[_+3]),new r.P(l[_+4],l[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return function(t,e,s){s.length=0;{const e=new r.H;Vs(t,e);const i=new y;if($s(t,e,i),i.isZero())return e.isZero()||e.eq(new r.H(1))?0:(s.push(e.value()),1)}const i=(0,r.m)(r.H,4);Ts(t,i,!0);const n=(0,r.m)(r.H,4);Is(t,n,!0);const o=(0,r.m)(r.H,6),a=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),m=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));o[0]=n[1].mulE(n[1]).mulE(a).addE(i[1].mulE(i[1]).mulE(h)).addE(i[1].mulE(n[1]).mulE(m).mul(2)).mul(6),o[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const u=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),l=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(u).mul(156),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),g=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(g).addE(n[1].mulE(n[3]).mulE(c)).mul(72),_=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),p=i[2].mulE(n[2]).mulE(_).mul(120),f=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),x=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(f).mul(36);o[2]=l.addE(d).addE(p).addE(x);const P=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),v=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),C=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),E=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);o[3]=P.addE(v).addE(C).addE(E),o[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),o[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=(0,r.m)(r.H,5),D=Vt(o,5,new r.E(0,1),!1,b,5);if(D>0){let i=Math.abs(t.getCurvature(0)),n=0;const o=Math.abs(t.getCurvature(1));(o>i||!Number.isFinite(o))&&(n=1);for(let e=0;e<D;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!(0,r.N)(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}if(!t.isClosed()){const e=[0,0],i=ci(t,e,!1);for(let t=0;t<i;t++)e[t]>0&&e[t]<1&&s.push(e[t]);return s.length}return 0}(this,t,e)}ensureXYMonotone(){return ks(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,r.U)(e,s,1/3,t.m_cp[0]),(0,r.U)(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&ks(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Rs(e,Fs(this))}reverseImpl(){this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t;return!!this.m_cp[0].equals(e.m_cp[0])&&!!this.m_cp[1].equals(e.m_cp[1])}equalsImplTol(t,e){const s=t;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[1],e)}swapImpl(t){const e=t;e.m_cp[0]=(0,r.c)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,r.c)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ls(this)}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(ai(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Xs(t);let h=0,m=a.specialPoints[0];const u=[];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=zs(t,e,m,n);if(0===u.length)u.push(r);else if(r.t===r.tmin)(0,i.g)(u.at(-1).d<=r.d),u.at(-1).tmax=r.tmax;else if(u.at(-1).t===u.at(-1).tmax){(0,i.g)(u.at(-1).d>=r.d);const t=u.at(-1).tmin;u[u.length-1]=r,u.at(-1).tmin=t}else u.push(r);m=n}for(const t of u)if(t.d<=n){const e=t.t;s?(h>=s.length&&(0,i.r)(""),s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Ls(this)}clearEndPointModified(){}}Ci.type=i.G.enumBezier;class Ei{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function bi(t,e,s,n,o,a,h,m){for(;;){const u=r.P.distance(e[0],e[2]),l=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2]);if(l-u<=o+n*l)return t+(0,r.q)(u,l,.5);const c=(0,r.m)(r.P,4),g=t=>(Yi(e,s,1,t,c),c[1].length());if(0===h&&m<8){(0,i.g)(m<8);let u=g(0),c=g(1);a[0]+=2,u>c&&(c=(0,r.c)(u,u=c),e[2]=(0,r.c)(e[0],e[0]=e[2]),s[2]=(0,r.c)(s[0],s[0]=s[2]));let d=u/(u+c),_=1,p=l;for(;d<1/32&&p>=o+n*p;){_/=4;const t=g(_);a[0]++,d=u/(t+u);const i=new r.P;if(cn(e,s,.5*_,i),p=r.P.distance(i,e[0]),p<=o){const t=new r.P;cn(e,s,_,t),p+=r.P.distance(t,i)}}if(1!==_){const i=(0,r.m)(r.P,3),u=[0,0,0];$i(e,s,_,e,s,i,u),t=bi(t,i,u,n,o,a,0,m+1),h++,m++;continue}}let d=!1;const _=8;a[0]+=_;const p=ns(_,g,0,1),f=16;a[0]+=f;const x=ns(f,g,0,1);if(d=Math.abs(p-x)>o+n*l,!d)return t+x;if(h<8&&m<9){const i=(0,r.m)(r.P,3),u=[0,0,0];$i(e,s,.5,e,s,i,u),t=bi(t,i,u,n,o,a,h+1,m+1),h++,m++;continue}const P=32;a[0]+=P;const y=ns(P,g,0,1);if(d=Math.abs(x-y)>o+n*l,!d)return t+y;const v=64;a[0]+=v;const C=ns(v,g,0,1);if(d=Math.abs(y-C)>o+n*l,!d)return t+C;const E=128;a[0]+=E;const b=ns(E,g,0,1);return d=Math.abs(C-b)>o+n*l,t+b}}function Di(t,e,s,i,n){if(s===e)return 0;const o=(0,r.m)(r.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);const h=[0,0,0],m=(0,r.m)(r.P,3);return Ki(o,a,e,s,m,h),bi(0,m,h,i,n,[0],0,0)}class Si{constructor(t,e,s){this.controlPoints=(0,r.L)(t,3),this.weights=[0,0,0],(0,r.b)(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,1,e,s),2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,2,e,s),2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,3,e,s),2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return(0,i.g)(0),0}}function wi(t,e,s,i){const n=function(t,e,s,i,n){return{tmin:0,tmax:0,t:0,d:0,pt:n.clone()}}(0,0,0,0,r.P.getNAN()),o=(0,r.d)(18,Number.NaN),a=(0,r.m)(r.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);const h=[0,0,0];t.queryWeights(h);const m=[1,dn(h),1],u=pn(h,s),l=pn(h,i),c=It(new Si(a,m,new r.P(0,0)),r.E.construct(u,l),18,o);cn(a,m,u,n.pt),n.t=u,n.d=r.P.distance(n.pt,new r.P(0,0));const g=new r.P;cn(a,m,l,g);const d=r.P.distance(g,new r.P(0,0));d<n.d&&(n.d=d,n.t=l,n.pt.assign(g));for(let t=0;t<c;t++){cn(a,m,o[t],g);const e=r.P.distance(g,new r.P(0,0));e<n.d&&(n.d=e,n.t=_n(h,o[t]),n.pt.assign(g))}return n}function Ai(t,e,s,i,n){let o=!0;const a=(0,r.m)(r.P,4),h=fe(5,e,s,i,n,e=>(Mi(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));o=!1;const m=fe(5,e,s,i,n,e=>(Mi(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));return new r.P(h,m)}function Ti(t){t.m_cachedValues=null}function Ii(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Ei,s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Ni(s,i,e.specialPoints),Hi(t,e),e}function Ni(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const i=(0,r.m)(r.H,8);i[0].set(0);let n=1;{const s=new r.H(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new r.H(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.H(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.H,2);let m=Lt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.N)(h[t].value(),0,1)||(i[n]=h[t],n++)}{const s=new r.H(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new r.H(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.H(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.H,2);let m=Lt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.N)(h[t].value(),0,1)||(i[n]=h[t],n++)}if(i[n].set(1),n++,n>2){(0,r.C)(i,0,n,(t,e)=>(0,r.a7)(t.value(),e.value()));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let t=0;t<n;t++)s[t]=i[t].value()}function qi(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+qi(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Ii(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Bi(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=Di(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function Mi(t,e,s,i){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=[0,0,0];t.queryWeights(o),Yi(n,o,e,s,i)}function Yi(t,e,s,n,o){const a=[t[0],t[1],t[2]],h=[e[0],e[1],e[2]],m=(0,r.m)(r.P,4);!function(t,e,s,n,r){(0,i.g)(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Xi(o,e,0,n),h=Ri(e,0,n),m=a.divide(h);if(r[0].assign(m),0===s)return;const u=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],l=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],c=h*h,g=Xi(l,u,0,n).mul(2).divide(c);if(r[1].assign(g),1===s)return;const d=Ri(e,1,n),_=2*h*d,p=Xi(l,u,1,n).mul(2).sub(g.mul(_)).divide(c);if(r[2].assign(p),2===s)return;const f=Xi(l,u,2,n).mul(2),x=2*(d*d+h*Ri(e,2,n)),P=f.sub(p.mul(_).mul(2)).sub(g.mul(x)).divide(c);r[3].assign(P),3!==s&&(0,i.d)("")}(a,h,s,n,m);for(let t=0;t<=s;t++)o[t].setCoords(m[t].x,m[t].y)}function Xi(t,e,s,n){if(0===s){if(n<=.5){const s=new r.P;(0,r.a1)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r.a1)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r.a1)(2,s,i,n,o),o}{const s=new r.P;(0,r.a2)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r.a2)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r.a2)(2,s,i,n,o),o}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-n).add(t[2].mul(e[2]).sub(s).mul(n));return i.mulThis(2),i}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}(0,i.d)("")}function Fi(t,e,s,i){if(i.toDouble()<=.5){const s=new y;(0,r.a3)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new y;(0,r.a3)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new y;return(0,r.a3)(2,s,n,i,o),o}{const s=new y;(0,r.a4)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new y;(0,r.a4)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new y;return(0,r.a4)(2,s,n,i,o),o}}function Ri(t,e,s){if(0===e){const e=(0,r.q)(t[0],t[1],s),i=(0,r.q)(t[1],t[2],s);return(0,r.q)(e,i,s)}return 1===e?2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,i.d)("")}function Li(t,e,s){const i=(0,r.s)(s,0,1),n=(0,r.m)(r.P,4);if(Yi(t,e,3,i,n),n[1].isZero()){if(n[2].isZero())return n[3];{const t=n[2].clone();return 1===i&&t.negateThis(),t}}return n[1]}class zi{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-qi(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}}function Vi(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=dn(e);if(1===s)return Me(t);if(0===s)return 0;const n=[new r.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=n[1].crossProduct(n[2]);if(s<1){(0,i.g)(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const i=t*(1+s),n=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-(0,r.ap)(i)*n)/i}return o*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*o-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-n[1].x*n[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}(e,s)}function Bi(t){return function(t){return 256*(0,r.O)()*t}(t.calculateUpperLength2D())}function Gi(t){return t.m_cachedValues}function Hi(t,e){t.m_cachedValues=e}function ki(t,e,s,i,n){const o=(0,r.m)(r.P,3);t.queryControlPoints(o);const a=[0,0,0];t.queryWeights(a);const h=[0];return 1===Wi(o,a,e,r.E.unit(),i,n,1,h)?h[0]:Number.NaN}function Wi(t,e,s,o,a,h,m,u){(0,i.x)(r.E.unit().contains(o)&&m>0,""),(h<0||Number.isNaN(h))&&(h=Number.MAX_VALUE);const l=new Array(3);for(let e=0;e<3;++e)l[e]=t[e].sub(s);const c=dn(e),g=C.constructPoint2D(l[0]),d=C.constructPoint2D(l[1]),_=C.constructPoint2D(l[2]),p=r.M.constructDouble(c),f=p.clone();f.ldexpThis(1);const x=g.dotProduct(d.sub(g)).mul(p),P=p.mul(p.addDouble(2)),y=_.sub(d.mul(P.ldexp(1))),v=d.sqrLength().mul(p.mul(p).ldexp(1)).add(g.sqrLength().mul(p.ldexp(2).subDouble(1))).add(g.dotProduct(y)),E=_.sub(d.mul(f)).add(g.mul(f.subDouble(1))),b=d.mul(p).sub(g).dotProduct(E).mulDouble(3),D=d.dotProduct(_).mul(p.subDouble(3).mul(p)).ldexp(1),S=d.sqrLength().mul(p.mul(p).ldexp(2)),w=g.sqrLength().mul(p.ldexp(2).subDouble(3)),A=g.dotProduct(_.sub(d.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),T=_.sqrLength().addThis(D).addThis(S).addThis(w).addThis(A),I=g.add(_).sub(d.mul(f)),N=p.subDouble(1),q=_.sub(g).dotProduct(I).mul(N),M=new r.P(0,0),Y=[];let X=new r.P;cn(l,e,o.vmin,X);let F=r.P.distance(X,M);if(F<=h&&Y.push(new r.P(o.vmin,F)),o.vmin!==o.vmax&&(cn(l,e,o.vmax,X),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(o.vmax,F))),o.width()>0){const t=l[2].isZero(),s=(0,r.m)(r.M,4),i=re(q,T,b,v,x,58,o,t,s);for(let t=0;t<i;t++){if(!o.containsExclusiveCoordinate(s[t].toDouble()))continue;let i=s[t].toDouble();i=_n(e,i);const n=new r.P;cn(l,e,i,n),F=r.P.distance(n,M),F<=h&&Y.push(new r.P(i,F))}}if(a){(0,i.g)(o.equals(r.E.unit()));{cn(l,e,-1,X,!0);const t=new r.P;cn(l,e,0,t);const s=new Fr({start:X,end:t}),i=s.getClosestCoordinate(M,!0);i<1&&(X=s.getCoord2D(i),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(i-1,F)))}{cn(l,e,2,X,!0);const t=new r.P;cn(l,e,o.vmax,t);const s=new Fr({start:t,end:X}),i=s.getClosestCoordinate(M,!0);i>0&&(X=s.getCoord2D(i),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(1+i,F)))}}if(!Y.length)return 0;Y.sort((t,e)=>t.compare(e));let R=0;const L=Y[0].x;if(u[R++]=L,R<m){const t=(0,n.J)(l,4,!1).total(),e=Y[0].y;for(let s=1,i=Y.length;s<i;s++)if(Y[s].y>e+t){Y.length=s;break}Y.sort((t,e)=>(0,r.a7)(t.x,e.x)),R=0,u[R++]=Y[0].x;for(let t=1,e=Y.length;t<e;t++)Y[t].x!==u[R-1]&&R<m&&(u[R++]=Y[t].x)}return R}function ji(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),Zi(i,n,e,s)}function Zi(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=(0,r.m)(r.P,3);Ki(t,e,s.vmin,s.vmax,n,[0,0,0]),i.setFromPoints(n,3)}function Ui(t){const e=(0,r.F)(t[0].y,t[1].y),s=(0,r.F)(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=(0,r.F)(t[0].x,t[1].x),s=(0,r.F)(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Oi(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Qi(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Qi(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[2][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function $i(t,e,s,o,a,h,m){(0,i.g)(s>=0&&s<=1&&o!==h&&a!==m),(0,i.g)(e[0]>0&&e[2]>0&&e[1]>=0);const u=[1,dn(e),1],l=pn(e,s),c=(0,r.L)(t,3),g=(0,r.m)(n.f,3);mn(c,u,g);const d=(0,r.m)(n.f,3),_=(0,r.m)(n.f,3);fn(g,l,o?d:null,h?_:null),xn(e,s,a,m);const p=Ui(c);if(o){for(let t=0;t<3;++t)ln(d[t],o[t]);yn(c,o),p&&Qi(o)}if(h){for(let t=0;t<3;++t)ln(_[t],h[t]);yn(c,h),p&&Qi(h)}}function Ki(t,e,s,o,a,h){if((0,i.g)(s>=0&&o<=1&&s<=o),s===o){const i=new r.P,n=un(t,e,s,i);return Pn(t,i),a[0].assign(i),a[1].assign(i),a[2].assign(i),h[0]=n,h[1]=n,void(h[2]=n)}if(0===s&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),h[0]=e[0],h[1]=e[1],void(h[2]=e[2]);const m=(0,r.m)(n.f,3);{const i=[1,dn(e),1],n=pn(e,s),r=pn(e,o);mn(t,i,m),fn(m,r,m,null),fn(m,n>=r?1:n/r,null,m)}const u=[0,0,0];xn(e,o,u,null),xn(u,s/o,null,u);const l=Ui(t),c=(0,r.m)(r.P,3);ln(m[1],c[1]),cn(t,e,s,c[0]),cn(t,e,o,c[2]),yn(t,c);for(let t=0;t<3;++t)a[t].assign(c[t]),h[t]=u[t];l&&Qi(a)}function Ji(t,e,s){const i=dn(e),n=[1,i,1],o=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),(0,r.U)(t[0],t[1],o,s[1]),(0,r.U)(t[2],t[1],o,s[2]),new Ci({cp:s}),new Ut({points:t,weight:i});let a=0,h=.1,m=0;for(let e=0;e<9;e++,h+=.1){const e=new r.P;cn(t,n,h,e);const i=new r.P;Os(s,h,i);const o=r.P.sqrDistance(e,i);o>a&&(a=o,m=h)}{const e=new r.P;cn(t,n,m,e);const i=[0];ui(s,e,r.E.unit(),!1,-1,1,i);const o=new r.P;return Os(s,i[0],o),a=r.P.sqrDistance(e,o),Math.sqrt(a)}}function tn(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==nn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function en(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==rn(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function sn(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==an(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function nn(t,e,s,n,o,a,h,m,u,l){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!=a)for(let t=0;t<i;t++)a.push(0);if(null!=n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=G(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Fr({start:e.getStartXY(),end:e.getEndXY()}),i=ot(t,s,n,o,a,h,m,l);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=(0,r.m)(r.P,3);e.queryControlPoints(g);const d=[0,0,0];e.queryWeights(d);const _=[1,dn(d),1],p=s.getEndXY().sub(s.getStartXY()),f=p.clone();f.leftPerpendicularThis();const x=g[0].clone(),P=g[1].clone(),y=g[2].clone(),v=P.sub(x),C=y.sub(x),E=y.sub(P),b=_[0],D=_[1],S=_[2],w=b*D,A=b*S,T=D*S,I=v.dotProduct(f)*w,N=C.dotProduct(f)*A;let q=I,M=N-2*I,Y=E.dotProduct(f)*T+N-N;const X=(0,r.d)(13,Number.NaN),F=(0,r.d)(13,Number.NaN);let R=Nt(Y,M,q,r.E.unit(),!1,X);R<0&&(X[0]=0,X[1]=1,R=2);let L=0;for(let t=0,e=L;t<R;++t){const i=new r.P;cn(g,_,X[t+e],i),F[L]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(F[L]))<=h&&(X[L]=X[t+e],L++)}const z=(0,r.m)(r.P,3),V=(0,r.m)(r.P,3);if(e.queryControlPoints(V),V[0].subThis(s.getStartXY()),V[1].subThis(s.getStartXY()),V[2].subThis(s.getStartXY()),function(t,e,s,i=!1){const n=(0,r.m)(r.P,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}(V,_,z,!1),Math.abs(p.x)>=Math.abs(p.y)){const t=p.y/p.x;Y=z[2].y-z[2].x*t,M=z[1].y-z[1].x*t,q=z[0].y-z[0].x*t}else{const t=p.x/p.y;Y=z[2].x-z[2].y*t,M=z[1].x-z[1].y*t,q=z[0].x-z[0].y*t}const B=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),k=[0,0];R=Nt(Y,M,q,r.E.unit(),B,k);for(let t=0,e=L;t<R;++t){X[t+e]=k[t];const i=new r.P;cn(g,_,X[t+e],i),F[L]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(F[L]))<=h&&(X[L]=X[t+e],L++)}(0,i.g)(L<X.length+4);for(let t=0;t<L;t++)X[t]=_n(d,X[t]);R=e.intersectPoint(s.getStartXY(),k,h);for(let t=0;t<R;t++)X[L]=k[t],F[L++]=0;R=e.intersectPoint(s.getEndXY(),k,h);for(let t=0;t<R;t++)X[L]=k[t],F[L++]=1;R=s.intersectPoint(e.getStartXY(),k,h);for(let t=0;t<R;t++)F[L]=k[t],X[L++]=0;R=s.intersectPoint(e.getEndXY(),k,h);for(let t=0;t<R;t++)F[L]=k[t],X[L++]=1;return 0===L?0:qr(t,e,s,X,F,L,n,o,a,h,m,0,l)}function rn(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return nn(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,4);{e.queryControlPoints(_);const t=(0,r.m)(r.P,4),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(_,4,t);const o=(0,r.m)(r.M,3),u=(0,r.m)(r.M,3),l=(0,r.m)(r.M,3),c=[0,0,0];e.queryWeights(c),hn(t,c,o,u,l);const p=(0,r.m)(r.M,3);p[0].setDouble(s.getSemiMinorAxis()),p[0].sqrThis(),p[1].setDouble(s.getSemiMajorAxis()),p[1].sqrThis(),p[2].setThis(p[0]),p[2].mulThis(p[1]),p[2].negateThis();const f=ee(o,2,u,2,l,2,p,0,r.E.unit(),r.E.unit(),g,m);if(f>0){let t=0;for(let i=0;i<f;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const i=0===t?s.getStartXY():s.getEndXY(),n=ki(e,i,r.E.unit(),!1,-1),o=new r.P;e.queryCoord2D(n,o),r.P.distance(i,o)<=h&&(g.push(n),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(_[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(_[e[t]],n)<=h&&(g.push(p[t]),d.push(i))}}return qr(t,e,s,g,d,g.length,i,n,o,h,m,0,l)}function on(t,e,s,n,o,a,h,m,u,l){const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);if(s.queryControlPoints(g),k(c,g,3)<0)return on(t,s,e,n,a,o,h,m,u,!l);const d=G(e,s);if(e.isDegenerateToLineHelper(d)){const i=new Fr({start:e.getStartXY(),end:e.getEndXY()}),r=nn(t,s,i,n,a,o,h,m,0,!l);if(o)for(let t=0;t<r;++t){const s=i.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(s,!1)}return r}if(s.isDegenerateToLineHelper(d)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()}),r=nn(t,e,i,n,o,a,h,m,0,l);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,d)))return 0;const _=(0,r.d)(3,Number.NaN);e.queryWeights(_);const f=(0,r.d)(3,Number.NaN);s.queryWeights(f);const x=[1,dn(_),1],P=[1,dn(f),1],y=new r.E(0,1),v=new r.E(0,1);{const t=p.constructEmpty();Zi(c,x,new r.E(0,1),t);const e=p.constructEmpty();Zi(g,P,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(gn(c,x,t,y),gn(g,P,t,v),y.isEmpty()||v.isEmpty())return 0;Ki(c,x,y.vmin,y.vmax,c,x),Ki(g,P,v.vmin,v.vmax,g,P)}}const C=Yr(c,2,g,2,h);if(0===C)return 0;const E=[],b=[];if(-1===C){const t=(0,r.m)(r.M,3),e=(0,r.m)(r.M,3),s=(0,r.m)(r.M,3);hn(c,x,t,e,s);const i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hn(g,P,i,n,o);const a=[],u=[],d=te(t,2,e,2,s,2,i,2,n,2,o,2,0,r.E.unit(),r.E.unit(),a,u,m,0,l);if(d>0)for(let t=0;t<d;t++){const e=new r.P;cn(g,P,u[t],e);const s=new r.P;cn(c,x,a[t],s),r.P.distance(s,e)<=h&&(E.push(a[t]),b.push(u[t]))}}for(let t=0;t<2;t++){let e,s,n;0===t?(e=c,s=g,n=P):(e=g,s=c,n=x);for(let o=0;o<2;o++){const a=0===o?0:e.length-1,m=new r.P,u=[0],l=Wi(s,n,e[a],r.E.unit(),!1,-1,1,u);(0,i.g)(1===l),cn(s,n,u[0],m),r.P.distance(e[a],m)<=h&&(0===t?(E.push(0===a?0:1),b.push(u[0])):(b.push(0===a?0:1),E.push(u[0])))}}if(0===E.length)return 0;if(!y.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ut.recalculateParentT(y.vmin,y.vmax,E[t]);if(!v.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(v.vmin,v.vmax,b[t]);for(let t=0;t<E.length;++t)E[t]=_n(_,E[t]);for(let t=0;t<b.length;++t)b[t]=_n(f,b[t]);return qr(t,e,s,E,b,E.length,n,o,a,h,m,0,l)}function an(t,e,s,i,n,o,a,h,m,u){if(e.isLine())return je(t,s,new Fr({start:e.getStartXY(),end:e.getEndXY()}),i,o,n,a,h,0,!u);if(s.isLine())return nn(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,a,h,0,u);const l=G(e,s);if(H(e,s,a=Math.max(a,l)))return 0;const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);s.queryControlPoints(g);const d=Yr(c,2,g,2,a);if(0===d)return 0;const _=[],p=[];if(-1===d){const t=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=[0,0,0];e.queryWeights(o),hn(c,o,t,i,n);const m=(0,r.m)(C,3);Qe(g,m);const l=te(t,2,i,2,n,2,[m[0].x,m[1].x,m[2].x],2,[m[0].y,m[1].y,m[2].y],2,null,0,0,r.E.unit(),r.E.unit(),_,p,h,0,u);if(l>0){let t=0;for(let i=0;i<l;i++){const n=new r.P;s.queryCoord2D(p[i],n);const o=new r.P;e.queryCoord2D(_[i],o),r.P.distance(o,n)<=a&&(_[t]=_[i],p[t]=p[i],t++)}_.length=t,p.length=t}}for(let t=0;t<2;t++){let i;i=0===t?c:g;for(let n=0;n<2;n++){const o=0===n?0:i.length-1;let h;const m=new r.P;0===t?(h=Fe(s,i[o],r.E.unit(),!1),s.queryCoord2D(h,m)):(h=ki(e,i[o],r.E.unit(),!1,-1),e.queryCoord2D(h,m)),r.P.distance(i[o],m)<=a&&(0===t?(_.push(0===o?0:1),p.push(h)):(p.push(0===o?0:1),_.push(h)))}}return qr(t,e,s,_,p,_.length,i,n,o,a,h,0,u)}function hn(t,e,s,i,n){const o=r.M.constructDouble(e[0]),a=r.M.constructDouble(e[1]),h=r.M.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(o),s[1].setDouble(t[1].x),s[1].mulThis(a),s[2].setDouble(t[2].x),s[2].mulThis(h),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(o),i[1].setDouble(t[1].y),i[1].mulThis(a),i[2].setDouble(t[2].y),i[2].mulThis(h),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function mn(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function un(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],o=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],a=[e[0],e[1],e[2]],h=s;let m,u,l;if(s<=.5){const t=(0,r.X)(n[0],n[1],h),e=(0,r.X)(n[1],n[2],h);m=(0,r.q)(t,e,h);const s=(0,r.X)(o[0],o[1],h),i=(0,r.X)(o[1],o[2],h);u=(0,r.q)(s,i,h);const c=(0,r.X)(a[0],a[1],h),g=(0,r.X)(a[1],a[2],h);l=(0,r.X)(c,g,h)}else{const t=(0,r.Y)(n[0],n[1],h),e=(0,r.Y)(n[1],n[2],h);m=(0,r.Y)(t,e,h);const s=(0,r.Y)(o[0],o[1],h),i=(0,r.Y)(o[1],o[2],h);u=(0,r.Y)(s,i,h);const c=(0,r.Y)(a[0],a[1],h),g=(0,r.Y)(a[1],a[2],h);l=(0,r.Y)(c,g,h)}return m/=l,u/=l,i.setCoords(m,u),Pn(t,i),l}function ln(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function cn(t,e,s,i,n){if(n){if(s<0)return void K(new Fr({start:t[0],end:t[0].add(Li(t,e,0).getUnitVector())}),s,i);if(s>1)return void K(new Fr({start:t[2],end:t[2].add(Li(t,e,1).getUnitVector())}),s-1,i)}un(t,e,s,i)}function gn(t,e,s,i){i.setEmpty();const n=[];n.push(new r.E(0,1));const o=.5*Math.max(s.width(),s.height());for(;n.length;){const a=n.at(-1);n.pop();const h=new p;if(Zi(t,e,a,h),h.isIntersectingW(s)){const t=Math.max(h.width(),h.height());if(s.containsW(h)||t<=o||a.width()<1e-12)i.merge(a);else{const t=a.getCenter();n.push(r.E.construct(a.vmin,t)),n.push(r.E.construct(t,a.vmax))}}}}function dn(t){return t[1]/Math.sqrt(t[0]*t[2])}function _n(t,e){const s=Math.sqrt(t[2]/t[0]);return e/(0,r.q)(s,1,e)}function pn(t,e){const s=Math.sqrt(t[0]/t[2]);return e/(0,r.q)(s,1,e)}function fn(t,e,s,o){(0,i.g)(e>=0&&e<=1),(new n.f).setCoordsPoint3D(t[0]),(new n.f).setCoordsPoint3D(t[1]),(new n.f).setCoordsPoint3D(t[2]);const a=new n.f,h=new n.f,m=new n.f;(0,r._)(3,t[0],t[1],e,a),(0,r._)(3,t[1],t[2],e,h),(0,r._)(3,a,h,e,m);const u=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(a),s[2].assign(m)),o&&(o[0].assign(m),o[1].assign(h),o[2].assign(u))}function xn(t,e,s,n){const o=[t[0],t[1],t[2]];(0,i.g)(e>=0&&e<=1&&s!==n);const a=(0,r.q)(o[0],o[1],e),h=(0,r.q)(o[1],o[2],e),m=(0,r.q)(a,h,e);s&&(s[0]=o[0],s[1]=a,s[2]=m),n&&(n[0]=m,n[1]=h,n[2]=o[2])}function Pn(t,e){const s=r.E.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=(0,r.s)(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=(0,r.s)(e.y,s.vmin,s.vmax)}function yn(t,e){const s=new r.E;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=(0,r.s)(e[0].x,s.vmin,s.vmax),e[1].x=(0,r.s)(e[1].x,s.vmin,s.vmax),e[2].x=(0,r.s)(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=(0,r.s)(e[0].y,s.vmin,s.vmax),e[1].y=(0,r.s)(e[1].y,s.vmin,s.vmax),e[2].y=(0,r.s)(e[2].y,s.vmin,s.vmax)}const vn=r.ag/180,Cn=180/r.ag;function En(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,r.l)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function bn(t){return t*vn}function Dn(t){return t*Cn}function Sn(t){const e=(0,r.a9)();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=(0,r.l)(s,e),s<0&&(s+=e),s)}function wn(t){const e=(0,r.$)();let s=t;return s>-e&&s<=e||(s=Sn(s),s>e&&(s-=(0,r.a9)())),s}function An(t,e){return En(e-t)}var Tn=n.V;class In extends Q{constructor(t){if(void 0===t||(0,r.W)(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new r.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new r.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=r.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=r.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return Kn(this,t,e,1),this}constructLineCircularArc(t,e){return Kn(this,t,e,0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=new r.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(i),h=Math.sin(i);return o.rotateDirect(a,h),o.addThis(s),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new a.T;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new a.T;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return function(t,e,s,n){0===s&&(0,i.a)("construct_enclosing_circle");const o=[0,0,0],a=function(t,e,s){const i=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&l(t,e)}(e,i),function(t,e,s,i){let n=0;const o=[0,0,0];let a=0,h=0;for(let m=0;m<3;++m){let u=!1;for(;h<s;){const s=t.at(e[h]);let l=1;if(3===n?l=r.P.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===n?l=r.P.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===n&&s.equals(t.at(i[0]))&&(l=0),l<=0){if(l<0&&m+1<3){e[a]=(0,r.c)(e[h],e[h]=e[a]);for(let t=0;t<n;t++)if(i[t]===e[h]){o[t]=h;break}a++}h++;continue}u=!0;let c=0;for(let t=0;t<n;t++)o[t]>h&&(i[c]=i[t],o[c]=o[t],c++);n=c,i[n]=e[h],o[n]=h,n++,n<3?h=a:(1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.c)(i[0],i[0]=i[2]),o[2]=(0,r.c)(o[0],o[0]=o[2])),h++)}if(!u)break;if(m+1<3){a=0;let s=!1;for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)o[t]>o[e]&&(o[e]=(0,r.c)(o[t],o[t]=o[e]),i[e]=(0,r.c)(i[t],i[t]=i[e]),s=!0);for(let t=0;t<n;t++)e[o[t]]=(0,r.c)(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===n&&1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.c)(i[0],i[0]=i[2]),o[2]=(0,r.c)(o[0],o[0]=o[2]))}h=n}return n}(t,i,e,s)}(e,s,o);if(1===a)t.constructCircleRadius(0,e[o[0]],n);else if(2===a){const s=r.P.lerp(e[o[0]],e[o[1]],.5),i=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s);t.constructCircleRadius(Math.max(i,a),s,n)}else if(3===a){const s=r.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),i=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s),h=r.P.distance(e[o[2]],s);t.constructCircleRadius(Math.max(i,a,h),s,n)}else(0,i.d)("unexpected")}(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const n=r.P.calculateCircleCenterFromThreePoints(t,e,s);if(!n.isFinite()||!Number.isFinite(r.P.distance(t,n))){const i=r.P.distance(t,e),n=r.P.distance(t,s);this.constructLineCircularArc(t,i>=n?e:s)}return this.constructCircleCenterAndPoint(n,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new r.H(t.x),n=new r.H(e.x),o=new r.H(s.x),a=new r.H(t.y),h=new r.H(e.y),m=new r.H(s.y),u=new r.H(.5),l=n.subE(i),c=h.subE(a),g=o.subE(i),d=m.subE(a),_=l.mulE(d).subThisE(c.mulE(g));if(_.scaleError(10),_.isZero()){if(!l.isZero()||!c.isZero())return Kn(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const p=l.sqr().addThisE(c.sqr()).mulThisE(u),f=g.sqr().addThisE(d.sqr()).mulThisE(u),x=p.mulE(d).subThisE(f.mulE(c)),P=l.mulE(f).subThisE(g.mulE(p));x.divThisE(_),P.divThisE(_);const y=x.sqr().addThisE(P.sqr());y.sqrtThis();const v=x.addE(i),C=P.addE(a);let E=t.x-v.value(),b=t.y-C.value();const D=Math.atan2(b,E);E=e.x-v.value(),b=e.y-C.value();const S=Math.atan2(b,E);E=s.x-v.value(),b=s.y-C.value();const w=Math.atan2(b,E);let A=w-2*(0,r.$)();for(;A<D;)A+=2*(0,r.$)();let T=S-2*(0,r.$)();for(;T<A;)T+=2*(0,r.$)();let I=w+2*(0,r.$)();for(;I>D;)I-=2*(0,r.$)();let N,q=S+2*(0,r.$)();for(;q>I;)q-=2*(0,r.$)();N=T-D<D-q?T-D:q-D;const M=new r.P(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(N)>(0,r.$)(),N>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return $n(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return $n(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,o){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const a=wn(o),h=Math.cos(a),m=Math.sin(a),u=new r.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),l=r.P.getNAN(),c=wn(i);l.x=u.x*Math.cos(c),l.y=u.y*Math.sin(c),l.rotateDirect(h,m),l.addThis(s);const g=(0,r.a8)(n,(0,r.a9)());let d=g;Math.abs(d)===(0,r.a9)()&&(d=0);const _=r.P.getNAN();return _.x=u.x*Math.cos(c+d),_.y=u.y*Math.sin(c+d),_.rotateDirect(h,m),_.addThis(s),this.constructEllipticArcEndPointsCenter(l,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,r.$)(),g>0,s)}constructEllipticArcAsNURB(t,e,s,n){return(n>=1||n<0)&&(0,i.a)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,i.a)("construct_elliptic_arc_as_NURB: control_point"),dr([t,e,s],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,xr(this),this.afterCompletedModification(),t!==this&&V(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){if(this.isLine())return!0;if(this.isMajor())return!1;const e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Jn(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return r.P.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!ar(this)}isMajor(){return mr(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Tn.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?Cr(this,r.E.unit(),t):(0,i.t)("3d not impl")}applyTransformation(t){sr(this,t,!1,null,null)}createInstance(){return new In}calculateLength2D(){return function(t){if(Jn(t))return 1*r.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;const e=tr(t,0);return tr(t,1)-e}(this)}queryControlPointsHelper(t){(0,i.d)("")}queryCoord2D(t,e){if(Jn(this))J(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(r.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(r.P.construct(this.m_XEnd,this.m_YEnd));else{const s=jn(this,t),i=new r.P(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){!function(t,e,s){if(Jn(t))st(new Fr({start:t.getStartXY(),end:t.getEndXY()}),e,s);else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new r.H;Zn(t,e,i);const n=new r.H,o=new r.H;r.H.st_cosAndSin(i,n,o);const a=y.constructCoordsE(new r.H(t.m_semiMajorAxis).mulThisE(n),new r.H(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),h=new r.H(t.m_rotation);r.H.st_cosAndSin(h,n,o),a.rotateDirect(n,o),a.addThisE(y.constructPoint2D(t.m_center)),s.setE(a)}}(this,t,e)}queryCoord2DMP(t,e){(0,i.t)("")}getCoordX(t){const e=new r.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();i&&n.dropAllAttributes();let o=0===t&&1===e;if(o&&!i)return void this.copyTo(n);const a=r.P.getNAN();this.queryCoord2D(t,a);const h=r.P.getNAN();if(this.queryCoord2D(e,h),!o)if(a.equals(h))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&h.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,N(n,a.x,a.y),M(n,h.x,h.y),o)return void nr(n,Un(this));n.m_startAngle=jn(this,t),n.m_sweepAngle=jn(this,e)-n.m_startAngle,n.m_startAngle=Bn(n.m_startAngle),hr(n,Math.abs(n.m_sweepAngle)>(0,r.$)()),i&&n.assignVertexDescription(this.m_description),xr(n),kn(n);const m=this.m_description.getAttributeCount();if(m>1&&!i){for(let e=1;e<m;e++){const s=this.m_description.getSemantics(e),i=Tn.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<m;t++){const s=this.m_description.getSemantics(t),i=Tn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){!function(t,e,s){if(Jn(t))s.setE(y.constructPoint2D(t.getEndXY()).subE(y.constructPoint2D(t.getStartXY())));else{const i=new r.H;Zn(t,e,i);const n=new y;if(n.setCoordsE(new r.H(t.m_semiMajorAxis).negate().mulE((new r.H).setSin(i)),new r.H(t.getSemiMinorAxis()).mulE((new r.H).setCos(i))),t.m_rotation){const e=new r.H(t.m_rotation);n.rotateDirect((new r.H).setCos(e),(new r.H).setSin(e))}n.scaleThis(new r.H(t.getSweepAngle())),s.setE(n)}}(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new r.P;this.queryCoord2D(t,n);const o=new r.P;this.queryCoord2D(e,o),i||(n.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,N(s,n.x,n.y),M(s,o.x,o.y),i?nr(s,Un(this)):(s.m_startAngle=jn(this,t),s.m_sweepAngle=jn(this,e)-s.m_startAngle,s.m_startAngle=Bn(s.m_startAngle),hr(s,Math.abs(s.m_sweepAngle)>Math.PI),xr(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Qn(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Tn.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Tn.getDefaultValue(e))}getClosestCoordinate(t,e){return Er(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Er(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,i.a)("");const s=this.getSemiAxes(),n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),o=n+(0,r.$)(),a=(0,r.d)(3,Number.NaN);let h=0;if(a[0]=Wn(this,n),a[0]>0&&a[0]<1&&h++,a[1]=Wn(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,(0,i.g)(t.length>=h);let m=0;for(let s=0;s<h;s++){const i=a[s];this.queryCut(m,i,t[s],e),m=i}return h}getMonotonicParts(t,e){if(t.length<4&&(0,i.a)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;const s=this.getSemiAxes(),n=(0,r.d)(4,Number.NaN);n[0]=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),n[1]=n[0]+(0,r.$)(),n[2]=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),n[3]=n[2]+(0,r.$)();const o=(0,r.d)(5,Number.NaN);let a=0;for(let t=0;t<4;t++)o[a]=Wn(this,n[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,r.Z)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,i.g)(t.length>=a);let h=0;for(let s=0;s<a;s++){const i=o[s];this.queryCut(h,i,t[s],e),h=i}return a}intersectionWithAxis2D(t,e,s,i){if(Jn(this))return new Fr({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i);let n,o;const a=new r.H(e),h=this.getSemiAxes();if(t){if(e>this.m_center.y+h.x||e<this.m_center.y-h.x)return 0;n=new r.H(h.x).mulThis(this.m_sinr),o=new r.H(h.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+h.x||e<this.m_center.x-h.x)return 0;n=new r.H(h.x).mulThis(this.m_cosr),o=new r.H(h.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}const m=n.sqr(),u=o.sqr(),l=m.addE(u),c=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(m),d=c.sqr().subThisE(l.mulE(g).mulThis(4)),_=n.mulE(a).mulThis(-2),p=a.sqr().subThisE(u),f=_.sqr().subThisE(l.mulE(p).mulThis(4));let x=d.eps()*Math.abs(f.value())<=f.eps()*Math.abs(d.value());x?n.isZero()&&(x=!1):o.isZero()&&(x=!0),x||(c.setE(_),g.setE(p));const P=(0,r.m)(r.H,2);let y=Lt(l,c,g,r.E.construct(-1,1),!1,P);if(0===y)return 0;const v=[0,0];let C=0;for(let t=0;t<y;t++){const e=new r.H,s=new r.H;x?(e.setE(P[t]),s.setE(a.subE(o.mulE(P[t])).divThisE(n))):(s.setE(P[t]),e.setE(a.subE(n.mulE(P[t])).divThisE(o)));const i=Wn(this,Math.atan2(e.value(),s.value()));i>=0&&i<=1&&(v[C]=i,C++)}return y=C,0===y?0:(2===y&&v[0]>v[1]&&(v[1]=(0,r.c)(v[0],v[0]=v[1])),i&&(0,r.b)(i,v,0,0,y),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),y>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=(0,r.c)(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new r.E(0,1),t):(0,i.t)("3d not impl")}clone(t){const e=new In;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Jn(this))return 0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=Wn(this,t),n[1]=Wn(this,i);const o=0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY()),a=new r.P;for(let t=0;t<2;t++){const s=n[t];s>0&&s<1&&(this.queryCoord2D(s,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new r.E(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Jn(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),n=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=r.o){let t=r.P.lerp(i,n,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*r.P.distance(i,n))),e.setCoords(i),e.mergeNe(n),void e.mergeNe(t)}Cr(this,s,e)}tToLength(t){return Jn(this)?t*r.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:tr(this,t)}parametricAngleToT(t){return Wn(this,t)}tToParametricAngle(t){return jn(this,t)}lengthToT(t){if(Jn(this)){const e=r.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(Jn(t)){const s=r.P.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=On(t),n=(0,r.T)(),o=er(t);s<0&&(e=-e);const a=e/t.m_semiMajorAxis+o;let h=(0,r.ab)(a,i.e2,i.completeE);return h-=n,h-=t.getStartAngle(),h/s}(this,t)}calculateWeightedAreaCentroid2D(t){if(Jn(this)){const t=new r.P;return t.setCoords(0,0),t}const e=fr(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),n=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,h=new r.P;h.x=n*o*(n*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,h.y=n*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+n*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const m=i.add(s).mul(i.crossProduct(s)/6);return h.x-=m.x,h.y-=m.y,h.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new r.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Jn(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),n=Math.sin(s),o=Math.cos(e),a=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,r=s*(n-i),h=s*(o-a);t.setCoords(r,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),r=e*e,h=s*s,m=e*s,u=r-h,l=u/h,c=u/r,g=Math.sqrt(l),d=Math.sqrt(c),_=.5*m*(Math.asinh(g*n)/g+n*Math.sqrt(1+l*n*n))-.5*m*(Math.asinh(g*i)/g+i*Math.sqrt(1+l*i*i)),p=-.5*m*(Math.asin(d*a)/d+a*Math.sqrt(1-c*a*a))- -.5*m*(Math.asin(d*o)/d+o*Math.sqrt(1-c*o*o));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Jn(this)){const s=r.P.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),n=new r.P;return this.queryCoord2D(i,n),r.P.distance(n,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getTangent(t){if(Jn(this))return this.getEndXY().sub(this.getStartXY());{const e=jn(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Jn(this))return this.getEndXY().sub(this.getStartXY());{const e=jn(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!ur(this)&&(Jn(this)?(lr(this),!1):cr(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new r.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new r.P(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=jn(this,t),s=new r.P,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const n=new r.P;n.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),n.rotateDirect(this.m_cosr,this.m_sinr));const o=s.sqrLength();if(0===o)return Number.NaN;const a=Math.sqrt(o);return s.divThis(a),s.crossProduct(n)/o}getMonotonicPartParams(t,e){const s=(0,r.d)(6,Number.NaN);s[0]=0;let n=1;if(this.isDegenerateToLine())s[1]=1,n=2;else{const t=this.getSemiAxes(),e=(0,r.d)(4,Number.NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=(0,r.a0)());for(let t=0;t<4;t++){const i=Wn(this,e[t]);i>0&&i<1&&(s[n]=i,n++)}n>2&&(0,r.Z)(s,n),s[n]=1,n++}if(e){t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s[t]}return n}calculateLowerLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Jn(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,rr(t)}calculateArea2DHelper(){return fr(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Jn(this))return;const s=this.getSemiAxes(),i=(0,r.d)(8,Number.NaN);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=Wn(this,t),i[1]=Wn(this,e),i[2]=Wn(this,n),i[3]=Wn(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=Wn(this,n),i[5]=Wn(this,r),i[6]=Wn(this,o),i[7]=Wn(this,a)}const n=r.P.getNAN();for(let s=0;s<8;s++){const r=i[s];t.containsExclusiveCoordinate(r)&&(this.queryCoord2D(r,n),e.mergeNe(n))}}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void Kn(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new r.P;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),h=t.getCenter(),m=new Array(4);m[0]=t.isMajor(),m[1]=!m[0],m[2]=m[0],m[3]=!m[0];const u=new Array(4);u[0]=t.isClockwise(),u[1]=u[0],u[2]=!u[0],u[3]=!u[0];const l=Math.trunc(s<5?1:(s+4)/5),c=(0,r.m)(In,4),g=(0,r.d)(4,Number.NaN);let d=0;for(let t=0;t<4;t++){c[t].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,o,a,m[t],u[t],h),g[t]=0;let i=0;for(let n=l;n<s-1;n+=l){const s=c[t].getClosestCoordinate(e[n],!1);g[t]+=r.P.sqrDistance(c[t].getCoord2D(s),e[n]),i++}g[t]/=i,g[t]<g[d]&&(d=t)}t.assignCopy(c[d])}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,i.d)("should not1; be called"),0}ensureXYMonotone(){if(Jn(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Kn(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=(0,r.m)(r.P,3);let e=gr(this,t);if(Qi(t)){let s=!1;if(0===this.projectionBehavior()){const i=new o.Envelope2D;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const n=new r.P;n.setSub(t[2],t[0]),n.leftPerpendicularThis(),n.normalize(),n.scale(r.P.distance(t[2],t[0]));const a=r.P.lerp(t[2],t[0],.5),h=a.sub(n),m=a.add(n);i.clipLine(h,m);const u=r.P.getClosestCoordinate(h,m,t[1],!1);t[1]=r.P.lerp(h,m,u);const l=t[2].sub(t[1]),c=t[0].sub(t[1]),g=l.crossProduct(c),d=l.dotProduct(c);e=(0,r.T)()-Math.abs(.5*Math.atan2(g,d)),s=!0}return dr(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Qn(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,nr(e,Un(this))}reverseImpl(){or(this,!ar(this)),kn(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&xr(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(bn(En(Dn(this.m_rotation-s.m_rotation)))),n=Math.abs((0,r.$)()-i),o=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;const a=this.getCoord2D(.5),h=s.getCoord2D(.5);return!!a.isEqualPoint2D(h,e)}swapImpl(t){const e=t;this.m_center=(0,r.c)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,r.c)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,r.c)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,r.c)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,r.c)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,r.c)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,r.c)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,r.c)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,r.c)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,r.c)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){lr(this),rr(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&(0,i.r)(""),Jn(this))return new Fr({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s);{const e=r.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),o=r.P.getNAN();return this.queryCoord2D(n,o),r.P.distance(o,t)<=s?(0,r.N)(n,0,1)&&(this.queryCoord2D(0===n?1:0,o),r.P.distance(o,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,rr(this)}clearEndPointModified(){lr(this)}}function Nn(t,e,s,i,n,o){return new Yn(0,0,0,null,!1,(0,r.i)()).densifyEx(t,e,s,i,!1,o)}function qn(t,e,s,n,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const u=t.getGeometryType();if(u===i.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(u===i.G.enumBezier){if(!n)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;const e=(0,r.d)(9,Number.NaN);let i=t.getMonotonicPartParams(e.length,e);if(e.length=i,i=Xn(t,s,e),2===i&&o&&(e[1]=.5,e.push(1),i=3),h&&h.splice(0,0,...e.slice(0,i)),a){const s=new Rr;for(let n=1;n<i;n++){const i=e[n-1],r=e[n];t.queryCut(i,r,s,!0);const o=s.get();ks(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return i-1}if(u===i.G.enumEllipticArc){const m=t;if(m.isDegenerateToLine()||m.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(n&&(o||!m.isMonotoneQuickAndDirty())){const u=(0,r.d)(6,Number.NaN);let l=m.getMonotonicPartParams(u.length,u);u.length=l,l=Xn(t,s,u),2===l&&o&&(u[1]=.5,u.push(1),l=3);let c=0;if(l>2){const t=new Rr,r=h||[];let o=0;for(let g=1;g<l;g++){const d=u[o],_=u[g];if(m.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=r.length,f=Fn(1===g,t.get(),e,s,n,a,h);(0,i.g)(f>0),c+=f;const x=g===l-1,P=u[o],y=t.get().getSweepAngle()/m.getSweepAngle();for(let t=p,e=r.length;t<e;t++)if(r[t]=!x||t+1<e?P+r[t]*y:1,a){const e=3*t,s=m.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Ws(a.slice(e-3))}o=g}return c}}return Fn(!0,m,e,s,n,a,h)}if(u===i.G.enumRationalBezier2){const i=t;if(n&&(o||!i.isMonotoneQuickAndDirty())){const n=(0,r.d)(6,Number.NaN);let m=i.getMonotonicPartParams(n.length,n);n.length=m,m=Xn(t,s,n),2===m&&o&&(n[1]=.5,n.push(1),m=3);let u=0;if(m>2){const t=new Rr,r=h||[];for(let o=1;o<m;o++){const l=n[o-1],c=n[o];i.queryCut(l,c,t,!0);const g=r.length;u+=Rn(1===o,t.get(),e,s,!1,a,h);const d=o===m-1,_=n[o-1];for(let t=g,e=r.length;t<e;t++)if(r[t]=!d||t+1<e?_+r[t]:1,a){const e=3*t,s=i.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Be(a.slice(e-3))}}return u}}return Rn(!0,i,e,s,n,a,h)}if(u===i.G.enumBezier2){const i=t,m=(0,r.m)(r.P,3);i.queryControlPoints(m);const u=new Ci;u.constructFromQuadratic(m);const l=qn(u,e,s,n,o,a,h);if(null!=a&&null!=h){const t=3;for(let e=1,s=0;e<l;++e,s+=t){const o=new r.P;i.queryCoord2D(h[e],o);const m=a[s+t];!o.equals(m)&&(a[s+t].setCoordsPoint2D(o),n)&&Ws(a.slice(s,s+4))}}return l}(0,i.t)("")}function Mn(t,e,s,n,o,a,h,m,u){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),l===i.G.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=(0,r.d)(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Xn(t,s,c);else{if(g=2,c[0]=0,c[1]=1,l===In.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else(0,i.g)(l===Ut.type);c.length=g}if(2===g&&n&&(c[1]=.5,c.push(1),g=3),a){const e=new Rr;let s=1;for(;s<g;){const n=c[s-1],m=c[s];t.queryCut(n,m,e,!0);const u=(0,r.m)(r.P,3),d=[1,1,1];if(l===i.G.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(m-n)/3;c.splice(s,0,n+t),c.splice(s+1,0,n+2*t),g+=2;continue}d[1]=gr(t,u)}else{const t=e.get();t.queryControlPoints(u),t.queryWeights(d)}o&&Qi(u),1===s&&(a.push(u[0].clone()),h.push(d[0])),a.push(u[1].clone()),a.push(u[2].clone()),h.push(d[1]),h.push(d[2]),s++}}return m&&(m.length=g,(0,r.b)(m,c,0,0,g)),g-1}In.type=i.G.enumEllipticArc;class Yn{static constructDefault(t){return new Yn(0,0,0,t,!1,(0,r.i)())}constructor(t,e,s,o,a,h){this.m_segmentBuffer=null,this.m_dummyPoint=new n.P,this.m_progressCounter=0,this.m_progressTracker=o,this.m_bSetDensifyFlag=a,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>(0,r.T)()?(0,r.T)():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=h,(0,i.x)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,n,o,a){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=n>(0,r.T)()?(0,r.T)():n,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,i.x)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return(0,i.j)(e)?t:(0,i.h)(e)?this.densifyMultiPath(t):(0,i.f)(e)?this.densifySegmentImpl(t):e===i.G.enumEnvelope?this.densifyEnvelope(t):void(0,i.d)("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.G.enumLine)&&(!n||s))return void(e?o===i.G.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.G.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.G.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Dt({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){const e=new rs({vd:t.getDescription()});e.addEnvelope(t,!1);const s=o.Envelope2D.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=e.getImpl(),n=t.getImpl(),o=n.getAttributeStreamRef(0),a=new Fr;for(let t=0,i=n.getPathCount();t<i;t++){const i=n.isClosedPath(t);if(0===n.getPathSize(t))continue;const h=n.getPathStart(t),m=o.readPoint2D(2*h),u=m.clone();s.startPath(m);for(let i=h+1,m=n.getPathEnd(t);i<m;i++){const t=o.readPoint2D(2*i),n=r.P.distance(u,t);if(n>this.m_maxLength){let e=Math.ceil(n/this.m_maxLength);e>(0,r.i)()&&(e=(0,r.i)());const i=1/e;let o,h,m;u.compare(t)<0?(a.setStartXY(u),a.setEndXY(t),o=0,h=1):(a.setStartXY(t),a.setEndXY(u),o=e-2,h=-1);for(let t=0,n=e-1;t<n;t++,o+=h){this.progress_(),m=i*(o+1);const t=new r.P;a.queryCoord2D(m,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),u.assign(t)}if(i){const t=r.P.distance(u,m);if(t>this.m_maxLength){const e=m;let i=Math.ceil(t/this.m_maxLength);i>(0,r.i)()&&(i=(0,r.i)());const n=1/i;let o,h;u.compare(e)<0?(a.setStartXY(u),a.setEndXY(e),o=0,h=1):(a.setStartXY(e),a.setEndXY(u),o=i-2,h=-1);const l=new r.P(0,0);let c;for(let t=0,e=i-1;t<e;t++,o+=h)this.progress_(),c=n*(o+1),a.queryCoord2D(c,l),s.lineTo(l),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,s,n,o,a){(0,i.g)(t.getGeometryType()!==i.G.enumBezier);let h=t.getStartXY().compare(t.getEndXY());0===h&&e<1&&(t.getGeometryType()===i.G.enumEllipticArc?h=t.getSweepAngle()<0?1:-1:(0,i.t)("densify segment by length"));let m=0;if(n&&(s?(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)):a.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new Rr);let i=Math.ceil(1/e);i>(0,r.i)()&&(i=(0,r.i)()),e=1/i,this.m_segmentBuffer.create(t.getGeometryType());let n,o,u,l=t;h<0?(n=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),n=i-2,o=-1,l=this.m_segmentBuffer.get());const c=i-1;for(let t=0;t<c;t++,n+=o)u=e*(n+1),s?(l.queryCoord(u,this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==u&&0!==u&&s.setAttribute(10,s.getPointCount()-1,0,1)):a.push(h>0?1-u:u),this.progress_();u=1,m+=c}(!o||o&&n&&m<2)&&(s?(t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,s,i,n){const o=new Ci;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());if(0===m&&h>0){const e=(0,r.m)(r.P,4);t.queryControlPoints(e),m=e[1].compare(e[2]),0===m&&(m=e[1].compare(e[0]))}m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=[],c=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let d=!0,_=0;if(m>0)for(l.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);l.length;){this.progress_();const t=l.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.mul(1-s).add(u.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[3];t[1]=i,t[2]=g,t[3]=f,t[4].setCoords(h,e);const P=[f,p,u,x,new r.P(e,m)];l.push(P),c[c.length-1]=o+1,c.push(o+1);continue}l.pop(),c.pop(),(l.length>0||!i||i&&s&&u<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(1-h),++u)}else for(l.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);l.length;){this.progress_();const t=l.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.mul(1-s).add(u.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[0];t[0]=f,t[1]=p,t[2]=u,t[4].setCoords(e,m);const P=[x,i,g,f,new r.P(h,e)];l.push(P),c[c.length-1]=o+1,c.push(o+1);continue}l.pop(),c.pop(),(l.length>0||!i||i&&s&&u<2)&&(e?(a.queryCoord(m,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m),++u)}}densifyRationalBezier2(t,e,s,i,n){const o=new Ut;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new Ut,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.rationalBezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}densifyBezier2(t,e,s,i,n){const o=new Qt;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),c=new Qt,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.bezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}densifyEllipticArc(t,e,s,i,n){const o=new In;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=t.isClockwise()?0:1),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new In,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.ellipticArcNeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}calculateLengthSubdivisionStep(t,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.G.enumEllipticArc){const i=t;if(i.isCircular()||i.isDegenerate(0)||i.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*i.getSemiAxes().y/i.getSemiAxes().x}t.getGeometryType()===i.G.enumBezier&&(0,i.t)(""),(0,i.t)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const i=s.getSemiMajorAxis(),n=1-e/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(e/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(t,o)}}(0,i.t)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}(0,i.t)("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);e.queryControlPoints(o);const a=[0,0,0];return e.queryWeights(a),!n&&this.m_maxDeviation>0&&(n=!Yn.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),n}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);return e.queryControlPoints(o),!n&&this.m_maxDeviation>0&&(n=!Yn.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),n}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(n=!0,!0):(!n&&this.m_maxDeviation>0&&(n=!Yn.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&r.P.distance(t[0],t[1])+r.P.distance(t[1],t[2])+r.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!Yn.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Yn.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1])),o=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(n),Math.abs(o))<=e){const e=new r.P;Os(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),n=[0,0];if(1===function(t,e,s){(0,i.g)(!Jn(t));const n=new a.T;n.setRotateAngle(-t.getAxisXRotation());const o=new r.P;n.queryTransform(e,o);const h=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),m=h+(0,r.$)();let u=Wn(t,h),l=Wn(t,m);l<u&&(l=(0,r.c)(u,u=l));let c=0;return u>=0&&u<=1&&(s[c++]=u),l>=0&&l<=1&&(s[c++]=l),c}(t,s,n)){const s=t.getCoord2D(n[0]),i=r.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),o=new r.P;return(0,r.U)(t.getStartXY(),t.getEndXY(),i,o),r.P.distance(s,o)<=e}}const s=t.getCoord2D(.5),n=new r.P;return(0,r.U)(t.getEndXY(),t.getStartXY(),.5,n),r.P.distance(s,n)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0||s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==i.G.enumEllipticArc||t.isCircular())}}function Xn(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const o=(0,r.d)(i-1,Number.NaN);for(let e=1,r=i;e<r;e++){const i=t.tToLength(s[e]);o[e-1]=i-n,n=i}for(;o.length>1;){const t=o.findIndex(t=>t<=2*e);if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===o.length||o[e]>o[n])&&(n=e,i--)}o[n]+=o[t],o.splice(t,1),s.splice(i,1)}return s.length}function Fn(t,e,s,i,n,h,m,u){const l=e.clone();l.dropAllAttributes();const c=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(r.P.getNAN()),e.push(r.P.getNAN()),e.push(i.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(l.isDegenerateToLine()||l.isDegenerate(0))return c(t,h,m,e);const g=l.getStartXY(),d=l.getEndXY(),_=l.getSemiAxes(),p=new a.T;if(l.isCircular())p.setIdentity();else{const t=l.getAxisXRotation();p.setScaleCoords(1,l.getMinorMajorRatio()),p.rotateAngle(t)}const f=l.getCenter();p.shift(f);const x=p.clone();x.invertThis(),l.applyTransformation(x);const P=l.getSweepAngle();if(0===P)return c(t,h,m,e);const y=o.Envelope2D.constructEmpty();y.setCoords({center:f,width:2*_.x,height:2*_.x});const v=.05*y.calculateToleranceFromEnvelope(),C=Math.max(s/_.x,v/_.x);let E=4*Math.pow(C/.0741,1/6);E=Math.min(E,Math.PI/2);const b=Sn(l.getStartAngle());let D=P>0?Math.floor(b/E):Math.ceil(b/E);D*=E;const S=P>0?E:-E;D+S===b&&(D+=S);let w=4/3*Math.tan(Math.abs(E)/4);P>0&&(w=-w),m&&t&&m.push(0);const A=E/Math.abs(P);let T=(D-b)/P;const I=g.clone(),N=new r.P;l.queryCoord2D(0,N);const q=N.clone(),M=1-.01*A;let Y=0,X=0;for(;T<1;){let s;if(T+=A,X>0&&T<M)s=w;else{T>=M&&(T=1);const t=(T-X)*P;s=4/3*Math.tan(Math.abs(t)/4),P>0&&(s=-s)}l.queryCoord2D(T,N);const o=new r.P;p.queryTransform(N,o);const a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==T&&(r.P.distance(I,o)<=2*i||r.P.distance(o,d)<=2*i))continue;I.setCoordsPoint2D(o);const u=(0,r.m)(r.P,4);u[0].assign(q),u[3].assign(N),u[1].rightPerpendicularOther(q),u[1].scaleAddThis(s,q),u[2].leftPerpendicularOther(N),u[2].scaleAddThis(s,N),p.transformPoints2D(u,3,u),u[3].assign(o),0===X&&u[0].setCoordsPoint2D(g),1===T&&u[3].setCoordsPoint2D(d),n&&Ws(u);let c=!0;for(let t=1;t<4;t++)if(!u[t].isEqualPoint2D(u[0])){c=!1;break}c||(m&&m.push(a),h&&(0===X&&t&&h.push(u[0].clone()),h.push(u[1].clone()),h.push(u[2].clone()),h.push(u[3].clone())),Y++),X=T,q.setCoordsPoint2D(N)}return Y}function Rn(t,e,s,i,n,a,h,m){e.clone().dropAllAttributes();const u=new o.Envelope2D;e.queryLooseEnvelope(u);const l=.05*u.calculateToleranceFromEnvelope(),c=Math.max(s,l);h&&t&&h.push(0);let g=0;const d=(0,r.m)(r.P,3);e.queryControlPoints(d);const _=[0,0,0];e.queryWeights(_);const p=[],f=(0,r.d)(9,Number.NaN);let x=0;n?(x=e.getMonotonicPartParams(f.length,f),f.length=x,x=Xn(e,i,f)):(f.length=2,x=2,f[0]=0,f[1]=1);let P=0,y=t;for(let t=1;t<x;t++){const e=f[t];for(p.length=0,p.push(e),p.push(P);p.length>1;){const t=p.at(-1);p.pop();const e=p.at(-1),s=(0,r.m)(r.P,3),i=[0,0,0];Ki(d,_,t,e,s,i);const n=(0,r.m)(r.P,4),o=Ji(s,i,n),m=16,u=p.length>m;c>=o||u?(h.push(e),a&&(y&&(a.push(n[0]),y=!1),a.push(n[1]),a.push(n[2]),a.push(n[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class Ln{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?r.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function zn(t,e){return t.convertToCanonic(e)}function Vn(t,e,s,i){let n=t.m_startAngle,o=t.m_sweepAngle;const a=1e-12;for(;n>(0,r.$)();)n-=2*(0,r.$)();for(;n<=-(0,r.$)();)n+=2*(0,r.$)();if(!Number.isNaN(e)){for(;e>(0,r.$)();)e-=2*(0,r.$)();for(;e<=-(0,r.$)();)e+=2*(0,r.$)();!s&&e>n&&(e-=2*(0,r.$)()),s&&e<n&&(e+=2*(0,r.$)()),o=e-n,Math.abs(o)<a&&!i&&(o=s?2*(0,r.$)():-2*(0,r.$)()),Math.abs(o)>2*(0,r.$)()-a&&i&&(o=0)}Math.abs(o)>2*(0,r.$)()-a&&(o=o>=0?2*(0,r.$)():-2*(0,r.$)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),i=Math.abs(o)<=(0,r.$)(),o&&(s=o>0),t.m_startAngle=Bn(n),t.m_sweepAngle=o,hr(t,!i),or(t,s)}function Bn(t){let e=t,s=!1;return e<=-(0,r.$)()?(e+=(0,r.a9)(),s=!0):e>(0,r.$)()&&(e-=(0,r.a9)(),s=!0),e<=-(0,r.$)()?(e=(0,r.l)(e,(0,r.a9)()),e<=-(0,r.$)()&&(e+=(0,r.a9)()),s=!0):e>(0,r.$)()&&(e=(0,r.l)(e,(0,r.a9)()),e>(0,r.$)()&&(e-=(0,r.a9)()),s=!0),s&&(e>(0,r.$)()||e<=-(0,r.$)())&&(e=(0,r.$)()),e}function Gn(t,e,s){const i=s,n=i.getSemiAxes();let o=new r.P(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return o=i.convertFromCanonic(o),r.P.sqrDistance(o,i.getStartXY())}function Hn(t,e,s){const i=s,n=i.getSemiAxes(),o=t[0]+i.getStartAngle();let a=new r.P(n.x*Math.cos(o),n.y*Math.sin(o));return a=i.convertFromCanonic(a),r.P.sqrDistance(a,i.getEndXY())}function kn(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=mr(t),o=ar(t),a=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Bn(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?o?(0,r.a9)():-(0,r.a9)():0}else{const i=t.convertToCanonic(e),h=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=h.x,i.y/=h.y;const m=t.convertToCanonic(s);m.x/=h.x,m.y/=h.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=r.P.calculateAngle(i,m),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,r.a9)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,r.a9)()),t.m_startAngle=Bn(t.m_startAngle);let u=Gn([t.m_startAngle],0,t);if(u=Math.sqrt(u),u>.25*B(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Mt(Gn,t,1,[t.m_startAngle],[e],[s],0,i),t.m_startAngle=Bn(i[0])}if(u=Hn([t.m_sweepAngle],0,t),u=Math.sqrt(u),u>.25*B(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Mt(Hn,t,1,[t.m_sweepAngle],[e],[s],0,i),t.m_sweepAngle=i[0]}const l=Math.abs(t.m_sweepAngle)>(0,r.$)();if(hr(t,l),n!==l&&!n&&Math.abs(t.m_sweepAngle)>1.5*(0,r.$)())return void Kn(t,e,s,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void Kn(t,e,s,a)}}function Wn(t,e){return(function(t,e){const s=new r.E(t.getStartAngle(),t.getEndAngle());s.normalize();const i=(0,r.a9)(),n=(0,r.l)(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}(t,e)-t.getStartAngle())/t.getSweepAngle()}function jn(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Zn(t,e,s){s.assign(new r.H(t.m_startAngle).addE(e.mulE(new r.H(t.m_sweepAngle))))}function Un(t){return t.m_cachedValues}function On(t){if(t.m_cachedValues)return t.m_cachedValues;const e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,r.a)(t.m_minorMajorRatio)}(t),e.completeE=(0,r.af)(e.e2),t.m_cachedValues=e,e}function Qn(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Jn(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,xr(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*(0,r.T)()){const i=(0,r.m)(r.P,3),n=gr(t,i);if(Ui(i)){if(i[0].assign(e),i[2].assign(s),Qi(i),0===t.projectionBehavior()){let e=0,s=2;r.P.sqrDistance(i[1],i[0])<r.P.sqrDistance(i[1],i[2])&&(s=(0,r.c)(e,e=s));const n=i[s].sub(i[e]),o=n.length();n.divThis(o);const a=i[1].sub(i[e]),h=a.length(),m=a.dotProduct(n)/h,u=a.crossProduct(n)/h,l=new r.P;(0,r.U)(i[e],i[s],.5,l);const c=.5*o/u*(0,r.s)(1-m,0,1),g=i[1].side(i[e],i[s]),d=n.clone();g?d.leftPerpendicularThis():d.rightPerpendicularThis();const _=l.sub(d.mul(c));t.constructCircularArcThreePoint(i[0],i[2],_)}else dr(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?function(t,e,s){const i=t.getStartXY(),n=t.getEndXY(),o=i.equals(n),h=e.equals(s);if(!o&&!h){const o=new a.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);const h=r.P.distance(e,s),m=r.P.distance(i,n),u=h/m;o.scale(u,u);const l=n.sub(i);l.divThis(m);const c=s.sub(e);c.divThis(h);const g=l.crossProduct(c),d=c.dotProduct(l);return o.rotate(d,g),o.shiftCoords(e.x,e.y),void sr(t,o,!0,e,s)}const m=new r.P;if(t.queryCoord2D(.5,m),h){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=m.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const u=e.add(s).mul(.5),l=s.sub(e);l.rightPerpendicularThis();const c=u.add(l),g=r.P.getClosestCoordinate(u,c,t.getCenter(),!0),d=new r.P;(0,r.U)(u,c,g,d);const _=r.P.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}(t,e,s):Dr(t,e,s)}}function $n(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,I(t,e),q(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),hr(t,o),or(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,cr(t,void 0===h)}function Kn(t,e,s,i){t.m_bits=0,t.m_rotation=0,I(t,e),q(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,hr(t,!1),or(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function Jn(t){return t.m_center.isNAN()}function tr(t,e){if(0===e)return 0;const s=On(t),i=jn(t,e),n=(0,r.T)(),o=er(t),a=(0,r.aa)(i+n,s.e2,s.completeE),h=t.m_semiMajorAxis*(a-o);return Math.abs(h)}function er(t){const e=On(t);return(0,r.aa)(t.getStartAngle()+(0,r.T)(),e.e2,e.completeE)}function sr(t,e,s,n,o){if(2===e.m_TransformationType)return void(0,i.g)(0);if((0,i.g)(!ur(t)),e.isIdentity()&&(!n||n.equals(t.getStartXY())&&o.equals(t.getEndXY())))return;rr(t);let a=r.P.getNAN(),h=r.P.getNAN();if(null===n?(a.x=t.m_XStart,a.y=t.m_YStart,e.transformInPlace(a),h.x=t.m_XEnd,h.y=t.m_YEnd,e.transformInPlace(h)):(a=n,h=o),Jn(t))return t.m_XStart=a.x,t.m_YStart=a.y,t.m_XEnd=h.x,void(t.m_YEnd=h.y);const m=t.m_center.clone();if(e.transformInPlace(m),s||e.isUniformNoRotation()){let s=ar(t);if(e.isReflective()&&(s=!s),0===t.projectionBehavior()){if(!a.equals(h)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(a,h,s)}return void ir(t,a,h,m,s,!1)}const i=new r.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const n=Math.atan2(i.y,i.x),o=t.getSemiAxes();e.transformWithoutTranslateInPlace(o);const u=t.m_center.clone();return e.transformInPlace(u),void t.constructEllipticArcEndPointsCenter(a,h,o.x,o.y/o.x,n,t.isMajor(),s,u)}{{const s=new Array(4);!function(t,e){const s=new r.H(t.m_cosr).sqrThis(),i=new r.H(t.m_sinr).sqrThis(),n=new r.H(t.m_minorMajorRatio),o=new r.H(1/t.m_minorMajorRatio),a=n.mulE(s).addThisE(o.mulE(i)),h=n.subE(o).mulThis(2*t.m_cosr*t.m_sinr),m=n.mulE(i).addThisE(o.mulE(s));e[0]=a,e[1]=h,e[2]=m,e[3]=new r.H(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,s);const i=new v;if(i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]),!i.det().isZero()){const n=new v;if(n.a11.set(e.xx),n.a12.set(e.xy),n.a21.set(e.yx),n.a22.set(e.yy),n.invertThis()){const o=n.clone();o.transposeThis();const u=i.clone();if(u.mulThis(n),u.mulLeftThis(o),!u.det().isZero()){const i=(0,r.m)(r.H,4);i[0].setE(u.a11),i[1].setE(u.a12),i[1].mulThisByPower2(2),i[2].setE(u.a22),i[3].setE(s[3]);const n=r.P.getNAN(),o=function(t,e){const s=new v;s.a11.setE(t[0]),s.a12=r.H.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[r.P.getNAN(),r.P.getNAN()],n=[new r.H,new r.H];s.eigenSymmetric(n,i);const o=t[3].clone();return o.negateThis(),o.invThis(),n[0].mulThisE(o),n[1].mulThisE(o),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble(),Math.atan2(i[0].y,i[0].x)}(i,n);let l=ar(t);return e.isReflective()&&(l=!l),void t.constructEllipticArcEndPointsCenter(a,h,n.x,n.y/n.x,o,t.isMajor(),l,m)}}}}const s=[r.P.getNAN(),r.P.getNAN(),r.P.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let i=t.isClockwise();i&&(s[2]=(0,r.c)(s[0],s[0]=s[2]));const n=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const o=new r.P(0,0),u=t.createInstance();dr(s,n,o,!1,u),t.constructEllipticArcEndPointsCenter(a,h,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!i,m)}}function ir(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),Vn(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function nr(t,e){t.m_cachedValues=e}function rr(t){t.m_cachedValues=null}function or(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function ar(t){return!!(1&t.m_bits)}function hr(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function mr(t){return!!(2&t.m_bits)}function ur(t){return!!(8&t.m_bits)}function lr(t){t.m_bits&=-9}function cr(t,e){lr(t);const s=t.getStartXY(),n=t.getEndXY();let o=!1;const a=mr(t),h=ar(t),m=t.projectionBehavior(),u=s.equals(n);let l=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,i.o)("NAN minor major ratio and non-zero major axis")),l||=e?u:t.m_center.isNAN(),l)return Kn(t,s,n,m),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const c=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if((0,i.g)(c.y>0&&c.x>=c.y),u){const e=t.convertToCanonic(s);(0,i.g)(!c.isZero()),e.x/=c.x,e.y/=c.y;const n=Math.sqrt((0,r.a)(e.x)+(0,r.a)(e.y));if(o=1!==n,t.m_semiMajorAxis*=n,c.mulThis(n),t.m_startAngle=Bn(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=h?(0,r.a9)():-(0,r.a9)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;const e=new y;e.setWithEps(t.getStartXY(),8),e.subThisE((new y).setWithEps(t.m_center,8));const s=new r.H;s.setWithEps(t.m_rotation,8);const i=new r.H,n=new r.H;r.H.st_cosAndSin(s,i,n),e.rotateReverse(i,n);const o=new y;o.setWithEps(t.getEndXY()),o.subThisE(y.constructPoint2D(t.m_center)),o.rotateReverse(i,n);const a=new r.H;a.setWithEps(t.m_semiMajorAxis,8);const h=a.clone(),m=new r.H;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),e.x.divThisE(a),e.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=e.x.sqr().addThisE(e.y.sqr()).subThisE(r.I),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(r.I);return!u.isZero()||!l.isZero()}(t);if(!e){const i=t.convertToCanonic(s);i.x/=c.x,i.y/=c.y;const o=new r.P(1,0);t.m_startAngle=r.P.calculateAngle(o,i);const a=t.convertToCanonic(n);a.x/=c.x,a.y/=c.y,t.m_sweepAngle=r.P.calculateAngle(i,a),e=!pr(t)}if(e){o=!0;const e=s.sub(n).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let i=(0,r.a)(e.x/c.x)+(0,r.a)(e.y/c.y);i>1&&(i=Math.sqrt(i),t.m_semiMajorAxis*=i,c.mulThis(i));const m=new r.P(0,0);{const t=c.x*c.x,s=c.y*c.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);m.setCoords(c.x*e.y/c.y,-c.y*e.x/c.x),m.mulThis(t),a===h&&m.negateThis()}}{const e=new r.P(m.x,m.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(n).mulThis(.5)),t.m_center.assign(e)}}if(kn(t),!pr(t))return Kn(t,s,n,m),!0}return xr(t),t.afterCompletedModification(),o}function gr(t,e){(0,i.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),n=t.getSemiMinorAxis();let o;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),o=1,o;if(0===n)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=r.P.lerp(e[0],e[2],.5),o=1,o;const a=t.getSweepAngle(),h=t.getStartAngle(),m=h+a,u=new r.P(-s*Math.sin(h),n*Math.cos(h)),l=new r.P(-s*Math.sin(m),n*Math.cos(m));u.normalize(),l.normalize(),u.rotateDirect(t.m_cosr,t.m_sinr),l.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const c=u.crossProduct(l);return e[1].assign(u.mul(e[1].crossProduct(l)/c)),e[1].addThis(e[0]),o=Math.cos(.5*a),o}function dr(t,e,s,n,o){if(n){const s=.5,i=Math.sqrt(e),n=(0,r.a)(1-s)+2*i*s*(1-s)+(0,r.a)(s),a=t[0].mul((0,r.a)(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul((0,r.a)(s))).divThis(n);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}const a=t[0].sub(t[1]),h=t[2].sub(t[1]),m=a.crossProduct(h),u=a.dotProduct(h),l=e;(0,i.g)(l<=1),(0,i.g)(l>0);const c=.5/(1-l),g=a.sqrLength(),d=u,_=h.sqrLength(),p=(0,r.a)(m),f=a.sub(h).sqrLength();if(0===p)return Kn(o,t[0],t[2],1),!1;if(u<=-Math.sqrt(g)*Math.sqrt(_))return Kn(o,t[0],t[2],1),!1;const x=[0,0],P=new r.E;P.setInfinite();const y=Nt(2*p,-(f/l+4*d),2*(1-l)/l,P,!1,x);if(0===y)return Kn(o,t[0],t[2],1),!1;1===y&&(x[1]=x[0]);const v=Math.sqrt(c/x[0]),C=Math.sqrt(c/x[1]),E=.5/l;let b=E-_*x[0],D=E-g*x[0];Math.abs(b)>Math.abs(D)?D=d*x[0]-E+1:b=d*x[0]-E+1;const S=a.mul(b).add(h.mul(D)),w=S.norm(1)<1e-15*v?0:Math.atan2(S.y,S.x)+Math.PI,A=a.add(h),T=s?s.clone():t[1].add(A.mul(c)),I=t[0].sub(T),N=t[2].sub(T),q=I.crossProduct(N)<0;return new In,o.constructEllipticArcEndPointsCenter(t[0],t[2],v,C/v,w,!1,!q,T)}function _r(t,e,s,i,n){return dr(t,e,s,i,n)}function pr(t){const e=B(t);let s=!1;{const i=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));i.rotateDirect(t.m_cosr,t.m_sinr),i.addThis(t.m_center),s=r.P.distance(t.getStartXY(),i)>e}let i=!1;if(!s){const s=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),i=r.P.distance(t.getEndXY(),s)>e}return!s&&!i}function fr(t){if(Jn(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,u=0;t.m_rotation&&(m=(a-h)*(a+h),u=2*a*h);const l=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;return t.m_rotation&&(c=-2*Math.sin(r+n)*Math.sin(r-n)*.125*u-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h),i*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function xr(t){t.queryCoord2D(.5,t.m_interior)}function Pr(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==yr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function yr(t,e,s,n,o,a,h,m,u,l){if(Jn(e))return ot(new Fr({start:e.getStartXY(),end:e.getEndXY()}),s,n,o,a,h,m,l);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0);const c=G(e,s);if(H(e,s,h=Math.max(c,h)))return 0;const g=s.getStartXY();g.subThis(e.m_center);const d=s.getEndXY();d.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);const _=d.clone();_.subThis(g);const p=e.m_semiMajorAxis,f=1/p,x=e.getSemiMinorAxis(),P=1/x,y=_.clone();y.leftPerpendicularThis();const v=Math.atan2(x*y.y,p*y.x),C=(0,r.d)(16,Number.NaN),E=(0,r.d)(16,Number.NaN);let b=0;const D=[v,v+Math.PI];for(let t=0;t<2;++t){const i=Wn(e,D[t]);if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(C[b]);E[b]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(E[b]))<=h&&b++}}const S=g.x*f,w=g.y*P,A=_.x*f,T=_.y*P;let I=Nt(A*A+T*T,2*(S*A+w*T),S*S+w*w-1,r.E.unit(),!1,E);(0,i.g)(I>=0);for(let t=0;t<I;t++){const i=_.mul(E[t]).add(g);i.x*=f,i.y*=P;const n=Wn(e,Math.atan2(i.y,i.x));if(n>=0&&n<=1){C[b]=n;const t=e.getCoord2D(n);E[b]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(E[b]))<=h&&b++}}(0,i.g)(b<C.length+4);const N=(0,r.d)(16,Number.NaN);I=e.intersectPoint(s.getStartXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=N[t],E[b]=0;I=e.intersectPoint(s.getEndXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=N[t],E[b]=1;I=s.intersectPoint(e.getStartXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=0,E[b]=N[t];I=s.intersectPoint(e.getEndXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=1,E[b]=N[t];return 0===b?0:qr(t,e,s,C,E,b,n,o,a,h,m,0,l)}function vr(t,e,s,n,o,a,h,m,u,l){if(Jn(e)){const i=new Fr({start:e.getStartXY(),end:e.getEndXY()});return yr(t,s,i,n,a,o,h,m,0,!l)}if(Jn(s)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()});return yr(t,e,i,n,o,a,h,m,0,l)}const c=G(e,s);h=Math.max(h,c);let g=!1;{const t=e.getSemiAxes(),n=e.getCenter(),l=s.getSemiAxes(),c=s.getCenter(),d=r.P.distance(c,n),_=t.x+l.x;if(d>_+h)return 0;if(t.y>l.x){if(d+l.x+h<t.y)return 0}else if(l.y>t.x&&d+t.x+h<l.y)return 0;if(u&&!m){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),r=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(n&&r&&(g=!0,d<=_)&&Math.max(t.x,l.x)<=Math.min(t.x,l.x)+d)return(0,i.g)(!o&&!a),1}}if(!g&&H(e,s,h))return 0;const d=[],_=[],p=!1,f=!1,x=Mn(e,0,0,p,f,d,_,null),P=[],y=[],v=Mn(s,0,0,p,f,P,y,null);if(1===x&&1===v){const t=new Ut({points:d,weights:_}),i=new Ut({points:P,weights:y}),c=[],g=[],p=on(!1,t,i,n,null===o?null:c,null===a?null:g,h,m,u,l);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let n=0;n<p;++n){if(o)if((0,r.N)(c[n],0,1))o.push(c[n]);else{const s=t.tToLength(c[n]),i=e.lengthToT(s);o.push(i)}if(a)if((0,r.N)(g[n],0,1))a.push(g[n]);else{const t=i.tToLength(g[n]),e=s.lengthToT(t);a.push(e)}}}return p}let C=[];const E=[];let b=0;const D=u&&!m;for(let t=0;t<x;t++){const i=new Ut({points:d.slice(2*t,2*t+3),weights:_.slice(2*t,2*t+3)});let n=0;for(let o=0;o<v;o++){E.length<=o&&E.push(new Ut({points:P.slice(2*o,2*o+3),weights:y.slice(2*o,2*o+3)}));const a=[],m=[],u=D?null:a,l=D?null:m,c=on(!1,i,E[o],null,u,l,h,!1,D,!1);if(c>0&&D)return 1;for(let h=0;h<c;++h){if(0===a[h]&&0===t)a[h]=0;else if(1===a[h]&&t===x-1)a[h]=1;else{const t=i.tToLength(a[h])+b,s=e.lengthToT(t);a[h]=s}if(0===m[h]&&0===o)m[h]=0;else if(1===m[h]&&o===v-1)m[h]=1;else{const t=E[o].tToLength(m[h])+n,e=s.lengthToT(t);m[h]=e}C.push((0,r.k)(a[h],m[h]))}n+=E[o].calculateLength2D()}b+=i.calculateLength2D()}if(0===C.length)return 0;if(m&&(C=C.filter(t=>!(0,r.N)(t.first,0,1)||!(0,r.N)(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second)))),u)return C.length;const S=[],w=[];for(const t of C)S.push(t.first),w.push(t.second);return qr(t,e,s,S,w,S.length,n,o,a,h,m,0,l)}function Cr(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Jn(t))return;const i=t.getSemiAxes(),n=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=r+Math.PI;n[0]=Wn(t,e),n[1]=Wn(t,s),n[2]=Wn(t,r),n[3]=Wn(t,o)}const o=new r.P;for(let i=0;i<4;i++){const r=n[i];e.containsExclusiveCoordinate(r)&&(t.queryCoord2D(r,o),s.mergeNe(o))}}function Er(t,e,s,n,o){if(0===t.m_semiMajorAxis)return s.vmin;let a=r.P.getNAN();t.queryCoord2D(s.vmin,a);let h=r.P.getNAN();if(t.queryCoord2D(s.vmax,h),Jn(t))return new Fr({start:a,end:h}).getClosestCoordinate(e,n);const m=zn(t,e);if(a=zn(t,a),h=zn(t,h),1===t.m_minorMajorRatio){if(m.isEqual(0,0))return s.vmin;const e=Wn(t,Math.atan2(m.y,m.x));return n||s.containsCoordinate(e)?e:r.P.distance(m,a)<=r.P.distance(m,h)?s.vmin:s.vmax}const u=t.getSemiMajorAxis(),l=t.getSemiMinorAxis(),c=(u-l)*(u+l),g=(0,r.a)(c),d=m.x,_=m.y,p=(0,r.a)(l*_),f=l*c*_*2,x=[new r.H(p),new r.H(f),new r.H(g-(0,r.a)(u*d)-p),new r.H(-f),new r.H(-g)],P=(0,r.m)(r.H,4),y=Vt(x,4,new r.E(-1,1),!1,P,4);let v=s.vmin,C=r.P.sqrDistance(m,a);{const t=r.P.sqrDistance(m,h);t<C&&(v=s.vmax,C=t)}(0,i.g)(!n);let E=(0,r.d)(8,Number.NaN);for(let e=0;e<y;++e){const s=P[e].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);E[2*e]=Wn(t,n),E[2*e+1]=Wn(t,r)}E=E.slice(0,2*y),(0,r.v)(E);for(let i=0,n=2*y;i<n;++i)if(E[i]>s.vmin&&E[i]<s.vmax){const s=r.P.sqrDistance(e,t.getCoord2D(E[i]));C>s&&(C=s,v=E[i])}return v}function br(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&t.isMajor()!==e.isMajor()&&!!t.m_center.equals(e.m_center)&&t.m_sinr===e.m_sinr&&t.m_cosr===e.m_cosr&&t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function Dr(t,e,s,n){const o=t.getStartXY(),h=t.getEndXY(),m=o.equals(h),u=e.equals(s);if(!m&&!u){const i=new a.T;return i.initializeFromTwoPoints(o,h,e,s),sr(t,i,!0,e,s),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Kn(t,e,s,1);if(m&&u){const i=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),i)}if(!m){const i=.5*((0,r.a9)()-Math.abs(t.getSweepAngle())),n=(t.getSweepAngle()+i*(0,r.e)(t.getSweepAngle()))/t.getSweepAngle(),o=new r.P;t.queryCoord2D(n,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}const l=r.P.sqrDistance(e,s);let c=.25,g=.75;if(l<r.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=It(new Ln(t,l),r.E.construct(0,.25),1,e);s>0&&((0,i.g)(1===s),c=e[0],g=1-e[0])}const d=t.getCoord2D(c),_=t.getCoord2D(g);(0,i.g)(!d.equals(_)),t.constructEllipticArcEndPointsCenter(d,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),Dr(t,e,s)}function Sr(t,e,s,i,n){return wr(t,!1,e,s,i,n)}function wr(t,e,s,n,r,o){const a=s.getGeometryType(),h=n.getGeometryType(),m=Math.max(r,G(s,n));if(a===i.G.enumLine&&h===i.G.enumLine)return rt(s,n,m,o);let u=s,l=n,c=s.getStartXY(),g=s.getEndXY();if(c.compare(g)>0&&(u=s.clone().reverse()),c=n.getStartXY(),g=n.getEndXY(),c.compare(g)>0&&(l=n.clone().reverse()),e){if(s.equals(n))return 2;if(function(t,e,s){return(0,i.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&T(t,e,0,0,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&T(t,e,1,1,s,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&T(t,e,0,1,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&T(t,e,1,0,s,2,[0,0],[0,0]))}(s,n,m))return 4}switch(a){case i.G.enumLine:switch(h){case i.G.enumEllipticArc:return Pr(t,l,u,m,o);case i.G.enumBezier:return Ks(t,l,u,m,o);case i.G.enumRationalBezier2:return tn(t,l,u,m,o);case i.G.enumBezier2:return ke(t,l,u,m,o);default:(0,i.d)("")}break;case i.G.enumEllipticArc:switch(h){case i.G.enumLine:return Pr(t,u,l,m,o);case i.G.enumEllipticArc:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==vr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumBezier:return Js(t,l,u,m,o);case i.G.enumRationalBezier2:return en(t,l,u,m,o);case i.G.enumBezier2:return We(t,l,u,m,o);default:(0,i.d)("")}break;case i.G.enumBezier:switch(h){case i.G.enumLine:return Ks(t,u,l,m,o);case i.G.enumEllipticArc:return Js(t,u,l,m,o);case i.G.enumBezier:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==ni(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumRationalBezier2:return ti(t,u,l,m,o);case i.G.enumBezier2:return ei(t,u,l,m,o);default:(0,i.d)("")}break;case i.G.enumRationalBezier2:switch(h){case i.G.enumLine:return tn(t,u,l,m,o);case i.G.enumEllipticArc:return en(t,u,l,m,o);case i.G.enumBezier:return ti(t,l,u,m,o);case i.G.enumRationalBezier2:return function(t,e,s,i,n){if(n){const i=Ar(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(D(e,s))return 1;return 0!==on(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumBezier2:return sn(t,u,l,m,o);default:(0,i.d)("")}break;case i.G.enumBezier2:switch(h){case i.G.enumLine:return ke(t,u,l,m,o);case i.G.enumEllipticArc:return We(t,u,l,m,o);case i.G.enumBezier:return ei(t,l,u,m,o);case i.G.enumRationalBezier2:return sn(t,l,u,m,o);case i.G.enumBezier2:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==Ue(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}(t,u,l,m,o);default:(0,i.d)("")}break;default:(0,i.d)("")}}function Ar(t,e,s=!0){if(!s&&!Tr(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===i.G.enumEllipticArc)return br(t,e,!1)?s:0;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===i.G.enumEllipticArc)return br(t,e,!0)?s:-1;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function Tr(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function Ir(t,e,s,n,r,o,a){!r&&o&&(0,i.a)("");const h=e.getGeometryType(),m=s.getGeometryType(),u=Math.max(a,G(e,s));if(n&&(n.length=0),r&&(r.length=0),o&&(o.length=0),h===i.G.enumLine&&m===i.G.enumLine)return ot(e,s,n,r,o,u,!1,!1);let l=e,c=s,g=e.getStartXY(),d=e.getEndXY(),_=!1,p=!1;g.compare(d)>0&&(l=e.clone(!0).reverse(),_=!0),g=s.getStartXY(),d=s.getEndXY(),g.compare(d)>0&&(c=s.clone(!0).reverse(),p=!0);let f=0;switch(h){case i.G.enumLine:switch(m){case i.G.enumEllipticArc:f=yr(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier:f=si(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=nn(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=je(t,c,l,n,o,r,u,!1,0,!0);break;default:(0,i.d)("")}break;case i.G.enumEllipticArc:switch(m){case i.G.enumLine:f=yr(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=vr(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier:f=ii(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=rn(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=Ze(t,c,l,n,o,r,u,!1,0,!0);break;default:(0,i.d)("")}break;case i.G.enumRationalBezier2:switch(m){case i.G.enumLine:f=nn(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=rn(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=ri(t,c,l,n,o,r,u,!1,!1,!0);break;case i.G.enumRationalBezier2:f=on(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier2:f=an(t,l,c,n,r,o,u,!1,0,!1);break;default:(0,i.d)("")}break;case i.G.enumBezier2:switch(m){case i.G.enumLine:f=je(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=Ze(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=oi(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=an(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=Ue(t,l,c,n,r,o,u,!1,!1,!1);break;default:(0,i.d)("")}break;case i.G.enumBezier:switch(m){case i.G.enumLine:f=si(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=ii(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=ni(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumRationalBezier2:f=ri(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier2:f=oi(t,l,c,n,r,o,u,!1,0,!1);break;default:(0,i.d)("")}break;default:(0,i.d)("")}if(_){if(r){for(let t=0;t<f;t++)r[t]=1-r[t];r.reverse()}n&&n.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function Nr(t,e,s){return e===s?0:(e>s&&(s=(0,r.c)(e,e=s)),t.cut(e,s,!0).calculateUpperLength2D())}function qr(t,e,s,i,n,o,a,h,m,u,l,c,g){if(!o)return 0;const d=(t,e)=>{for(let s=0;s<o;++s){let i=e[s];if((0,r.N)(i,0,1)){i=(0,r.ak)(i);continue}const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&Nr(t,0,i)<=B(t)&&(e[s]=0):n.equals(t.getEndXY())&&Nr(t,i,1)<=B(t)&&(e[s]=1)}};d(e,i),d(s,n),function(t,e,s,i,n){const o=[],a=[],h=[];for(let m=0,u=n;m<u;m++)o.push(t.calculateSubLengthFromStart(s[m])),a.push(e.calculateSubLengthFromStart(i[m])),(0,r.N)(s[m],0,1)&&(0,r.N)(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&h.push(m);if(0===h.length||h.length===n)return;h.sort((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0);let m=-1;for(const u of h){if(m>=0&&s[u]===s[m]&&s[u]===s[m]){m=u;continue}m=u;const h=[];h.length=n;for(let t=0;t<h.length;++t)h[t]=t;h.sort((t,e)=>{const s=o[u],i=a[u],n=o[t]-s,r=a[t]-i,h=n*n+r*r,m=o[e]-s,l=a[e]-i,c=m*m+l*l;return h<c?-1:h>c?1:0});for(let o=0;o<n;o++){const n=h[o];if(n===u||s[n]===s[u]&&i[n]===i[u]||(0,r.N)(s[n],0,1)&&(0,r.N)(i[n],0,1))continue;const a=(s,i,n,o)=>{const a=new y,h=new r.H;h.setWithEps(1);const m=new r.H;m.set(i,h.eps()),t.queryCoord2DE(m,a);const u=new y;t.queryCoord2DE(new r.H(s),u);let l=!1;return a.eq(u)&&(m.set(o,h.eps()),e.queryCoord2DE(m,a),e.queryCoord2DE(new r.H(n),u),l=a.eq(u)),!l},m=r.P.getNAN();t.queryCoord2D(s[n],m);const l=r.P.getNAN();if(e.queryCoord2D(i[n],l),0===r.P.distance(m,l)&&a(s[u],s[n],i[u],i[n]))break;const c=new r.E(i[n],i[u]);c.normalizeNoNAN();const g=new r.E(s[n],s[u]);g.normalizeNoNAN();let d=-1,_=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,f=s[n];m.assign(t.getCoord2D(f));for(let o=0;o<5;o++){const o=e.getClosestCoordinateOnInterval(m,c,-1);l.assign(e.getCoord2D(o));const h=r.P.distance(m,l);if(f=t.getClosestCoordinateOnInterval(l,g,-1),f===s[u]&&o===i[u]){d=1;break}m.assign(t.getCoord2D(f));const x=r.P.distance(l,m);if(!(x<p&&h<_)){d=0;break}if(0===x&&0===h){a(s[u],s[n],i[u],i[n])?(s[n]=f,i[n]=o,d=0):d=1;break}p=x,_=h}if(-1===d&&(d=(0,r.N)(s[n],0,1)||(0,r.N)(i[n],0,1)?0:1),1!==d)break;s[n]=s[u],i[n]=i[u]}}}(e,s,i,n,o);const _=[];for(let t=0,e=o;t<e;t++)_.push(t);const p=(t,e)=>g?(0,r.al)(n[t],i[t],n[e],i[e]):(0,r.al)(i[t],n[t],i[e],n[e]);if(_.length>1){_.sort(p);const t=Math.max(B(e),B(s));let o=0;for(let a=1,h=_.length;a<h;a++){const h=i[_[o]],m=i[_[a]],u=n[_[o]],l=n[_[a]];if(h!==m||u!==l){if(Nr(e,h,m)<=t&&Nr(s,u,l)<=t&&!((0,r.N)(h,0,1)&&(0,r.N)(u,0,1)||(0,r.N)(m,0,1)&&(0,r.N)(l,0,1))){const t=r.P.distance(e.getCoord2D(h),s.getCoord2D(u)),i=r.P.distance(e.getCoord2D(m),s.getCoord2D(l));if(t<=i)continue;if(i<t){_[o]=_[a];continue}continue}o++,_[o]=_[a]}}if(_.length=o+1,1===_.length&&0!==_[0]&&(i[0]=i[_[0]],n[0]=n[_[0]],_[0]=0),_.length>2){const t=r.E.constructEmpty(),o=r.E.constructEmpty();t.setCoords(i[_[0]],i[_.at(-1)]),o.setCoords(n[_[0]],n[_.at(-1)]);let a=!0;for(let e=1,s=_.length-1;e<s;e++)if(!t.containsCoordinate(i[_[e]])||!o.containsCoordinate(n[_[e]])){a=!1;break}if(a){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let h=(0,r.q)(t.vmin,t.vmax,i[n]);const m=e.getCoord2D(h);if(!s.isCloserThanDistance(m,o,u)){a=!1;break}h=(0,r.q)(o.vmin,o.vmax,i[n]);const l=s.getCoord2D(h);if(!e.isCloserThanDistance(l,t,u)){a=!1;break}}}a&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t){const t=0,r=0;T(e,s,i[0],n[0],u,1,[t],[r])&&(_.push(1),i[1]=t,n[1]=r,_.sort(p))}if(l&&1===_.length){let t=!0;for(let o=0,a=_.length;o<a;o++)if(!(0,r.N)(i[_[o]],0,1)||!(0,r.N)(n[_[o]],0,1)||0!==r.P.distance(e.getCoord2D(i[_[o]]),s.getCoord2D(n[_[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,s=_.length;t<s;t++){if(h&&h.push(i[_[t]]),m&&m.push(n[_[t]]),a){const s=r.P.getNAN();e.queryCoord2D(i[_[t]],s),a.push(s)}f++}return f}function Mr(t,e,s,i,n,o,a,h,m){if((0,r.N)(s,0,1)&&(0,r.N)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const u=1e-12,l=new y,c=Number.EPSILON;if(t.queryDerivative(new r.H(s,c),l),l.isTrueZero()){const e=1===s?-u:u;t.queryDerivative(new r.H(s,c).add(e),l)}1===s&&l.negateThis();const g=new y;if(e.queryDerivative(new r.H(i,c),g),g.isTrueZero()){const t=1===s?-u:u;e.queryDerivative(new r.H(i,c).add(t),g)}1===i&&g.negateThis(),l.isZero()||l.normalize(),g.isZero()||g.normalize();const d=l.dotProduct(g),_=l.crossProduct(g);_.scaleError(3);const p=()=>{if(m)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(r.J)&&(_.isZero()||Math.abs(_.value())<p()))return A(t,e,s,i,n,o,a,h)}return 0}function Yr(t,e,s,n,o){let a=-1,h=-1,m=-1,u=-1;{const i=[0,e],r=[e,0],o=[0,n],l=[n,0];for(let e=0;e<2&&-1===a;++e)for(let n=0;n<2;++n)if(t[i[e]].equals(s[o[n]])){a=i[e],h=r[e],m=o[n],u=l[n];break}}if(-1===a){const i=new p;i.setFromPoints(t,e+1);const r=new p;return r.setFromPoints(s,n+1),r.inflate(o),i.isIntersectingW(r)?-1:0}{const l=(0,r.d)(e+1,Number.NaN),c=gs(t,e+1,l);(0,i.g)(c>1);let g=0,d=0;for(let t=0;t<c;++t)a===l[t]&&(d=t,g++),h===l[t]&&g++;if(2!==g)return-1;const _=(0,r.d)(n+1,Number.NaN),p=gs(s,n+1,_);(0,i.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===_[t]&&(f=t,g++),u===_[t]&&g++;if(2!==g)return-1;const x=t[l[(d+c-1)%c]],P=t[l[(d+1)%c]],y=s[_[(f+p-1)%p]],v=s[_[(f+1)%p]],C=t[a],E=[x,P,y,v],b=[0,1,2,3];b.sort((t,e)=>r.P.compareVectorsOrigin(C,E[t],E[e]));let D=b[0];for(let t=1;t<4;t++){if(b[t]!==(D+1)%4)return-1;D=b[t]}{const t=x.sub(C),e=v.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}return 1}}var Xr=n.V;class Fr extends ${constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,i.g)(0),0}calculateUpperLength3D(){return(0,i.g)(0),0}changeEndPoints3D(t,e){(0,i.g)(0)}getClosestCoordinate3D(t,e,s){return(0,i.g)(0),0}getBoundary(){return At(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?tt(this,t):et(this,t);const i=Xr.getInterpolation(e),n=this.getStartAttributeAsDbl(e,s),o=this.getEndAttributeAsDbl(e,s);return(0,r.V)(i,n,o,t,Xr.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,i.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Fr.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Xr.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,L(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,L(this,1,1,0))):(0,i.t)("env type not impl")}applyTransformation(t){(0,i.g)(t instanceof a.T);const e=new r.P;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new Fr({vd:this.m_description})}calculateLength2D(){return Math.sqrt(lt(this))}calculateLength3D(t){return(0,i.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return(0,i.g)(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return K(this,t,e)}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return function(t,e){const s=t.getStartZ(),i=t.getEndZ();return(0,r.q)(s,i,e)}(this,t)}queryCoord2DE(t,e){st(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=C.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(r.M.constructDouble(t)),e.addThis(s)}getCoordX(t){return tt(this,t)}getCoordY(t){return et(this,t)}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const o=r.P.getNAN();if(K(this,t,o),n.setStartXYCoords(o.x,o.y),K(this,e,o),n.setEndXYCoords(o.x,o.y),!i)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=Xr.getComponentCount(i);for(let s=0;s<r;s++){const r=this.getAttributeAsDbl(t,i,s);n.setStartAttribute(i,s,r);const o=this.getAttributeAsDbl(e,i,s);n.setEndAttribute(i,s,o)}}}queryDerivative(t,e){!function(t,e,s){const i=y.constructPoint2D(t.getStartXY()),n=y.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}(this,0,e)}getClosestCoordinate(t,e){return r.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new r.P;this.queryCoord2D(e.vmin,i);const n=new r.P;this.queryCoord2D(e.vmax,n);const o=r.P.getClosestCoordinate(i,n,t,!1);return j.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=tt(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new Fr;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new r.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=r.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new r.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return at(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,i.a)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=tt(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=et(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=(0,r.s)(t.vmin,0,1);const i=new r.P;return this.queryCoord2D(s,i),e.setCoords({pt:i}),s=(0,r.s)(t.vmax,0,1),this.queryCoord2D(s,i),void e.mergeNe(i)}(0,i.t)("3d dst not impl")}orientBottomUp(){nt(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return function(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoordsForStitcher(t,e){it(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,i.g)(0),0}readFromBufferStream(t,e){(0,i.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){it(this,t,e)}static isIntersectingLineLine(t,e,s,i){return rt(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return rt(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&(0,i.r)("");const n=at(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}}Fr.type=i.G.enumLine;class Rr{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new Fr,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,i.d)("bad constructor params"))}assignCopy(t){return t instanceof Rr?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Rr){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,i.d)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,i.g)(0)}createImpl(t){switch(t){case i.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Fr,this.m_mask|=1,this.m_active=1);break;case i.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new In,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.G.enumBezier:4&this.m_mask||(this.m_curves=new Ci,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.G.enumBezier2:8&this.m_mask||(this.m_curves=new Qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Ut,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,i.a)("")}}create(t){t===i.G.enumLine?this.createLine():t===i.G.enumEllipticArc?this.createEllipticArc():t===i.G.enumBezier?this.createCubicBezier():t===i.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.G.enumBezier2?this.createQuadraticBezier():(0,i.a)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,i.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(i.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,i.d)("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,i.d)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Rr?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,i.t)("seg comparison not yet impl"),!1)}}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8885,9187],{95213(t,e,s){s.d(e,{$:()=>Ct,A:()=>L,B:()=>V,C:()=>J,D:()=>N,E:()=>Ft,F:()=>q,G:()=>M,H:()=>wt,I:()=>St,J:()=>ot,K:()=>nt,L:()=>rt,M:()=>A,N:()=>ct,O:()=>l,P:()=>qt,Q:()=>vt,R:()=>Z,S:()=>B,T:()=>j,U:()=>_t,V:()=>g,W:()=>mt,X:()=>Pt,Y:()=>pt,Z:()=>ht,_:()=>At,a:()=>F,a0:()=>bt,a1:()=>Dt,a2:()=>Et,a3:()=>$,a4:()=>tt,a5:()=>It,a6:()=>W,a7:()=>S,b:()=>X,c:()=>at,d:()=>lt,e:()=>ut,f:()=>b,g:()=>it,h:()=>dt,i:()=>yt,j:()=>st,k:()=>ft,l:()=>v,m:()=>Xt,n:()=>x,o:()=>P,p:()=>D,q:()=>c,r:()=>y,s:()=>xt,t:()=>_,u:()=>E,v:()=>T,w:()=>I,x:()=>et,y:()=>z,z:()=>C});var i=s(83661),n=s(79187),r=s(55537);const o=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],a=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],h=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],m=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],u=[4,8,4,8,1],l=25;function c(){return(0,i.d)(l,Number.NaN)}let g=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return h[t]}static getPersistence(t){return m[t]}static getPersistenceSize(t){return u[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return a[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return o[t]}static isDefaultValue(t,e){return(0,i.Q)(o[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=(0,i.d)(l,Number.NaN),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,n=1,r=14;for(;s<r;s++)e&n&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),n<<=1;let o=0;for(s=0,r=this.getAttributeCount();s<r;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=o;for(let t=0;t<i;t++)this.m_defaultPointAttributes[o]=n,o++}}};var d=g;function _(){return(0,i.d)(14,0)}class p{static getInstance(){return p.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new d(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new d(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new d(t);return this.m_map.set(t,s),s}}function f(t){return p.getInstance().FindOrAdd(t)}function x(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:f(s)}function P(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:f(s)}function y(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:f(s)}function v(){return p.getInstance().GetVD2D()}function C(){return p.getInstance().GetVD3D()}function E(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}p.s_thisInstance=new p;class b{static construct(t,e,s){return new b(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new b(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new b;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,i.a)(t.x-e.x)+(0,i.a)(t.y-e.y)+(0,i.a)(t.z-e.z)}static sqrDistanceCoords(t,e,s,n,r,o){return(0,i.a)(t-n)+(0,i.a)(e-r)+(0,i.a)(s-o)}static distance(t,e){return Math.sqrt(b.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,i.G)(this.z,t.z,e)}static compareByLength(t,e,s,i){return(0,r.g)(0),0}isEqualCoords(t,e,s,i){return(0,r.g)(0),this.x===t&&this.y===e&&this.z===s}isEqualsTols(t,e,s){return(0,r.g)(0),!1}isEqualCoordsTols(t,e,s,i,n){return(0,r.g)(0),!1}static st_isEqual(t,e,s,i){return(0,r.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,s){return(0,r.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return b.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return b.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new b(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return b.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return(0,r.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,r.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,r.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,s,i=!1){return(0,r.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return(0,r.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,r.g)(0),{}}static average(t,e){return(0,r.g)(0),{}}static size(){return b.dimensions}static lerp(t,e,s){const n=new b;return(0,i.x)(t,e,s,n),n}static slerp(t,e,s){return(0,r.g)(0),{}}static compareVectors(t,e){return(0,r.g)(0),0}static selectRightHandedBasisFromNormal(t,e,s){const i=t.getUnitVector(),n=i.createAPerpendicular(),r=new b;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new b(0,0,1)),this.crossProductVector(new b(1,0,0)),this.crossProductVector(new b(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce((t,s,i)=>e[t]>e[i]?t:i,0)];return s.normalizeThis(),s}calculateAngle(t){return(0,r.g)(0),0}static crossDotSign(t,e,s){return(0,r.g)(0),0}static isBisectorRobust(t,e,s){return(0,r.g)(0),0}static compareZOrder(t,e){return(0,r.g)(0),!1}}b.dimensions=3;class D{static constructEmpty(){return new D(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,s){(0,r.g)(0)}getEnvelope2D(){return new n.Envelope2D(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new i.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,i.c)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,i.c)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,i.c)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,s,i=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}const S=-559038737;var w=g;function A(t,e,s){switch(t){case 0:return new R(e,s);case 1:return new L(e,s);case 2:return new F(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new X(e,s);default:(0,r.a)("")}}function T(t,e){const s=w.getComponentCount(t);return A(w.getPersistence(t),e*s,w.getDefaultValue(t))}function I(t,e){const s=w.getComponentCount(t);return A(w.getPersistence(t),e*s)}function N(t,e){return new F(t,e)}function q(t,e){return new X(t,e)}function M(t,e){return new L(t,e)}class Y{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>Y.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&(0,r.a)(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}getArray(){return this.m_a}equals(t,e,s,n){return this.getPersistence()===t.getPersistence()&&function(t,e,s,n,r){if(t.getPersistence()!==e.getPersistence())return!1;const o=t.getPersistence()<=1,a=t.size(),h=e.size();if(n>a||n>h)return!1;if(r)if(o){for(let o=s;o<n;o++)if(!(0,i.G)(t.read(o),e.read(o),r))return!1}else for(let i=s;i<n;i++){let s=t.read(i)-e.read(i);if(s<0&&(s=-s),s>r)return!1}else for(let i=s;i<n;i++){const s=t.read(i),n=e.read(i);if(s!==n){if(o&&Number.isNaN(s)&&Number.isNaN(n))continue;return!1}}return!0}(this,t,e,s,n)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,s,i,n,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;i&&this.checkResize(Math.max(0,a)+i),this.m_a.copyWithin(t+i,t,a>=0?a:m),this.m_a.set(h.readRange(s,i),t),n||this.reverseRange(t,i,o)}writeRange(t,e,s,i,n,o){(0,r.g)(this.getPersistence()===s.getPersistence());const a=s;if((t<0||e<0||i<0)&&(0,r.a)(),a.size()<i+e&&(0,r.a)(),0===e)return;this.size()<e+t&&this.resize(e+t);const h=a.m_a.subarray(i,i+e);!function(t,e,s,i){if((e<0||s<0)&&(0,r.a)(),0===s)return;if(1===s)return void(t[e]=i[0]);let n=i;s<i.length&&(n=i.subarray(0,s)),t.set(n,e)}(this.m_a,t,e,h)}insertAttributes(t,e,s,i){const n=w.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let i=0;i<n;i++)this.m_a[t+i]=e.getAttributeAsDbl(s,i)}insertAttributesFromPoints(t,e,s,n,o){(0,r.g)(w.getPersistence(n)===this.getPersistence());const a=w.getComponentCount(n),h=this.m_size;if(this.checkResize(Math.max(0,o)+a*s),this.m_a.copyWithin(t+a*s,t,o>=0?o:h),0===n){const n=new i.P;for(let i=t,r=0;r<s;r++,i+=2)e[r].queryXY(n),this.m_a[i]=n.x,this.m_a[i+1]=n.y}else if(1===a)for(let i=t,r=0;r<s;r++,i++)this.m_a[i]=e[r].getAttributeAsDbl(n,0);else for(let i=t,r=0;r<s;r++,i+=a)for(let t=0;t<a;t++)this.m_a[i+t]=e[r].getAttributeAsDbl(n,t)}eraseRange(t,e,s){this.m_size<t+e&&(0,r.a)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!==0)&&(0,r.a)(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let i=t,n=t+e;i<n;i+=s){let t=i,e=i+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(t,e,s){(e<t||e>s||t>s)&&(0,r.r)("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.fromArray)this.m_a=t.fromArray,this.m_size=t.size??t.fromArray.length;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,Y.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}Y.s_constructMin=2,Y.s_resizeMin=30;class X extends Y{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new X({ctor:Int8Array,copy:this})}restrictedClone(t){return new X({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class F extends Y{getPersistence(){return 2}clone(){return new F({ctor:Int32Array,copy:this})}restrictedClone(t){return new F({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,i.i)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class R extends Y{getPersistence(){return 0}clone(){return new R({ctor:Float32Array,copy:this})}restrictedClone(t){return new R({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class L extends Y{getPersistence(){return 1}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&(0,r.a)();const i=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(i,s,i)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new i.P(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let n=s,r=t,o=0;o<i;++o,++n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}else for(let n=s+i-1,r=t,o=0;o<i;++o,--n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}}queryRange(t,e,s,i,n){if((t<0||e<0)&&(0,r.a)(),!i&&(n<=0||e%n!==0)&&(0,r.a)(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+e);s.set(o)}writeRangeFromArray(t,e,s,i,n){if((t<0||e<0)&&(0,r.a)(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let o=s;e<s.length&&(o=s.subarray(0,e)),this.m_a.set(o,t)}clone(){return new L({ctor:Float64Array,copy:this})}restrictedClone(t){return new L({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}const z={partCount:0,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:0,segmentCountBezier:0};class V{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new F(0),this.m_bucketedIndices=new F(0)}static sortEx(t,e,s,i,n=32){s-e<=n?i.userSort(e,s,t):(new V).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let n=e;n<s;n++){const e=i.getValue(t.read(n));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let n=e;n<s;n++){const s=t.read(n),r=i.getValue(s),o=this.getBucket(r);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(n-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let n=e;n<s;n++){const s=this.m_bucketedIndices.read(n-e),r=i.getValue(s),o=this.getBucket(r),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let s=0,n=this.m_buckets.size();s<n;s++){const n=h;h=this.m_buckets.read(s),h>n&&i.userSort(e+n,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(V.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}V.c_maxBuckets=65536;class B{capacity(){return this.capacity_}constructor(t){this.m_buffer=new Int32Array(0),this.m_firstFree=-1,this.m_last=0,this.size_=0,this.capacity_=0,this.stride=t}size(){return this.size_}deleteElement(t){t<this.m_last?(this.m_buffer[t*this.stride]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.size_--}getField(t,e){return this.m_buffer[t*this.stride+e]}setField(t,e,s){this.m_buffer[t*this.stride+e]=s}elementToIndex(t){return t}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}t=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[t*this.stride];this.size_++;for(let e=t*this.stride;e<t*this.stride+this.stride;e++)this.m_buffer[e]=-1;return t}newElementPset(t){let e=this.m_firstFree;if(-1===e){if(this.m_last===this.capacity_){let t=0!==this.capacity_?Math.trunc(3*(this.capacity_+1)/2):1;if(t>Number.MAX_SAFE_INTEGER&&(t=Number.MAX_SAFE_INTEGER),t===this.capacity_)throw new Error("index out of bounds");this.grow_(t)}e=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[e*this.stride];this.size_++;const s=e*this.stride;for(let e=0;e<t.length;e++)this.m_buffer[s+e]=t[e];return e}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.size_=0,t&&(this.m_buffer=new Int32Array(0),this.capacity_=0)}setCapacity(t){t>this.capacity_&&this.grow_(t)}swap(t,e){const s=t*this.stride,i=e*this.stride;for(let t=0;t<this.stride;t++){const e=this.m_buffer[i+t];this.m_buffer[i+t]=this.m_buffer[s+t],this.m_buffer[s+t]=e}}swapField(t,e,s){const i=this.m_buffer[this.stride*e+s];this.m_buffer[this.stride*e+s]=this.m_buffer[this.stride*t+s],this.m_buffer[this.stride*t+s]=i}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}grow_(t){null==this.m_buffer&&(this.m_buffer=new Int32Array(0));const e=this.stride*t,s=new Int32Array(e);s.set(this.m_buffer,0),this.m_buffer=s,this.capacity_=t}}class G{constructor(t,e,s){this.m_extent=new n.Envelope2D,this.m_dataExtent=new n.Envelope2D,this.m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D],this.m_elementNodes=new B(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new B(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){this.m_quadTreeNodes.deleteAll(!1),this.m_elementNodes.deleteAll(!1),this.m_data.length=0,this.m_freeData.length=0,this.reset_(t,e)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,r.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,r.g)(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,r.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,r.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>G.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new n.Envelope2D;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const r=s.length;for(let t=0;t<r;t++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const r=new n.Envelope2D;r.setCoords({env2D:t}),r.inflateCoords(e,e);const o=[],a=[];o.push(this.m_root),a.push(this.m_extent.clone());const h=(0,i.m)(n.Envelope2D,4);let m=0;for(;o.length>0;){let t=!1;const e=o.at(-1),i=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(i)){if(m+=this.getSubTreeElementCount(e),s>0&&m>=s)return s}else if(r.isIntersecting(i)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(r)&&(m++,s>0&&m>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){G.setChildExtents_(i,h);for(let t=0;t<4;t++){const s=this.getChild_(e,t);-1!==s&&this.getSubTreeElementCount_(s)>0&&r.isIntersecting(h[t])&&(o.push(s),a.push(h[t].clone()))}}}return m}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new H(this,t,e)}getIteratorForQT(){return new H(this)}getSortedIterator(t,e){return new k(this.getIterator(t,e))}getSortedIteratorForQT(){return new k(this.getIteratorForQT())}visitLeavesNearest(t,e,s,i){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.a)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,r,o,a){if(!i.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,o,a);if(!o)for(let t=r;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);const h=new n.Envelope2D;h.setCoords({env2D:i});let m,u=r;for(m=s;m<this.m_height&&this.canPushDown_(u);m++){G.setChildExtents_(h,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(u,s);-1===e&&(e=this.createChild_(u,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),u=e,h.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,m,h,u,o,r,a,-1)}insertDuplicates_(t,e,s,r,o,a,h){if(!a){if(!r.containsEnvelope(e))return-1;this.setSubTreeElementCount_(o,this.getSubTreeElementCount_(o)+1),this.setContainedSubTreeElementCount_(o,this.getContainedSubTreeElementCount_(o)+1)}const m=Math.max(e.width(),e.height());let u=-1;const l=[],c=[],g=[];l.push(o),c.push(r.clone()),g.push(s);const d=(0,i.m)(n.Envelope2D,4);for(;l.length>0;){let s=!1;const i=l.at(-1),n=c.at(-1),r=g.at(-1);if(l.pop(),c.pop(),g.pop(),r+1<this.m_height&&this.canPushDown_(i)&&m<=Math.max(n.width(),n.height())/2&&(s=!0),s){G.setChildExtents_(n,d);let t=!1;for(let s=0;s<4;s++)if(t=d[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),l.push(t),c.push(d[s].clone()),g.push(r+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(d[t].isIntersecting(e)){let e=this.getChild_(i,t);-1===e&&(e=this.createChild_(i,t)),l.push(e),c.push(d[t].clone()),g.push(r+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else u=this.insertAtQuad_(t,e,r,n,i,a,o,h,u),a=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let u=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),u=a}else-1===h?(u=this.createElement_(),this.setDataValues_(this.getData_(u),t,e)):u=this.createElementFromDuplicate_(h);return this.setQuad_(u,n),-1!==m?(this.setPrevElement_(u,m),this.setNextElement_(m,u)):this.setFirstElement_(n,u),this.setLastElement_(n,u),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),u}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===G.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const r=new n.Envelope2D;let o=this.getFirstElement_(s),a=-1,h=-1;do{h=this.getData_(o),i=this.getElementValue_(h),r.setCoords({env2D:this.getBoundingBoxValue_(h)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(i,r,t,e,s,!0,o):this.insert_(i,r,t,e,s,!0,o),o=a}while(-1!==o)}canPushDown_(t){return this.getLocalElementCount_(t)>=G.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){(0,r.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&G.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>G.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const i=e<<G.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,s)}}G.m_quadrantMask=3,G.m_heightBitShift=2,G.m_flushingCount=5;class H{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new i.P,this.m_queryEnd=new i.P,this.m_queryBox=new n.Envelope2D,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof n.Envelope2D)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===r.G.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new i.P,e=new i.P,s=new n.Envelope2D;let r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){const i=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(i)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){r=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){r=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),i=this.m_extentsStack.at(-1);G.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let i=0;i<4;i++){const r=this.m_quadTree.getChild_(s,i);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[i].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new n.Envelope2D;s.setCoords({env2D:this.m_childExtents[i]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[i].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[i].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class k{constructor(t){this.m_bucketSort=new V,this.m_sortedHandles=new F(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,(t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,r.g)(0),{}}}class W{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class j{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new B(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||((0,r.g)(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,n,r,o=-1){if(-1===o&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===j.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,h,m,u,l;if(r?(a=e!==j.st_nullNode()?this.m_comparator.compare(this,s,e):-1,h=t!==j.st_nullNode()?this.m_comparator.compare(this,s,t):1):(a=-1,h=1),n&&(0===a||0===h)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===a?e:t;return this.setDuplicateElement_(i,o),-1}l=e!==j.st_nullNode()&&t!==j.st_nullNode()?this.m_random>(0,i.B)(this.m_random)>>1:e!==j.st_nullNode(),l?(u=a,m=e):(u=h,m=t);let c=-1,g=-1,d=!0;for(;;){if(u<0){const t=this.getLeft(m);if(t===j.st_nullNode()){g=m,c=this.newNode_(s),this.setLeft_(m,c),this.setParent_(c,m);break}m=t}else{const t=this.getRight(m);if(t===j.st_nullNode()){g=this.getNext(m),c=this.newNode_(s),this.setRight_(m,c),this.setParent_(c,m);break}m=t}d&&(u*=-1,d=!1)}return this.bubbleUp_(c),this.getParent(c)===j.st_nullNode()&&this.setRoot_(c,o),this.addToList_(g,c,o),c}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==j.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==j.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===j.st_nullNode()&&(this.m_defaultTreap===j.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==j.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),j.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==j.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==j.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=j.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return B.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const n=this.getPriority_(t);for(;e!==j.st_nullNode()||s!==j.st_nullNode();){const r=e!==j.st_nullNode()?this.getPriority_(e):(0,i.j)(),o=s!==j.st_nullNode()?this.getPriority_(s):(0,i.j)();if(n<=Math.min(r,o))return;r<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==j.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==j.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==j.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==j.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==j.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?j.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==j.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,i.B)(this.m_random),this.m_random&(0,i.j)()>>1}maxPriority(){return(0,r.g)(0),0}getMaxDepthHelper_(t){return t===j.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===j.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===j.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===j.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===j.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),n=this.getRight(t),r=this.getParent(t),o=t;if(-1!==s&&-1!==n){let a;this.m_random=(0,i.B)(this.m_random),a=this.m_random>(0,i.j)()>>1?this.getNext(t):this.getPrev(t);const h=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1!==r?this.getLeft(r)===t?this.setLeft_(r,a):this.setRight_(r,a):this.setRoot_(a,e),h?(s===a?(this.setLeft_(a,t),this.setParent_(n,a)):n===a&&(this.setRight_(a,t),this.setParent_(s,a)),this.setParent_(t,a),r=a):(this.setParent_(s,a),this.setParent_(n,a),r=this.getParent(t),o=a),s=this.getLeft(t),n=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==n&&this.setParent_(n,t)}const a=-1!==s?s:n;-1===r?this.setRoot_(a,e):this.getLeft(r)===o?this.setLeft_(r,a):this.setRight_(r,a),-1!==a&&this.setParent_(a,r),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,i.j)());let s=j.st_nullNode(),n=j.st_nullNode();const r=this.getRoot_(e),o=r===t;if(o&&(s=this.getLeft(r),n=this.getRight(r),s===j.st_nullNode()&&n===j.st_nullNode()))return this.removeFromList_(r,e),this.freeNode_(r,e),void this.setRoot_(j.st_nullNode(),e);this.bubbleDown_(t);const a=this.getParent(t);a!==j.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,j.st_nullNode()):this.setRight_(a,j.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(s===j.st_nullNode()||this.getParent(s)!==j.st_nullNode()?n:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===j.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===j.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Z{constructor(t){this.m_lists=new B(6),this.m_listOfLists=Z.st_nullNode(),void 0===t?(this.m_listNodes=new B(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new B(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,r.g)(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){(0,r.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,r.g)(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Z.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Z.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Z.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){(0,r.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,r.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;if(e!==Z.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Z.st_nullNode()&&this.setNext_(n,i),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Z.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Z.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Z.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Z.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,r.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class U extends W{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?O.isLeft_(e)&&O.isRight_(i)?-1:O.isLeft_(i)&&O.isRight_(e)?1:0:1}}class O{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new B(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new B(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new j,this.m_secondaryTreaps.setComparator(new U(this)),this.m_secondaryLists=new Z}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.q)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.q)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new F(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)("");const e=this.m_intervalHandles[t];let s;-1===e&&(0,r.a)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(i),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),i),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),i),s=this.m_secondaryTreaps.size(i),0===s&&(this.m_secondaryTreaps.deleteTreap(i),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(n),a=this.getLptr_(n),h=this.getRptr_(n);for(;!(s>0||n===this.m_root||-1!==a&&-1!==h);)n===this.getLptr_(o)?-1!==a?(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setLptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(o,-1),this.setPptr_(n,-1)):-1!==a?(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==h?(this.setRptr_(o,h),this.setPptr_(h,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(o,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=o,i=this.getSecondaryFromTertiary_(n),s=-1!==i?this.m_secondaryTreaps.size(i):0,a=this.getLptr_(n),h=this.getRptr_(n),o=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof i.E?new Q(this,t,e):((0,r.g)(0),{})}getIterator(){return new Q(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new F(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=(0,i.d)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){const i=e.read(t);let n=s[i>>1];if(-1!==n){const t=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(t,i))}else n=this.insertIntervalEnd_(i,this.m_root),s[i>>1]=n}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const g=this.getMin_(m),d=this.getMax_(m);let _=-1;for(;c;){h=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(_);if(d<e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(g>e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||_!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(_):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&_===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,r.q)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;return s=t<e?t+(e-t>>1)+2:-(t+2),s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new V).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,(t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&O.isLeft_(t)&&O.isRight_(e)?-1:1})}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return O.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return O.isLeft_(t)?e.xmin:e.xmax}}class Q{constructor(t,e,s){this.m_query=i.E.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return(0,r.d)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new i.E;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||(0,r.q)(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&O.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class ${constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new F(0),this.m_sortedEndIndicesBlue=new F(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Z,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new n.Envelope2D(e))}endConstruction(){this.m_bAddRedRed||(0,r.q)(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.q)(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||(0,r.q)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.q)(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new O(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new O(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new O(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=i.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&((0,i.w)(this.m_queuedIndicesRed,this.m_envelopesRed.length,-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=i.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&((0,i.w)(this.m_queuedIndicesBlue,this.m_envelopesBlue.length,-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.d)("should not be called"),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new V).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,(t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1})}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}var K=g;class J{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new J(this.tolerance+t,this.resolution)}scale(t){return new J(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function tt(t,e,s,n,r){const o=n*n,a=t.sub(e),h=s.sub(e),m=a.sqrLength(),u=h.sqrLength();if(m<=o||u<=o)return!0;const l=(0,i.a)(a.crossProduct(h));return(l<=o*m||l<=o*u)&&a.dotProduct(h)>=0}function et(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function st(t,e){const s=new n.Envelope2D;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function it(t,e){const s=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s);const i=n.Envelope2D.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function nt(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function rt(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function ot(t,e,s){const i=n.Envelope2D.constructEmpty();return i.setFromPoints(t,e),gt(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function at(t,e,s){return gt(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function ht(t,e,s){return gt(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function mt(t,e,s){return ht(t,e.queryInterval(1,0),s)}function ut(t,e,s){const i=n.Envelope2D.constructEmpty();return e.queryEnvelope(i),at(t,i,s)}function lt(t,e,s=!1){return gt(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ct(t,e,s){const i=n.Envelope2D.constructEmpty();return e.queryEnvelope(i),lt(t,i,s)}function gt(t,e,s,i,n){const r=new J(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}return i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01),r.total()<s?new J(s,0):r}function dt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function _t(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function pt(t){return t>=3}function ft(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function xt(t,e){t.getImpl().setIsSimple(3,e)}function Pt(t,e,s,n){if((0,i.a)(e.x-t.x)+(0,i.a)(e.y-t.y)<=s*s){const s=t.z,r=e.z;return(0,i.G)(s,r,n)}return!1}function yt(t){return t>=4}function vt(t,e){return t===r.G.enumPolygon?pt(e):e>=1}function Ct(t,e,s){const i=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=e.querySegmentIterator(),m=n.Envelope2D.constructEmpty(),u=n.Envelope2D.constructEmpty(),l=new $;l.setTolerance(s);let c=!1;for(l.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(o)&&(c=!0,l.addRedEnvelope(a.getStartPointIndex(),m));if(l.endRedConstruction(),!c)return null;let g=!1;for(l.startBlueConstruction();h.nextPath();)for(;h.hasNextSegment();)h.nextSegment().queryLooseEnvelope(u),u.isIntersecting(o)&&(g=!0,l.addBlueEnvelope(h.getStartPointIndex(),u));return l.endBlueConstruction(),g?l:null}function Et(t,e,s,i,r){t.getGeometryType(),e.getGeometryType();const o=n.Envelope2D.constructEmpty(),a=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(s,s),a.inflateCoords(s,s);const h=n.Envelope2D.constructEmpty();h.setCoords({env2D:o}),h.intersect(a);const m=new $;m.setTolerance(s);let u=!1;m.startRedConstruction();for(let e=0,s=t.getPathCount();e<s;e++)t.queryLoosePathEnvelope(e,o),o.isIntersecting(h)&&(u=!0,m.addRedEnvelope(e,o));if(m.endRedConstruction(),!u)return null;let l=!1;m.startBlueConstruction();for(let t=0,s=e.getPathCount();t<s;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(h)&&(l=!0,m.addBlueEnvelope(t,a));return m.endBlueConstruction(),l?m:null}function bt(t,e,s){const i=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const o=n.Envelope2D.constructEmpty();o.setCoords({env2D:i}),o.intersect(r);const a=t.querySegmentIterator(),h=new $;h.setTolerance(s);let m=!1;for(h.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(i),i.isIntersecting(o)&&(m=!0,h.addRedEnvelope(a.getStartPointIndex(),i));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let t=0,s=e.getPointCount();t<s;t++){const s=e.getXY(t);o.contains(s)&&(u=!0,h.addBlueEnvelope(t,n.Envelope2D.construct(s.x,s.y,s.x,s.y)))}return h.endBlueConstruction(),u?h:null}function Dt(t,e,s){const r=n.Envelope2D.constructEmpty(),o=n.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=n.Envelope2D.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new $;h.setTolerance(s);let m=!1;h.startRedConstruction();const u=new i.P;for(let e=0,s=t.getPointCount();e<s;e++)t.queryXY(e,u),a.contains(u)&&(m=!0,h.addRedEnvelope(e,n.Envelope2D.construct(u.x,u.y,u.x,u.y)));if(h.endRedConstruction(),!m)return null;let l=!1;h.startBlueConstruction();const c=new i.P;for(let t=0,s=e.getPointCount();t<s;t++)e.queryXY(t,c),a.contains(c)&&(l=!0,h.addBlueEnvelope(t,n.Envelope2D.construct(c.x,c.y,c.x,c.y)));return h.endBlueConstruction(),l?h:null}function St(t){const e=new n.Envelope2D;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){const s=new n.Envelope2D;if(t.queryLooseEnvelope(s),s.isEmpty())return null;t.getGeometryType();const i=new G(s,8);let o=-1;const a=new n.Envelope2D;let h=!1;do{for(let n=0,m=t.getPathCount();n<m;n++)if(t.queryLoosePathEnvelope(n,a),a.isIntersecting(e)){if(o=i.insertEx(n,a,o),-1===o){h&&(0,r.d)("build_quad_tree_for_paths"),s.assign(t.calculateEnvelope2D(!1)),h=!0,i.reset(s,8);break}h=!1}}while(h);return i}(t,e)}function wt(t,e){if(!e){const e=new n.Envelope2D;t.queryLooseEnvelope(e);const s=new G(e,8);let i=-1;const o=new n.Envelope2D,a=t.querySegmentIterator();let h=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const n=a.nextSegment(),m=a.getStartPointIndex();if(n.queryLooseEnvelope(o),i=s.insertEx(m,o,i),-1===i){h&&(0,r.d)(""),e.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(e,8),a.resetToFirstPath();break}}return s}const s=new n.Envelope2D;t.queryLooseEnvelope(s);const i=new G(s,8);let o=-1;const a=new n.Envelope2D,h=t.querySegmentIterator();let m=!1;for(;h.nextPath();)for(;h.hasNextSegment();){const n=h.nextSegment(),u=h.getStartPointIndex();if(n.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=i.insertEx(u,a,o),-1===o)){m&&(0,r.d)(""),s.assign(t.calculateEnvelope2D(!1)),m=!0,i.reset(s,8),h.resetToFirstPath();break}}return i}function At(t,e){if(e){const s=new G(e,8),o=new i.P,a=new n.Envelope2D;let h=!1;for(let i=0;i<t.getPointCount();i++)o.setCoordsPoint2D(t.getXY(i)),e.contains(o)&&(a.setCoords({pt:o}),-1!==s.insert(i,a)||(h&&(0,r.d)(""),h=!0,s.reset(t.calculateEnvelope2D(),8),i=-1));return s}return(0,r.t)("no-extent version not yet impl"),null}function Tt(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let n=s;n<e;n+=i){const e=t.read(n);e<o?(r=!0,t.write(n,o)):e>a&&(r=!0,t.write(n,a))}return r}function It(t,e,s,i){if(!t.hasAttribute(s))return!1;const n=t.getGeometryType();if(n===r.G.enumGeometryCollection){const n=t,r=n.getGeometryCount();let o=0;for(let t=0;t<r;++t)o|=It(n.getGeometry(t),e,s,i)?1:0;return!!o}if((0,r.i)(n)){const n=t,o=K.getPersistence(s),a=K.getComponentCount(s),h=n.getPointCount();if(1===o){const t=Tt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}if(2===o){const t=Tt(n.getAttributeStreamRef(s),h*a,i,a,e);return t&&n.notifyModified(),t}(0,r.d)("snap_coordinate not implemented")}if(n===r.G.enumEnvelope){const n=t,r=n.queryInterval(s,i);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&n.setIntervalEnvelope(s,i,r),o}if(n===r.G.enumPoint){const n=t;let r=n.getAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setAttributeBasic(s,i,r),o}if((0,r.f)(n)){const n=t;let r=n.getStartAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setStartAttribute(s,i,r),r=n.getEndAttributeAsDbl(s,i),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setEndAttribute(s,i,r),o}(0,r.d)("snap_coordinate not implemented")}var Nt=g;class qt{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=v(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=C(),this.ensureAttributes(),this.setXYZ(new b(t.x,t.y,t.z))):(this.m_description=v(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=v()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new i.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new b;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Nt.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;(0,r.r)("")}const s=Nt.getComponentCount(t);(e<0||e>=s)&&(0,r.r)("");const i=this.m_description.getAttributeIndex(t);return i>=0?this.m_attribs[this.m_description.getPointAttributeOffset(i)-2+e]:Nt.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:(0,r.r)(""));const i=Nt.getComponentCount(t);(e<0||e>=i)&&(0,r.r)("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=Nt.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=v();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof Ft)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof D){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new i.E;if(this.isEmpty())return s.setEmpty(),s;const n=this.getAttributeAsDbl(t,e);return s.vmin=n,s.vmax=n,s}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){const e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,r.t)("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=et(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new qt({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=v(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&(0,i.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.G.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let t=0,n=this.m_description.getTotalComponentCount()-2;t<n;t++)if(!(0,i.G)(this.m_attribs[t],s.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){const t=new qt({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,i.c)(this.m_description,this.m_description=e.m_description),e.x=(0,i.c)(this.x,this.x=e.x),e.y=(0,i.c)(this.y,this.y=e.y),e.m_attribs=(0,i.c)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Nt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,e,s){if(t.getDescription()!==e.getDescription()&&(0,r.a)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const n=c();t.queryValues(n,n.length);const o=c();e.queryValues(o,o.length);const a=c();let h=n,m=o;const u=a;let l=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),n=Nt.getInterpolation(e),r=Nt.getComponentCount(e),o=Nt.getDefaultValue(e);(0,i.A)(n,h,m,u,l,r,s,o),h=h.slice(r),m=m.slice(r),l+=r}return this.setValues(a,l),this}static lerp(t,e,s,i){i.lerp(t,e,s)}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,i.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return i.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=v());const e=_();E(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=Nt.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),t[0]=this.x,t[1]=this.y,(0,i.b)(t,this.m_attribs,2,0,s-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,i.b)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=Nt.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Nt.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const s=this.m_description.getTotalComponentCount();(0,r.g)(s<=e),this.x=t[0],this.y=t[1],(0,i.b)(this.m_attribs,t,0,2,s-2)}dbgDefaultAttribs(){}toFlatGeometry(){const t=Float64Array.of(this.getX(),this.getY(),this.getZ(),this.getM());return{type:"point",vertexCount:1,vertexXY:t.subarray(0,2),vertexZ:this.hasAttribute(1)?t.subarray(2,3):void 0,vertexM:this.hasAttribute(2)?t.subarray(3,4):void 0,...z}}}qt.type=r.G.enumPoint;var Mt=g;function Yt(t,e){return e*(t.getTotalComponentCount()-2)}class Xt{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new n.Envelope2D(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new n.Envelope2D(t.env2D);else if(t.move)this.m_envelope2D=new n.Envelope2D(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new n.Envelope2D(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=n.Envelope2D.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=(0,i.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const s=e,o=t.getTotalComponentCount()-2;if(s.m_description!==t&&(s.releaseAttributes_(),s.m_description=t,o&&(s.m_data.m_attributes=(0,i.d)(2*o,Number.NaN))),o){(0,r.g)(this.m_attributes&&s.m_data.m_attributes);const t=2*o;(0,i.b)(s.m_data.m_attributes,this.m_attributes,0,0,t)}s.m_data.m_envelope2D=new n.Envelope2D(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new n.Envelope2D(this.m_envelope2D),e.releaseAttributes(),t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,s,i,n){(0,r.g)(0)}queryInterval(t,e,s,i){if(this.isEmpty())return void i.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(i):1===s?this.m_envelope2D.queryIntervalY(i):(0,r.r)(""));const n=Mt.getComponentCount(e);(s<0||s>=n)&&(0,r.r)("");const o=t.getAttributeIndex(e);if(o>=0)return i.vmin=this.m_attributes[Yt(t,0)+t.getPointAttributeOffset(o)-2+s],void(i.vmax=this.m_attributes[Yt(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=Mt.getDefaultValue(e);return void i.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new i.E;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=(0,i.d)(2*e,Number.NaN),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}let Ft=class t{constructor(t){if(this.m_EnvelopeType=4,this.m_description=v(),void 0===t)this.m_data=new Xt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Xt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Xt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Xt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Xt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Xt({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Xt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Xt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,s,i,n){(0,r.g)(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=x(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new n.Envelope2D(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.G.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new i.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=Mt.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof n.Envelope2D)this.m_data.m_envelope2D=new n.Envelope2D(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=i.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof n.Envelope2D)return e.isValid()||(0,r.a)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(e);if(e instanceof t){if(e.m_data.isEmpty())return;const t=e.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(e.m_data.m_envelope2D);for(let s=1,i=t.getAttributeCount();s<i;s++){const i=t.getSemantics(s),n=Mt.getComponentCount(i);for(let t=0;t<n;t++){const s=e.queryInterval(i,t),n=this.queryInterval(i,t);n.merge(s),this.setIntervalEnvelope(i,t,n)}}return}if(e instanceof qt){const t=e;if(t.isEmpty())return;const s=t.getDescription();if(this.mergeVertexDescription(s),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let e=1,i=s.getAttributeCount();e<i;e++){const i=s.getSemantics(e),n=Mt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.getAttributeAsDbl(i,e),n=this.queryInterval(i,e);n.mergeCoordinate(s),this.setIntervalEnvelope(i,e,n)}}return}(0,r.t)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=Mt.getComponentCount(s);for(let e=0;e<i;e++){const i=t.queryInterval(s,e),n=this.queryInterval(s,e);n.intersect(i),this.setIntervalEnvelope(s,e,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=Mt.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=new i.E(s);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):(0,r.r)("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,s,n){this.setIntervalEnvelope(t,e,new i.E(s,n))}queryInterval(t,e){const s=new i.E;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,r.t)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,r.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new t({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=v()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,r.g)(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,n=2*(this.m_description.getTotalComponentCount()-2);t<n;t++)if(!(0,i.G)(this.m_data.m_attributes[t],s.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.t)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new t({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumEnvelope&&(0,r.a)("wrong geometry type");const e=t;e.m_description=(0,i.c)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,i.c)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,i.c)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.a)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.r)(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=Mt.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=v();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=Mt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let e=1,s=i.getAttributeCount();e<s;e++){const s=i.getSemantics(e),n=Mt.getComponentCount(s);for(let e=0;e<n;e++){const i=t.getAttributeAsDbl(s,e);this.setInterval(s,e,i,i)}}}assignVertexDescriptionImpl(t){const e=_();E(t,this.m_description,e);let s=null;const n=t.getTotalComponentCount()-2,r=this.m_description?this.m_description.getTotalComponentCount()-2:0;n>0&&(s=(0,i.d)(2*n,Number.NaN));for(let o=1;o<t.getAttributeCount();o++){const a=e[o];if(-1!==a){const e=t.getPointAttributeOffset(o)-2,h=Mt.getComponentCount(t.getSemantics(o)),m=this.m_description.getPointAttributeOffset(a)-2;(0,i.b)(s,this.m_data.m_attributes,e,m,h),(0,i.b)(s,this.m_data.m_attributes,n+e,r+m,h)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&(0,r.u)(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=Mt.getComponentCount(e)&&(0,r.r)("");const i=this.m_description.getAttributeIndex(e);return i>=0?this.m_data.m_attributes[Yt(this.m_description,t)+this.m_description.getPointAttributeOffset(i)-2+s]:g.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,i){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=i:0===s?this.m_data.m_envelope2D.xmax=i:(0,r.r)(""):1===s?this.m_data.m_envelope2D.ymin=i:0===s?this.m_data.m_envelope2D.xmin=i:(0,r.r)(""));const n=Mt.getComponentCount(e);(s<0||s>=n)&&(0,r.r)(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[Yt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=i}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}};Ft.type=r.G.enumEnvelope,Object.freeze(Object.defineProperty({__proto__:null,Envelope:Ft,EnvelopeData:Xt},Symbol.toStringTag,{value:"Module"}))},79187(t,e,s){s.r(e),s.d(e,{Envelope2D:()=>r});var i=s(55537),n=s(83661);class r{static construct(t,e,s,i){return new r(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new r(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new r(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return n.P.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(t){void 0!==t.xmin?(this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax):void 0!==t.x?(this.xmin=t.x,this.xmax=t.x,this.ymin=t.y,this.ymax=t.y):void 0!==t.pt1?(this.xmin=t.pt1.x,this.ymin=t.pt1.y,this.xmax=t.pt2.x,this.ymax=t.pt2.y,this.normalize()):void 0!==t.env2D?(this.xmin=t.env2D.xmin,this.xmax=t.env2D.xmax,this.ymin=t.env2D.ymin,this.ymax=t.env2D.ymax,this.normalize()):void 0!==t.pt?(this.xmin=t.pt.x,this.xmax=t.pt.x,this.ymin=t.pt.y,this.ymax=t.pt.y):void 0!==t.center?(this.xmin=t.center.x-.5*t.width,this.xmax=this.xmin+t.width,this.ymin=t.center.y-.5*t.height,this.ymax=this.ymin+t.height,this.normalize()):(0,i.t)("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let t=1,i=2*e;t<i;t+=2){if(!this.isEmpty()){for(let i=t,n=2*e;i<n;i+=2)this.mergeNeCoords(s[i],s[i+1]);return}this.setCoords({x:s[t],y:s[t+1]}),t+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new n.P(this.xmin,this.ymin)}getLowerRight(){return new n.P(this.xmax,this.ymin)}getUpperLeft(){return new n.P(this.xmin,this.ymax)}getUpperRight(){return new n.P(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new n.P(this.xmin,this.ymin);case 1:return new n.P(this.xmin,this.ymax);case 2:return new n.P(this.xmax,this.ymax);default:return new n.P(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,o=e.y-t.y;if(Math.abs(n)>Math.abs(o)?s&r.XMASK?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&r.XMASK?(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s&r.YMASK?(s&r.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/o,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/o,t.y=this.ymax),s=this.clipCode(t)):i&r.YMASK?(i&r.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/o,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/o,e.y=this.ymax),i=this.clipCode(e)):s?(s&r.XLESSXMIN?(t.y+=o*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=o*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&r.XLESSXMIN?(e.y+=o*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=o*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),o=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),o=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=(0,n.m)(n.P,4);this.queryCorners(s);const i=(0,n.m)(n.P,4);t.queryCorners(i);for(let t=0;t<4;t++)for(let r=0;r<4;r++){const o=n.P.sqrDistance(s[t],i[r]);o>e&&(e=o)}return e}sqrMaxMinDistance(t){const e=n.P.sqrDistance(t,this.getLowerLeft()),s=n.P.sqrDistance(t,this.getUpperLeft()),i=n.P.sqrDistance(t,this.getLowerRight()),r=n.P.sqrDistance(t,this.getUpperRight());let o,a=Math.max(e,s);return o=Math.max(e,i),a>o&&(a=o),o=Math.max(s,r),a>o&&(a=o),o=Math.max(i,r),a>o&&(a=o),a}sqrMinDistance(t){return this.contains(t)?0:this.sqrDistance(t)}sqrMaxDistance(t){let e=n.P.sqrDistance(t,this.getLowerLeft());return e=Math.max(n.P.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(n.P.sqrDistance(t,this.getUpperRight()),e),e=Math.max(n.P.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=(0,n.s)(t.x,this.xmin,this.xmax),s=(0,n.s)(t.y,this.ymin,this.ymax);return n.P.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new n.P;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:(0,i.a)("query_side")}return e}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){return this.isEmpty()?(0,n.g)():(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*(0,n.g)()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}r.XLESSXMIN=1,r.YLESSYMIN=4,r.XMASK=3,r.YMASK=12},88885(t,e,s){s.d(e,{$:()=>B,A:()=>lr,B:()=>ir,C:()=>fs,D:()=>Yn,E:()=>ls,F:()=>Vn,H:()=>xt,I:()=>dt,J:()=>_t,K:()=>wt,L:()=>Fr,M:()=>_,N:()=>qn,O:()=>Mn,P:()=>rs,Q:()=>Sr,R:()=>w,S:()=>Rr,T:()=>Ut,U:()=>dn,V:()=>_r,W:()=>j,X:()=>ms,Y:()=>wr,Z:()=>Ir,_:()=>y,a:()=>Dt,a0:()=>nt,a1:()=>Ar,a2:()=>Tr,a3:()=>Mr,a4:()=>An,a5:()=>C,a6:()=>jn,a7:()=>us,a8:()=>u,a9:()=>Dn,b:()=>bn,c:()=>At,d:()=>Nn,e:()=>_s,f:()=>cs,g:()=>O,i:()=>ds,l:()=>In,n:()=>as,s:()=>l,x:()=>fe,y:()=>Ci,z:()=>ur});var i=s(55537),n=s(95213),r=s(83661),o=s(79187),a=s(11878),h=s(61691);class m{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function u(t,e,s){if(t)for(let t=e.length-1;t>=0;--t)s(e[t]);else e.forEach(s)}function l(t,e){let s=(0,r.B)(t);const i=e.length/(0,r.i)();for(let t=0;t<e.length;++t){const t=Math.trunc(s*i);s=(0,r.B)(s);const n=Math.trunc(s*i),o=e[t];e[t]=e[n],e[n]=o}}var c=n.V;const g="can not assign an empty point to a vertex";class d{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,n.l)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new m,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new n.m,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:(0,n.l)();this.m_description=e,this.m_vertexAttributes=new m,this.m_envelopeData=new n.m,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,i.i)(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const i=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(i),o=s.getAttributeStreamRef(i),a=c.getComponentCount(i);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,r,o){if(this.addAttribute(t),!this.isEmpty()&&(0!==s||1!==r)){if(0===t){const t=new a.T;return 0===o?0===e?(t.setShiftCoords(s,0),t.scale(r,1)):1===e?(t.setShiftCoords(0,s),t.scale(1,r)):(0,i.a)(""):0===e?(t.setScaleCoords(1/r,1),t.shiftCoords(-s,0)):1===e?(t.setScaleCoords(1,1/r),t.shiftCoords(0,-s)):(0,i.a)(""),void this.applyTransformation(t)}(function(t,e,s,n,r){(e<0||s<0||n<1||e+n*(s-1)+1>t.size())&&(0,i.a)("Index out of bound");for(let i=e,o=e+n*(s-1)+1;i<o;i+=n)t.writeAsDbl(i,r(t.readAsDbl(i)))})(this.getAttributeStreamRef(t),e,this.getPointCount(),c.getComponentCount(t),(0,n.x)(s,r,o)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,i.a)("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,i.a)("stream"),e&&c.getPersistence(t)!==e.getPersistence()&&(0,i.a)(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){const i=this.m_description.getSemantics(e);for(let n=0,r=c.getComponentCount(i);n<r;n++){const o=this.m_vertexAttributes.get(e).readAsDbl(r*t+n);s.setAttributeBasic(i,n,o)}}}setPointByValNoCurves(t,e){const s=e;s.isEmpty()&&(0,i.a)(g);const n=s.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,s.getX()),r.write(2*t+1,s.getY());for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),n=c.getComponentCount(i);for(let r=0;r<n;r++){const o=s.getAttributeAsDbl(i,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,s,n){(0,i.g)(0)}getPointByValAsArray(t,e,s,n){(0,i.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=c.getComponentCount(t);s>=n&&(0,i.r)("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):c.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=c.getComponentCount(t);n<r&&(0,i.r)("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=c.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}setAttributeNoCurves(t,e,s,n){const r=c.getComponentCount(t);s>=r&&(0,i.r)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArrayNoCurves(t,e,s,n){(e<0||e>=this.m_pointCount)&&(0,i.r)("");const r=c.getComponentCount(t);n<r&&(0,i.r)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let t=0;t<r;++t)a.writeAsDbl(e*r+t,s[t])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=n.f.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=c.getDefaultValue(1),s}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.Envelope2D||t instanceof n.p?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=r.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let i=!1;const n=c.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let t=e,o=this.m_pointCount*n;t<o;t+=n)r.readAsDbl(t)!==s&&(r.writeAsDbl(t,s),i=!0);i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=c.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let t=0;t<i;t++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,r=this.m_pointCount*i;t<r;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,i.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,i.a)(""),this.m_envelopeData=new n.m({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,i.a)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*s,i=2*r,n=0;e<i;e+=2,n++)o.queryPoint2D(e,t[n]);return r}queryCoordinates3D(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=c.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=s;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;return 1&i||(s=(14&i)>>1,e[0]=n,n<t&&(s=-1)),s}setIsSimple(t,e,s=!1){if(2===t?(0,i.g)(this.getGeometryType()===i.G.enumPolyline):1===t?(0,i.g)(this.getGeometryType()===i.G.enumMultiPoint||this.getGeometryType()===i.G.enumPolyline):3===t&&(0,i.g)(this.getGeometryType()===i.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let i=t<<1;s||(i|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,i),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&(0,i.s)("Cannot do shallow clone on unprepared geometry");const s=t,n=this.getGeometryType(),r=s.getGeometryType();(0,i.g)(n===r||n===i.G.enumPolygon&&r===i.G.enumPolyline,"failure in copyToUnchcked"),s.clearAccelerators(),s.m_description=this.m_description,s.m_vertexAttributes.destroyAndSetSize(0),s.m_envelopeData.releaseAttributes();const o=this.m_description.getAttributeCount(),a=new m;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{const e=c.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,s.m_envelopeData),s.m_flags=this.m_flags,s.m_simpleTolerance=this.m_simpleTolerance,n!==r){const t=[Number.NaN];s.getIsSimple(0,t)>=3?s.setIsSimple(1,t[0]):s.setIsSimple(-1,0)}s.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),s.m_pointCount=this.m_pointCount,s.hasDirtyFlag(32)||s.m_vertexAttributes.empty()?((0,i.g)(!e||0===s.m_pointCount),s.m_reservedPointCount=-1):s.m_reservedPointCount=s.m_pointCount;try{this.copyToImpl(s,e)}catch(t){throw s.setEmpty(),t}s.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,o){(t<0||t>=this.m_pointCount)&&(0,i.r)(""),(e<0||e>=this.m_pointCount)&&(0,i.r)(""),o.assignVertexDescription(this.m_description);const a=(0,r.d)(c.maxComponentCount(),Number.NaN),h=(0,r.d)(c.maxComponentCount(),Number.NaN),m=(0,n.q)();let u=0;for(let o=0;o<this.m_description.getAttributeCount();o++){const l=this.m_description.getSemantics(o),g=c.getInterpolation(l),d=c.getComponentCount(l),_=c.getDefaultValue(l);this.queryAttributeAsDbl(l,t,a,d),this.queryAttributeAsDbl(l,e,h,d),(0,i.g)(u+d<=n.O),(0,r.A)(g,a,h,m,u,d,s,_),u+=d}!function(t,e){const s=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,r.b)(t.getAttributeArray(),e,0,2,s-2)}(o,m)}getShortestDistance(t,e){return r.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return r.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,i.a)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=(0,n.t)();(0,n.u)(t,this.m_description,e);const s=new m;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return 0!==(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const i=this.m_description.getSemantics(s);let r=0;if(null!==this.m_vertexAttributes.get(s)){const t=c.getComponentCount(i);r=this.m_vertexAttributes.get(s).size()/t,r<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,c.getDefaultValue(i)),r=e)}else this.m_vertexAttributes.set(s,(0,n.v)(i,e)),r=e;r<t&&(t=r)}this.m_reservedPointCount=t}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new n.E({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=c.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const o=new r.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);o.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new n.m({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=o.Envelope2D.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){(0,i.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.Envelope2D?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&(0,i.a)(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,n.w)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*s),s=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,n.w)(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=c.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,(0,n.w)(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&(0,i.a)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,i.u)("")}exportVertexAttributes(){const t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),s=this.m_description.getAttributeIndex(2),i=this.m_vertexAttributes.posStream,n=e>0?this.m_vertexAttributes.get(e):void 0,r=s>0?this.m_vertexAttributes.get(s):void 0,o=i?.getArray()??new Float64Array,a=n?.getArray(),h=r?.getArray();return{vertexCount:t,vertexXY:o,vertexZ:a,vertexM:h}}}class _ extends d{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,e){t>this.getPointCount()&&(0,i.a)("invalid point index"),t<0&&(t=this.getPointCount());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(0===r)this.m_vertexAttributes.get(i).insert(o*t,e,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,i.a)(g),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=n.V.getComponentCount(r);if(e.hasAttribute(r))this.m_vertexAttributes.get(i).insertAttributes(o*t,e,r,o*s);else{const e=n.V.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*s)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.r)(""),t<0&&(t=this.getPointCount()),0===s)return;const r=e[0].getDescription();this.mergeVertexDescription(r);const o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,a=this.m_description.getAttributeCount();i<a;i++){const a=this.m_description.getSemantics(i),h=n.V.getComponentCount(a);if(this.m_vertexAttributes.get(i))if(r.hasAttribute(a))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*h,e,s,a,o*h);else{const e=n.V.getDefaultValue(a);this.m_vertexAttributes.get(i).insertRange(h*t,e,h*s,h*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.a)("invalid point index"),t<0&&(t=this.getPointCount()),0===s)return;const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=n.V.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(0===o)this.m_vertexAttributes.get(i).insertRangeFromPoints(a*t,e,0,s,!0,a*r);else{const e=n.V.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a,a*r)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,i.r)("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i);this.m_vertexAttributes.get(s).eraseRange(r*t,r*e,r*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),i=n.V.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=n.V.getDefaultValue(s),r=n.V.getComponentCount(s);this.m_vertexAttributes.get(t).insertRange(r*e,i,r*(this.m_pointCount-e),r*e)}}queryCoordinates3D(t,e,s,r){let o=r<0?this.m_pointCount:r;if(o=Math.min(o,s+e),(s<0||o<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.a)(""),0===this.m_pointCount)return o;const a=this.getAttributeStreamRef(0);let h=null;const m=n.V.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(h=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<o;e++,l++)t[l].x=a.read(2*e),t[l].y=a.read(2*e+1),t[l].z=u?h.read(e):m;return o}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}add(t){t.isEmpty()&&(0,i.a)(g),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new r.P(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new n.f;i.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,s){this===t&&(0,i.a)("Multi_point_impl.add");const r=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||r<e)&&(0,i.a)(""),e===r)return;const o=t.getDescription();this.mergeVertexDescription(o);const a=r-e,h=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let s=0,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=n.V.getComponentCount(i),m=this.getAttributeStreamRef(i);if(o.hasAttribute(i)){const s=t.getAttributeStreamRef(i);m.insertRangeFromStream(h*r,s,e*r,a*r,!0,1,h*r)}else{const t=n.V.getDefaultValue(i);m.insertRange(h*r,t,a*r,h*r)}}}addPoints2D(t,e,s,n){let r=e;const o=n<0?r:n;if((r<0||s<0||s>r||o<s)&&(0,i.a)(""),s===o)return;r=o-s;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[s+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,s,n){let o=e;const a=n<0?o:n;if((o<0||s<0||s>o||a<s)&&(0,i.a)(""),this.addAttribute(1),s===a)return;o=a-s;const h=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);const m=this.getAttributeStreamRef(0),u=new r.P;for(let e=0;e<o;e++)u.x=t[s+e].x,u.y=t[s+e].y,m.writePoint2D(2*(h+e),u);const l=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)l.write(h+e,t[s+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,i){this.setAttributeNoCurves(t,e,s,i)}getGeometryType(){return i.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new _({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,i.t)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.G.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):(0,i.t)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){(0,i.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...n.y}}}_.type=i.G.enumMultiPoint;class p{constructor(){this.m_EnvelopeType=5,this.envAabb=o.Envelope2D.constructEmpty(),this.envRot=o.Envelope2D.constructEmpty()}static constructEmpty(){return new p}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:f(t),y:x(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(f(t),x(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=f(t[i]),s=x(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=f(t[s]),i=x(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(f(t),x(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*(0,r.D)();this.envRot.inflateCoords(e,e),e<0&&p.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(P(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(P(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(P(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=function(t,e){return t-e}(t.x,t.y),i=function(t,e){return t+e}(t.x,t.y);e.setCoords(s,i)}}function f(t){return t.x-t.y}function x(t){return t.x+t.y}function P(t){return new r.P(f(t),x(t))}class y{constructor(){this.x=r.H.getNAN(),this.y=r.H.getNAN()}static getNAN(){return new y}static constructPoint2D(t){const e=new y;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new y;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new y;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new y).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new y;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new y;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=r.I.clone(),this.y=r.J.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return r.P.construct(this.x.value(),this.y.value())}}class v{constructor(){this.a11=new r.H(1),this.a12=new r.H(0),this.a21=new r.H(0),this.a22=new r.H(1)}clone(){const t=new v;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,r.c)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new r.H(1),n=new r.H(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new r.H(1);if(this.a11.ne(this.a22)){const o=this.a11.subE(this.a22).divE(s);o.mulThisByPower2(.5);const a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(r.J)&&e.negateThis();const h=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(h),i.setE(h);const m=e.mulE(s);t[0]=this.a11.addE(m),t[1]=this.a22.subE(m)}else i=new r.H(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,r.c)(t[0],t[0]=t[1]),e[1]=(0,r.c)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class C{static constructPoint2D(t){return new C(r.M.constructDouble(t.x),r.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new r.M).setNAN(),void(this.y=(new r.M).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new r.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new C(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new C(this.x.add(t.x),this.y.add(t.y))}sub(t){return new C(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var E=n.V;function b(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[3][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),(0,r.F)(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),(0,r.F)(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),(0,r.F)(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),(0,r.F)(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function D(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function S(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function w(t,e,s){const n=(0,r.m)(r.P,4);let o=t.queryControlPointsHelper(n);const a=(0,r.m)(r.P,4);let h=e.queryControlPointsHelper(a);n[0].equals(a[0])||(0,i.w)("");const m=t.getGeometryType();if(m===e.getGeometryType()&&n.map((t,e)=>a[e].equals(t)).reduce((t,e)=>t&&e)){if(m!==i.G.enumRationalBezier2)return 0;{const s=e,i=[0,0,0],n=[0,0,0];if(t.queryWeights(i),s.queryWeights(n),i.map((t,e)=>n[e]===t).reduce((t,e)=>t&&e))return 0}}for(;o>2&&n[1].equals(n[0]);)n.splice(1,1),o--;for(;h>2&&a[1].equals(a[0]);)a.splice(1,1),h--;(n[1].equals(n[0])||a[1].equals(n[0]))&&(0,i.w)("");const u=r.P.compareVectorsOrigin(n[0],n[1],a[1]);if(0===u){const s=C.constructPoint2D(n[0]),i=new C;t.queryCoord2DMP(1e-16,i),i.sub(s);const r=new C;return e.queryCoord2DMP(1e-16,r),r.sub(s),r.crossProduct(i).sign()}return u}function A(t,e,s,n,o,a,h,m){let u=t.calculateUpperLength2D(),l=e.calculateUpperLength2D(),c=t,g=e,d=!1;u>l&&(g=(0,r.c)(c,c=g),n=(0,r.c)(s,s=n),l=(0,r.c)(u,u=l),d=!0);const _=0===s;{h[0]=_?1:0;const t=c.getCoord2D(h[0]);m[0]=g.getClosestCoordinate(t,!1);const e=g.getCoord2D(m[0]);if(r.P.distance(t,e)<=o){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(c.getCoord2D(e[i])),!g.isCloserThanDistance(t,new r.E(0,1),o)){s=!1;break}if(s)return d&&(m[0]=(0,r.c)(h[0],h[0]=m[0])),1}}if(u<=3*o)return 0;let p=(0,r.s)(Math.max(o/u,.1),0,.5),f=.01*o,x=0,P=0,y=p,v=-1,C=0,E=1/32;for(let t=0;;t++){(0,i.g)(t<4095);const e=_?p:1-p,s=c.getCoord2D(e),u=g.getClosestCoordinate(s,!1);if(u===n)return C;const l=g.getCoord2D(u),b=r.P.distance(s,l);if(0===t&&(v=b),b<=f?(E=.5,P=b,x=p):(y=p,v=b),Math.abs(P-v)>.1*f&&y-x>1e-16)p=(0,r.q)(x,y,E);else{if(h[C]=e,m[C]=u,d&&(m[C]=(0,r.c)(h[C],h[C]=m[C])),1===a||1===C)return 1===C&&h[0]>h[1]&&(h[1]=(0,r.c)(h[0],h[0]=h[1]),m[1]=(0,r.c)(m[0],m[0]=m[1])),C+1;C++,x=y,P=v,y=.8,v=-1,p=.8,E=1/32,f=10*o,t=0}}}function T(t,e,s,i,n,o,a,h,m){if((0,r.N)(s,0,1)&&(0,r.N)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new y,l=(0,r.O)();if(t.queryDerivative(new r.H(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new r.H(s,l).add(e),u)}1===s&&u.negateThis();const c=new y;if(e.queryDerivative(new r.H(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new r.H(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const g=u.dotProduct(c),d=u.crossProduct(c);d.scaleError(3);const _=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(g.ge(r.J)&&(d.isZero()||Math.abs(d.value())<_()))return A(t,e,s,i,n,o,a,h)}return 0}function I(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function N(t,e,s){t.m_XStart=e,t.m_YStart=s}function q(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function M(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Y(t,e){const s=new n.f;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:E.getDefaultValue(1)}(t,e),s}function X(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function F(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let i=1;i<t.m_description.getAttributeCount();i++){const n=t.m_description.getSemantics(i);for(let i=0,r=E.getComponentCount(n);i<r;i++){const r=L(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function R(t,e,s){s.isEmpty()&&(0,i.u)(""),function(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=E.getComponentCount(r);for(let i=0;i<o;i++)z(t,e,r,i,s.getAttributeAsDbl(r,i))}}function L(t,e,s,n){if((e<0||e>1)&&(0,i.r)(""),0===s)return(n<0||n>=2)&&(0,i.r)(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=E.getComponentCount(s);(n<0||n>=r)&&(0,i.r)("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:E.getDefaultValue(s)}function z(t,e,s,n,r){if((e<0||e>1)&&(0,i.r)(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:(0,i.r)(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:(0,i.r)(""):(0,i.r)(""),void t.endPointModified();const o=E.getComponentCount(s);(n<0||n>=o)&&(0,i.r)("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function V(t,e){if(t===e)return;e.isEmpty()&&(0,i.u)("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=E.getComponentCount(n);for(let s=0;s<r;s++){let i=L(e,0,n,s);z(t,0,n,s,i),i=L(e,1,n,s),z(t,1,n,s,i)}}}function B(t){return t.absNorm()*(0,r.g)()}function G(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,r.g)()}function H(t,e,s){const i=new p;t.queryEnvelopeW(r.E.unit(),i);const n=new p;return e.queryEnvelopeW(r.E.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function k(t,e,s){const i=(0,r.L)(t,s),n=(0,r.L)(e,s);i.sort((t,e)=>t.compare(e)),n.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(i[t].compare(n[t])<0)return-1;if(0!==i[t].compare(n[t]))return 1}return 0}var W=n.V;class j{constructor(t){if(t.copy)this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice());else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:(0,n.l)(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:(0,n.z)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=(0,n.l)());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:(0,n.z)(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);(0,i.d)("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,r.d)(2*t,Number.NaN)),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,r.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,i.t)("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return(0,i.t)("not implemented"),!1}setCoordsForIntersector3D(t,e,s){(0,i.t)("not implemented")}transformAttribute(t,e,s,n,r){(0,i.t)("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let s=1,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=W.getComponentCount(i);for(let s=0;s<r;s++)z(this,0,i,s,t.getAttributeAsDbl(i,s)),z(this,1,i,s,e.getAttributeAsDbl(i,s))}}getStartXY(){return new r.P(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return Y(this,0)}setStartXYZ(t){X(this,0,t)}setStartXYZCoords(t,e,s){X(this,0,n.f.construct(t,e,s))}queryStart(t){F(this,0,t)}setStart(t){R(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return L(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,i.g)(0),0}setStartAttribute(t,e,s){z(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=W.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=W.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,i.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,i.g)(0),0}getEndXY(){return new r.P(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return Y(this,1)}setEndXYZ(t){X(this,1,t)}setEndXYZCoords(t,e,s){X(this,1,n.f.construct(t,e,s))}queryEnd(t){F(this,1,t)}setEnd(t){R(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return L(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,i.g)(0),Math.trunc(0)}setEndAttribute(t,e,s){z(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.a)("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,r.b)(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=r.E.constructEmpty();return s.vmin=L(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(L(this,1,t,e)),s}calculateLength3D(t){return(0,i.g)(0),0}getCoord3D(t){return(0,i.g)(0),{}}getCoord2D(t){const e=r.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return(0,i.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=W.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=o.Envelope2D.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,i),i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&r.P.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=W.getComponentCount(e);t<s;t++){const s=L(this,0,e,t);z(this,0,e,t,L(this,1,e,t)),z(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==n){const e=(0,r.d)(9,Number.NaN),o=(0,r.d)(9,Number.NaN),a=this.intersect(t,null,e,o,0);(0,i.g)(a<=9),0===a&&(0,i.d)(""),null!==s&&(s[0]=e[0]),null!==n&&(n[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,h=-1,m=a;return o=this.getStartXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==n&&(n[0]=h),null!==s&&(s[0]=0)),o=this.getEndXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==n&&(n[0]=h),null!==s&&(s[0]=1)),o=t.getStartXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==n&&(n[0]=0)),o=t.getEndXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),m=o.length(),m<a&&(a=m,null!==s&&(s[0]=h),null!==n&&(n[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return(0,r.q)(t,e,s)}moveTo(t){const e=this.isClosed(),s=new a.T;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,i.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){const s=(0,n.t)();(0,n.u)(e,t.m_description,s);let i=null;const o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(i=(0,r.d)(2*o,Number.NaN),(0,r.b)(i,e.getDefaultPointAttributes(),0,2,o),(0,r.b)(i,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let n=1;n<e.getAttributeCount();n++){const r=s[n];if(-1!==r){const s=t.m_description.getPointAttributeOffset(r)-2,h=e.getPointAttributeOffset(n)-2,m=E.getComponentCount(e.getSemantics(n));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[o+h]=t.m_attributes[a+s]}}t.m_attributes=i,t.m_description=e}(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.a)("wrong geometry type");const e=t;e.m_description=(0,r.c)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,r.c)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,r.c)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,r.c)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,r.c)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,r.c)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let t=0,s=2*(this.m_description.getTotalComponentCount()-2);t<s;t++)if(!(0,r.G)(this.m_attributes[t],i.m_attributes[t],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,e,s){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,i.a)("");const t=new a.T,n=0===e?s:0,r=1===e?s:0;t.setShiftCoords(n,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,s),this.setEndAttribute(t,e,s)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=W.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}j.s_maxMonotonicPartParams=8;class Z extends h.G{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class U{constructor(t){this.m_geoms=[],this.m_description=(0,n.l)(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,i.a)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&(0,i.a)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.G.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=(0,n.o)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=(0,n.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=(0,n.l)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new r.E;const i=new r.E;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new n.E;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,i.t)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new o.Envelope2D;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,i.t)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);(0,i.t)("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new U({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.a)("");const e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(const t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new r.K(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,i.g)(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const t of this.m_geoms){const s=t.getBoundary();s&&e.m_geoms.push(s)}return t}clone(){return new U({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.G.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(s.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.a)("");const e=t;e!==this&&(this.m_geoms=(0,r.c)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=(0,n.n)(e,t);this.assignVertexDescription(s)}}function O(t,e=-1){return new Z(t,e)}U.type=i.G.enumGeometryCollection;class Q extends j{constructor(t){super(t)}}class $ extends Q{isTrue3D(){return!0}constructor(t){super(t)}}function K(t,e,s){J(e,t.getStartXY(),t.getEndXY(),s)}function J(t,e,s,i){(0,r.U)(e,s,t,i)}function tt(t,e){return(0,r.q)(t.m_XStart,t.m_XEnd,e)}function et(t,e){return(0,r.q)(t.m_YStart,t.m_YEnd,e)}function st(t,e,s){e.value()<=.5?(0,r.a3)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,s):(0,r.a4)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,s)}function it(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function nt(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,r.c)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,r.c)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=(0,r.c)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function rt(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:function(t,e){const s=ht(t,e.m_XStart,e.m_YStart),i=ht(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=ht(e,t.m_XStart,t.m_YStart),r=ht(e,t.m_XEnd,t.m_YEnd);return!(n<0&&r<0||n>0&&r>0)&&(lt(t)>lt(e)?ut(t,e):ut(e,t))}(t,e)?4:0}function ot(t,e,s,i,n,o,a,h){null!==i&&(0,r.w)(i,2,Number.NaN),null!==n&&(0,r.w)(n,2,Number.NaN),null!==s&&(0,r.ac)(s,r.P,2);const m=function(t,e,s,i,n,o,a,h,m){const u=at(t,e.getStartXY(),a,!1),l=at(t,e.getEndXY(),a,!1),c=at(e,t.getStartXY(),a,!1),g=at(e,t.getEndXY(),a,!1);let d=0,_=0;if(!Number.isNaN(u)){let s=!1;h&&(0,r.N)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[_]=u),o&&(o[_]=0),i&&i[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(l)){let s=!1;h&&(0,r.N)(l,0,1)&&t.getCoord2D(l).isEqualPoint2D(e.getEndXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=l),o&&(o[_]=1),i&&i[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(2!==_&&!Number.isNaN(c)&&!(0===u&&0===c||0===l&&1===c)){let s=!1;h&&(0,r.N)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getStartXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=0),o&&(o[_]=c),i&&i[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(2!==_&&!Number.isNaN(g)&&!(1===u&&0===g||1===l&&1===g)){let s=!1;h&&(0,r.N)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(d++,s=!0),s||(2>_&&(n&&(n[_]=1),o&&(o[_]=g),i&&i[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return m&&(o=(0,r.c)(n,n=o)),2===_&&n&&n[0]>n[1]&&(n[1]=(0,r.c)(n[0],n[0]=n[1]),o&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),i&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),_;if(d>0)return 0;const p=function(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,h=o*n-i*a;if(0===h)return r.P.getNAN();const m=4*(0,r.O)()*(Math.abs(o*n)+Math.abs(i*a)),u=e.m_XStart-t.m_XStart,l=e.m_YStart-t.m_YStart,c=o*l-u*a,g=4*(0,r.O)()*(Math.abs(o*l)+Math.abs(u*a)),d=c/h,_=Math.abs(h),p=(g*_+m*Math.abs(c))/(h*h)+(0,r.O)()*Math.abs(d);if(d<-p||d>1+p)return r.P.getNAN();const f=i*l-u*n,x=f/h,P=(4*(0,r.O)()*(Math.abs(i*l)+Math.abs(u*n))*_+m*Math.abs(f))/(h*h)+(0,r.O)()*Math.abs(x);if(x<-P||x>1+P)return r.P.getNAN();let y=(0,r.s)(d,0,1),v=(0,r.s)(x,0,1);const C=r.P.getNAN();K(t,y,C);const E=r.P.getNAN();if(K(e,v,E),!s||r.P.distance(C,E)>s){const i=r.P.getNAN();(0,r.U)(C,E,.5,i),y=t.getClosestCoordinate(i,!1),v=e.getClosestCoordinate(i,!1);const n=r.P.getNAN();K(t,y,n);const o=r.P.getNAN();K(e,v,o),n.subThis(o);const a=n.length(),h=(t.absNorm()+e.absNorm())*(0,r.g)();if(a>Math.max(s,h))return r.P.getNAN()}return new r.P(y,v)}(t,e,a);return Number.isNaN(p.x)?0:(i&&(i[0]=t.getCoord2D(p.x)),n&&(n[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,s,i,n,o,a,h);return i&&(i.length=m),n&&(n.length=m),s&&(s.length=m),m}function at(t,e,s,i){const n=r.P.getNAN(),o=r.P.getNAN();let a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(n.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));const h=a?1:0,m=a?0:1,u=r.P.getNAN();u.setSub(e,n);let l=u.length(),c=3*l*(0,r.O)();if(l<=Math.max(s,c))return i&&0===l?Number.NaN:h;if(u.setSub(e,o),l=u.length(),c=3*l*(0,r.O)(),l<=Math.max(s,c))return i&&0===l?Number.NaN:m;u.setCoords(o.x-n.x,o.y-n.y);const g=u.length();if(g>0){const t=1/g;u.scale(t);const i=r.P.getNAN();i.setSub(e,n);const l=i.dotProduct(u),c=8*i.dotProductAbs(u)*(0,r.O)();u.leftPerpendicularThis();const d=i.dotProduct(u),_=8*i.dotProductAbs(u)*(0,r.O)(),p=Math.max(s,c);if(l<-p||l>g+p)return Number.NaN;const f=Math.max(s,_);if(Math.abs(d)<=f){let i=l*t;i=(0,r.s)(i,0,1);const u=r.P.getNAN();if(J(i,n,o,u),r.P.distance(u,e)<=s){if(i<.5){if(r.P.distance(u,n)<=s&&r.P.distance(e,n)<=s)return h}else if(r.P.distance(u,o)<=s&&r.P.distance(e,o)<=s)return m;return a?1-i:i}}}return Number.NaN}function ht(t,e,s){const i=r.P.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=r.P.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const o=n.crossProduct(i),a=4*(0,r.O)()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?-1:o<-a?1:0}function mt(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,o=i?t.m_YStart:t.m_YEnd,a=r.P.getNAN();return a.x=e.getEndX()-n,a.y=e.getEndY()-o,!(s.dotProduct(a)>3*(0,r.O)()*s.dotProductAbs(a))||(a.x=e.getStartX()-n,a.y=e.getStartY()-o,s.dotProduct(a)<=3*(0,r.O)()*s.dotProductAbs(a))}function ut(t,e){const s=r.P.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!mt(t,e,s,!1)&&(s.negateThis(),!!mt(t,e,s,!0))}function lt(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}class ct{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&(0,i.r)("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&(0,i.r)("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,i.r)(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount()||(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,0))}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&(0,i.r)(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,i.q)(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.r)("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&(0,i.r)(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!=(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,i.r)(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&(0,i.r)(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class gt{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,i.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new gt;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0===--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,i.g)(this.uniqueUse())}setQuadTree(t){(0,i.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,i.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function dt(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function _t(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function pt(t,e){return t.readPoint2D(e+4)}function ft(t){const e=t.getGeometryType();return e===i.G.enumEllipticArc?10:e===i.G.enumBezier?4:e===i.G.enumRationalBezier2?5:e===i.G.enumBezier2?2:void(0,i.d)("")}function xt(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Pt(t,e,s,i){const n=t.getPathStart(e),o=t.getPathEnd(e);if(o-n<3)return;const a=2*n,h=r.P.getNAN();s.queryPoint2D(a,h);const m=h.x,u=h.y,l=r.P.getNAN();s.queryPoint2D(a+2,l);const c=r.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)s.queryPoint2D(t,c),i.pe((c.x-h.x)*(l.y-u)),h.setCoordsPoint2D(l),l.setCoordsPoint2D(c);i.pe((m-h.x)*(l.y-u))}function yt(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var vt=n.V;class Ct{static toSegType(t){let e=0;switch(t){case i.G.enumLine:e=1;break;case i.G.enumBezier:e=2;break;case i.G.enumEllipticArc:e=4;break;case i.G.enumRationalBezier2:e=8;break;case i.G.enumBezier2:e=16;break;default:(0,i.d)("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Et extends d{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?i.G.enumPolygon:i.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,i.g)(this.m_bPolygon);const e=this.getPathIndexFromPointIndex(t),s=this.getPathStart(e);if(s===t)return;const n=this.getPathEnd(e);(t>=n||t<s)&&(0,i.a)("change_ring_start_point");for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=vt.getComponentCount(i);this.m_vertexAttributes.get(e).rotate(s*r,t*r,n*r)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(s,t,n),this.m_curveData.m_segmentParamIndex.rotate(s,t,n))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new n.A(t),s=new r.K(0),i=new r.K(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new ct({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();Pt(this,r,n,i),yt(0,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),Pt(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),o=xt(s);for(let t=0;t<o;t++){const s=this.m_curveData.m_segmentParams.read(i+t),o=e.m_curveData.m_segmentParams.read(n+t);if(!(0,r.Q)(s,o))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=(0,n.D)(1,0),this.m_pathFlags=(0,n.F)(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Ct),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new r.K(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new r.K(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return(0,i.g)(0),0}calculatePathLength3D(t,e){return(0,i.g)(0),0}copyTo(t){(0,i.h)(t.getGeometryType())||(0,i.a)(""),this!==t&&super.copyTo(t)}swap(t){(0,i.g)(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){const s=e.getXY();if(this.setXYCoordsWithCurves(t,s.x,s.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,s){if(this.hasNonLinearSegments()){const i=Et.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=i;const n=this.getPrevSegmentTypeFromPath(i,t),o=this.getNextSegmentType(t);if(1!==n||1!==o){let a=t-1;const h=new Rr;1!==n&&(this.isClosedPath(i)&&t===this.getPathStart(i)&&(a=this.getPathEnd(i)-1),this.getSegmentBuffer(a,h,!0));const m=new Rr;1!==o&&this.getSegmentBuffer(t,m,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const l=new r.P(e,s);return 1!==n&&(h.get().changeEndPoints2D(h.get().getStartXY(),l),this.replaceSegmentImpl(a,t,h.get(),!0)),void(1!==o&&(m.get().changeEndPoints2D(l,m.get().getEndXY()),this.replaceSegmentImpl(t,u,m.get(),!0)))}}this.setXYCoordsNoCurves(t,e,s)}setXYZWithCurves(t,e){this.hasNonLinearSegments()?(this.setXYCoordsWithCurves(t,e.x,e.y),this.setAttributeNoCurves(1,t,0,e.z)):this.setXYZNoCurves(t,e)}setAttributeWithCurves(t,e,s,i){if(0===t&&this.hasNonLinearSegments()){const t=this.getXY(e);0===s?t.x=i:t.y=i,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,s,i)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,s){this.setXYCoordsWithCurves(t,e,s)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,s,i){this.setAttributeWithCurves(t,e,s,i)}setAttributeWithCurvesFromArray(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){n<2&&(0,i.r)("");const t=this.getXY(e);t.x=s[0],t.y=s[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,s,n)}setAttributeFromArray(t,e,s,i){this.setAttributeWithCurvesFromArray(t,e,s,i)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,i.a)("Multi_path_impl::add");for(let s=0,i=t.getPathCount();s<i;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addPathMultiPoint(t,e,s,i){s<0&&(s=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,s,i)}addSegmentsFromPath(t,e,s,n,r){if(this===t&&(0,i.a)("Multi_path_impl.add_segments_from_path"),r||0!==this.getPathCount()||(r=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||n<0||s+n>t.getSegmentCountPath(e))&&(0,i.r)("add_segments_from_path"),0===n)return;const o=t.getPathStart(e),a=t.isClosedPath(e)&&s+n===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let h=n;const m=o+s;let u=m+1;r&&(h++,u--),!r&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||(0,i.a)("add_segments_from_path: start point mismatch"));const l=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange(),r){if(0===h)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const c=a?h-1:h;for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=vt.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(c>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=vt.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*l,t,c*i,i*l),a&&this.m_vertexAttributes.get(e).insertRange(i*l+c*i,t,i,i*l);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*l,t.m_vertexAttributes.get(n),i*u,c*i,!0,i,i*l)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(l+c),t.m_vertexAttributes.get(n),i*o,i,!0,i,i*(l+c))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=m;s<n;s++)e+=xt(t.m_curveData.m_segmentFlags.read(i)),i++;if(e>0){this.initSegmentData(e);let s=m,i=l-(r?0:1),o=0;for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),Et.isNonLinearSegmentFlag(e)){o++;let n=t.m_curveData.m_segmentParamIndex.read(s);const r=xt(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentParams.read(n);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,n++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(o)}}if(a){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&(0,i.a)("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const i=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,i,!0),i.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,s)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const r=n?1:0;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++)if(this.m_vertexAttributes.get(t)){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i);this.m_vertexAttributes.get(t).reverseRange(n*(s+r),n*(e-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,i.a)("");const s=this.getPathStart(t),n=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*s,i*n,i*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=s,i=s+n;e<i;e++){const s=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(s,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(s,n,this.m_pointCount)}for(let s=t+1;s<=e;s++){const t=this.m_paths.read(s);this.m_paths.write(s-1,t-n)}if(this.m_pathFlags)for(let s=t+1;s<=e;s++){const t=this.m_pathFlags.read(s);this.m_pathFlags.write(s-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,s,r){this===e&&(0,i.a)("Multi_path_impl::insert_path");const o=this.getPathCount();if(!r&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&(0,i.a)(""),t>o&&(0,i.a)(""),t<0&&(t=o),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const a=e.getPathStart(s),h=e.getPathSize(s);if(0===h)return this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=e.isClosedPath(s)&&!r?1:0;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<o?this.getPathStart(t):m;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=e.getDescription().getAttributeIndex(s),n=vt.getComponentCount(s);if(i>=0&&e.m_vertexAttributes.get(i))0!==u&&this.m_vertexAttributes.get(t).insertRangeFromStream(l*n,e.m_vertexAttributes.get(i),n*a,n,!0,n,n*m),this.m_vertexAttributes.get(t).insertRangeFromStream((l+u)*n,e.m_vertexAttributes.get(i),n*(a+u),n*(h-u),r,n,n*(m+u));else{const e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(l*n,e,n*h,n*m)}}const c=m+h;this.m_paths.add(c);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=e.getPathFlagsStreamRef().read(s);if(g&=-9,this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,s=0;for(let i=0;i<h;i++)s+=xt(e.m_curveData.m_segmentFlags.read(t)),t++;if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,n.F)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,n.D)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(l,1,h,m),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,h,m)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=(0,n.G)(s),t=a;let i=l,r=0;for(let s=0;s<h;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const n=xt(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<n;t++){const t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}r++,this.incCurveType(s,1)}t++,i++}this.modifyCurveCounter(r)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,n,r){const o=this.getPathCount();(t>o||s<0)&&(0,i.a)(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,e,s,n,r,2*a);else{const t=vt.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e),i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,s,n,r){const o=e.getImpl(),a=this.getPathCount();(t>a||s<0)&&(0,i.a)("");const h=n<0?o.getPointCount()-s:n;if(h>o.getPointCount()&&(0,i.a)(""),s>=o.getPointCount()&&(0,i.a)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=s;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):m;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),i=vt.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(l*i,s,i*u,i*h,r,i,i*m)}else{const s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,e,s,n,r,o,a){if(this===s&&(0,i.a)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),n<0&&(n=s.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||n>=s.getPathCount()||o>s.getPathSize(n))&&(0,i.r)(""),!o)return;if(this.mergeVertexDescription(s.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=s.m_pathFlags.read(n);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),u=m+e;o<0&&(o=s.getPathSize(n));const l=s.getPathStart(n),c=l+o;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i),g=s.m_description.getAttributeIndex(i);if(g<0||!s.m_vertexAttributes.get(g)){const e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*u,e,c*n,n*h);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(n*(m+e),s.m_vertexAttributes.get(g),n*(l+r),o*n,a,n,n*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,o,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,o,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&(0,i.r)(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=vt.getComponentCount(s),n=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange((h+e)*i,n,i*r,i*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const m=a.getPointCount();if((n<0||n>m)&&(0,i.r)(""),(r<0||n+r>m)&&(r=m-n),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&(0,i.r)(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===h){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const l=this.getPathStart(t),c=l+e,g=0+r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=vt.getComponentCount(s);if(a.getDescription().getAttributeIndex(s)<0){const e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(i*c,e,g*i,i*u);continue}const h=a.getAttributeStreamRef(s);this.m_vertexAttributes.get(t).insertRangeFromStream(i*(l+e),h,i*(0+n),r*i,o,i,i*u)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,r,u),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,r,u),e>0&&this.isNonLinearSegment(l+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(l+e-1),-1),this.m_curveData.m_segmentFlags.write(l+e-1,1),this.m_curveData.m_segmentParamIndex.write(l+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.r)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e),i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.r)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByValNoCurves(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=vt.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&(0,i.r)("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,i.r)("Multi_path.remove_point");const o=n+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*o,s,s*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=s;e>=t+1;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNextSegmentType(t){return this.hasNonLinearSegments()?this.m_curveData.m_segmentFlags.read(t):1}getPrevSegmentTypeFromPath(t,e){if(!this.hasNonLinearSegments())return 1;const s=this.getPathStart(t);if(e>s)return this.m_curveData.m_segmentFlags.read(e-1);if(e===s){if(this.isClosedPath(t)){const e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}(0,i.d)("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)Et.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=Et.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new n.P({x:t,y:e}))}startPath(t){this.startPathPoint(new n.P({pt:t}))}startPath3D(t){this.startPathPoint(new n.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new n.P({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&(0,i.a)("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new n.P({vd:this.m_description});t.copyCommonAttributesTo(i),s=i}else s=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,n.D)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,n.F)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoordsNoCurves(this.m_pointCount-1,t,e);else{const s=(0,n.q)(),i=new n.P({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=(0,n.n)(this.m_description,(0,n.z)()),s=(0,n.q)(),i=new n.P({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new n.f(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=(0,n.q)(),s=new n.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,i.d)("");const e=this.getPathCount();if(t>e&&(0,i.a)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,i.d)("");const s=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!==0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(i*r,this.m_vertexAttributes.get(t),i*n,i,!0,1,i*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,i.d)(""),t>this.getPathCount()&&(0,i.a)(""),this.m_pathFlags||(0,i.d)(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&(0,i.d)(""),this.isEmpty())return;this.m_pathFlags||(0,i.d)("");let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)this.isClosedPath(s)&&(this.getPathSize(s)>0?t++:this.m_pathFlags.clearBits(s,1));if(0===t)return;const s=this.hasNonLinearSegments();let r=0;const o=this.getPathCount(),a=this.m_description.getAttributeCount(),h=new Array(a);let m=null,u=null;for(let e=0;e<o;++e){const i=this.getPathStart(e),o=this.getPathSize(e),l=this.isClosedPath(e);if(o>0){const e=i+r;for(let s=0;s<a;s++)if(this.m_vertexAttributes.get(s)){const r=this.m_description.getSemantics(s),a=vt.getComponentCount(r);if(!h[s]){const e=a*(this.m_pointCount+t),i=(0,n.w)(r,e);h[s]=i}h[s].writeRange(e*a,o*a,this.m_vertexAttributes.get(s),i*a,!0,1),l&&h[s].writeRange((e+o)*a,a,this.m_vertexAttributes.get(s),i*a,!0,1)}if(s){if(null===m){const e=this.m_pointCount+t;m=(0,n.F)(e),u=(0,n.D)(e)}m.writeRange(e,o,this.m_curveData.m_segmentFlags,i,!0,1),u.writeRange(e,o,this.m_curveData.m_segmentParamIndex,i,!0,1),l&&(m.write(e+o,1),u.write(e+o,-1))}}this.m_paths.write(e,i+r),l&&(this.m_pathFlags.clearBits(e,1),++r)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,h[t]);s&&(this.m_curveData.m_segmentFlags=m,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,i.a)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);1!==s&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,i.a)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,i.a)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),n=this.getPathEnd(t)-1;s.equals(this.getXY(n))||(0,i.a)("close_path_with_segment: start point mismatch");const r=e.getGeometryType();if(r===i.G.enumLine)return void this.closePathWithLine(t);{const t=ft(e);this.initSegmentData(t);const s=Ct.toSegType(r),i=this.m_curveData.m_segmentFlags.read(n);if(i!==s)this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(n);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(n,s)}}const s=this.m_pathFlags.read(t);1&s||this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(t){return(0,i.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Et.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof o.Envelope2D)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=(0,n.q)(),r=new n.P({vd:s,attribBuffer:i,initDefaultValues:!1});for(let s=0,i=4;s<i;s++){const n=e?i-s-1:s;t.queryCornerByVal(n,r),0===s?this.startPathPoint(r):this.lineToPoint(r)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,i.a)("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new n.P;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new n.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const r=(0,n.q)(),o=new n.P({vd:s,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===i.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),s||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,i.a)("add_segment: start point mismatch"),s&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=(0,n.q)(),e=new n.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const r=ft(t);this.initSegmentData(r),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=r;const h=Ct.toSegType(a);this.incCurveType(h,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,h)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,s,n){for(let e=t;e<s-1;e++)this.isClosedPath(e)&&(0,i.a)("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,e,s,n);if(0!==o)for(let i=1;i<r;i++){const r=this.m_description.getSemantics(i);this.interpolateAttributesSemanticsImpl(r,t,e,s,n,o)}}interpolateAttributesSemantics(t,e,s,n,r){if(0===t)return;this.hasAttribute(t)||(0,i.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,i.a)("angular interpolation");for(let t=e;t<n-1;t++)this.isClosedPath(t)&&(0,i.a)("cannot interpolate across closed paths");const o=this.calculateSubLength2D(e,s,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,s,n,r,o)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(t,e,s,n){if(0===t)return;this.hasAttribute(t)||(0,i.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,i.a)("angular interpolation");const r=this.calculatePathSubLength2D(e,s,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,e,s,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,n,o){const a=this.querySegmentIterator(),h=this.getPathStart(e)+s,m=this.getPathStart(i)+n,u=vt.getComponentCount(t),l=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,u);const g=(0,r.d)(vt.maxComponentCount(),Number.NaN);(0,r.b)(g,l,0,0,u);let d=0;const _=vt.getDefaultValue(t),p=vt.getInterpolation(t);a.resetToVertex(h,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===m)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,u),a.previousSegment();do{const e=a.nextSegment();if(a.getEndPointIndex()===m)return;d+=e.calculateLength2D(),(0,r.A)(p,l,c,g,0,u,d/o,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,u)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,n,o){(0,i.g)(0!==t);const a=this.querySegmentIterator(),h=vt.getInterpolation(t),m=this.getPathStart(e)+s,u=this.getPathStart(e)+n;if(u===m)return;const l=vt.getComponentCount(t),c=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,m,c,l);const g=(0,r.d)(vt.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,g,l);const d=new r.K(0);a.resetToVertex(m,e),a.setCirculator(this.isClosedPath(e));const _=vt.getDefaultValue(t),p=(0,r.d)(vt.maxComponentCount(),Number.NaN);(0,r.b)(p,c,0,0,l);const f=0===o;let x=.5;do{const e=a.nextSegment();if(this.setAttributeFromArrayNoCurves(t,a.getStartPointIndex(),p,l),!f){const t=e.calculateLength2D();d.pe(t),x=d.getResult()/o}(0,r.A)(h,c,g,p,0,l,x,_)}while(a.getEndPointIndex()!==u)}querySegment(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.a)("get_segment"),this.getSegmentFromPath(n,r,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const e=this.getPathIndexFromPointIndex(t),s=t-this.getPathStart(e);return s>=this.getSegmentCountPath(e)&&(0,i.a)("get_segment"),this.getSegmentTypeFromPath(e,s)}getSegmentFromPath(t,e,s,r){const o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef();let h=1;switch(a&&(h=31&a.read(o)),h){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:(0,i.d)("")}const m=s.get();let u,l=null;if(r?(l=(0,n.l)(),m.assignVertexDescription(l)):m.assignVertexDescription(this.m_description),u=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,I(m,this.getXY(o)),q(m,this.getXY(u)),!r)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);for(let t=0;t<s;t++){const s=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,s);const i=this.getAttributeAsDbl(e,u,t);m.setEndAttribute(e,t,i)}}if(Et.isNonLinearSegmentFlag(h)){const t=this.m_curveData.m_segmentParamIndex.read(o);m.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);pt(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,e,s,n=!1){const o={iSegment:-1},a=n?o:{tSegment:0};if(s.setEmpty(),this.isEmpty())return o;if((t<0||t>=this.getPathCount())&&(0,i.a)("query_point_along_path"),e<0)return o;const h=this.getPathSize(t);if(0===h)return o;if(1===h)return this.getPointByVal(this.getPathStart(t),s),a.tSegment=0,o.iSegment=this.getPathStart(t),o;const m=this.querySegmentIteratorAtVertex(this.getPathStart(t)),u=new r.K(0);for(;m.hasNextSegment();){const t=m.nextSegment(),i=t.calculateLength2D(),n=u.getResult();if(u.add(i),u.getResult()>=e){let r=e-n;r>i&&(r=i);const h=t.lengthToT(r);return t.queryCoord(h,s),a.tSegment=h,o.iSegment=m.getStartPointIndex(),o}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,s,n,o,a){{let t=0;for(let r=0;r<e;++r)n&&n[r].setEmpty(),o&&(o[r]=-1),a&&(a[r]=0),t>s[r]&&(0,i.a)("query_points_along"),t=s[r]}const h=this.getPathSize(t);if(0===e||0===h)return 0;if(1===h){const e=this.getPathStart(t);return n&&this.getPointByVal(e,n[0]),a&&(a[0]=0),o&&(o[0]=e),1}const m=this.getPathStart(t),u=new r.K(0),l=this.querySegmentIteratorAtVertex(m);let c=0,g=0,d=s[c];for(;l.hasNextSegment();){const t=l.nextSegment(),i=t.calculateLength2D(),r=u.getResult();for(u.add(i);u.getResult()>=d;){let h=d-r;h>i&&(h=i);const m=t.lengthToT(h);if(n&&t.queryCoord(m,n[g]),a&&(a[g]=m),o&&(o[g]=l.getStartPointIndex()),g++,c++,d=s[c],c===e)return g}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;n&&this.getPointByVal(e,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;n&&this.getPointByVal(e+1,n[g]),a&&(a[g]=s),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,s,n,o){{let r=0;for(let a=0;a<t;++a)s&&s[a].setEmpty(),n&&(n[a]=-1),o&&(o[a]=0),r>e[a]&&(0,i.a)("query_points_along"),r=e[a]}if(0===t)return 0;const a=new r.K(0),h=this.querySegmentIterator();let m=-1,u=0,l=0,c=e[u];for(;h.nextPath();)for(;h.hasNextSegment();){m=h.getPathIndex();const i=h.nextSegment(),r=i.calculateLength2D(),g=a.getResult();for(a.add(r);a.getResult()>=c;){let a=c-g;a>r&&(a=r);const m=i.lengthToT(a);if(s&&i.queryCoord(m,s[l]),o&&(o[l]=m),n&&(n[l]=h.getStartPointIndex()),l++,u++,c=e[u],u===t)return l}}if(m<0)return 0;if(this.isClosedPath(m)){const t=this.getPathStart(m),e=0;s&&this.getPointByVal(t,s[l]),o&&(o[l]=e),n&&(n[l]=t),l++}else if(this.getPathSize(m)>1){const t=this.getPathEnd(m)-2,e=1;s&&this.getPointByVal(t+1,s[l]),o&&(o[l]=e),n&&(n[l]=t),l++}return l}querySegmentIterator(){return new ct({parent:this})}querySegmentIteratorAtVertex(t){return new ct({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,s){if(e instanceof n.E&&(0,i.g)(0,"not implemented for Envelope"),e instanceof n.p&&(0,i.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,i.a)(""),this.isEmpty())return void e.setEmpty();const r=this.getAttributeStreamRef(0),a=o.Envelope2D.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),s=2*this.getPathEnd(t);e<s;){const t=s-e;(0,i.g)(!(1&t)),a.mergePointsInterleaved(r,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){const n=this.querySegmentIterator();if(n.resetToPath(t),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const i=o.Envelope2D.constructEmpty();s?t.queryEnvelope(i):t.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}else(0,i.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=xt(4)*this.m_curveData.m_arcCount+xt(2)*this.m_curveData.m_bezierCount+xt(8)*this.m_curveData.m_rbezier2Count+xt(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,s=this.getPointCount();e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(s)&&(t+=xt(s))}const e=(0,n.G)(t);let s=0;for(let t=0,i=this.getPointCount();t<i;t++){const i=this.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(i)){let n=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,s);const r=xt(i);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,i.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,n.D)(0),this.m_pathFlags=(0,n.F)(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=(0,n.D)(0),this.m_pathFlags=(0,n.F)(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new bt(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new Ct),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;(0,i.o)("")}let r=0,o=e-1;for(;o>r;){const e=r+(o-r>>1);if(s<t.read(e))o=e-1;else{if(!(s>=t.read(e+1)))return e;r=e+1}}return r}getHighestPointIndex(t){(0,i.g)(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),n=this.getPathStart(t);let o=-1;const a=new r.P;a.y=Number.NEGATIVE_INFINITY,a.x=Number.NEGATIVE_INFINITY;for(let t=n+0;t<s;t++){const s=e.readPoint2D(2*t);-1===a.compare(s)&&(o=t,a.setCoordsPoint2D(s))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,i.a)("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let i,n;return e<0?(i=0,n=this.m_pointCount):(i=this.getPathStart(e),n=this.getPathEnd(e)),s.applyTransformation(t,2*i,n-i),void this.notifyModifiedFlags(2001)}const n=new this.m_segmentBufferCTor,o=this.getPathCount();let a=e<0?0:e;do{const i=this.getPathStart(a),o=this.getPathEnd(a),h=this.isClosedPath(a),m=s.readPoint2D(2*i);if(!this.hasNonLinearSegmentsPath(a)){s.applyTransformation(t,2*i,o-i);continue}const u=r.P.getNAN();for(let e=i;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){const r=h&&e+1===o;r&&s.writePoint2D(2*i,m),this.getSegmentBuffer(e,n,!0),n.get().applyTransformation(t);const a=this.m_curveData.m_segmentParamIndex.read(e);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),s.writePoint2D(2*e,n.get().getStartXY()),r&&s.writePoint2D(2*i,n.get().getEndXY());continue}const r=2*e;s.queryPoint2D(r,u),t.transformInPlace(u),s.writePoint2D(r,u)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,n){const r=this.getPathStart(t)+e,o=this.getPathStart(s)+n;(o<r||r<0||o>this.getPointCount()-1)&&(0,i.q)("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(r,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===o)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return h}calculatePathSubLength2D(t,e,s){const n=this.getPathStart(t)+e,r=this.getPathStart(t)+s;(n<0||r>this.getPointCount()-1)&&(0,i.q)("");const o=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||(0,i.a)("cannot iterate across an open path"),o.setCirculator(!0)),n===r)return 0;let a=0,h=0;o.resetToVertex(n,t);do{h+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=o.Envelope2D.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&(0,i.a)("Multi_path_impl::add");let s=this.getPathCount();for(let i=0,n=t.getPathCount();i<n;i++)this.addPath(t,i,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.a)("getSegmentBuffer"),this.getSegmentFromPath(n,r,e,s)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.G.enumLine;case 2:return i.G.enumBezier;case 4:return i.G.enumEllipticArc;case 8:return i.G.enumRationalBezier2;case 16:return i.G.enumBezier2;default:(0,i.d)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),n=this.getPathEnd(e),o=n-s;for(let e=s;e<n;e++){const n=31&this.m_curveData.m_segmentFlags.read(e);if(1===n)continue;2!==n&&(0,i.t)("ensure_xy_monotone_segments");const a=(e-s+1)%o+s,h=this.m_curveData.m_segmentParamIndex.read(e),m=(0,r.m)(r.P,4);m[0]=this.getXY(e),m[3]=this.getXY(a),m[1].x=this.m_curveData.m_segmentParams.read(h),m[1].y=this.m_curveData.m_segmentParams.read(h+1),m[2].x=this.m_curveData.m_segmentParams.read(h+2),m[2].y=this.m_curveData.m_segmentParams.read(h+3),b(m)&&(t=!0,this.m_curveData.m_segmentParams.write(h,m[1].x),this.m_curveData.m_segmentParams.write(h+1,m[1].y),this.m_curveData.m_segmentParams.write(h+2,m[2].x),this.m_curveData.m_segmentParams.write(h+3,m[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=(0,n.H)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new gt),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=(0,n.I)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Et.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Ct),Et.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Ct),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Ct);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,n.F)(e,1),this.m_curveData.m_segmentParamIndex=(0,n.D)(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,n.G)(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Ct),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=(0,r.e)(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,s){(t<0||t>=this.getPointCount())&&(0,i.a)("Multi_path_impl.replace_segment"),(0,i.g)(e.isCurve());const n=this.getPathIndexFromPointIndex(t),r=this.getPathStart(n),o=(t-r+1)%this.getPathSize(n)+r;{const s=this.getXY(t),n=this.getXY(o),r=!s.isEqualPoint2D(e.getStartXY())||!n.isEqualPoint2D(e.getEndXY());(0,i.g)(!r)}this.replaceSegmentImpl(t,o,e,s)}replaceSegmentImpl(t,e,s,o){const a=s.getDescription();this.mergeVertexDescription(a);const h=(0,r.d)(32,Number.NaN),m=new n.P({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),l=xt(u),c=ft(s);let g,d=!1;l>=c?((0,i.g)(null!==this.m_curveData),d=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(c),d=!1,g=this.m_curveData.m_curveParamWritePoint);const _=s.getGeometryType(),p=Ct.toSegType(_);o||(s.queryStart(m),this.setPointByValNoCurves(t,m),s.queryEnd(m),this.setPointByValNoCurves(e,m)),this.m_curveData.m_segmentParamIndex.write(t,1!==p?g:-1),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&s.writeInBufferStream(this.m_curveData.m_segmentParams,g),d||(this.m_curveData.m_curveParamWritePoint+=c),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}setAttributeImpl(t,e,s){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,i.a)("");const t=new a.T,n=0===e?s:0,r=0===e?0:1;t.setShiftCoords(n,r),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,s)}toFlatGeometry(){const t=this.m_bPolygon?"polygon":"polyline",e=this.getPathCount(),s=this.m_paths?this.m_paths.getArray():new Int32Array,i=this.m_paths?this.m_pathFlags.getArray():new Int8Array;let n,r,o,a=0,h=0;if(this.m_curveData){const{m_segmentFlags:t,m_segmentParamIndex:e,m_segmentParams:s}=this.m_curveData;n=t?.getArray()??new Int8Array,r=e?.getArray()??new Int32Array,o=s?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,h=this.m_curveData.m_bezierCount}return{type:t,...this.exportVertexAttributes(),partCount:e,partOffsets:s,partFlags:i,segmentFlags:n,segmentIndices:r,segmentParams:o,segmentCountArc:a,segmentCountBezier:h}}}Et.st_totalCurveCount=0;class bt{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o.Envelope2D(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=o.Envelope2D.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Dt extends Et{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Rr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Rr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Rr):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Rr,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Rr,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,i.d)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Rr)}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Dt.type}getDimension(){return 1}createInstance(){return new Dt({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Dt.type=i.G.enumPolyline;var St=i.G;function wt(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===St.enumPolygon)return 0!==t.calculateArea2D();if(s===St.enumPolyline)return Tt(t.getImpl(),0,!0).bNotEmpty;if(s===St.enumEnvelope)return!0;if((0,i.f)(s))return!!t.isClosed();if((0,i.e)(s))return!1;if(s===St.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(wt(s.getGeometry(t),e))return!0;return!1}(0,i.t)("")}function At(t,e){const s=t.getGeometryType();if(s===St.enumPolygon){const e=new Dt({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===St.enumPolyline)return Tt(t.getImpl(),0,!1).boundary;if(s===St.enumEnvelope){const e=new Dt({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,i.f)(s)){const e=new _({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new n.P;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===St.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=At(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if((0,i.e)(s))return new n.P({vd:t.getDescription()});(0,i.t)("")}function Tt(t,e,s){const i=!1,o=t;let a=null;if(s||(a=new _({vd:o.getDescription()})),!o.isEmpty()){const t=new n.a(0);for(let e=0,s=o.getPathCount();e<s;e++)if(o.getPathSize(e)>0&&!o.isClosedPathInXYPlane(e)){const s=o.getPathStart(e);t.add(s);const i=o.getPathEnd(e)-1;t.add(i)}if(t.size()>0){const e=new n.B,i=o.getAttributeStreamRef(0),h={userSort(t,e,s){const n=r.P.getNAN(),o=r.P.getNAN();s.sort(t,e,(t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,o),n.compare(o)))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),h);let m=i.readPoint2D(2*t.read(0)),u=0,l=1;const c=new n.P;for(let e=1,n=t.size();e<n;e++){const n=i.readPoint2D(2*t.read(e));if(n.isEqualPoint2D(m))t.read(u)>t.read(e)?(t.write(u,(0,r.j)()),u=e):t.write(e,(0,r.j)()),l++;else{if(1&l){if(s)return{bNotEmpty:!0,boundary:new _({})}}else t.write(u,(0,r.j)());m=n,u=e,l=1}}if(1&l){if(s)return{bNotEmpty:!0,boundary:new _({})}}else t.write(u,(0,r.j)());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==(0,r.j)();e++)o.getPointByVal(t.read(e),c),a.add(c)}}}return s?{bNotEmpty:i,boundary:new _({})}:{bNotEmpty:i,boundary:a}}function It(t,e,s,n){const o=4*(0,r.O)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,r.O)();if(1===t.getMaxDerivative()){(0,i.g)(s>0);const a=Yt(t,0,e,(0,r.O)(),o);return n[0]=a.root,a.cRoots}let h,m=[];const u=new r.E(e.vmin-o,e.vmax+o);m.push(new r.P(u.vmin,u.vmax));let l=0;for(let i=t.getMaxDerivative()-1;i>=0;i--){h=m,m=[];for(let u=0,c=h.length;u<c;u++){if(h[u][0]<h[u][1]){let c,g,d;if(i===t.getMaxDerivative()-1?({root:c,funcAtRoot:g,cRoots:d}=Yt(t,i,r.E.construct(h[u][0],h[u][1]),a,.5*o)):({root:c,funcAtRoot:g,cRoots:d}=Xt(t,i,r.E.construct(h[u][0],h[u][1]),0,.5*o)),1===d){if(0===i)l<s&&(h[u][0]<=e.vmin&&h[u][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),h[u][0]<=e.vmax&&h[u][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),n[l]=e.snapClip(c),l>0?n[l]-n[l-1]>o&&l++:l++);else{const t=r.P.getNAN();t[0]=h[u][0],t[1]=c,m.push(t);const e=r.P.getNAN();e[0]=c,e[1]=h[u][1],m.push(e)}continue}}m.push(h[u])}}return l}function Nt(t,e,s,i,n,o){const a=(0,r.m)(r.H,2),h=Lt(new r.H(t),new r.H(e),new r.H(s),i,n,a);return o[0]=a[0].value(),o[1]=a[1].value(),h}function qt(t,e,s,i,n,o,a){const h=(0,r.m)(r.H,3),m=zt(new r.H(t),new r.H(e),new r.H(s),new r.H(i),n,o,h);return a[0]=h[0].value(),a[1]=h[1].value(),a[2]=h[2].value(),m}function Mt(t,e,s,i,n,o,a,h){return function(t,e,s,i,n,o,a,h){const m=(0,r.d)(s*s,Number.NaN);m.fill(0),(0,r.b)(h,i,0,0,s);const u=(0,r.d)(s,Number.NaN),l=(0,r.d)(s,Number.NaN),c=(0,r.d)(s,Number.NaN);let g=t(h,s,e);let d=0;for(d=0;d<100;d++){const i=g;for(let t=0;t<s;++t)l[t]=h[t];if(d%s===0){m.fill(0);for(let t=0;t<s;t++)m[t*s+t]=1}let a=0,_=0;for(let i=0;i<s;++i){for(let t=0;t<s;++t)u[t]=m[i*s+t];const r=g;g=Ft(t,e,h,u,n,o,s);const l=r-g;l>a&&(_=i,a=l)}for(let t=0;t<s;t++)u[t]=h[t]-l[t],c[t]=h[t]+(h[t]-l[t]);const p=t(c,s,e);if(p<i&&2*(i-2*g+p)*(0,r.a)(i-g-a)<(0,r.a)(i-p)*a){g=Ft(t,e,h,u,n,o,s);for(let t=0;t<s;++t)m[_*s+t]=m[(s-1)*s+t],m[(s-1)*s+t]=u[t]}if(i<=g)return t(h,s,e)}return g}(t,e,s,i,n,o,0,h)}function Yt(t,e,s,n,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=s.vmax,u=0,l=Number.MAX_VALUE,c=t.getValue(e,h),g=t.getValue(e,m),d=0,_=0,p=0;if(c>=0&&g>=0||c<=0&&g<=0)return Math.abs(c)<Math.abs(g)?(a.funcAtRoot=c,a.root=h,a.cRoots=0===c?1:0,a):(a.funcAtRoot=g,a.root=m,a.cRoots=0===g?1:0,a);Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),u=h,d=c;let f=!0,x=0;for(;0!==g&&Math.abs(h-m)>n*Math.abs(m)+o;x++){let s=x>64;if(!s){_=c!==d&&g!==d?h*g*d/((c-g)*(c-d))+m*c*d/((g-c)*(g-d))+u*c*g/((d-c)*(d-g)):m-g*(m-h)/(g-c);const t=(3*h+m)/4;if(s=!(_>t&&_<m||_>m&&_<t),!s){const t=n*Math.abs(m)+o;if(f){const e=Math.abs(m-u);s=Math.abs(_-m)>=.5*e||e<t}else{const e=Math.abs(u-l);s=Math.abs(_-m)>=.5*e||e<t}}}if(s?(_=(h+m)/2,f=!0):f=!1,p=t.getValue(e,_),0===p)return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!s){const s=h-_,i=_-m;if(Math.abs(s)>10*Math.abs(i)){let s=m+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);(0,r.e)(c)*(0,r.e)(i)>0?(h=s,c=i):s=(0,r.q)(h,m,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=h-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);(0,r.e)(g)*(0,r.e)(s)>0?(m=i,g=s):i=(0,r.q)(h,m,.25)}}}l=u,u=m,d=g,(0,r.e)(c)*(0,r.e)(p)<0?(m=_,g=p):(h=_,c=p),Math.abs(c)<Math.abs(g)&&(m=(0,r.c)(h,h=m),g=(0,r.c)(c,c=g)),128===x&&(0,i.d)("Root_finder iterations exceeded")}return a.root=m,a.funcAtRoot=g,a.cRoots=1,a}function Xt(t,e,s,n,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=t.getValue(e,h),u=s.vmax,l=t.getValue(e,u);if(m>=0&&l>=0||m<=0&&l<=0)return Math.abs(m)<Math.abs(l)?(a.funcAtRoot=m,a.root=h,a.cRoots=0===m?1:0,a):(a.funcAtRoot=l,a.root=u,a.cRoots=0===l?1:0,a);l<0&&(l=(0,r.c)(m,m=l),u=(0,r.c)(h,h=u));let c=.5*(h+u),g=Math.abs(u-h),d=g,_=t.getValue(e,c),p=t.getValue(e+1,c),f=4,x=1,P=0,y=0,v=1,C=0;for(;++C<100;){let s;C>32||0===p||2===v&&P>1||1===v&&f<4?(v=1,x>1&&x--):(v=2,y>1&&Math.abs(2*_)>Math.abs(g*p)&&x++),g=d;let i=!1;if(1===v)do{if(y>2){const t=16*Math.abs(g);if(.5*Math.abs(h-u)>t){const e=Math.min(h,u),i=Math.max(h,u);if(c===e){s=c,c=e+t,d=c-s;break}if(c===i){s=c,c=i-t,d=c-s;break}}}d=.5*(u-h),s=c,c=h+d,i=h===c||u===c}while(0);else for(;;){d=x*_/p,s=c,c-=d,i=c===s;const t=Math.min(h,u),e=Math.max(h,u);if(c<t){if(x>1){c=s,x--;continue}d=s-t,c=t}else if(c>e){if(x>1){c=s,x--;continue}d=s-e,c=e}break}if(i||Math.abs(d)<o){s!==c&&(_=t.getValue(e,c));break}_=t.getValue(e,c),p=t.getValue(e+1,c);const n=h,r=u;_<0?(m=_,h=c):(l=_,u=c),2===v&&(h===n&&u===r||y>1&&Math.abs(d)>=.5001*Math.abs(g))?P++:P=0,1===v?(f++,y=0):(f=0,y++)}return 100===C&&(0,i.d)("Root_finder iterations exceeded"),a.root=c,a.funcAtRoot=_,a.cRoots=1,a}function Ft(t,e,s,i,n,o,a){const h=i.slice(0,a);let m=0;for(let t=0;t<a;t++)m+=i[t]*i[t];if(m=Math.sqrt(m),m>0)for(let t=0;t<a;t++)h[t]/=m;let u=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;{const t=(0,r.d)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{const s=Math.abs(h[t]),i=Math.abs(h[e]);return s<i?-1:s>i?1:0});for(let e=0;e<a;e++){const i=t[e];if(0===h[i])continue;let a=(n[i]-s[i])/h[i],m=(o[i]-s[i])/h[i];m<a&&(m=(0,r.c)(a,a=m)),a>u&&(u=a),m<l&&(l=m)}}let c=0;const g=(Math.abs(u)+Math.abs(l))*(0,r.O)()*100,d=(0,r.d)(a,Number.NaN),_=h.slice();function p(i,n){for(let t=0,e=a;t<e;t++)d[t]=s[t]+i*_[t];return t(d,a,e)}g>0&&(c=function(t,e,s,i,n,o){return function(t,e,s,i,n,o){const a=(0,r.aq)();let h=i,m=t(h,e),u=s,l=n,c=t(u,e),g=t(l,e);m>c&&(m=c,h=u),m>g&&(m=g,h=l);let d=u,_=l,p=c,f=g;p>f&&(p=(0,r.c)(f,f=p),_=(0,r.c)(d,d=_));let x=h-d,P=d-_;const y=.5*Math.min(o,l-u),v=2*y;let C,E=0;for(C=0;C<100&&!(l-u<=v);++C){const s=u+.5*(l-u);let i=E>0;if(!i&&Math.abs(P)<=y&&(i=!0,E=3),!i){const t=h-d,e=h-_,s=t*(m-f);let n=e*(m-p),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*P/2)||r<=n*(u-h)||r>=n*(l-h)?(i=!0,E=3):(P=x,x=r/n)}i&&(P=h>=s?u-h:l-h,x=a*P,E--);let n=h+x;n<u+y?n=u+y:n>l-y&&(n=l-y);const r=t(n,e);r<m?(n>=h?(u=h,c=m):(l=h,g=m),_=d,d=h,h=n,f=p,p=m,m=r):(n<h?(u=n,c=r):(l=n,g=r),r<=p||d===h?(_=d,d=n,f=p,p=r):(r<=f||_===h||_===d)&&(_=n,f=r))}return h}(t,e,s,i,n,o)}(p,null,u,0,l,g));const f=p(c);for(let t=0,e=a;t<e;t++)s[t]=(0,r.s)(d[t],n[t],o[t]);return f}function Rt(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Lt(t,e,s,i,n,o){if(0===t.value())return n?(o[0].set(1),i.containsCoordinate(o[0].value())?1:0):Rt(e,s,i,o[0]);if(n){let e=2;return o[0].set(1),o[1].setE(s).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),e}const a=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(r.a5));if(a.lt(r.J))return 0;const h=new r.H(e.value()>=0?1:-1),m=a.clone().sqrtThis(),u=new r.H(-.5).mulThisE(e.clone().addThisE(h.clone().mulThisE(m)));let l=0;o[0].setE(u.divE(t));const c=new r.H(o[0].value()),g=new r.H(t.value()).mulE(c).addE(new r.H(e.value()).mulE(c).addE(new r.H(s.value())));return g.isZero()||jt(o[0],t,e,s,o[0]),i.containsCoordinate(o[0].value())&&l++,0!==m.value()&&0!==u.value()?(o[l].assign(s.divE(u)),c.set(o[l].value()),g.assign(new r.H(t.value()).mulE(c).addE(new r.H(e.value()).mulE(c).addE(new r.H(s.value())))),g.isZero()||jt(o[l],t,e,s,o[l]),i.containsCoordinate(o[l].value())&&l++,2===l&&o[0].value()>o[1].value()&&(o[1]=(0,r.c)(o[0],o[0]=o[1])),l):l}function zt(t,e,s,n,o,a,h){if(0===t.value())return Lt(e,s,n,o,a,h);if(a){let s=1;h[0].set(1);const i=h.slice(s),a=Lt(t,e.addE(t),n.negate(),o,!1,i);if(a>0){s+=a;for(let t=1;t<s;t++)h[t].eq(r.I)&&(h[s-1]=(0,r.c)(h[t],h[t]=h[s-1]),s--)}const m=h.slice(0,s);m.sort((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);for(let t=0;t<s;++t)h[t]=m[t];return s}return function(t,e,s,n,o,a){const h=(0,r.m)(r.H,3);let m=0;const u=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(u.value())&&(h[0].setE(u),m=1);const l=(0,r.m)(r.H,2),c=Lt(t.mul(3),e.mul(2),s,o,!1,l);if(c<0)return n.isZero()?-1:0;for(let t=0;t<c;t++)o.containsCoordinate(l[t].value())&&h[m++].setE(l[t]);(0,r.C)(h,0,m,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const g=(0,r.m)(r.H,5);g[0].set(o.vmin);for(let t=0;t<m;t++)g[1+t].setE(h[t]);g[1+m].set(o.vmax);const d=m+2;let _=1,p=0;{const i=g[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(n).isZero()){const r=Bt(t,e,s,n);i.setError(r.estimateError(i.value())),a[p]=i,p++,_++}}for(let r=_;r<d;r++){const h=g[r].clone(),m=t.clone().mulThisE(h).addThisE(e).mulThisE(h).addThisE(s).mulThisE(h).addThisE(n).isZero();if(m||!g[r].eq(g[r-1])){if(m||kt(g[r-1].value(),g[r].value(),g[r-1].clone().addThisE(g[r]).divThisByPower2(2),t,e,s,n,h)){if(p>0&&h.eq(a[p-1]))continue;if(p>=3&&(0,i.d)("cubic_polynomial_solver_too_many_roots"),m){const i=Bt(t,e,s,n);h.setError(i.estimateError(h.value()))}a[p]=h,p++}if(g[r].value()===o.vmax)break;m&&r++}}return p}(t,e,s,n,o,h)}function Vt(t,e,s,n,o,a){return(a<e||e<0)&&(0,i.a)("nth_degree_real_roots"),function(t,e,s,i,n){const o=new Gt(t,e,s,(0,r.O)());let a=0;if(2===o.truePower)a=Lt(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Rt(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=It(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let t=0;t<a;t++)n[t].setError(o.getError(n[t].value()));return a}(t,e,s,n,o)}function Bt(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class Gt{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let s=0,i=this.truePower-t;s<=i;++s){e.push(this.coefs[s+t].clone());let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new r.K(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new r.K(0),i=new r.H(1),n=new r.H(0);for(let t=0,r=this.power;t<=r;++t)n.addThisE(this.coefs[t].mulE(i)),s.pe(i.value()*this.coefs[t].eps()),i.mulThis(e);s.pe(n.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);const i=new r.H(1),n=new r.H(0);for(let s=0,r=this.truePower-e;s<=r;++s)n.addThisE(this.curCoefs[s].mulE(i)),i.mulThis(t);if(!n.isZero())return Math.pow(o*s.getResult()/Math.abs(n.value()),1/e)}return 0}}function Ht(t,e,s,i,n,o){let a=t,h=e,m=h-a;if(!o){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(h=(0,r.c)(a,a=h),n=(0,r.c)(s,s=n)),s>=0||n<=0)return!1}let u,l=!1,c=s,g=0;for(;g<100;g++){const t=i.calcF(c);if(u=i.calcDF(c),u.isZero())return!1;if(!t.value()||g>3&&t.isZero()){l=!0;break}o||(t.value()<0?a=c:h=c);const e=t.value()/u.value(),s=c-e;o||(s>=a&&s<=h||s>=h&&s<=a)&&Math.abs(e)<=.5*m?(c=s,m=Math.abs(e)):(m=Math.abs(.5*(h-a)),c=.5*(a+h))}return!!l&&(n.set(c,i.estimateError(c)),!0)}function kt(t,e,s,i,n,r,o,a){return Ht(t,e,s.value(),Bt(i,n,r,o),a,!1)}class Wt{constructor(t,e,s){this.coefs=(0,r.m)(r.H,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new r.H(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new r.H(t);return r.H.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new r.H(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function jt(t,e,s,i,n){return Ht(0,0,t.value(),new Wt(e,s,i),n,!0)}var Zt=n.V;class Ut extends Q{constructor(t){return void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&(0,i.a)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,i.t)("unexpected constructor param"))}getBoundary(){return At(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Ti(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),Ti(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Ti(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.Envelope2D){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Gi(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ni(s,this.m_weights,e);const i=new r.P;for(const s of e)this.queryCoord2D(s,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof a.T){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new Ut({vd:this.m_description})}calculateLength2D(){return qi(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp):r.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),function(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const n=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],h=new r.H,m=new r.H,u=new r.H;if(s.value()<=.5){const t=(0,r.ad)(n[0],n[1],s),e=(0,r.ad)(n[1],n[2],s);h.setE((0,r.ad)(t,e,s));const i=(0,r.ad)(o[0],o[1],s),l=(0,r.ad)(o[1],o[2],s);m.setE((0,r.ad)(i,l,s));const c=(0,r.ad)(a[0],a[1],s),g=(0,r.ad)(a[1],a[2],s);u.setE((0,r.ad)(c,g,s))}else{const t=(0,r.ae)(n[0],n[1],s),e=(0,r.ae)(n[1],n[2],s);h.setE((0,r.ae)(t,e,s));const i=(0,r.ae)(o[0],o[1],s),l=(0,r.ae)(o[1],o[2],s);m.setE((0,r.ae)(i,l,s));const c=(0,r.ae)(a[0],a[1],s),g=(0,r.ae)(a[1],a[2],s);u.setE((0,r.ae)(c,g,s))}h.divThisE(u),m.divThisE(u);const l=new r.P(h.value(),m.value());Pn([t[0].value(),t[1].value(),t[2].value()],l),i.x.set(l.x,h.eps()),i.y.set(l.y,m.eps())}([y.constructPoint2D(i[0]),y.constructPoint2D(i[1]),y.constructPoint2D(i[2])],[new r.H(n[0]),new r.H(n[1]),new r.H(n[2])],e,s)}(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0)return void K(new Fr({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void K(new Fr({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}const i=(0,r.m)(r.P,3);this.queryControlPoints(i),cn(i,this.m_weights,t,e)}getCoordX(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Zt.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Zt.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=(0,r.d)(3,Number.NaN);t.queryWeights(o),function(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const o=(0,r.m)(y,4);(function(t,e,s,n,o){const a=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,s,n,o){(0,i.g)(!0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=y.constructCoords(0,0)}const h=Fi(a,e,0,n),m=function(t,e,s){if(s.toDouble()<=.5){const e=(0,r.ad)(t[0],t[1],s),i=(0,r.ad)(t[1],t[2],s);return(0,r.ad)(e,i,s)}{const e=(0,r.ae)(t[0],t[1],s),i=(0,r.ae)(t[1],t[2],s);return(0,r.ae)(e,i,s)}}(e,0,n),u=h.divE(m);o[0].setE(u);const l=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],c=Fi([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],l,0,n).mul(2),g=m.sqr(),d=c.divE(g);o[1].setE(d)}(a,[new r.H(e[0]),new r.H(e[1]),new r.H(e[2])],0,n,o)})(t,e,0,s,o),n.setE(o[1])}(n,o,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.a)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,3);this.queryControlPoints(n);const o=[0,0,0];Ki(n,this.m_weights,t,e,n,o),s.setControlPointsAndWeights(n,o)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Zt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Zt.getDefaultValue(e))}getClosestCoordinate(t,e){return ki(this,t,r.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return ki(this,t,0,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=Ii(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)Oi(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),o=(0,r.m)(r.H,2),a=new r.E(0,1);let h=0;const m=(0,r.m)(r.P,3);if(this.queryControlPoints(m),t){if(n[0]=new r.H(m[0].y).sub(e).mul(this.m_weights[0]),n[1]=new r.H(m[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.H(m[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.H(m[0].x).sub(e).mul(this.m_weights[0]),n[1]=new r.H(m[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new r.H(m[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.C)(s,0,h,r.a7);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.Envelope2D)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Ki(s,this.m_weights,t.vmin,t.vmax,s,[0,0,0]),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return qi(this,t,!0)}lengthToT(t){return function(t,e){const s=qi(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new zi(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=function(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=dn(e);if(1===s){const e=(0,r.m)(r.P,3);Oe(t,e);const s=e[2].clone(),i=e[1].clone(),n=new r.P,o=s.y*i.x-s.x*i.y;return n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60,n}if(0===s)return new r.P(0,0);(0,i.g)(s>0);const n=t[1].sub(t[0]),o=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atan2(t,e),a=s*t*e,h=s*s,m=n.mul(2*(2+h)),u=o.mul(2*h-5),l=m.add(u).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return l.add(c).mul(i)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),i=(n.y*o.x-n.x*o.y)*s/Math.pow(t*e,5)/12,r=Math.atanh(t/e),a=s*t*e,h=s*s,m=n.mul(4).sub(o.mul(5)),u=n.add(o).mul(2*h),l=m.add(u).mul(a),c=o.sub(n.mul(2*h)).mul(6*r);return l.add(c).mul(i)}}(e,s)}(this),s=Vi(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=Ii(t),a=Bi(t),h=a/t.calculateUpperLength2D();let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Ai(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}queryCoord2DMP(t,e){const s=(0,r.m)(r.P,3);return this.queryControlPoints(s),function(t,e,s,i){const n=s.lte(r.a6)?r.M.lerpLo:r.M.lerpHi,[o,a,h]=[e.map((e,s)=>t[s].x.mul(e)),e.map((e,s)=>t[s].y.mul(e)),e].map(([t,e,i])=>n(n(t,e,s),n(e,i,s),s)),m=new r.P(o.divThis(h).value(),a.divThis(h).value());Pn(t.map(t=>t.asPoint2D()),m),i.x=r.M.constructDouble(m.x),i.y=r.M.constructDouble(m.y)}(s.map(t=>C.constructPoint2D(t)),this.m_weights.map(t=>r.M.constructDouble(t)),r.M.constructDouble(t),e)}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),Li(e,this.m_weights,t)}getDerivative(t){const e=(0,r.s)(t,0,1),s=(0,r.m)(r.P,4);return Mi(this,1,e,s),s[1]}getCurvature(t){const e=(0,r.m)(r.P,4);Mi(this,2,t,e);const s=e[1].sqrLength();return 0===s?Number.NaN:(e[1].divThis(Math.sqrt(s)),e[1].crossProduct(e[2])/s)}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,3);return this.queryControlPoints(t),Ui(t)}getMonotonicPartParams(t,e){const s=Ii(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-i>t)return!1;const n=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/i>n)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Vi(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,i.g)(0),0}queryEnvelopeW(t,e){ji(this,t,e)}setSegmentFromCoordsForStitcher(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),i=r.P.sqrDistance(e[1],e[2]);let n=e[0].clone(),o=s;s>i&&(n=e[2].clone(),o=i);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(n)),a}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=r.P.sqrDistance(e[1],e[0]),i=r.P.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Oi(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformInPlace(t.m_cp):(0,r.U)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Oi(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Hi(e,Gi(this))}reverseImpl(){this.m_weights[2]=(0,r.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=(0,r.m)(r.P,3);this.queryControlPoints(i);const o=(0,r.m)(r.P,3);s.queryControlPoints(o);const a=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let t=0;t<3;t++){const s=new n.f;s.setCoordsPoint2DZ(i[t].mul(this.m_weights[t]),this.m_weights[t]);const r=new n.f;if(r.setCoordsPoint2DZ(o[t].mul(a[t]),a[t]),!s.isEqual(r,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,r.c)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ti(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(ji(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Ii(t);let h=0;const m=[];let u=a.specialPoints[0];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=wi(t,e,u,n);if(0===m.length)m.push(r);else if(r.t===r.tmin)(0,i.g)(m.at(-1).d<=r.d),m.at(-1).tmax=r.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,i.g)(m.at(-1).d>=r.d);const t=m.at(-1).tmin;m[m.length-1]=r,m.at(-1).tmin=t}else m.push(r);u=n}for(const t of m)if(t.d<=n){const e=t.t;s?(s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Ti(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,n,r,o){(n<=0||o<=0||r<0)&&(0,i.a)("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&(0,i.a)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}Ut.type=i.G.enumRationalBezier2;var Ot=n.V;class Qt extends Q{constructor(t){void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new r.P(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):(0,i.d)("unexpected constructor args")}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),Ee(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),Ee(this)}getGeometryType(){return i.G.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Ye(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[];De(this,e);const s=new r.P;for(const i of e)this.queryCoord2D(i,s),t.mergeNe(s)}return}(0,i.t)("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}(0,i.g)(0)}createInstance(){return new Qt({vd:this.m_description})}calculateLength2D(){return Se(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return r.P.distance(this.getStartXY(),this.m_cp)+r.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=(0,r.m)(r.P,3);this.queryControlPoints(i),$e(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=y.constructPoint2D(t[1]),n=new y;(0,r.a3)(2,y.constructPoint2D(t[0]),i,e,n);const o=new y;(0,r.a3)(2,i,y.constructPoint2D(t[2]),e,o);const a=new y;(0,r.a3)(2,n,o,e,a),s.setE(a)}else{const i=y.constructPoint2D(t[1]),n=new y;(0,r.a4)(2,y.constructPoint2D(t[0]),i,e,n);const o=new y;(0,r.a4)(2,i,y.constructPoint2D(t[2]),e,o);const a=new y;(0,r.a4)(2,n,o,e,a),s.setE(a)}}(i,e,s)}(this,t,e)}queryCoord2DMP(t,e){(0,i.g)(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=(0,r.X)(this.getStartX(),this.m_cp.x,t),s=(0,r.X)(this.m_cp.x,this.getEndX(),t);return(0,r.X)(e,s,t)}{const e=(0,r.Y)(this.getStartX(),this.m_cp.x,t),s=(0,r.Y)(this.m_cp.x,this.getEndX(),t);return(0,r.Y)(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=(0,r.X)(this.getStartX(),this.m_cp.x,t),s=(0,r.X)(this.m_cp.x,this.getEndX(),t);return(0,r.X)(e,s,t)}{const e=(0,r.Y)(this.getStartY(),this.m_cp.y,t),s=(0,r.Y)(this.m_cp.y,this.getEndY(),t);return(0,r.Y)(e,s,t)}}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=Ot.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=Ot.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){{const e=y.constructPoint2D(t[1]).subE(y.constructPoint2D(t[0])),i=new r.H(1).subE(s),n=y.constructPoint2D(t[2]).subE(y.constructPoint2D(t[1])),o=e.mulE(i).addE(n.mulE(s));return o.mulThisE(new r.H(2)),o}}(t,0,e))}(i,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&(0,i.a)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const n=(0,r.m)(r.P,3);this.queryControlPoints(n),He(n,t,e,n),s.constructPoints(n)}splitBezierIgnoreAttributes(t,e,s){(0,i.g)(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Ot.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Ot.getDefaultValue(e))}getClosestCoordinate(t,e){return Fe(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Fe(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=be(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)Ve(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.H,3),o=(0,r.m)(r.H,2),a=new r.E(0,1);let h=0;if(t){if(n[0]=new r.H(this.getStartY()).sub(e),n[1]=new r.H(this.m_cp.y).subE(new r.H(this.getStartY())).mulThisByPower2(2),n[2]=new r.H(this.getStartY()).add(this.getEndY()).subE(new r.H(this.m_cp.y).mulThisByPower2(2)),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(n[0]=new r.H(this.getStartX()).sub(e),n[1]=new r.H(this.m_cp.x).subE(new r.H(this.getStartX())).mulThisByPower2(2),n[2]=new r.H(this.getStartX()).add(this.getEndX()).subE(new r.H(this.m_cp.x).mulThisByPower2(2)),h=Lt(n[2],n[1],n[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,r.Z)(s,h);return h}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new o.Envelope2D;this.queryEnvelope(t);const s=new r.E;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),He(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Se(this,t,!0)}lengthToT(t){return function(t,e){const s=Se(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new ve(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,3);!function(t,e,s=!1){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),Oe(i,e,s)}(this,e);const s=e[2],i=e[1],n=new r.P,o=s.y*i.x-s.x*i.y;n.x=-(4*s.x+5*i.x)*o/60,n.y=-(4*s.y+5*i.y)*o/60;const a=qe(this);return n.x+=(e[0].x-t.x)*a,n.y+=(e[0].y-t.y)*a,n}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=be(t),a=B(t),h=Math.min(a/t.calculateUpperLength2D(),1e-7);let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Ce(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPoints(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,i.a)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.s)(t,0,1);let s=Ie(this,1,e);return s.isZero()&&(s=Ie(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Ie(this,1,(0,r.s)(t,0,1))}getCurvature(t){const e=Ie(this,1,t),s=Ie(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new o.Envelope2D;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){const s=be(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])-i>t)return!1;const n=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(s))/i>n)}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return qe(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){const s=(0,r.m)(r.P,3);this.queryControlPoints(s),Le(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);let o=s[0].clone(),a=i;i>n&&(o=s[2].clone(),a=n);let h=!1;return a<=e&&0!==a&&(h=!0,t.setControlPoint1(o)),h}(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=r.P.sqrDistance(s[1],s[0]),n=r.P.sqrDistance(s[1],s[2]);s[0].clone();let o=i;return i>n&&(s[2].clone(),o=n),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ve(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformInPlace(t.m_cp):(0,r.U)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Ve(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Xe(e,Ye(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=(0,r.c)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ee(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,i,n){const o=new p;if(function(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i),Le(i,e,s)}(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=new r.P,h=Fe(t,e,r.E.unit(),!1);return t.queryCoord2D(h,a),r.P.distance(a,e)<=n?(i&&(i[0]=h),1):0}(this,t,e.length,e,s)}endPointModified(){Ee(this)}clearEndPointModified(){}}Qt.type=i.G.enumBezier2;class $t{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,i.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}scaleRangeToUnitInterval(t,e){const s=e;s.subThis(t);const i=this.power();for(let e=0;e<=i;e++){const n=new this.m_zeroCtor;for(let s=e;s<=i;s++){const i=this.m_elements[s];i.mulDoubleThis((0,r.ao)(s,e));const o=t.pow(s-e);i.mulThis(o),n.addThis(i)}const o=s.pow(e);n.mulThis(o),this.m_elements[e]=n}}fmSubThis(t,e){return(0,i.g)(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].addThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,i.g)(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(t){return(0,i.g)(0),this}subNumber0(t){return(0,i.g)(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let s=e;s<=n;++s)this.m_elements[s].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=n+1;e<=i;++e)this.m_elements[e].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let i=s;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let s=r+1;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let i=0,n=e.power();i<=n;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return(0,i.g)(0),this}mulBigint0(t){return(0,i.g)(0),this}mulBigIntThis(t){return(0,i.g)(0),this}mulInt320(t){return(0,i.g)(0),this}div0(t){return(0,i.g)(0),this}absThis(){return(0,i.g)(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let o=n.power();const a=n.power()-t.power();let h=a;for(e.m_elements=(0,r.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){s.assignMove(n);break}if(o===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[h]=s.clone()}h--,o--}s.updatePower(),e.updatePower()}divThis(t){return(0,i.g)(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,i.g)(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(r.M.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{const s=e.hiBitIndex();return t<s?s:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){const e=this.power(),s=this.m_elements[e];s.mulDoubleThis(e);for(let i=e-1;i>=1;--i){s.mulThis(t);const e=this.m_elements[i];e.mulDoubleThis(i),s.addThis(e)}return s}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class Kt extends $t{constructor(t){super(void 0===t?{zeroCtor:r.M}:{...t,zeroCtor:r.M})}clone(){return new Kt({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let t=e-1;t>=0;--t)s.mulThis(i),s.addThis(this.m_elements[t].abs());return s}}class Jt extends $t{constructor(t){super(void 0===t?{zeroCtor:Kt}:{...t,zeroCtor:Kt})}clone(){return new Jt({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new Kt({coef0:t[s]}));return this.updatePower(),this}}function te(t,e,s,n,o,a,h,m,u,l,c,g,d,_,p,f,x,P,y,v=!1){const C={polypoly1:new Jt,polypoly2:new Jt,polyX2:new Kt,polyY2:new Kt,polyX2Deriv:new Kt,polyY2Deriv:new Kt,polypolyX1:new Jt,polypolyY1:new Jt,polypolyX1Deriv:new Jt,polypolyY1Deriv:new Jt,lazyPolypolyD1:new Jt,lazyPolypolyD1Deriv:new Jt,lazyPolyD2:new Kt,lazyPolyD2Deriv:null,polypoly11:new Jt,polypoly12:new Jt,tempPp:new Jt,tempPp1:new Jt,tempPp2:new Jt,tempP:new Kt,tempP1:new Kt,tempP2:new Kt};C.polyX2.construct(h,m),C.polyY2.construct(u,l),C.polypolyX1.constructFromMPValues(t,e),C.polypolyY1.constructFromMPValues(s,n),C.polypoly11.assignCopy(C.polypolyX1),C.polypoly12.assignCopy(C.polypolyY1),c&&(C.lazyPolyD2.construct(c,g),C.polypoly11.mulElementThis(C.lazyPolyD2),C.polypoly12.mulElementThis(C.lazyPolyD2)),o?(C.lazyPolypolyD1.constructFromMPValues(o,a),C.lazyPolypolyD1Deriv=new Jt({copy:C.lazyPolypolyD1}),C.lazyPolypolyD1Deriv.derivative1This(),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyX2),C.polypoly11.subThis(C.tempPp),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyY2),C.polypoly12.subThis(C.tempPp)):(C.polypoly11.sub0This(C.polyX2),C.polypoly12.sub0This(C.polyY2)),C.polypolyX1Deriv.assignCopy(C.polypolyX1),C.polypolyX1Deriv.derivative1This(),C.polypolyY1Deriv.assignCopy(C.polypolyY1),C.polypolyY1Deriv.derivative1This(),o&&(C.polypolyX1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyX1),C.polypolyX1Deriv.subThis(C.tempPp2),C.polypolyY1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyY1),C.polypolyY1Deriv.subThis(C.tempPp2)),C.polyX2Deriv.assignCopy(C.polyX2),C.polyX2Deriv.derivative1This(),C.polyY2Deriv.assignCopy(C.polyY2),C.polyY2Deriv.derivative1This(),c&&((0,i.g)(null===C.lazyPolyD2Deriv),C.lazyPolyD2Deriv=new Kt({copy:C.lazyPolyD2}),C.lazyPolyD2Deriv.derivative1This(),C.polyX2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyX2),C.polyX2Deriv.subThis(C.tempP1),C.polyY2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyY2),C.polyY2Deriv.subThis(C.tempP1)),C.polypoly1.assignCopy(C.polypoly11),C.polypoly1.mulElementThis(C.polyX2Deriv),C.tempPp.assignCopy(C.polypoly12),C.tempPp.mulElementThis(C.polyY2Deriv),C.polypoly1.addThis(C.tempPp),C.polypoly2.assignCopy(C.polypolyX1Deriv),C.polypoly2.mulElementThis(C.polyY2Deriv),C.tempPp.assignCopy(C.polypolyY1Deriv),C.tempPp.mulElementThis(C.polyX2Deriv),C.polypoly2.subThis(C.tempPp);let E=[];const b=[];x||(x=[]),f||(f=[]),he(C.polypoly11,C.polypoly12,C.tempP);const D=r.ai.ldexp(-59).toDouble(),S=[];let w=me(C.tempP,0,p,D,64,S,P,P);if(w<0)return-1;for(let t=0;t<w;t++){const e=C.tempP1,s=C.tempP2;Kt.evaluateCoefs(C.polypoly11,S[t],e);const n=(0,r.aj)(e.m_elements,e.power()+1);n.sort((t,e)=>t.compare(e)),Kt.evaluateCoefs(C.polypoly12,S[t],s);const o=(0,r.aj)(s.m_elements,s.power()+1);o.sort((t,e)=>t.compare(e));const a=n[0],h=n.at(-1),m=o[0],u=o.at(-1);h.subThis(a),u.subThis(m);const l=h.subThis(u).GEZ(),c=58,g=[];let d;if(d=me(l?e:s,0,_,r.ai.ldexp(-59).toDouble(),c,g,P,P),d<0&&(0,i.d)("mp_curve_proximity"),d>0){const n=l?s:e;for(let e=0;e<d;e++){let s;if(l){const i=C.tempP;Kt.evaluateCoefs(C.polypoly12,S[t].addDouble(Number.EPSILON),i),s=i.evaluate(g[e])}else{const i=C.tempP;Kt.evaluateCoefs(C.polypoly11,S[t].addDouble(Number.EPSILON),i),s=i.evaluate(g[e])}const o=n.evaluateDerivative(g[e]).abs().mulDoubleThis(Number.EPSILON),a=n.evaluate(g[e]);o.addThis(s.sub(a).absThis()),o.ldexpThis(3),a.absThis(),a.lt(o)?b.push((0,r.k)(g[e].toDouble(),S[t].toDouble())):(0,i.g)(a.gte(o))}}}w=b.length,he(C.polypoly1,C.polypoly2,C.tempP);const A=[];let T=me(C.tempP,0,p,D,64,A);T<0&&(T=0);for(let t=0;t<T;t++){Kt.evaluateCoefs(C.polypoly1,A[t],C.tempP1);const e=[];let s=me(C.tempP1,0,_,D,64,e);if(0!==s)if(Kt.evaluateCoefs(C.polypoly2,A[t],C.tempP2),s<0){if(s=me(C.tempP2,0,_,D,64,e),s<0)continue;for(let i=0;i<s;i++)E.push((0,r.k)(e[i].toDouble(),A[t].toDouble()))}else{const i=C.tempP2.absEvaluate(r.ai);i.mulThis(r.M.constructDouble(1e-12));for(let n=0;n<s;n++){const s=C.tempP2.evaluate(e[n]);s.absThis(),s.lt(i)&&E.push((0,r.k)(e[n].toDouble(),A[t].toDouble()))}}}if(T=E.length,0===w&&0===T)return 0;E=E.concat(b),E.sort((t,e)=>v?(0,r.a7)(t.second,e.second):(0,r.a7)(t.first,e.first));const I=(0,r.u)(E,(t,e)=>t.first===e.first&&t.second===e.second);E=E.slice(0,I),f.length=0,x.length=0;for(const t of E)f.push(t.first),x.push(t.second);return(0,i.g)(f.length===x.length),x.length}function ee(t,e,s,i,n,o,a,h,m,u,l,c,g){const d={polyIntersect:new Kt,polyX1:new Kt,polyY1:new Kt,polyX1Deriv:new Kt,polyY1Deriv:new Kt,lazyPolyD1:new Kt,lazyPolyD1Deriv:new Kt,tempP:new Kt,tempP1:new Kt,tempP2:new Kt,polypoly1Proximity:new Jt,polypoly2Proximity:new Jt};d.polyX1.construct(t,e),d.polyY1.construct(s,i),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.polyIntersect.assignCopy(d.polyX1),d.polyIntersect.mulThis(d.polyX1),d.polyIntersect.mulElementThis(a[0]),d.tempP.assignCopy(d.polyY1),d.tempP.mulThis(d.polyY1),d.tempP.mulElementThis(a[1]),d.polyIntersect.addThis(d.tempP),n?(d.lazyPolyD1.construct(n,o),d.tempP.assignCopy(d.lazyPolyD1),d.tempP.mulThis(d.lazyPolyD1),d.tempP.mulElementThis(a[2]),d.polyIntersect.addThis(d.tempP)):d.polyIntersect.add0(a[2]);{const n=a[0].clone(),o=n.clone();o.sqrThis();const h=a[1].clone(),m=h.clone();m.sqrThis();const u=a[2].clone(),l=n.clone();l.subThis(h),d.polyX1.construct(t,e),d.polyX1Deriv.assignCopy(d.polyX1),d.polyX1Deriv.derivative1This(),d.polyY1.construct(s,i),d.polyY1Deriv.assignCopy(d.polyY1),d.polyY1Deriv.derivative1This(),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(m),d.tempP.mulElementThis(u),d.polypoly1Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(h.mul(l).mul(u).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1),d.tempP.mulElementThis(n.mul(m)),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1),d.tempP1.mulElementThis(o.mul(h)),d.tempP.addThis(d.tempP1),d.tempP.add0(l.mul(l).mul(u)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulElementThis(l.mul(n).mul(h).ldexpThis(1)),d.polypoly1Proximity.addElement(d.tempP),d.tempP.construct0(n.mul(l).mul(l)),d.polypoly1Proximity.addElement(d.tempP),d.polypoly1Proximity.updatePower(),d.tempP.construct0(r.ah),d.polypoly2Proximity.construct0(d.tempP),d.tempP.assignCopy(d.polyX1),d.tempP.mulThis(d.polyX1Deriv),d.tempP1.assignCopy(d.polyY1),d.tempP1.mulThis(d.polyY1Deriv),d.tempP.addThis(d.tempP1),d.tempP.mulElementThis(n.mul(h)),d.polypoly2Proximity.addElement(d.tempP),d.tempP.assignCopy(d.polyX1Deriv),d.tempP.mulElementThis(l.mul(n)),d.polypoly2Proximity.addElement(d.tempP),d.polypoly2Proximity.updatePower()}const _=[],p=[];null===l&&(l=[]);let f=2*d.polyIntersect.power()+58;const x=.5*Number.EPSILON,P=[],y=me(d.polyIntersect,0,m,x,f,P,c,c);if(y<0)return-1;for(const t of P)p.push(t.toDouble());he(d.polypoly1Proximity,d.polypoly2Proximity,d.tempP),f=2*d.tempP.power()+58,P.length=0;let v=me(d.tempP,0,m,x,f,P);if(v<0&&(v=0),0===y&&0===v)return 0;for(const t of P)_.push(t.toDouble());const C=_.concat(p);l.length=C.length,(0,r.b)(l,C,0,0,C.length),(0,r.v)(l);const E=(0,r.u)(l,(t,e)=>0===(0,r.a7)(t,e));return l.length=E,l.length}function se(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function ie(t,e,s,i,n,o,a){if(t.isZero())return o?(a[0].setInt32(1),n.containsCoordinate(1)?1:0):se(e,s,n,a[0]);if(o){let e=2;return a[0].setInt32(1),s.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(s.div(t)),n.containsCoordinate(a[1].value())||(e=1),n.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,r.c)(a[0],a[0]=a[1])),e}const h=e.clone();h.sqrThis();const m=t.clone();if(m.mulThis(s).ldexpThis(2).negateThis().addThis(h),m.LZ())return 0;const u=i+2,l=r.M.sqrt(m,u),c=l.clone();e.LZ()&&c.negateThis(),c.addThis(e).limitPrecisionThis(u).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(c).divThis(r.M.constructAssign(t,u)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(a[0].value()))&&g++,l.isZero()||c.isZero()||(a[g].setThis(s).divThis(c).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,r.c)(a[0],a[0]=a[1]))),g}function ne(t,e,s,n,o,a,h,m){if(t.isZero())return ie(e,s,n,o,a,h,m);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.C)(m,0,e,(t,e)=>t.compare(e)),e};if(n.isZero()){let i=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),i=1),u(ie(t,e,s,o,a,h,m.slice(1)),i)}if(h){let s=0;a.containsCoordinate(1)&&(m[0].setInt32(1),s=1);const i=e.add(t),r=n.negate(),h=t.add(i).add(r).isZero();return u(ie(t,i,r,o,a,h,m.slice(s)),s)}const l=new r.M,c=new r.M,g=new r.M,d=e.clone();if(d.isZero())c.setThis(s),c.divThis(t),g.setThis(n),g.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();const i=e.clone();i.sqrThis();const r=t.clone();r.sqrThis(),c.setThis(t),c.mulThis(s).mulDoubleThis(3).subThis(i).divThis(r).divDoubleThis(3),g.setThis(i),g.mulThis(e),g.ldexpThis(1),l.setThis(t),l.mulThis(e).mulThis(s).mulDoubleThis(9),g.subThis(l),l.setThis(r),l.mulThis(n).mulDoubleThis(27),g.addThis(l),g.divThis(r).divThis(t).divDoubleThis(27)}if(c.isZero()){const t=g.clone();return t.negateThis(),t.isZero()?(m[0].setThis(d),pe(a,o,m,1)):(m[0].setThis(r.M.cubicRoot(t,o).add(d)),pe(a,o,m,1))}const _=g.clone();if(_.sqrThis().ldexpThis(-2),l.setThis(c.clone()),l.sqrThis().mulThis(c).divDoubleThis(27),_.addThis(l),_.isZero())return m[0].setThis(g),m[0].mulDoubleThis(3).divThis(c),m[1].setThis(m[0]),m[1].negateThis(),m[1].ldexpThis(-1),m[0].addThis(d),m[1].addThis(d),pe(a,o,m,2);if(_.GZ())return _.setThis(r.M.sqrt(_,o+8)),l.setThis(g),l.ldexpThis(-1).negateThis(),l.addThis(_),m[0].setThis(r.M.cubicRoot(l,o+8)),l.setThis(g),l.ldexpThis(-1).negateThis(),l.subThis(_),m[0].addThis(r.M.cubicRoot(l,o+8)),m[0].addThis(d),pe(a,o,m,1);l.setThis(c),l.divDoubleThis(3).negateThis(),(0,i.g)(l.GEZ());const p=r.M.sqrt(l,o+8),f=p.clone();f.negateThis(),f.addThis(d),p.addThis(d);const x=r.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),P=r.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),y=new Kt({zeroCtor:r.M});y.construct0(n),y.addElement(s),y.addElement(e),y.addElement(t);const v=new Kt({copy:y});v.derivative1This();let C=0;const E=(0,r.m)(r.M,4);E[C++].setThis(x),f.gt(x)&&f.lt(P)&&E[C++].setThis(f),p.gt(x)&&p.lt(P)&&E[C++].setThis(p),E[C++].setThis(P);const b=3*o;let D=52,S=Number.EPSILON;for(;D<b;)2*D<=b?(S*=S,D*=2):(S*=Number.EPSILON,D+=52);D+=2;let w=0,A=!1;for(let t=1;t<C;t++)if(ce(y,v,E[t-1],E[t],S,D,m[0])){w=1,A=t+1<C;break}if(!w)return 0;if(A){const t=new Kt({zeroCtor:r.M,coef0:m[0]});t.negateThis(),t.addElement(r.ai);const e=new Kt({zeroCtor:r.M}),s=new Kt({zeroCtor:r.M});y.div(t,e,s),(0,i.g)(2===e.power()),(0,i.g)(0===s.power());const n=ie(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,m.slice(1));(0,i.g)(n>=0&&n<=2),w+=n}return pe(a,o,m,w)}function re(t,e,s,i,n,o,a,h,m){if(t.isZero())return ne(e,s,i,n,o,a,h,m);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,r.c)(m[t],m[t]=m[s-1]),s--);e=s}return(0,r.C)(m,0,e,(t,e)=>t.compare(e)),e};if(n.isZero()){let n=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),n=1),u(ne(t,e,s,i,o,a,h,m.slice(n)),n)}const l=new Kt({zeroCtor:r.M,coef0:n});if(l.addElement(i),l.addElement(s),l.addElement(e),l.addElement(t),h){let t=0;a.containsCoordinate(1)&&(m[0].setInt32(1),t=1);const e=new Kt({zeroCtor:r.M,coef0:r.M.constructInt32(-1)});e.addElement(r.M.constructInt32(1));const s=new Kt({zeroCtor:r.M}),i=new Kt({zeroCtor:r.M});return l.div(e,s,i),u(ne(3===s.power()?s.getElement(3):r.ah.clone(),s.power()>=2?s.getElement(2):r.ah.clone(),s.power()>=1?s.getElement(1):r.ah.clone(),s.getElement(0),o,a,s.evaluate(r.ai).isZero(),m.slice(t)),t)}if(l.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,m[0].setDouble(0));l.getElement(0).isZero()&&l.power()>0;)l.shiftRight(1);const e=ne(3===l.power()?l.getElement(3):r.ah.clone(),l.power()>=2?l.getElement(2):r.ah.clone(),l.power()>=1?l.getElement(1):r.ah.clone(),l.getElement(0),o,a,!1,m.slice(t));return e>0&&(t+=e),(0,r.C)(m,0,t,(t,e)=>t.compare(e)),t}let c=52,g=Number.EPSILON;for(;c<o;)2*c<=o?(g*=g,c*=2):(g*=Number.EPSILON,c+=52);c+=2;const d=_e(l),_=r.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(d.lt(_)?d:_).mul(r.M.constructDouble(g)).toDouble(),de(l,a,g,c,h,0,m,4)}function oe(t,e){let s=t,i=e;i.power()>s.power()&&(i=(0,r.c)(s,s=i));const n=s.power()-i.power(),o=new Kt({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let t=0,e=s.power();t<e;t++)if(t>=n){const e=new Kt({copy:i.getElement(t-n)});e.mulThis(o);const r=s.getElement(t).sub(e);s.setElement(t,r)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),ae(s)}function ae(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function he(t,e,s){const i=t.clone(),n=e.clone();for(ae(i),ae(n);0!==i.power()||0!==n.power();)oe(i,n);s.assignMove(i.getElement(0))}function me(t,e,s,i,n,o,a=!1,h=!1){o.length=0;const m=t.power(),u=(0,r.m)(r.M,2*m+4),l=function(t,e,s,i,n,o,a){if(0===t.power())return t.isZero()?-1:0;const h=t.evaluate(r.M.constructInt32(1)).isZero();if(1===t.power()){const s=se(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(i),1!==s?0:(o[0].limitPrecisionThis(i),1)}return 2===t.power()?ie(t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):3===t.power()?ne(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):4===t.power()?re(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):de(t,e,s,i,h,0,o,a)}(t,s||r.E.unit(),i,n,0,u,u.length);if(l>0){o.length=0;for(let t=0;t<l;t++){const e=u[t];t>0&&e.lte(o.at(-1))||o.push(e.clone())}return o.length}return l}function ue(t,e,s){if((0,i.g)(s>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function le(t,e,s,n){if(t.power()<2)return ue(t,s,n);(0,i.g)(n>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));const a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){const i=t.getElement(1);return i.negateThis(),i.divThis(t.getElement(2)),i.ldexpThis(-1),i.limitPrecisionThis(e),s[0].setThis(i),1}(0,i.g)(n>=2),o=r.M.sqrt(o,e+8);const h=t.getElement(1);h.negateThis();const m=h.clone();m.subThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e);const u=h.clone();return u.addThis(o),u.divThis(t.getElement(2)),u.ldexpThis(-1),u.limitPrecisionThis(e),m.lt(u)?(s[0].setThis(m),s[1].setThis(u)):(s[1].setThis(m),s[0].setThis(u)),2}function ce(t,e,s,n,o,a,h){let m=s.clone(),u=n.clone();m.limitPrecisionThis(a),u.limitPrecisionThis(a);let l=t.evaluate(m);l.limitPrecisionThis(a+2);let c=t.evaluate(u);if(c.limitPrecisionThis(a+2),l.GEZ()&&c.GEZ()||l.LEZ()&&c.LEZ())return l.absLessAbs(c)?(h=m,l.isZero()):(h=u,c.isZero());const g=c.LZ();g&&(c=(0,r.c)(l,l=c),u=(0,r.c)(m,m=u));const d=g?u:m,_=g?m:u,p=m.add(u).ldexpThis(-1);p.limitPrecisionThis(a);const f=u.sub(m);f.limitPrecisionThis(a),f.absThis();const x=f.clone();let P=t.evaluate(p),y=e.evaluate(p);const v=new Kt({copy:t}),C=new Kt({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=r.ai.clone();i.ldexpThis(-(a+2));for(let n=64;n<s;){v.limitPrecisionThis(n),C.limitPrecisionThis(n);const r=v.evaluate(p),o=C.evaluate(p),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(i)&&(y.isZero()||h.divThis(y).absThis().lt(i)))break;v.assignCopy(t),C.assignCopy(e),n=Math.min(n+64,s)}P.limitPrecisionThis(a+2),y.limitPrecisionThis(a+2)}let E=4,b=1,D=0,S=0,w=1;const A=r.M.constructDouble(.25*o),T=r.M.constructDouble(.5001);let I=0;for(;++I<300;){if(I>32&&D>0||y.isZero()||2===w&&D>1||1===w&&E<4)w=1,b>1&&b--;else if(w=2,S>1){const t=f.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&b++}f.setThis(x);const t=new r.M;let e=!1;if(1===w)do{if(S>2){const e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(d).ldexpThis(-1).gt(e)){if(p.equals(d)){t.setThis(p),p.setThis(d.add(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}}}x.setThis(u.sub(m)),x.ldexpThis(-1),x.limitPrecisionThis(a),t.setThis(p),p.setThis(m.add(x)),p.limitPrecisionThis(a),p.lt(d)?p.setThis(d):p.gt(_)&&p.setThis(_),e=m.equals(p)||u.equals(p)}while(0);else for(;;){if(x.setThis(P.div(y)),x.limitPrecisionThis(a),1!==b&&x.mulDoubleThis(b),t.setThis(p),p.subThis(x),p.limitPrecisionThis(a),e=p.equals(t),p.lt(d)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(d)),p.setThis(d)}else if(p.gt(_)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(_)),p.setThis(_)}break}if(e||x.absLessAbs(A)){t.equals(p)||(P=v.evaluate(p),P.limitPrecisionThis(a+2));break}P=v.evaluate(p),P.limitPrecisionThis(a+2),y=C.evaluate(p),y.limitPrecisionThis(a+2);const s=m.clone(),i=u.clone();P.LZ()?(l.setThis(P),m.setThis(p)):(c.setThis(P),u.setThis(p)),2===w&&(m.equals(s)&&u.equals(i)||S>1&&!x.absLessAbs(T.mul(f)))?D++:D=0,1===w?(E++,S=0):(E=0,S++)}return I>=300&&(0,i.d)("Root_finder iterations exceeded"),h.setThis(p),!0}function ge(t,e,s,i,n){const o=t.evaluate(s);if(o.isZero())return!0;const a=r.M.constructDouble(.5*i),h=s.clone();h.subThis(a);const m=t.evaluate(h),u=s.clone();u.addThis(a);const l=t.evaluate(u);if(m.LZ()&&l.GZ()||m.GZ()&&l.LZ())return!0;if(o.GZ()?m.LEZ()||l.LEZ():m.GEZ()||l.GEZ())return!0;const c=m.LEZ()&&l.LEZ(),g=m.GEZ()&&l.GEZ();let d=!1;return c?o.gt(m)&&o.gt(l)&&(d=!0):g&&o.lt(m)&&o.lt(l)&&(d=!0),!!d&&o.absThis().lt(r.M.constructDouble(1e-17))}function de(t,e,s,n,o,a,h,m){(0,i.g)(s>0),(0,i.g)(m>=t.power());const u=h,l=[];let c=[];const g=new Kt({zeroCtor:t.m_zeroCtor}),d=new Kt({zeroCtor:t.m_zeroCtor}),_=new Kt({zeroCtor:t.m_zeroCtor}),p=r.M.constructDouble(s),f=r.M.constructDouble(e.vmin),x=r.M.constructDouble(e.vmax),P=f.sub(p),y=x.add(p),v=_e(t),C=v.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(p));else if(P.gt(v))return 0;if(y.gt(v))y.setThis(v.add(p));else if(y.lt(C))return 0;let E=t,b=null;if(o){const e=new Kt({coef0:r.M.constructInt32(-1)});e.addElement(r.ai),b=new Kt,E=b;const s=new Kt,i=new Kt;for(t.div(e,s,i),b.assignCopy(s);E.evaluate(r.ai).isZero();)E.div(e,s,i),b.assignCopy(s)}let D=!1;if(E.power()>0&&E.getElement(0).isZero())for(D=!0,b||(b=new Kt({copy:E}),E=b);E.getElement(0).isZero();)b.shiftRight(1);let S=n+2*E.power()+2,w=s/Math.pow(2,E.power()+2),A=S;if(r.ah.gt(P)&&r.ah.lt(y))for(let t=0,e=E.power();t<e;t++)if(E.getElement(t).isZero()){l.push(r.ah.clone());break}for(let t=E.power()-1;t>0;t--)if(w*=2,S-=2,A-=2,E.power()-t!==1){if(E.power()-t===2){d.assignMove(E.derivative(t));const e=le(d,S,u,m);(0,i.g)(e>=0&&e<=2);for(let t=0;t<e;t++)u[t].gt(P)&&u[t].lt(y)&&!u[t].isZero()&&l.push(u[t].clone());if(l.length>1&&l.sort((t,e)=>t.compare(e)),l.length>0){let t=l[0].sub(p);t.limitPrecisionThis(A),c.push((0,r.k)(P.clone(),t));let e=1===l.length?y.clone():l[1].sub(p);t=l[0].add(p),t.limitPrecisionThis(A),e.limitPrecisionThis(A),c.push((0,r.k)(t,e)),l.length>1&&(e=2===l.length?y.clone():l[2].sub(p),e.limitPrecisionThis(A),t=l[1].add(p),t.limitPrecisionThis(A),c.push((0,r.k)(t,e)),l.length>2&&(t=l[2].add(p),t.limitPrecisionThis(A),c.push((0,r.k)(t,y.clone()))))}else c.push((0,r.k)(P.clone(),y.clone()));g.assignCopy(d),_.assignMove(E.derivative(t-1));continue}{d.assignMove(_),_.assignMove(E.derivative(t-1));let e=[];for(let t=0,s=c.length;t<s;++t)if(c[t].first.lte(c[t].second)){const s=new r.M;if(ce(d,g,c[t].first,c[t].second,w,S,s)){l.push(s);let i=s.sub(p);i.limitPrecisionThis(A),e.push((0,r.k)(c[t].first,i)),i=s.add(p),i.limitPrecisionThis(A),e.push((0,r.k)(i,c[t].second))}else e.push(c[t])}c=e,e=[],g.assignMove(d)}}else d.assignMove(E.derivative(t)),1===ue(d,u,m)&&(u[0].gt(P)&&u[0].lt(y)&&!u[0].isZero()&&l.push(u[0].clone()),g.assignMove(d),_.assignMove(E.derivative(t-1)));l.sort((t,e)=>t.compare(e)),0===c.length&&(g.assignMove(E.derivative(E.power())),g.isZero()||c.push((0,r.k)(P.clone(),y.clone())));let T=0,I=0,N=0;const q=new r.M;for(;;){if(I<c.length){if(c[I].first.gt(c[I].second)){I++;continue}let t=!1;if(N<l.length&&l[N].lt(c[I].first)&&(t=!0),!t){ce(E,g,c[I].first,c[I].second,s,n,q)&&(q.lt(f)?u[T++].setThis(f):q.gt(x)?u[T++].setThis(x):u[T++].setThis(q)),I++;continue}}if(!(N<l.length))break;0!==N&&l[N-1].equals(l[N])||ge(E,0,l[N],s)&&(q.setThis(l[N]),q.lt(f)?q.setThis(f):q.gt(x)&&q.setThis(x),0!==T&&u[T].equals(q)||u[T++].setThis(q)),N++}return D&&r.ah.gt(P)&&r.ah.lt(y)&&(u[T++].setThis(r.ah),(0,r.C)(u,0,T,(t,e)=>t.compare(e))),o&&r.ai.gt(P)&&r.ai.lt(y)&&(u[T++].setThis(r.ai),(0,r.C)(u,0,T,(t,e)=>t.compare(e))),T}function _e(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=r.ah.clone();for(let e=0,i=t.power();e<i;e++){const i=t.getElement(e);i.limitPrecisionThis(53),i.gt(s)&&s.setThis(i)}return s.divThis(e),s.addThis(r.ai),s.mulThis(r.M.constructDouble(1+100*Number.EPSILON)),s}function pe(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=(0,r.c)(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=(0,r.c)(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=(0,r.c)(s[1],s[1]=s[2]))));for(let t=0;t<n;++t)s[t].limitPrecisionThis(e);return n}function fe(t,e,s,n,o,a){return function(t,e,s,n,o,a){if(s<e&&(0,i.a)("xTo < xFrom"),s===e)return 0;const h=[0];let m=Number.MAX_VALUE;const u=[Number.MAX_VALUE];let l=0;const c=(0,r.d)(33,Number.NaN),g=(0,r.d)(33,Number.NaN),d=[0];c[0]=1;let _=0,p=0;for(let r=0;r<32;r++){if(l=xe(e,s,n,0===r,l,d),g[r]=l,r+1>=t){Pe(r+1-t,t,c,g,0,h,u)||(0,i.d)("polynomial_interpolation");const e=o*Math.abs(h[0])+a,s=Math.abs(m-h[0]);if(s<=e&&Math.abs(u[0])<=e){if(_++,_>1&&(s<=.1*p||0===p||_>2))return h[0]}else _=0;p=s,m=h[0]}g[r+1]=g[r],c[r+1]=.25*c[r]}return h[0]}(t,e,s,a,n,o)}function xe(t,e,s,i,n,o){let a=n;if(i)return o[0]=1,a=.5*(e-t)*(s(t)+s(e)),a;const h=o[0],m=(e-t)/h,u=t,l=new r.K(0);for(let t=1;t<=o[0];++t){const e=(t-.5)*m;l.add(s(u+e))}return a=.5*(a+(e-t)*l.getResult()/h),o[0]*=2,a}function Pe(t,e,s,i,n,o,a){let h=0,m=Math.abs(n-s[t]);const u=(0,r.d)(e,Number.NaN),l=(0,r.d)(e,Number.NaN);for(let r=0;r<e;++r){const e=Math.abs(n-s[t+r]);e<m&&(h=r,m=e),u[r]=i[t+r],l[r]=i[t+r]}let c=0,g=0,d=0;o[0]=i[t+h],h--;for(let i=1;i<e;i++){for(let r=0;r<e-i;r++){if(g=s[t+r]-n,d=s[t+r+i]-n,c=g-d,0===c)return!1;const e=(u[r+1]-l[r])/c;u[r]=g*e,l[r]=d*e}if(2*(h+1)<e-i){const t=h+1;a[0]=u[t]}else{const t=h;a[0]=l[t],h--}o[0]+=a[0]}return!0}class ye{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ve=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Se(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}};function Ce(t,e,s,i,n){let o=!0;const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=o?0:1,m=a[1][h]-a[0][h],u=a[2][h]-a[0][h];const l=fe(5,e,s,i,n,t=>{let e;if(t<=.5){const s=(0,r.X)(0,m,t),i=(0,r.X)(m,u,t);e=(0,r.X)(s,i,t)}else{const s=(0,r.Y)(0,m,t),i=(0,r.Y)(m,u,t);e=(0,r.Y)(s,i,t)}return e*Ne(a,1,t).length()});o=!1,h=o?0:1,m=a[1][h]-a[0][h],u=a[2][h]-a[0][h];const c=fe(5,e,s,i,n,t=>{let e;if(t<=.5){const s=(0,r.X)(0,m,t),i=(0,r.X)(m,u,t);e=(0,r.X)(s,i,t)}else{const s=(0,r.Y)(0,m,t),i=(0,r.Y)(m,u,t);e=(0,r.Y)(s,i,t)}return e*Ne(a,1,t).length()});return new r.P(l,c)}function Ee(t){t.m_cachedValues=null}function be(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ye;return De(t,e.specialPoints),Xe(t,e),e}function De(t,e){const s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=(0,r.m)(r.H,8);i[0].set(0);let n=1;{const t=(0,r.m)(r.H,3);!function(t,e,s=!1){const i=new r.H(t[1][0]).subE(new r.H(t[0][0]));e[1]=i.mul(2),e[2]=new r.H(t[2][0]).subE(new r.H(t[1][0])).subE(i),s?e[0].set(0):e[0].set(t[0][0])}(s,t,!1);const e=(0,r.m)(r.H,2),o=new r.E(0,1);let a=Rt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.N)(e[t].value(),0,1)||(i[n]=e[t],n++)}{const t=(0,r.m)(r.H,3);!function(t,e,s=!1){const i=new r.H(t[1][1]).subE(new r.H(t[0][1]));e[1]=i.mul(2),e[2]=new r.H(t[2][1]).subE(new r.H(t[1][1])).subE(i),s?e[0].set(0):e[0].set(t[0][1])}(s,t,!1);const e=(0,r.m)(r.H,2),o=new r.E(0,1);let a=Rt(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,r.N)(e[t].value(),0,1)||(i[n]=e[t],n++)}if(i[n].set(1),n++,n>2){(0,r.C)(i,0,n,(t,e)=>t.value()-e.value());let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),e.length=n;for(let t=0;t<n;t++)e[t]=i[t].value()}function Se(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),we(i,e,s)}function we(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+we(t,1,!1)}if(1===e)return Ae(t);const i=(0,r.m)(r.P,3);return Ge(t,e,i,null),Ae(i)}function Ae(t){if(t[0].equals(t[1]))return r.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return r.P.distance(t[0],t[2]);const e=r.P.distance(t[0],t[1])+r.P.distance(t[2],t[1]),s=r.P.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const i=(0,r.m)(r.P,3);Oe(t,i,!0);const n=4*((0,r.a)(i[2].x)+(0,r.a)(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=(0,r.a)(i[1].x)+(0,r.a)(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(n))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*(Math.pow(1*o+a,1.5)-Math.pow(a,1.5));const h=o/n,m=a/n,u=m-h*h,l=1+h;if(0===u)return h>=0&&l>=0||h<=0&&l<=0?Math.abs(.5*Math.sqrt(n)*(l*l-h*h)):.5*Math.sqrt(n)*(l*l+h*h);const c=Math.sqrt(u+l*l),g=Math.sqrt(m);return.5*Math.sqrt(n)*(l*c-h*g+u*Math.log(Math.abs((l+c)/(h+g))))}function Te(t,e){const s=(0,r.s)(e,0,1);let i=Ne(t,1,s);return i.isZero()&&(i=Ne(t,2,s)),i}function Ie(t,e,s){const i=(0,r.m)(r.P,3);return t.queryControlPoints(i),Ne(i,e,s)}function Ne(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):r.P.construct(0,0)}function qe(t){const e=(0,r.m)(r.P,3);return t.queryControlPoints(e),Me(e)}function Me(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Ye(t){return t.m_cachedValues}function Xe(t,e){t.m_cachedValues=e}function Fe(t,e,s,n,o){(0,i.x)(r.E.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const a=(0,r.m)(r.P,3);t.queryControlPoints(a);let h=Number.MAX_VALUE;const m=[0],u=Re(a,e,m);if(s.containsCoordinate(m[0]))h=r.P.distance(e,u);else{m[0]=s.vmin,$e(a,m[0],u),h=r.P.distance(u,e);const t=new r.P;$e(a,s.vmax,t);const i=r.P.distance(t,e);h>i&&(u.setCoordsPoint2D(t),m[0]=s.vmax,h=i)}if(!n)return m[0];if(s.vmin<=0){const i=new r.P;t.queryCoord2DExtended(-1,i,!0);const n=new r.P;t.queryCoord2D(s.vmin,n);const o=new Fr({start:i,end:n}),a=o.getClosestCoordinate(e,!0);if(a<1){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=a-1,u.assign(t))}}if(s.vmin>=1){const i=new r.P;t.queryCoord2DExtended(2,i,!0);const n=new r.P;t.queryCoord2D(s.vmax,n);const o=new Fr({start:n,end:i}),a=o.getClosestCoordinate(e,!0);if(a>0){const t=o.getCoord2D(a),s=r.P.distance(t,e);s<h&&(h=s,m[0]=1+a,u.assign(t))}}return m[0]}function Re(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(n),h=o.dotProduct(i)+2*n.dotProduct(n),m=3*n.dotProduct(i),u=i.dotProduct(i),l=(0,r.d)(3,Number.NaN),c=qt(u,m,h,a,r.E.unit(),!1,l),g=t[0].clone();let d=0,_=r.P.sqrDistance(t[0],e),p=r.P.sqrDistance(t[2],e);p<_&&(d=1,g.assign(t[2]),_=p);for(let s=0;s<c;s++){const i=new r.P;$e(t,l[s],i),p=r.P.sqrDistance(i,e),p<_&&(_=p,g.assign(i),d=l[s])}return s&&(s[0]=d),g}function Le(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=(0,r.m)(r.P,3);He(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function ze(t,e,s){s.setEmpty();const i=[];i.push(new r.E(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new p;if(Le(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=n||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(r.E.construct(o.vmin,t)),i.push(r.E.construct(t,o.vmax))}}}}function Ve(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Be(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Be(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[2][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Ge(t,e,s,i){(new r.P).setCoordsPoint2D(t[0]),(new r.P).setCoordsPoint2D(t[1]),(new r.P).setCoordsPoint2D(t[2]);const n=new r.P,o=new r.P,a=new r.P;if((0,r.U)(t[0],t[1],e,n),(0,r.U)(t[1],t[2],e,o),(0,r.U)(n,o,e,a),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(a)),i){const e=t[2];i[0].assign(a),i[1].assign(o),i[2].assign(e)}}function He(t,e,s,i){if(e===s){const s=new r.P;return $e(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=(0,r.m)(r.P,3);Ge(t,s,n,null),Ge(n,e/s,null,n),$e(t,e,n[0]),$e(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ke(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==je(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function We(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==Ze(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function je(t,e,s,n,o,a,h,m,u,l){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!==a)for(let t=0;t<i;t++)a.push(0);if(null!==n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=G(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Fr({start:e.getStartXY(),end:e.getEndXY()}),i=ot(t,s,n,o,a,h,m,l);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=C.constructPoint2D(s.getStartXY()),d=C.constructPoint2D(s.getEndXY()).sub(g),_=d.clone();_.leftPerpendicularThis();const p=C.constructPoint2D(e.m_cp).sub(C.constructPoint2D(e.getStartXY())),f=C.constructPoint2D(e.getEndXY()).sub(C.constructPoint2D(e.m_cp));let x=p.dotProduct(_).toDouble(),P=f.sub(p).dotProduct(_).toDouble();const y=(0,r.d)(12,Number.NaN),v=(0,r.d)(12,Number.NaN);let E=function(t,e,s,i){const n=new r.H,o=Rt(new r.H(t),new r.H(e),s,n);return i[0]=n.value(),o}(P,x,r.E.unit(),y);E<0&&(y[0]=0,y[1]=1,E=2);let b,D=0;for(let t=0,i=D;t<E;++t){const n=e.getCoord2D(y[t+i]);v[D]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(v[D]))<=h&&(y[D]=y[t+i],D++)}const S=(0,r.m)(r.P,3);e.queryControlPoints(S);{const t=(0,r.m)(C,3);if(Qe(S,t,!1),t[0]=t[0].sub(g),d.x.abs().gte(d.y.abs())){const e=d.y.div(d.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),x=t[1].y.sub(t[1].x.mul(e)).toDouble(),b=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=d.x.div(d.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),x=t[1].x.sub(t[1].y.mul(e)).toDouble(),b=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const w=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),A=[0,0];E=Nt(P,x,b,r.E.unit(),w,A);for(let t=0,i=D;t<E;++t){y[t+i]=A[t];const n=e.getCoord2D(y[t+i]);v[D]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(v[D]))<=h&&(y[D]=y[t+i],D++)}(0,i.g)(D<y.length+4),E=e.intersectPoint(s.getStartXY(),A,h);for(let t=0;t<E;t++)y[D]=A[t],v[D++]=0;E=e.intersectPoint(s.getEndXY(),A,h);for(let t=0;t<E;t++)y[D]=A[t],v[D++]=1;E=s.intersectPoint(e.getStartXY(),A,h);for(let t=0;t<E;t++)v[D]=A[t],y[D++]=0;E=s.intersectPoint(e.getEndXY(),A,h);for(let t=0;t<E;t++)v[D]=A[t],y[D++]=0;return 0===D?0:qr(t,e,s,y,v,D,n,o,a,h,m,0,l)}function Ze(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return je(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,3);{e.queryControlPoints(_);const t=(0,r.m)(r.P,3),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(_,3,t);const o=(0,r.m)(C,3);Qe(t,o);const u=[o[0].x,o[1].x,o[2].x],l=[o[0].y,o[1].y,o[2].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2]=c[0],c[2].mul(c[1]),c[2].negate();const p=ee(u,2,l,2,null,0,c,0,r.E.unit(),r.E.unit(),g,m);if(p>0){let t=0;for(let i=0;i<p;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];Re(_,e,i);const n=new r.P;$e(_,i[0],n),r.P.distance(e,n)<=h&&(g.push(i[0]),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,2];{const i=s.getClosestCoordinate(_[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(_[e[t]],n)<=h&&(g.push(p[t]),d.push(i))}}return qr(t,e,s,g,d,g.length,i,n,o,h,m,0,l)}function Ue(t,e,s,i,n,o,a,h,m,u){const l=(0,r.m)(r.P,3);e.queryControlPoints(l);const c=(0,r.m)(r.P,3);if(s.queryControlPoints(c),k(l,c,3)<0)return Ue(t,s,e,i,o,n,a,h,m,!u);const g=G(e,s);if(H(e,s,a=Math.max(a,g)))return 0;if(function(t,e,s,i,n,o,a,h,m){const u=(0,r.m)(r.P,3);t.queryControlPoints(u);const l=(0,r.m)(r.P,3);if(e.queryControlPoints(l),u[0].equals(l[0])){if(u[1].equals(l[1])&&u[2].equals(l[2]))return s&&(s.length=0,s.push(u[0]),s.push(u[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!u[0].equals(l[2]))return!1}return!!(u[0].equals(l[2])&&u[1].equals(l[1])&&u[2].equals(l[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,i,n,o,0,0,0,u))return 2;const d=new r.E(0,1),_=new r.E(0,1);{const t=new p;Le(l,r.E.unit(),t);const e=new p;Le(c,r.E.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(ze(l,t,d),ze(c,t,_),d.isEmpty()||_.isEmpty())return 0;He(l,d.vmin,d.vmax,l),He(c,_.vmin,_.vmax,c)}}const f=Yr(l,2,c,2,a);if(0===f)return 0;const x=[],P=[];if(-1===f){const t=(0,r.m)(C,3);Qe(l,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=(0,r.m)(C,3);Qe(c,i);const n=te(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,0,r.E.unit(),r.E.unit(),x,P,u,0,u);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new r.P,i=new r.P;$e(c,P[e],i),$e(l,x[e],s),r.P.distance(s,i)<=a&&(x[t]=x[e],P[t]=P[e],t++)}x.length=t,P.length=t}}for(let t=0;t<2;t++){const e=0===t?l:c,s=0===t?c:l;for(let i=0;i<2;i++){const n=0===i?0:2,o=[0];Re(s,e[n],o);const h=new r.P;$e(s,o[0],h),r.P.distance(e[n],h)<=a&&(0===t?(x.push(0===n?0:1),P.push(o[0])):(P.push(0===n?0:1),x.push(o[0])))}}if(0===x.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=Qt.recalculateParentT(d.vmin,d.vmax,x[t]);if(!_.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=Qt.recalculateParentT(_.vmin,_.vmax,P[t]);return qr(t,e,s,x,P,x.length,i,n,o,a,h,0,u)}function Oe(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Qe(t,e,s=!1){const i=C.constructPoint2D(t[1]),n=i.sub(C.constructPoint2D(t[0]));e[1]=n.mul(r.M.constructInt32(2)),e[2]=C.constructPoint2D(t[2]).sub(i).sub(n),e[0]=s?new C(r.ah,r.ah):C.constructPoint2D(t[0])}function $e(t,e,s,i){if(i){if(e<0)return void K(new Fr({start:t[0],end:t[0].add(Te(t,0).getUnitVector())}),e,s);if(e>1)return void K(new Fr({start:t[2],end:t[2].add(Te(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=t[1].clone(),n=new r.P;(0,r.a1)(2,t[0],i,e,n);const o=new r.P;(0,r.a1)(2,i,t[2],e,o);const a=new r.P;(0,r.a1)(2,n,o,e,a),s.assign(a)}else{const i=t[1].clone(),n=new r.P;(0,r.a2)(2,t[0],i,e,n);const o=new r.P;(0,r.a2)(2,i,t[2],e,o);const a=new r.P;(0,r.a2)(2,n,o,e,a),s.assign(a)}}const Ke=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Je=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ts=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],es=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],ss=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],is=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function ns(t,e,s,i){const n=.5*(i-s),o=s+n,a=new r.K(0);for(let s=0,i=Math.trunc(t/2);s<i;++s){let i,h;switch(t){case 4:i=Ke[s][0],h=Ke[s][1];break;case 8:i=Je[s][0],h=Je[s][1];break;case 16:i=ts[s][0],h=ts[s][1];break;case 32:i=es[s][0],h=es[s][1];break;case 64:i=ss[s][0],h=ss[s][1];break;case 128:i=is[s][0],h=is[s][1];break;default:throw new Error("Quadrature_integral: invalid n")}const m=(0,r.am)(-n,i,o),u=(0,r.am)(n,i,o);a.pe(e(m)*h),a.pe(e(u)*h)}return a.getResult()*n}class rs extends Et{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Rr):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Rr,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Rr):t.envelope?(0,i.t)("envelope constructor not impl"):(0,i.d)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Rr)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return At(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return rs.type}getDimension(){return 2}createInstance(){return new rs({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}rs.type=i.G.enumPolygon;var os=n.V;const as=-1;class hs{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}class ms{constructor(t){!function(t){return void 0!==t.parent}(t)?(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom):(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==as;){for(;this.m_path!==as;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==as)return this.m_vertex;if(this.m_bOneGeom)return as;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===as)break;this.m_bSkipMultiPoints&&!(0,i.h)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return as}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==as&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return as}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==as?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==as&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):as}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new ms({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class us{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class ls{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,s=this.m_indices.length;t<s;t++){if(t===this.m_selectionIndex)continue;const s=this.m_indices[t];null!==s&&s.size()>e&&s.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,1),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==as?this.getPrevVertex(e):this.getLastVertex(t),r=n!==as?this.getNextVertex(n):as,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByValNoCurves(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==as&&this.setPrevVertex(r,o),n!==as&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===as&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==as||this.setFirstVertex(t,o)),h&&r===as&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new n.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(i.G.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let e=0,n=s.getPathCount();e<n;e++){if(0===s.getPathSize(e))continue;const n=this.insertPath(t,as);this.setClosedPath(n,s.isClosedPath(e));for(let t=s.getPathStart(e),r=s.getPathEnd(e);t<r;t++){const e=this.insertVertex_(n,as,null,!1);if(i){const i=this.getVertexIndex(e);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{const e=new Rr;s.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}s.isStrongPathStart(e)&&this.setStrongPathStart(n,!0),s.isStrongPathEnd(e)&&this.setStrongPathEnd(n,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.G.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new o.Envelope2D;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,u=0,l=-1,c=as,g=!1,d=s.nextSegment();if(null!==d)for(;;d=s.nextSegment()){let r=null===d;const o=null!==d?s.getPathIndex():a,_=null!==d?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?u++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(u===m){this.setClosedPath(c,g);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-l),this.m_verticesMp.addPoints(e,l,n),s=i.getPathSize(a),t=n-1}else if(!g||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,as,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Rr;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;u=1,l=_,a!==o?(c=this.insertPath(t,as),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),g=i.isClosedPath(o),a=o):c=this.insertPath(t,as)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const n=e.getImpl(),a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),h=o.Envelope2D.constructEmpty();e.queryEnvelope(h),(0,i.g)(s.isIntersecting(h)&&!s.containsEnvelope(h));let m=o.Envelope2D.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),u=o.Envelope2D.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const l=n.getAccelerators();if(l&&l.getQuadTree()){const t=l.getQuadTree(),e=t.getIntersectionCount(m,0,0);e>t.getIntersectionCount(u,0,e+1)&&(u=(0,r.c)(m,m=u))}else m.height()>u.width()&&(u=(0,r.c)(m,m=u));const c=[],g=n.queryLimitedSegmentIterator(m);let d=-1,_=-100,p=-1,f=0,x=-1,P=-1,y=as,v=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let s=null===C;const h=null!==C?g.getPathIndex():d,m=null!==C?g.getStartPointIndex():_;if(s||(h===d?_+1===m?f++:s=!0:(s=d>=0,d<0&&(d=h,p=n.getSegmentCountPath(d),x=m,y=as,f=1))),s){if(0!==c.length||p!==f){0!==c.length&&c[0].first===x||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,x,x+1),-1===P&&(P=x),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(y,as,null,!1));for(const{first:s,second:r}of c){-1===P&&(P=s);let o=-1,h=-1;const m=s+r-1;if(r===p){const t=m+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m,(0,i.g)(1===c.length)}else if(m+1<n.getPathEnd(d)){const t=m+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m}else{const t=n.getPathStart(d),i=t!==P?1:0,r=m+1;h=r-s+i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+i),this.m_verticesMp.addPoints(e,s,r),o=m,i>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),y===as&&(y=this.insertPath(t,as),this.setClosedPath(y,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(y,as,null,!1);if(a){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>o)this.setSegmentToIndex(s,null);else{const t=new Rr;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===c.length||c.at(-1).first+c.at(-1).second!==x+f){let t=x+f;t===e.getPathEnd(d)&&(t=e.getPathStart(d)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(y,as,null,!1))}}c.length=0,v=!0,h!==d&&(d=h,p=n.getSegmentCountPath(d),y=as,P=-1),x=m,f=1}if(!C)break;{const t=o.Envelope2D.constructEmpty();C.queryLooseEnvelope(t),u.isIntersecting(t)?(v?c.push((0,r.k)(m,1)):c.at(-1).second++,v=!1):v=!0}_=m}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.G.enumPolygon,r=o.Envelope2D.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,as);this.insertVertex_(i,as,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,as);for(let t=0,i=e.getPointCount();t<i;t++)this.insertVertex_(s,as,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let t=0,r=e.getPointCount();t<r;t++){const e=i.readPoint2D(2*t);s.contains(e)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let t=0,n=e.getPointCount();t<n;t++){const n=i.readPoint2D(2*t);s.contains(n)?(-1===r&&(r=t,o=t),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,as);for(let t=0,n=e.getPointCount();t<n;t++){const e=i.readPoint2D(2*t);s.contains(e)&&this.insertVertex_(h,as,null,!1)}}splitSegmentForward(t,e,s,n,r){const o=this.getNextVertex(t);o===as&&(0,i.a)("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const l=this.getVertexIndex(m),c=this.getNextVertex(m),g=e.getResultSegment(s,t);let d=null;if(g.getGeometryType()!==i.G.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(l,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),r)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),u){const i=e.getResultSegmentSegmentParentage(s,t),n=e.getResultSegmentStartPointIsBreak(s,t);this.setSegmentParentageAndBreak(m,i,n)}if(g.queryEnd(a),t<n-1){this.setSegmentToIndex(l,d);const i=this.insertVertex(h,c,a);this.setWeight(i,e.getResultSegmentEndPointWeight(s,t)),this.setRank(i,e.getResultSegmentEndPointRank(s,t)),this.select(i),m=i}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),r);const i=e.getResultSegmentEndPointIsBreak(s,t);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(l,d)}}}splitSegmentBackward(t,e,s,n,r){const o=this.getNextVertex(t);o===as&&(0,i.a)("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const l=n-t-1,c=this.getVertexIndex(m),g=this.getNextVertex(m),d=e.getResultSegment(s,l);let _=null;if(d.getGeometryType()!==i.G.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(a),this.setSegmentToIndex(c,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,l),e.getResultSegmentEndPointWeight(s,l),r),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,l),e.getResultSegmentEndPointIsBreak(s,l))),d.getGeometryType()===i.G.enumLine?this.setSegmentToIndex(c,null):this.setSegmentToIndex(c,_),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,l)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,l)),d.queryStart(a),t<n-1){const t=this.insertVertex(h,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(s,l)),this.setRank(t,e.getResultSegmentStartPointRank(s,l)),this.select(t),m=t,u&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(s,l),e.getResultSegmentEndPointIsBreak(s,l))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,l),e.getResultSegmentStartPointWeight(s,l),r)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,n.D)(0,-1):(0,n.D)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,n.D)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=(0,r.c)(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,as,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return as}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,(t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s})}sortVerticesSimpleByYHelper3D(t,e,s){(0,i.g)(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=n.p.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=r.P.getNAN(),this.m_workPoint2_2D=r.P.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=as,this.m_lastGeometry=as,this.m_vertexIndexList=new n.S(5),this.m_pathIndexList=new n.S(8),this.m_geometryIndexList=new n.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new n.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.Envelope2D(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=o.Envelope2D.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let t=i.next();t!==as;t=i.next()){if(n?s.merge(this.getXY(t)):s.mergeNe(this.getXY(t)),e){const e=this.getSegment(t);if(null!==e){const t=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}n=!1}return s}getEnvelope3D(t){return(0,i.g)(0),n.p.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,i.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if((0,i.h)(s))return this.addMultiPath(t,e);if(s===i.G.enumMultiPoint)return this.addMultiPoint(t,e);if(s===i.G.enumPoint)return this.addPoint_(t,e);if(s===i.G.enumEnvelope){const s=new rs;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}(0,i.a)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());const s=e.getGeometryType();(0,i.h)(s)?this.appendMultiPath(t,e):s!==i.G.enumMultiPoint?(0,i.a)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);const s=this.queryVertexIterator();for(let t=s.next();t!==as;t=s.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=as,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==as;){if(t===i.G.enumUnknown||this.getGeometryType(r)===t){if(e===as){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let t=this.getFirstPath(r);t!==as;t=this.getNextPath(t))this.setPathGeometry(t,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==as?this.setNextPath(t,i):this.setFirstPath(e,i),i!==as&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,as),this.setLastPath(r,as);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return e!==as&&(this.setGeometryVertexCount(e,n),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let s=this.getFirstPath(t);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,e);for(let s=this.getFirstPath(e);s!==as;s=this.getNextPath(s))this.setPathGeometry(s,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const u=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,u)}addPathFromMultiPath(t,e,s){const n=this.createGeometry(s?i.G.enumPolygon:i.G.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,as);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let t=r.getPathStart(e),s=r.getPathEnd(e);t<s;t++){const e=this.insertVertex_(o,as,null,!1);if(a){const s=this.getVertexIndex(e);if(1&r.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{const e=new Rr;r.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=function(t,e){let s,r=e,o=null;switch(r||(o=(0,i.j)(t)?(0,n.z)():(0,n.l)(),r=o),t){case i.G.enumPoint:s=new n.P({vd:r});break;case i.G.enumLine:s=new Fr({vd:r});break;case i.G.enumBezier:s=new Ci({vd:r});break;case i.G.enumEllipticArc:s=new In({vd:r});break;case i.G.enumRationalBezier2:s=new Ut({vd:r});break;case i.G.enumBezier2:s=new Qt({vd:r});break;case i.G.enumEnvelope:s=new n.E({vd:r});break;case i.G.enumMultiPoint:s=new _({vd:r});break;case i.G.enumPolyline:s=new Dt({vd:r});break;case i.G.enumPolygon:s=new rs({vd:r});break;case i.G.enumMultipatch:(0,i.t)("multipatch not impl");break;case i.G.enumGeometryCollection:s=new U({vd:r});break;default:(0,i.a)("Geometry.create")}return s}(e,this.m_verticesMp.getDescription()),r=this.getPointCount(t);if(0===r)return s;if((0,i.h)(e)){const e=s.getImpl(),i=this.getPathCount(t),o=(0,n.D)(i+1),a=(0,n.F)(i+1,0),h=s.getDescription(),m=this.hasCurves();for(let s=0,m=h.getAttributeCount();s<m;s++){const m=h.getSemantics(s),u=os.getComponentCount(m),l=(0,n.v)(m,r),c=this.m_vertices.getAttributeStreamRef(m);let g=0,d=0,_=0;for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&a.setBits(d,t);const s=this.getPathSize(e);if(o.write(d++,_),_+=s,0===m){const t=c,s=l;let i;for(let n=this.getFirstVertex(e);g<_;n=this.getNextVertex(n),g++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*g,i)}}else for(let t=this.getFirstVertex(e);g<_;t=this.getNextVertex(t),g++){const e=this.getVertexIndex(t);for(let t=0;t<u;t++){const s=c.readAsDbl(e*u+t);l.writeAsDbl(g*u+t,s)}}}e.setAttributeStreamRef(m,l),o.write(i,r)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),m){let s=0,i=0;for(let n=this.getFirstPath(t);n!==as;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===i.G.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(r),e.resizeNoInit(r);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=os.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(t),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(n,o)}e.notifyModifiedFlags(65535)}else(0,i.d)("getGeometry");return s}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==i.G.enumMultiPoint&&(0,i.a)("get_point_geometry_only");const s=this.getPointCount(t);if(s>1&&(0,i.a)("get_point_geometry_only"),0===s)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();const n=this.getFirstPath(t),r=this.getFirstVertex(n);this.queryPoint(r,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==as;e=this.removePath(e));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==as?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==as?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=(0,n.l)());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new _({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===as?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,n.D)(0),t;this.m_geometryIndices.push((0,n.D)(0));const t=this.m_geometryIndices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))if(!(0,i.h)(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,s,n,o){const a=t*t;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage(),l=!0;for(let t=o===as?this.getFirstGeometry():o;t!==as;t=o===as?this.getNextGeometry(t):as){const o=this.getGeometryType(t);if(!(0,i.h)(o))continue;if(s&&o!==i.G.enumPolygon)continue;const c=this.getGeometryType(t)===i.G.enumPolygon;let g=this.getGeometryModified(t);for(let s=this.getFirstPath(t);s!==as;){let o=0;for(let e=this.getFirstVertex(s);o<Math.trunc(this.getPathSize(s)/2);){const c=this.getNextVertex(e);if(c===as)break;const d=this.getXY(e),_=this.getXY(c);let p=r.P.sqrDistance(d,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,c!==this.getLastVertex(s)){const s=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(c));if(this.transferAllDataToTheVertex(c,e,l),this.removeVertex(c,!1),n&&!g&&(this.setGeometryModified(t,!0),g=!0),u&&e!==c){this.setSegmentParentageBreakVertex(e,s);const t=this.getNextVertex(e);(0,i.g)(t!==as),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}f=!1}}while(0);f&&(e=this.getNextVertex(e)),o++}let d=this.getFirstVertex(s);for(let e=this.isClosedPath(s)?d:this.getLastVertex(s);this.getPathSize(s)>0;){const o=this.getPrevVertex(e);if(o===as)break;{const c=this.getXY(o),_=this.getXY(e);let p=r.P.sqrDistance(c,_),f=!0;do{if(p<=a){if(m){const t=this.getSegment(o);if(null!==t){const e=t.calculateLength2D();if(p=e*e,p>a)break}}if(0===p?0===h&&(h=-1):h=1,u){(0,i.g)(this.m_segmentParentageIndex>=0);const t=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(o,e,l),this.setUserIndex(e,this.m_segmentParentageIndex,t)}else this.transferAllDataToTheVertex(o,e,l);const r=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(o));this.removeVertex(o,!0),n&&!g&&(this.setGeometryModified(t,!0),g=!0),u&&o!==e&&(r||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),d===o&&(d=this.getFirstVertex(s)),f=!1}}while(0);if(f&&(e=this.getPrevVertex(e),e===d))break}}const _=this.getPathSize(s);let p=e&&_<(c?3:2);p&&c&&2===_&&m&&(p=!this.pathHasCurves(s)),p?(s=this.removePath(s),0===h&&(h=-1),n&&!g&&(this.setGeometryModified(t,!0),g=!0)):s=this.getNextPath(s)}}return h}filterClosePoints3D(t,e,s,n,r,o){return(0,i.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==as;e=this.getNextGeometry(e))if((0,i.h)(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==as;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===as)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return(0,i.g)(0),!1}transferAllDataToTheVertex(t,e,s=!1){const i=this.getVertexIndex(t),n=this.getVertexIndex(e);if(s){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(i),e=this.getRankWithIndex(n)),t>e&&this.setRankWithIndex(n,t),t>=e&&this.m_weights){const s=this.getWeightWithIndex(i),r=this.getWeightWithIndex(n);(t>e||s>r)&&this.setWeightWithIndex(n,s)}}else{if(this.m_weights){const t=this.getWeightWithIndex(i);this.setWeightWithIndex(n,t)}if(this.m_ranks){const t=this.getRankWithIndex(i);this.setRankWithIndex(n,t)}}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(i);this.setSegmentWeightWithIndex(n,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(i);this.setSegmentRankWithIndex(n,t)}for(let s=0,i=this.m_indices.length;s<i;s++)if(s!==this.m_selectionIndex&&null!==this.m_indices[s]){const i=this.getUserIndex(t,s);this.setUserIndex(e,s,i)}const r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,n,r){let o=0;const a=this.getNextVertex(t);a===as&&(0,i.a)("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),u=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&u&&(l=u.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(u){let t=0,i=0,r=as;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=u.cut(t,s);if(null!==n&&(p>0&&e.setStartXY(n[p-1]),e.setEndXY(n[p]),e.normalizeAfterEndpointChange(),i=p),g){const t=l>0?u.calculateSubLengthFromStart(s)/l:0;this.m_vertices.interpolateTwoVertices(h,m,t,_)}_.setXY(e.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==d&&this.setSegmentParentageAndBreak(r,d,!1),t=s}}if(r!==as){const e=u.cut(t,1);null!==n&&(e.setStartXY(n[i]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(r);this.setSegmentToIndex(s,e)}}else{let t=0;for(let i=0;i<s;i++){const s=e[i];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(h,m,s,_);const t=this.insertVertex(c,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=s}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,e,s){this.getNextVertex(t)===as&&(0,i.a)("");let n=t,r=!1;for(let t=0;t<e;++t){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(s);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==as;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return(0,i.g)(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(s,e)}setPointOnlyEx(t,e,s,n){(0,i.g)(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==as){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new r.P(e,s),t,!1),n.ensureXYMonotone()}const o=this.getPrevVertex(t);if(o!==as){const t=this.getVertexIndex(o),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new r.P(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){(0,i.g)(0)}setXYZ(t,e,s){(0,i.g)(0)}setXYZCoords(t,e,s,n){(0,i.g)(0)}queryXYZ(t,e){(0,i.g)(0)}getXYZ(t){return(0,i.g)(0),n.f.getNAN()}getXYZWithIndex(t){return(0,i.g)(0),n.f.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,i.g)(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){(0,i.g)(0)}setAttributeInt(t,e,s,n){(0,i.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,i.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return(0,i.g)(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=(0,n.G)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=(0,n.G)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return 1;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,n.D)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,1)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=(0,n.D)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,n.G)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=(0,n.G)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return ls.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?ls.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,n.D)(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,1)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=(0,n.D)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];return s<i.size()?i.read(s):-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=(0,r.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let r=0,o=this.getPathSize(e);r<o;r++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){(0,i.g)(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===as)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new n.P({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return(0,i.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,i.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===as)return!1;const s=this.getPathSize(t);let n=e;for(let t=0;t<s;t++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.G.enumLine)return!0}return!1}insertPath(t,e){let s=as;e!==as?(t!==this.getGeometryFromPath(e)&&(0,i.a)(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const n=this.newPath(t);return e!==as&&this.setPrevPath(e,n),this.setNextPath(n,e),this.setPrevPath(n,s),s!==as?this.setNextPath(s,n):this.setFirstPath(t,n),e===as&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==as?this.setNextPath(e,s):this.setFirstPath(i,s),s!==as?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==as){let s=e;for(let e=0,i=this.getPathSize(t);e<i;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,as),this.setPrevVertex(s,as);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){(0,i.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===as)return 0;const s=this.getXY(e),n=new r.K(0),o=this.getPathSize(t);if(o>2){const t=s.clone(),i=t.x,a=t.y;let h=this.getNextVertex(e);const m=this.getXY(h);h=this.getNextVertex(h);const u=r.P.getNAN();for(let e=2;e<o;e++,h=this.getNextVertex(h))this.queryXY(h,u),n.pe((u.x-t.x)*(m.y-a)),t.setCoordsPoint2D(m),m.setCoordsPoint2D(u);n.pe((i-t.x)*(m.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.G.enumLine)continue;const s=2*e.calculateArea2DHelper();n.pe(s)}}this.setRingAreaValid(t,!0);const a=.5*n.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){const t=this.getPathIndex(e);t<n&&i.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===as&&(0,i.a)(""),e===s)return;const n=this.getNextPath(s);let r=this.getPrevPath(s);const o=this.getGeometryFromPath(s);r===as?this.setFirstPath(o,n):this.setNextPath(r,n),n===as?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(s)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=e===as?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,r),this.setNextPath(s,e),e===as?this.setLastPath(t,s):this.setPrevPath(e,s),r===as?this.setFirstPath(t,s):this.setNextPath(r,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,as,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==as&&this.setNextVertex(i,n);const r=this.getPathSize(s);if(t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:as),n!==as&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:as),this.hasCurves()&&i!==as&&n!==as){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(t,e){(0,i.g)(t!==e);const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==as&&this.setNextVertex(n,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,as),this.setNextVertex(r,as);let h=0,m=t;const u=this.getFirstVertex(s);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(s,o>0?e:as),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,as,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,i.d)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==as;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==as;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=as){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=as){let s=as,n=as,r=as,o=as,a=0,h=!1;for(s=e!==as?e:this.getFirstGeometry();s!==as;s=this.getNextGeometry(s))if(!t||(0,i.h)(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==as;n=this.getNextPath(n))if(r=this.getFirstVertex(n),o=r,a=0,r!==as){h=!0;break}if(h||e!==as)break}return h||(s=as),ms.create_(this,s,n,r,o,a,t,!1,e!==as)}queryVertexIteratorOnSelection(t=as){return this.m_selection?ms.create_(this,t,as,as,as,-1,!1,!0,t!==as):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,i.g)(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=as,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return(0,i.g)(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;const e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===as)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return(0,i.g)(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==as?this.setNextPath(e,s):this.setFirstPath(i,s),s!==as?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,as),this.setLastVertex(t,as),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,as);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return(0,i.g)(0),0}findVertex3D(t,e,s){return(0,i.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let s=t;for(let t=0;t<e;++t)if(s=e>0?this.getNextVertex(s):this.getPrevVertex(s),s===as)return as;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);if(s!==as&&this.setNextVertex(s,i),i!==as&&this.setPrevVertex(i,s),this.hasCurves()&&s!==as&&i!==as){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,i.g)(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new hs(this))}sortVerticesSimpleByX(t,e,s){(0,i.g)(0)}sortVerticesSimpleByY3D(t,e,s){(0,i.g)(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==as&&this.replaceCurveWithLine(s),this.getNextVertex(t)!==as&&this.replaceCurveWithLine(t);const i=new r.P;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.j)()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,i.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,r.j)()>>1),e<<=1,e|=this.getSegmentParentageBreakVertex(t)?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new us(e)}return new us(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=(0,r.j)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);return e!==as&&this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function cs(t){if(t.isEmpty())return new rs({vd:t.getDescription()});if((0,i.h)(t.getGeometryType())&&t.hasNonLinearSegments())return function(t){(0,i.g)(t.hasNonLinearSegments()&&!t.isEmpty());const e=new fs;return e.addGeometry(t),e.getBoundingGeometry()}(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new n.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new n.P,s=new Dt({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const o=e.getAttributeStreamRef(0),a=new fs({stream:o,n:s});let h=1;const m=o.readPoint2D(0),u=new r.P;for(;h<s&&o.queryPoint2D(h<<1,u).equals(m);)h++;if(a.m_treeHull.addElement(0),h<s){a.m_treeHull.addBiggestElement(h);const t=new r.P;for(let s=h+1;s<e.getPointCount();s++){o.queryPoint2D(s<<1,t);const e=a.treeHull(t);-1!==e&&a.m_treeHull.setElement(e,s)}}const l=e.getDescription(),c=l.getAttributeCount()>1,g=a.m_treeHull.size();let d=null;if(g>=2){d=g>=3?new rs({vd:l}):new Dt({vd:l});const t=d.getImpl();t.reserve(a.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new r.P;for(let i=a.m_treeHull.getFirst();-1!==i;i=a.m_treeHull.getNext(i))if(c){const s=new n.P;e.getPointByVal(a.m_treeHull.getElement(i),s),t.insertPoint(0,-1,s)}else o.queryPoint2D(a.m_treeHull.getElement(i)<<1,s),t.insertPoint2D(0,-1,s)}else if(c){const t=new n.P({vd:l});e.getPointByVal(a.m_treeHull.getElement(a.m_treeHull.getFirst()),t),d=t}else{const t=o.readPoint2D(a.m_treeHull.getElement(a.m_treeHull.getFirst())<<1);d=new n.P(t)}return d}function gs(t,e,s,i=!1){if(e<=262144)return function(t,e,s,i){const r=new n.a(0);for(let t=0;t<e;t++)r.add(t);const o={userSort(e,s,i){i.sort(e,s,(e,s)=>t[e].compareX(t[s]))},getValue:e=>t[e].x};i||n.B.sortEx(r,0,e,o);let a=0;t:for(let i=0;i<e;++i){const e=r.read(i);for(;a>=2;){const n=s[a-2],o=s[a-1];if(t[o].equals(t[e])){r.write(i,-1);continue t}if(!(xs(t[n],t[o],t[e])>=0)){o===r.read(i-1)&&r.write(i-1,-1);break}a--}s[a++]=e,2===a&&t[e].equals(t[s[0]])&&(r.write(1,-1),a--)}const h=a+1;t:for(let i=e-2;i>=0;--i){const e=r.read(i);if(!(e<0)){for(;a>=h;){const i=s[a-2],n=s[a-1];if(t[n].equals(t[e]))continue t;if(!(Ps(t[i],t[n],t[e])>=0))break;a--}if(0!==i){const i=s[a-1];s[a++]=e,t[e].equals(t[i])&&a--}}}return a>1&&t[s[0]].equals(t[s[a-1]])&&a--,a}(t,e,s,i);const r=new fs({points:t,n:e});let o=1;const a=t[0];for(;o<e&&t[o].equals(a);)o++;if(r.m_treeHull.addElement(0),o<e){r.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],i=r.treeHull(e);-1!==i&&r.m_treeHull.setElement(i,s)}}let h=0;for(let t=r.m_treeHull.getFirst();-1!==t;t=r.m_treeHull.getNext(t))s[h++]=r.m_treeHull.getElement(t);return h}function ds(t,e,s){if((e<0||e>=t.getPathCount())&&(0,i.a)("path index"),t.hasNonLinearSegmentsPath(e))return!1;const n=t.getImpl(),o=n.getPathStart(e),a=n.getPathEnd(e),h=!n.isClosedPath(e)&&n.isClosedPathInXYPlane(e),m=n.getAttributeStreamRef(0),u=2*o;let l=2*a;if(h&&(l-=2),l-u<6)return!0;const c=m.readPoint2D(u),g=m.readPoint2D(u+2),d=m.readPoint2D(u+4);if(!ys(r.P.orientationRobust(g,d,c)))return!1;const _=g.clone(),p=new r.P;for(let t=u+6;t<l;t+=2){if(p.assign(g),g.assign(d),m.queryPoint2D(t,d),!ys(r.P.orientationRobust(g,d,c)))return!1;if(!ys(r.P.orientationRobust(_,d,c)))return!1;if(!ys(r.P.orientationRobust(g,d,p)))return!1}return!0}function _s(t,e,s,n,o){if(function(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}(s,n,o),t.isEmpty())return;if(t.getGeometryType()===i.G.enumPoint)return void s.assign(t.getXY());const a=t,h=a.getPointCount();0!==h&&(1!==h?function(t,e,s,i,n,o){if(2===e){const e=t.getXY(0),s=t.getXY(1);i.assign(e.add(s).mul(.5));const r=s.sub(e);n=Es(r),o.setCoords(.5*r.length(),0)}else{let a=Number.MAX_VALUE;const h=[0,1,0,0],m=new r.R(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);h[0]<e;++h[0],bs(m,0,e)){h[1]===h[0]&&(++h[1],bs(m,1,e));for(let s=1;;++s){for(;;){const i=Ds(t.getXY(m.get(0,0)),t.getXY(m.get(0,1)),t.getXY(m.get(s,0)),t.getXY(m.get(s,1)),2^s);if(i>0)break;if(++h[s],bs(m,s,e),0===i)break}if(3===s)break;h[s+1]<h[s]&&(h[s+1]=h[s],m.set(s+1,0,m.get(s,0)),m.set(s+1,1,m.get(s,1)))}const u=t.getXY(m.get(0,0)).add(t.getXY(m.get(2,0))).mul(.5),l=Es(t.getXY(m.get(0,1)).sub(t.getXY(m.get(0,0)))),c=new r.P;let g,d;if(c.x=Math.max(0,l.dotProduct(t.getXY(m.get(1,0)).sub(t.getXY(m.get(3,0))))),c.y=Math.max(0,l.crossProduct(t.getXY(m.get(0,0)).sub(t.getXY(m.get(2,0))))),s?(g=c.x*c.y,d=g<a):(g=c.y,d=g<a),d){a=g;const e=t.getXY(m.get(1,0)),s=t.getXY(m.get(3,0)),r=e.add(s).mul(.5).sub(u);i.assign(u.add(l.mul(l.dotProduct(r)))),n.assign(l),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,r.c)(o.x,o.x=o.y),n.leftPerpendicularThis())}n.y<0?n.negateThis():0===n.y&&(n.x=1)}(a,h,e,s,n,o):s.assign(a.getXY(0)))}ls.st_defaultRank=1;class ps{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,i.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,i.g)(0),!1}get_vertex_handle_p(){return(0,i.g)(0),0}get_vertex_handle_q(){return(0,i.g)(0),0}get_current_support(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}intialize_(){return(0,i.g)(0),!1}increment_(){return(0,i.g)(0),!1}increment_q_(){return(0,i.g)(0),!1}increment_p_(){return(0,i.g)(0),!1}parallel_edge_with_q_support_(){return(0,i.g)(0),!1}parallel_edge_with_p_support_(){return(0,i.g)(0),!1}done_(){return(0,i.g)(0),!1}}class fs{nullGetXY(t){return(0,i.d)("m_getXY is null"),{}}nullDeleteNode(t){(0,i.d)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new n.T,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=as,void(this.m_pathHandle=as)):void(0,i.q)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new ls,this.m_geometryHandle=this.m_shape.createGeometry(i.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,as),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,i.g)(0),new r.P}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){(0,i.g)(0)}addGeometry(t){if(t.isEmpty())return;const e=t.getGeometryType();if(e===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else(0,i.i)(e)?this.addMultiVertexGeometry(t):(0,i.f)(e)?this.addSegment(t,!1):e===i.G.enumEnvelope?this.addEnvelope(t):e===i.G.enumPoint?this.addPoint(t):(0,i.a)("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new n.P,e=this.m_treeHull.getFirst(),s=new rs({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return(0,i.g)(0),new ps(this)}getXY(t){return(0,i.g)(0),new r.P}getXYWithIndex(t){return(0,i.g)(0),new r.P}getFirst(){return(0,i.g)(0),0}getLast(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}getVertexIndex(t){return(0,i.g)(0),0}getPointCount(){return(0,i.g)(0),0}addMultiVertexGeometry(t){const e=new n.P,s=t.getImpl(),o=new r.P;for(let i=0;i<t.getPointCount();i++){s.queryXY(i,o);const n=this.addPoint2D(o);if(-1!==n){t.getPointByVal(i,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,s)}}if((0,i.h)(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments()){const t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){const e=new n.P;for(let s=0;s<4;s++){const i=new r.P;t.queryCorner(s,i);const n=this.addPoint2D(i);if(-1!==n){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}static querySegmentControlPoints(t,e,s){const o=t.getGeometryType();if((0,i.g)(o!==i.G.enumLine),o===i.G.enumEllipticArc){const s=t,i=60*Math.PI/180,o=Math.abs(s.getSweepAngle());if(o>i){const t=Math.min(6,Math.ceil(o/i)),a=1/t,h=new Rr;s.queryStart(e[0]);let m=1;for(let i=0;i<t;i++){s.queryCut(i*a,(i+1)*a,h);const o=(0,r.m)(r.P,3);gr(h.get(),o);const u=r.P.calculateLength(o,3),l=r.P.calculateLength(o,2),c=u>0?l/u:.5;i<t-1?h.get().queryEnd(e[m+1]):s.queryEnd(e[m+1]),n.P.lerp(e[m-1],e[m+1],c,e[m]),e[m].setXY(o[1]),m+=2}return m}{const s=(0,r.m)(r.P,3);gr(t,s);const i=r.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);const o=r.P.calculateLength(s,2),a=i>0?o/i:.5;return n.P.lerp(e[0],e[2],a,e[1]),e[1].setXY(s[1]),3}}if(o===i.G.enumBezier){const s=t,i=(0,r.m)(r.P,4);s.queryControlPoints(i);const o=r.P.calculateLength(i,4),a=r.P.calculateLength(i,2),h=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[3]);const m=o>0?a/o:.5;n.P.lerp(e[0],e[3],m,e[1]),e[1].setXY(i[1]);const u=o>0?h/o:.5;return n.P.lerp(e[0],e[3],u,e[2]),e[2].setXY(i[2]),4}if(o===i.G.enumBezier2){const s=t,i=(0,r.m)(r.P,3);s.queryControlPoints(i);const o=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(i,2),h=o>0?a/o:.5;return n.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(i[1]),3}if(o===i.G.enumRationalBezier2){const s=t,i=(0,r.m)(r.P,3);s.queryControlPoints(i);const o=r.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);const a=r.P.calculateLength(i,2),h=o>0?a/o:.5;return n.P.lerp(e[0],e[2],h,e[1]),e[1].setXY(i[1]),3}(0,i.a)("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new n.P,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const r=t.getEndXY(),o=this.addPoint2D(r);if(-1!==o){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,s)}}if(t.isCurve()){const e=(0,r.m)(n.P,13);for(let s=1,i=fs.querySegmentControlPoints(t,e,e.length)-1;s<i;++s){const t=e[s].getXY(),i=this.addPoint2D(t);if(-1!==i){const t=this.m_shape.addPoint(this.m_pathHandle,e[s]);this.m_treeHull.setElement(i,t)}}}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),n=this.m_treeHull.getElement(s),o=this.m_treeHull.getElement(i),a=this.m_getXY(n),h=this.m_getXY(o),m=r.P.orientationRobust(h,t,a);if(ys(m)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(vs(m)){let n=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),h=this.m_treeHull.getLast(),m=-1,u=-1,l=-1;for(;o!==this.m_treeHull.getPrev(h);){u=this.m_treeHull.getElement(n);const e=this.m_getXY(u);vs(r.P.orientationRobust(e,t,a))?(h=n,n=this.m_treeHull.getLeft(n)):(o=n,n=this.m_treeHull.getRight(n))}n=h,m=o,u=this.m_treeHull.getElement(n),l=this.m_treeHull.getElement(m);const c=this.m_getXY(u),g=this.m_getXY(l);if(m!==s&&!ys(r.P.orientationRobust(g,t,c)))break;e=this.m_treeHull.addElementAtPosition(m,n,-2,!0,!1),this.treeHullWalkForward(t,n,i),this.treeHullWalkBackward(t,m,s);break}{const n=Cs(t,h,a);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getNext(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(s,t,a)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getNext(i),this.m_deleteNode(h)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),o=this.m_treeHull.getPrev(i);const a=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(ys(r.P.orientationRobust(a,t,s)))break;const h=i;i=o,n=e,a.assign(s),o=this.m_treeHull.getPrev(i),this.m_deleteNode(h)}return i}}function xs(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function Ps(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const o=i.crossProduct(n),a=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return o>a?1:o<-a?-1:r.P.orientationRobust(t,e,s)}function ys(t){return t<0}function vs(t){return t>0}function Cs(t,e,s){let i=-1;i=e.y===s.y?0:e.x===s.x?1:Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1;let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Es(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function bs(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Ds(t,e,s,n,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,i.a)("")}return r.P.orientationRobustEx(t,e,s,n)}class Ss{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function ws(t){return function(t){return 256*(0,r.O)()*t}(t.calculateUpperLength2D())}function As(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Ts(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),Ns(i,e,s)}function Is(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),qs(i,e,s)}function Ns(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function qs(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function Ms(t,e,s=!1){const i=(0,r.m)(C,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(r.M.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(r.M.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(r.ah,r.ah):e[0]=i[0].clone()}function Ys(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ys(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Xs(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=ws(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=xi(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function Xs(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Ss,s=(0,r.m)(r.H,8),i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=gi(i,s);e.specialPoints=[];for(let t=0;t<n;t++)e.specialPoints.push(s[t].value());return Rs(t,e),e}function Fs(t){let e=null;return e=t.m_cachedValues,e}function Rs(t,e){t.m_cachedValues=e}function Ls(t){t.m_cachedValues=null}function zs(t,e,s,i){const n=(0,r.m)(r.P,4);t.queryControlPoints(n);const o=(0,r.d)(18,NaN),a=It(new mi(n,e,NaN),r.E.construct(s,i),18,o),h=new r.P;t.queryCoord2D(s,h);let m=s,u=r.P.distance(h,e);const l=new r.P;t.queryCoord2D(i,l);const c=r.P.distance(l,e);c<u&&(u=c,m=i,h.assign(l));for(let s=0;s<a;s++){t.queryCoord2D(o[s],l);const i=r.P.distance(l,e);i<u&&(u=i,m=o[s],h.assign(l))}return function(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}(s,i,m,u,h)}function Vs(t,e){const s=(0,r.m)(r.H,4);Ts(t,s,!0);const n=(0,r.m)(r.H,4);Is(t,n,!0);const o=s[3].clone(),a=s[2].clone(),h=s[1].clone(),m=n[3].clone(),u=n[2].clone(),l=n[1].clone(),c=a.mulE(h).addE(u.mulE(l)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(h).mul(12)).addE(u.mulE(u).mul(8).addE(m.mulE(l).mul(12))),d=o.mulE(a).addE(m.mulE(u)).mul(36),_=o.mulE(o).addE(m.mulE(m)).mul(36),p=(0,r.m)(r.H,3),f=zt(_,d,g,c,new r.E(0,1),!1,p);if((0,i.g)(f<=3),f>0){const s=Gs(t,1,0).sqrLength(),i=Gs(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let s=0;s<f;s++){const i=Gs(t,1,p[s].value()).sqrLength();i<n&&(n=i,e=p[s])}}}function Bs(t,e,s){const i=new r.P;return function(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}(t,e,s,i),i}function Gs(t,e,s){const i=(0,r.m)(r.P,4);return t.queryControlPoints(i),Bs(i,e,s)}function Hs(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e),(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function ks(t){const e=(0,r.m)(r.P,4);t.queryControlPoints(e);const s=Ws(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Ws(t){return b(t)}function js(t,e,s){const i=new r.P,n=new r.P,o=new r.P,a=new r.P,h=new r.P;e<=.5?((0,r.a1)(2,t[0],t[1],e,i),(0,r.a1)(2,t[1],t[2],e,n),(0,r.a1)(2,t[2],t[3],e,o),(0,r.a1)(2,i,n,e,a),(0,r.a1)(2,n,o,e,h),(0,r.a1)(2,a,h,e,s)):((0,r.a2)(2,t[0],t[1],e,i),(0,r.a2)(2,t[1],t[2],e,n),(0,r.a2)(2,t[2],t[3],e,o),(0,r.a2)(2,i,n,e,a),(0,r.a2)(2,n,o,e,h),(0,r.a2)(2,a,h,e,s))}function Zs(t,e,s,n){(0,i.g)(e>=0&&e<=1);const o=new r.P,a=new r.P,h=new r.P,m=new r.P,u=new r.P,l=new r.P;e<=.5?((0,r.a1)(2,t[0],t[1],e,o),(0,r.a1)(2,t[1],t[2],e,a),(0,r.a1)(2,t[2],t[3],e,h),(0,r.a1)(2,o,a,e,m),(0,r.a1)(2,a,h,e,u),(0,r.a1)(2,m,u,e,l)):((0,r.a2)(2,t[0],t[1],e,o),(0,r.a2)(2,t[1],t[2],e,a),(0,r.a2)(2,t[2],t[3],e,h),(0,r.a2)(2,o,a,e,m),(0,r.a2)(2,a,h,e,u),(0,r.a2)(2,m,u,e,l));const c=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(o),s[2].assign(m),s[3].assign(l)),n&&(n[0].assign(l),n[1].assign(u),n[2].assign(h),n[3].assign(c))}function Us(t,e,s,n){if((0,i.g)(e>=0&&s<=1&&e<=s),e===s){const s=new r.P;return Os(t,e,s),n[0].assign(s),n[1].assign(s),n[2].assign(s),void n[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)n[e].assign(t[e]);return}const o=(0,r.m)(r.P,4);Zs(t,s,o,null),Zs(o,s>0?e/s:0,null,o),Os(t,e,o[0]),Os(t,s,o[3]),n[0].setCoordsPoint2D(o[0]),n[1].setCoordsPoint2D(o[1]),n[2].setCoordsPoint2D(o[2]),n[3].setCoordsPoint2D(o[3])}function Os(t,e,s,i){if(i){if(e<0)return void K(new Fr({start:t[0],end:t[0].add(Qs(t,0).getUnitVector())}),e,s);if(e>1)return void K(new Fr({start:t[3],end:t[3].add(Qs(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=new r.P;(0,r.a1)(2,t[0],t[1],e,i);const n=new r.P;(0,r.a1)(2,t[1],t[2],e,n);const o=new r.P;(0,r.a1)(2,t[2],t[3],e,o);const a=new r.P;(0,r.a1)(2,i,n,e,a);const h=new r.P;(0,r.a1)(2,n,o,e,h),(0,r.a1)(2,a,h,e,s)}else{const i=new r.P;(0,r.a2)(2,t[0],t[1],e,i);const n=new r.P;(0,r.a2)(2,t[1],t[2],e,n);const o=new r.P;(0,r.a2)(2,t[2],t[3],e,o);const a=new r.P;(0,r.a2)(2,i,n,e,a);const h=new r.P;(0,r.a2)(2,n,o,e,h),(0,r.a2)(2,a,h,e,s)}}function Qs(t,e){const s=(0,r.s)(e,0,1);let i=Bs(t,1,s);return i.isZero()&&(i=Bs(t,2,s),i.isZero()?i=Bs(t,3,s):1===s&&i.negateThis()),i}function $s(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){const i=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),y.constructPoint2D(t[3])],n=new y;return function(t,e,s,i){{const e=r.I.subE(s),n=e.sqr(),o=s.sqr(),a=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new r.H(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(o));i.setE(a.mulE(new r.H(3)))}}(i,0,s,n),n}(t,0,e))}(i,e,s)}function Ks(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==si(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Js(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==ii(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ti(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==ri(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ei(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==oi(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function si(t,e,s,i,n,o,a,h,m,u){if(null!==n&&(n.length=0),null!=o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],h=e.intersectPoint(s.getStartXY(),t,a);if(h>0){if(null!==n)for(let e=0;e<h;e++)n.push(t[e]);if(null!==o)for(let t=0;t<h;t++)o.push(0);if(null!=i)for(let s=0;s<h;s++){const n=new r.P;e.queryCoord2D(t[s],n),i.push(n)}}return h}const l=G(e,s);if(H(e,s,a=Math.max(a,l)))return 0;const c=(0,r.m)(r.P,4);As(e,c);const g=s.getEndXY();g.subThis(s.getStartXY());const d=g.clone();d.leftPerpendicularThis();let _=3*c[3].dotProduct(d),p=2*c[2].dotProduct(d),f=c[1].dotProduct(d);const x=(0,r.d)(15,Number.NaN),P=(0,r.d)(15,Number.NaN);let y=Nt(_,p,f,r.E.unit(),!1,x);y<0&&(x[0]=0,x[1]=1,y=2);let v,C=0;for(let t=0,i=C;t<y;++t){const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}if(c[0].subThis(s.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;_=c[3].y-c[3].x*t,p=c[2].y-c[2].x*t,f=c[1].y-c[1].x*t,v=c[0].y-c[0].x*t}else{const t=g.x/g.y;_=c[3].x-c[3].y*t,p=c[2].x-c[2].y*t,f=c[1].x-c[1].y*t,v=c[0].x-c[0].y*t}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),b=[0,0,0];y=qt(_,p,f,v,r.E.unit(),E,b);for(let t=0,i=C;t<y;++t){x[t+i]=b[t];const n=e.getCoord2D(x[t+i]);P[C]=s.getClosestCoordinate(n,!1),r.P.distance(n,s.getCoord2D(P[C]))<=a&&(x[C]=x[t+i],C++)}y=e.intersectPoint(s.getStartXY(),b,a);for(let t=0;t<y;t++)x[C]=b[t],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,a);for(let t=0;t<y;t++)x[C]=b[t],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),b,a)&&(P[C]=b[0],x[C++]=0),0!==s.intersectPoint(e.getEndXY(),b,a)&&(P[C]=b[0],x[C++]=1),0===C?0:qr(t,e,s,x,P,C,i,n,o,a,h,0,u)}function ii(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return si(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=[],p=(0,r.m)(r.P,4);{e.queryControlPoints(p);const t=(0,r.m)(r.P,4),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(p,4,t);const o=(0,r.m)(C,4);Ms(t,o);const u=[o[0].x,o[1].x,o[2].x,o[3].x],l=[o[0].y,o[1].y,o[2].y,o[3].y],c=(0,r.m)(r.M,3);c[0].setDouble(s.getSemiMinorAxis()),c[0].sqrThis(),c[1].setDouble(s.getSemiMajorAxis()),c[1].sqrThis(),c[2].setThis(c[0]),c[2].mulThis(c[1]),c[2].negateThis();const f=ee(u,3,l,3,null,0,c,0,r.E.unit(),r.E.unit(),d,m);if(f>0){let t=0;for(let i=0;i<f;i++){const n=new r.P;e.queryCoord2D(d[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g.push(n.clone()),d[t]=d[i],_.push(o),t++)}d.length=t,g.length=t}}const f=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];ui(p,e,r.E.unit(),!1,-1,1,i);const n=new r.P;Os(p,i[0],n),r.P.distance(e,n)<=h&&(d.push(i[0]),_.push(f[t]),g.push(n.clone()))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(p[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(p[e[t]],n)<=h&&(d.push(f[t]),_.push(i),g.push(n.clone()))}}return qr(t,e,s,d,_,d.length,i,n,o,h,m,0,l)}function ni(t,e,s,n,o,a,h,m,u,l){const c=(0,r.m)(r.P,4);e.queryControlPoints(c);const g=(0,r.m)(r.P,4);if(s.queryControlPoints(g),k(c,g,4)<0)return ni(t,s,e,n,a,o,h,m,u,!l);const d=G(e,s);if(H(e,s,h=Math.max(h,d)))return 0;if(function(t,e,s,i,n,o,a,h,m){const u=(0,r.m)(r.P,4);t.queryControlPoints(u);const l=(0,r.m)(r.P,4);if(e.queryControlPoints(l),u[0].equals(l[0])){if(u[1].equals(l[1])&&u[2].equals(l[2])&&u[3].equals(l[3]))return s&&(s.length=0,s.push(u[0]),s.push(u[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!u[0].equals(l[3]))return!1}return!!(u[0].equals(l[3])&&u[1].equals(l[2])&&u[2].equals(l[1])&&u[3].equals(l[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,r.c)(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),m&&(n[1]=(0,r.c)(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),m&&(s[1]=(0,r.c)(s[0],s[0]=s[1]))),!0)}(e,s,n,o,a,0,0,0,l))return 2;const _=new r.E(0,1),f=new r.E(0,1);{const t=new p;hi(c,new r.E(0,1),t);const e=new p;hi(g,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(_i(c,t,_),_.isEmpty())return 0;if(_i(g,t,f),f.isEmpty())return 0;Us(c,_.vmin,_.vmax,c),Us(g,f.vmin,f.vmax,g)}}const x=Yr(c,3,g,3,h);if(0===x)return 0;const P=[],y=[],v=[];let E=!1;if(-1===x){const t=(0,r.m)(C,4);Ms(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(C,4);Ms(g,i);const n=[],o=[],a=te(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,0,r.E.unit(),r.E.unit(),n,o,u);if(a>0)for(let t=0;t<a;t++){const e=new r.P;Os(g,o[t],e);const s=new r.P;Os(c,n[t],s),r.P.distance(s,e)<=h&&(P.push(s.clone()),v.push(o[t]),y.push(n[t]))}else-1===a&&(E=!0)}for(let t=0;t<2;t++){const e=0===t?c:g,s=0===t?g:c;for(let i=0;i<2;i++){const n=0===i?0:3,o=[0];ui(s,e[n],r.E.unit(),!1,-1,1,o);const a=new r.P;Os(s,o[0],a),r.P.distance(e[n],a)<=h&&(0===t?(y.push(0===n?0:1),v.push(o[0])):(v.push(0===n?0:1),y.push(o[0])),P.push(a.clone()))}}if(0===y.length&&E){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const n=[0,0];if(2===ci(t?e:s,n,!0)&&((0,i.g)(r.E.unit().containsCoordinate(n[0])),!r.E.unit().containsCoordinate(n[1]))){const e=new r.P;Os(t?c:g,n[0],e);const s=[0,0];1===ui(t?g:c,e,r.E.unit(),!1,-1,2,s)&&(P.push(e.clone()),y.push(t?n[0]:s[0]),v.push(t?s[0]:n[0]))}}}if(0===y.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=Ci.recalculateParentT(_.vmin,_.vmax,y[t]);if(!f.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=Ci.recalculateParentT(f.vmin,f.vmax,v[t]);return qr(t,e,s,y,v,y.length,n,o,a,h,m,0,l)}function ri(t,e,s,n,o,a,h,m,u,l){const c=G(e,s);if(s.isDegenerateToLineHelper(c)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()}),r=si(t,e,i,n,o,a,h,m,0,l);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);s.queryControlPoints(d);const _=new r.E(0,1),f=new r.E(0,1),x=[0,0,0];s.queryWeights(x);const P=[1,dn(x),1];{const t=new p;hi(g,new r.E(0,1),t);const e=new p;Zi(d,P,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(_i(g,t,_),_.isEmpty())return 0;if(gn(d,P,t,f),f.isEmpty())return 0;Us(g,_.vmin,_.vmax,g),Ki(d,P,f.vmin,f.vmax,d,P)}}const y=Yr(g,3,d,2,h);if(0===y)return 0;const v=[],E=[],b=[];if(-1===y){const t=(0,r.m)(C,4);Ms(g,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hn(d,P,i,n,o);const a=[],m=[],l=te(i,2,n,2,o,2,e,3,s,3,null,0,0,r.E.unit(),r.E.unit(),m,a,u);if(l>0)for(let t=0;t<l;t++){const e=new r.P;Os(g,a[t],e);const s=new r.P;cn(d,P,m[t],s),r.P.distance(e,s)<=h&&(v.push(e.clone()),E.push(a[t]),b.push(m[t]))}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=d):(s=g,e=d);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t){const t=Wi(s,P,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),cn(s,P,a[0],m)}else{const t=ui(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),Os(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(E.push(0===o?0:1),b.push(a[0])):(b.push(0===o?0:1),E.push(a[0])),v.push(m.clone()))}}if(0===E.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ci.recalculateParentT(_.vmin,_.vmax,E[t]);if(!f.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(f.vmin,f.vmax,b[t]);for(let t=0;t<b.length;++t)b[t]=_n(x,b[t]);return qr(t,e,s,E,b,E.length,n,o,a,h,m,0,l)}function oi(t,e,s,n,o,a,h,m,u,l){const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=(0,r.m)(r.P,4);e.queryControlPoints(g);const d=(0,r.m)(r.P,3);s.queryControlPoints(d);const _=Yr(g,3,d,2,h);if(0===_)return 0;const p=[],f=[],x=[];if(-1===_){const t=(0,r.m)(C,4);Ms(g,t);const i=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,r.m)(C,3);Qe(d,o);const a=te([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,i,3,n,3,null,0,0,r.E.unit(),r.E.unit(),x,f,m);if(a>0){let t=0;for(let i=0;i<a;i++){const n=new r.P;e.queryCoord2D(f[i],n);const o=new r.P;s.queryCoord2D(x[i],o),r.P.distance(n,o)<=h&&(p.push(n.clone()),f[t]=f[i],x[t]=x[i],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=d):(s=g,e=d);for(let n=0;n<2;n++){const o=0===n?0:e.length-1,a=[0],m=new r.P;if(0===t)Re(s,e[o],a),$e(s,a[0],m);else{const t=ui(s,e[o],r.E.unit(),!1,-1,1,a);(0,i.g)(1===t),Os(s,a[0],m)}r.P.distance(e[o],m)<=h&&(0===t?(f.push(0===o?0:1),x.push(a[0])):(x.push(0===o?0:1),f.push(a[0])),p.push(m.clone()))}}return qr(t,e,s,f,x,f.length,n,o,a,h,m,0,l)}function ai(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),hi(i,e,s)}function hi(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=(0,r.m)(r.P,4);Us(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}let mi=class{constructor(t,e,s){this.dbgCounter=0,this.controlPoints=t,this.point=e.clone(),this.maxDistance=s}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e),i=Bs(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new r.P;Os(this.controlPoints,e,t);const s=Bs(this.controlPoints,1,e),i=Bs(this.controlPoints,2,e),n=Bs(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=Bs(this.controlPoints,1,e),s=Bs(this.controlPoints,2,e),i=Bs(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=Bs(this.controlPoints,2,e),s=Bs(this.controlPoints,3,e);return 10*t.dotProduct(s)*2}case 5:{const t=Bs(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){const s=(0,r.m)(r.P,4);Us(this.controlPoints,t,e,s);const i=new p;if(i.setFromPoints(s,4),Math.sqrt(i.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function ui(t,e,s,o,a,h,m){(0,i.x)(r.E.unit().contains(s)&&h>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);const u=[],l=new r.P;Os(t,s.vmin,l);let c=r.P.distance(l,e);if(c<=a&&u.push(new r.P(s.vmin,c)),s.vmin!==s.vmax&&(Os(t,s.vmax,l),c=r.P.distance(l,e),c<=a&&u.push(new r.P(s.vmax,c))),s.width()>0){const i=(0,r.d)(18,Number.NaN),n=It(new mi(t,e,a),s,18,i);for(let s=0;s<n;s++)Os(t,i[s],l),c=r.P.distance(l,e),c>a||u.push(new r.P(i[s],c))}if(o){(0,i.g)(s.equals(r.E.unit()));{Os(t,-1,l,!0);const s=new r.P;Os(t,0,s);const i=new Fr({start:l,end:s}),n=i.getClosestCoordinate(e,!0);n<1&&(l.assign(i.getCoord2D(n)),c=r.P.distance(l,e),c<=a&&u.push(new r.P(n-1,c)))}{Os(t,2,l,!0);const i=new r.P;Os(t,s.vmax,i);const n=new Fr({start:i,end:l}),o=n.getClosestCoordinate(e,!0);o>0&&(l.assign(n.getCoord2D(o)),c=r.P.distance(l,e),c<=a&&u.push(new r.P(1+o,c)))}}if(!u.length)return 0;u.sort((t,e)=>t.compare(e));let g=0;const d=u[0].x;if(m[g++]=d,g<h){const e=(0,n.J)(t,4,!1).total(),s=u[0].y;for(let t=1,i=u.length;t<i;t++)if(u[t].y>s+e){u.length=t;break}u.sort((t,e)=>(0,r.a7)(t.x,e.x)),g=0,m[g++]=u[0].x;for(let t=1,e=u.length;t<e;t++)u[t].x!==m[g-1]&&g<h&&(m[g++]=u[t].x)}return g}function li(t,e,s,i,n,o,a){const h=(0,r.m)(r.P,4);return t.queryControlPoints(h),ui(h,e,s,i,n,o,a)}function ci(t,e,s=!1){const i=(0,r.m)(r.P,4);t.queryControlPoints(i);const n=(0,r.m)(C,4);let o,a,h;Ms(i,n,!0);const m=n[3].x.isZero(),u=n[3].y.isZero();if(m||u)if(m&&!u){if(n[2].x.isZero())return 0;o=n[1].x.div(n[2].x).negate(),a=n[2].y.div(n[3].y),h=n[1].y.div(n[3].y)}else{if(m||!u)return 0;if(n[2].y.isZero())return 0;o=n[1].y.div(n[2].y).negate(),a=n[2].x.div(n[3].x),h=n[1].x.div(n[3].x)}else{n[2].x.divThis(n[3].x),n[1].x.divThis(n[3].x),n[2].y.divThis(n[3].y),n[1].y.divThis(n[3].y);const t=n[2].x.sub(n[2].y);if(t.isZero())return 0;o=n[1].x.sub(n[1].y).div(t).negate(),a=n[2].x.clone(),h=n[1].x.clone()}if(!s&&o.abs().value()>2)return 0;const l=[0,0],c=t.getStartXY().equals(t.getEndXY()),g=Nt(1,-o.toDouble(),o.add(a).mul(o).add(h).toDouble(),r.E.unit(),c,l);if(0===g)return 0;if(l[0]>=0&&l[0]<=1){const t=o.toDouble()-l[0];if(s||t>=0&&t<=1)return e[0]=l[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}if(2===g&&l[1]>=0&&l[1]<=1){const t=o.toDouble()-l[1];if(s||t>=0&&t<=1)return e[0]=l[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,r.c)(e[0],e[0]=e[1])),2}return 0}function gi(t,e){e[0].set(0);let s=1;const n=(0,r.m)(r.H,4);Ns(t,n,!0);const o=(0,r.m)(r.H,4);qs(t,o,!0);{const t=n[3].mul(3),i=n[2].mul(2),o=n[1].clone(),a=(0,r.m)(r.H,2);let h=Lt(t,i,o,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(e[s]=a[t],s++)}{const t=o[3].mul(3),i=o[2].mul(2),n=o[1].clone(),a=(0,r.m)(r.H,2);let h=Lt(t,i,n,new r.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(e[s]=a[t],s++)}if(s+=function(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,r.m)(r.H,2);let h=Lt(o,n,i,new r.E(0,1),!1,a);h<0&&(h=0);let m=0;for(let t=0;t<h;t++)(0,r.N)(a[t].value(),0,1)||(s[m].setE(a[t]),m++);return m}(n,o,e.slice(s)),e[s].set(1),s++,s>2){(0,r.C)(e,0,s,(t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0});let i=0;const n=e[0].clone();let o=0;const a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,r.O)(),h=new r.P;js(t,e[0].value(),h);for(let m=1;m<s;m++){const s=new r.P;if(js(t,e[m].value(),s),e[m].eq(n)||s.isEqualPoint2D(h,a)){if(0!==i){if(0===e[m].eps())n.setE(e[m]),o=0;else if(0!==o){const t=(0,r.a)(1/e[m].eps()),s=1/o,i=t+s;n.set((e[m].value()*t+n.value()*s)/i),o=1/i,n.setError(Math.sqrt(o))}e[i].setE(n),js(t,n.value(),h)}}else i++,e[i].setE(e[m]),n.setE(e[m]),js(t,n.value(),h),o=(0,r.a)(e[m].eps())}i++,s=i}return 1===s&&(s=2,e[1].set(1)),(0,i.g)(0===e[0].value()),(0,i.g)(1===e[s-1].value()),s}function di(t,e,s,i){const n=(0,r.m)(r.P,s);for(let t=0;t<s;++t)n[t]=new r.P(t/(s-1),0);const o=(t,e,s,i)=>{const n=new r.H(e.x).subE(new r.H(t.x)).divE(new r.H(e.y).subE(new r.H(t.y))).mulE(new r.H(s).subE(new r.H(t.y))).addE(new r.H(t.x));if(n.eps()>.1){const i=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;n.set(i,(0,r.O)())}if(n.lt(new r.H(0))||n.gt(new r.H(1)))return!1;let o=n.value()-n.eps();o=(0,r.s)(o,0,1);let a=n.value()+n.eps();return a=(0,r.s)(a,0,1),i.mergeCoordinate(o),i.mergeCoordinate(a),!0},a=[];{const e=(t,e)=>{a.length=s;const i=gs(n,s,a,!0),h=new r.E;h.setEmpty();const m=s=>s.y<t?-1:s.y>e?1:0;let u=n[a[0]],l=m(u);0===l&&h.mergeCoordinate(u.x);for(let s=1;s<=i;++s){const r=n[a[s%i]],c=m(r);0===c&&h.mergeCoordinate(r.x);let g=0;c!==l&&(g=c*l===0?1===c||1===l?2:1:3,1&g&&o(u,r,t,h),2&g&&o(u,r,e,h)),u=r,l=c}return h};for(let e=0;e<s;++e)n[e].y=t[e].x;const h=e(i.xmin,i.xmax);if(h.isEmpty())return new r.E(h);for(let e=0;e<s;++e)n[e].y=t[e].y;const m=e(i.ymin,i.ymax);return h.intersect(new r.E(m)),new r.E(h)}}function _i(t,e,s){s.setEmpty(),s.merge(function(t,e,s,i){const n=di(t,0,4,i.getEnvelope2D());if(n.isEmpty())return new r.E(n);const o=(0,r.m)(r.P,4);for(let e=0;e<4;++e)i.xyRot(t[e],o[e]);const a=di(o,0,4,i.getRotatedEnvelope2D());return n.intersect(new r.E(a)),new r.E(n)}(t,0,0,e))}class pi{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ys(this.b,e,!1):0}getError(t){return 0}}function fi(t,e,s,n,o,a,h){for(;;){const m=r.P.distance(e[0],e[3]),u=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2])+r.P.distance(e[2],e[3]);if(u-m<=n+s*u)return t+(0,r.q)(m,u,.5);const l=t=>Bs(e,1,t).length();{(0,i.g)(h<12);let m=l(0),c=l(1);o[0]+=2,m>c&&(c=(0,r.c)(m,m=c),e[3]=(0,r.c)(e[0],e[0]=e[3]),e[2]=(0,r.c)(e[1],e[1]=e[2]));let g=m/(m+c),d=1,_=u;for(;g<1/32&&_>=32*(n+s*_);){d/=4;const t=l(d);o[0]++,g=m/(t+m);const s=new r.P;if(Os(e,.5*d,s),_=r.P.distance(s,e[0]),_<=n){const t=new r.P;Os(e,d,t),_+=r.P.distance(t,s)}}if(1!==d){const i=(0,r.m)(r.P,4);Zs(e,d,e,i),t=fi(t,i,s,n,o,0,h+1),a++,h++;continue}}const c=8;o[0]+=c;const g=ns(c,l,0,1),d=16;o[0]+=d;const _=ns(d,l,0,1);let p=Math.abs(g-_)>n+s*u;if(!p)return t+_;if(a<3){const i=(0,r.m)(r.P,4);Zs(e,.5,e,i),t=fi(t,i,s,n,o,a+1,h+1),a++,h++;continue}const f=32;o[0]+=f;const x=ns(f,l,0,1);if(p=Math.abs(_-x)>n+s*u,!p)return t+x;const P=64;o[0]+=P;const y=ns(P,l,0,1);if(p=Math.abs(x-y)>n+s*u,!p)return t+y;const v=128;o[0]+=v;const C=ns(v,l,0,1);return p=Math.abs(y-C)>n+s*u,t+C}}function xi(t,e,s,i,n){if(s===e)return 0;const o=(0,r.m)(r.P,4);t.queryControlPoints(o);const a=(0,r.m)(r.P,4);return Us(o,e,s,a),fi(0,a,i,n,[0],0,0)}function Pi(t,e,s,i,n){let o=!0;const a=fe(5,e,s,i,n,e=>{const s=Gs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});o=!1;const h=fe(5,e,s,i,n,e=>{const s=Gs(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new r.P(a,h)}function yi(t,e,s,n,o,a,h,m,u,l,c,g){(0,i.g)(l+2===g);let d=0,_=0,p=0,f=0,x=0,P=0,y=0;const v=(t,e)=>{const i=1-e,h=s.mul((0,r.an)(i)),m=n.mul(3*e*i*i),u=o.mul(3*e*e*i),l=a.mul((0,r.an)(e));return h.add(m).add(u).add(l).sub(c[t]).sqrLength()};for(let e=1,i=g-1;e<i;e++){let i=u[e-1];if(t){e>2?(i=(0,r.s)(2*u[e-2]-u[e-3],0,1),u[e-1]=i):2===e&&(i=(0,r.s)(2*u[e-2],0,1),u[e-1]=i);const t=(t,e,i)=>{let h=-1;for(let m=0;!(Math.abs(e-h)<1e-12)&&10!==m;m++){const m=e*e,u=1-e,l=u*u,g=l*u,d=s.x-2*n.x+o.x,_=s.x-3*n.x+3*o.x-a.x,p=s.y-2*n.y+o.y,f=s.y-3*n.y+3*o.y-a.y,x=s.x-n.x-2*d*e+_*m,P=-c[t].x+s.x*g+e*(3*n.x*l+e*(3*o.x*u+a.x*e)),y=s.y-n.y-2*p*e+f*m,v=-c[t].y+s.y*g+e*(3*n.y*l+e*(3*o.y*u+a.y*e)),C=-6*(x*P+y*v),E=6*(3*(0,r.a)(x)-(-2*d+2*_*e)*P)+6*(3*(0,r.a)(y)-(-2*p+2*f*e)*v);if(h=e,0===E)break;e=(0,r.s)(e-C/E,i,1)}return h};{const s=v(e,u[e-1]);let i=t(e,u[e-1],0),n=v(e,i);if(1.01*s<n){const s=e>1?u[e-2]:0,r=t(e,.3*(u[e-1]-s)+s,0),o=v(e,r);o<n&&(n=o,i=r)}s>n&&(u[e-1]=i)}}const h=u[e-1],m=h*h,l=m*h,g=1-h,C=g*g,E=C*g;d+=3*m*C*C,_+=3*l*E,p+=3*m*m*C;const b=-(E*s.x+l*a.x-c[e].x);f+=b*h*C,x+=b*m*g;const D=-(E*s.y+l*a.y-c[e].y);P+=D*h*C,y+=D*m*g}if(e){const t=d*p-_*_;Math.abs(t)>=1e-12*(Math.abs(d*p)+Math.abs(_*_))+1e-10?(h||(n.x=(f*p-x*_)/t,n.y=(P*p-y*_)/t),m||(o.x=(d*x-_*f)/t,o.y=(d*y-_*P)/t)):((0,r.U)(s,a,.3,n),(0,r.U)(s,a,.6,o))}let C=0;for(let t=1,e=g-1;t<e;t++)C+=v(t,u[t-1]);return C}var vi=n.V;class Ci extends Q{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,r.W)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),(0,i.d)("unrecognized constructor params"),this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return At(this)}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=(0,r.m)(r.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,r.U)(t[0],t[1],2/3,e[1]),(0,r.U)(t[1],t[2],1/3,e[2])})(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),(0,r._)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,r._)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),V(this,t)}getGeometryType(){return i.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,i.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Fs(this);if(null!==e){const s=new r.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const s=(0,r.m)(r.H,8),n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=gi(n,s),a=new r.P;for(let e=1;e<o-1;e++)this.queryCoord2D(s[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Ls(this)}(0,i.g)(0)}createInstance(){return new Ci({vd:this.m_description})}calculateLength2D(){return Ys(this,1,!1)}calculateLowerLength2D(){return r.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return r.P.distance(this.getStartXY(),this.m_cp[0])+r.P.distance(this.m_cp[0],this.m_cp[1])+r.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){(0,i.g)(0)}queryCoord2DExtends(t,e,s){const i=(0,r.m)(r.P,4);this.queryControlPoints(i),Os(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,r.m)(r.P,4);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=new y;(0,r.a3)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,i);const n=new y;(0,r.a3)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,n);const o=new y;(0,r.a3)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);const a=new y;(0,r.a3)(2,i,n,e,a);const h=new y;(0,r.a3)(2,n,o,e,h),(0,r.a3)(2,a,h,e,s)}else{const i=new y;(0,r.a4)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,i);const n=new y;(0,r.a4)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,n);const o=new y;(0,r.a4)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);const a=new y;(0,r.a4)(2,i,n,e,a);const h=new y;(0,r.a4)(2,n,o,e,h),(0,r.a4)(2,a,h,e,s)}}(i,e,s)}(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.x}const e=(0,r.q)(this.getStartX(),this.m_cp[0].x,t),s=(0,r.q)(this.m_cp[0].x,this.m_cp[1].x,t),i=(0,r.q)(this.m_cp[1].x,this.getEndX(),t),n=(0,r.q)(e,s,t),o=(0,r.q)(s,i,t);return(0,r.q)(n,o,t)}getCoordY(t){if(t<0||t>1){const e=new r.P;return this.queryCoord2DExtends(t,e,!0),e.y}const e=(0,r.q)(this.getStartY(),this.m_cp[0].y,t),s=(0,r.q)(this.m_cp[0].y,this.m_cp[1].y,t),i=(0,r.q)(this.m_cp[1].y,this.getEndY(),t),n=(0,r.q)(e,s,t),o=(0,r.q)(s,i,t);return(0,r.q)(n,o,t)}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=vi.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=vi.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){$s(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.a)("Cubic_bezier.cut_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4);Us(n,t,e,o),s.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&(0,i.a)("Cubic_bezier.split_bezier_ignore_attributes");const n=(0,r.m)(r.P,4);this.queryControlPoints(n);const o=(0,r.m)(r.P,4),a=(0,r.m)(r.P,4);Zs(n,t,o,a),e&&e.setControlPoints(o),s&&s.setControlPoints(a)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.getStartAttributeAsDbl(e,s),n=this.getEndAttributeAsDbl(e,s),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,h=vi.getInterpolation(e);return(0,r.V)(h,i,n,a,vi.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return li(this,t,r.E.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===li(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.a)("");const s=Xs(this);if(2===s.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)ks(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const n=(0,r.m)(r.P,4);return this.queryControlPoints(n),function(t,e,s,i,n){const o=(0,r.m)(r.H,4),a=(0,r.m)(r.H,3),h=new r.E(0,1);let m=0;if(e){if(qs(t,o,!1),m=zt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;Os(t,a[e].value(),s),i[e]=s.x}}else if(Ns(t,o,!1),m=zt(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new r.P;Os(t,a[e].value(),s),i[e]=s.y}if(n)for(let t=0;t<m;t++)n[t]=a[t].value();else i&&(0,r.C)(i,0,m,r.a7);return m}(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);const s=r.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,r.m)(r.P,4);this.queryControlPoints(s),Us(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ys(this,t,!0)}lengthToT(t){return function(t,e){const s=Ys(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const n=[0];return 1!==It(new pi(t,e),r.E.unit(),1,n)&&(0,i.d)(""),n[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,r.m)(r.P,4);As(this,e);const s=e[3],i=e[2],n=e[1],o=new r.P;o.x=(5*s.x*s.x*(7*i.y+16*n.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*n.x+140*i.x*n.y+112*n.x*n.y)-2*(s.y*(20*i.x*i.x+70*i.x*n.x+56*n.x*n.x)-7*(4*i.x+5*n.x)*(-i.y*n.x+i.x*n.y)))/840,o.y=(-5*s.y*s.y*(7*i.x+16*n.x)+s.y*(5*s.x*(7*i.y+16*n.y)-4*(10*i.x*i.y+35*i.y*n.x+28*n.x*n.y))+2*(-7*(4*i.y+5*n.y)*(i.y*n.x-i.x*n.y)+s.x*(20*i.y*i.y+70*i.y*n.y+56*n.y*n.y)))/840;const a=Hs(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){const t=new r.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=r.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const n=new r.P;if(e<0||s>1)return n.setNAN(),n;if(e>s&&(0,i.a)("calculate_sub_weightedCentroid"),e===s||t.isDegenerate(0))return n.setCoords(0,0),n;const o=Xs(t),a=ws(t),h=a/t.calculateUpperLength2D();let m=e,u=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){u=t-1;break}n.setCoords(0,0);for(let e=u+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),r=Pi(t,m,i,h,a);if(n.addThis(r),m=i,s<=o.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),4}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&(0,i.a)("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Qs(e,t)}getDerivative(t){const e=(0,r.m)(r.P,4);return this.queryControlPoints(e),Bs(e,1,t)}getCurvature(t){const e=Gs(this,1,t),s=Gs(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new o.Envelope2D;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),a=new r.P;return this.queryCoord2D(n,a),r.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){const t=(0,r.m)(r.P,4);return this.queryControlPoints(t),function(t){return function(t){const e=(0,r.F)(t[0].y,t[1].y),s=(0,r.F)(t[1].y,t[2].y),i=(0,r.F)(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=(0,r.F)(t[0].x,t[1].x),s=(0,r.F)(t[1].x,t[2].x),i=(0,r.F)(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}(t)}(t)}getMonotonicPartParams(t,e){const s=Xs(this),n=s.specialPointsCount();if((0,i.g)(j.s_maxMonotonicPartParams>=n),!e)return s.specialPointsCount();t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new r.H;return Vs(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),i=s.length();if(r.P.distance(e[0],e[1])+r.P.distance(e[2],e[1])+r.P.distance(e[2],e[3])-i>t)return!1;const n=t;let o=e[1].clone();o.subThis(e[0]);let a=Math.abs(o.crossProduct(s))/i;return!(a>n||(o=e[2].clone(),o.subThis(e[1]),a=Math.abs(o.crossProduct(s))/i,a>n))}copyIgnoreAttributes(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Hs(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){ai(this,t,e)}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){if((0,i.g)(s>=2),2===s){const i=new r.P;(0,r.U)(e[0],e[s-1],1/3,i);const n=new r.P;return(0,r.U)(e[0],e[s-1],2/3,n),void t.construct(e[0],i,n,e[s-1])}const n=e[0],o=e[s-1],a=[0,0],h=li(t,n,r.E.unit(),!1,Number.NaN,2,a),m=[0,0],u=li(t,o,r.E.unit(),!1,Number.NaN,2,m),l=[];for(let i=0;i<h;i++)for(let h=0;h<u;h++){const u=a[i],c=m[h],g=u>c,d=(i,a)=>{const h=(0,r.d)(s-2,Number.NaN),m=()=>{let t=0;for(let i=1,n=s-1;i<n;i++){t+=r.P.distance(e[i-1],e[i]);const s=t;h[i-1]=s}t+=r.P.distance(e[s-2],e[s-1]),g&&h.reverse();for(let e=1,i=s-1;e<i;e++)h[e-1]/=t,g&&(h[e-1]=1-h[e-1])};let l=!1,d=!1;{const e=new Rr;g?(t.queryCut(c,u,e,!0),i.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())):(t.queryCut(u,c,e,!0),i.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())),n.equals(i)&&(l=!0),o.equals(a)&&(d=!0)}m();let _=Number.MAX_VALUE;const p=i.clone(),f=a.clone();for(let t=0;t<5;t++)_=yi(!0,!1,n,p,f,o,l,d,h,s-2,e,s);for(let t=0;t<30;t++){const t=p.clone();f.clone();const i=yi(!0,!0,n,p,f,o,l,d,h,s-2,e,s);if(_<=i&&t.equals(p)&&t.equals(f))break;_=i}m();let x=!1,P=Number.MAX_VALUE;const y=i.clone(),v=a.clone();for(let t=0;t<30;t++){const t=y.clone();v.clone();const i=yi(x,!0,n,y,v,o,l,d,h,s-2,e,s);if(P<=i&&t.equals(y)&&t.equals(v))break;x=!0,P=i}return P<_?(i.assign(y),a.assign(v)):(i.assign(p),a.assign(f),P=_),P},_=new r.P,p=new r.P,f=[d(_,p),r.P.distance(n,_)+r.P.distance(_,p)+r.P.distance(p,o),_.x,_.y,p.x,p.y];l.splice(l.length,0,...f)}let c=l[0],g=l[1],d=0;for(let t=6;t<l.length;t+=6)l[t]<c&&(c=l[t],g=l[t+1],d=t);let _=d;for(let t=0;t<l.length;t+=6)t!==d&&l[t+1]<g&&Math.abs(c-l[t])<10*c&&(g=l[t+1],_=t);t.construct(n,new r.P(l[_+2],l[_+3]),new r.P(l[_+4],l[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=(0,r.m)(r.P,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=(0,r.m)(r.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;return r.P.sqrDistance(e,i)<=t&&(n=!e.equals(i),e.setCoordsPoint2D(i),r.P.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))),n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return function(t,e,s){s.length=0;{const e=new r.H;Vs(t,e);const i=new y;if($s(t,e,i),i.isZero())return e.isZero()||e.eq(new r.H(1))?0:(s.push(e.value()),1)}const i=(0,r.m)(r.H,4);Ts(t,i,!0);const n=(0,r.m)(r.H,4);Is(t,n,!0);const o=(0,r.m)(r.H,6),a=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),m=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));o[0]=n[1].mulE(n[1]).mulE(a).addE(i[1].mulE(i[1]).mulE(h)).addE(i[1].mulE(n[1]).mulE(m).mul(2)).mul(6),o[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const u=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),l=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(u).mul(156),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),g=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(g).addE(n[1].mulE(n[3]).mulE(c)).mul(72),_=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),p=i[2].mulE(n[2]).mulE(_).mul(120),f=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),x=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(f).mul(36);o[2]=l.addE(d).addE(p).addE(x);const P=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),v=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),C=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),E=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);o[3]=P.addE(v).addE(C).addE(E),o[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),o[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=(0,r.m)(r.H,5),D=Vt(o,5,new r.E(0,1),!1,b,5);if(D>0){let i=Math.abs(t.getCurvature(0)),n=0;const o=Math.abs(t.getCurvature(1));(o>i||!Number.isFinite(o))&&(n=1);for(let e=0;e<D;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!(0,r.N)(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}if(!t.isClosed()){const e=[0,0],i=ci(t,e,!1);for(let t=0;t<i;t++)e[t]>0&&e[t]<1&&s.push(e[t]);return s.length}return 0}(this,t,e)}ensureXYMonotone(){return ks(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),o=new a.T,h=(0,r.m)(r.P,3);h[0].setCoords(t.m_XStart,t.m_YStart),h[2].setCoords(t.m_XEnd,t.m_YEnd);const m=new r.P;m.setSub(h[2],h[0]),m.leftPerpendicularThis(),h[1].setAdd(h[0],m);const u=(0,r.m)(r.P,3);u[0].setCoordsPoint2D(e),u[2].setCoordsPoint2D(s),m.setSub(u[2],u[0]),m.leftPerpendicularThis(),u[1].setAdd(u[0],m),o.setFromTwoTriangles(h,u)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,r.U)(e,s,1/3,t.m_cp[0]),(0,r.U)(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&ks(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Rs(e,Fs(this))}reverseImpl(){this.m_cp[1]=(0,r.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t;return!!this.m_cp[0].equals(e.m_cp[0])&&!!this.m_cp[1].equals(e.m_cp[1])}equalsImplTol(t,e){const s=t;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[1],e)}swapImpl(t){const e=t;e.m_cp[0]=(0,r.c)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,r.c)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ls(this)}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,n){const o=new p;if(ai(t,r.E.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Xs(t);let h=0,m=a.specialPoints[0];const u=[];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=zs(t,e,m,n);if(0===u.length)u.push(r);else if(r.t===r.tmin)(0,i.g)(u.at(-1).d<=r.d),u.at(-1).tmax=r.tmax;else if(u.at(-1).t===u.at(-1).tmax){(0,i.g)(u.at(-1).d>=r.d);const t=u.at(-1).tmin;u[u.length-1]=r,u.at(-1).tmin=t}else u.push(r);m=n}for(const t of u)if(t.d<=n){const e=t.t;s?(h>=s.length&&(0,i.r)(""),s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Ls(this)}clearEndPointModified(){}}Ci.type=i.G.enumBezier;class Ei{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function bi(t,e,s,n,o,a,h,m){for(;;){const u=r.P.distance(e[0],e[2]),l=r.P.distance(e[0],e[1])+r.P.distance(e[1],e[2]);if(l-u<=o+n*l)return t+(0,r.q)(u,l,.5);const c=(0,r.m)(r.P,4),g=t=>(Yi(e,s,1,t,c),c[1].length());if(0===h&&m<8){(0,i.g)(m<8);let u=g(0),c=g(1);a[0]+=2,u>c&&(c=(0,r.c)(u,u=c),e[2]=(0,r.c)(e[0],e[0]=e[2]),s[2]=(0,r.c)(s[0],s[0]=s[2]));let d=u/(u+c),_=1,p=l;for(;d<1/32&&p>=o+n*p;){_/=4;const t=g(_);a[0]++,d=u/(t+u);const i=new r.P;if(cn(e,s,.5*_,i),p=r.P.distance(i,e[0]),p<=o){const t=new r.P;cn(e,s,_,t),p+=r.P.distance(t,i)}}if(1!==_){const i=(0,r.m)(r.P,3),u=[0,0,0];$i(e,s,_,e,s,i,u),t=bi(t,i,u,n,o,a,0,m+1),h++,m++;continue}}let d=!1;const _=8;a[0]+=_;const p=ns(_,g,0,1),f=16;a[0]+=f;const x=ns(f,g,0,1);if(d=Math.abs(p-x)>o+n*l,!d)return t+x;if(h<8&&m<9){const i=(0,r.m)(r.P,3),u=[0,0,0];$i(e,s,.5,e,s,i,u),t=bi(t,i,u,n,o,a,h+1,m+1),h++,m++;continue}const P=32;a[0]+=P;const y=ns(P,g,0,1);if(d=Math.abs(x-y)>o+n*l,!d)return t+y;const v=64;a[0]+=v;const C=ns(v,g,0,1);if(d=Math.abs(y-C)>o+n*l,!d)return t+C;const E=128;a[0]+=E;const b=ns(E,g,0,1);return d=Math.abs(C-b)>o+n*l,t+b}}function Di(t,e,s,i,n){if(s===e)return 0;const o=(0,r.m)(r.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);const h=[0,0,0],m=(0,r.m)(r.P,3);return Ki(o,a,e,s,m,h),bi(0,m,h,i,n,[0],0,0)}class Si{constructor(t,e,s){this.controlPoints=(0,r.L)(t,3),this.weights=[0,0,0],(0,r.b)(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,1,e,s),2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,2,e,s),2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new r.P;cn(this.controlPoints,this.weights,e,t);const s=(0,r.m)(r.P,4);return Yi(this.controlPoints,this.weights,3,e,s),2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return(0,i.g)(0),0}}function wi(t,e,s,i){const n=function(t,e,s,i,n){return{tmin:0,tmax:0,t:0,d:0,pt:n.clone()}}(0,0,0,0,r.P.getNAN()),o=(0,r.d)(18,Number.NaN),a=(0,r.m)(r.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);const h=[0,0,0];t.queryWeights(h);const m=[1,dn(h),1],u=pn(h,s),l=pn(h,i),c=It(new Si(a,m,new r.P(0,0)),r.E.construct(u,l),18,o);cn(a,m,u,n.pt),n.t=u,n.d=r.P.distance(n.pt,new r.P(0,0));const g=new r.P;cn(a,m,l,g);const d=r.P.distance(g,new r.P(0,0));d<n.d&&(n.d=d,n.t=l,n.pt.assign(g));for(let t=0;t<c;t++){cn(a,m,o[t],g);const e=r.P.distance(g,new r.P(0,0));e<n.d&&(n.d=e,n.t=_n(h,o[t]),n.pt.assign(g))}return n}function Ai(t,e,s,i,n){let o=!0;const a=(0,r.m)(r.P,4),h=fe(5,e,s,i,n,e=>(Mi(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));o=!1;const m=fe(5,e,s,i,n,e=>(Mi(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));return new r.P(h,m)}function Ti(t){t.m_cachedValues=null}function Ii(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Ei,s=(0,r.m)(r.P,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Ni(s,i,e.specialPoints),Hi(t,e),e}function Ni(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const i=(0,r.m)(r.H,8);i[0].set(0);let n=1;{const s=new r.H(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new r.H(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.H(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.H,2);let m=Lt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.N)(h[t].value(),0,1)||(i[n]=h[t],n++)}{const s=new r.H(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new r.H(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new r.H(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,r.m)(r.H,2);let m=Lt(a,o,s,new r.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,r.N)(h[t].value(),0,1)||(i[n]=h[t],n++)}if(i[n].set(1),n++,n>2){(0,r.C)(i,0,n,(t,e)=>(0,r.a7)(t.value(),e.value()));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let t=0;t<n;t++)s[t]=i[t].value()}function qi(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+qi(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Ii(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Bi(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=Di(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function Mi(t,e,s,i){const n=(0,r.m)(r.P,3);t.queryControlPoints(n);const o=[0,0,0];t.queryWeights(o),Yi(n,o,e,s,i)}function Yi(t,e,s,n,o){const a=[t[0],t[1],t[2]],h=[e[0],e[1],e[2]],m=(0,r.m)(r.P,4);!function(t,e,s,n,r){(0,i.g)(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Xi(o,e,0,n),h=Ri(e,0,n),m=a.divide(h);if(r[0].assign(m),0===s)return;const u=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],l=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],c=h*h,g=Xi(l,u,0,n).mul(2).divide(c);if(r[1].assign(g),1===s)return;const d=Ri(e,1,n),_=2*h*d,p=Xi(l,u,1,n).mul(2).sub(g.mul(_)).divide(c);if(r[2].assign(p),2===s)return;const f=Xi(l,u,2,n).mul(2),x=2*(d*d+h*Ri(e,2,n)),P=f.sub(p.mul(_).mul(2)).sub(g.mul(x)).divide(c);r[3].assign(P),3!==s&&(0,i.d)("")}(a,h,s,n,m);for(let t=0;t<=s;t++)o[t].setCoords(m[t].x,m[t].y)}function Xi(t,e,s,n){if(0===s){if(n<=.5){const s=new r.P;(0,r.a1)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r.a1)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r.a1)(2,s,i,n,o),o}{const s=new r.P;(0,r.a2)(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new r.P;(0,r.a2)(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const o=new r.P;return(0,r.a2)(2,s,i,n,o),o}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-n).add(t[2].mul(e[2]).sub(s).mul(n));return i.mulThis(2),i}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}(0,i.d)("")}function Fi(t,e,s,i){if(i.toDouble()<=.5){const s=new y;(0,r.a3)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new y;(0,r.a3)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new y;return(0,r.a3)(2,s,n,i,o),o}{const s=new y;(0,r.a4)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new y;(0,r.a4)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const o=new y;return(0,r.a4)(2,s,n,i,o),o}}function Ri(t,e,s){if(0===e){const e=(0,r.q)(t[0],t[1],s),i=(0,r.q)(t[1],t[2],s);return(0,r.q)(e,i,s)}return 1===e?2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,i.d)("")}function Li(t,e,s){const i=(0,r.s)(s,0,1),n=(0,r.m)(r.P,4);if(Yi(t,e,3,i,n),n[1].isZero()){if(n[2].isZero())return n[3];{const t=n[2].clone();return 1===i&&t.negateThis(),t}}return n[1]}class zi{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-qi(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}}function Vi(t){const e=(0,r.m)(r.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=dn(e);if(1===s)return Me(t);if(0===s)return 0;const n=[new r.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=n[1].crossProduct(n[2]);if(s<1){(0,i.g)(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const i=t*(1+s),n=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-(0,r.ap)(i)*n)/i}return o*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*o-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-n[1].x*n[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}(e,s)}function Bi(t){return function(t){return 256*(0,r.O)()*t}(t.calculateUpperLength2D())}function Gi(t){return t.m_cachedValues}function Hi(t,e){t.m_cachedValues=e}function ki(t,e,s,i,n){const o=(0,r.m)(r.P,3);t.queryControlPoints(o);const a=[0,0,0];t.queryWeights(a);const h=[0];return 1===Wi(o,a,e,r.E.unit(),i,n,1,h)?h[0]:Number.NaN}function Wi(t,e,s,o,a,h,m,u){(0,i.x)(r.E.unit().contains(o)&&m>0,""),(h<0||Number.isNaN(h))&&(h=Number.MAX_VALUE);const l=new Array(3);for(let e=0;e<3;++e)l[e]=t[e].sub(s);const c=dn(e),g=C.constructPoint2D(l[0]),d=C.constructPoint2D(l[1]),_=C.constructPoint2D(l[2]),p=r.M.constructDouble(c),f=p.clone();f.ldexpThis(1);const x=g.dotProduct(d.sub(g)).mul(p),P=p.mul(p.addDouble(2)),y=_.sub(d.mul(P.ldexp(1))),v=d.sqrLength().mul(p.mul(p).ldexp(1)).add(g.sqrLength().mul(p.ldexp(2).subDouble(1))).add(g.dotProduct(y)),E=_.sub(d.mul(f)).add(g.mul(f.subDouble(1))),b=d.mul(p).sub(g).dotProduct(E).mulDouble(3),D=d.dotProduct(_).mul(p.subDouble(3).mul(p)).ldexp(1),S=d.sqrLength().mul(p.mul(p).ldexp(2)),w=g.sqrLength().mul(p.ldexp(2).subDouble(3)),A=g.dotProduct(_.sub(d.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),T=_.sqrLength().addThis(D).addThis(S).addThis(w).addThis(A),I=g.add(_).sub(d.mul(f)),N=p.subDouble(1),q=_.sub(g).dotProduct(I).mul(N),M=new r.P(0,0),Y=[];let X=new r.P;cn(l,e,o.vmin,X);let F=r.P.distance(X,M);if(F<=h&&Y.push(new r.P(o.vmin,F)),o.vmin!==o.vmax&&(cn(l,e,o.vmax,X),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(o.vmax,F))),o.width()>0){const t=l[2].isZero(),s=(0,r.m)(r.M,4),i=re(q,T,b,v,x,58,o,t,s);for(let t=0;t<i;t++){if(!o.containsExclusiveCoordinate(s[t].toDouble()))continue;let i=s[t].toDouble();i=_n(e,i);const n=new r.P;cn(l,e,i,n),F=r.P.distance(n,M),F<=h&&Y.push(new r.P(i,F))}}if(a){(0,i.g)(o.equals(r.E.unit()));{cn(l,e,-1,X,!0);const t=new r.P;cn(l,e,0,t);const s=new Fr({start:X,end:t}),i=s.getClosestCoordinate(M,!0);i<1&&(X=s.getCoord2D(i),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(i-1,F)))}{cn(l,e,2,X,!0);const t=new r.P;cn(l,e,o.vmax,t);const s=new Fr({start:t,end:X}),i=s.getClosestCoordinate(M,!0);i>0&&(X=s.getCoord2D(i),F=r.P.distance(X,M),F<=h&&Y.push(new r.P(1+i,F)))}}if(!Y.length)return 0;Y.sort((t,e)=>t.compare(e));let R=0;const L=Y[0].x;if(u[R++]=L,R<m){const t=(0,n.J)(l,4,!1).total(),e=Y[0].y;for(let s=1,i=Y.length;s<i;s++)if(Y[s].y>e+t){Y.length=s;break}Y.sort((t,e)=>(0,r.a7)(t.x,e.x)),R=0,u[R++]=Y[0].x;for(let t=1,e=Y.length;t<e;t++)Y[t].x!==u[R-1]&&R<m&&(u[R++]=Y[t].x)}return R}function ji(t,e,s){const i=(0,r.m)(r.P,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),Zi(i,n,e,s)}function Zi(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=(0,r.m)(r.P,3);Ki(t,e,s.vmin,s.vmax,n,[0,0,0]),i.setFromPoints(n,3)}function Ui(t){const e=(0,r.F)(t[0].y,t[1].y),s=(0,r.F)(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=(0,r.F)(t[0].x,t[1].x),s=(0,r.F)(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Oi(t){const e=(0,r.m)(r.P,3);t.queryControlPoints(e);const s=Qi(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Qi(t){let e=!1;for(let s=0;s<2;s++){const i=(0,r.F)(t[0][s],t[2][s]);i>0?((0,r.F)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,r.F)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,r.F)(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function $i(t,e,s,o,a,h,m){(0,i.g)(s>=0&&s<=1&&o!==h&&a!==m),(0,i.g)(e[0]>0&&e[2]>0&&e[1]>=0);const u=[1,dn(e),1],l=pn(e,s),c=(0,r.L)(t,3),g=(0,r.m)(n.f,3);mn(c,u,g);const d=(0,r.m)(n.f,3),_=(0,r.m)(n.f,3);fn(g,l,o?d:null,h?_:null),xn(e,s,a,m);const p=Ui(c);if(o){for(let t=0;t<3;++t)ln(d[t],o[t]);yn(c,o),p&&Qi(o)}if(h){for(let t=0;t<3;++t)ln(_[t],h[t]);yn(c,h),p&&Qi(h)}}function Ki(t,e,s,o,a,h){if((0,i.g)(s>=0&&o<=1&&s<=o),s===o){const i=new r.P,n=un(t,e,s,i);return Pn(t,i),a[0].assign(i),a[1].assign(i),a[2].assign(i),h[0]=n,h[1]=n,void(h[2]=n)}if(0===s&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),h[0]=e[0],h[1]=e[1],void(h[2]=e[2]);const m=(0,r.m)(n.f,3);{const i=[1,dn(e),1],n=pn(e,s),r=pn(e,o);mn(t,i,m),fn(m,r,m,null),fn(m,n>=r?1:n/r,null,m)}const u=[0,0,0];xn(e,o,u,null),xn(u,s/o,null,u);const l=Ui(t),c=(0,r.m)(r.P,3);ln(m[1],c[1]),cn(t,e,s,c[0]),cn(t,e,o,c[2]),yn(t,c);for(let t=0;t<3;++t)a[t].assign(c[t]),h[t]=u[t];l&&Qi(a)}function Ji(t,e,s){const i=dn(e),n=[1,i,1],o=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),(0,r.U)(t[0],t[1],o,s[1]),(0,r.U)(t[2],t[1],o,s[2]),new Ci({cp:s}),new Ut({points:t,weight:i});let a=0,h=.1,m=0;for(let e=0;e<9;e++,h+=.1){const e=new r.P;cn(t,n,h,e);const i=new r.P;Os(s,h,i);const o=r.P.sqrDistance(e,i);o>a&&(a=o,m=h)}{const e=new r.P;cn(t,n,m,e);const i=[0];ui(s,e,r.E.unit(),!1,-1,1,i);const o=new r.P;return Os(s,i[0],o),a=r.P.sqrDistance(e,o),Math.sqrt(a)}}function tn(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==nn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function en(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==rn(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function sn(t,e,s,i,n){if(n){if(0!==Ar(e,s))return t?4:2}else if(D(e,s))return 1;return 0!==an(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function nn(t,e,s,n,o,a,h,m,u,l){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!=a)for(let t=0;t<i;t++)a.push(0);if(null!=n)for(let s=0;s<i;s++){const i=new r.P;e.queryCoord2D(t[s],i),n.push(i)}}return i}const c=G(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new Fr({start:e.getStartXY(),end:e.getEndXY()}),i=ot(t,s,n,o,a,h,m,l);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(H(e,s,h))return 0;const g=(0,r.m)(r.P,3);e.queryControlPoints(g);const d=[0,0,0];e.queryWeights(d);const _=[1,dn(d),1],p=s.getEndXY().sub(s.getStartXY()),f=p.clone();f.leftPerpendicularThis();const x=g[0].clone(),P=g[1].clone(),y=g[2].clone(),v=P.sub(x),C=y.sub(x),E=y.sub(P),b=_[0],D=_[1],S=_[2],w=b*D,A=b*S,T=D*S,I=v.dotProduct(f)*w,N=C.dotProduct(f)*A;let q=I,M=N-2*I,Y=E.dotProduct(f)*T+N-N;const X=(0,r.d)(13,Number.NaN),F=(0,r.d)(13,Number.NaN);let R=Nt(Y,M,q,r.E.unit(),!1,X);R<0&&(X[0]=0,X[1]=1,R=2);let L=0;for(let t=0,e=L;t<R;++t){const i=new r.P;cn(g,_,X[t+e],i),F[L]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(F[L]))<=h&&(X[L]=X[t+e],L++)}const z=(0,r.m)(r.P,3),V=(0,r.m)(r.P,3);if(e.queryControlPoints(V),V[0].subThis(s.getStartXY()),V[1].subThis(s.getStartXY()),V[2].subThis(s.getStartXY()),function(t,e,s,i=!1){const n=(0,r.m)(r.P,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}(V,_,z,!1),Math.abs(p.x)>=Math.abs(p.y)){const t=p.y/p.x;Y=z[2].y-z[2].x*t,M=z[1].y-z[1].x*t,q=z[0].y-z[0].x*t}else{const t=p.x/p.y;Y=z[2].x-z[2].y*t,M=z[1].x-z[1].y*t,q=z[0].x-z[0].y*t}const B=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),k=[0,0];R=Nt(Y,M,q,r.E.unit(),B,k);for(let t=0,e=L;t<R;++t){X[t+e]=k[t];const i=new r.P;cn(g,_,X[t+e],i),F[L]=s.getClosestCoordinate(i,!1),r.P.distance(i,s.getCoord2D(F[L]))<=h&&(X[L]=X[t+e],L++)}(0,i.g)(L<X.length+4);for(let t=0;t<L;t++)X[t]=_n(d,X[t]);R=e.intersectPoint(s.getStartXY(),k,h);for(let t=0;t<R;t++)X[L]=k[t],F[L++]=0;R=e.intersectPoint(s.getEndXY(),k,h);for(let t=0;t<R;t++)X[L]=k[t],F[L++]=1;R=s.intersectPoint(e.getStartXY(),k,h);for(let t=0;t<R;t++)F[L]=k[t],X[L++]=0;R=s.intersectPoint(e.getEndXY(),k,h);for(let t=0;t<R;t++)F[L]=k[t],X[L++]=1;return 0===L?0:qr(t,e,s,X,F,L,n,o,a,h,m,0,l)}function rn(t,e,s,i,n,o,h,m,u,l){if(Jn(s))return nn(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,h,m,0,l);const c=G(e,s);if(H(e,s,h=Math.max(h,c)))return 0;const g=[],d=[],_=(0,r.m)(r.P,4);{e.queryControlPoints(_);const t=(0,r.m)(r.P,4),i=new a.T;s.canonicToWorldTransformation(i);const n=new a.T;n.setInvert(i),n.transformPoints2D(_,4,t);const o=(0,r.m)(r.M,3),u=(0,r.m)(r.M,3),l=(0,r.m)(r.M,3),c=[0,0,0];e.queryWeights(c),hn(t,c,o,u,l);const p=(0,r.m)(r.M,3);p[0].setDouble(s.getSemiMinorAxis()),p[0].sqrThis(),p[1].setDouble(s.getSemiMajorAxis()),p[1].sqrThis(),p[2].setThis(p[0]),p[2].mulThis(p[1]),p[2].negateThis();const f=ee(o,2,u,2,l,2,p,0,r.E.unit(),r.E.unit(),g,m);if(f>0){let t=0;for(let i=0;i<f;i++){const n=new r.P;e.queryCoord2D(g[i],n);const o=s.getClosestCoordinate(n,!1),a=new r.P;s.queryCoord2D(o,a),r.P.distance(n,a)<=h&&(g[t]=g[i],d.push(o),t++)}g.length=t}}const p=[0,1];for(let t=0;t<2;t++){const i=0===t?s.getStartXY():s.getEndXY(),n=ki(e,i,r.E.unit(),!1,-1),o=new r.P;e.queryCoord2D(n,o),r.P.distance(i,o)<=h&&(g.push(n),d.push(p[t]))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(_[e[t]],!1),n=new r.P;s.queryCoord2D(i,n),r.P.distance(_[e[t]],n)<=h&&(g.push(p[t]),d.push(i))}}return qr(t,e,s,g,d,g.length,i,n,o,h,m,0,l)}function on(t,e,s,n,o,a,h,m,u,l){const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);if(s.queryControlPoints(g),k(c,g,3)<0)return on(t,s,e,n,a,o,h,m,u,!l);const d=G(e,s);if(e.isDegenerateToLineHelper(d)){const i=new Fr({start:e.getStartXY(),end:e.getEndXY()}),r=nn(t,s,i,n,a,o,h,m,0,!l);if(o)for(let t=0;t<r;++t){const s=i.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(s,!1)}return r}if(s.isDegenerateToLineHelper(d)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()}),r=nn(t,e,i,n,o,a,h,m,0,l);if(a)for(let t=0;t<r;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return r}if(H(e,s,h=Math.max(h,d)))return 0;const _=(0,r.d)(3,Number.NaN);e.queryWeights(_);const f=(0,r.d)(3,Number.NaN);s.queryWeights(f);const x=[1,dn(_),1],P=[1,dn(f),1],y=new r.E(0,1),v=new r.E(0,1);{const t=p.constructEmpty();Zi(c,x,new r.E(0,1),t);const e=p.constructEmpty();Zi(g,P,new r.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(gn(c,x,t,y),gn(g,P,t,v),y.isEmpty()||v.isEmpty())return 0;Ki(c,x,y.vmin,y.vmax,c,x),Ki(g,P,v.vmin,v.vmax,g,P)}}const C=Yr(c,2,g,2,h);if(0===C)return 0;const E=[],b=[];if(-1===C){const t=(0,r.m)(r.M,3),e=(0,r.m)(r.M,3),s=(0,r.m)(r.M,3);hn(c,x,t,e,s);const i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=(0,r.m)(r.M,3);hn(g,P,i,n,o);const a=[],u=[],d=te(t,2,e,2,s,2,i,2,n,2,o,2,0,r.E.unit(),r.E.unit(),a,u,m,0,l);if(d>0)for(let t=0;t<d;t++){const e=new r.P;cn(g,P,u[t],e);const s=new r.P;cn(c,x,a[t],s),r.P.distance(s,e)<=h&&(E.push(a[t]),b.push(u[t]))}}for(let t=0;t<2;t++){let e,s,n;0===t?(e=c,s=g,n=P):(e=g,s=c,n=x);for(let o=0;o<2;o++){const a=0===o?0:e.length-1,m=new r.P,u=[0],l=Wi(s,n,e[a],r.E.unit(),!1,-1,1,u);(0,i.g)(1===l),cn(s,n,u[0],m),r.P.distance(e[a],m)<=h&&(0===t?(E.push(0===a?0:1),b.push(u[0])):(b.push(0===a?0:1),E.push(u[0])))}}if(0===E.length)return 0;if(!y.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ut.recalculateParentT(y.vmin,y.vmax,E[t]);if(!v.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(v.vmin,v.vmax,b[t]);for(let t=0;t<E.length;++t)E[t]=_n(_,E[t]);for(let t=0;t<b.length;++t)b[t]=_n(f,b[t]);return qr(t,e,s,E,b,E.length,n,o,a,h,m,0,l)}function an(t,e,s,i,n,o,a,h,m,u){if(e.isLine())return je(t,s,new Fr({start:e.getStartXY(),end:e.getEndXY()}),i,o,n,a,h,0,!u);if(s.isLine())return nn(t,e,new Fr({start:s.getStartXY(),end:s.getEndXY()}),i,n,o,a,h,0,u);const l=G(e,s);if(H(e,s,a=Math.max(a,l)))return 0;const c=(0,r.m)(r.P,3);e.queryControlPoints(c);const g=(0,r.m)(r.P,3);s.queryControlPoints(g);const d=Yr(c,2,g,2,a);if(0===d)return 0;const _=[],p=[];if(-1===d){const t=(0,r.m)(r.M,3),i=(0,r.m)(r.M,3),n=(0,r.m)(r.M,3),o=[0,0,0];e.queryWeights(o),hn(c,o,t,i,n);const m=(0,r.m)(C,3);Qe(g,m);const l=te(t,2,i,2,n,2,[m[0].x,m[1].x,m[2].x],2,[m[0].y,m[1].y,m[2].y],2,null,0,0,r.E.unit(),r.E.unit(),_,p,h,0,u);if(l>0){let t=0;for(let i=0;i<l;i++){const n=new r.P;s.queryCoord2D(p[i],n);const o=new r.P;e.queryCoord2D(_[i],o),r.P.distance(o,n)<=a&&(_[t]=_[i],p[t]=p[i],t++)}_.length=t,p.length=t}}for(let t=0;t<2;t++){let i;i=0===t?c:g;for(let n=0;n<2;n++){const o=0===n?0:i.length-1;let h;const m=new r.P;0===t?(h=Fe(s,i[o],r.E.unit(),!1),s.queryCoord2D(h,m)):(h=ki(e,i[o],r.E.unit(),!1,-1),e.queryCoord2D(h,m)),r.P.distance(i[o],m)<=a&&(0===t?(_.push(0===o?0:1),p.push(h)):(p.push(0===o?0:1),_.push(h)))}}return qr(t,e,s,_,p,_.length,i,n,o,a,h,0,u)}function hn(t,e,s,i,n){const o=r.M.constructDouble(e[0]),a=r.M.constructDouble(e[1]),h=r.M.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(o),s[1].setDouble(t[1].x),s[1].mulThis(a),s[2].setDouble(t[2].x),s[2].mulThis(h),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(o),i[1].setDouble(t[1].y),i[1].mulThis(a),i[2].setDouble(t[2].y),i[2].mulThis(h),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function mn(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function un(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],o=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],a=[e[0],e[1],e[2]],h=s;let m,u,l;if(s<=.5){const t=(0,r.X)(n[0],n[1],h),e=(0,r.X)(n[1],n[2],h);m=(0,r.q)(t,e,h);const s=(0,r.X)(o[0],o[1],h),i=(0,r.X)(o[1],o[2],h);u=(0,r.q)(s,i,h);const c=(0,r.X)(a[0],a[1],h),g=(0,r.X)(a[1],a[2],h);l=(0,r.X)(c,g,h)}else{const t=(0,r.Y)(n[0],n[1],h),e=(0,r.Y)(n[1],n[2],h);m=(0,r.Y)(t,e,h);const s=(0,r.Y)(o[0],o[1],h),i=(0,r.Y)(o[1],o[2],h);u=(0,r.Y)(s,i,h);const c=(0,r.Y)(a[0],a[1],h),g=(0,r.Y)(a[1],a[2],h);l=(0,r.Y)(c,g,h)}return m/=l,u/=l,i.setCoords(m,u),Pn(t,i),l}function ln(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function cn(t,e,s,i,n){if(n){if(s<0)return void K(new Fr({start:t[0],end:t[0].add(Li(t,e,0).getUnitVector())}),s,i);if(s>1)return void K(new Fr({start:t[2],end:t[2].add(Li(t,e,1).getUnitVector())}),s-1,i)}un(t,e,s,i)}function gn(t,e,s,i){i.setEmpty();const n=[];n.push(new r.E(0,1));const o=.5*Math.max(s.width(),s.height());for(;n.length;){const a=n.at(-1);n.pop();const h=new p;if(Zi(t,e,a,h),h.isIntersectingW(s)){const t=Math.max(h.width(),h.height());if(s.containsW(h)||t<=o||a.width()<1e-12)i.merge(a);else{const t=a.getCenter();n.push(r.E.construct(a.vmin,t)),n.push(r.E.construct(t,a.vmax))}}}}function dn(t){return t[1]/Math.sqrt(t[0]*t[2])}function _n(t,e){const s=Math.sqrt(t[2]/t[0]);return e/(0,r.q)(s,1,e)}function pn(t,e){const s=Math.sqrt(t[0]/t[2]);return e/(0,r.q)(s,1,e)}function fn(t,e,s,o){(0,i.g)(e>=0&&e<=1),(new n.f).setCoordsPoint3D(t[0]),(new n.f).setCoordsPoint3D(t[1]),(new n.f).setCoordsPoint3D(t[2]);const a=new n.f,h=new n.f,m=new n.f;(0,r._)(3,t[0],t[1],e,a),(0,r._)(3,t[1],t[2],e,h),(0,r._)(3,a,h,e,m);const u=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(a),s[2].assign(m)),o&&(o[0].assign(m),o[1].assign(h),o[2].assign(u))}function xn(t,e,s,n){const o=[t[0],t[1],t[2]];(0,i.g)(e>=0&&e<=1&&s!==n);const a=(0,r.q)(o[0],o[1],e),h=(0,r.q)(o[1],o[2],e),m=(0,r.q)(a,h,e);s&&(s[0]=o[0],s[1]=a,s[2]=m),n&&(n[0]=m,n[1]=h,n[2]=o[2])}function Pn(t,e){const s=r.E.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=(0,r.s)(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=(0,r.s)(e.y,s.vmin,s.vmax)}function yn(t,e){const s=new r.E;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=(0,r.s)(e[0].x,s.vmin,s.vmax),e[1].x=(0,r.s)(e[1].x,s.vmin,s.vmax),e[2].x=(0,r.s)(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=(0,r.s)(e[0].y,s.vmin,s.vmax),e[1].y=(0,r.s)(e[1].y,s.vmin,s.vmax),e[2].y=(0,r.s)(e[2].y,s.vmin,s.vmax)}const vn=r.ag/180,Cn=180/r.ag;function En(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,r.l)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function bn(t){return t*vn}function Dn(t){return t*Cn}function Sn(t){const e=(0,r.a9)();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=(0,r.l)(s,e),s<0&&(s+=e),s)}function wn(t){const e=(0,r.$)();let s=t;return s>-e&&s<=e||(s=Sn(s),s>e&&(s-=(0,r.a9)())),s}function An(t,e){return En(e-t)}var Tn=n.V;class In extends Q{constructor(t){if(void 0===t||(0,r.W)(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new r.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new r.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new r.P(0,0),this.m_interior=new r.P(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=r.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=r.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return Kn(this,t,e,1),this}constructLineCircularArc(t,e){return Kn(this,t,e,0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=new r.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(i),h=Math.sin(i);return o.rotateDirect(a,h),o.addThis(s),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new a.T;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new a.T;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return function(t,e,s,n){0===s&&(0,i.a)("construct_enclosing_circle");const o=[0,0,0],a=function(t,e,s){const i=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&l(t,e)}(e,i),function(t,e,s,i){let n=0;const o=[0,0,0];let a=0,h=0;for(let m=0;m<3;++m){let u=!1;for(;h<s;){const s=t.at(e[h]);let l=1;if(3===n?l=r.P.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===n?l=r.P.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===n&&s.equals(t.at(i[0]))&&(l=0),l<=0){if(l<0&&m+1<3){e[a]=(0,r.c)(e[h],e[h]=e[a]);for(let t=0;t<n;t++)if(i[t]===e[h]){o[t]=h;break}a++}h++;continue}u=!0;let c=0;for(let t=0;t<n;t++)o[t]>h&&(i[c]=i[t],o[c]=o[t],c++);n=c,i[n]=e[h],o[n]=h,n++,n<3?h=a:(1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.c)(i[0],i[0]=i[2]),o[2]=(0,r.c)(o[0],o[0]=o[2])),h++)}if(!u)break;if(m+1<3){a=0;let s=!1;for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)o[t]>o[e]&&(o[e]=(0,r.c)(o[t],o[t]=o[e]),i[e]=(0,r.c)(i[t],i[t]=i[e]),s=!0);for(let t=0;t<n;t++)e[o[t]]=(0,r.c)(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===n&&1===r.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,r.c)(i[0],i[0]=i[2]),o[2]=(0,r.c)(o[0],o[0]=o[2]))}h=n}return n}(t,i,e,s)}(e,s,o);if(1===a)t.constructCircleRadius(0,e[o[0]],n);else if(2===a){const s=r.P.lerp(e[o[0]],e[o[1]],.5),i=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s);t.constructCircleRadius(Math.max(i,a),s,n)}else if(3===a){const s=r.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),i=r.P.distance(e[o[0]],s),a=r.P.distance(e[o[1]],s),h=r.P.distance(e[o[2]],s);t.constructCircleRadius(Math.max(i,a,h),s,n)}else(0,i.d)("unexpected")}(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const n=r.P.calculateCircleCenterFromThreePoints(t,e,s);if(!n.isFinite()||!Number.isFinite(r.P.distance(t,n))){const i=r.P.distance(t,e),n=r.P.distance(t,s);this.constructLineCircularArc(t,i>=n?e:s)}return this.constructCircleCenterAndPoint(n,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new r.H(t.x),n=new r.H(e.x),o=new r.H(s.x),a=new r.H(t.y),h=new r.H(e.y),m=new r.H(s.y),u=new r.H(.5),l=n.subE(i),c=h.subE(a),g=o.subE(i),d=m.subE(a),_=l.mulE(d).subThisE(c.mulE(g));if(_.scaleError(10),_.isZero()){if(!l.isZero()||!c.isZero())return Kn(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const p=l.sqr().addThisE(c.sqr()).mulThisE(u),f=g.sqr().addThisE(d.sqr()).mulThisE(u),x=p.mulE(d).subThisE(f.mulE(c)),P=l.mulE(f).subThisE(g.mulE(p));x.divThisE(_),P.divThisE(_);const y=x.sqr().addThisE(P.sqr());y.sqrtThis();const v=x.addE(i),C=P.addE(a);let E=t.x-v.value(),b=t.y-C.value();const D=Math.atan2(b,E);E=e.x-v.value(),b=e.y-C.value();const S=Math.atan2(b,E);E=s.x-v.value(),b=s.y-C.value();const w=Math.atan2(b,E);let A=w-2*(0,r.$)();for(;A<D;)A+=2*(0,r.$)();let T=S-2*(0,r.$)();for(;T<A;)T+=2*(0,r.$)();let I=w+2*(0,r.$)();for(;I>D;)I-=2*(0,r.$)();let N,q=S+2*(0,r.$)();for(;q>I;)q-=2*(0,r.$)();N=T-D<D-q?T-D:q-D;const M=new r.P(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(N)>(0,r.$)(),N>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return $n(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return $n(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,o){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const a=wn(o),h=Math.cos(a),m=Math.sin(a),u=new r.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),l=r.P.getNAN(),c=wn(i);l.x=u.x*Math.cos(c),l.y=u.y*Math.sin(c),l.rotateDirect(h,m),l.addThis(s);const g=(0,r.a8)(n,(0,r.a9)());let d=g;Math.abs(d)===(0,r.a9)()&&(d=0);const _=r.P.getNAN();return _.x=u.x*Math.cos(c+d),_.y=u.y*Math.sin(c+d),_.rotateDirect(h,m),_.addThis(s),this.constructEllipticArcEndPointsCenter(l,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,r.$)(),g>0,s)}constructEllipticArcAsNURB(t,e,s,n){return(n>=1||n<0)&&(0,i.a)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,i.a)("construct_elliptic_arc_as_NURB: control_point"),dr([t,e,s],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,xr(this),this.afterCompletedModification(),t!==this&&V(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){if(this.isLine())return!0;if(this.isMajor())return!1;const e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Jn(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return r.P.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!ar(this)}isMajor(){return mr(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Tn.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?Cr(this,r.E.unit(),t):(0,i.t)("3d not impl")}applyTransformation(t){sr(this,t,!1,null,null)}createInstance(){return new In}calculateLength2D(){return function(t){if(Jn(t))return 1*r.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;const e=tr(t,0);return tr(t,1)-e}(this)}queryControlPointsHelper(t){(0,i.d)("")}queryCoord2D(t,e){if(Jn(this))J(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(r.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(r.P.construct(this.m_XEnd,this.m_YEnd));else{const s=jn(this,t),i=new r.P(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){!function(t,e,s){if(Jn(t))st(new Fr({start:t.getStartXY(),end:t.getEndXY()}),e,s);else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new r.H;Zn(t,e,i);const n=new r.H,o=new r.H;r.H.st_cosAndSin(i,n,o);const a=y.constructCoordsE(new r.H(t.m_semiMajorAxis).mulThisE(n),new r.H(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),h=new r.H(t.m_rotation);r.H.st_cosAndSin(h,n,o),a.rotateDirect(n,o),a.addThisE(y.constructPoint2D(t.m_center)),s.setE(a)}}(this,t,e)}queryCoord2DMP(t,e){(0,i.t)("")}getCoordX(t){const e=new r.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new r.P;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();i&&n.dropAllAttributes();let o=0===t&&1===e;if(o&&!i)return void this.copyTo(n);const a=r.P.getNAN();this.queryCoord2D(t,a);const h=r.P.getNAN();if(this.queryCoord2D(e,h),!o)if(a.equals(h))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&h.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,N(n,a.x,a.y),M(n,h.x,h.y),o)return void nr(n,Un(this));n.m_startAngle=jn(this,t),n.m_sweepAngle=jn(this,e)-n.m_startAngle,n.m_startAngle=Bn(n.m_startAngle),hr(n,Math.abs(n.m_sweepAngle)>(0,r.$)()),i&&n.assignVertexDescription(this.m_description),xr(n),kn(n);const m=this.m_description.getAttributeCount();if(m>1&&!i){for(let e=1;e<m;e++){const s=this.m_description.getSemantics(e),i=Tn.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<m;t++){const s=this.m_description.getSemantics(t),i=Tn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){!function(t,e,s){if(Jn(t))s.setE(y.constructPoint2D(t.getEndXY()).subE(y.constructPoint2D(t.getStartXY())));else{const i=new r.H;Zn(t,e,i);const n=new y;if(n.setCoordsE(new r.H(t.m_semiMajorAxis).negate().mulE((new r.H).setSin(i)),new r.H(t.getSemiMinorAxis()).mulE((new r.H).setCos(i))),t.m_rotation){const e=new r.H(t.m_rotation);n.rotateDirect((new r.H).setCos(e),(new r.H).setSin(e))}n.scaleThis(new r.H(t.getSweepAngle())),s.setE(n)}}(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new r.P;this.queryCoord2D(t,n);const o=new r.P;this.queryCoord2D(e,o),i||(n.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,N(s,n.x,n.y),M(s,o.x,o.y),i?nr(s,Un(this)):(s.m_startAngle=jn(this,t),s.m_sweepAngle=jn(this,e)-s.m_startAngle,s.m_startAngle=Bn(s.m_startAngle),hr(s,Math.abs(s.m_sweepAngle)>Math.PI),xr(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Qn(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,o=Tn.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,r.V)(o,a,h,n,Tn.getDefaultValue(e))}getClosestCoordinate(t,e){return Er(this,t,r.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Er(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,i.a)("");const s=this.getSemiAxes(),n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),o=n+(0,r.$)(),a=(0,r.d)(3,Number.NaN);let h=0;if(a[0]=Wn(this,n),a[0]>0&&a[0]<1&&h++,a[1]=Wn(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,(0,i.g)(t.length>=h);let m=0;for(let s=0;s<h;s++){const i=a[s];this.queryCut(m,i,t[s],e),m=i}return h}getMonotonicParts(t,e){if(t.length<4&&(0,i.a)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;const s=this.getSemiAxes(),n=(0,r.d)(4,Number.NaN);n[0]=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),n[1]=n[0]+(0,r.$)(),n[2]=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),n[3]=n[2]+(0,r.$)();const o=(0,r.d)(5,Number.NaN);let a=0;for(let t=0;t<4;t++)o[a]=Wn(this,n[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,r.Z)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,i.g)(t.length>=a);let h=0;for(let s=0;s<a;s++){const i=o[s];this.queryCut(h,i,t[s],e),h=i}return a}intersectionWithAxis2D(t,e,s,i){if(Jn(this))return new Fr({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i);let n,o;const a=new r.H(e),h=this.getSemiAxes();if(t){if(e>this.m_center.y+h.x||e<this.m_center.y-h.x)return 0;n=new r.H(h.x).mulThis(this.m_sinr),o=new r.H(h.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+h.x||e<this.m_center.x-h.x)return 0;n=new r.H(h.x).mulThis(this.m_cosr),o=new r.H(h.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}const m=n.sqr(),u=o.sqr(),l=m.addE(u),c=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(m),d=c.sqr().subThisE(l.mulE(g).mulThis(4)),_=n.mulE(a).mulThis(-2),p=a.sqr().subThisE(u),f=_.sqr().subThisE(l.mulE(p).mulThis(4));let x=d.eps()*Math.abs(f.value())<=f.eps()*Math.abs(d.value());x?n.isZero()&&(x=!1):o.isZero()&&(x=!0),x||(c.setE(_),g.setE(p));const P=(0,r.m)(r.H,2);let y=Lt(l,c,g,r.E.construct(-1,1),!1,P);if(0===y)return 0;const v=[0,0];let C=0;for(let t=0;t<y;t++){const e=new r.H,s=new r.H;x?(e.setE(P[t]),s.setE(a.subE(o.mulE(P[t])).divThisE(n))):(s.setE(P[t]),e.setE(a.subE(n.mulE(P[t])).divThisE(o)));const i=Wn(this,Math.atan2(e.value(),s.value()));i>=0&&i<=1&&(v[C]=i,C++)}return y=C,0===y?0:(2===y&&v[0]>v[1]&&(v[1]=(0,r.c)(v[0],v[0]=v[1])),i&&(0,r.b)(i,v,0,0,y),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),y>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=(0,r.c)(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return S(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new r.E(0,1),t):(0,i.t)("3d not impl")}clone(t){const e=new In;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Jn(this))return 0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=Wn(this,t),n[1]=Wn(this,i);const o=0===e?r.E.construct(this.getStartX(),this.getEndX()):r.E.construct(this.getStartY(),this.getEndY()),a=new r.P;for(let t=0;t<2;t++){const s=n[t];s>0&&s<1&&(this.queryCoord2D(s,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new r.E(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Jn(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),n=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=r.o){let t=r.P.lerp(i,n,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*r.P.distance(i,n))),e.setCoords(i),e.mergeNe(n),void e.mergeNe(t)}Cr(this,s,e)}tToLength(t){return Jn(this)?t*r.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:tr(this,t)}parametricAngleToT(t){return Wn(this,t)}tToParametricAngle(t){return jn(this,t)}lengthToT(t){if(Jn(this)){const e=r.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(Jn(t)){const s=r.P.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=On(t),n=(0,r.T)(),o=er(t);s<0&&(e=-e);const a=e/t.m_semiMajorAxis+o;let h=(0,r.ab)(a,i.e2,i.completeE);return h-=n,h-=t.getStartAngle(),h/s}(this,t)}calculateWeightedAreaCentroid2D(t){if(Jn(this)){const t=new r.P;return t.setCoords(0,0),t}const e=fr(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),n=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,h=new r.P;h.x=n*o*(n*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,h.y=n*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+n*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const m=i.add(s).mul(i.crossProduct(s)/6);return h.x-=m.x,h.y-=m.y,h.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new r.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Jn(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),n=Math.sin(s),o=Math.cos(e),a=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,r=s*(n-i),h=s*(o-a);t.setCoords(r,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),r=e*e,h=s*s,m=e*s,u=r-h,l=u/h,c=u/r,g=Math.sqrt(l),d=Math.sqrt(c),_=.5*m*(Math.asinh(g*n)/g+n*Math.sqrt(1+l*n*n))-.5*m*(Math.asinh(g*i)/g+i*Math.sqrt(1+l*i*i)),p=-.5*m*(Math.asin(d*a)/d+a*Math.sqrt(1-c*a*a))- -.5*m*(Math.asin(d*o)/d+o*Math.sqrt(1-c*o*o));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Jn(this)){const s=r.P.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),n=new r.P;return this.queryCoord2D(i,n),r.P.distance(n,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getTangent(t){if(Jn(this))return this.getEndXY().sub(this.getStartXY());{const e=jn(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Jn(this))return this.getEndXY().sub(this.getStartXY());{const e=jn(this,t),s=new r.P;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!ur(this)&&(Jn(this)?(lr(this),!1):cr(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new r.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new r.P(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=jn(this,t),s=new r.P,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const n=new r.P;n.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),n.rotateDirect(this.m_cosr,this.m_sinr));const o=s.sqrLength();if(0===o)return Number.NaN;const a=Math.sqrt(o);return s.divThis(a),s.crossProduct(n)/o}getMonotonicPartParams(t,e){const s=(0,r.d)(6,Number.NaN);s[0]=0;let n=1;if(this.isDegenerateToLine())s[1]=1,n=2;else{const t=this.getSemiAxes(),e=(0,r.d)(4,Number.NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=(0,r.a0)());for(let t=0;t<4;t++){const i=Wn(this,e[t]);i>0&&i<1&&(s[n]=i,n++)}n>2&&(0,r.Z)(s,n),s[n]=1,n++}if(e){t<n&&(0,i.a)("");for(let t=0;t<n;t++)e[t]=s[t]}return n}calculateLowerLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=r.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,r.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,r.c)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,r.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Jn(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,rr(t)}calculateArea2DHelper(){return fr(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Jn(this))return;const s=this.getSemiAxes(),i=(0,r.d)(8,Number.NaN);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=Wn(this,t),i[1]=Wn(this,e),i[2]=Wn(this,n),i[3]=Wn(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=Wn(this,n),i[5]=Wn(this,r),i[6]=Wn(this,o),i[7]=Wn(this,a)}const n=r.P.getNAN();for(let s=0;s<8;s++){const r=i[s];t.containsExclusiveCoordinate(r)&&(this.queryCoord2D(r,n),e.mergeNe(n))}}setSegmentFromCoordsForStitcher(t,e){!function(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void Kn(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new r.P;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),h=t.getCenter(),m=new Array(4);m[0]=t.isMajor(),m[1]=!m[0],m[2]=m[0],m[3]=!m[0];const u=new Array(4);u[0]=t.isClockwise(),u[1]=u[0],u[2]=!u[0],u[3]=!u[0];const l=Math.trunc(s<5?1:(s+4)/5),c=(0,r.m)(In,4),g=(0,r.d)(4,Number.NaN);let d=0;for(let t=0;t<4;t++){c[t].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,o,a,m[t],u[t],h),g[t]=0;let i=0;for(let n=l;n<s-1;n+=l){const s=c[t].getClosestCoordinate(e[n],!1);g[t]+=r.P.sqrDistance(c[t].getCoord2D(s),e[n]),i++}g[t]/=i,g[t]<g[d]&&(d=t)}t.assignCopy(c[d])}(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,i.d)("should not1; be called"),0}ensureXYMonotone(){if(Jn(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Kn(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=(0,r.m)(r.P,3);let e=gr(this,t);if(Qi(t)){let s=!1;if(0===this.projectionBehavior()){const i=new o.Envelope2D;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const n=new r.P;n.setSub(t[2],t[0]),n.leftPerpendicularThis(),n.normalize(),n.scale(r.P.distance(t[2],t[0]));const a=r.P.lerp(t[2],t[0],.5),h=a.sub(n),m=a.add(n);i.clipLine(h,m);const u=r.P.getClosestCoordinate(h,m,t[1],!1);t[1]=r.P.lerp(h,m,u);const l=t[2].sub(t[1]),c=t[0].sub(t[1]),g=l.crossProduct(c),d=l.dotProduct(c);e=(0,r.T)()-Math.abs(.5*Math.atan2(g,d)),s=!0}return dr(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Qn(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,nr(e,Un(this))}reverseImpl(){or(this,!ar(this)),kn(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&xr(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(bn(En(Dn(this.m_rotation-s.m_rotation)))),n=Math.abs((0,r.$)()-i),o=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;const a=this.getCoord2D(.5),h=s.getCoord2D(.5);return!!a.isEqualPoint2D(h,e)}swapImpl(t){const e=t;this.m_center=(0,r.c)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,r.c)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,r.c)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,r.c)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,r.c)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,r.c)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,r.c)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,r.c)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,r.c)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,r.c)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,r.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){lr(this),rr(this)}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&(0,i.r)(""),Jn(this))return new Fr({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s);{const e=r.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),o=r.P.getNAN();return this.queryCoord2D(n,o),r.P.distance(o,t)<=s?(0,r.N)(n,0,1)&&(this.queryCoord2D(0===n?1:0,o),r.P.distance(o,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,rr(this)}clearEndPointModified(){lr(this)}}function Nn(t,e,s,i,n,o){return new Yn(0,0,0,null,!1,(0,r.i)()).densifyEx(t,e,s,i,!1,o)}function qn(t,e,s,n,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const u=t.getGeometryType();if(u===i.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(u===i.G.enumBezier){if(!n)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;const e=(0,r.d)(9,Number.NaN);let i=t.getMonotonicPartParams(e.length,e);if(e.length=i,i=Xn(t,s,e),2===i&&o&&(e[1]=.5,e.push(1),i=3),h&&h.splice(0,0,...e.slice(0,i)),a){const s=new Rr;for(let n=1;n<i;n++){const i=e[n-1],r=e[n];t.queryCut(i,r,s,!0);const o=s.get();ks(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return i-1}if(u===i.G.enumEllipticArc){const m=t;if(m.isDegenerateToLine()||m.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(r.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(n&&(o||!m.isMonotoneQuickAndDirty())){const u=(0,r.d)(6,Number.NaN);let l=m.getMonotonicPartParams(u.length,u);u.length=l,l=Xn(t,s,u),2===l&&o&&(u[1]=.5,u.push(1),l=3);let c=0;if(l>2){const t=new Rr,r=h||[];let o=0;for(let g=1;g<l;g++){const d=u[o],_=u[g];if(m.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=r.length,f=Fn(1===g,t.get(),e,s,n,a,h);(0,i.g)(f>0),c+=f;const x=g===l-1,P=u[o],y=t.get().getSweepAngle()/m.getSweepAngle();for(let t=p,e=r.length;t<e;t++)if(r[t]=!x||t+1<e?P+r[t]*y:1,a){const e=3*t,s=m.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Ws(a.slice(e-3))}o=g}return c}}return Fn(!0,m,e,s,n,a,h)}if(u===i.G.enumRationalBezier2){const i=t;if(n&&(o||!i.isMonotoneQuickAndDirty())){const n=(0,r.d)(6,Number.NaN);let m=i.getMonotonicPartParams(n.length,n);n.length=m,m=Xn(t,s,n),2===m&&o&&(n[1]=.5,n.push(1),m=3);let u=0;if(m>2){const t=new Rr,r=h||[];for(let o=1;o<m;o++){const l=n[o-1],c=n[o];i.queryCut(l,c,t,!0);const g=r.length;u+=Rn(1===o,t.get(),e,s,!1,a,h);const d=o===m-1,_=n[o-1];for(let t=g,e=r.length;t<e;t++)if(r[t]=!d||t+1<e?_+r[t]:1,a){const e=3*t,s=i.getCoord2D(r[t]);a[e].setCoordsPoint2D(s),e>0&&Be(a.slice(e-3))}}return u}}return Rn(!0,i,e,s,n,a,h)}if(u===i.G.enumBezier2){const i=t,m=(0,r.m)(r.P,3);i.queryControlPoints(m);const u=new Ci;u.constructFromQuadratic(m);const l=qn(u,e,s,n,o,a,h);if(null!=a&&null!=h){const t=3;for(let e=1,s=0;e<l;++e,s+=t){const o=new r.P;i.queryCoord2D(h[e],o);const m=a[s+t];!o.equals(m)&&(a[s+t].setCoordsPoint2D(o),n)&&Ws(a.slice(s,s+4))}}return l}(0,i.t)("")}function Mn(t,e,s,n,o,a,h,m,u){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),l===i.G.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(r.P.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=(0,r.d)(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Xn(t,s,c);else{if(g=2,c[0]=0,c[1]=1,l===In.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else(0,i.g)(l===Ut.type);c.length=g}if(2===g&&n&&(c[1]=.5,c.push(1),g=3),a){const e=new Rr;let s=1;for(;s<g;){const n=c[s-1],m=c[s];t.queryCut(n,m,e,!0);const u=(0,r.m)(r.P,3),d=[1,1,1];if(l===i.G.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(m-n)/3;c.splice(s,0,n+t),c.splice(s+1,0,n+2*t),g+=2;continue}d[1]=gr(t,u)}else{const t=e.get();t.queryControlPoints(u),t.queryWeights(d)}o&&Qi(u),1===s&&(a.push(u[0].clone()),h.push(d[0])),a.push(u[1].clone()),a.push(u[2].clone()),h.push(d[1]),h.push(d[2]),s++}}return m&&(m.length=g,(0,r.b)(m,c,0,0,g)),g-1}In.type=i.G.enumEllipticArc;class Yn{static constructDefault(t){return new Yn(0,0,0,t,!1,(0,r.i)())}constructor(t,e,s,o,a,h){this.m_segmentBuffer=null,this.m_dummyPoint=new n.P,this.m_progressCounter=0,this.m_progressTracker=o,this.m_bSetDensifyFlag=a,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>(0,r.T)()?(0,r.T)():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=h,(0,i.x)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,n,o,a){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=n>(0,r.T)()?(0,r.T)():n,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,i.x)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return(0,i.j)(e)?t:(0,i.h)(e)?this.densifyMultiPath(t):(0,i.f)(e)?this.densifySegmentImpl(t):e===i.G.enumEnvelope?this.densifyEnvelope(t):void(0,i.d)("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.G.enumLine)&&(!n||s))return void(e?o===i.G.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.G.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.G.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Dt({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){const e=new rs({vd:t.getDescription()});e.addEnvelope(t,!1);const s=o.Envelope2D.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=e.getImpl(),n=t.getImpl(),o=n.getAttributeStreamRef(0),a=new Fr;for(let t=0,i=n.getPathCount();t<i;t++){const i=n.isClosedPath(t);if(0===n.getPathSize(t))continue;const h=n.getPathStart(t),m=o.readPoint2D(2*h),u=m.clone();s.startPath(m);for(let i=h+1,m=n.getPathEnd(t);i<m;i++){const t=o.readPoint2D(2*i),n=r.P.distance(u,t);if(n>this.m_maxLength){let e=Math.ceil(n/this.m_maxLength);e>(0,r.i)()&&(e=(0,r.i)());const i=1/e;let o,h,m;u.compare(t)<0?(a.setStartXY(u),a.setEndXY(t),o=0,h=1):(a.setStartXY(t),a.setEndXY(u),o=e-2,h=-1);for(let t=0,n=e-1;t<n;t++,o+=h){this.progress_(),m=i*(o+1);const t=new r.P;a.queryCoord2D(m,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),u.assign(t)}if(i){const t=r.P.distance(u,m);if(t>this.m_maxLength){const e=m;let i=Math.ceil(t/this.m_maxLength);i>(0,r.i)()&&(i=(0,r.i)());const n=1/i;let o,h;u.compare(e)<0?(a.setStartXY(u),a.setEndXY(e),o=0,h=1):(a.setStartXY(e),a.setEndXY(u),o=i-2,h=-1);const l=new r.P(0,0);let c;for(let t=0,e=i-1;t<e;t++,o+=h)this.progress_(),c=n*(o+1),a.queryCoord2D(c,l),s.lineTo(l),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,s,n,o,a){(0,i.g)(t.getGeometryType()!==i.G.enumBezier);let h=t.getStartXY().compare(t.getEndXY());0===h&&e<1&&(t.getGeometryType()===i.G.enumEllipticArc?h=t.getSweepAngle()<0?1:-1:(0,i.t)("densify segment by length"));let m=0;if(n&&(s?(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)):a.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new Rr);let i=Math.ceil(1/e);i>(0,r.i)()&&(i=(0,r.i)()),e=1/i,this.m_segmentBuffer.create(t.getGeometryType());let n,o,u,l=t;h<0?(n=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),n=i-2,o=-1,l=this.m_segmentBuffer.get());const c=i-1;for(let t=0;t<c;t++,n+=o)u=e*(n+1),s?(l.queryCoord(u,this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==u&&0!==u&&s.setAttribute(10,s.getPointCount()-1,0,1)):a.push(h>0?1-u:u),this.progress_();u=1,m+=c}(!o||o&&n&&m<2)&&(s?(t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,s,i,n){const o=new Ci;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());if(0===m&&h>0){const e=(0,r.m)(r.P,4);t.queryControlPoints(e),m=e[1].compare(e[2]),0===m&&(m=e[1].compare(e[0]))}m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=[],c=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let d=!0,_=0;if(m>0)for(l.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);l.length;){this.progress_();const t=l.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.mul(1-s).add(u.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[3];t[1]=i,t[2]=g,t[3]=f,t[4].setCoords(h,e);const P=[f,p,u,x,new r.P(e,m)];l.push(P),c[c.length-1]=o+1,c.push(o+1);continue}l.pop(),c.pop(),(l.length>0||!i||i&&s&&u<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(1-h),++u)}else for(l.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new r.P(0,1)]),c.push(0);l.length;){this.progress_();const t=l.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(h+m);Math.abs(_-e)<.4*(m-h)&&(e=_);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(n.mul(s)),p=n.mul(1-s).add(u.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[0];t[0]=f,t[1]=p,t[2]=u,t[4].setCoords(e,m);const P=[x,i,g,f,new r.P(h,e)];l.push(P),c[c.length-1]=o+1,c.push(o+1);continue}l.pop(),c.pop(),(l.length>0||!i||i&&s&&u<2)&&(e?(a.queryCoord(m,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m),++u)}}densifyRationalBezier2(t,e,s,i,n){const o=new Ut;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new Ut,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.rationalBezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}densifyBezier2(t,e,s,i,n){const o=new Qt;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),c=new Qt,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.bezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}densifyEllipticArc(t,e,s,i,n){const o=new In;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=t.isClockwise()?0:1),m>0&&(t.copyTo(o),o.reverse(),a=o);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++u);const l=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new In,g=[],d=[];for(g.push(new r.E(0,1)),d.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=d.at(-1);if(o<l&&this.ellipticArcNeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new r.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new r.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1);continue}if(g.pop(),d.pop(),g.length>0||!i||i&&s&&u<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(m>0?1-s:s),++u}}}calculateLengthSubdivisionStep(t,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.G.enumEllipticArc){const i=t;if(i.isCircular()||i.isDegenerate(0)||i.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*i.getSemiAxes().y/i.getSemiAxes().x}t.getGeometryType()===i.G.enumBezier&&(0,i.t)(""),(0,i.t)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const i=s.getSemiMajorAxis(),n=1-e/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(e/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(t,o)}}(0,i.t)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}(0,i.t)("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);e.queryControlPoints(o);const a=[0,0,0];return e.queryWeights(a),!n&&this.m_maxDeviation>0&&(n=!Yn.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),n}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0;const o=(0,r.m)(r.P,3);return e.queryControlPoints(o),!n&&this.m_maxDeviation>0&&(n=!Yn.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),n}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(n=!0,!0):(!n&&this.m_maxDeviation>0&&(n=!Yn.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Yn.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&r.P.distance(t[0],t[1])+r.P.distance(t[1],t[2])+r.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!Yn.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Yn.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1])),o=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(n),Math.abs(o))<=e){const e=new r.P;Os(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),n=[0,0];if(1===function(t,e,s){(0,i.g)(!Jn(t));const n=new a.T;n.setRotateAngle(-t.getAxisXRotation());const o=new r.P;n.queryTransform(e,o);const h=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),m=h+(0,r.$)();let u=Wn(t,h),l=Wn(t,m);l<u&&(l=(0,r.c)(u,u=l));let c=0;return u>=0&&u<=1&&(s[c++]=u),l>=0&&l<=1&&(s[c++]=l),c}(t,s,n)){const s=t.getCoord2D(n[0]),i=r.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),o=new r.P;return(0,r.U)(t.getStartXY(),t.getEndXY(),i,o),r.P.distance(s,o)<=e}}const s=t.getCoord2D(.5),n=new r.P;return(0,r.U)(t.getEndXY(),t.getStartXY(),.5,n),r.P.distance(s,n)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0||s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==i.G.enumEllipticArc||t.isCircular())}}function Xn(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const o=(0,r.d)(i-1,Number.NaN);for(let e=1,r=i;e<r;e++){const i=t.tToLength(s[e]);o[e-1]=i-n,n=i}for(;o.length>1;){const t=o.findIndex(t=>t<=2*e);if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===o.length||o[e]>o[n])&&(n=e,i--)}o[n]+=o[t],o.splice(t,1),s.splice(i,1)}return s.length}function Fn(t,e,s,i,n,h,m,u){const l=e.clone();l.dropAllAttributes();const c=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(r.P.getNAN()),e.push(r.P.getNAN()),e.push(i.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(l.isDegenerateToLine()||l.isDegenerate(0))return c(t,h,m,e);const g=l.getStartXY(),d=l.getEndXY(),_=l.getSemiAxes(),p=new a.T;if(l.isCircular())p.setIdentity();else{const t=l.getAxisXRotation();p.setScaleCoords(1,l.getMinorMajorRatio()),p.rotateAngle(t)}const f=l.getCenter();p.shift(f);const x=p.clone();x.invertThis(),l.applyTransformation(x);const P=l.getSweepAngle();if(0===P)return c(t,h,m,e);const y=o.Envelope2D.constructEmpty();y.setCoords({center:f,width:2*_.x,height:2*_.x});const v=.05*y.calculateToleranceFromEnvelope(),C=Math.max(s/_.x,v/_.x);let E=4*Math.pow(C/.0741,1/6);E=Math.min(E,Math.PI/2);const b=Sn(l.getStartAngle());let D=P>0?Math.floor(b/E):Math.ceil(b/E);D*=E;const S=P>0?E:-E;D+S===b&&(D+=S);let w=4/3*Math.tan(Math.abs(E)/4);P>0&&(w=-w),m&&t&&m.push(0);const A=E/Math.abs(P);let T=(D-b)/P;const I=g.clone(),N=new r.P;l.queryCoord2D(0,N);const q=N.clone(),M=1-.01*A;let Y=0,X=0;for(;T<1;){let s;if(T+=A,X>0&&T<M)s=w;else{T>=M&&(T=1);const t=(T-X)*P;s=4/3*Math.tan(Math.abs(t)/4),P>0&&(s=-s)}l.queryCoord2D(T,N);const o=new r.P;p.queryTransform(N,o);const a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==T&&(r.P.distance(I,o)<=2*i||r.P.distance(o,d)<=2*i))continue;I.setCoordsPoint2D(o);const u=(0,r.m)(r.P,4);u[0].assign(q),u[3].assign(N),u[1].rightPerpendicularOther(q),u[1].scaleAddThis(s,q),u[2].leftPerpendicularOther(N),u[2].scaleAddThis(s,N),p.transformPoints2D(u,3,u),u[3].assign(o),0===X&&u[0].setCoordsPoint2D(g),1===T&&u[3].setCoordsPoint2D(d),n&&Ws(u);let c=!0;for(let t=1;t<4;t++)if(!u[t].isEqualPoint2D(u[0])){c=!1;break}c||(m&&m.push(a),h&&(0===X&&t&&h.push(u[0].clone()),h.push(u[1].clone()),h.push(u[2].clone()),h.push(u[3].clone())),Y++),X=T,q.setCoordsPoint2D(N)}return Y}function Rn(t,e,s,i,n,a,h,m){e.clone().dropAllAttributes();const u=new o.Envelope2D;e.queryLooseEnvelope(u);const l=.05*u.calculateToleranceFromEnvelope(),c=Math.max(s,l);h&&t&&h.push(0);let g=0;const d=(0,r.m)(r.P,3);e.queryControlPoints(d);const _=[0,0,0];e.queryWeights(_);const p=[],f=(0,r.d)(9,Number.NaN);let x=0;n?(x=e.getMonotonicPartParams(f.length,f),f.length=x,x=Xn(e,i,f)):(f.length=2,x=2,f[0]=0,f[1]=1);let P=0,y=t;for(let t=1;t<x;t++){const e=f[t];for(p.length=0,p.push(e),p.push(P);p.length>1;){const t=p.at(-1);p.pop();const e=p.at(-1),s=(0,r.m)(r.P,3),i=[0,0,0];Ki(d,_,t,e,s,i);const n=(0,r.m)(r.P,4),o=Ji(s,i,n),m=16,u=p.length>m;c>=o||u?(h.push(e),a&&(y&&(a.push(n[0]),y=!1),a.push(n[1]),a.push(n[2]),a.push(n[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class Ln{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?r.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function zn(t,e){return t.convertToCanonic(e)}function Vn(t,e,s,i){let n=t.m_startAngle,o=t.m_sweepAngle;const a=1e-12;for(;n>(0,r.$)();)n-=2*(0,r.$)();for(;n<=-(0,r.$)();)n+=2*(0,r.$)();if(!Number.isNaN(e)){for(;e>(0,r.$)();)e-=2*(0,r.$)();for(;e<=-(0,r.$)();)e+=2*(0,r.$)();!s&&e>n&&(e-=2*(0,r.$)()),s&&e<n&&(e+=2*(0,r.$)()),o=e-n,Math.abs(o)<a&&!i&&(o=s?2*(0,r.$)():-2*(0,r.$)()),Math.abs(o)>2*(0,r.$)()-a&&i&&(o=0)}Math.abs(o)>2*(0,r.$)()-a&&(o=o>=0?2*(0,r.$)():-2*(0,r.$)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),i=Math.abs(o)<=(0,r.$)(),o&&(s=o>0),t.m_startAngle=Bn(n),t.m_sweepAngle=o,hr(t,!i),or(t,s)}function Bn(t){let e=t,s=!1;return e<=-(0,r.$)()?(e+=(0,r.a9)(),s=!0):e>(0,r.$)()&&(e-=(0,r.a9)(),s=!0),e<=-(0,r.$)()?(e=(0,r.l)(e,(0,r.a9)()),e<=-(0,r.$)()&&(e+=(0,r.a9)()),s=!0):e>(0,r.$)()&&(e=(0,r.l)(e,(0,r.a9)()),e>(0,r.$)()&&(e-=(0,r.a9)()),s=!0),s&&(e>(0,r.$)()||e<=-(0,r.$)())&&(e=(0,r.$)()),e}function Gn(t,e,s){const i=s,n=i.getSemiAxes();let o=new r.P(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return o=i.convertFromCanonic(o),r.P.sqrDistance(o,i.getStartXY())}function Hn(t,e,s){const i=s,n=i.getSemiAxes(),o=t[0]+i.getStartAngle();let a=new r.P(n.x*Math.cos(o),n.y*Math.sin(o));return a=i.convertFromCanonic(a),r.P.sqrDistance(a,i.getEndXY())}function kn(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=mr(t),o=ar(t),a=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Bn(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?o?(0,r.a9)():-(0,r.a9)():0}else{const i=t.convertToCanonic(e),h=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=h.x,i.y/=h.y;const m=t.convertToCanonic(s);m.x/=h.x,m.y/=h.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=r.P.calculateAngle(i,m),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,r.a9)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,r.a9)()),t.m_startAngle=Bn(t.m_startAngle);let u=Gn([t.m_startAngle],0,t);if(u=Math.sqrt(u),u>.25*B(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Mt(Gn,t,1,[t.m_startAngle],[e],[s],0,i),t.m_startAngle=Bn(i[0])}if(u=Hn([t.m_sweepAngle],0,t),u=Math.sqrt(u),u>.25*B(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Mt(Hn,t,1,[t.m_sweepAngle],[e],[s],0,i),t.m_sweepAngle=i[0]}const l=Math.abs(t.m_sweepAngle)>(0,r.$)();if(hr(t,l),n!==l&&!n&&Math.abs(t.m_sweepAngle)>1.5*(0,r.$)())return void Kn(t,e,s,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void Kn(t,e,s,a)}}function Wn(t,e){return(function(t,e){const s=new r.E(t.getStartAngle(),t.getEndAngle());s.normalize();const i=(0,r.a9)(),n=(0,r.l)(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}(t,e)-t.getStartAngle())/t.getSweepAngle()}function jn(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Zn(t,e,s){s.assign(new r.H(t.m_startAngle).addE(e.mulE(new r.H(t.m_sweepAngle))))}function Un(t){return t.m_cachedValues}function On(t){if(t.m_cachedValues)return t.m_cachedValues;const e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,r.a)(t.m_minorMajorRatio)}(t),e.completeE=(0,r.af)(e.e2),t.m_cachedValues=e,e}function Qn(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Jn(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,xr(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*(0,r.T)()){const i=(0,r.m)(r.P,3),n=gr(t,i);if(Ui(i)){if(i[0].assign(e),i[2].assign(s),Qi(i),0===t.projectionBehavior()){let e=0,s=2;r.P.sqrDistance(i[1],i[0])<r.P.sqrDistance(i[1],i[2])&&(s=(0,r.c)(e,e=s));const n=i[s].sub(i[e]),o=n.length();n.divThis(o);const a=i[1].sub(i[e]),h=a.length(),m=a.dotProduct(n)/h,u=a.crossProduct(n)/h,l=new r.P;(0,r.U)(i[e],i[s],.5,l);const c=.5*o/u*(0,r.s)(1-m,0,1),g=i[1].side(i[e],i[s]),d=n.clone();g?d.leftPerpendicularThis():d.rightPerpendicularThis();const _=l.sub(d.mul(c));t.constructCircularArcThreePoint(i[0],i[2],_)}else dr(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?function(t,e,s){const i=t.getStartXY(),n=t.getEndXY(),o=i.equals(n),h=e.equals(s);if(!o&&!h){const o=new a.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);const h=r.P.distance(e,s),m=r.P.distance(i,n),u=h/m;o.scale(u,u);const l=n.sub(i);l.divThis(m);const c=s.sub(e);c.divThis(h);const g=l.crossProduct(c),d=c.dotProduct(l);return o.rotate(d,g),o.shiftCoords(e.x,e.y),void sr(t,o,!0,e,s)}const m=new r.P;if(t.queryCoord2D(.5,m),h){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=m.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const u=e.add(s).mul(.5),l=s.sub(e);l.rightPerpendicularThis();const c=u.add(l),g=r.P.getClosestCoordinate(u,c,t.getCenter(),!0),d=new r.P;(0,r.U)(u,c,g,d);const _=r.P.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}(t,e,s):Dr(t,e,s)}}function $n(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,I(t,e),q(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),hr(t,o),or(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,cr(t,void 0===h)}function Kn(t,e,s,i){t.m_bits=0,t.m_rotation=0,I(t,e),q(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,hr(t,!1),or(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function Jn(t){return t.m_center.isNAN()}function tr(t,e){if(0===e)return 0;const s=On(t),i=jn(t,e),n=(0,r.T)(),o=er(t),a=(0,r.aa)(i+n,s.e2,s.completeE),h=t.m_semiMajorAxis*(a-o);return Math.abs(h)}function er(t){const e=On(t);return(0,r.aa)(t.getStartAngle()+(0,r.T)(),e.e2,e.completeE)}function sr(t,e,s,n,o){if(2===e.m_TransformationType)return void(0,i.g)(0);if((0,i.g)(!ur(t)),e.isIdentity()&&(!n||n.equals(t.getStartXY())&&o.equals(t.getEndXY())))return;rr(t);let a=r.P.getNAN(),h=r.P.getNAN();if(null===n?(a.x=t.m_XStart,a.y=t.m_YStart,e.transformInPlace(a),h.x=t.m_XEnd,h.y=t.m_YEnd,e.transformInPlace(h)):(a=n,h=o),Jn(t))return t.m_XStart=a.x,t.m_YStart=a.y,t.m_XEnd=h.x,void(t.m_YEnd=h.y);const m=t.m_center.clone();if(e.transformInPlace(m),s||e.isUniformNoRotation()){let s=ar(t);if(e.isReflective()&&(s=!s),0===t.projectionBehavior()){if(!a.equals(h)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(a,h,s)}return void ir(t,a,h,m,s,!1)}const i=new r.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const n=Math.atan2(i.y,i.x),o=t.getSemiAxes();e.transformWithoutTranslateInPlace(o);const u=t.m_center.clone();return e.transformInPlace(u),void t.constructEllipticArcEndPointsCenter(a,h,o.x,o.y/o.x,n,t.isMajor(),s,u)}{{const s=new Array(4);!function(t,e){const s=new r.H(t.m_cosr).sqrThis(),i=new r.H(t.m_sinr).sqrThis(),n=new r.H(t.m_minorMajorRatio),o=new r.H(1/t.m_minorMajorRatio),a=n.mulE(s).addThisE(o.mulE(i)),h=n.subE(o).mulThis(2*t.m_cosr*t.m_sinr),m=n.mulE(i).addThisE(o.mulE(s));e[0]=a,e[1]=h,e[2]=m,e[3]=new r.H(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,s);const i=new v;if(i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]),!i.det().isZero()){const n=new v;if(n.a11.set(e.xx),n.a12.set(e.xy),n.a21.set(e.yx),n.a22.set(e.yy),n.invertThis()){const o=n.clone();o.transposeThis();const u=i.clone();if(u.mulThis(n),u.mulLeftThis(o),!u.det().isZero()){const i=(0,r.m)(r.H,4);i[0].setE(u.a11),i[1].setE(u.a12),i[1].mulThisByPower2(2),i[2].setE(u.a22),i[3].setE(s[3]);const n=r.P.getNAN(),o=function(t,e){const s=new v;s.a11.setE(t[0]),s.a12=r.H.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[r.P.getNAN(),r.P.getNAN()],n=[new r.H,new r.H];s.eigenSymmetric(n,i);const o=t[3].clone();return o.negateThis(),o.invThis(),n[0].mulThisE(o),n[1].mulThisE(o),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble(),Math.atan2(i[0].y,i[0].x)}(i,n);let l=ar(t);return e.isReflective()&&(l=!l),void t.constructEllipticArcEndPointsCenter(a,h,n.x,n.y/n.x,o,t.isMajor(),l,m)}}}}const s=[r.P.getNAN(),r.P.getNAN(),r.P.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let i=t.isClockwise();i&&(s[2]=(0,r.c)(s[0],s[0]=s[2]));const n=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const o=new r.P(0,0),u=t.createInstance();dr(s,n,o,!1,u),t.constructEllipticArcEndPointsCenter(a,h,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!i,m)}}function ir(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),Vn(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function nr(t,e){t.m_cachedValues=e}function rr(t){t.m_cachedValues=null}function or(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function ar(t){return!!(1&t.m_bits)}function hr(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function mr(t){return!!(2&t.m_bits)}function ur(t){return!!(8&t.m_bits)}function lr(t){t.m_bits&=-9}function cr(t,e){lr(t);const s=t.getStartXY(),n=t.getEndXY();let o=!1;const a=mr(t),h=ar(t),m=t.projectionBehavior(),u=s.equals(n);let l=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,i.o)("NAN minor major ratio and non-zero major axis")),l||=e?u:t.m_center.isNAN(),l)return Kn(t,s,n,m),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const c=new r.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if((0,i.g)(c.y>0&&c.x>=c.y),u){const e=t.convertToCanonic(s);(0,i.g)(!c.isZero()),e.x/=c.x,e.y/=c.y;const n=Math.sqrt((0,r.a)(e.x)+(0,r.a)(e.y));if(o=1!==n,t.m_semiMajorAxis*=n,c.mulThis(n),t.m_startAngle=Bn(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=h?(0,r.a9)():-(0,r.a9)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;const e=new y;e.setWithEps(t.getStartXY(),8),e.subThisE((new y).setWithEps(t.m_center,8));const s=new r.H;s.setWithEps(t.m_rotation,8);const i=new r.H,n=new r.H;r.H.st_cosAndSin(s,i,n),e.rotateReverse(i,n);const o=new y;o.setWithEps(t.getEndXY()),o.subThisE(y.constructPoint2D(t.m_center)),o.rotateReverse(i,n);const a=new r.H;a.setWithEps(t.m_semiMajorAxis,8);const h=a.clone(),m=new r.H;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),e.x.divThisE(a),e.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=e.x.sqr().addThisE(e.y.sqr()).subThisE(r.I),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(r.I);return!u.isZero()||!l.isZero()}(t);if(!e){const i=t.convertToCanonic(s);i.x/=c.x,i.y/=c.y;const o=new r.P(1,0);t.m_startAngle=r.P.calculateAngle(o,i);const a=t.convertToCanonic(n);a.x/=c.x,a.y/=c.y,t.m_sweepAngle=r.P.calculateAngle(i,a),e=!pr(t)}if(e){o=!0;const e=s.sub(n).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let i=(0,r.a)(e.x/c.x)+(0,r.a)(e.y/c.y);i>1&&(i=Math.sqrt(i),t.m_semiMajorAxis*=i,c.mulThis(i));const m=new r.P(0,0);{const t=c.x*c.x,s=c.y*c.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);m.setCoords(c.x*e.y/c.y,-c.y*e.x/c.x),m.mulThis(t),a===h&&m.negateThis()}}{const e=new r.P(m.x,m.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(n).mulThis(.5)),t.m_center.assign(e)}}if(kn(t),!pr(t))return Kn(t,s,n,m),!0}return xr(t),t.afterCompletedModification(),o}function gr(t,e){(0,i.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),n=t.getSemiMinorAxis();let o;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),o=1,o;if(0===n)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=r.P.lerp(e[0],e[2],.5),o=1,o;const a=t.getSweepAngle(),h=t.getStartAngle(),m=h+a,u=new r.P(-s*Math.sin(h),n*Math.cos(h)),l=new r.P(-s*Math.sin(m),n*Math.cos(m));u.normalize(),l.normalize(),u.rotateDirect(t.m_cosr,t.m_sinr),l.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const c=u.crossProduct(l);return e[1].assign(u.mul(e[1].crossProduct(l)/c)),e[1].addThis(e[0]),o=Math.cos(.5*a),o}function dr(t,e,s,n,o){if(n){const s=.5,i=Math.sqrt(e),n=(0,r.a)(1-s)+2*i*s*(1-s)+(0,r.a)(s),a=t[0].mul((0,r.a)(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul((0,r.a)(s))).divThis(n);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}const a=t[0].sub(t[1]),h=t[2].sub(t[1]),m=a.crossProduct(h),u=a.dotProduct(h),l=e;(0,i.g)(l<=1),(0,i.g)(l>0);const c=.5/(1-l),g=a.sqrLength(),d=u,_=h.sqrLength(),p=(0,r.a)(m),f=a.sub(h).sqrLength();if(0===p)return Kn(o,t[0],t[2],1),!1;if(u<=-Math.sqrt(g)*Math.sqrt(_))return Kn(o,t[0],t[2],1),!1;const x=[0,0],P=new r.E;P.setInfinite();const y=Nt(2*p,-(f/l+4*d),2*(1-l)/l,P,!1,x);if(0===y)return Kn(o,t[0],t[2],1),!1;1===y&&(x[1]=x[0]);const v=Math.sqrt(c/x[0]),C=Math.sqrt(c/x[1]),E=.5/l;let b=E-_*x[0],D=E-g*x[0];Math.abs(b)>Math.abs(D)?D=d*x[0]-E+1:b=d*x[0]-E+1;const S=a.mul(b).add(h.mul(D)),w=S.norm(1)<1e-15*v?0:Math.atan2(S.y,S.x)+Math.PI,A=a.add(h),T=s?s.clone():t[1].add(A.mul(c)),I=t[0].sub(T),N=t[2].sub(T),q=I.crossProduct(N)<0;return new In,o.constructEllipticArcEndPointsCenter(t[0],t[2],v,C/v,w,!1,!q,T)}function _r(t,e,s,i,n){return dr(t,e,s,i,n)}function pr(t){const e=B(t);let s=!1;{const i=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));i.rotateDirect(t.m_cosr,t.m_sinr),i.addThis(t.m_center),s=r.P.distance(t.getStartXY(),i)>e}let i=!1;if(!s){const s=new r.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),i=r.P.distance(t.getEndXY(),s)>e}return!s&&!i}function fr(t){if(Jn(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,u=0;t.m_rotation&&(m=(a-h)*(a+h),u=2*a*h);const l=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;return t.m_rotation&&(c=-2*Math.sin(r+n)*Math.sin(r-n)*.125*u-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h),i*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function xr(t){t.queryCoord2D(.5,t.m_interior)}function Pr(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==yr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function yr(t,e,s,n,o,a,h,m,u,l){if(Jn(e))return ot(new Fr({start:e.getStartXY(),end:e.getEndXY()}),s,n,o,a,h,m,l);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==n&&(n.length=0);const c=G(e,s);if(H(e,s,h=Math.max(c,h)))return 0;const g=s.getStartXY();g.subThis(e.m_center);const d=s.getEndXY();d.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);const _=d.clone();_.subThis(g);const p=e.m_semiMajorAxis,f=1/p,x=e.getSemiMinorAxis(),P=1/x,y=_.clone();y.leftPerpendicularThis();const v=Math.atan2(x*y.y,p*y.x),C=(0,r.d)(16,Number.NaN),E=(0,r.d)(16,Number.NaN);let b=0;const D=[v,v+Math.PI];for(let t=0;t<2;++t){const i=Wn(e,D[t]);if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(C[b]);E[b]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(E[b]))<=h&&b++}}const S=g.x*f,w=g.y*P,A=_.x*f,T=_.y*P;let I=Nt(A*A+T*T,2*(S*A+w*T),S*S+w*w-1,r.E.unit(),!1,E);(0,i.g)(I>=0);for(let t=0;t<I;t++){const i=_.mul(E[t]).add(g);i.x*=f,i.y*=P;const n=Wn(e,Math.atan2(i.y,i.x));if(n>=0&&n<=1){C[b]=n;const t=e.getCoord2D(n);E[b]=s.getClosestCoordinate(t,!1),r.P.distance(t,s.getCoord2D(E[b]))<=h&&b++}}(0,i.g)(b<C.length+4);const N=(0,r.d)(16,Number.NaN);I=e.intersectPoint(s.getStartXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=N[t],E[b]=0;I=e.intersectPoint(s.getEndXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=N[t],E[b]=1;I=s.intersectPoint(e.getStartXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=0,E[b]=N[t];I=s.intersectPoint(e.getEndXY(),N,h);for(let t=0;t<I;t++,b++)C[b]=1,E[b]=N[t];return 0===b?0:qr(t,e,s,C,E,b,n,o,a,h,m,0,l)}function vr(t,e,s,n,o,a,h,m,u,l){if(Jn(e)){const i=new Fr({start:e.getStartXY(),end:e.getEndXY()});return yr(t,s,i,n,a,o,h,m,0,!l)}if(Jn(s)){const i=new Fr({start:s.getStartXY(),end:s.getEndXY()});return yr(t,e,i,n,o,a,h,m,0,l)}const c=G(e,s);h=Math.max(h,c);let g=!1;{const t=e.getSemiAxes(),n=e.getCenter(),l=s.getSemiAxes(),c=s.getCenter(),d=r.P.distance(c,n),_=t.x+l.x;if(d>_+h)return 0;if(t.y>l.x){if(d+l.x+h<t.y)return 0}else if(l.y>t.x&&d+t.x+h<l.y)return 0;if(u&&!m){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),r=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(n&&r&&(g=!0,d<=_)&&Math.max(t.x,l.x)<=Math.min(t.x,l.x)+d)return(0,i.g)(!o&&!a),1}}if(!g&&H(e,s,h))return 0;const d=[],_=[],p=!1,f=!1,x=Mn(e,0,0,p,f,d,_,null),P=[],y=[],v=Mn(s,0,0,p,f,P,y,null);if(1===x&&1===v){const t=new Ut({points:d,weights:_}),i=new Ut({points:P,weights:y}),c=[],g=[],p=on(!1,t,i,n,null===o?null:c,null===a?null:g,h,m,u,l);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let n=0;n<p;++n){if(o)if((0,r.N)(c[n],0,1))o.push(c[n]);else{const s=t.tToLength(c[n]),i=e.lengthToT(s);o.push(i)}if(a)if((0,r.N)(g[n],0,1))a.push(g[n]);else{const t=i.tToLength(g[n]),e=s.lengthToT(t);a.push(e)}}}return p}let C=[];const E=[];let b=0;const D=u&&!m;for(let t=0;t<x;t++){const i=new Ut({points:d.slice(2*t,2*t+3),weights:_.slice(2*t,2*t+3)});let n=0;for(let o=0;o<v;o++){E.length<=o&&E.push(new Ut({points:P.slice(2*o,2*o+3),weights:y.slice(2*o,2*o+3)}));const a=[],m=[],u=D?null:a,l=D?null:m,c=on(!1,i,E[o],null,u,l,h,!1,D,!1);if(c>0&&D)return 1;for(let h=0;h<c;++h){if(0===a[h]&&0===t)a[h]=0;else if(1===a[h]&&t===x-1)a[h]=1;else{const t=i.tToLength(a[h])+b,s=e.lengthToT(t);a[h]=s}if(0===m[h]&&0===o)m[h]=0;else if(1===m[h]&&o===v-1)m[h]=1;else{const t=E[o].tToLength(m[h])+n,e=s.lengthToT(t);m[h]=e}C.push((0,r.k)(a[h],m[h]))}n+=E[o].calculateLength2D()}b+=i.calculateLength2D()}if(0===C.length)return 0;if(m&&(C=C.filter(t=>!(0,r.N)(t.first,0,1)||!(0,r.N)(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second)))),u)return C.length;const S=[],w=[];for(const t of C)S.push(t.first),w.push(t.second);return qr(t,e,s,S,w,S.length,n,o,a,h,m,0,l)}function Cr(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Jn(t))return;const i=t.getSemiAxes(),n=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=r+Math.PI;n[0]=Wn(t,e),n[1]=Wn(t,s),n[2]=Wn(t,r),n[3]=Wn(t,o)}const o=new r.P;for(let i=0;i<4;i++){const r=n[i];e.containsExclusiveCoordinate(r)&&(t.queryCoord2D(r,o),s.mergeNe(o))}}function Er(t,e,s,n,o){if(0===t.m_semiMajorAxis)return s.vmin;let a=r.P.getNAN();t.queryCoord2D(s.vmin,a);let h=r.P.getNAN();if(t.queryCoord2D(s.vmax,h),Jn(t))return new Fr({start:a,end:h}).getClosestCoordinate(e,n);const m=zn(t,e);if(a=zn(t,a),h=zn(t,h),1===t.m_minorMajorRatio){if(m.isEqual(0,0))return s.vmin;const e=Wn(t,Math.atan2(m.y,m.x));return n||s.containsCoordinate(e)?e:r.P.distance(m,a)<=r.P.distance(m,h)?s.vmin:s.vmax}const u=t.getSemiMajorAxis(),l=t.getSemiMinorAxis(),c=(u-l)*(u+l),g=(0,r.a)(c),d=m.x,_=m.y,p=(0,r.a)(l*_),f=l*c*_*2,x=[new r.H(p),new r.H(f),new r.H(g-(0,r.a)(u*d)-p),new r.H(-f),new r.H(-g)],P=(0,r.m)(r.H,4),y=Vt(x,4,new r.E(-1,1),!1,P,4);let v=s.vmin,C=r.P.sqrDistance(m,a);{const t=r.P.sqrDistance(m,h);t<C&&(v=s.vmax,C=t)}(0,i.g)(!n);let E=(0,r.d)(8,Number.NaN);for(let e=0;e<y;++e){const s=P[e].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);E[2*e]=Wn(t,n),E[2*e+1]=Wn(t,r)}E=E.slice(0,2*y),(0,r.v)(E);for(let i=0,n=2*y;i<n;++i)if(E[i]>s.vmin&&E[i]<s.vmax){const s=r.P.sqrDistance(e,t.getCoord2D(E[i]));C>s&&(C=s,v=E[i])}return v}function br(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&t.isMajor()!==e.isMajor()&&!!t.m_center.equals(e.m_center)&&t.m_sinr===e.m_sinr&&t.m_cosr===e.m_cosr&&t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function Dr(t,e,s,n){const o=t.getStartXY(),h=t.getEndXY(),m=o.equals(h),u=e.equals(s);if(!m&&!u){const i=new a.T;return i.initializeFromTwoPoints(o,h,e,s),sr(t,i,!0,e,s),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Kn(t,e,s,1);if(m&&u){const i=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),i)}if(!m){const i=.5*((0,r.a9)()-Math.abs(t.getSweepAngle())),n=(t.getSweepAngle()+i*(0,r.e)(t.getSweepAngle()))/t.getSweepAngle(),o=new r.P;t.queryCoord2D(n,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}const l=r.P.sqrDistance(e,s);let c=.25,g=.75;if(l<r.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=It(new Ln(t,l),r.E.construct(0,.25),1,e);s>0&&((0,i.g)(1===s),c=e[0],g=1-e[0])}const d=t.getCoord2D(c),_=t.getCoord2D(g);(0,i.g)(!d.equals(_)),t.constructEllipticArcEndPointsCenter(d,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),Dr(t,e,s)}function Sr(t,e,s,i,n){return wr(t,!1,e,s,i,n)}function wr(t,e,s,n,r,o){const a=s.getGeometryType(),h=n.getGeometryType(),m=Math.max(r,G(s,n));if(a===i.G.enumLine&&h===i.G.enumLine)return rt(s,n,m,o);let u=s,l=n,c=s.getStartXY(),g=s.getEndXY();if(c.compare(g)>0&&(u=s.clone().reverse()),c=n.getStartXY(),g=n.getEndXY(),c.compare(g)>0&&(l=n.clone().reverse()),e){if(s.equals(n))return 2;if(function(t,e,s){return(0,i.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&T(t,e,0,0,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&T(t,e,1,1,s,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&T(t,e,0,1,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&T(t,e,1,0,s,2,[0,0],[0,0]))}(s,n,m))return 4}switch(a){case i.G.enumLine:switch(h){case i.G.enumEllipticArc:return Pr(t,l,u,m,o);case i.G.enumBezier:return Ks(t,l,u,m,o);case i.G.enumRationalBezier2:return tn(t,l,u,m,o);case i.G.enumBezier2:return ke(t,l,u,m,o);default:(0,i.d)("")}break;case i.G.enumEllipticArc:switch(h){case i.G.enumLine:return Pr(t,u,l,m,o);case i.G.enumEllipticArc:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==vr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumBezier:return Js(t,l,u,m,o);case i.G.enumRationalBezier2:return en(t,l,u,m,o);case i.G.enumBezier2:return We(t,l,u,m,o);default:(0,i.d)("")}break;case i.G.enumBezier:switch(h){case i.G.enumLine:return Ks(t,u,l,m,o);case i.G.enumEllipticArc:return Js(t,u,l,m,o);case i.G.enumBezier:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==ni(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumRationalBezier2:return ti(t,u,l,m,o);case i.G.enumBezier2:return ei(t,u,l,m,o);default:(0,i.d)("")}break;case i.G.enumRationalBezier2:switch(h){case i.G.enumLine:return tn(t,u,l,m,o);case i.G.enumEllipticArc:return en(t,u,l,m,o);case i.G.enumBezier:return ti(t,l,u,m,o);case i.G.enumRationalBezier2:return function(t,e,s,i,n){if(n){const i=Ar(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(D(e,s))return 1;return 0!==on(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,u,l,m,o);case i.G.enumBezier2:return sn(t,u,l,m,o);default:(0,i.d)("")}break;case i.G.enumBezier2:switch(h){case i.G.enumLine:return ke(t,u,l,m,o);case i.G.enumEllipticArc:return We(t,u,l,m,o);case i.G.enumBezier:return ei(t,l,u,m,o);case i.G.enumRationalBezier2:return sn(t,l,u,m,o);case i.G.enumBezier2:return function(t,e,s,i,n){if(n){if(0!==Ar(e,s))return 2}else if(D(e,s))return 1;return 0!==Ue(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}(t,u,l,m,o);default:(0,i.d)("")}break;default:(0,i.d)("")}}function Ar(t,e,s=!0){if(!s&&!Tr(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===i.G.enumEllipticArc)return br(t,e,!1)?s:0;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===i.G.enumEllipticArc)return br(t,e,!0)?s:-1;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function Tr(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function Ir(t,e,s,n,r,o,a){!r&&o&&(0,i.a)("");const h=e.getGeometryType(),m=s.getGeometryType(),u=Math.max(a,G(e,s));if(n&&(n.length=0),r&&(r.length=0),o&&(o.length=0),h===i.G.enumLine&&m===i.G.enumLine)return ot(e,s,n,r,o,u,!1,!1);let l=e,c=s,g=e.getStartXY(),d=e.getEndXY(),_=!1,p=!1;g.compare(d)>0&&(l=e.clone(!0).reverse(),_=!0),g=s.getStartXY(),d=s.getEndXY(),g.compare(d)>0&&(c=s.clone(!0).reverse(),p=!0);let f=0;switch(h){case i.G.enumLine:switch(m){case i.G.enumEllipticArc:f=yr(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier:f=si(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=nn(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=je(t,c,l,n,o,r,u,!1,0,!0);break;default:(0,i.d)("")}break;case i.G.enumEllipticArc:switch(m){case i.G.enumLine:f=yr(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=vr(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier:f=ii(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=rn(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=Ze(t,c,l,n,o,r,u,!1,0,!0);break;default:(0,i.d)("")}break;case i.G.enumRationalBezier2:switch(m){case i.G.enumLine:f=nn(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=rn(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=ri(t,c,l,n,o,r,u,!1,!1,!0);break;case i.G.enumRationalBezier2:f=on(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier2:f=an(t,l,c,n,r,o,u,!1,0,!1);break;default:(0,i.d)("")}break;case i.G.enumBezier2:switch(m){case i.G.enumLine:f=je(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=Ze(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=oi(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumRationalBezier2:f=an(t,c,l,n,o,r,u,!1,0,!0);break;case i.G.enumBezier2:f=Ue(t,l,c,n,r,o,u,!1,!1,!1);break;default:(0,i.d)("")}break;case i.G.enumBezier:switch(m){case i.G.enumLine:f=si(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumEllipticArc:f=ii(t,l,c,n,r,o,u,!1,0,!1);break;case i.G.enumBezier:f=ni(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumRationalBezier2:f=ri(t,l,c,n,r,o,u,!1,!1,!1);break;case i.G.enumBezier2:f=oi(t,l,c,n,r,o,u,!1,0,!1);break;default:(0,i.d)("")}break;default:(0,i.d)("")}if(_){if(r){for(let t=0;t<f;t++)r[t]=1-r[t];r.reverse()}n&&n.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function Nr(t,e,s){return e===s?0:(e>s&&(s=(0,r.c)(e,e=s)),t.cut(e,s,!0).calculateUpperLength2D())}function qr(t,e,s,i,n,o,a,h,m,u,l,c,g){if(!o)return 0;const d=(t,e)=>{for(let s=0;s<o;++s){let i=e[s];if((0,r.N)(i,0,1)){i=(0,r.ak)(i);continue}const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&Nr(t,0,i)<=B(t)&&(e[s]=0):n.equals(t.getEndXY())&&Nr(t,i,1)<=B(t)&&(e[s]=1)}};d(e,i),d(s,n),function(t,e,s,i,n){const o=[],a=[],h=[];for(let m=0,u=n;m<u;m++)o.push(t.calculateSubLengthFromStart(s[m])),a.push(e.calculateSubLengthFromStart(i[m])),(0,r.N)(s[m],0,1)&&(0,r.N)(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&h.push(m);if(0===h.length||h.length===n)return;h.sort((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0);let m=-1;for(const u of h){if(m>=0&&s[u]===s[m]&&s[u]===s[m]){m=u;continue}m=u;const h=[];h.length=n;for(let t=0;t<h.length;++t)h[t]=t;h.sort((t,e)=>{const s=o[u],i=a[u],n=o[t]-s,r=a[t]-i,h=n*n+r*r,m=o[e]-s,l=a[e]-i,c=m*m+l*l;return h<c?-1:h>c?1:0});for(let o=0;o<n;o++){const n=h[o];if(n===u||s[n]===s[u]&&i[n]===i[u]||(0,r.N)(s[n],0,1)&&(0,r.N)(i[n],0,1))continue;const a=(s,i,n,o)=>{const a=new y,h=new r.H;h.setWithEps(1);const m=new r.H;m.set(i,h.eps()),t.queryCoord2DE(m,a);const u=new y;t.queryCoord2DE(new r.H(s),u);let l=!1;return a.eq(u)&&(m.set(o,h.eps()),e.queryCoord2DE(m,a),e.queryCoord2DE(new r.H(n),u),l=a.eq(u)),!l},m=r.P.getNAN();t.queryCoord2D(s[n],m);const l=r.P.getNAN();if(e.queryCoord2D(i[n],l),0===r.P.distance(m,l)&&a(s[u],s[n],i[u],i[n]))break;const c=new r.E(i[n],i[u]);c.normalizeNoNAN();const g=new r.E(s[n],s[u]);g.normalizeNoNAN();let d=-1,_=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,f=s[n];m.assign(t.getCoord2D(f));for(let o=0;o<5;o++){const o=e.getClosestCoordinateOnInterval(m,c,-1);l.assign(e.getCoord2D(o));const h=r.P.distance(m,l);if(f=t.getClosestCoordinateOnInterval(l,g,-1),f===s[u]&&o===i[u]){d=1;break}m.assign(t.getCoord2D(f));const x=r.P.distance(l,m);if(!(x<p&&h<_)){d=0;break}if(0===x&&0===h){a(s[u],s[n],i[u],i[n])?(s[n]=f,i[n]=o,d=0):d=1;break}p=x,_=h}if(-1===d&&(d=(0,r.N)(s[n],0,1)||(0,r.N)(i[n],0,1)?0:1),1!==d)break;s[n]=s[u],i[n]=i[u]}}}(e,s,i,n,o);const _=[];for(let t=0,e=o;t<e;t++)_.push(t);const p=(t,e)=>g?(0,r.al)(n[t],i[t],n[e],i[e]):(0,r.al)(i[t],n[t],i[e],n[e]);if(_.length>1){_.sort(p);const t=Math.max(B(e),B(s));let o=0;for(let a=1,h=_.length;a<h;a++){const h=i[_[o]],m=i[_[a]],u=n[_[o]],l=n[_[a]];if(h!==m||u!==l){if(Nr(e,h,m)<=t&&Nr(s,u,l)<=t&&!((0,r.N)(h,0,1)&&(0,r.N)(u,0,1)||(0,r.N)(m,0,1)&&(0,r.N)(l,0,1))){const t=r.P.distance(e.getCoord2D(h),s.getCoord2D(u)),i=r.P.distance(e.getCoord2D(m),s.getCoord2D(l));if(t<=i)continue;if(i<t){_[o]=_[a];continue}continue}o++,_[o]=_[a]}}if(_.length=o+1,1===_.length&&0!==_[0]&&(i[0]=i[_[0]],n[0]=n[_[0]],_[0]=0),_.length>2){const t=r.E.constructEmpty(),o=r.E.constructEmpty();t.setCoords(i[_[0]],i[_.at(-1)]),o.setCoords(n[_[0]],n[_.at(-1)]);let a=!0;for(let e=1,s=_.length-1;e<s;e++)if(!t.containsCoordinate(i[_[e]])||!o.containsCoordinate(n[_[e]])){a=!1;break}if(a){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let h=(0,r.q)(t.vmin,t.vmax,i[n]);const m=e.getCoord2D(h);if(!s.isCloserThanDistance(m,o,u)){a=!1;break}h=(0,r.q)(o.vmin,o.vmax,i[n]);const l=s.getCoord2D(h);if(!e.isCloserThanDistance(l,t,u)){a=!1;break}}}a&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t){const t=0,r=0;T(e,s,i[0],n[0],u,1,[t],[r])&&(_.push(1),i[1]=t,n[1]=r,_.sort(p))}if(l&&1===_.length){let t=!0;for(let o=0,a=_.length;o<a;o++)if(!(0,r.N)(i[_[o]],0,1)||!(0,r.N)(n[_[o]],0,1)||0!==r.P.distance(e.getCoord2D(i[_[o]]),s.getCoord2D(n[_[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,s=_.length;t<s;t++){if(h&&h.push(i[_[t]]),m&&m.push(n[_[t]]),a){const s=r.P.getNAN();e.queryCoord2D(i[_[t]],s),a.push(s)}f++}return f}function Mr(t,e,s,i,n,o,a,h,m){if((0,r.N)(s,0,1)&&(0,r.N)(i,0,1)&&0===r.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const u=1e-12,l=new y,c=Number.EPSILON;if(t.queryDerivative(new r.H(s,c),l),l.isTrueZero()){const e=1===s?-u:u;t.queryDerivative(new r.H(s,c).add(e),l)}1===s&&l.negateThis();const g=new y;if(e.queryDerivative(new r.H(i,c),g),g.isTrueZero()){const t=1===s?-u:u;e.queryDerivative(new r.H(i,c).add(t),g)}1===i&&g.negateThis(),l.isZero()||l.normalize(),g.isZero()||g.normalize();const d=l.dotProduct(g),_=l.crossProduct(g);_.scaleError(3);const p=()=>{if(m)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(r.J)&&(_.isZero()||Math.abs(_.value())<p()))return A(t,e,s,i,n,o,a,h)}return 0}function Yr(t,e,s,n,o){let a=-1,h=-1,m=-1,u=-1;{const i=[0,e],r=[e,0],o=[0,n],l=[n,0];for(let e=0;e<2&&-1===a;++e)for(let n=0;n<2;++n)if(t[i[e]].equals(s[o[n]])){a=i[e],h=r[e],m=o[n],u=l[n];break}}if(-1===a){const i=new p;i.setFromPoints(t,e+1);const r=new p;return r.setFromPoints(s,n+1),r.inflate(o),i.isIntersectingW(r)?-1:0}{const l=(0,r.d)(e+1,Number.NaN),c=gs(t,e+1,l);(0,i.g)(c>1);let g=0,d=0;for(let t=0;t<c;++t)a===l[t]&&(d=t,g++),h===l[t]&&g++;if(2!==g)return-1;const _=(0,r.d)(n+1,Number.NaN),p=gs(s,n+1,_);(0,i.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===_[t]&&(f=t,g++),u===_[t]&&g++;if(2!==g)return-1;const x=t[l[(d+c-1)%c]],P=t[l[(d+1)%c]],y=s[_[(f+p-1)%p]],v=s[_[(f+1)%p]],C=t[a],E=[x,P,y,v],b=[0,1,2,3];b.sort((t,e)=>r.P.compareVectorsOrigin(C,E[t],E[e]));let D=b[0];for(let t=1;t<4;t++){if(b[t]!==(D+1)%4)return-1;D=b[t]}{const t=x.sub(C),e=v.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}return 1}}var Xr=n.V;class Fr extends ${constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,i.g)(0),0}calculateUpperLength3D(){return(0,i.g)(0),0}changeEndPoints3D(t,e){(0,i.g)(0)}getClosestCoordinate3D(t,e,s){return(0,i.g)(0),0}getBoundary(){return At(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?tt(this,t):et(this,t);const i=Xr.getInterpolation(e),n=this.getStartAttributeAsDbl(e,s),o=this.getEndAttributeAsDbl(e,s);return(0,r.V)(i,n,o,t,Xr.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,i.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Fr.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Xr.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,L(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,L(this,1,1,0))):(0,i.t)("env type not impl")}applyTransformation(t){(0,i.g)(t instanceof a.T);const e=new r.P;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new Fr({vd:this.m_description})}calculateLength2D(){return Math.sqrt(lt(this))}calculateLength3D(t){return(0,i.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return(0,i.g)(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return K(this,t,e)}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return function(t,e){const s=t.getStartZ(),i=t.getEndZ();return(0,r.q)(s,i,e)}(this,t)}queryCoord2DE(t,e){st(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=C.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(r.M.constructDouble(t)),e.addThis(s)}getCoordX(t){return tt(this,t)}getCoordY(t){return et(this,t)}cut(t,e,s){const i=new Rr;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const o=r.P.getNAN();if(K(this,t,o),n.setStartXYCoords(o.x,o.y),K(this,e,o),n.setEndXYCoords(o.x,o.y),!i)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),r=Xr.getComponentCount(i);for(let s=0;s<r;s++){const r=this.getAttributeAsDbl(t,i,s);n.setStartAttribute(i,s,r);const o=this.getAttributeAsDbl(e,i,s);n.setEndAttribute(i,s,o)}}}queryDerivative(t,e){!function(t,e,s){const i=y.constructPoint2D(t.getStartXY()),n=y.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}(this,0,e)}getClosestCoordinate(t,e){return r.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new r.P;this.queryCoord2D(e.vmin,i);const n=new r.P;this.queryCoord2D(e.vmax,n);const o=r.P.getClosestCoordinate(i,n,t,!1);return j.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=tt(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new Fr;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new r.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=r.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new r.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return at(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,i.a)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=tt(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=et(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=(0,r.s)(t.vmin,0,1);const i=new r.P;return this.queryCoord2D(s,i),e.setCoords({pt:i}),s=(0,r.s)(t.vmax,0,1),this.queryCoord2D(s,i),void e.mergeNe(i)}(0,i.t)("3d dst not impl")}orientBottomUp(){nt(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return function(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoordsForStitcher(t,e){it(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,i.g)(0),0}readFromBufferStream(t,e){(0,i.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){it(this,t,e)}static isIntersectingLineLine(t,e,s,i){return rt(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return rt(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return Ir(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&(0,i.r)("");const n=at(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Sr(!1,this,t,e,s)}}Fr.type=i.G.enumLine;class Rr{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new Fr,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,i.d)("bad constructor params"))}assignCopy(t){return t instanceof Rr?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Rr){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,i.d)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,i.g)(0)}createImpl(t){switch(t){case i.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Fr,this.m_mask|=1,this.m_active=1);break;case i.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new In,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.G.enumBezier:4&this.m_mask||(this.m_curves=new Ci,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.G.enumBezier2:8&this.m_mask||(this.m_curves=new Qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Ut,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,i.a)("")}}create(t){t===i.G.enumLine?this.createLine():t===i.G.enumEllipticArc?this.createEllipticArc():t===i.G.enumBezier?this.createCubicBezier():t===i.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.G.enumBezier2?this.createQuadraticBezier():(0,i.a)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,i.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(i.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,i.d)("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,i.d)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Rr?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,i.t)("seg comparison not yet impl"),!1)}}}}]);